aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/atomutil.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-03-02 14:19:14 -0600
committerSean Hall <r.sean.hall@gmail.com>2021-03-02 15:40:02 -0600
commit10ebf674da5df9224e4eddd3545518434c5b455b (patch)
treeea1f4063edd46e9942eab94dd7adb2f75c6c589e /src/dutil/atomutil.cpp
parent3bbf1347b900ec115a12faf8f46965c9b7649696 (diff)
downloadwix-10ebf674da5df9224e4eddd3545518434c5b455b.tar.gz
wix-10ebf674da5df9224e4eddd3545518434c5b455b.tar.bz2
wix-10ebf674da5df9224e4eddd3545518434c5b455b.zip
Update rest of dutil to use their own source with the Exit* macros.
Fix some CA warnings.
Diffstat (limited to 'src/dutil/atomutil.cpp')
-rw-r--r--src/dutil/atomutil.cpp233
1 files changed, 123 insertions, 110 deletions
diff --git a/src/dutil/atomutil.cpp b/src/dutil/atomutil.cpp
index 4a12fb80..c7c7975a 100644
--- a/src/dutil/atomutil.cpp
+++ b/src/dutil/atomutil.cpp
@@ -2,6 +2,19 @@
2 2
3#include "precomp.h" 3#include "precomp.h"
4 4
5// Exit macros
6#define AtomExitOnLastError(x, s, ...) ExitOnLastErrorSource(DUTIL_SOURCE_ATOMUTIL, x, s, __VA_ARGS__)
7#define AtomExitOnLastErrorDebugTrace(x, s, ...) ExitOnLastErrorDebugTraceSource(DUTIL_SOURCE_ATOMUTIL, x, s, __VA_ARGS__)
8#define AtomExitWithLastError(x, s, ...) ExitWithLastErrorSource(DUTIL_SOURCE_ATOMUTIL, x, s, __VA_ARGS__)
9#define AtomExitOnFailure(x, s, ...) ExitOnFailureSource(DUTIL_SOURCE_ATOMUTIL, x, s, __VA_ARGS__)
10#define AtomExitOnRootFailure(x, s, ...) ExitOnRootFailureSource(DUTIL_SOURCE_ATOMUTIL, x, s, __VA_ARGS__)
11#define AtomExitOnFailureDebugTrace(x, s, ...) ExitOnFailureDebugTraceSource(DUTIL_SOURCE_ATOMUTIL, x, s, __VA_ARGS__)
12#define AtomExitOnNull(p, x, e, s, ...) ExitOnNullSource(DUTIL_SOURCE_ATOMUTIL, p, x, e, s, __VA_ARGS__)
13#define AtomExitOnNullWithLastError(p, x, s, ...) ExitOnNullWithLastErrorSource(DUTIL_SOURCE_ATOMUTIL, p, x, s, __VA_ARGS__)
14#define AtomExitOnNullDebugTrace(p, x, e, s, ...) ExitOnNullDebugTraceSource(DUTIL_SOURCE_ATOMUTIL, p, x, e, s, __VA_ARGS__)
15#define AtomExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_ATOMUTIL, p, x, s, __VA_ARGS__)
16#define AtomExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_ATOMUTIL, e, x, s, __VA_ARGS__)
17#define AtomExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_ATOMUTIL, g, x, s, __VA_ARGS__)
5 18
6static HRESULT ParseAtomDocument( 19static HRESULT ParseAtomDocument(
7 __in IXMLDOMDocument *pixd, 20 __in IXMLDOMDocument *pixd,
@@ -98,7 +111,7 @@ extern "C" void DAPI AtomUninitialize()
98 111
99*********************************************************************/ 112*********************************************************************/
100extern "C" HRESULT DAPI AtomParseFromString( 113extern "C" HRESULT DAPI AtomParseFromString(
101 __in LPCWSTR wzAtomString, 114 __in_z LPCWSTR wzAtomString,
102 __out ATOM_FEED **ppFeed 115 __out ATOM_FEED **ppFeed
103 ) 116 )
104{ 117{
@@ -110,10 +123,10 @@ extern "C" HRESULT DAPI AtomParseFromString(
110 IXMLDOMDocument *pixdAtom = NULL; 123 IXMLDOMDocument *pixdAtom = NULL;
111 124
112 hr = XmlLoadDocument(wzAtomString, &pixdAtom); 125 hr = XmlLoadDocument(wzAtomString, &pixdAtom);
113 ExitOnFailure(hr, "Failed to load ATOM string as XML document."); 126 AtomExitOnFailure(hr, "Failed to load ATOM string as XML document.");
114 127
115 hr = ParseAtomDocument(pixdAtom, &pNewFeed); 128 hr = ParseAtomDocument(pixdAtom, &pNewFeed);
116 ExitOnFailure(hr, "Failed to parse ATOM document."); 129 AtomExitOnFailure(hr, "Failed to parse ATOM document.");
117 130
118 *ppFeed = pNewFeed; 131 *ppFeed = pNewFeed;
119 pNewFeed = NULL; 132 pNewFeed = NULL;
@@ -131,7 +144,7 @@ LExit:
131 144
132*********************************************************************/ 145*********************************************************************/
133extern "C" HRESULT DAPI AtomParseFromFile( 146extern "C" HRESULT DAPI AtomParseFromFile(
134 __in LPCWSTR wzAtomFile, 147 __in_z LPCWSTR wzAtomFile,
135 __out ATOM_FEED **ppFeed 148 __out ATOM_FEED **ppFeed
136 ) 149 )
137{ 150{
@@ -143,10 +156,10 @@ extern "C" HRESULT DAPI AtomParseFromFile(
143 IXMLDOMDocument *pixdAtom = NULL; 156 IXMLDOMDocument *pixdAtom = NULL;
144 157
145 hr = XmlLoadDocumentFromFile(wzAtomFile, &pixdAtom); 158 hr = XmlLoadDocumentFromFile(wzAtomFile, &pixdAtom);
146 ExitOnFailure(hr, "Failed to load ATOM string as XML document."); 159 AtomExitOnFailure(hr, "Failed to load ATOM string as XML document.");
147 160
148 hr = ParseAtomDocument(pixdAtom, &pNewFeed); 161 hr = ParseAtomDocument(pixdAtom, &pNewFeed);
149 ExitOnFailure(hr, "Failed to parse ATOM document."); 162 AtomExitOnFailure(hr, "Failed to parse ATOM document.");
150 163
151 *ppFeed = pNewFeed; 164 *ppFeed = pNewFeed;
152 pNewFeed = NULL; 165 pNewFeed = NULL;
@@ -175,7 +188,7 @@ extern "C" HRESULT DAPI AtomParseFromDocument(
175 ATOM_FEED *pNewFeed = NULL; 188 ATOM_FEED *pNewFeed = NULL;
176 189
177 hr = ParseAtomDocument(pixdDocument, &pNewFeed); 190 hr = ParseAtomDocument(pixdDocument, &pNewFeed);
178 ExitOnFailure(hr, "Failed to parse ATOM document."); 191 AtomExitOnFailure(hr, "Failed to parse ATOM document.");
179 192
180 *ppFeed = pNewFeed; 193 *ppFeed = pNewFeed;
181 pNewFeed = NULL; 194 pNewFeed = NULL;
@@ -192,7 +205,7 @@ LExit:
192 205
193*********************************************************************/ 206*********************************************************************/
194extern "C" void DAPI AtomFreeFeed( 207extern "C" void DAPI AtomFreeFeed(
195 __in_xcount(pFeed->cItems) ATOM_FEED *pFeed 208 __in_xcount(pFeed->cItems) ATOM_FEED* pFeed
196 ) 209 )
197{ 210{
198 if (pFeed) 211 if (pFeed)
@@ -257,10 +270,10 @@ static HRESULT ParseAtomDocument(
257 // Get the document element and start processing feeds. 270 // Get the document element and start processing feeds.
258 // 271 //
259 hr = pixd->get_documentElement(&pFeedElement); 272 hr = pixd->get_documentElement(&pFeedElement);
260 ExitOnFailure(hr, "failed get_documentElement in ParseAtomDocument"); 273 AtomExitOnFailure(hr, "failed get_documentElement in ParseAtomDocument");
261 274
262 hr = ParseAtomFeed(pFeedElement, &pNewFeed); 275 hr = ParseAtomFeed(pFeedElement, &pNewFeed);
263 ExitOnFailure(hr, "Failed to parse ATOM feed."); 276 AtomExitOnFailure(hr, "Failed to parse ATOM feed.");
264 277
265 if (S_FALSE == hr) 278 if (S_FALSE == hr)
266 { 279 {
@@ -305,96 +318,96 @@ static HRESULT ParseAtomFeed(
305 318
306 // First, allocate the new feed and all the possible sub elements. 319 // First, allocate the new feed and all the possible sub elements.
307 pNewFeed = (ATOM_FEED*)MemAlloc(sizeof(ATOM_FEED), TRUE); 320 pNewFeed = (ATOM_FEED*)MemAlloc(sizeof(ATOM_FEED), TRUE);
308 ExitOnNull(pNewFeed, hr, E_OUTOFMEMORY, "Failed to allocate ATOM feed structure."); 321 AtomExitOnNull(pNewFeed, hr, E_OUTOFMEMORY, "Failed to allocate ATOM feed structure.");
309 322
310 pNewFeed->pixn = pixnFeed; 323 pNewFeed->pixn = pixnFeed;
311 pNewFeed->pixn->AddRef(); 324 pNewFeed->pixn->AddRef();
312 325
313 hr = AllocateAtomType<ATOM_AUTHOR>(pixnFeed, L"author", &pNewFeed->rgAuthors, &pNewFeed->cAuthors); 326 hr = AllocateAtomType<ATOM_AUTHOR>(pixnFeed, L"author", &pNewFeed->rgAuthors, &pNewFeed->cAuthors);
314 ExitOnFailure(hr, "Failed to allocate ATOM feed authors."); 327 AtomExitOnFailure(hr, "Failed to allocate ATOM feed authors.");
315 328
316 hr = AllocateAtomType<ATOM_CATEGORY>(pixnFeed, L"category", &pNewFeed->rgCategories, &pNewFeed->cCategories); 329 hr = AllocateAtomType<ATOM_CATEGORY>(pixnFeed, L"category", &pNewFeed->rgCategories, &pNewFeed->cCategories);
317 ExitOnFailure(hr, "Failed to allocate ATOM feed categories."); 330 AtomExitOnFailure(hr, "Failed to allocate ATOM feed categories.");
318 331
319 hr = AllocateAtomType<ATOM_ENTRY>(pixnFeed, L"entry", &pNewFeed->rgEntries, &pNewFeed->cEntries); 332 hr = AllocateAtomType<ATOM_ENTRY>(pixnFeed, L"entry", &pNewFeed->rgEntries, &pNewFeed->cEntries);
320 ExitOnFailure(hr, "Failed to allocate ATOM feed entries."); 333 AtomExitOnFailure(hr, "Failed to allocate ATOM feed entries.");
321 334
322 hr = AllocateAtomType<ATOM_LINK>(pixnFeed, L"link", &pNewFeed->rgLinks, &pNewFeed->cLinks); 335 hr = AllocateAtomType<ATOM_LINK>(pixnFeed, L"link", &pNewFeed->rgLinks, &pNewFeed->cLinks);
323 ExitOnFailure(hr, "Failed to allocate ATOM feed links."); 336 AtomExitOnFailure(hr, "Failed to allocate ATOM feed links.");
324 337
325 // Second, process the elements under a feed. 338 // Second, process the elements under a feed.
326 hr = pixnFeed->get_childNodes(&pNodeList); 339 hr = pixnFeed->get_childNodes(&pNodeList);
327 ExitOnFailure(hr, "Failed to get child nodes of ATOM feed element."); 340 AtomExitOnFailure(hr, "Failed to get child nodes of ATOM feed element.");
328 341
329 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, &bstrNodeName))) 342 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, &bstrNodeName)))
330 { 343 {
331 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"generator", -1)) 344 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"generator", -1))
332 { 345 {
333 hr = AssignString(&pNewFeed->wzGenerator, pNode); 346 hr = AssignString(&pNewFeed->wzGenerator, pNode);
334 ExitOnFailure(hr, "Failed to allocate ATOM feed generator."); 347 AtomExitOnFailure(hr, "Failed to allocate ATOM feed generator.");
335 } 348 }
336 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"icon", -1)) 349 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"icon", -1))
337 { 350 {
338 hr = AssignString(&pNewFeed->wzIcon, pNode); 351 hr = AssignString(&pNewFeed->wzIcon, pNode);
339 ExitOnFailure(hr, "Failed to allocate ATOM feed icon."); 352 AtomExitOnFailure(hr, "Failed to allocate ATOM feed icon.");
340 } 353 }
341 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"id", -1)) 354 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"id", -1))
342 { 355 {
343 hr = AssignString(&pNewFeed->wzId, pNode); 356 hr = AssignString(&pNewFeed->wzId, pNode);
344 ExitOnFailure(hr, "Failed to allocate ATOM feed id."); 357 AtomExitOnFailure(hr, "Failed to allocate ATOM feed id.");
345 } 358 }
346 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"logo", -1)) 359 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"logo", -1))
347 { 360 {
348 hr = AssignString(&pNewFeed->wzLogo, pNode); 361 hr = AssignString(&pNewFeed->wzLogo, pNode);
349 ExitOnFailure(hr, "Failed to allocate ATOM feed logo."); 362 AtomExitOnFailure(hr, "Failed to allocate ATOM feed logo.");
350 } 363 }
351 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"subtitle", -1)) 364 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"subtitle", -1))
352 { 365 {
353 hr = AssignString(&pNewFeed->wzSubtitle, pNode); 366 hr = AssignString(&pNewFeed->wzSubtitle, pNode);
354 ExitOnFailure(hr, "Failed to allocate ATOM feed subtitle."); 367 AtomExitOnFailure(hr, "Failed to allocate ATOM feed subtitle.");
355 } 368 }
356 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"title", -1)) 369 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"title", -1))
357 { 370 {
358 hr = AssignString(&pNewFeed->wzTitle, pNode); 371 hr = AssignString(&pNewFeed->wzTitle, pNode);
359 ExitOnFailure(hr, "Failed to allocate ATOM feed title."); 372 AtomExitOnFailure(hr, "Failed to allocate ATOM feed title.");
360 } 373 }
361 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"updated", -1)) 374 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"updated", -1))
362 { 375 {
363 hr = AssignDateTime(&pNewFeed->ftUpdated, pNode); 376 hr = AssignDateTime(&pNewFeed->ftUpdated, pNode);
364 ExitOnFailure(hr, "Failed to allocate ATOM feed updated."); 377 AtomExitOnFailure(hr, "Failed to allocate ATOM feed updated.");
365 } 378 }
366 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"author", -1)) 379 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"author", -1))
367 { 380 {
368 hr = ParseAtomAuthor(pNode, &pNewFeed->rgAuthors[cAuthors]); 381 hr = ParseAtomAuthor(pNode, &pNewFeed->rgAuthors[cAuthors]);
369 ExitOnFailure(hr, "Failed to parse ATOM author."); 382 AtomExitOnFailure(hr, "Failed to parse ATOM author.");
370 383
371 ++cAuthors; 384 ++cAuthors;
372 } 385 }
373 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"category", -1)) 386 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"category", -1))
374 { 387 {
375 hr = ParseAtomCategory(pNode, &pNewFeed->rgCategories[cCategories]); 388 hr = ParseAtomCategory(pNode, &pNewFeed->rgCategories[cCategories]);
376 ExitOnFailure(hr, "Failed to parse ATOM category."); 389 AtomExitOnFailure(hr, "Failed to parse ATOM category.");
377 390
378 ++cCategories; 391 ++cCategories;
379 } 392 }
380 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"entry", -1)) 393 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"entry", -1))
381 { 394 {
382 hr = ParseAtomEntry(pNode, &pNewFeed->rgEntries[cEntries]); 395 hr = ParseAtomEntry(pNode, &pNewFeed->rgEntries[cEntries]);
383 ExitOnFailure(hr, "Failed to parse ATOM entry."); 396 AtomExitOnFailure(hr, "Failed to parse ATOM entry.");
384 397
385 ++cEntries; 398 ++cEntries;
386 } 399 }
387 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"link", -1)) 400 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"link", -1))
388 { 401 {
389 hr = ParseAtomLink(pNode, &pNewFeed->rgLinks[cLinks]); 402 hr = ParseAtomLink(pNode, &pNewFeed->rgLinks[cLinks]);
390 ExitOnFailure(hr, "Failed to parse ATOM link."); 403 AtomExitOnFailure(hr, "Failed to parse ATOM link.");
391 404
392 ++cLinks; 405 ++cLinks;
393 } 406 }
394 else 407 else
395 { 408 {
396 hr = ParseAtomUnknownElement(pNode, &pNewFeed->pUnknownElements); 409 hr = ParseAtomUnknownElement(pNode, &pNewFeed->pUnknownElements);
397 ExitOnFailure(hr, "Failed to parse unknown ATOM feed element: %ls", bstrNodeName); 410 AtomExitOnFailure(hr, "Failed to parse unknown ATOM feed element: %ls", bstrNodeName);
398 } 411 }
399 412
400 ReleaseNullBSTR(bstrNodeName); 413 ReleaseNullBSTR(bstrNodeName);
@@ -404,17 +417,17 @@ static HRESULT ParseAtomFeed(
404 if (!pNewFeed->wzId || !*pNewFeed->wzId) 417 if (!pNewFeed->wzId || !*pNewFeed->wzId)
405 { 418 {
406 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 419 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
407 ExitOnRootFailure(hr, "Failed to find required feed/id element."); 420 AtomExitOnRootFailure(hr, "Failed to find required feed/id element.");
408 } 421 }
409 else if (!pNewFeed->wzTitle || !*pNewFeed->wzTitle) 422 else if (!pNewFeed->wzTitle || !*pNewFeed->wzTitle)
410 { 423 {
411 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 424 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
412 ExitOnRootFailure(hr, "Failed to find required feed/title element."); 425 AtomExitOnRootFailure(hr, "Failed to find required feed/title element.");
413 } 426 }
414 else if (0 == pNewFeed->ftUpdated.dwHighDateTime && 0 == pNewFeed->ftUpdated.dwLowDateTime) 427 else if (0 == pNewFeed->ftUpdated.dwHighDateTime && 0 == pNewFeed->ftUpdated.dwLowDateTime)
415 { 428 {
416 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 429 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
417 ExitOnRootFailure(hr, "Failed to find required feed/updated element."); 430 AtomExitOnRootFailure(hr, "Failed to find required feed/updated element.");
418 } 431 }
419 432
420 *ppFeed = pNewFeed; 433 *ppFeed = pNewFeed;
@@ -450,12 +463,12 @@ template<class T> static HRESULT AllocateAtomType(
450 T* prgT = NULL; 463 T* prgT = NULL;
451 464
452 hr = XmlSelectNodes(pixnParent, wzT, &pNodeList); 465 hr = XmlSelectNodes(pixnParent, wzT, &pNodeList);
453 ExitOnFailure(hr, "Failed to select all ATOM %ls.", wzT); 466 AtomExitOnFailure(hr, "Failed to select all ATOM %ls.", wzT);
454 467
455 if (S_OK == hr) 468 if (S_OK == hr)
456 { 469 {
457 hr = pNodeList->get_length(&cT); 470 hr = pNodeList->get_length(&cT);
458 ExitOnFailure(hr, "Failed to count the number of ATOM %ls.", wzT); 471 AtomExitOnFailure(hr, "Failed to count the number of ATOM %ls.", wzT);
459 472
460 if (cT == 0) 473 if (cT == 0)
461 { 474 {
@@ -463,7 +476,7 @@ template<class T> static HRESULT AllocateAtomType(
463 } 476 }
464 477
465 prgT = static_cast<T*>(MemAlloc(sizeof(T) * cT, TRUE)); 478 prgT = static_cast<T*>(MemAlloc(sizeof(T) * cT, TRUE));
466 ExitOnNull(prgT, hr, E_OUTOFMEMORY, "Failed to allocate ATOM."); 479 AtomExitOnNull(prgT, hr, E_OUTOFMEMORY, "Failed to allocate ATOM.");
467 480
468 *pcT = cT; 481 *pcT = cT;
469 *pprgT = prgT; 482 *pprgT = prgT;
@@ -499,30 +512,30 @@ static HRESULT ParseAtomAuthor(
499 BSTR bstrNodeName = NULL; 512 BSTR bstrNodeName = NULL;
500 513
501 hr = pixnAuthor->get_childNodes(&pNodeList); 514 hr = pixnAuthor->get_childNodes(&pNodeList);
502 ExitOnFailure(hr, "Failed to get child nodes of ATOM author element."); 515 AtomExitOnFailure(hr, "Failed to get child nodes of ATOM author element.");
503 516
504 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, &bstrNodeName))) 517 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, &bstrNodeName)))
505 { 518 {
506 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"name", -1)) 519 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"name", -1))
507 { 520 {
508 hr = AssignString(&pAuthor->wzName, pNode); 521 hr = AssignString(&pAuthor->wzName, pNode);
509 ExitOnFailure(hr, "Failed to allocate ATOM author name."); 522 AtomExitOnFailure(hr, "Failed to allocate ATOM author name.");
510 } 523 }
511 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"email", -1)) 524 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"email", -1))
512 { 525 {
513 hr = AssignString(&pAuthor->wzEmail, pNode); 526 hr = AssignString(&pAuthor->wzEmail, pNode);
514 ExitOnFailure(hr, "Failed to allocate ATOM author email."); 527 AtomExitOnFailure(hr, "Failed to allocate ATOM author email.");
515 } 528 }
516 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"uri", -1)) 529 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"uri", -1))
517 { 530 {
518 hr = AssignString(&pAuthor->wzUrl, pNode); 531 hr = AssignString(&pAuthor->wzUrl, pNode);
519 ExitOnFailure(hr, "Failed to allocate ATOM author uri."); 532 AtomExitOnFailure(hr, "Failed to allocate ATOM author uri.");
520 } 533 }
521 534
522 ReleaseNullBSTR(bstrNodeName); 535 ReleaseNullBSTR(bstrNodeName);
523 ReleaseNullObject(pNode); 536 ReleaseNullObject(pNode);
524 } 537 }
525 ExitOnFailure(hr, "Failed to process all ATOM author elements."); 538 AtomExitOnFailure(hr, "Failed to process all ATOM author elements.");
526 539
527 hr = S_OK; 540 hr = S_OK;
528 541
@@ -553,44 +566,44 @@ static HRESULT ParseAtomCategory(
553 566
554 // Process attributes first. 567 // Process attributes first.
555 hr = pixnCategory->get_attributes(&pixnnmAttributes); 568 hr = pixnCategory->get_attributes(&pixnnmAttributes);
556 ExitOnFailure(hr, "Failed get attributes on ATOM unknown element."); 569 AtomExitOnFailure(hr, "Failed get attributes on ATOM unknown element.");
557 570
558 while (S_OK == (hr = XmlNextAttribute(pixnnmAttributes, &pNode, &bstrNodeName))) 571 while (S_OK == (hr = XmlNextAttribute(pixnnmAttributes, &pNode, &bstrNodeName)))
559 { 572 {
560 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"label", -1)) 573 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"label", -1))
561 { 574 {
562 hr = AssignString(&pCategory->wzLabel, pNode); 575 hr = AssignString(&pCategory->wzLabel, pNode);
563 ExitOnFailure(hr, "Failed to allocate ATOM category label."); 576 AtomExitOnFailure(hr, "Failed to allocate ATOM category label.");
564 } 577 }
565 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"scheme", -1)) 578 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"scheme", -1))
566 { 579 {
567 hr = AssignString(&pCategory->wzScheme, pNode); 580 hr = AssignString(&pCategory->wzScheme, pNode);
568 ExitOnFailure(hr, "Failed to allocate ATOM category scheme."); 581 AtomExitOnFailure(hr, "Failed to allocate ATOM category scheme.");
569 } 582 }
570 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"term", -1)) 583 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"term", -1))
571 { 584 {
572 hr = AssignString(&pCategory->wzTerm, pNode); 585 hr = AssignString(&pCategory->wzTerm, pNode);
573 ExitOnFailure(hr, "Failed to allocate ATOM category term."); 586 AtomExitOnFailure(hr, "Failed to allocate ATOM category term.");
574 } 587 }
575 588
576 ReleaseNullBSTR(bstrNodeName); 589 ReleaseNullBSTR(bstrNodeName);
577 ReleaseNullObject(pNode); 590 ReleaseNullObject(pNode);
578 } 591 }
579 ExitOnFailure(hr, "Failed to process all ATOM category attributes."); 592 AtomExitOnFailure(hr, "Failed to process all ATOM category attributes.");
580 593
581 // Process elements second. 594 // Process elements second.
582 hr = pixnCategory->get_childNodes(&pNodeList); 595 hr = pixnCategory->get_childNodes(&pNodeList);
583 ExitOnFailure(hr, "Failed to get child nodes of ATOM category element."); 596 AtomExitOnFailure(hr, "Failed to get child nodes of ATOM category element.");
584 597
585 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, &bstrNodeName))) 598 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, &bstrNodeName)))
586 { 599 {
587 hr = ParseAtomUnknownElement(pNode, &pCategory->pUnknownElements); 600 hr = ParseAtomUnknownElement(pNode, &pCategory->pUnknownElements);
588 ExitOnFailure(hr, "Failed to parse unknown ATOM category element: %ls", bstrNodeName); 601 AtomExitOnFailure(hr, "Failed to parse unknown ATOM category element: %ls", bstrNodeName);
589 602
590 ReleaseNullBSTR(bstrNodeName); 603 ReleaseNullBSTR(bstrNodeName);
591 ReleaseNullObject(pNode); 604 ReleaseNullObject(pNode);
592 } 605 }
593 ExitOnFailure(hr, "Failed to process all ATOM category elements."); 606 AtomExitOnFailure(hr, "Failed to process all ATOM category elements.");
594 607
595 hr = S_OK; 608 hr = S_OK;
596 609
@@ -622,42 +635,42 @@ static HRESULT ParseAtomContent(
622 635
623 // Process attributes first. 636 // Process attributes first.
624 hr = pixnContent->get_attributes(&pixnnmAttributes); 637 hr = pixnContent->get_attributes(&pixnnmAttributes);
625 ExitOnFailure(hr, "Failed get attributes on ATOM unknown element."); 638 AtomExitOnFailure(hr, "Failed get attributes on ATOM unknown element.");
626 639
627 while (S_OK == (hr = XmlNextAttribute(pixnnmAttributes, &pNode, &bstrNodeName))) 640 while (S_OK == (hr = XmlNextAttribute(pixnnmAttributes, &pNode, &bstrNodeName)))
628 { 641 {
629 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"type", -1)) 642 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"type", -1))
630 { 643 {
631 hr = AssignString(&pContent->wzType, pNode); 644 hr = AssignString(&pContent->wzType, pNode);
632 ExitOnFailure(hr, "Failed to allocate ATOM content type."); 645 AtomExitOnFailure(hr, "Failed to allocate ATOM content type.");
633 } 646 }
634 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"url", -1)) 647 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"url", -1))
635 { 648 {
636 hr = AssignString(&pContent->wzUrl, pNode); 649 hr = AssignString(&pContent->wzUrl, pNode);
637 ExitOnFailure(hr, "Failed to allocate ATOM content scheme."); 650 AtomExitOnFailure(hr, "Failed to allocate ATOM content scheme.");
638 } 651 }
639 652
640 ReleaseNullBSTR(bstrNodeName); 653 ReleaseNullBSTR(bstrNodeName);
641 ReleaseNullObject(pNode); 654 ReleaseNullObject(pNode);
642 } 655 }
643 ExitOnFailure(hr, "Failed to process all ATOM content attributes."); 656 AtomExitOnFailure(hr, "Failed to process all ATOM content attributes.");
644 657
645 // Process elements second. 658 // Process elements second.
646 hr = pixnContent->get_childNodes(&pNodeList); 659 hr = pixnContent->get_childNodes(&pNodeList);
647 ExitOnFailure(hr, "Failed to get child nodes of ATOM content element."); 660 AtomExitOnFailure(hr, "Failed to get child nodes of ATOM content element.");
648 661
649 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, &bstrNodeName))) 662 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, &bstrNodeName)))
650 { 663 {
651 hr = ParseAtomUnknownElement(pNode, &pContent->pUnknownElements); 664 hr = ParseAtomUnknownElement(pNode, &pContent->pUnknownElements);
652 ExitOnFailure(hr, "Failed to parse unknown ATOM content element: %ls", bstrNodeName); 665 AtomExitOnFailure(hr, "Failed to parse unknown ATOM content element: %ls", bstrNodeName);
653 666
654 ReleaseNullBSTR(bstrNodeName); 667 ReleaseNullBSTR(bstrNodeName);
655 ReleaseNullObject(pNode); 668 ReleaseNullObject(pNode);
656 } 669 }
657 ExitOnFailure(hr, "Failed to process all ATOM content elements."); 670 AtomExitOnFailure(hr, "Failed to process all ATOM content elements.");
658 671
659 hr = AssignString(&pContent->wzValue, pixnContent); 672 hr = AssignString(&pContent->wzValue, pixnContent);
660 ExitOnFailure(hr, "Failed to allocate ATOM content value."); 673 AtomExitOnFailure(hr, "Failed to allocate ATOM content value.");
661 674
662LExit: 675LExit:
663 ReleaseBSTR(bstrNodeName); 676 ReleaseBSTR(bstrNodeName);
@@ -694,56 +707,56 @@ static HRESULT ParseAtomEntry(
694 707
695 // First, allocate all the possible sub elements. 708 // First, allocate all the possible sub elements.
696 hr = AllocateAtomType<ATOM_AUTHOR>(pixnEntry, L"author", &pEntry->rgAuthors, &pEntry->cAuthors); 709 hr = AllocateAtomType<ATOM_AUTHOR>(pixnEntry, L"author", &pEntry->rgAuthors, &pEntry->cAuthors);
697 ExitOnFailure(hr, "Failed to allocate ATOM entry authors."); 710 AtomExitOnFailure(hr, "Failed to allocate ATOM entry authors.");
698 711
699 hr = AllocateAtomType<ATOM_CATEGORY>(pixnEntry, L"category", &pEntry->rgCategories, &pEntry->cCategories); 712 hr = AllocateAtomType<ATOM_CATEGORY>(pixnEntry, L"category", &pEntry->rgCategories, &pEntry->cCategories);
700 ExitOnFailure(hr, "Failed to allocate ATOM entry categories."); 713 AtomExitOnFailure(hr, "Failed to allocate ATOM entry categories.");
701 714
702 hr = AllocateAtomType<ATOM_LINK>(pixnEntry, L"link", &pEntry->rgLinks, &pEntry->cLinks); 715 hr = AllocateAtomType<ATOM_LINK>(pixnEntry, L"link", &pEntry->rgLinks, &pEntry->cLinks);
703 ExitOnFailure(hr, "Failed to allocate ATOM entry links."); 716 AtomExitOnFailure(hr, "Failed to allocate ATOM entry links.");
704 717
705 // Second, process elements. 718 // Second, process elements.
706 hr = pixnEntry->get_childNodes(&pNodeList); 719 hr = pixnEntry->get_childNodes(&pNodeList);
707 ExitOnFailure(hr, "Failed to get child nodes of ATOM entry element."); 720 AtomExitOnFailure(hr, "Failed to get child nodes of ATOM entry element.");
708 721
709 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, &bstrNodeName))) 722 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, &bstrNodeName)))
710 { 723 {
711 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"id", -1)) 724 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"id", -1))
712 { 725 {
713 hr = AssignString(&pEntry->wzId, pNode); 726 hr = AssignString(&pEntry->wzId, pNode);
714 ExitOnFailure(hr, "Failed to allocate ATOM entry id."); 727 AtomExitOnFailure(hr, "Failed to allocate ATOM entry id.");
715 } 728 }
716 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"summary", -1)) 729 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"summary", -1))
717 { 730 {
718 hr = AssignString(&pEntry->wzSummary, pNode); 731 hr = AssignString(&pEntry->wzSummary, pNode);
719 ExitOnFailure(hr, "Failed to allocate ATOM entry summary."); 732 AtomExitOnFailure(hr, "Failed to allocate ATOM entry summary.");
720 } 733 }
721 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"title", -1)) 734 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"title", -1))
722 { 735 {
723 hr = AssignString(&pEntry->wzTitle, pNode); 736 hr = AssignString(&pEntry->wzTitle, pNode);
724 ExitOnFailure(hr, "Failed to allocate ATOM entry title."); 737 AtomExitOnFailure(hr, "Failed to allocate ATOM entry title.");
725 } 738 }
726 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"published", -1)) 739 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"published", -1))
727 { 740 {
728 hr = AssignDateTime(&pEntry->ftPublished, pNode); 741 hr = AssignDateTime(&pEntry->ftPublished, pNode);
729 ExitOnFailure(hr, "Failed to allocate ATOM entry published."); 742 AtomExitOnFailure(hr, "Failed to allocate ATOM entry published.");
730 } 743 }
731 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"updated", -1)) 744 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"updated", -1))
732 { 745 {
733 hr = AssignDateTime(&pEntry->ftUpdated, pNode); 746 hr = AssignDateTime(&pEntry->ftUpdated, pNode);
734 ExitOnFailure(hr, "Failed to allocate ATOM entry updated."); 747 AtomExitOnFailure(hr, "Failed to allocate ATOM entry updated.");
735 } 748 }
736 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"author", -1)) 749 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"author", -1))
737 { 750 {
738 hr = ParseAtomAuthor(pNode, &pEntry->rgAuthors[cAuthors]); 751 hr = ParseAtomAuthor(pNode, &pEntry->rgAuthors[cAuthors]);
739 ExitOnFailure(hr, "Failed to parse ATOM entry author."); 752 AtomExitOnFailure(hr, "Failed to parse ATOM entry author.");
740 753
741 ++cAuthors; 754 ++cAuthors;
742 } 755 }
743 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"category", -1)) 756 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"category", -1))
744 { 757 {
745 hr = ParseAtomCategory(pNode, &pEntry->rgCategories[cCategories]); 758 hr = ParseAtomCategory(pNode, &pEntry->rgCategories[cCategories]);
746 ExitOnFailure(hr, "Failed to parse ATOM entry category."); 759 AtomExitOnFailure(hr, "Failed to parse ATOM entry category.");
747 760
748 ++cCategories; 761 ++cCategories;
749 } 762 }
@@ -752,47 +765,47 @@ static HRESULT ParseAtomEntry(
752 if (NULL != pEntry->pContent) 765 if (NULL != pEntry->pContent)
753 { 766 {
754 hr = E_UNEXPECTED; 767 hr = E_UNEXPECTED;
755 ExitOnFailure(hr, "Cannot have two content elements in ATOM entry."); 768 AtomExitOnFailure(hr, "Cannot have two content elements in ATOM entry.");
756 } 769 }
757 770
758 pEntry->pContent = static_cast<ATOM_CONTENT*>(MemAlloc(sizeof(ATOM_CONTENT), TRUE)); 771 pEntry->pContent = static_cast<ATOM_CONTENT*>(MemAlloc(sizeof(ATOM_CONTENT), TRUE));
759 ExitOnNull(pEntry->pContent, hr, E_OUTOFMEMORY, "Failed to allocate ATOM entry content."); 772 AtomExitOnNull(pEntry->pContent, hr, E_OUTOFMEMORY, "Failed to allocate ATOM entry content.");
760 773
761 hr = ParseAtomContent(pNode, pEntry->pContent); 774 hr = ParseAtomContent(pNode, pEntry->pContent);
762 ExitOnFailure(hr, "Failed to parse ATOM entry content."); 775 AtomExitOnFailure(hr, "Failed to parse ATOM entry content.");
763 } 776 }
764 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"link", -1)) 777 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"link", -1))
765 { 778 {
766 hr = ParseAtomLink(pNode, &pEntry->rgLinks[cLinks]); 779 hr = ParseAtomLink(pNode, &pEntry->rgLinks[cLinks]);
767 ExitOnFailure(hr, "Failed to parse ATOM entry link."); 780 AtomExitOnFailure(hr, "Failed to parse ATOM entry link.");
768 781
769 ++cLinks; 782 ++cLinks;
770 } 783 }
771 else 784 else
772 { 785 {
773 hr = ParseAtomUnknownElement(pNode, &pEntry->pUnknownElements); 786 hr = ParseAtomUnknownElement(pNode, &pEntry->pUnknownElements);
774 ExitOnFailure(hr, "Failed to parse unknown ATOM entry element: %ls", bstrNodeName); 787 AtomExitOnFailure(hr, "Failed to parse unknown ATOM entry element: %ls", bstrNodeName);
775 } 788 }
776 789
777 ReleaseNullBSTR(bstrNodeName); 790 ReleaseNullBSTR(bstrNodeName);
778 ReleaseNullObject(pNode); 791 ReleaseNullObject(pNode);
779 } 792 }
780 ExitOnFailure(hr, "Failed to process all ATOM entry elements."); 793 AtomExitOnFailure(hr, "Failed to process all ATOM entry elements.");
781 794
782 if (!pEntry->wzId || !*pEntry->wzId) 795 if (!pEntry->wzId || !*pEntry->wzId)
783 { 796 {
784 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 797 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
785 ExitOnRootFailure(hr, "Failed to find required feed/entry/id element."); 798 AtomExitOnRootFailure(hr, "Failed to find required feed/entry/id element.");
786 } 799 }
787 else if (!pEntry->wzTitle || !*pEntry->wzTitle) 800 else if (!pEntry->wzTitle || !*pEntry->wzTitle)
788 { 801 {
789 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 802 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
790 ExitOnRootFailure(hr, "Failed to find required feed/entry/title element."); 803 AtomExitOnRootFailure(hr, "Failed to find required feed/entry/title element.");
791 } 804 }
792 else if (0 == pEntry->ftUpdated.dwHighDateTime && 0 == pEntry->ftUpdated.dwLowDateTime) 805 else if (0 == pEntry->ftUpdated.dwHighDateTime && 0 == pEntry->ftUpdated.dwLowDateTime)
793 { 806 {
794 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 807 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
795 ExitOnRootFailure(hr, "Failed to find required feed/entry/updated element."); 808 AtomExitOnRootFailure(hr, "Failed to find required feed/entry/updated element.");
796 } 809 }
797 810
798 hr = S_OK; 811 hr = S_OK;
@@ -825,19 +838,19 @@ static HRESULT ParseAtomLink(
825 838
826 // Process attributes first. 839 // Process attributes first.
827 hr = pixnLink->get_attributes(&pixnnmAttributes); 840 hr = pixnLink->get_attributes(&pixnnmAttributes);
828 ExitOnFailure(hr, "Failed get attributes for ATOM link."); 841 AtomExitOnFailure(hr, "Failed get attributes for ATOM link.");
829 842
830 while (S_OK == (hr = XmlNextAttribute(pixnnmAttributes, &pNode, &bstrNodeName))) 843 while (S_OK == (hr = XmlNextAttribute(pixnnmAttributes, &pNode, &bstrNodeName)))
831 { 844 {
832 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"rel", -1)) 845 if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"rel", -1))
833 { 846 {
834 hr = AssignString(&pLink->wzRel, pNode); 847 hr = AssignString(&pLink->wzRel, pNode);
835 ExitOnFailure(hr, "Failed to allocate ATOM link rel."); 848 AtomExitOnFailure(hr, "Failed to allocate ATOM link rel.");
836 } 849 }
837 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"href", -1)) 850 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"href", -1))
838 { 851 {
839 hr = AssignString(&pLink->wzUrl, pNode); 852 hr = AssignString(&pLink->wzUrl, pNode);
840 ExitOnFailure(hr, "Failed to allocate ATOM link href."); 853 AtomExitOnFailure(hr, "Failed to allocate ATOM link href.");
841 } 854 }
842 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"length", -1)) 855 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"length", -1))
843 { 856 {
@@ -846,45 +859,45 @@ static HRESULT ParseAtomLink(
846 { 859 {
847 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 860 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
848 } 861 }
849 ExitOnFailure(hr, "Failed to parse ATOM link length."); 862 AtomExitOnFailure(hr, "Failed to parse ATOM link length.");
850 } 863 }
851 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"title", -1)) 864 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"title", -1))
852 { 865 {
853 hr = AssignString(&pLink->wzTitle, pNode); 866 hr = AssignString(&pLink->wzTitle, pNode);
854 ExitOnFailure(hr, "Failed to allocate ATOM link title."); 867 AtomExitOnFailure(hr, "Failed to allocate ATOM link title.");
855 } 868 }
856 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"type", -1)) 869 else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, bstrNodeName, -1, L"type", -1))
857 { 870 {
858 hr = AssignString(&pLink->wzType, pNode); 871 hr = AssignString(&pLink->wzType, pNode);
859 ExitOnFailure(hr, "Failed to allocate ATOM link type."); 872 AtomExitOnFailure(hr, "Failed to allocate ATOM link type.");
860 } 873 }
861 else 874 else
862 { 875 {
863 hr = ParseAtomUnknownAttribute(pNode, &pLink->pUnknownAttributes); 876 hr = ParseAtomUnknownAttribute(pNode, &pLink->pUnknownAttributes);
864 ExitOnFailure(hr, "Failed to parse unknown ATOM link attribute: %ls", bstrNodeName); 877 AtomExitOnFailure(hr, "Failed to parse unknown ATOM link attribute: %ls", bstrNodeName);
865 } 878 }
866 879
867 ReleaseNullBSTR(bstrNodeName); 880 ReleaseNullBSTR(bstrNodeName);
868 ReleaseNullObject(pNode); 881 ReleaseNullObject(pNode);
869 } 882 }
870 ExitOnFailure(hr, "Failed to process all ATOM link attributes."); 883 AtomExitOnFailure(hr, "Failed to process all ATOM link attributes.");
871 884
872 // Process elements second. 885 // Process elements second.
873 hr = pixnLink->get_childNodes(&pNodeList); 886 hr = pixnLink->get_childNodes(&pNodeList);
874 ExitOnFailure(hr, "Failed to get child nodes of ATOM link element."); 887 AtomExitOnFailure(hr, "Failed to get child nodes of ATOM link element.");
875 888
876 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, &bstrNodeName))) 889 while (S_OK == (hr = XmlNextElement(pNodeList, &pNode, &bstrNodeName)))
877 { 890 {
878 hr = ParseAtomUnknownElement(pNode, &pLink->pUnknownElements); 891 hr = ParseAtomUnknownElement(pNode, &pLink->pUnknownElements);
879 ExitOnFailure(hr, "Failed to parse unknown ATOM link element: %ls", bstrNodeName); 892 AtomExitOnFailure(hr, "Failed to parse unknown ATOM link element: %ls", bstrNodeName);
880 893
881 ReleaseNullBSTR(bstrNodeName); 894 ReleaseNullBSTR(bstrNodeName);
882 ReleaseNullObject(pNode); 895 ReleaseNullObject(pNode);
883 } 896 }
884 ExitOnFailure(hr, "Failed to process all ATOM link elements."); 897 AtomExitOnFailure(hr, "Failed to process all ATOM link elements.");
885 898
886 hr = AssignString(&pLink->wzValue, pixnLink); 899 hr = AssignString(&pLink->wzValue, pixnLink);
887 ExitOnFailure(hr, "Failed to allocate ATOM link value."); 900 AtomExitOnFailure(hr, "Failed to allocate ATOM link value.");
888 901
889LExit: 902LExit:
890 ReleaseBSTR(bstrNodeName); 903 ReleaseBSTR(bstrNodeName);
@@ -916,39 +929,39 @@ static HRESULT ParseAtomUnknownElement(
916 ATOM_UNKNOWN_ELEMENT* pNewUnknownElement; 929 ATOM_UNKNOWN_ELEMENT* pNewUnknownElement;
917 930
918 pNewUnknownElement = (ATOM_UNKNOWN_ELEMENT*)MemAlloc(sizeof(ATOM_UNKNOWN_ELEMENT), TRUE); 931 pNewUnknownElement = (ATOM_UNKNOWN_ELEMENT*)MemAlloc(sizeof(ATOM_UNKNOWN_ELEMENT), TRUE);
919 ExitOnNull(pNewUnknownElement, hr, E_OUTOFMEMORY, "Failed to allocate unknown element."); 932 AtomExitOnNull(pNewUnknownElement, hr, E_OUTOFMEMORY, "Failed to allocate unknown element.");
920 933
921 hr = pNode->get_namespaceURI(&bstrNodeNamespace); 934 hr = pNode->get_namespaceURI(&bstrNodeNamespace);
922 if (S_OK == hr) 935 if (S_OK == hr)
923 { 936 {
924 hr = StrAllocString(&pNewUnknownElement->wzNamespace, bstrNodeNamespace, 0); 937 hr = StrAllocString(&pNewUnknownElement->wzNamespace, bstrNodeNamespace, 0);
925 ExitOnFailure(hr, "Failed to allocate ATOM unknown element namespace."); 938 AtomExitOnFailure(hr, "Failed to allocate ATOM unknown element namespace.");
926 } 939 }
927 else if (S_FALSE == hr) 940 else if (S_FALSE == hr)
928 { 941 {
929 hr = S_OK; 942 hr = S_OK;
930 } 943 }
931 ExitOnFailure(hr, "Failed to get unknown element namespace."); 944 AtomExitOnFailure(hr, "Failed to get unknown element namespace.");
932 945
933 hr = pNode->get_baseName(&bstrNodeName); 946 hr = pNode->get_baseName(&bstrNodeName);
934 ExitOnFailure(hr, "Failed to get unknown element name."); 947 AtomExitOnFailure(hr, "Failed to get unknown element name.");
935 948
936 hr = StrAllocString(&pNewUnknownElement->wzElement, bstrNodeName, 0); 949 hr = StrAllocString(&pNewUnknownElement->wzElement, bstrNodeName, 0);
937 ExitOnFailure(hr, "Failed to allocate ATOM unknown element name."); 950 AtomExitOnFailure(hr, "Failed to allocate ATOM unknown element name.");
938 951
939 hr = XmlGetText(pNode, &bstrNodeValue); 952 hr = XmlGetText(pNode, &bstrNodeValue);
940 ExitOnFailure(hr, "Failed to get unknown element value."); 953 AtomExitOnFailure(hr, "Failed to get unknown element value.");
941 954
942 hr = StrAllocString(&pNewUnknownElement->wzValue, bstrNodeValue, 0); 955 hr = StrAllocString(&pNewUnknownElement->wzValue, bstrNodeValue, 0);
943 ExitOnFailure(hr, "Failed to allocate ATOM unknown element value."); 956 AtomExitOnFailure(hr, "Failed to allocate ATOM unknown element value.");
944 957
945 hr = pNode->get_attributes(&pixnnmAttributes); 958 hr = pNode->get_attributes(&pixnnmAttributes);
946 ExitOnFailure(hr, "Failed get attributes on ATOM unknown element."); 959 AtomExitOnFailure(hr, "Failed get attributes on ATOM unknown element.");
947 960
948 while (S_OK == (hr = pixnnmAttributes->nextNode(&pixnAttribute))) 961 while (S_OK == (hr = pixnnmAttributes->nextNode(&pixnAttribute)))
949 { 962 {
950 hr = ParseAtomUnknownAttribute(pixnAttribute, &pNewUnknownElement->pAttributes); 963 hr = ParseAtomUnknownAttribute(pixnAttribute, &pNewUnknownElement->pAttributes);
951 ExitOnFailure(hr, "Failed to parse attribute on ATOM unknown element."); 964 AtomExitOnFailure(hr, "Failed to parse attribute on ATOM unknown element.");
952 965
953 ReleaseNullObject(pixnAttribute); 966 ReleaseNullObject(pixnAttribute);
954 } 967 }
@@ -957,7 +970,7 @@ static HRESULT ParseAtomUnknownElement(
957 { 970 {
958 hr = S_OK; 971 hr = S_OK;
959 } 972 }
960 ExitOnFailure(hr, "Failed to enumerate all attributes on ATOM unknown element."); 973 AtomExitOnFailure(hr, "Failed to enumerate all attributes on ATOM unknown element.");
961 974
962 ATOM_UNKNOWN_ELEMENT** ppTail = ppUnknownElement; 975 ATOM_UNKNOWN_ELEMENT** ppTail = ppUnknownElement;
963 while (*ppTail) 976 while (*ppTail)
@@ -999,31 +1012,31 @@ static HRESULT ParseAtomUnknownAttribute(
999 ATOM_UNKNOWN_ATTRIBUTE* pNewUnknownAttribute; 1012 ATOM_UNKNOWN_ATTRIBUTE* pNewUnknownAttribute;
1000 1013
1001 pNewUnknownAttribute = (ATOM_UNKNOWN_ATTRIBUTE*)MemAlloc(sizeof(ATOM_UNKNOWN_ATTRIBUTE), TRUE); 1014 pNewUnknownAttribute = (ATOM_UNKNOWN_ATTRIBUTE*)MemAlloc(sizeof(ATOM_UNKNOWN_ATTRIBUTE), TRUE);
1002 ExitOnNull(pNewUnknownAttribute, hr, E_OUTOFMEMORY, "Failed to allocate unknown attribute."); 1015 AtomExitOnNull(pNewUnknownAttribute, hr, E_OUTOFMEMORY, "Failed to allocate unknown attribute.");
1003 1016
1004 hr = pNode->get_namespaceURI(&bstrNodeNamespace); 1017 hr = pNode->get_namespaceURI(&bstrNodeNamespace);
1005 if (S_OK == hr) 1018 if (S_OK == hr)
1006 { 1019 {
1007 hr = StrAllocString(&pNewUnknownAttribute->wzNamespace, bstrNodeNamespace, 0); 1020 hr = StrAllocString(&pNewUnknownAttribute->wzNamespace, bstrNodeNamespace, 0);
1008 ExitOnFailure(hr, "Failed to allocate ATOM unknown attribute namespace."); 1021 AtomExitOnFailure(hr, "Failed to allocate ATOM unknown attribute namespace.");
1009 } 1022 }
1010 else if (S_FALSE == hr) 1023 else if (S_FALSE == hr)
1011 { 1024 {
1012 hr = S_OK; 1025 hr = S_OK;
1013 } 1026 }
1014 ExitOnFailure(hr, "Failed to get unknown attribute namespace."); 1027 AtomExitOnFailure(hr, "Failed to get unknown attribute namespace.");
1015 1028
1016 hr = pNode->get_baseName(&bstrNodeName); 1029 hr = pNode->get_baseName(&bstrNodeName);
1017 ExitOnFailure(hr, "Failed to get unknown attribute name."); 1030 AtomExitOnFailure(hr, "Failed to get unknown attribute name.");
1018 1031
1019 hr = StrAllocString(&pNewUnknownAttribute->wzAttribute, bstrNodeName, 0); 1032 hr = StrAllocString(&pNewUnknownAttribute->wzAttribute, bstrNodeName, 0);
1020 ExitOnFailure(hr, "Failed to allocate ATOM unknown attribute name."); 1033 AtomExitOnFailure(hr, "Failed to allocate ATOM unknown attribute name.");
1021 1034
1022 hr = XmlGetText(pNode, &bstrNodeValue); 1035 hr = XmlGetText(pNode, &bstrNodeValue);
1023 ExitOnFailure(hr, "Failed to get unknown attribute value."); 1036 AtomExitOnFailure(hr, "Failed to get unknown attribute value.");
1024 1037
1025 hr = StrAllocString(&pNewUnknownAttribute->wzValue, bstrNodeValue, 0); 1038 hr = StrAllocString(&pNewUnknownAttribute->wzValue, bstrNodeValue, 0);
1026 ExitOnFailure(hr, "Failed to allocate ATOM unknown attribute value."); 1039 AtomExitOnFailure(hr, "Failed to allocate ATOM unknown attribute value.");
1027 1040
1028 ATOM_UNKNOWN_ATTRIBUTE** ppTail = ppUnknownAttribute; 1041 ATOM_UNKNOWN_ATTRIBUTE** ppTail = ppUnknownAttribute;
1029 while (*ppTail) 1042 while (*ppTail)
@@ -1060,16 +1073,16 @@ static HRESULT AssignDateTime(
1060 if (0 != pft->dwHighDateTime || 0 != pft->dwLowDateTime) 1073 if (0 != pft->dwHighDateTime || 0 != pft->dwLowDateTime)
1061 { 1074 {
1062 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 1075 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
1063 ExitOnRootFailure(hr, "Already process this datetime value."); 1076 AtomExitOnRootFailure(hr, "Already process this datetime value.");
1064 } 1077 }
1065 1078
1066 hr = XmlGetText(pNode, &bstrValue); 1079 hr = XmlGetText(pNode, &bstrValue);
1067 ExitOnFailure(hr, "Failed to get value."); 1080 AtomExitOnFailure(hr, "Failed to get value.");
1068 1081
1069 if (S_OK == hr) 1082 if (S_OK == hr)
1070 { 1083 {
1071 hr = TimeFromString3339(bstrValue, pft); 1084 hr = TimeFromString3339(bstrValue, pft);
1072 ExitOnFailure(hr, "Failed to convert value to time."); 1085 AtomExitOnFailure(hr, "Failed to convert value to time.");
1073 } 1086 }
1074 else 1087 else
1075 { 1088 {
@@ -1099,16 +1112,16 @@ static HRESULT AssignString(
1099 if (pwzValue && *pwzValue) 1112 if (pwzValue && *pwzValue)
1100 { 1113 {
1101 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA); 1114 hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATA);
1102 ExitOnRootFailure(hr, "Already processed this value."); 1115 AtomExitOnRootFailure(hr, "Already processed this value.");
1103 } 1116 }
1104 1117
1105 hr = XmlGetText(pNode, &bstrValue); 1118 hr = XmlGetText(pNode, &bstrValue);
1106 ExitOnFailure(hr, "Failed to get value."); 1119 AtomExitOnFailure(hr, "Failed to get value.");
1107 1120
1108 if (S_OK == hr) 1121 if (S_OK == hr)
1109 { 1122 {
1110 hr = StrAllocString(pwzValue, bstrValue, 0); 1123 hr = StrAllocString(pwzValue, bstrValue, 0);
1111 ExitOnFailure(hr, "Failed to allocate value."); 1124 AtomExitOnFailure(hr, "Failed to allocate value.");
1112 } 1125 }
1113 else 1126 else
1114 { 1127 {