Lines Matching +full:- +full:- +full:catalog
2 * catalog.c: set of generic Catalog related routines
5 * http://www.jclark.com/sp/catalog.htm
8 * http://www.oasis-open.org/committees/entity/spec-2001-08-06.html
39 #include <libxml/catalog.h>
71 #define XML_CATAL_BREAK ((xmlChar *) -1)
73 #define XML_XML_DEFAULT_CATALOG "file:///etc/xml/catalog"
76 #define XML_SGML_DEFAULT_CATALOG "file:///etc/sgml/catalog"
81 static char XML_XML_DEFAULT_CATALOG[256] = "file:///etc/xml/catalog";
104 XML_CATA_REMOVED = -1,
158 * SGML Catalogs are stored as a simple hash table of catalog entries
159 * Catalog stack to check against overflows when building the
160 * SGML catalog
168 * XML Catalogs are stored as a tree of Catalog entries
194 * The default catalog in use by the application
199 * A mutex for modifying the shared global catalog(s)
207 * Whether the catalog support was initialized.
213 * Catalog error handlers *
234 * @catal: the Catalog entry
239 * Handle a catalog error
268 * create a new Catalog entry, this type is shared both by XML and
282 xmlCatalogErrMemory("allocating catalog entry"); in xmlNewCatalogEntry()
285 ret->next = NULL; in xmlNewCatalogEntry()
286 ret->parent = NULL; in xmlNewCatalogEntry()
287 ret->children = NULL; in xmlNewCatalogEntry()
288 ret->type = type; in xmlNewCatalogEntry()
295 ret->name = xmlStrdup(name); in xmlNewCatalogEntry()
297 ret->name = NULL; in xmlNewCatalogEntry()
301 ret->value = xmlStrdup(value); in xmlNewCatalogEntry()
303 ret->value = NULL; in xmlNewCatalogEntry()
307 ret->URL = xmlStrdup(URL); in xmlNewCatalogEntry()
309 ret->URL = NULL; in xmlNewCatalogEntry()
310 ret->prefer = prefer; in xmlNewCatalogEntry()
311 ret->dealloc = 0; in xmlNewCatalogEntry()
312 ret->depth = 0; in xmlNewCatalogEntry()
313 ret->group = group; in xmlNewCatalogEntry()
322 * @payload: a Catalog entry
324 * Free the memory allocated to a Catalog entry
335 if (ret->dealloc == 1) in xmlFreeCatalogEntry()
339 if (ret->name != NULL) in xmlFreeCatalogEntry()
341 "Free catalog entry %s\n", ret->name); in xmlFreeCatalogEntry()
342 else if (ret->value != NULL) in xmlFreeCatalogEntry()
344 "Free catalog entry %s\n", ret->value); in xmlFreeCatalogEntry()
347 "Free catalog entry\n"); in xmlFreeCatalogEntry()
350 if (ret->name != NULL) in xmlFreeCatalogEntry()
351 xmlFree(ret->name); in xmlFreeCatalogEntry()
352 if (ret->value != NULL) in xmlFreeCatalogEntry()
353 xmlFree(ret->value); in xmlFreeCatalogEntry()
354 if (ret->URL != NULL) in xmlFreeCatalogEntry()
355 xmlFree(ret->URL); in xmlFreeCatalogEntry()
361 * @ret: a Catalog entry list
363 * Free the memory allocated to a full chained list of Catalog entries
370 next = ret->next; in xmlFreeCatalogEntryList()
378 * @payload: a Catalog entry list
380 * Free the memory allocated to list of Catalog entries from the
381 * catalog file hash.
392 children = catal->children; in xmlFreeCatalogHashEntryList()
394 next = children->next; in xmlFreeCatalogHashEntryList()
395 children->dealloc = 0; in xmlFreeCatalogHashEntryList()
396 children->children = NULL; in xmlFreeCatalogHashEntryList()
400 catal->dealloc = 0; in xmlFreeCatalogHashEntryList()
406 * @type: type of catalog
409 * create a new Catalog, this type is shared both by XML and
420 xmlCatalogErrMemory("allocating catalog"); in xmlCreateNewCatalog()
424 ret->type = type; in xmlCreateNewCatalog()
425 ret->catalNr = 0; in xmlCreateNewCatalog()
426 ret->catalMax = XML_MAX_SGML_CATA_DEPTH; in xmlCreateNewCatalog()
427 ret->prefer = prefer; in xmlCreateNewCatalog()
428 if (ret->type == XML_SGML_CATALOG_TYPE) in xmlCreateNewCatalog()
429 ret->sgml = xmlHashCreate(10); in xmlCreateNewCatalog()
435 * @catal: a Catalog
437 * Free the memory allocated to a Catalog
443 if (catal->xml != NULL) in xmlFreeCatalog()
444 xmlFreeCatalogEntryList(catal->xml); in xmlFreeCatalog()
445 if (catal->sgml != NULL) in xmlFreeCatalog()
446 xmlHashFree(catal->sgml, xmlFreeCatalogEntry); in xmlFreeCatalog()
459 * @entry: the catalog entry
462 * Serialize an SGML Catalog entry
471 switch (entry->type) { in xmlCatalogDumpEntry()
491 fprintf(out, "CATALOG "); break; in xmlCatalogDumpEntry()
499 switch (entry->type) { in xmlCatalogDumpEntry()
505 fprintf(out, "%s", (const char *) entry->name); break; in xmlCatalogDumpEntry()
513 fprintf(out, "\"%s\"", entry->name); break; in xmlCatalogDumpEntry()
517 switch (entry->type) { in xmlCatalogDumpEntry()
526 fprintf(out, " \"%s\"", entry->value); break; in xmlCatalogDumpEntry()
535 * @catal: top catalog entry
536 * @catalog: pointer to the xml tree
541 * Serializes a Catalog entry, called by xmlDumpXMLCatalog and recursively
544 static void xmlDumpXMLCatalogNode(xmlCatalogEntryPtr catal, xmlNodePtr catalog, in xmlDumpXMLCatalogNode() argument
549 * add all the catalog entries in xmlDumpXMLCatalogNode()
553 if (cur->group == cgroup) { in xmlDumpXMLCatalogNode()
554 switch (cur->type) { in xmlDumpXMLCatalogNode()
560 cur = cur->children; in xmlDumpXMLCatalogNode()
566 xmlSetProp(node, BAD_CAST "catalog", cur->value); in xmlDumpXMLCatalogNode()
567 xmlAddChild(catalog, node); in xmlDumpXMLCatalogNode()
573 xmlSetProp(node, BAD_CAST "id", cur->name); in xmlDumpXMLCatalogNode()
574 if (cur->value != NULL) { in xmlDumpXMLCatalogNode()
579 cur->value); in xmlDumpXMLCatalogNode()
581 switch (cur->prefer) { in xmlDumpXMLCatalogNode()
591 xmlDumpXMLCatalogNode(cur->next, node, doc, ns, cur); in xmlDumpXMLCatalogNode()
592 xmlAddChild(catalog, node); in xmlDumpXMLCatalogNode()
596 xmlSetProp(node, BAD_CAST "publicId", cur->name); in xmlDumpXMLCatalogNode()
597 xmlSetProp(node, BAD_CAST "uri", cur->value); in xmlDumpXMLCatalogNode()
598 xmlAddChild(catalog, node); in xmlDumpXMLCatalogNode()
602 xmlSetProp(node, BAD_CAST "systemId", cur->name); in xmlDumpXMLCatalogNode()
603 xmlSetProp(node, BAD_CAST "uri", cur->value); in xmlDumpXMLCatalogNode()
604 xmlAddChild(catalog, node); in xmlDumpXMLCatalogNode()
608 xmlSetProp(node, BAD_CAST "systemIdStartString", cur->name); in xmlDumpXMLCatalogNode()
609 xmlSetProp(node, BAD_CAST "rewritePrefix", cur->value); in xmlDumpXMLCatalogNode()
610 xmlAddChild(catalog, node); in xmlDumpXMLCatalogNode()
614 xmlSetProp(node, BAD_CAST "publicIdStartString", cur->name); in xmlDumpXMLCatalogNode()
615 xmlSetProp(node, BAD_CAST "catalog", cur->value); in xmlDumpXMLCatalogNode()
616 xmlAddChild(catalog, node); in xmlDumpXMLCatalogNode()
620 xmlSetProp(node, BAD_CAST "systemIdStartString", cur->name); in xmlDumpXMLCatalogNode()
621 xmlSetProp(node, BAD_CAST "catalog", cur->value); in xmlDumpXMLCatalogNode()
622 xmlAddChild(catalog, node); in xmlDumpXMLCatalogNode()
626 xmlSetProp(node, BAD_CAST "name", cur->name); in xmlDumpXMLCatalogNode()
627 xmlSetProp(node, BAD_CAST "uri", cur->value); in xmlDumpXMLCatalogNode()
628 xmlAddChild(catalog, node); in xmlDumpXMLCatalogNode()
632 xmlSetProp(node, BAD_CAST "uriStartString", cur->name); in xmlDumpXMLCatalogNode()
633 xmlSetProp(node, BAD_CAST "rewritePrefix", cur->value); in xmlDumpXMLCatalogNode()
634 xmlAddChild(catalog, node); in xmlDumpXMLCatalogNode()
638 xmlSetProp(node, BAD_CAST "uriStartString", cur->name); in xmlDumpXMLCatalogNode()
639 xmlSetProp(node, BAD_CAST "catalog", cur->value); in xmlDumpXMLCatalogNode()
640 xmlAddChild(catalog, node); in xmlDumpXMLCatalogNode()
657 cur = cur->next; in xmlDumpXMLCatalogNode()
667 xmlNodePtr catalog; in xmlDumpXMLCatalog() local
671 * Rebuild a catalog in xmlDumpXMLCatalog()
675 return(-1); in xmlDumpXMLCatalog()
676 dtd = xmlNewDtd(doc, BAD_CAST "catalog", in xmlDumpXMLCatalog()
677 BAD_CAST "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN", in xmlDumpXMLCatalog()
678 BAD_CAST "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd"); in xmlDumpXMLCatalog()
685 return(-1); in xmlDumpXMLCatalog()
687 catalog = xmlNewDocNode(doc, ns, BAD_CAST "catalog", NULL); in xmlDumpXMLCatalog()
688 if (catalog == NULL) { in xmlDumpXMLCatalog()
691 return(-1); in xmlDumpXMLCatalog()
693 catalog->nsDef = ns; in xmlDumpXMLCatalog()
694 xmlAddChild((xmlNodePtr) doc, catalog); in xmlDumpXMLCatalog()
696 xmlDumpXMLCatalogNode(catal, catalog, doc, ns, NULL); in xmlDumpXMLCatalog()
704 return(-1); in xmlDumpXMLCatalog()
726 * @catal: pointer to the catalog being converted
728 * Convert one entry from the catalog
735 if ((entry == NULL) || (catal == NULL) || (catal->sgml == NULL) || in xmlCatalogConvertEntry()
736 (catal->xml == NULL)) in xmlCatalogConvertEntry()
738 switch (entry->type) { in xmlCatalogConvertEntry()
740 entry->type = XML_CATA_PUBLIC; in xmlCatalogConvertEntry()
743 entry->type = XML_CATA_PUBLIC; in xmlCatalogConvertEntry()
746 entry->type = XML_CATA_PUBLIC; in xmlCatalogConvertEntry()
749 entry->type = XML_CATA_PUBLIC; in xmlCatalogConvertEntry()
752 entry->type = XML_CATA_PUBLIC; in xmlCatalogConvertEntry()
755 entry->type = XML_CATA_PUBLIC; in xmlCatalogConvertEntry()
758 entry->type = XML_CATA_SYSTEM; in xmlCatalogConvertEntry()
761 entry->type = XML_CATA_DELEGATE_PUBLIC; in xmlCatalogConvertEntry()
764 entry->type = XML_CATA_CATALOG; in xmlCatalogConvertEntry()
767 xmlHashRemoveEntry(catal->sgml, entry->name, xmlFreeCatalogEntry); in xmlCatalogConvertEntry()
771 * Conversion successful, remove from the SGML catalog in xmlCatalogConvertEntry()
774 xmlHashRemoveEntry(catal->sgml, entry->name, NULL); in xmlCatalogConvertEntry()
775 entry->parent = catal->xml; in xmlCatalogConvertEntry()
776 entry->next = NULL; in xmlCatalogConvertEntry()
777 if (catal->xml->children == NULL) in xmlCatalogConvertEntry()
778 catal->xml->children = entry; in xmlCatalogConvertEntry()
782 prev = catal->xml->children; in xmlCatalogConvertEntry()
783 while (prev->next != NULL) in xmlCatalogConvertEntry()
784 prev = prev->next; in xmlCatalogConvertEntry()
785 prev->next = entry; in xmlCatalogConvertEntry()
791 * @catal: the catalog
793 * Convert all the SGML catalog entries as XML ones
795 * Returns the number of entries converted if successful, -1 otherwise
800 if ((catal == NULL) || (catal->type != XML_SGML_CATALOG_TYPE)) in xmlConvertSGMLCatalog()
801 return(-1); in xmlConvertSGMLCatalog()
805 "Converting SGML catalog to XML\n"); in xmlConvertSGMLCatalog()
807 xmlHashScan(catal->sgml, xmlCatalogConvertEntry, &catal); in xmlConvertSGMLCatalog()
831 if (xmlStrncmp(urn, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) in xmlCatalogUnWrapURN()
833 urn += sizeof(XML_URN_PUBID) - 1; in xmlCatalogUnWrapURN()
836 if (i > sizeof(result) - 4) in xmlCatalogUnWrapURN()
887 * except it bypass all catalog lookups.
922 inputStream->filename = (char *) xmlCanonicPath((const xmlChar *)filename); in xmlParseCatalogFile()
923 inputStream->buf = buf; in xmlParseCatalogFile()
924 xmlBufResetInput(buf->buffer, inputStream); in xmlParseCatalogFile()
927 if (ctxt->directory == NULL) in xmlParseCatalogFile()
929 if ((ctxt->directory == NULL) && (directory != NULL)) in xmlParseCatalogFile()
930 ctxt->directory = directory; in xmlParseCatalogFile()
931 ctxt->valid = 0; in xmlParseCatalogFile()
932 ctxt->validate = 0; in xmlParseCatalogFile()
933 ctxt->loadsubset = 0; in xmlParseCatalogFile()
934 ctxt->pedantic = 0; in xmlParseCatalogFile()
935 ctxt->dictNames = 1; in xmlParseCatalogFile()
939 if (ctxt->wellFormed) in xmlParseCatalogFile()
940 ret = ctxt->myDoc; in xmlParseCatalogFile()
943 xmlFreeDoc(ctxt->myDoc); in xmlParseCatalogFile()
944 ctxt->myDoc = NULL; in xmlParseCatalogFile()
1001 xmlCatalogErrMemory("allocating catalog data"); in xmlLoadFileContent()
1032 * from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html
1082 * The XML Catalog parser *
1102 * lookup the internal type associated to an XML catalog entry name
1127 else if (xmlStrEqual(name, (const xmlChar *) "catalog")) in xmlGetXMLCatalogEntryType()
1135 * @type: the type of Catalog entry
1138 * @uriAttrName: the attribute holding the URI-Reference
1142 * Finishes the examination of an XML tree node of a catalog and build
1143 * a Catalog entry from it.
1145 * Returns the new Catalog entry node or NULL in case of error.
1181 base = xmlNodeGetBase(cur->doc, cur); in xmlParseXMLCatalogOneNode()
1212 * @parent: the parent Catalog entry
1215 * Examines an XML tree node of a catalog and build
1216 * a Catalog entry from it adding it to its parent. The examination can
1228 if (xmlStrEqual(cur->name, BAD_CAST "group")) { in xmlParseXMLCatalogNode()
1250 } else if (xmlStrEqual(cur->name, BAD_CAST "public")) { in xmlParseXMLCatalogNode()
1253 } else if (xmlStrEqual(cur->name, BAD_CAST "system")) { in xmlParseXMLCatalogNode()
1256 } else if (xmlStrEqual(cur->name, BAD_CAST "rewriteSystem")) { in xmlParseXMLCatalogNode()
1260 } else if (xmlStrEqual(cur->name, BAD_CAST "delegatePublic")) { in xmlParseXMLCatalogNode()
1263 BAD_CAST "catalog", prefer, cgroup); in xmlParseXMLCatalogNode()
1264 } else if (xmlStrEqual(cur->name, BAD_CAST "delegateSystem")) { in xmlParseXMLCatalogNode()
1267 BAD_CAST "catalog", prefer, cgroup); in xmlParseXMLCatalogNode()
1268 } else if (xmlStrEqual(cur->name, BAD_CAST "uri")) { in xmlParseXMLCatalogNode()
1272 } else if (xmlStrEqual(cur->name, BAD_CAST "rewriteURI")) { in xmlParseXMLCatalogNode()
1276 } else if (xmlStrEqual(cur->name, BAD_CAST "delegateURI")) { in xmlParseXMLCatalogNode()
1279 BAD_CAST "catalog", prefer, cgroup); in xmlParseXMLCatalogNode()
1280 } else if (xmlStrEqual(cur->name, BAD_CAST "nextCatalog")) { in xmlParseXMLCatalogNode()
1283 BAD_CAST "catalog", prefer, cgroup); in xmlParseXMLCatalogNode()
1287 entry->parent = parent; in xmlParseXMLCatalogNode()
1288 if (parent->children == NULL) in xmlParseXMLCatalogNode()
1289 parent->children = entry; in xmlParseXMLCatalogNode()
1293 prev = parent->children; in xmlParseXMLCatalogNode()
1294 while (prev->next != NULL) in xmlParseXMLCatalogNode()
1295 prev = prev->next; in xmlParseXMLCatalogNode()
1296 prev->next = entry; in xmlParseXMLCatalogNode()
1299 if (entry->type == XML_CATA_GROUP) { in xmlParseXMLCatalogNode()
1304 xmlParseXMLCatalogNodeList(cur->children, prefer, parent, entry); in xmlParseXMLCatalogNode()
1315 * @parent: the parent Catalog entry
1318 * Examines a list of XML sibling nodes of a catalog and build
1319 * a list of Catalog entry from it adding it to the parent.
1326 if ((cur->ns != NULL) && (cur->ns->href != NULL) && in xmlParseXMLCatalogNodeList()
1327 (xmlStrEqual(cur->ns->href, XML_CATALOGS_NAMESPACE))) { in xmlParseXMLCatalogNodeList()
1330 cur = cur->next; in xmlParseXMLCatalogNodeList()
1338 * @filename: the filename for the catalog
1340 * Parses the catalog file to extract the XML tree and then analyze the
1341 * tree to build a list of Catalog entries corresponding to this catalog
1343 * Returns the resulting Catalog entries list
1359 "Failed to parse catalog %s\n", filename); in xmlParseXMLCatalogFile()
1365 "%d Parsing catalog %s\n", xmlGetThreadId(), filename); in xmlParseXMLCatalogFile()
1368 if ((cur != NULL) && (xmlStrEqual(cur->name, BAD_CAST "catalog")) && in xmlParseXMLCatalogFile()
1369 (cur->ns != NULL) && (cur->ns->href != NULL) && in xmlParseXMLCatalogFile()
1370 (xmlStrEqual(cur->ns->href, XML_CATALOGS_NAMESPACE))) { in xmlParseXMLCatalogFile()
1392 cur = cur->children; in xmlParseXMLCatalogFile()
1396 "File %s is not an XML Catalog\n", in xmlParseXMLCatalogFile()
1407 * @catal: an existing but incomplete catalog entry
1411 * Returns 0 in case of success, -1 otherwise
1418 return(-1); in xmlFetchXMLCatalogFile()
1419 if (catal->URL == NULL) in xmlFetchXMLCatalogFile()
1420 return(-1); in xmlFetchXMLCatalogFile()
1423 * lock the whole catalog for modification in xmlFetchXMLCatalogFile()
1426 if (catal->children != NULL) { in xmlFetchXMLCatalogFile()
1434 xmlHashLookup(xmlCatalogXMLFiles, catal->URL); in xmlFetchXMLCatalogFile()
1438 "Found %s in file hash\n", catal->URL); in xmlFetchXMLCatalogFile()
1440 if (catal->type == XML_CATA_CATALOG) in xmlFetchXMLCatalogFile()
1441 catal->children = doc->children; in xmlFetchXMLCatalogFile()
1443 catal->children = doc; in xmlFetchXMLCatalogFile()
1444 catal->dealloc = 0; in xmlFetchXMLCatalogFile()
1450 "%s not found in file hash\n", catal->URL); in xmlFetchXMLCatalogFile()
1455 * use the existing catalog, there is no recursion allowed at in xmlFetchXMLCatalogFile()
1458 doc = xmlParseXMLCatalogFile(catal->prefer, catal->URL); in xmlFetchXMLCatalogFile()
1460 catal->type = XML_CATA_BROKEN_CATALOG; in xmlFetchXMLCatalogFile()
1462 return(-1); in xmlFetchXMLCatalogFile()
1465 if (catal->type == XML_CATA_CATALOG) in xmlFetchXMLCatalogFile()
1466 catal->children = doc->children; in xmlFetchXMLCatalogFile()
1468 catal->children = doc; in xmlFetchXMLCatalogFile()
1470 doc->dealloc = 1; in xmlFetchXMLCatalogFile()
1477 "%s added to file hash\n", catal->URL); in xmlFetchXMLCatalogFile()
1478 xmlHashAddEntry(xmlCatalogXMLFiles, catal->URL, doc); in xmlFetchXMLCatalogFile()
1486 * XML Catalog handling *
1492 * @catal: top of an XML catalog
1493 * @type: the type of record to add to the catalog
1497 * Add an entry in the XML catalog, it may overwrite existing but
1500 * Returns 0 if successful, -1 otherwise
1510 ((catal->type != XML_CATA_CATALOG) && in xmlAddXMLCatalog()
1511 (catal->type != XML_CATA_BROKEN_CATALOG))) in xmlAddXMLCatalog()
1512 return(-1); in xmlAddXMLCatalog()
1513 if (catal->children == NULL) { in xmlAddXMLCatalog()
1516 if (catal->children == NULL) in xmlAddXMLCatalog()
1523 "Failed to add unknown element %s to catalog\n", type); in xmlAddXMLCatalog()
1524 return(-1); in xmlAddXMLCatalog()
1527 cur = catal->children; in xmlAddXMLCatalog()
1533 if ((orig != NULL) && (cur->type == typ) && in xmlAddXMLCatalog()
1534 (xmlStrEqual(orig, cur->name))) { in xmlAddXMLCatalog()
1537 "Updating element %s to catalog\n", type); in xmlAddXMLCatalog()
1538 if (cur->value != NULL) in xmlAddXMLCatalog()
1539 xmlFree(cur->value); in xmlAddXMLCatalog()
1540 if (cur->URL != NULL) in xmlAddXMLCatalog()
1541 xmlFree(cur->URL); in xmlAddXMLCatalog()
1542 cur->value = xmlStrdup(replace); in xmlAddXMLCatalog()
1543 cur->URL = xmlStrdup(replace); in xmlAddXMLCatalog()
1546 if (cur->next == NULL) in xmlAddXMLCatalog()
1548 cur = cur->next; in xmlAddXMLCatalog()
1553 "Adding element %s to catalog\n", type); in xmlAddXMLCatalog()
1555 catal->children = xmlNewCatalogEntry(typ, orig, replace, in xmlAddXMLCatalog()
1556 NULL, catal->prefer, NULL); in xmlAddXMLCatalog()
1558 cur->next = xmlNewCatalogEntry(typ, orig, replace, in xmlAddXMLCatalog()
1559 NULL, catal->prefer, NULL); in xmlAddXMLCatalog()
1561 catal->type = XML_CATA_CATALOG; in xmlAddXMLCatalog()
1562 cur = (xmlCatalogEntryPtr)xmlHashLookup(xmlCatalogXMLFiles, catal->URL); in xmlAddXMLCatalog()
1564 cur->children = catal->children; in xmlAddXMLCatalog()
1572 * @catal: top of an XML catalog
1573 * @value: the value to remove from the catalog
1575 * Remove entries in the XML catalog where the value or the URI
1578 * Returns the number of entries removed if successful, -1 otherwise
1586 ((catal->type != XML_CATA_CATALOG) && in xmlDelXMLCatalog()
1587 (catal->type != XML_CATA_BROKEN_CATALOG))) in xmlDelXMLCatalog()
1588 return(-1); in xmlDelXMLCatalog()
1590 return(-1); in xmlDelXMLCatalog()
1591 if (catal->children == NULL) { in xmlDelXMLCatalog()
1598 cur = catal->children; in xmlDelXMLCatalog()
1600 if (((cur->name != NULL) && (xmlStrEqual(value, cur->name))) || in xmlDelXMLCatalog()
1601 (xmlStrEqual(value, cur->value))) { in xmlDelXMLCatalog()
1603 if (cur->name != NULL) in xmlDelXMLCatalog()
1605 "Removing element %s from catalog\n", cur->name); in xmlDelXMLCatalog()
1608 "Removing element %s from catalog\n", cur->value); in xmlDelXMLCatalog()
1610 cur->type = XML_CATA_REMOVED; in xmlDelXMLCatalog()
1612 cur = cur->next; in xmlDelXMLCatalog()
1619 * @catal: a catalog list
1624 * list of catalog entries.
1627 * from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html
1642 if (catal->depth > MAX_CATAL_DEPTH) { in xmlCatalogXMLResolve()
1644 "Detected recursion in catalog %s\n", in xmlCatalogXMLResolve()
1645 catal->name, NULL, NULL); in xmlCatalogXMLResolve()
1648 catal->depth++; in xmlCatalogXMLResolve()
1659 switch (cur->type) { in xmlCatalogXMLResolve()
1661 if (xmlStrEqual(sysID, cur->name)) { in xmlCatalogXMLResolve()
1665 cur->name, cur->URL); in xmlCatalogXMLResolve()
1666 catal->depth--; in xmlCatalogXMLResolve()
1667 return(xmlStrdup(cur->URL)); in xmlCatalogXMLResolve()
1671 len = xmlStrlen(cur->name); in xmlCatalogXMLResolve()
1673 (!xmlStrncmp(sysID, cur->name, len))) { in xmlCatalogXMLResolve()
1679 if (!xmlStrncmp(sysID, cur->name, xmlStrlen(cur->name))) in xmlCatalogXMLResolve()
1688 cur = cur->next; in xmlCatalogXMLResolve()
1693 "Using rewriting rule %s\n", rewrite->name); in xmlCatalogXMLResolve()
1694 ret = xmlStrdup(rewrite->URL); in xmlCatalogXMLResolve()
1697 catal->depth--; in xmlCatalogXMLResolve()
1710 if ((cur->type == XML_CATA_DELEGATE_SYSTEM) && in xmlCatalogXMLResolve()
1711 (!xmlStrncmp(sysID, cur->name, xmlStrlen(cur->name)))) { in xmlCatalogXMLResolve()
1713 if (xmlStrEqual(cur->URL, delegates[i])) in xmlCatalogXMLResolve()
1716 cur = cur->next; in xmlCatalogXMLResolve()
1720 delegates[nbList++] = cur->URL; in xmlCatalogXMLResolve()
1722 if (cur->children == NULL) { in xmlCatalogXMLResolve()
1725 if (cur->children != NULL) { in xmlCatalogXMLResolve()
1728 "Trying system delegate %s\n", cur->URL); in xmlCatalogXMLResolve()
1730 cur->children, NULL, sysID); in xmlCatalogXMLResolve()
1732 catal->depth--; in xmlCatalogXMLResolve()
1737 cur = cur->next; in xmlCatalogXMLResolve()
1742 catal->depth--; in xmlCatalogXMLResolve()
1753 switch (cur->type) { in xmlCatalogXMLResolve()
1755 if (xmlStrEqual(pubID, cur->name)) { in xmlCatalogXMLResolve()
1758 "Found public match %s\n", cur->name); in xmlCatalogXMLResolve()
1759 catal->depth--; in xmlCatalogXMLResolve()
1760 return(xmlStrdup(cur->URL)); in xmlCatalogXMLResolve()
1764 if (!xmlStrncmp(pubID, cur->name, xmlStrlen(cur->name)) && in xmlCatalogXMLResolve()
1765 (cur->prefer == XML_CATA_PREFER_PUBLIC)) in xmlCatalogXMLResolve()
1775 cur = cur->next; in xmlCatalogXMLResolve()
1787 if ((cur->type == XML_CATA_DELEGATE_PUBLIC) && in xmlCatalogXMLResolve()
1788 (cur->prefer == XML_CATA_PREFER_PUBLIC) && in xmlCatalogXMLResolve()
1789 (!xmlStrncmp(pubID, cur->name, xmlStrlen(cur->name)))) { in xmlCatalogXMLResolve()
1792 if (xmlStrEqual(cur->URL, delegates[i])) in xmlCatalogXMLResolve()
1795 cur = cur->next; in xmlCatalogXMLResolve()
1799 delegates[nbList++] = cur->URL; in xmlCatalogXMLResolve()
1801 if (cur->children == NULL) { in xmlCatalogXMLResolve()
1804 if (cur->children != NULL) { in xmlCatalogXMLResolve()
1807 "Trying public delegate %s\n", cur->URL); in xmlCatalogXMLResolve()
1809 cur->children, pubID, NULL); in xmlCatalogXMLResolve()
1811 catal->depth--; in xmlCatalogXMLResolve()
1816 cur = cur->next; in xmlCatalogXMLResolve()
1821 catal->depth--; in xmlCatalogXMLResolve()
1828 if (cur->type == XML_CATA_NEXT_CATALOG) { in xmlCatalogXMLResolve()
1829 if (cur->children == NULL) { in xmlCatalogXMLResolve()
1832 if (cur->children != NULL) { in xmlCatalogXMLResolve()
1833 ret = xmlCatalogListXMLResolve(cur->children, pubID, sysID); in xmlCatalogXMLResolve()
1835 catal->depth--; in xmlCatalogXMLResolve()
1837 } else if (catal->depth > MAX_CATAL_DEPTH) { in xmlCatalogXMLResolve()
1842 cur = cur->next; in xmlCatalogXMLResolve()
1846 catal->depth--; in xmlCatalogXMLResolve()
1852 * @catal: a catalog list
1857 * list of catalog entries.
1860 * from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html
1879 if (catal->depth > MAX_CATAL_DEPTH) { in xmlCatalogXMLResolveURI()
1881 "Detected recursion in catalog %s\n", in xmlCatalogXMLResolveURI()
1882 catal->name, NULL, NULL); in xmlCatalogXMLResolveURI()
1892 switch (cur->type) { in xmlCatalogXMLResolveURI()
1894 if (xmlStrEqual(URI, cur->name)) { in xmlCatalogXMLResolveURI()
1897 "Found URI match %s\n", cur->name); in xmlCatalogXMLResolveURI()
1898 return(xmlStrdup(cur->URL)); in xmlCatalogXMLResolveURI()
1902 len = xmlStrlen(cur->name); in xmlCatalogXMLResolveURI()
1904 (!xmlStrncmp(URI, cur->name, len))) { in xmlCatalogXMLResolveURI()
1910 if (!xmlStrncmp(URI, cur->name, xmlStrlen(cur->name))) in xmlCatalogXMLResolveURI()
1919 cur = cur->next; in xmlCatalogXMLResolveURI()
1924 "Using rewriting rule %s\n", rewrite->name); in xmlCatalogXMLResolveURI()
1925 ret = xmlStrdup(rewrite->URL); in xmlCatalogXMLResolveURI()
1940 if (((cur->type == XML_CATA_DELEGATE_SYSTEM) || in xmlCatalogXMLResolveURI()
1941 (cur->type == XML_CATA_DELEGATE_URI)) && in xmlCatalogXMLResolveURI()
1942 (!xmlStrncmp(URI, cur->name, xmlStrlen(cur->name)))) { in xmlCatalogXMLResolveURI()
1944 if (xmlStrEqual(cur->URL, delegates[i])) in xmlCatalogXMLResolveURI()
1947 cur = cur->next; in xmlCatalogXMLResolveURI()
1951 delegates[nbList++] = cur->URL; in xmlCatalogXMLResolveURI()
1953 if (cur->children == NULL) { in xmlCatalogXMLResolveURI()
1956 if (cur->children != NULL) { in xmlCatalogXMLResolveURI()
1959 "Trying URI delegate %s\n", cur->URL); in xmlCatalogXMLResolveURI()
1961 cur->children, URI); in xmlCatalogXMLResolveURI()
1966 cur = cur->next; in xmlCatalogXMLResolveURI()
1976 if (cur->type == XML_CATA_NEXT_CATALOG) { in xmlCatalogXMLResolveURI()
1977 if (cur->children == NULL) { in xmlCatalogXMLResolveURI()
1980 if (cur->children != NULL) { in xmlCatalogXMLResolveURI()
1981 ret = xmlCatalogListXMLResolveURI(cur->children, URI); in xmlCatalogXMLResolveURI()
1986 cur = cur->next; in xmlCatalogXMLResolveURI()
1995 * @catal: a catalog list
2003 * from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html
2023 if (!xmlStrncmp(pubID, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) { in xmlCatalogListXMLResolve()
2040 if (!xmlStrncmp(sysID, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) { in xmlCatalogListXMLResolve()
2064 if (catal->type == XML_CATA_CATALOG) { in xmlCatalogListXMLResolve()
2065 if (catal->children == NULL) { in xmlCatalogListXMLResolve()
2068 if (catal->children != NULL) { in xmlCatalogListXMLResolve()
2069 ret = xmlCatalogXMLResolve(catal->children, pubID, sysID); in xmlCatalogListXMLResolve()
2072 } else if (catal->children->depth > MAX_CATAL_DEPTH) { in xmlCatalogListXMLResolve()
2078 catal = catal->next; in xmlCatalogListXMLResolve()
2087 * @catal: a catalog list
2093 * from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html
2107 if (!xmlStrncmp(URI, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) { in xmlCatalogListXMLResolveURI()
2123 if (catal->type == XML_CATA_CATALOG) { in xmlCatalogListXMLResolveURI()
2124 if (catal->children == NULL) { in xmlCatalogListXMLResolveURI()
2127 if (catal->children != NULL) { in xmlCatalogListXMLResolveURI()
2128 ret = xmlCatalogXMLResolveURI(catal->children, URI); in xmlCatalogListXMLResolveURI()
2133 catal = catal->next; in xmlCatalogListXMLResolveURI()
2140 * The SGML Catalog parser *
2155 * Skip a comment in an SGML catalog
2161 if ((cur[0] != '-') || (cur[1] != '-')) in xmlParseSGMLCatalogComment()
2164 while ((cur[0] != 0) && ((cur[0] != '-') || ((cur[1] != '-')))) in xmlParseSGMLCatalogComment()
2177 * Parse an SGML catalog ID
2246 * Parse an SGML catalog name
2267 (c == '.') || (c == '-') || in xmlParseSGMLCatalogName()
2283 * Get the Catalog entry type for a given SGML Catalog name
2285 * Returns Catalog entry type
2308 else if (xmlStrEqual(name, (const xmlChar *) "CATALOG")) in xmlGetSGMLCatalogEntryType()
2317 * @catal: the SGML Catalog
2318 * @value: the content of the SGML Catalog serialization
2319 * @file: the filepath for the catalog
2320 * @super: should this be handled as a Super Catalog in which case
2323 * Parse an SGML catalog content and fill up the @catal hash table with
2326 * Returns 0 in case of success, -1 in case of error.
2336 return(-1); in xmlParseSGMLCatalog()
2343 if ((cur[0] == '-') && (cur[1] == '-')) { in xmlParseSGMLCatalog()
2382 else if (xmlStrEqual(name, (const xmlChar *) "CATALOG")) in xmlParseSGMLCatalog()
2491 res = xmlHashAddEntry(catal->sgml, name, entry); in xmlParseSGMLCatalog()
2504 res = xmlHashAddEntry(catal->sgml, sysid, entry); in xmlParseSGMLCatalog()
2530 return(-1); in xmlParseSGMLCatalog()
2536 * SGML Catalog handling *
2542 * @catal: an SGML catalog hash
2545 * Try to lookup the catalog local reference associated to a public ID
2567 if (entry->type == SGML_CATA_PUBLIC) { in xmlCatalogGetSGMLPublic()
2570 return(entry->URL); in xmlCatalogGetSGMLPublic()
2579 * @catal: an SGML catalog hash
2582 * Try to lookup the catalog local reference for a system ID
2596 if (entry->type == SGML_CATA_SYSTEM) in xmlCatalogGetSGMLSystem()
2597 return(entry->URL); in xmlCatalogGetSGMLSystem()
2603 * @catal: the SGML catalog
2616 if (catal->sgml == NULL) in xmlCatalogSGMLResolve()
2620 ret = xmlCatalogGetSGMLPublic(catal->sgml, pubID); in xmlCatalogSGMLResolve()
2624 ret = xmlCatalogGetSGMLSystem(catal->sgml, sysID); in xmlCatalogSGMLResolve()
2640 * Load an SGML super catalog. It won't expand CATALOG or DELEGATE
2642 * like adding and removing CATALOG or DELEGATE entries.
2644 * Returns the catalog parsed or NULL in case of error
2676 * Load the catalog and build the associated data structures.
2677 * This can be either an XML Catalog or an SGML Catalog
2678 * It will recurse in SGML CATALOG entries. On the other hand XML
2681 * Returns the catalog parsed or NULL in case of error
2698 while ((*first != 0) && (*first != '-') && (*first != '<') && in xmlLoadACatalog()
2721 catal->xml = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, in xmlLoadACatalog()
2730 * @catal: a catalog
2733 * Load the catalog and expand the existing catal structure.
2734 * This can be either an XML Catalog or an SGML Catalog
2736 * Returns 0 in case of success, -1 in case of error
2744 return(-1); in xmlExpandCatalog()
2747 if (catal->type == XML_SGML_CATALOG_TYPE) { in xmlExpandCatalog()
2752 return(-1); in xmlExpandCatalog()
2757 return(-1); in xmlExpandCatalog()
2765 cur = catal->xml; in xmlExpandCatalog()
2767 catal->xml = tmp; in xmlExpandCatalog()
2769 while (cur->next != NULL) cur = cur->next; in xmlExpandCatalog()
2770 cur->next = tmp; in xmlExpandCatalog()
2778 * @catal: a Catalog
2781 * Try to lookup the catalog resource for a system ID
2797 if (catal->type == XML_XML_CATALOG_TYPE) { in xmlACatalogResolveSystem()
2798 ret = xmlCatalogListXMLResolve(catal->xml, NULL, sysID); in xmlACatalogResolveSystem()
2804 sgml = xmlCatalogGetSGMLSystem(catal->sgml, sysID); in xmlACatalogResolveSystem()
2813 * @catal: a Catalog
2816 * Try to lookup the catalog local reference associated to a public ID in that catalog
2832 if (catal->type == XML_XML_CATALOG_TYPE) { in xmlACatalogResolvePublic()
2833 ret = xmlCatalogListXMLResolve(catal->xml, pubID, NULL); in xmlACatalogResolvePublic()
2839 sgml = xmlCatalogGetSGMLPublic(catal->sgml, pubID); in xmlACatalogResolvePublic()
2848 * @catal: a Catalog
2879 if (catal->type == XML_XML_CATALOG_TYPE) { in xmlACatalogResolve()
2880 ret = xmlCatalogListXMLResolve(catal->xml, pubID, sysID); in xmlACatalogResolve()
2895 * @catal: a Catalog
2914 if (catal->type == XML_XML_CATALOG_TYPE) { in xmlACatalogResolveURI()
2915 ret = xmlCatalogListXMLResolveURI(catal->xml, URI); in xmlACatalogResolveURI()
2931 * @catal: a Catalog
2934 * Dump the given catalog to the given file.
2941 if (catal->type == XML_XML_CATALOG_TYPE) { in xmlACatalogDump()
2942 xmlDumpXMLCatalog(out, catal->xml); in xmlACatalogDump()
2944 xmlHashScan(catal->sgml, xmlCatalogDumpEntry, out); in xmlACatalogDump()
2951 * @catal: a Catalog
2952 * @type: the type of record to add to the catalog
2956 * Add an entry in the catalog, it may overwrite existing but
2959 * Returns 0 if successful, -1 otherwise
2965 int res = -1; in xmlACatalogAdd()
2968 return(-1); in xmlACatalogAdd()
2970 if (catal->type == XML_XML_CATALOG_TYPE) { in xmlACatalogAdd()
2971 res = xmlAddXMLCatalog(catal->xml, type, orig, replace); in xmlACatalogAdd()
2981 if (catal->sgml == NULL) in xmlACatalogAdd()
2982 catal->sgml = xmlHashCreate(10); in xmlACatalogAdd()
2983 res = xmlHashAddEntry(catal->sgml, orig, entry); in xmlACatalogAdd()
2991 * @catal: a Catalog
2994 * Remove an entry from the catalog
2996 * Returns the number of entries removed if successful, -1 otherwise
3000 int res = -1; in xmlACatalogRemove()
3003 return(-1); in xmlACatalogRemove()
3005 if (catal->type == XML_XML_CATALOG_TYPE) { in xmlACatalogRemove()
3006 res = xmlDelXMLCatalog(catal->xml, value); in xmlACatalogRemove()
3008 res = xmlHashRemoveEntry(catal->sgml, value, xmlFreeCatalogEntry); in xmlACatalogRemove()
3017 * @sgml: should this create an SGML catalog
3019 * create a new Catalog.
3030 if ((catal != NULL) && (catal->sgml == NULL)) in xmlNewCatalog()
3031 catal->sgml = xmlHashCreate(10); in xmlNewCatalog()
3040 * @catal: should this create an SGML catalog
3042 * Check is a catalog is empty
3044 * Returns 1 if the catalog is empty, 0 if not, amd -1 in case of error.
3049 return(-1); in xmlCatalogIsEmpty()
3051 if (catal->type == XML_XML_CATALOG_TYPE) { in xmlCatalogIsEmpty()
3052 if (catal->xml == NULL) in xmlCatalogIsEmpty()
3054 if ((catal->xml->type != XML_CATA_CATALOG) && in xmlCatalogIsEmpty()
3055 (catal->xml->type != XML_CATA_BROKEN_CATALOG)) in xmlCatalogIsEmpty()
3056 return(-1); in xmlCatalogIsEmpty()
3057 if (catal->xml->children == NULL) in xmlCatalogIsEmpty()
3063 if (catal->sgml == NULL) in xmlCatalogIsEmpty()
3065 res = xmlHashSize(catal->sgml); in xmlCatalogIsEmpty()
3069 return(-1); in xmlCatalogIsEmpty()
3076 * Public interfaces manipulating the global shared default catalog *
3083 * Do the catalog initialization only of global data, doesn't try to load
3084 * any catalog actually.
3085 * this function is not thread safe, catalog initialization should
3102 * Do the catalog initialization.
3103 * this function is not thread safe, catalog initialization should
3138 p--; in xmlInitializeCatalog()
3141 strncpy(p, "\\..\\etc\\catalog", 255 - (p - buf)); in xmlInitializeCatalog()
3160 space-separated list of entries. */ in xmlInitializeCatalog()
3162 nextent = &catal->xml; in xmlInitializeCatalog()
3170 path = (char *) xmlStrndup((const xmlChar *)paths, cur - paths); in xmlInitializeCatalog()
3175 nextent = &((*nextent)->next); in xmlInitializeCatalog()
3192 * Load the catalog and makes its definitions effective for the default
3193 * external entity loader. It will recurse in SGML CATALOG entries.
3194 * this function is not thread safe, catalog initialization should
3197 * Returns 0 in case of success -1 in case of error
3214 return(-1); in xmlLoadCatalog()
3233 * this function is not thread safe, catalog initialization should
3255 path = xmlStrndup((const xmlChar *)paths, cur - paths); in xmlLoadCatalogs()
3304 * Try to lookup the catalog resource for a system ID
3324 * Try to lookup the catalog reference associated to a public ID
3386 * Dump all the global catalog content to the given file.
3402 * @type: the type of record to add to the catalog
3406 * Add an entry in the catalog, it may overwrite existing but
3408 * If called before any other catalog routine, allows to override the
3409 * default shared catalog put in place by xmlInitializeCatalog();
3411 * Returns 0 if successful, -1 otherwise
3415 int res = -1; in xmlCatalogAdd()
3422 * Specific case where one want to override the default catalog in xmlCatalogAdd()
3426 (xmlStrEqual(type, BAD_CAST "catalog"))) { in xmlCatalogAdd()
3430 xmlDefaultCatalog->xml = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, in xmlCatalogAdd()
3446 * Remove an entry from the catalog
3448 * Returns the number of entries removed if successful, -1 otherwise
3466 * Convert all the SGML catalog entries as XML ones
3468 * Returns the number of entries converted if successful, -1 otherwise
3472 int res = -1; in xmlCatalogConvert()
3515 "Disabling catalog usage\n"); in xmlCatalogSetDefaults()
3539 * in XML Catalog resolution. C.f. section 4.1.1 of the spec
3555 "Setting catalog preference to PUBLIC\n"); in xmlCatalogSetDefaultPrefer()
3559 "Setting catalog preference to SYSTEM\n"); in xmlCatalogSetDefaultPrefer()
3573 * Used to set the debug level for catalog operation, 0 disable
3576 * Returns the previous value of the catalog debugging level
3591 * Minimal interfaces used for per-document catalogs by the parser *
3599 * Free up the memory associated to the catalog list
3617 * @URL: the URL to a new local catalog
3619 * Add the new entry to the catalog list
3635 "Adding document catalog %s\n", URL); in xmlCatalogAddLocal()
3646 while (catal->next != NULL) in xmlCatalogAddLocal()
3647 catal = catal->next; in xmlCatalogAddLocal()
3648 catal->next = add; in xmlCatalogAddLocal()
3659 * document's private catalog list
3704 * document's private catalog list
3742 * Try to lookup the catalog reference associated to a system ID
3769 ret = xmlCatalogListXMLResolve(xmlDefaultCatalog->xml, NULL, sysID); in xmlCatalogGetSystem()
3771 snprintf((char *) result, sizeof(result) - 1, "%s", (char *) ret); in xmlCatalogGetSystem()
3772 result[sizeof(result) - 1] = 0; in xmlCatalogGetSystem()
3778 return(xmlCatalogGetSGMLSystem(xmlDefaultCatalog->sgml, sysID)); in xmlCatalogGetSystem()
3786 * Try to lookup the catalog reference associated to a public ID
3813 ret = xmlCatalogListXMLResolve(xmlDefaultCatalog->xml, pubID, NULL); in xmlCatalogGetPublic()
3815 snprintf((char *) result, sizeof(result) - 1, "%s", (char *) ret); in xmlCatalogGetPublic()
3816 result[sizeof(result) - 1] = 0; in xmlCatalogGetPublic()
3822 return(xmlCatalogGetSGMLPublic(xmlDefaultCatalog->sgml, pubID)); in xmlCatalogGetPublic()