MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlFetchXMLCatalogFile

Function xmlFetchXMLCatalogFile

ThirdParty/libxml2/vtklibxml2/catalog.c:1375–1444  ·  view source on GitHub ↗

* xmlFetchXMLCatalogFile: * @catal: an existing but incomplete catalog entry * * Fetch and parse the subcatalog referenced by an entry * * Returns 0 in case of success, -1 otherwise */

Source from the content-addressed store, hash-verified

1373 * Returns 0 in case of success, -1 otherwise
1374 */
1375static int
1376xmlFetchXMLCatalogFile(xmlCatalogEntryPtr catal) {
1377 xmlCatalogEntryPtr doc;
1378
1379 if (catal == NULL)
1380 return(-1);
1381 if (catal->URL == NULL)
1382 return(-1);
1383
1384 /*
1385 * lock the whole catalog for modification
1386 */
1387 xmlRMutexLock(xmlCatalogMutex);
1388 if (catal->children != NULL) {
1389 /* Okay someone else did it in the meantime */
1390 xmlRMutexUnlock(xmlCatalogMutex);
1391 return(0);
1392 }
1393
1394 if (xmlCatalogXMLFiles != NULL) {
1395 doc = (xmlCatalogEntryPtr)
1396 xmlHashLookup(xmlCatalogXMLFiles, catal->URL);
1397 if (doc != NULL) {
1398 if (xmlDebugCatalogs)
1399 fprintf(stderr,
1400 "Found %s in file hash\n", catal->URL);
1401
1402 if (catal->type == XML_CATA_CATALOG)
1403 catal->children = doc->children;
1404 else
1405 catal->children = doc;
1406 catal->dealloc = 0;
1407 xmlRMutexUnlock(xmlCatalogMutex);
1408 return(0);
1409 }
1410 if (xmlDebugCatalogs)
1411 fprintf(stderr,
1412 "%s not found in file hash\n", catal->URL);
1413 }
1414
1415 /*
1416 * Fetch and parse. Note that xmlParseXMLCatalogFile does not
1417 * use the existing catalog, there is no recursion allowed at
1418 * that level.
1419 */
1420 doc = xmlParseXMLCatalogFile(catal->prefer, catal->URL);
1421 if (doc == NULL) {
1422 catal->type = XML_CATA_BROKEN_CATALOG;
1423 xmlRMutexUnlock(xmlCatalogMutex);
1424 return(-1);
1425 }
1426
1427 if (catal->type == XML_CATA_CATALOG)
1428 catal->children = doc->children;
1429 else
1430 catal->children = doc;
1431
1432 doc->dealloc = 1;

Callers 6

xmlAddXMLCatalogFunction · 0.85
xmlDelXMLCatalogFunction · 0.85
xmlCatalogXMLResolveFunction · 0.85
xmlCatalogXMLResolveURIFunction · 0.85
xmlCatalogListXMLResolveFunction · 0.85

Calls 7

xmlRMutexLockFunction · 0.85
xmlRMutexUnlockFunction · 0.85
xmlHashLookupFunction · 0.85
fprintfFunction · 0.85
xmlParseXMLCatalogFileFunction · 0.85
xmlHashCreateFunction · 0.85
xmlHashAddEntryFunction · 0.85

Tested by

no test coverage detected