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

Function xmlLoadACatalog

ThirdParty/libxml2/vtklibxml2/catalog.c:2644–2687  ·  view source on GitHub ↗

* xmlLoadACatalog: * @filename: a file path * * Load the catalog and build the associated data structures. * This can be either an XML Catalog or an SGML Catalog * It will recurse in SGML CATALOG entries. On the other hand XML * Catalogs are not handled recursively. * * Returns the catalog parsed or NULL in case of error */

Source from the content-addressed store, hash-verified

2642 * Returns the catalog parsed or NULL in case of error
2643 */
2644xmlCatalogPtr
2645xmlLoadACatalog(const char *filename)
2646{
2647 xmlChar *content;
2648 xmlChar *first;
2649 xmlCatalogPtr catal;
2650 int ret;
2651
2652 content = xmlLoadFileContent(filename);
2653 if (content == NULL)
2654 return(NULL);
2655
2656
2657 first = content;
2658
2659 while ((*first != 0) && (*first != '-') && (*first != '<') &&
2660 (!(((*first >= 'A') && (*first <= 'Z')) ||
2661 ((*first >= 'a') && (*first <= 'z')))))
2662 first++;
2663
2664 if (*first != '<') {
2665 catal = xmlCreateNewCatalog(XML_SGML_CATALOG_TYPE, xmlCatalogDefaultPrefer);
2666 if (catal == NULL) {
2667 xmlFree(content);
2668 return(NULL);
2669 }
2670 ret = xmlParseSGMLCatalog(catal, content, filename, 0);
2671 if (ret < 0) {
2672 xmlFreeCatalog(catal);
2673 xmlFree(content);
2674 return(NULL);
2675 }
2676 } else {
2677 catal = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE, xmlCatalogDefaultPrefer);
2678 if (catal == NULL) {
2679 xmlFree(content);
2680 return(NULL);
2681 }
2682 catal->xml = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL,
2683 NULL, BAD_CAST filename, xmlCatalogDefaultPrefer, NULL);
2684 }
2685 xmlFree(content);
2686 return (catal);
2687}
2688
2689/**
2690 * xmlExpandCatalog:

Callers 1

xmlLoadCatalogFunction · 0.85

Calls 4

xmlLoadFileContentFunction · 0.85
xmlCreateNewCatalogFunction · 0.85
xmlParseSGMLCatalogFunction · 0.85
xmlFreeCatalogFunction · 0.85

Tested by

no test coverage detected