summaryrefslogtreecommitdiff
path: root/xmlIO.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2001-08-22 00:06:49 +0000
committerDaniel Veillard <veillard@src.gnome.org>2001-08-22 00:06:49 +0000
commite2940ddb351e0aa2055ec6b74c245685196d532b (patch)
tree00d08550a570bc97b7c70fcd8e681588cacdb559 /xmlIO.c
parent6433954692abb5620ed4e554a2979ef4ecdc6871 (diff)
downloadlibxml2-e2940ddb351e0aa2055ec6b74c245685196d532b.tar.gz
starts to look okay, really plugged the new framework, cleaned a lot of
* catalog.c parser.c xmlIO.c xmlcatalog.c xmllint.c include/libxml/catalog.h: starts to look okay, really plugged the new framework, cleaned a lot of stuff, added some APIs, except the PI's support missing this should be mostly complete * result/catalogs/* test/catalogs/*: added new test, enriched the existing one with URN ID tests Daniel
Diffstat (limited to 'xmlIO.c')
-rw-r--r--xmlIO.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/xmlIO.c b/xmlIO.c
index 981528ff..1cfefcef 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -2371,7 +2371,10 @@ xmlParserInputPtr
xmlDefaultExternalEntityLoader(const char *URL, const char *ID,
xmlParserCtxtPtr ctxt) {
xmlParserInputPtr ret = NULL;
- const xmlChar *resource = NULL;
+ xmlChar *resource = NULL;
+#ifdef LIBXML_CATALOG_ENABLED
+ struct stat info;
+#endif
#ifdef DEBUG_EXTERNAL_ENTITIES
xmlGenericError(xmlGenericErrorContext,
@@ -2379,16 +2382,18 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID,
#endif
#ifdef LIBXML_CATALOG_ENABLED
/*
- * Try to load it from the resource pointed in the catalog
+ * If the resource doesn't exists as a file,
+ * try to load it from the resource pointed in the catalog
*/
- if (ID != NULL)
- resource = xmlCatalogGetPublic((const xmlChar *)ID);
- if ((resource == NULL) && (URL != NULL))
- resource = xmlCatalogGetSystem((const xmlChar *)URL);
+#ifdef HAVE_STAT
+ if ((URL == NULL) || (stat(URL, &info) < 0))
+#endif
+ resource = xmlCatalogResolve((const xmlChar *)ID,
+ (const xmlChar *)URL);
#endif
if (resource == NULL)
- resource = (const xmlChar *)URL;
+ resource = (xmlChar *) URL;
if (resource == NULL) {
if ((ctxt->validate) && (ctxt->sax != NULL) &&
@@ -2410,6 +2415,8 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID,
ctxt->sax->warning(ctxt,
"failed to load external entity \"%s\"\n", resource);
}
+ if (resource != (xmlChar *) URL)
+ xmlFree(resource);
return(ret);
}