implemented the XML_PARSE_NONET parser option. converted xmllint.c to use
* parser.c xmlIO.c include/libxml/parserInternals.h: implemented
the XML_PARSE_NONET parser option.
* xmllint.c: converted xmllint.c to use the option instead of
relying on the global resolver variable.
Daniel
diff --git a/ChangeLog b/ChangeLog
index aaccd9b..4a1b04c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Nov 3 15:25:58 CET 2003 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c xmlIO.c include/libxml/parserInternals.h: implemented
+ the XML_PARSE_NONET parser option.
+ * xmllint.c: converted xmllint.c to use the option instead of
+ relying on the global resolver variable.
+
Mon Nov 3 13:26:32 CET 2003 Daniel Veillard <daniel@veillard.com>
* xinclude.c xmlreader.c include/libxml/xinclude.h: adding XInclude
diff --git a/include/libxml/parserInternals.h b/include/libxml/parserInternals.h
index 495b051..e139199 100644
--- a/include/libxml/parserInternals.h
+++ b/include/libxml/parserInternals.h
@@ -260,6 +260,9 @@
XMLPUBFUN xmlParserCtxtPtr XMLCALL
xmlCreateFileParserCtxt (const char *filename);
XMLPUBFUN xmlParserCtxtPtr XMLCALL
+ xmlCreateURLParserCtxt (const char *filename,
+ int options);
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
xmlCreateMemoryParserCtxt(const char *buffer,
int size);
XMLPUBFUN xmlParserCtxtPtr XMLCALL
diff --git a/parser.c b/parser.c
index 7680e3a..ff58294 100644
--- a/parser.c
+++ b/parser.c
@@ -11433,17 +11433,18 @@
************************************************************************/
/**
- * xmlCreateFileParserCtxt:
- * @filename: the filename
+ * xmlCreateURLParserCtxt:
+ * @filename: the filename or URL
+ * @options: a combination of xmlParserOption(s)
*
- * Create a parser context for a file content.
+ * Create a parser context for a file or URL content.
* Automatic support for ZLIB/Compress compressed document is provided
- * by default if found at compile-time.
+ * by default if found at compile-time and for file accesses
*
* Returns the new parser context or NULL
*/
xmlParserCtxtPtr
-xmlCreateFileParserCtxt(const char *filename)
+xmlCreateURLParserCtxt(const char *filename, int options)
{
xmlParserCtxtPtr ctxt;
xmlParserInputPtr inputStream;
@@ -11455,6 +11456,8 @@
return(NULL);
}
+ if (options != 0)
+ xmlCtxtUseOptions(ctxt, options);
inputStream = xmlLoadExternalEntity(filename, NULL, ctxt);
if (inputStream == NULL) {
@@ -11471,6 +11474,22 @@
return(ctxt);
}
+/**
+ * xmlCreateFileParserCtxt:
+ * @filename: the filename
+ *
+ * Create a parser context for a file content.
+ * Automatic support for ZLIB/Compress compressed document is provided
+ * by default if found at compile-time.
+ *
+ * Returns the new parser context or NULL
+ */
+xmlParserCtxtPtr
+xmlCreateFileParserCtxt(const char *filename)
+{
+ return(xmlCreateURLParserCtxt(filename, 0));
+}
+
#ifdef LIBXML_SAX1_ENABLED
/**
* xmlSAXParseFileWithData:
@@ -12385,6 +12404,10 @@
ctxt->options |= XML_PARSE_NSCLEAN;
options -= XML_PARSE_NSCLEAN;
}
+ if (options & XML_PARSE_NONET) {
+ ctxt->options |= XML_PARSE_NONET;
+ options -= XML_PARSE_NONET;
+ }
ctxt->linenumbers = 1;
return (options);
}
@@ -12488,7 +12511,7 @@
{
xmlParserCtxtPtr ctxt;
- ctxt = xmlCreateFileParserCtxt(filename);
+ ctxt = xmlCreateURLParserCtxt(filename, options);
if (ctxt == NULL)
return (NULL);
return (xmlDoRead(ctxt, NULL, encoding, options, 0));
diff --git a/xmlIO.c b/xmlIO.c
index 33c544b..02c5ec9 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -3091,6 +3091,15 @@
"xmlDefaultExternalEntityLoader(%s, xxx)\n", URL);
#endif
#ifdef LIBXML_CATALOG_ENABLED
+ if ((ctxt != NULL) && (ctxt->options & XML_PARSE_NONET)) {
+ int options = ctxt->options;
+
+ ctxt->options -= XML_PARSE_NONET;
+ ret = xmlNoNetExternalEntityLoader(URL, ID, ctxt);
+ ctxt->options = options;
+ return(ret);
+ }
+
/*
* If the resource doesn't exists as a file,
* try to load it from the resource pointed in the catalogs
diff --git a/xmllint.c b/xmllint.c
index f8556d0..9ecad8e 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -1686,7 +1686,7 @@
#endif
} else if ((!strcmp(argv[i], "-nonet")) ||
(!strcmp(argv[i], "--nonet"))) {
- xmlSetExternalEntityLoader(xmlNoNetExternalEntityLoader);
+ options |= XML_PARSE_NONET;
} else {
fprintf(stderr, "Unknown option %s\n", argv[i]);
usage(argv[0]);