OLD | NEW |
1 /** | 1 /** |
2 * catalog.c: set of generic Catalog related routines | 2 * catalog.c: set of generic Catalog related routines |
3 * | 3 * |
4 * Reference: SGML Open Technical Resolution TR9401:1997. | 4 * Reference: SGML Open Technical Resolution TR9401:1997. |
5 * http://www.jclark.com/sp/catalog.htm | 5 * http://www.jclark.com/sp/catalog.htm |
6 * | 6 * |
7 * XML Catalogs Working Draft 06 August 2001 | 7 * XML Catalogs Working Draft 06 August 2001 |
8 * http://www.oasis-open.org/committees/entity/spec-2001-08-06.html | 8 * http://www.oasis-open.org/committees/entity/spec-2001-08-06.html |
9 * | 9 * |
10 * See Copyright for the status of this software. | 10 * See Copyright for the status of this software. |
11 * | 11 * |
12 * Daniel.Veillard@imag.fr | 12 * Daniel.Veillard@imag.fr |
(...skipping 21 matching lines...) Expand all Loading... |
34 #include <string.h> | 34 #include <string.h> |
35 #include <libxml/xmlmemory.h> | 35 #include <libxml/xmlmemory.h> |
36 #include <libxml/hash.h> | 36 #include <libxml/hash.h> |
37 #include <libxml/uri.h> | 37 #include <libxml/uri.h> |
38 #include <libxml/parserInternals.h> | 38 #include <libxml/parserInternals.h> |
39 #include <libxml/catalog.h> | 39 #include <libxml/catalog.h> |
40 #include <libxml/xmlerror.h> | 40 #include <libxml/xmlerror.h> |
41 #include <libxml/threads.h> | 41 #include <libxml/threads.h> |
42 #include <libxml/globals.h> | 42 #include <libxml/globals.h> |
43 | 43 |
| 44 #include "buf.h" |
| 45 |
44 #define MAX_DELEGATE 50 | 46 #define MAX_DELEGATE 50 |
45 #define MAX_CATAL_DEPTH 50 | 47 #define MAX_CATAL_DEPTH 50 |
46 | 48 |
47 #ifdef _WIN32 | 49 #ifdef _WIN32 |
48 # define PATH_SEAPARATOR ';' | 50 # define PATH_SEAPARATOR ';' |
49 #else | 51 #else |
50 # define PATH_SEAPARATOR ':' | 52 # define PATH_SEAPARATOR ':' |
51 #endif | 53 #endif |
52 | 54 |
53 /** | 55 /** |
54 * TODO: | 56 * TODO: |
55 * | 57 * |
56 * macro to flag unimplemented blocks | 58 * macro to flag unimplemented blocks |
57 * XML_CATALOG_PREFER user env to select between system/public prefered | 59 * XML_CATALOG_PREFER user env to select between system/public prefered |
58 * option. C.f. Richard Tobin <richard@cogsci.ed.ac.uk> | 60 * option. C.f. Richard Tobin <richard@cogsci.ed.ac.uk> |
59 *> Just FYI, I am using an environment variable XML_CATALOG_PREFER with | 61 *> Just FYI, I am using an environment variable XML_CATALOG_PREFER with |
60 *> values "system" and "public". I have made the default be "system" to | 62 *> values "system" and "public". I have made the default be "system" to |
61 *> match yours. | 63 *> match yours. |
62 */ | 64 */ |
63 #define TODO » » » » » » » » \ | 65 #define TODO» » » » » » » » \ |
64 xmlGenericError(xmlGenericErrorContext, \ | 66 xmlGenericError(xmlGenericErrorContext, \ |
65 "Unimplemented block at %s:%d\n", \ | 67 "Unimplemented block at %s:%d\n", \ |
66 __FILE__, __LINE__); | 68 __FILE__, __LINE__); |
67 | 69 |
68 #define XML_URN_PUBID "urn:publicid:" | 70 #define XML_URN_PUBID "urn:publicid:" |
69 #define XML_CATAL_BREAK ((xmlChar *) -1) | 71 #define XML_CATAL_BREAK ((xmlChar *) -1) |
70 #ifndef XML_XML_DEFAULT_CATALOG | 72 #ifndef XML_XML_DEFAULT_CATALOG |
71 #define XML_XML_DEFAULT_CATALOG "file:///etc/xml/catalog" | 73 #define XML_XML_DEFAULT_CATALOG "file:///etc/xml/catalog" |
72 #endif | 74 #endif |
73 #ifndef XML_SGML_DEFAULT_CATALOG | 75 #ifndef XML_SGML_DEFAULT_CATALOG |
74 #define XML_SGML_DEFAULT_CATALOG "file:///etc/sgml/catalog" | 76 #define XML_SGML_DEFAULT_CATALOG "file:///etc/sgml/catalog" |
75 #endif | 77 #endif |
76 | 78 |
77 #if defined(_WIN32) && defined(_MSC_VER) | 79 #if defined(_WIN32) && defined(_MSC_VER) |
78 #undef XML_XML_DEFAULT_CATALOG | 80 #undef XML_XML_DEFAULT_CATALOG |
79 static char XML_XML_DEFAULT_CATALOG[256] = "file:///etc/xml/catalog"; | 81 static char XML_XML_DEFAULT_CATALOG[256] = "file:///etc/xml/catalog"; |
80 #if defined(_WIN32_WCE) | 82 #if defined(_WIN32_WCE) |
81 /* Windows CE don't have a A variant */ | 83 /* Windows CE don't have a A variant */ |
82 #define GetModuleHandleA GetModuleHandle | 84 #define GetModuleHandleA GetModuleHandle |
83 #define GetModuleFileNameA GetModuleFileName | 85 #define GetModuleFileNameA GetModuleFileName |
84 #else | 86 #else |
| 87 #if !defined(_WINDOWS_) |
85 void* __stdcall GetModuleHandleA(const char*); | 88 void* __stdcall GetModuleHandleA(const char*); |
86 unsigned long __stdcall GetModuleFileNameA(void*, char*, unsigned long); | 89 unsigned long __stdcall GetModuleFileNameA(void*, char*, unsigned long); |
87 #endif | 90 #endif |
88 #endif | 91 #endif |
| 92 #endif |
89 | 93 |
90 static xmlChar *xmlCatalogNormalizePublic(const xmlChar *pubID); | 94 static xmlChar *xmlCatalogNormalizePublic(const xmlChar *pubID); |
91 static int xmlExpandCatalog(xmlCatalogPtr catal, const char *filename); | 95 static int xmlExpandCatalog(xmlCatalogPtr catal, const char *filename); |
92 | 96 |
93 /************************************************************************ | 97 /************************************************************************ |
94 * * | 98 * * |
95 * Types, all private * | 99 * Types, all private * |
96 * * | 100 * * |
97 ************************************************************************/ | 101 ************************************************************************/ |
98 | 102 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 */ | 203 */ |
200 static xmlRMutexPtr xmlCatalogMutex = NULL; | 204 static xmlRMutexPtr xmlCatalogMutex = NULL; |
201 | 205 |
202 /* | 206 /* |
203 * Whether the catalog support was initialized. | 207 * Whether the catalog support was initialized. |
204 */ | 208 */ |
205 static int xmlCatalogInitialized = 0; | 209 static int xmlCatalogInitialized = 0; |
206 | 210 |
207 /************************************************************************ | 211 /************************************************************************ |
208 * * | 212 * * |
209 * » » » Catalog error handlers» » » » * | 213 *» » » Catalog error handlers» » » » * |
210 * * | 214 * * |
211 ************************************************************************/ | 215 ************************************************************************/ |
212 | 216 |
213 /** | 217 /** |
214 * xmlCatalogErrMemory: | 218 * xmlCatalogErrMemory: |
215 * @extra: extra informations | 219 * @extra: extra informations |
216 * | 220 * |
217 * Handle an out of memory condition | 221 * Handle an out of memory condition |
218 */ | 222 */ |
219 static void | 223 static void |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 * Allocation and Freeing * | 256 * Allocation and Freeing * |
253 * * | 257 * * |
254 ************************************************************************/ | 258 ************************************************************************/ |
255 | 259 |
256 /** | 260 /** |
257 * xmlNewCatalogEntry: | 261 * xmlNewCatalogEntry: |
258 * @type: type of entry | 262 * @type: type of entry |
259 * @name: name of the entry | 263 * @name: name of the entry |
260 * @value: value of the entry | 264 * @value: value of the entry |
261 * @prefer: the PUBLIC vs. SYSTEM current preference value | 265 * @prefer: the PUBLIC vs. SYSTEM current preference value |
262 * @group: for members of a group, the group entry | 266 * @group: for members of a group, the group entry |
263 * | 267 * |
264 * create a new Catalog entry, this type is shared both by XML and | 268 * create a new Catalog entry, this type is shared both by XML and |
265 * SGML catalogs, but the acceptable types values differs. | 269 * SGML catalogs, but the acceptable types values differs. |
266 * | 270 * |
267 * Returns the xmlCatalogEntryPtr or NULL in case of error | 271 * Returns the xmlCatalogEntryPtr or NULL in case of error |
268 */ | 272 */ |
269 static xmlCatalogEntryPtr | 273 static xmlCatalogEntryPtr |
270 xmlNewCatalogEntry(xmlCatalogEntryType type, const xmlChar *name, | 274 xmlNewCatalogEntry(xmlCatalogEntryType type, const xmlChar *name, |
271 const xmlChar *value, const xmlChar *URL, xmlCatalogPrefer prefer, | 275 const xmlChar *value, const xmlChar *URL, xmlCatalogPrefer prefer, |
272 xmlCatalogEntryPtr group) { | 276 xmlCatalogEntryPtr group) { |
273 xmlCatalogEntryPtr ret; | 277 xmlCatalogEntryPtr ret; |
274 xmlChar *normid = NULL; | 278 xmlChar *normid = NULL; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 } | 396 } |
393 catal->dealloc = 0; | 397 catal->dealloc = 0; |
394 xmlFreeCatalogEntry(catal); | 398 xmlFreeCatalogEntry(catal); |
395 } | 399 } |
396 | 400 |
397 /** | 401 /** |
398 * xmlCreateNewCatalog: | 402 * xmlCreateNewCatalog: |
399 * @type: type of catalog | 403 * @type: type of catalog |
400 * @prefer: the PUBLIC vs. SYSTEM current preference value | 404 * @prefer: the PUBLIC vs. SYSTEM current preference value |
401 * | 405 * |
402 * create a new Catalog, this type is shared both by XML and | 406 * create a new Catalog, this type is shared both by XML and |
403 * SGML catalogs, but the acceptable types values differs. | 407 * SGML catalogs, but the acceptable types values differs. |
404 * | 408 * |
405 * Returns the xmlCatalogPtr or NULL in case of error | 409 * Returns the xmlCatalogPtr or NULL in case of error |
406 */ | 410 */ |
407 static xmlCatalogPtr | 411 static xmlCatalogPtr |
408 xmlCreateNewCatalog(xmlCatalogType type, xmlCatalogPrefer prefer) { | 412 xmlCreateNewCatalog(xmlCatalogType type, xmlCatalogPrefer prefer) { |
409 xmlCatalogPtr ret; | 413 xmlCatalogPtr ret; |
410 | 414 |
411 ret = (xmlCatalogPtr) xmlMalloc(sizeof(xmlCatalog)); | 415 ret = (xmlCatalogPtr) xmlMalloc(sizeof(xmlCatalog)); |
412 if (ret == NULL) { | 416 if (ret == NULL) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 case XML_CATA_NONE: | 564 case XML_CATA_NONE: |
561 break; | 565 break; |
562 case XML_CATA_GROUP: | 566 case XML_CATA_GROUP: |
563 node = xmlNewDocNode(doc, ns, BAD_CAST "group", NULL); | 567 node = xmlNewDocNode(doc, ns, BAD_CAST "group", NULL); |
564 xmlSetProp(node, BAD_CAST "id", cur->name); | 568 xmlSetProp(node, BAD_CAST "id", cur->name); |
565 if (cur->value != NULL) { | 569 if (cur->value != NULL) { |
566 xmlNsPtr xns; | 570 xmlNsPtr xns; |
567 xns = xmlSearchNsByHref(doc, node, XML_XML_NAMESPACE); | 571 xns = xmlSearchNsByHref(doc, node, XML_XML_NAMESPACE); |
568 if (xns != NULL) | 572 if (xns != NULL) |
569 xmlSetNsProp(node, xns, BAD_CAST "base", | 573 xmlSetNsProp(node, xns, BAD_CAST "base", |
570 » » » » » cur->value); | 574 » » » » » cur->value); |
571 } | 575 } |
572 switch (cur->prefer) { | 576 switch (cur->prefer) { |
573 case XML_CATA_PREFER_NONE: | 577 case XML_CATA_PREFER_NONE: |
574 break; | 578 break; |
575 case XML_CATA_PREFER_PUBLIC: | 579 case XML_CATA_PREFER_PUBLIC: |
576 xmlSetProp(node, BAD_CAST "prefer", BAD_CAST "public
"); | 580 xmlSetProp(node, BAD_CAST "prefer", BAD_CAST "public
"); |
577 break; | 581 break; |
578 case XML_CATA_PREFER_SYSTEM: | 582 case XML_CATA_PREFER_SYSTEM: |
579 xmlSetProp(node, BAD_CAST "prefer", BAD_CAST "system
"); | 583 xmlSetProp(node, BAD_CAST "prefer", BAD_CAST "system
"); |
580 break; | 584 break; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 catalog = xmlNewDocNode(doc, ns, BAD_CAST "catalog", NULL); | 682 catalog = xmlNewDocNode(doc, ns, BAD_CAST "catalog", NULL); |
679 if (catalog == NULL) { | 683 if (catalog == NULL) { |
680 xmlFreeNs(ns); | 684 xmlFreeNs(ns); |
681 xmlFreeDoc(doc); | 685 xmlFreeDoc(doc); |
682 return(-1); | 686 return(-1); |
683 } | 687 } |
684 catalog->nsDef = ns; | 688 catalog->nsDef = ns; |
685 xmlAddChild((xmlNodePtr) doc, catalog); | 689 xmlAddChild((xmlNodePtr) doc, catalog); |
686 | 690 |
687 xmlDumpXMLCatalogNode(catal, catalog, doc, ns, NULL); | 691 xmlDumpXMLCatalogNode(catal, catalog, doc, ns, NULL); |
688 | 692 |
689 /* | 693 /* |
690 * reserialize it | 694 * reserialize it |
691 */ | 695 */ |
692 buf = xmlOutputBufferCreateFile(out, NULL); | 696 buf = xmlOutputBufferCreateFile(out, NULL); |
693 if (buf == NULL) { | 697 if (buf == NULL) { |
694 xmlFreeDoc(doc); | 698 xmlFreeDoc(doc); |
695 return(-1); | 699 return(-1); |
696 } | 700 } |
697 ret = xmlSaveFormatFileTo(buf, doc, NULL, 1); | 701 ret = xmlSaveFormatFileTo(buf, doc, NULL, 1); |
698 | 702 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 * by the caller. | 819 * by the caller. |
816 */ | 820 */ |
817 static xmlChar * | 821 static xmlChar * |
818 xmlCatalogUnWrapURN(const xmlChar *urn) { | 822 xmlCatalogUnWrapURN(const xmlChar *urn) { |
819 xmlChar result[2000]; | 823 xmlChar result[2000]; |
820 unsigned int i = 0; | 824 unsigned int i = 0; |
821 | 825 |
822 if (xmlStrncmp(urn, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) | 826 if (xmlStrncmp(urn, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) |
823 return(NULL); | 827 return(NULL); |
824 urn += sizeof(XML_URN_PUBID) - 1; | 828 urn += sizeof(XML_URN_PUBID) - 1; |
825 | 829 |
826 while (*urn != 0) { | 830 while (*urn != 0) { |
827 if (i > sizeof(result) - 4) | 831 if (i > sizeof(result) - 4) |
828 break; | 832 break; |
829 if (*urn == '+') { | 833 if (*urn == '+') { |
830 result[i++] = ' '; | 834 result[i++] = ' '; |
831 urn++; | 835 urn++; |
832 } else if (*urn == ':') { | 836 } else if (*urn == ':') { |
833 result[i++] = '/'; | 837 result[i++] = '/'; |
834 result[i++] = '/'; | 838 result[i++] = '/'; |
835 urn++; | 839 urn++; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 } | 909 } |
906 | 910 |
907 inputStream = xmlNewInputStream(ctxt); | 911 inputStream = xmlNewInputStream(ctxt); |
908 if (inputStream == NULL) { | 912 if (inputStream == NULL) { |
909 xmlFreeParserCtxt(ctxt); | 913 xmlFreeParserCtxt(ctxt); |
910 return(NULL); | 914 return(NULL); |
911 } | 915 } |
912 | 916 |
913 inputStream->filename = (char *) xmlCanonicPath((const xmlChar *)filename); | 917 inputStream->filename = (char *) xmlCanonicPath((const xmlChar *)filename); |
914 inputStream->buf = buf; | 918 inputStream->buf = buf; |
915 inputStream->base = inputStream->buf->buffer->content; | 919 xmlBufResetInput(buf->buffer, inputStream); |
916 inputStream->cur = inputStream->buf->buffer->content; | |
917 inputStream->end = | |
918 » &inputStream->buf->buffer->content[inputStream->buf->buffer->use]; | |
919 | 920 |
920 inputPush(ctxt, inputStream); | 921 inputPush(ctxt, inputStream); |
921 if ((ctxt->directory == NULL) && (directory == NULL)) | 922 if ((ctxt->directory == NULL) && (directory == NULL)) |
922 directory = xmlParserGetDirectory(filename); | 923 directory = xmlParserGetDirectory(filename); |
923 if ((ctxt->directory == NULL) && (directory != NULL)) | 924 if ((ctxt->directory == NULL) && (directory != NULL)) |
924 ctxt->directory = directory; | 925 ctxt->directory = directory; |
925 ctxt->valid = 0; | 926 ctxt->valid = 0; |
926 ctxt->validate = 0; | 927 ctxt->validate = 0; |
927 ctxt->loadsubset = 0; | 928 ctxt->loadsubset = 0; |
928 ctxt->pedantic = 0; | 929 ctxt->pedantic = 0; |
929 ctxt->dictNames = 1; | 930 ctxt->dictNames = 1; |
930 | 931 |
931 xmlParseDocument(ctxt); | 932 xmlParseDocument(ctxt); |
932 | 933 |
933 if (ctxt->wellFormed) | 934 if (ctxt->wellFormed) |
934 ret = ctxt->myDoc; | 935 ret = ctxt->myDoc; |
935 else { | 936 else { |
936 ret = NULL; | 937 ret = NULL; |
937 xmlFreeDoc(ctxt->myDoc); | 938 xmlFreeDoc(ctxt->myDoc); |
938 ctxt->myDoc = NULL; | 939 ctxt->myDoc = NULL; |
939 } | 940 } |
940 xmlFreeParserCtxt(ctxt); | 941 xmlFreeParserCtxt(ctxt); |
941 | 942 |
942 return(ret); | 943 return(ret); |
943 } | 944 } |
944 | 945 |
945 /** | 946 /** |
946 * xmlLoadFileContent: | 947 * xmlLoadFileContent: |
947 * @filename: a file path | 948 * @filename: a file path |
948 * | 949 * |
949 * Load a file content into memory. | 950 * Load a file content into memory. |
950 * | 951 * |
951 * Returns a pointer to the 0 terminated string or NULL in case of error | 952 * Returns a pointer to the 0 terminated string or NULL in case of error |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 return (NULL); | 984 return (NULL); |
984 } | 985 } |
985 #ifdef HAVE_STAT | 986 #ifdef HAVE_STAT |
986 size = info.st_size; | 987 size = info.st_size; |
987 #else | 988 #else |
988 if (fseek(fd, 0, SEEK_END) || (size = ftell(fd)) == EOF || fseek(fd, 0, SEEK
_SET)) { /* File operations denied? ok, just close and return failure */ | 989 if (fseek(fd, 0, SEEK_END) || (size = ftell(fd)) == EOF || fseek(fd, 0, SEEK
_SET)) { /* File operations denied? ok, just close and return failure */ |
989 fclose(fd); | 990 fclose(fd); |
990 return (NULL); | 991 return (NULL); |
991 } | 992 } |
992 #endif | 993 #endif |
993 content = xmlMallocAtomic(size + 10); | 994 content = (xmlChar*)xmlMallocAtomic(size + 10); |
994 if (content == NULL) { | 995 if (content == NULL) { |
995 xmlCatalogErrMemory("allocating catalog data"); | 996 xmlCatalogErrMemory("allocating catalog data"); |
| 997 #ifdef HAVE_STAT |
| 998 close(fd); |
| 999 #else |
| 1000 fclose(fd); |
| 1001 #endif |
996 return (NULL); | 1002 return (NULL); |
997 } | 1003 } |
998 #ifdef HAVE_STAT | 1004 #ifdef HAVE_STAT |
999 len = read(fd, content, size); | 1005 len = read(fd, content, size); |
| 1006 close(fd); |
1000 #else | 1007 #else |
1001 len = fread(content, 1, size, fd); | 1008 len = fread(content, 1, size, fd); |
| 1009 fclose(fd); |
1002 #endif | 1010 #endif |
1003 if (len < 0) { | 1011 if (len < 0) { |
1004 xmlFree(content); | 1012 xmlFree(content); |
1005 return (NULL); | 1013 return (NULL); |
1006 } | 1014 } |
1007 #ifdef HAVE_STAT | |
1008 close(fd); | |
1009 #else | |
1010 fclose(fd); | |
1011 #endif | |
1012 content[len] = 0; | 1015 content[len] = 0; |
1013 | 1016 |
1014 return(content); | 1017 return(content); |
1015 } | 1018 } |
1016 | 1019 |
1017 /** | 1020 /** |
1018 * xmlCatalogNormalizePublic: | 1021 * xmlCatalogNormalizePublic: |
1019 * @pubID: the public ID string | 1022 * @pubID: the public ID string |
1020 * | 1023 * |
1021 * Normalizes the Public Identifier | 1024 * Normalizes the Public Identifier |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 /* TODO: sort the list according to REWRITE lengths and prefer value */ | 1327 /* TODO: sort the list according to REWRITE lengths and prefer value */ |
1325 } | 1328 } |
1326 | 1329 |
1327 /** | 1330 /** |
1328 * xmlParseXMLCatalogFile: | 1331 * xmlParseXMLCatalogFile: |
1329 * @prefer: the PUBLIC vs. SYSTEM current preference value | 1332 * @prefer: the PUBLIC vs. SYSTEM current preference value |
1330 * @filename: the filename for the catalog | 1333 * @filename: the filename for the catalog |
1331 * | 1334 * |
1332 * Parses the catalog file to extract the XML tree and then analyze the | 1335 * Parses the catalog file to extract the XML tree and then analyze the |
1333 * tree to build a list of Catalog entries corresponding to this catalog | 1336 * tree to build a list of Catalog entries corresponding to this catalog |
1334 * | 1337 * |
1335 * Returns the resulting Catalog entries list | 1338 * Returns the resulting Catalog entries list |
1336 */ | 1339 */ |
1337 static xmlCatalogEntryPtr | 1340 static xmlCatalogEntryPtr |
1338 xmlParseXMLCatalogFile(xmlCatalogPrefer prefer, const xmlChar *filename) { | 1341 xmlParseXMLCatalogFile(xmlCatalogPrefer prefer, const xmlChar *filename) { |
1339 xmlDocPtr doc; | 1342 xmlDocPtr doc; |
1340 xmlNodePtr cur; | 1343 xmlNodePtr cur; |
1341 xmlChar *prop; | 1344 xmlChar *prop; |
1342 xmlCatalogEntryPtr parent = NULL; | 1345 xmlCatalogEntryPtr parent = NULL; |
1343 | 1346 |
1344 if (filename == NULL) | 1347 if (filename == NULL) |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 } | 1395 } |
1393 xmlFreeDoc(doc); | 1396 xmlFreeDoc(doc); |
1394 return(parent); | 1397 return(parent); |
1395 } | 1398 } |
1396 | 1399 |
1397 /** | 1400 /** |
1398 * xmlFetchXMLCatalogFile: | 1401 * xmlFetchXMLCatalogFile: |
1399 * @catal: an existing but incomplete catalog entry | 1402 * @catal: an existing but incomplete catalog entry |
1400 * | 1403 * |
1401 * Fetch and parse the subcatalog referenced by an entry | 1404 * Fetch and parse the subcatalog referenced by an entry |
1402 * | 1405 * |
1403 * Returns 0 in case of success, -1 otherwise | 1406 * Returns 0 in case of success, -1 otherwise |
1404 */ | 1407 */ |
1405 static int | 1408 static int |
1406 xmlFetchXMLCatalogFile(xmlCatalogEntryPtr catal) { | 1409 xmlFetchXMLCatalogFile(xmlCatalogEntryPtr catal) { |
1407 xmlCatalogEntryPtr doc; | 1410 xmlCatalogEntryPtr doc; |
1408 | 1411 |
1409 if (catal == NULL) | 1412 if (catal == NULL) |
1410 return(-1); | 1413 return(-1); |
1411 if (catal->URL == NULL) | 1414 if (catal->URL == NULL) |
1412 return(-1); | 1415 return(-1); |
1413 if (catal->children != NULL) | |
1414 return(-1); | |
1415 | 1416 |
1416 /* | 1417 /* |
1417 * lock the whole catalog for modification | 1418 * lock the whole catalog for modification |
1418 */ | 1419 */ |
1419 xmlRMutexLock(xmlCatalogMutex); | 1420 xmlRMutexLock(xmlCatalogMutex); |
1420 if (catal->children != NULL) { | 1421 if (catal->children != NULL) { |
1421 /* Okay someone else did it in the meantime */ | 1422 /* Okay someone else did it in the meantime */ |
1422 xmlRMutexUnlock(xmlCatalogMutex); | 1423 xmlRMutexUnlock(xmlCatalogMutex); |
1423 return(0); | 1424 return(0); |
1424 } | 1425 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 * | 1494 * |
1494 * Returns 0 if successful, -1 otherwise | 1495 * Returns 0 if successful, -1 otherwise |
1495 */ | 1496 */ |
1496 static int | 1497 static int |
1497 xmlAddXMLCatalog(xmlCatalogEntryPtr catal, const xmlChar *type, | 1498 xmlAddXMLCatalog(xmlCatalogEntryPtr catal, const xmlChar *type, |
1498 const xmlChar *orig, const xmlChar *replace) { | 1499 const xmlChar *orig, const xmlChar *replace) { |
1499 xmlCatalogEntryPtr cur; | 1500 xmlCatalogEntryPtr cur; |
1500 xmlCatalogEntryType typ; | 1501 xmlCatalogEntryType typ; |
1501 int doregister = 0; | 1502 int doregister = 0; |
1502 | 1503 |
1503 if ((catal == NULL) || | 1504 if ((catal == NULL) || |
1504 ((catal->type != XML_CATA_CATALOG) && | 1505 ((catal->type != XML_CATA_CATALOG) && |
1505 (catal->type != XML_CATA_BROKEN_CATALOG))) | 1506 (catal->type != XML_CATA_BROKEN_CATALOG))) |
1506 return(-1); | 1507 return(-1); |
1507 if (catal->children == NULL) { | 1508 if (catal->children == NULL) { |
1508 xmlFetchXMLCatalogFile(catal); | 1509 xmlFetchXMLCatalogFile(catal); |
1509 } | 1510 } |
1510 if (catal->children == NULL) | 1511 if (catal->children == NULL) |
1511 doregister = 1; | 1512 doregister = 1; |
1512 | 1513 |
1513 typ = xmlGetXMLCatalogEntryType(type); | 1514 typ = xmlGetXMLCatalogEntryType(type); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 xmlGenericError(xmlGenericErrorContext, | 1547 xmlGenericError(xmlGenericErrorContext, |
1547 "Adding element %s to catalog\n", type); | 1548 "Adding element %s to catalog\n", type); |
1548 if (cur == NULL) | 1549 if (cur == NULL) |
1549 catal->children = xmlNewCatalogEntry(typ, orig, replace, | 1550 catal->children = xmlNewCatalogEntry(typ, orig, replace, |
1550 NULL, catal->prefer, NULL); | 1551 NULL, catal->prefer, NULL); |
1551 else | 1552 else |
1552 cur->next = xmlNewCatalogEntry(typ, orig, replace, | 1553 cur->next = xmlNewCatalogEntry(typ, orig, replace, |
1553 NULL, catal->prefer, NULL); | 1554 NULL, catal->prefer, NULL); |
1554 if (doregister) { | 1555 if (doregister) { |
1555 catal->type = XML_CATA_CATALOG; | 1556 catal->type = XML_CATA_CATALOG; |
1556 » cur = xmlHashLookup(xmlCatalogXMLFiles, catal->URL); | 1557 » cur = (xmlCatalogEntryPtr)xmlHashLookup(xmlCatalogXMLFiles, catal->URL); |
1557 if (cur != NULL) | 1558 if (cur != NULL) |
1558 cur->children = catal->children; | 1559 cur->children = catal->children; |
1559 } | 1560 } |
1560 | 1561 |
1561 return(0); | 1562 return(0); |
1562 } | 1563 } |
1563 | 1564 |
1564 /** | 1565 /** |
1565 * xmlDelXMLCatalog: | 1566 * xmlDelXMLCatalog: |
1566 * @catal: top of an XML catalog | 1567 * @catal: top of an XML catalog |
1567 * @value: the value to remove from the catalog | 1568 * @value: the value to remove from the catalog |
1568 * | 1569 * |
1569 * Remove entries in the XML catalog where the value or the URI | 1570 * Remove entries in the XML catalog where the value or the URI |
1570 * is equal to @value | 1571 * is equal to @value |
1571 * | 1572 * |
1572 * Returns the number of entries removed if successful, -1 otherwise | 1573 * Returns the number of entries removed if successful, -1 otherwise |
1573 */ | 1574 */ |
1574 static int | 1575 static int |
1575 xmlDelXMLCatalog(xmlCatalogEntryPtr catal, const xmlChar *value) { | 1576 xmlDelXMLCatalog(xmlCatalogEntryPtr catal, const xmlChar *value) { |
1576 xmlCatalogEntryPtr cur; | 1577 xmlCatalogEntryPtr cur; |
1577 int ret = 0; | 1578 int ret = 0; |
1578 | 1579 |
1579 if ((catal == NULL) || | 1580 if ((catal == NULL) || |
1580 ((catal->type != XML_CATA_CATALOG) && | 1581 ((catal->type != XML_CATA_CATALOG) && |
1581 (catal->type != XML_CATA_BROKEN_CATALOG))) | 1582 (catal->type != XML_CATA_BROKEN_CATALOG))) |
1582 return(-1); | 1583 return(-1); |
1583 if (value == NULL) | 1584 if (value == NULL) |
1584 return(-1); | 1585 return(-1); |
1585 if (catal->children == NULL) { | 1586 if (catal->children == NULL) { |
1586 xmlFetchXMLCatalogFile(catal); | 1587 xmlFetchXMLCatalogFile(catal); |
1587 } | 1588 } |
1588 | 1589 |
1589 /* | 1590 /* |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1784 | 1785 |
1785 for (i = 0;i < nbList;i++) | 1786 for (i = 0;i < nbList;i++) |
1786 if (xmlStrEqual(cur->URL, delegates[i])) | 1787 if (xmlStrEqual(cur->URL, delegates[i])) |
1787 break; | 1788 break; |
1788 if (i < nbList) { | 1789 if (i < nbList) { |
1789 cur = cur->next; | 1790 cur = cur->next; |
1790 continue; | 1791 continue; |
1791 } | 1792 } |
1792 if (nbList < MAX_DELEGATE) | 1793 if (nbList < MAX_DELEGATE) |
1793 delegates[nbList++] = cur->URL; | 1794 delegates[nbList++] = cur->URL; |
1794 » » » | 1795 |
1795 if (cur->children == NULL) { | 1796 if (cur->children == NULL) { |
1796 xmlFetchXMLCatalogFile(cur); | 1797 xmlFetchXMLCatalogFile(cur); |
1797 } | 1798 } |
1798 if (cur->children != NULL) { | 1799 if (cur->children != NULL) { |
1799 if (xmlDebugCatalogs) | 1800 if (xmlDebugCatalogs) |
1800 xmlGenericError(xmlGenericErrorContext, | 1801 xmlGenericError(xmlGenericErrorContext, |
1801 "Trying public delegate %s\n", cur->URL); | 1802 "Trying public delegate %s\n", cur->URL); |
1802 ret = xmlCatalogListXMLResolve( | 1803 ret = xmlCatalogListXMLResolve( |
1803 cur->children, pubID, NULL); | 1804 cur->children, pubID, NULL); |
1804 if (ret != NULL) { | 1805 if (ret != NULL) { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1997 * from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html | 1998 * from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html |
1998 * | 1999 * |
1999 * Returns the URI of the resource or NULL if not found | 2000 * Returns the URI of the resource or NULL if not found |
2000 */ | 2001 */ |
2001 static xmlChar * | 2002 static xmlChar * |
2002 xmlCatalogListXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID, | 2003 xmlCatalogListXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID, |
2003 const xmlChar *sysID) { | 2004 const xmlChar *sysID) { |
2004 xmlChar *ret = NULL; | 2005 xmlChar *ret = NULL; |
2005 xmlChar *urnID = NULL; | 2006 xmlChar *urnID = NULL; |
2006 xmlChar *normid; | 2007 xmlChar *normid; |
2007 | 2008 |
2008 if (catal == NULL) | 2009 if (catal == NULL) |
2009 return(NULL); | 2010 return(NULL); |
2010 if ((pubID == NULL) && (sysID == NULL)) | 2011 if ((pubID == NULL) && (sysID == NULL)) |
2011 return(NULL); | 2012 return(NULL); |
2012 | 2013 |
2013 normid = xmlCatalogNormalizePublic(pubID); | 2014 normid = xmlCatalogNormalizePublic(pubID); |
2014 if (normid != NULL) | 2015 if (normid != NULL) |
2015 pubID = (*normid != 0 ? normid : NULL); | 2016 pubID = (*normid != 0 ? normid : NULL); |
2016 | 2017 |
2017 if (!xmlStrncmp(pubID, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) { | 2018 if (!xmlStrncmp(pubID, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) { |
2018 urnID = xmlCatalogUnWrapURN(pubID); | 2019 urnID = xmlCatalogUnWrapURN(pubID); |
2019 if (xmlDebugCatalogs) { | 2020 if (xmlDebugCatalogs) { |
2020 if (urnID == NULL) | 2021 if (urnID == NULL) |
2021 xmlGenericError(xmlGenericErrorContext, | 2022 xmlGenericError(xmlGenericErrorContext, |
2022 "Public URN ID %s expanded to NULL\n", pubID); | 2023 "Public URN ID %s expanded to NULL\n", pubID); |
2023 else | 2024 else |
2024 xmlGenericError(xmlGenericErrorContext, | 2025 xmlGenericError(xmlGenericErrorContext, |
2025 "Public URN ID expanded to %s\n", urnID); | 2026 "Public URN ID expanded to %s\n", urnID); |
2026 } | 2027 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2086 * | 2087 * |
2087 * Implements (or tries to) 7.2. URI Resolution | 2088 * Implements (or tries to) 7.2. URI Resolution |
2088 * from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html | 2089 * from http://www.oasis-open.org/committees/entity/spec-2001-08-06.html |
2089 * | 2090 * |
2090 * Returns the URI of the resource or NULL if not found | 2091 * Returns the URI of the resource or NULL if not found |
2091 */ | 2092 */ |
2092 static xmlChar * | 2093 static xmlChar * |
2093 xmlCatalogListXMLResolveURI(xmlCatalogEntryPtr catal, const xmlChar *URI) { | 2094 xmlCatalogListXMLResolveURI(xmlCatalogEntryPtr catal, const xmlChar *URI) { |
2094 xmlChar *ret = NULL; | 2095 xmlChar *ret = NULL; |
2095 xmlChar *urnID = NULL; | 2096 xmlChar *urnID = NULL; |
2096 | 2097 |
2097 if (catal == NULL) | 2098 if (catal == NULL) |
2098 return(NULL); | 2099 return(NULL); |
2099 if (URI == NULL) | 2100 if (URI == NULL) |
2100 return(NULL); | 2101 return(NULL); |
2101 | 2102 |
2102 if (!xmlStrncmp(URI, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) { | 2103 if (!xmlStrncmp(URI, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) { |
2103 urnID = xmlCatalogUnWrapURN(URI); | 2104 urnID = xmlCatalogUnWrapURN(URI); |
2104 if (xmlDebugCatalogs) { | 2105 if (xmlDebugCatalogs) { |
2105 if (urnID == NULL) | 2106 if (urnID == NULL) |
2106 xmlGenericError(xmlGenericErrorContext, | 2107 xmlGenericError(xmlGenericErrorContext, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2146 /** | 2147 /** |
2147 * xmlParseSGMLCatalogComment: | 2148 * xmlParseSGMLCatalogComment: |
2148 * @cur: the current character | 2149 * @cur: the current character |
2149 * | 2150 * |
2150 * Skip a comment in an SGML catalog | 2151 * Skip a comment in an SGML catalog |
2151 * | 2152 * |
2152 * Returns new current character | 2153 * Returns new current character |
2153 */ | 2154 */ |
2154 static const xmlChar * | 2155 static const xmlChar * |
2155 xmlParseSGMLCatalogComment(const xmlChar *cur) { | 2156 xmlParseSGMLCatalogComment(const xmlChar *cur) { |
2156 if ((cur[0] != '-') || (cur[1] != '-')) | 2157 if ((cur[0] != '-') || (cur[1] != '-')) |
2157 return(cur); | 2158 return(cur); |
2158 SKIP(2); | 2159 SKIP(2); |
2159 while ((cur[0] != 0) && ((cur[0] != '-') || ((cur[1] != '-')))) | 2160 while ((cur[0] != 0) && ((cur[0] != '-') || ((cur[1] != '-')))) |
2160 NEXT; | 2161 NEXT; |
2161 if (cur[0] == 0) { | 2162 if (cur[0] == 0) { |
2162 return(NULL); | 2163 return(NULL); |
2163 } | 2164 } |
2164 return(cur + 2); | 2165 return(cur + 2); |
2165 } | 2166 } |
2166 | 2167 |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2681 xmlChar *first; | 2682 xmlChar *first; |
2682 xmlCatalogPtr catal; | 2683 xmlCatalogPtr catal; |
2683 int ret; | 2684 int ret; |
2684 | 2685 |
2685 content = xmlLoadFileContent(filename); | 2686 content = xmlLoadFileContent(filename); |
2686 if (content == NULL) | 2687 if (content == NULL) |
2687 return(NULL); | 2688 return(NULL); |
2688 | 2689 |
2689 | 2690 |
2690 first = content; | 2691 first = content; |
2691 | 2692 |
2692 while ((*first != 0) && (*first != '-') && (*first != '<') && | 2693 while ((*first != 0) && (*first != '-') && (*first != '<') && |
2693 (!(((*first >= 'A') && (*first <= 'Z')) || | 2694 (!(((*first >= 'A') && (*first <= 'Z')) || |
2694 ((*first >= 'a') && (*first <= 'z'))))) | 2695 ((*first >= 'a') && (*first <= 'z'))))) |
2695 first++; | 2696 first++; |
2696 | 2697 |
2697 if (*first != '<') { | 2698 if (*first != '<') { |
2698 catal = xmlCreateNewCatalog(XML_SGML_CATALOG_TYPE, xmlCatalogDefaultPref
er); | 2699 catal = xmlCreateNewCatalog(XML_SGML_CATALOG_TYPE, xmlCatalogDefaultPref
er); |
2699 if (catal == NULL) { | 2700 if (catal == NULL) { |
2700 xmlFree(content); | 2701 xmlFree(content); |
2701 return(NULL); | 2702 return(NULL); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2776 * | 2777 * |
2777 * Returns the resource if found or NULL otherwise, the value returned | 2778 * Returns the resource if found or NULL otherwise, the value returned |
2778 * must be freed by the caller. | 2779 * must be freed by the caller. |
2779 */ | 2780 */ |
2780 xmlChar * | 2781 xmlChar * |
2781 xmlACatalogResolveSystem(xmlCatalogPtr catal, const xmlChar *sysID) { | 2782 xmlACatalogResolveSystem(xmlCatalogPtr catal, const xmlChar *sysID) { |
2782 xmlChar *ret = NULL; | 2783 xmlChar *ret = NULL; |
2783 | 2784 |
2784 if ((sysID == NULL) || (catal == NULL)) | 2785 if ((sysID == NULL) || (catal == NULL)) |
2785 return(NULL); | 2786 return(NULL); |
2786 | 2787 |
2787 if (xmlDebugCatalogs) | 2788 if (xmlDebugCatalogs) |
2788 xmlGenericError(xmlGenericErrorContext, | 2789 xmlGenericError(xmlGenericErrorContext, |
2789 "Resolve sysID %s\n", sysID); | 2790 "Resolve sysID %s\n", sysID); |
2790 | 2791 |
2791 if (catal->type == XML_XML_CATALOG_TYPE) { | 2792 if (catal->type == XML_XML_CATALOG_TYPE) { |
2792 ret = xmlCatalogListXMLResolve(catal->xml, NULL, sysID); | 2793 ret = xmlCatalogListXMLResolve(catal->xml, NULL, sysID); |
2793 if (ret == XML_CATAL_BREAK) | 2794 if (ret == XML_CATAL_BREAK) |
2794 ret = NULL; | 2795 ret = NULL; |
2795 } else { | 2796 } else { |
2796 const xmlChar *sgml; | 2797 const xmlChar *sgml; |
(...skipping 14 matching lines...) Expand all Loading... |
2811 * | 2812 * |
2812 * Returns the local resource if found or NULL otherwise, the value returned | 2813 * Returns the local resource if found or NULL otherwise, the value returned |
2813 * must be freed by the caller. | 2814 * must be freed by the caller. |
2814 */ | 2815 */ |
2815 xmlChar * | 2816 xmlChar * |
2816 xmlACatalogResolvePublic(xmlCatalogPtr catal, const xmlChar *pubID) { | 2817 xmlACatalogResolvePublic(xmlCatalogPtr catal, const xmlChar *pubID) { |
2817 xmlChar *ret = NULL; | 2818 xmlChar *ret = NULL; |
2818 | 2819 |
2819 if ((pubID == NULL) || (catal == NULL)) | 2820 if ((pubID == NULL) || (catal == NULL)) |
2820 return(NULL); | 2821 return(NULL); |
2821 | 2822 |
2822 if (xmlDebugCatalogs) | 2823 if (xmlDebugCatalogs) |
2823 xmlGenericError(xmlGenericErrorContext, | 2824 xmlGenericError(xmlGenericErrorContext, |
2824 "Resolve pubID %s\n", pubID); | 2825 "Resolve pubID %s\n", pubID); |
2825 | 2826 |
2826 if (catal->type == XML_XML_CATALOG_TYPE) { | 2827 if (catal->type == XML_XML_CATALOG_TYPE) { |
2827 ret = xmlCatalogListXMLResolve(catal->xml, pubID, NULL); | 2828 ret = xmlCatalogListXMLResolve(catal->xml, pubID, NULL); |
2828 if (ret == XML_CATAL_BREAK) | 2829 if (ret == XML_CATAL_BREAK) |
2829 ret = NULL; | 2830 ret = NULL; |
2830 } else { | 2831 } else { |
2831 const xmlChar *sgml; | 2832 const xmlChar *sgml; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2930 void | 2931 void |
2931 xmlACatalogDump(xmlCatalogPtr catal, FILE *out) { | 2932 xmlACatalogDump(xmlCatalogPtr catal, FILE *out) { |
2932 if ((out == NULL) || (catal == NULL)) | 2933 if ((out == NULL) || (catal == NULL)) |
2933 return; | 2934 return; |
2934 | 2935 |
2935 if (catal->type == XML_XML_CATALOG_TYPE) { | 2936 if (catal->type == XML_XML_CATALOG_TYPE) { |
2936 xmlDumpXMLCatalog(out, catal->xml); | 2937 xmlDumpXMLCatalog(out, catal->xml); |
2937 } else { | 2938 } else { |
2938 xmlHashScan(catal->sgml, | 2939 xmlHashScan(catal->sgml, |
2939 (xmlHashScanner) xmlCatalogDumpEntry, out); | 2940 (xmlHashScanner) xmlCatalogDumpEntry, out); |
2940 } | 2941 } |
2941 } | 2942 } |
2942 #endif /* LIBXML_OUTPUT_ENABLED */ | 2943 #endif /* LIBXML_OUTPUT_ENABLED */ |
2943 | 2944 |
2944 /** | 2945 /** |
2945 * xmlACatalogAdd: | 2946 * xmlACatalogAdd: |
2946 * @catal: a Catalog | 2947 * @catal: a Catalog |
2947 * @type: the type of record to add to the catalog | 2948 * @type: the type of record to add to the catalog |
2948 * @orig: the system, public or prefix to match | 2949 * @orig: the system, public or prefix to match |
2949 * @replace: the replacement value for the match | 2950 * @replace: the replacement value for the match |
2950 * | 2951 * |
2951 * Add an entry in the catalog, it may overwrite existing but | 2952 * Add an entry in the catalog, it may overwrite existing but |
2952 * different entries. | 2953 * different entries. |
2953 * | 2954 * |
2954 * Returns 0 if successful, -1 otherwise | 2955 * Returns 0 if successful, -1 otherwise |
2955 */ | 2956 */ |
2956 int | 2957 int |
2957 xmlACatalogAdd(xmlCatalogPtr catal, const xmlChar * type, | 2958 xmlACatalogAdd(xmlCatalogPtr catal, const xmlChar * type, |
2958 const xmlChar * orig, const xmlChar * replace) | 2959 const xmlChar * orig, const xmlChar * replace) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2997 if ((catal == NULL) || (value == NULL)) | 2998 if ((catal == NULL) || (value == NULL)) |
2998 return(-1); | 2999 return(-1); |
2999 | 3000 |
3000 if (catal->type == XML_XML_CATALOG_TYPE) { | 3001 if (catal->type == XML_XML_CATALOG_TYPE) { |
3001 res = xmlDelXMLCatalog(catal->xml, value); | 3002 res = xmlDelXMLCatalog(catal->xml, value); |
3002 } else { | 3003 } else { |
3003 res = xmlHashRemoveEntry(catal->sgml, value, | 3004 res = xmlHashRemoveEntry(catal->sgml, value, |
3004 (xmlHashDeallocator) xmlFreeCatalogEntry); | 3005 (xmlHashDeallocator) xmlFreeCatalogEntry); |
3005 if (res == 0) | 3006 if (res == 0) |
3006 res = 1; | 3007 res = 1; |
3007 } | 3008 } |
3008 return(res); | 3009 return(res); |
3009 } | 3010 } |
3010 | 3011 |
3011 /** | 3012 /** |
3012 * xmlNewCatalog: | 3013 * xmlNewCatalog: |
3013 * @sgml: should this create an SGML catalog | 3014 * @sgml: should this create an SGML catalog |
3014 * | 3015 * |
3015 * create a new Catalog. | 3016 * create a new Catalog. |
3016 * | 3017 * |
3017 * Returns the xmlCatalogPtr or NULL in case of error | 3018 * Returns the xmlCatalogPtr or NULL in case of error |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3056 } else { | 3057 } else { |
3057 int res; | 3058 int res; |
3058 | 3059 |
3059 if (catal->sgml == NULL) | 3060 if (catal->sgml == NULL) |
3060 return(1); | 3061 return(1); |
3061 res = xmlHashSize(catal->sgml); | 3062 res = xmlHashSize(catal->sgml); |
3062 if (res == 0) | 3063 if (res == 0) |
3063 return(1); | 3064 return(1); |
3064 if (res < 0) | 3065 if (res < 0) |
3065 return(-1); | 3066 return(-1); |
3066 } | 3067 } |
3067 return(0); | 3068 return(0); |
3068 } | 3069 } |
3069 | 3070 |
3070 /************************************************************************ | 3071 /************************************************************************ |
3071 * * | 3072 * * |
3072 * Public interfaces manipulating the global shared default catalog * | 3073 * Public interfaces manipulating the global shared default catalog * |
3073 * * | 3074 * * |
3074 ************************************************************************/ | 3075 ************************************************************************/ |
3075 | 3076 |
3076 /** | 3077 /** |
3077 * xmlInitializeCatalogData: | 3078 * xmlInitializeCatalogData: |
3078 * | 3079 * |
3079 * Do the catalog initialization only of global data, doesn't try to load | 3080 * Do the catalog initialization only of global data, doesn't try to load |
3080 * any catalog actually. | 3081 * any catalog actually. |
3081 * this function is not thread safe, catalog initialization should | 3082 * this function is not thread safe, catalog initialization should |
3082 * preferably be done once at startup | 3083 * preferably be done once at startup |
3083 */ | 3084 */ |
3084 static void | 3085 static void |
3085 xmlInitializeCatalogData(void) { | 3086 xmlInitializeCatalogData(void) { |
3086 if (xmlCatalogInitialized != 0) | 3087 if (xmlCatalogInitialized != 0) |
3087 return; | 3088 return; |
3088 | 3089 |
3089 if (getenv("XML_DEBUG_CATALOG")) | 3090 if (getenv("XML_DEBUG_CATALOG")) |
3090 xmlDebugCatalogs = 1; | 3091 xmlDebugCatalogs = 1; |
3091 xmlCatalogMutex = xmlNewRMutex(); | 3092 xmlCatalogMutex = xmlNewRMutex(); |
3092 | 3093 |
3093 xmlCatalogInitialized = 1; | 3094 xmlCatalogInitialized = 1; |
3094 } | 3095 } |
3095 /** | 3096 /** |
3096 * xmlInitializeCatalog: | 3097 * xmlInitializeCatalog: |
3097 * | 3098 * |
3098 * Do the catalog initialization. | 3099 * Do the catalog initialization. |
3099 * this function is not thread safe, catalog initialization should | 3100 * this function is not thread safe, catalog initialization should |
3100 * preferably be done once at startup | 3101 * preferably be done once at startup |
3101 */ | 3102 */ |
3102 void | 3103 void |
3103 xmlInitializeCatalog(void) { | 3104 xmlInitializeCatalog(void) { |
3104 if (xmlCatalogInitialized != 0) | 3105 if (xmlCatalogInitialized != 0) |
3105 return; | 3106 return; |
3106 | 3107 |
3107 xmlInitializeCatalogData(); | 3108 xmlInitializeCatalogData(); |
3108 xmlRMutexLock(xmlCatalogMutex); | 3109 xmlRMutexLock(xmlCatalogMutex); |
3109 | 3110 |
3110 if (getenv("XML_DEBUG_CATALOG")) | 3111 if (getenv("XML_DEBUG_CATALOG")) |
3111 xmlDebugCatalogs = 1; | 3112 xmlDebugCatalogs = 1; |
3112 | 3113 |
3113 if (xmlDefaultCatalog == NULL) { | 3114 if (xmlDefaultCatalog == NULL) { |
3114 const char *catalogs; | 3115 const char *catalogs; |
3115 char *path; | 3116 char *path; |
3116 const char *cur, *paths; | 3117 const char *cur, *paths; |
3117 xmlCatalogPtr catal; | 3118 xmlCatalogPtr catal; |
3118 xmlCatalogEntryPtr *nextent; | 3119 xmlCatalogEntryPtr *nextent; |
3119 | 3120 |
3120 catalogs = (const char *) getenv("XML_CATALOG_FILES"); | 3121 catalogs = (const char *) getenv("XML_CATALOG_FILES"); |
3121 if (catalogs == NULL) | 3122 if (catalogs == NULL) |
3122 #if defined(_WIN32) && defined(_MSC_VER) | 3123 #if defined(_WIN32) && defined(_MSC_VER) |
3123 { | 3124 { |
3124 void* hmodule; | 3125 void* hmodule; |
3125 hmodule = GetModuleHandleA("libxml2.dll"); | 3126 hmodule = GetModuleHandleA("libxml2.dll"); |
3126 if (hmodule == NULL) | 3127 if (hmodule == NULL) |
3127 hmodule = GetModuleHandleA(NULL); | 3128 hmodule = GetModuleHandleA(NULL); |
3128 if (hmodule != NULL) { | 3129 if (hmodule != NULL) { |
3129 char buf[256]; | 3130 char buf[256]; |
3130 unsigned long len = GetModuleFileNameA(hmodule, buf, 255
); | 3131 unsigned long len = GetModuleFileNameA(hmodule, buf, 255
); |
3131 if (len != 0) { | 3132 if (len != 0) { |
3132 char* p = &(buf[len]); | 3133 char* p = &(buf[len]); |
3133 » » » » while (*p != '\\' && p > buf) | 3134 » » » » while (*p != '\\' && p > buf) |
3134 p--; | 3135 p--; |
3135 if (p != buf) { | 3136 if (p != buf) { |
3136 xmlChar* uri; | 3137 xmlChar* uri; |
3137 strncpy(p, "\\..\\etc\\catalog", 255 - (
p - buf)); | 3138 strncpy(p, "\\..\\etc\\catalog", 255 - (
p - buf)); |
3138 » » » » » uri = xmlCanonicPath(buf); | 3139 » » » » » uri = xmlCanonicPath((const xmlChar*)buf
); |
3139 if (uri != NULL) { | 3140 if (uri != NULL) { |
3140 strncpy(XML_XML_DEFAULT_CATALOG,
uri, 255); | 3141 strncpy(XML_XML_DEFAULT_CATALOG,
uri, 255); |
3141 xmlFree(uri); | 3142 xmlFree(uri); |
3142 } | 3143 } |
3143 } | 3144 } |
3144 } | 3145 } |
3145 } | 3146 } |
3146 catalogs = XML_XML_DEFAULT_CATALOG; | 3147 catalogs = XML_XML_DEFAULT_CATALOG; |
3147 } | 3148 } |
3148 #else | 3149 #else |
3149 catalogs = XML_XML_DEFAULT_CATALOG; | 3150 catalogs = XML_XML_DEFAULT_CATALOG; |
3150 #endif | 3151 #endif |
3151 | 3152 |
3152 » catal = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE, | 3153 » catal = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE, |
3153 xmlCatalogDefaultPrefer); | 3154 xmlCatalogDefaultPrefer); |
3154 if (catal != NULL) { | 3155 if (catal != NULL) { |
3155 » /* the XML_CATALOG_FILES envvar is allowed to contain a | 3156 » /* the XML_CATALOG_FILES envvar is allowed to contain a |
3156 space-separated list of entries. */ | 3157 space-separated list of entries. */ |
3157 cur = catalogs; | 3158 cur = catalogs; |
3158 nextent = &catal->xml; | 3159 nextent = &catal->xml; |
3159 while (*cur != '\0') { | 3160 while (*cur != '\0') { |
3160 » » while (xmlIsBlank_ch(*cur)) | 3161 » » while (xmlIsBlank_ch(*cur)) |
3161 cur++; | 3162 cur++; |
3162 if (*cur != 0) { | 3163 if (*cur != 0) { |
3163 paths = cur; | 3164 paths = cur; |
3164 while ((*cur != 0) && (!xmlIsBlank_ch(*cur))) | 3165 while ((*cur != 0) && (!xmlIsBlank_ch(*cur))) |
3165 cur++; | 3166 cur++; |
3166 path = (char *) xmlStrndup((const xmlChar *)paths, cur - pat
hs); | 3167 path = (char *) xmlStrndup((const xmlChar *)paths, cur - pat
hs); |
3167 if (path != NULL) { | 3168 if (path != NULL) { |
3168 *nextent = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, | 3169 *nextent = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, |
3169 NULL, BAD_CAST path, xmlCatalogDefaultPrefer, NU
LL); | 3170 NULL, BAD_CAST path, xmlCatalogDefaultPrefer, NU
LL); |
3170 if (*nextent != NULL) | 3171 if (*nextent != NULL) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3243 | 3244 |
3244 cur = pathss; | 3245 cur = pathss; |
3245 while (*cur != 0) { | 3246 while (*cur != 0) { |
3246 while (xmlIsBlank_ch(*cur)) cur++; | 3247 while (xmlIsBlank_ch(*cur)) cur++; |
3247 if (*cur != 0) { | 3248 if (*cur != 0) { |
3248 paths = cur; | 3249 paths = cur; |
3249 while ((*cur != 0) && (*cur != PATH_SEAPARATOR) && (!xmlIsBlank_ch(*
cur))) | 3250 while ((*cur != 0) && (*cur != PATH_SEAPARATOR) && (!xmlIsBlank_ch(*
cur))) |
3250 cur++; | 3251 cur++; |
3251 path = xmlStrndup((const xmlChar *)paths, cur - paths); | 3252 path = xmlStrndup((const xmlChar *)paths, cur - paths); |
3252 #ifdef _WIN32 | 3253 #ifdef _WIN32 |
3253 iLen = strlen(path); | 3254 iLen = strlen((const char*)path); |
3254 for(i = 0; i < iLen; i++) { | 3255 for(i = 0; i < iLen; i++) { |
3255 if(path[i] == '\\') { | 3256 if(path[i] == '\\') { |
3256 path[i] = '/'; | 3257 path[i] = '/'; |
3257 } | 3258 } |
3258 } | 3259 } |
3259 #endif | 3260 #endif |
3260 if (path != NULL) { | 3261 if (path != NULL) { |
3261 xmlLoadCatalog((const char *) path); | 3262 xmlLoadCatalog((const char *) path); |
3262 xmlFree(path); | 3263 xmlFree(path); |
3263 } | 3264 } |
(...skipping 11 matching lines...) Expand all Loading... |
3275 void | 3276 void |
3276 xmlCatalogCleanup(void) { | 3277 xmlCatalogCleanup(void) { |
3277 if (xmlCatalogInitialized == 0) | 3278 if (xmlCatalogInitialized == 0) |
3278 return; | 3279 return; |
3279 | 3280 |
3280 xmlRMutexLock(xmlCatalogMutex); | 3281 xmlRMutexLock(xmlCatalogMutex); |
3281 if (xmlDebugCatalogs) | 3282 if (xmlDebugCatalogs) |
3282 xmlGenericError(xmlGenericErrorContext, | 3283 xmlGenericError(xmlGenericErrorContext, |
3283 "Catalogs cleanup\n"); | 3284 "Catalogs cleanup\n"); |
3284 if (xmlCatalogXMLFiles != NULL) | 3285 if (xmlCatalogXMLFiles != NULL) |
3285 » xmlHashFree(xmlCatalogXMLFiles, | 3286 » xmlHashFree(xmlCatalogXMLFiles, |
3286 (xmlHashDeallocator)xmlFreeCatalogHashEntryList); | 3287 (xmlHashDeallocator)xmlFreeCatalogHashEntryList); |
3287 xmlCatalogXMLFiles = NULL; | 3288 xmlCatalogXMLFiles = NULL; |
3288 if (xmlDefaultCatalog != NULL) | 3289 if (xmlDefaultCatalog != NULL) |
3289 xmlFreeCatalog(xmlDefaultCatalog); | 3290 xmlFreeCatalog(xmlDefaultCatalog); |
3290 xmlDefaultCatalog = NULL; | 3291 xmlDefaultCatalog = NULL; |
3291 xmlDebugCatalogs = 0; | 3292 xmlDebugCatalogs = 0; |
3292 xmlCatalogInitialized = 0; | 3293 xmlCatalogInitialized = 0; |
3293 xmlRMutexUnlock(xmlCatalogMutex); | 3294 xmlRMutexUnlock(xmlCatalogMutex); |
3294 xmlFreeRMutex(xmlCatalogMutex); | 3295 xmlFreeRMutex(xmlCatalogMutex); |
3295 } | 3296 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3390 if (!xmlCatalogInitialized) | 3391 if (!xmlCatalogInitialized) |
3391 xmlInitializeCatalog(); | 3392 xmlInitializeCatalog(); |
3392 | 3393 |
3393 xmlACatalogDump(xmlDefaultCatalog, out); | 3394 xmlACatalogDump(xmlDefaultCatalog, out); |
3394 } | 3395 } |
3395 #endif /* LIBXML_OUTPUT_ENABLED */ | 3396 #endif /* LIBXML_OUTPUT_ENABLED */ |
3396 | 3397 |
3397 /** | 3398 /** |
3398 * xmlCatalogAdd: | 3399 * xmlCatalogAdd: |
3399 * @type: the type of record to add to the catalog | 3400 * @type: the type of record to add to the catalog |
3400 * @orig: the system, public or prefix to match | 3401 * @orig: the system, public or prefix to match |
3401 * @replace: the replacement value for the match | 3402 * @replace: the replacement value for the match |
3402 * | 3403 * |
3403 * Add an entry in the catalog, it may overwrite existing but | 3404 * Add an entry in the catalog, it may overwrite existing but |
3404 * different entries. | 3405 * different entries. |
3405 * If called before any other catalog routine, allows to override the | 3406 * If called before any other catalog routine, allows to override the |
3406 * default shared catalog put in place by xmlInitializeCatalog(); | 3407 * default shared catalog put in place by xmlInitializeCatalog(); |
3407 * | 3408 * |
3408 * Returns 0 if successful, -1 otherwise | 3409 * Returns 0 if successful, -1 otherwise |
3409 */ | 3410 */ |
3410 int | 3411 int |
(...skipping 10 matching lines...) Expand all Loading... |
3421 */ | 3422 */ |
3422 if ((xmlDefaultCatalog == NULL) && | 3423 if ((xmlDefaultCatalog == NULL) && |
3423 (xmlStrEqual(type, BAD_CAST "catalog"))) { | 3424 (xmlStrEqual(type, BAD_CAST "catalog"))) { |
3424 xmlDefaultCatalog = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE, | 3425 xmlDefaultCatalog = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE, |
3425 xmlCatalogDefaultPrefer); | 3426 xmlCatalogDefaultPrefer); |
3426 xmlDefaultCatalog->xml = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, | 3427 xmlDefaultCatalog->xml = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, |
3427 orig, NULL, xmlCatalogDefaultPrefer, NULL); | 3428 orig, NULL, xmlCatalogDefaultPrefer, NULL); |
3428 | 3429 |
3429 xmlRMutexUnlock(xmlCatalogMutex); | 3430 xmlRMutexUnlock(xmlCatalogMutex); |
3430 return(0); | 3431 return(0); |
3431 } | 3432 } |
3432 | 3433 |
3433 res = xmlACatalogAdd(xmlDefaultCatalog, type, orig, replace); | 3434 res = xmlACatalogAdd(xmlDefaultCatalog, type, orig, replace); |
3434 xmlRMutexUnlock(xmlCatalogMutex); | 3435 xmlRMutexUnlock(xmlCatalogMutex); |
3435 return(res); | 3436 return(res); |
3436 } | 3437 } |
3437 | 3438 |
3438 /** | 3439 /** |
3439 * xmlCatalogRemove: | 3440 * xmlCatalogRemove: |
3440 * @value: the value to remove | 3441 * @value: the value to remove |
3441 * | 3442 * |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3547 if (xmlDebugCatalogs) { | 3548 if (xmlDebugCatalogs) { |
3548 switch (prefer) { | 3549 switch (prefer) { |
3549 case XML_CATA_PREFER_PUBLIC: | 3550 case XML_CATA_PREFER_PUBLIC: |
3550 xmlGenericError(xmlGenericErrorContext, | 3551 xmlGenericError(xmlGenericErrorContext, |
3551 "Setting catalog preference to PUBLIC\n"); | 3552 "Setting catalog preference to PUBLIC\n"); |
3552 break; | 3553 break; |
3553 case XML_CATA_PREFER_SYSTEM: | 3554 case XML_CATA_PREFER_SYSTEM: |
3554 xmlGenericError(xmlGenericErrorContext, | 3555 xmlGenericError(xmlGenericErrorContext, |
3555 "Setting catalog preference to SYSTEM\n"); | 3556 "Setting catalog preference to SYSTEM\n"); |
3556 break; | 3557 break; |
3557 » case XML_CATA_PREFER_NONE: | 3558 » default: |
3558 » » break; | 3559 » » return(ret); |
3559 } | 3560 } |
3560 } | 3561 } |
3561 xmlCatalogDefaultPrefer = prefer; | 3562 xmlCatalogDefaultPrefer = prefer; |
3562 return(ret); | 3563 return(ret); |
3563 } | 3564 } |
3564 | 3565 |
3565 /** | 3566 /** |
3566 * xmlCatalogSetDebug: | 3567 * xmlCatalogSetDebug: |
3567 * @level: the debug level of catalogs required | 3568 * @level: the debug level of catalogs required |
3568 * | 3569 * |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3609 | 3610 |
3610 /** | 3611 /** |
3611 * xmlCatalogAddLocal: | 3612 * xmlCatalogAddLocal: |
3612 * @catalogs: a document's list of catalogs | 3613 * @catalogs: a document's list of catalogs |
3613 * @URL: the URL to a new local catalog | 3614 * @URL: the URL to a new local catalog |
3614 * | 3615 * |
3615 * Add the new entry to the catalog list | 3616 * Add the new entry to the catalog list |
3616 * | 3617 * |
3617 * Returns the updated list | 3618 * Returns the updated list |
3618 */ | 3619 */ |
3619 void *» | 3620 void * |
3620 xmlCatalogAddLocal(void *catalogs, const xmlChar *URL) { | 3621 xmlCatalogAddLocal(void *catalogs, const xmlChar *URL) { |
3621 xmlCatalogEntryPtr catal, add; | 3622 xmlCatalogEntryPtr catal, add; |
3622 | 3623 |
3623 if (!xmlCatalogInitialized) | 3624 if (!xmlCatalogInitialized) |
3624 xmlInitializeCatalog(); | 3625 xmlInitializeCatalog(); |
3625 | 3626 |
3626 if (URL == NULL) | 3627 if (URL == NULL) |
3627 return(catalogs); | 3628 return(catalogs); |
3628 | 3629 |
3629 if (xmlDebugCatalogs) | 3630 if (xmlDebugCatalogs) |
3630 xmlGenericError(xmlGenericErrorContext, | 3631 xmlGenericError(xmlGenericErrorContext, |
3631 "Adding document catalog %s\n", URL); | 3632 "Adding document catalog %s\n", URL); |
3632 | 3633 |
3633 add = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, URL, NULL, | 3634 add = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, URL, NULL, |
3634 xmlCatalogDefaultPrefer, NULL); | 3635 xmlCatalogDefaultPrefer, NULL); |
3635 if (add == NULL) | 3636 if (add == NULL) |
3636 return(catalogs); | 3637 return(catalogs); |
3637 | 3638 |
3638 catal = (xmlCatalogEntryPtr) catalogs; | 3639 catal = (xmlCatalogEntryPtr) catalogs; |
3639 if (catal == NULL) | 3640 if (catal == NULL) |
3640 return((void *) add); | 3641 return((void *) add); |
3641 | 3642 |
3642 while (catal->next != NULL) | 3643 while (catal->next != NULL) |
3643 catal = catal->next; | 3644 catal = catal->next; |
3644 catal->next = add; | 3645 catal->next = add; |
3645 return(catalogs); | 3646 return(catalogs); |
3646 } | 3647 } |
3647 | 3648 |
3648 /** | 3649 /** |
3649 * xmlCatalogLocalResolve: | 3650 * xmlCatalogLocalResolve: |
3650 * @catalogs: a document's list of catalogs | 3651 * @catalogs: a document's list of catalogs |
3651 * @pubID: the public ID string | 3652 * @pubID: the public ID string |
3652 * @sysID: the system ID string | 3653 * @sysID: the system ID string |
3653 * | 3654 * |
3654 * Do a complete resolution lookup of an External Identifier using a | 3655 * Do a complete resolution lookup of an External Identifier using a |
3655 * document's private catalog list | 3656 * document's private catalog list |
3656 * | 3657 * |
3657 * Returns the URI of the resource or NULL if not found, it must be freed | 3658 * Returns the URI of the resource or NULL if not found, it must be freed |
3658 * by the caller. | 3659 * by the caller. |
3659 */ | 3660 */ |
3660 xmlChar * | 3661 xmlChar * |
3661 xmlCatalogLocalResolve(void *catalogs, const xmlChar *pubID, | 3662 xmlCatalogLocalResolve(void *catalogs, const xmlChar *pubID, |
3662 const xmlChar *sysID) { | 3663 const xmlChar *sysID) { |
3663 xmlCatalogEntryPtr catal; | 3664 xmlCatalogEntryPtr catal; |
3664 xmlChar *ret; | 3665 xmlChar *ret; |
(...skipping 24 matching lines...) Expand all Loading... |
3689 if ((ret != NULL) && (ret != XML_CATAL_BREAK)) | 3690 if ((ret != NULL) && (ret != XML_CATAL_BREAK)) |
3690 return(ret); | 3691 return(ret); |
3691 return(NULL); | 3692 return(NULL); |
3692 } | 3693 } |
3693 | 3694 |
3694 /** | 3695 /** |
3695 * xmlCatalogLocalResolveURI: | 3696 * xmlCatalogLocalResolveURI: |
3696 * @catalogs: a document's list of catalogs | 3697 * @catalogs: a document's list of catalogs |
3697 * @URI: the URI | 3698 * @URI: the URI |
3698 * | 3699 * |
3699 * Do a complete resolution lookup of an URI using a | 3700 * Do a complete resolution lookup of an URI using a |
3700 * document's private catalog list | 3701 * document's private catalog list |
3701 * | 3702 * |
3702 * Returns the URI of the resource or NULL if not found, it must be freed | 3703 * Returns the URI of the resource or NULL if not found, it must be freed |
3703 * by the caller. | 3704 * by the caller. |
3704 */ | 3705 */ |
3705 xmlChar * | 3706 xmlChar * |
3706 xmlCatalogLocalResolveURI(void *catalogs, const xmlChar *URI) { | 3707 xmlCatalogLocalResolveURI(void *catalogs, const xmlChar *URI) { |
3707 xmlCatalogEntryPtr catal; | 3708 xmlCatalogEntryPtr catal; |
3708 xmlChar *ret; | 3709 xmlChar *ret; |
3709 | 3710 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3750 xmlInitializeCatalog(); | 3751 xmlInitializeCatalog(); |
3751 | 3752 |
3752 if (msg == 0) { | 3753 if (msg == 0) { |
3753 xmlGenericError(xmlGenericErrorContext, | 3754 xmlGenericError(xmlGenericErrorContext, |
3754 "Use of deprecated xmlCatalogGetSystem() call\n"); | 3755 "Use of deprecated xmlCatalogGetSystem() call\n"); |
3755 msg++; | 3756 msg++; |
3756 } | 3757 } |
3757 | 3758 |
3758 if (sysID == NULL) | 3759 if (sysID == NULL) |
3759 return(NULL); | 3760 return(NULL); |
3760 | 3761 |
3761 /* | 3762 /* |
3762 * Check first the XML catalogs | 3763 * Check first the XML catalogs |
3763 */ | 3764 */ |
3764 if (xmlDefaultCatalog != NULL) { | 3765 if (xmlDefaultCatalog != NULL) { |
3765 ret = xmlCatalogListXMLResolve(xmlDefaultCatalog->xml, NULL, sysID); | 3766 ret = xmlCatalogListXMLResolve(xmlDefaultCatalog->xml, NULL, sysID); |
3766 if ((ret != NULL) && (ret != XML_CATAL_BREAK)) { | 3767 if ((ret != NULL) && (ret != XML_CATAL_BREAK)) { |
3767 snprintf((char *) result, sizeof(result) - 1, "%s", (char *) ret); | 3768 snprintf((char *) result, sizeof(result) - 1, "%s", (char *) ret); |
3768 result[sizeof(result) - 1] = 0; | 3769 result[sizeof(result) - 1] = 0; |
3769 return(result); | 3770 return(result); |
3770 } | 3771 } |
(...skipping 23 matching lines...) Expand all Loading... |
3794 xmlInitializeCatalog(); | 3795 xmlInitializeCatalog(); |
3795 | 3796 |
3796 if (msg == 0) { | 3797 if (msg == 0) { |
3797 xmlGenericError(xmlGenericErrorContext, | 3798 xmlGenericError(xmlGenericErrorContext, |
3798 "Use of deprecated xmlCatalogGetPublic() call\n"); | 3799 "Use of deprecated xmlCatalogGetPublic() call\n"); |
3799 msg++; | 3800 msg++; |
3800 } | 3801 } |
3801 | 3802 |
3802 if (pubID == NULL) | 3803 if (pubID == NULL) |
3803 return(NULL); | 3804 return(NULL); |
3804 | 3805 |
3805 /* | 3806 /* |
3806 * Check first the XML catalogs | 3807 * Check first the XML catalogs |
3807 */ | 3808 */ |
3808 if (xmlDefaultCatalog != NULL) { | 3809 if (xmlDefaultCatalog != NULL) { |
3809 ret = xmlCatalogListXMLResolve(xmlDefaultCatalog->xml, pubID, NULL); | 3810 ret = xmlCatalogListXMLResolve(xmlDefaultCatalog->xml, pubID, NULL); |
3810 if ((ret != NULL) && (ret != XML_CATAL_BREAK)) { | 3811 if ((ret != NULL) && (ret != XML_CATAL_BREAK)) { |
3811 snprintf((char *) result, sizeof(result) - 1, "%s", (char *) ret); | 3812 snprintf((char *) result, sizeof(result) - 1, "%s", (char *) ret); |
3812 result[sizeof(result) - 1] = 0; | 3813 result[sizeof(result) - 1] = 0; |
3813 return(result); | 3814 return(result); |
3814 } | 3815 } |
3815 } | 3816 } |
3816 | 3817 |
3817 if (xmlDefaultCatalog != NULL) | 3818 if (xmlDefaultCatalog != NULL) |
3818 return(xmlCatalogGetSGMLPublic(xmlDefaultCatalog->sgml, pubID)); | 3819 return(xmlCatalogGetSGMLPublic(xmlDefaultCatalog->sgml, pubID)); |
3819 return(NULL); | 3820 return(NULL); |
3820 } | 3821 } |
3821 | 3822 |
3822 #define bottom_catalog | 3823 #define bottom_catalog |
3823 #include "elfgcchack.h" | 3824 #include "elfgcchack.h" |
3824 #endif /* LIBXML_CATALOG_ENABLED */ | 3825 #endif /* LIBXML_CATALOG_ENABLED */ |
OLD | NEW |