aboutsummaryrefslogtreecommitdiff
path: root/src/burn/engine/registration.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-04-04 14:14:08 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-04-05 13:52:11 -0500
commit5ac804d68360fc8a2f66ec020e1fe2536792f179 (patch)
tree22f87b5a09147e197fb6a33d34da37b66753f458 /src/burn/engine/registration.cpp
parentc0822d3142abcd17589861566d0724f5f0a6d0a0 (diff)
downloadwix-5ac804d68360fc8a2f66ec020e1fe2536792f179.tar.gz
wix-5ac804d68360fc8a2f66ec020e1fe2536792f179.tar.bz2
wix-5ac804d68360fc8a2f66ec020e1fe2536792f179.zip
Update registration code with more concise Exit* macros.
Diffstat (limited to 'src/burn/engine/registration.cpp')
-rw-r--r--src/burn/engine/registration.cpp133
1 files changed, 42 insertions, 91 deletions
diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp
index f2b8383d..7b6aa6bb 100644
--- a/src/burn/engine/registration.cpp
+++ b/src/burn/engine/registration.cpp
@@ -122,29 +122,26 @@ extern "C" HRESULT RegistrationParseFromXml(
122 IXMLDOMNode* pixnArpNode = NULL; 122 IXMLDOMNode* pixnArpNode = NULL;
123 IXMLDOMNode* pixnUpdateNode = NULL; 123 IXMLDOMNode* pixnUpdateNode = NULL;
124 LPWSTR scz = NULL; 124 LPWSTR scz = NULL;
125 BOOL fFoundXml = FALSE;
125 126
126 // select registration node 127 // select registration node
127 hr = XmlSelectSingleNode(pixnBundle, L"Registration", &pixnRegistrationNode); 128 hr = XmlSelectSingleNode(pixnBundle, L"Registration", &pixnRegistrationNode);
128 if (S_FALSE == hr) 129 ExitOnRequiredXmlQueryFailure(hr, "Failed to select registration node.");
129 {
130 hr = E_NOTFOUND;
131 }
132 ExitOnFailure(hr, "Failed to select registration node.");
133 130
134 // @Id 131 // @Id
135 hr = XmlGetAttributeEx(pixnRegistrationNode, L"Id", &pRegistration->sczId); 132 hr = XmlGetAttributeEx(pixnRegistrationNode, L"Id", &pRegistration->sczId);
136 ExitOnFailure(hr, "Failed to get @Id."); 133 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Id.");
137 134
138 // @Tag 135 // @Tag
139 hr = XmlGetAttributeEx(pixnRegistrationNode, L"Tag", &pRegistration->sczTag); 136 hr = XmlGetAttributeEx(pixnRegistrationNode, L"Tag", &pRegistration->sczTag);
140 ExitOnFailure(hr, "Failed to get @Tag."); 137 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Tag.");
141 138
142 hr = BundlePackageEngineParseRelatedCodes(pixnBundle, &pRegistration->rgsczDetectCodes, &pRegistration->cDetectCodes, &pRegistration->rgsczUpgradeCodes, &pRegistration->cUpgradeCodes, &pRegistration->rgsczAddonCodes, &pRegistration->cAddonCodes, &pRegistration->rgsczPatchCodes, &pRegistration->cPatchCodes); 139 hr = BundlePackageEngineParseRelatedCodes(pixnBundle, &pRegistration->rgsczDetectCodes, &pRegistration->cDetectCodes, &pRegistration->rgsczUpgradeCodes, &pRegistration->cUpgradeCodes, &pRegistration->rgsczAddonCodes, &pRegistration->cAddonCodes, &pRegistration->rgsczPatchCodes, &pRegistration->cPatchCodes);
143 ExitOnFailure(hr, "Failed to parse related bundles"); 140 ExitOnFailure(hr, "Failed to parse related bundles");
144 141
145 // @Version 142 // @Version
146 hr = XmlGetAttributeEx(pixnRegistrationNode, L"Version", &scz); 143 hr = XmlGetAttributeEx(pixnRegistrationNode, L"Version", &scz);
147 ExitOnFailure(hr, "Failed to get @Version."); 144 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Version.");
148 145
149 hr = VerParseVersion(scz, 0, FALSE, &pRegistration->pVersion); 146 hr = VerParseVersion(scz, 0, FALSE, &pRegistration->pVersion);
150 ExitOnFailure(hr, "Failed to parse @Version: %ls", scz); 147 ExitOnFailure(hr, "Failed to parse @Version: %ls", scz);
@@ -156,106 +153,75 @@ extern "C" HRESULT RegistrationParseFromXml(
156 153
157 // @ProviderKey 154 // @ProviderKey
158 hr = XmlGetAttributeEx(pixnRegistrationNode, L"ProviderKey", &pRegistration->sczProviderKey); 155 hr = XmlGetAttributeEx(pixnRegistrationNode, L"ProviderKey", &pRegistration->sczProviderKey);
159 ExitOnFailure(hr, "Failed to get @ProviderKey."); 156 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @ProviderKey.");
160 157
161 // @ExecutableName 158 // @ExecutableName
162 hr = XmlGetAttributeEx(pixnRegistrationNode, L"ExecutableName", &pRegistration->sczExecutableName); 159 hr = XmlGetAttributeEx(pixnRegistrationNode, L"ExecutableName", &pRegistration->sczExecutableName);
163 ExitOnFailure(hr, "Failed to get @ExecutableName."); 160 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @ExecutableName.");
164 161
165 // @PerMachine 162 // @PerMachine
166 hr = XmlGetYesNoAttribute(pixnRegistrationNode, L"PerMachine", &pRegistration->fPerMachine); 163 hr = XmlGetYesNoAttribute(pixnRegistrationNode, L"PerMachine", &pRegistration->fPerMachine);
167 ExitOnFailure(hr, "Failed to get @PerMachine."); 164 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @PerMachine.");
168 165
169 // select ARP node 166 // select ARP node
170 hr = XmlSelectSingleNode(pixnRegistrationNode, L"Arp", &pixnArpNode); 167 hr = XmlSelectSingleNode(pixnRegistrationNode, L"Arp", &pixnArpNode);
171 if (S_FALSE != hr) 168 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to select ARP node.");
172 {
173 ExitOnFailure(hr, "Failed to select ARP node.");
174 169
170 if (fFoundXml)
171 {
175 // @Register 172 // @Register
176 hr = XmlGetYesNoAttribute(pixnArpNode, L"Register", &pRegistration->fRegisterArp); 173 hr = XmlGetYesNoAttribute(pixnArpNode, L"Register", &pRegistration->fRegisterArp);
177 ExitOnFailure(hr, "Failed to get @Register."); 174 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Register.");
178 175
179 // @DisplayName 176 // @DisplayName
180 hr = XmlGetAttributeEx(pixnArpNode, L"DisplayName", &pRegistration->sczDisplayName); 177 hr = XmlGetAttributeEx(pixnArpNode, L"DisplayName", &pRegistration->sczDisplayName);
181 if (E_NOTFOUND != hr) 178 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @DisplayName.");
182 {
183 ExitOnFailure(hr, "Failed to get @DisplayName.");
184 }
185 179
186 // @InProgressDisplayName 180 // @InProgressDisplayName
187 hr = XmlGetAttributeEx(pixnArpNode, L"InProgressDisplayName", &pRegistration->sczInProgressDisplayName); 181 hr = XmlGetAttributeEx(pixnArpNode, L"InProgressDisplayName", &pRegistration->sczInProgressDisplayName);
188 if (E_NOTFOUND != hr) 182 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @InProgressDisplayName.");
189 {
190 ExitOnFailure(hr, "Failed to get @InProgressDisplayName.");
191 }
192 183
193 // @DisplayVersion 184 // @DisplayVersion
194 hr = XmlGetAttributeEx(pixnArpNode, L"DisplayVersion", &pRegistration->sczDisplayVersion); 185 hr = XmlGetAttributeEx(pixnArpNode, L"DisplayVersion", &pRegistration->sczDisplayVersion);
195 if (E_NOTFOUND != hr) 186 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @DisplayVersion.");
196 {
197 ExitOnFailure(hr, "Failed to get @DisplayVersion.");
198 }
199 187
200 // @Publisher 188 // @Publisher
201 hr = XmlGetAttributeEx(pixnArpNode, L"Publisher", &pRegistration->sczPublisher); 189 hr = XmlGetAttributeEx(pixnArpNode, L"Publisher", &pRegistration->sczPublisher);
202 if (E_NOTFOUND != hr) 190 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @Publisher.");
203 {
204 ExitOnFailure(hr, "Failed to get @Publisher.");
205 }
206 191
207 // @HelpLink 192 // @HelpLink
208 hr = XmlGetAttributeEx(pixnArpNode, L"HelpLink", &pRegistration->sczHelpLink); 193 hr = XmlGetAttributeEx(pixnArpNode, L"HelpLink", &pRegistration->sczHelpLink);
209 if (E_NOTFOUND != hr) 194 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @HelpLink.");
210 {
211 ExitOnFailure(hr, "Failed to get @HelpLink.");
212 }
213 195
214 // @HelpTelephone 196 // @HelpTelephone
215 hr = XmlGetAttributeEx(pixnArpNode, L"HelpTelephone", &pRegistration->sczHelpTelephone); 197 hr = XmlGetAttributeEx(pixnArpNode, L"HelpTelephone", &pRegistration->sczHelpTelephone);
216 if (E_NOTFOUND != hr) 198 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @HelpTelephone.");
217 {
218 ExitOnFailure(hr, "Failed to get @HelpTelephone.");
219 }
220 199
221 // @AboutUrl 200 // @AboutUrl
222 hr = XmlGetAttributeEx(pixnArpNode, L"AboutUrl", &pRegistration->sczAboutUrl); 201 hr = XmlGetAttributeEx(pixnArpNode, L"AboutUrl", &pRegistration->sczAboutUrl);
223 if (E_NOTFOUND != hr) 202 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @AboutUrl.");
224 {
225 ExitOnFailure(hr, "Failed to get @AboutUrl.");
226 }
227 203
228 // @UpdateUrl 204 // @UpdateUrl
229 hr = XmlGetAttributeEx(pixnArpNode, L"UpdateUrl", &pRegistration->sczUpdateUrl); 205 hr = XmlGetAttributeEx(pixnArpNode, L"UpdateUrl", &pRegistration->sczUpdateUrl);
230 if (E_NOTFOUND != hr) 206 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @UpdateUrl.");
231 {
232 ExitOnFailure(hr, "Failed to get @UpdateUrl.");
233 }
234 207
235 // @ParentDisplayName 208 // @ParentDisplayName
236 hr = XmlGetAttributeEx(pixnArpNode, L"ParentDisplayName", &pRegistration->sczParentDisplayName); 209 hr = XmlGetAttributeEx(pixnArpNode, L"ParentDisplayName", &pRegistration->sczParentDisplayName);
237 if (E_NOTFOUND != hr) 210 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @ParentDisplayName.");
238 {
239 ExitOnFailure(hr, "Failed to get @ParentDisplayName.");
240 }
241 211
242 // @Comments 212 // @Comments
243 hr = XmlGetAttributeEx(pixnArpNode, L"Comments", &pRegistration->sczComments); 213 hr = XmlGetAttributeEx(pixnArpNode, L"Comments", &pRegistration->sczComments);
244 if (E_NOTFOUND != hr) 214 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @Comments.");
245 {
246 ExitOnFailure(hr, "Failed to get @Comments.");
247 }
248 215
249 // @Contact 216 // @Contact
250 hr = XmlGetAttributeEx(pixnArpNode, L"Contact", &pRegistration->sczContact); 217 hr = XmlGetAttributeEx(pixnArpNode, L"Contact", &pRegistration->sczContact);
251 if (E_NOTFOUND != hr) 218 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @Contact.");
252 {
253 ExitOnFailure(hr, "Failed to get @Contact.");
254 }
255 219
256 // @DisableModify 220 // @DisableModify
257 hr = XmlGetAttributeEx(pixnArpNode, L"DisableModify", &scz); 221 hr = XmlGetAttributeEx(pixnArpNode, L"DisableModify", &scz);
258 if (SUCCEEDED(hr)) 222 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @DisableModify.");
223
224 if (fFoundXml)
259 { 225 {
260 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"button", -1)) 226 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"button", -1))
261 { 227 {
@@ -271,24 +237,17 @@ extern "C" HRESULT RegistrationParseFromXml(
271 } 237 }
272 else 238 else
273 { 239 {
274 hr = E_UNEXPECTED; 240 ExitWithRootFailure(hr, E_UNEXPECTED, "Invalid modify disabled type: %ls", scz);
275 ExitOnRootFailure(hr, "Invalid modify disabled type: %ls", scz);
276 } 241 }
277 } 242 }
278 else if (E_NOTFOUND == hr) 243 else
279 { 244 {
280 pRegistration->modify = BURN_REGISTRATION_MODIFY_ENABLED; 245 pRegistration->modify = BURN_REGISTRATION_MODIFY_ENABLED;
281 hr = S_OK;
282 } 246 }
283 ExitOnFailure(hr, "Failed to get @DisableModify.");
284 247
285 // @DisableRemove 248 // @DisableRemove
286 hr = XmlGetYesNoAttribute(pixnArpNode, L"DisableRemove", &pRegistration->fNoRemove); 249 hr = XmlGetYesNoAttribute(pixnArpNode, L"DisableRemove", &pRegistration->fNoRemove);
287 if (E_NOTFOUND != hr) 250 ExitOnOptionalXmlQueryFailure(hr, pRegistration->fNoRemoveDefined, "Failed to get @DisableRemove.");
288 {
289 ExitOnFailure(hr, "Failed to get @DisableRemove.");
290 pRegistration->fNoRemoveDefined = TRUE;
291 }
292 } 251 }
293 252
294 hr = ParseSoftwareTagsFromXml(pixnRegistrationNode, &pRegistration->softwareTags.rgSoftwareTags, &pRegistration->softwareTags.cSoftwareTags); 253 hr = ParseSoftwareTagsFromXml(pixnRegistrationNode, &pRegistration->softwareTags.rgSoftwareTags, &pRegistration->softwareTags.cSoftwareTags);
@@ -296,37 +255,29 @@ extern "C" HRESULT RegistrationParseFromXml(
296 255
297 // select Update node 256 // select Update node
298 hr = XmlSelectSingleNode(pixnRegistrationNode, L"Update", &pixnUpdateNode); 257 hr = XmlSelectSingleNode(pixnRegistrationNode, L"Update", &pixnUpdateNode);
299 if (S_FALSE != hr) 258 ExitOnOptionalXmlQueryFailure(hr, pRegistration->update.fRegisterUpdate, "Failed to select Update node.");
300 {
301 ExitOnFailure(hr, "Failed to select Update node.");
302
303 pRegistration->update.fRegisterUpdate = TRUE;
304 259
260 if (pRegistration->update.fRegisterUpdate)
261 {
305 // @Manufacturer 262 // @Manufacturer
306 hr = XmlGetAttributeEx(pixnUpdateNode, L"Manufacturer", &pRegistration->update.sczManufacturer); 263 hr = XmlGetAttributeEx(pixnUpdateNode, L"Manufacturer", &pRegistration->update.sczManufacturer);
307 ExitOnFailure(hr, "Failed to get @Manufacturer."); 264 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Manufacturer.");
308 265
309 // @Department 266 // @Department
310 hr = XmlGetAttributeEx(pixnUpdateNode, L"Department", &pRegistration->update.sczDepartment); 267 hr = XmlGetAttributeEx(pixnUpdateNode, L"Department", &pRegistration->update.sczDepartment);
311 if (E_NOTFOUND != hr) 268 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @Department.");
312 {
313 ExitOnFailure(hr, "Failed to get @Department.");
314 }
315 269
316 // @ProductFamily 270 // @ProductFamily
317 hr = XmlGetAttributeEx(pixnUpdateNode, L"ProductFamily", &pRegistration->update.sczProductFamily); 271 hr = XmlGetAttributeEx(pixnUpdateNode, L"ProductFamily", &pRegistration->update.sczProductFamily);
318 if (E_NOTFOUND != hr) 272 ExitOnOptionalXmlQueryFailure(hr, fFoundXml, "Failed to get @ProductFamily.");
319 {
320 ExitOnFailure(hr, "Failed to get @ProductFamily.");
321 }
322 273
323 // @Name 274 // @Name
324 hr = XmlGetAttributeEx(pixnUpdateNode, L"Name", &pRegistration->update.sczName); 275 hr = XmlGetAttributeEx(pixnUpdateNode, L"Name", &pRegistration->update.sczName);
325 ExitOnFailure(hr, "Failed to get @Name."); 276 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Name.");
326 277
327 // @Classification 278 // @Classification
328 hr = XmlGetAttributeEx(pixnUpdateNode, L"Classification", &pRegistration->update.sczClassification); 279 hr = XmlGetAttributeEx(pixnUpdateNode, L"Classification", &pRegistration->update.sczClassification);
329 ExitOnFailure(hr, "Failed to get @Classification."); 280 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Classification.");
330 } 281 }
331 282
332 hr = SetPaths(pRegistration, pCache); 283 hr = SetPaths(pRegistration, pCache);
@@ -1164,19 +1115,19 @@ static HRESULT ParseSoftwareTagsFromXml(
1164 BURN_SOFTWARE_TAG* pSoftwareTag = &pSoftwareTags[i]; 1115 BURN_SOFTWARE_TAG* pSoftwareTag = &pSoftwareTags[i];
1165 1116
1166 hr = XmlNextElement(pixnNodes, &pixnNode, NULL); 1117 hr = XmlNextElement(pixnNodes, &pixnNode, NULL);
1167 ExitOnFailure(hr, "Failed to get next node."); 1118 ExitOnRequiredXmlQueryFailure(hr, "Failed to get next node.");
1168 1119
1169 hr = XmlGetAttributeEx(pixnNode, L"Filename", &pSoftwareTag->sczFilename); 1120 hr = XmlGetAttributeEx(pixnNode, L"Filename", &pSoftwareTag->sczFilename);
1170 ExitOnFailure(hr, "Failed to get @Filename."); 1121 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Filename.");
1171 1122
1172 hr = XmlGetAttributeEx(pixnNode, L"Regid", &pSoftwareTag->sczRegid); 1123 hr = XmlGetAttributeEx(pixnNode, L"Regid", &pSoftwareTag->sczRegid);
1173 ExitOnFailure(hr, "Failed to get @Regid."); 1124 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Regid.");
1174 1125
1175 hr = XmlGetAttributeEx(pixnNode, L"Path", &pSoftwareTag->sczPath); 1126 hr = XmlGetAttributeEx(pixnNode, L"Path", &pSoftwareTag->sczPath);
1176 ExitOnFailure(hr, "Failed to get @Path."); 1127 ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Path.");
1177 1128
1178 hr = XmlGetText(pixnNode, &bstrTagXml); 1129 hr = XmlGetText(pixnNode, &bstrTagXml);
1179 ExitOnFailure(hr, "Failed to get SoftwareTag text."); 1130 ExitOnRequiredXmlQueryFailure(hr, "Failed to get SoftwareTag text.");
1180 1131
1181 hr = StrAnsiAllocString(&pSoftwareTag->sczTag, bstrTagXml, 0, CP_UTF8); 1132 hr = StrAnsiAllocString(&pSoftwareTag->sczTag, bstrTagXml, 0, CP_UTF8);
1182 ExitOnFailure(hr, "Failed to convert SoftwareTag text to UTF-8"); 1133 ExitOnFailure(hr, "Failed to convert SoftwareTag text to UTF-8");