Commit 61b9338c authored by Daniel Veillard's avatar Daniel Veillard

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
parent 7899c5c5
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
......
......@@ -259,6 +259,9 @@ XMLPUBFUN int XMLCALL xmlIsLetter (int c);
*/
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);
......
......@@ -11433,17 +11433,18 @@ xmlCreateEntityParserCtxt(const xmlChar *URL, const xmlChar *ID,
************************************************************************/
/**
* 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 @@ xmlCreateFileParserCtxt(const char *filename)
return(NULL);
}
if (options != 0)
xmlCtxtUseOptions(ctxt, options);
inputStream = xmlLoadExternalEntity(filename, NULL, ctxt);
if (inputStream == NULL) {
......@@ -11471,6 +11474,22 @@ xmlCreateFileParserCtxt(const char *filename)
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 @@ xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
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 @@ xmlReadFile(const char *filename, const char *encoding, int options)
{
xmlParserCtxtPtr ctxt;
ctxt = xmlCreateFileParserCtxt(filename);
ctxt = xmlCreateURLParserCtxt(filename, options);
if (ctxt == NULL)
return (NULL);
return (xmlDoRead(ctxt, NULL, encoding, options, 0));
......
......@@ -3091,6 +3091,15 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID,
"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
......
......@@ -1686,7 +1686,7 @@ main(int argc, char **argv) {
#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]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment