1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-19 14:50:07 +03:00

Changed the new xmlRead/xmlCtxtRead APIs to have an extra base URL

* parser.c xmllint.c doc/libxml2-api.xml include/libxml/parser.h:
  Changed the new xmlRead/xmlCtxtRead APIs to have an extra
  base URL parameter when not loading from a file or URL.
Daniel
This commit is contained in:
Daniel Veillard 2003-09-25 21:05:58 +00:00
parent 092643b52d
commit 60942def6a
6 changed files with 66 additions and 28 deletions

View File

@ -1,3 +1,9 @@
Thu Sep 25 23:03:23 CEST 2003 Daniel Veillard <daniel@veillard.com>
* parser.c xmllint.c doc/libxml2-api.xml include/libxml/parser.h:
Changed the new xmlRead/xmlCtxtRead APIs to have an extra
base URL parameter when not loading from a file or URL.
Thu Sep 25 16:23:58 CEST 2003 Daniel Veillard <daniel@veillard.com>
* configure.in: preparing a beta3 solving the ABI problems

View File

@ -5746,6 +5746,7 @@ actually an xmlCharEncoding'/>
<return type='xmlDocPtr' info='the resulting document tree'/>
<arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
<arg name='cur' type='const xmlChar *' info='a pointer to a zero terminated string'/>
<arg name='URL' type='const char *' info='the base URL to use for the document'/>
<arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
<arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
</function>
@ -5754,6 +5755,7 @@ actually an xmlCharEncoding'/>
<return type='xmlDocPtr' info='the resulting document tree'/>
<arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
<arg name='fd' type='int' info='an open file descriptor'/>
<arg name='URL' type='const char *' info='the base URL to use for the document'/>
<arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
<arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
</function>
@ -5772,6 +5774,7 @@ actually an xmlCharEncoding'/>
<arg name='ioread' type='xmlInputReadCallback' info='an I/O read function'/>
<arg name='ioclose' type='xmlInputCloseCallback' info='an I/O close function'/>
<arg name='ioctx' type='void *' info='an I/O handler'/>
<arg name='URL' type='const char *' info='the base URL to use for the document'/>
<arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
<arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
</function>
@ -5781,6 +5784,7 @@ actually an xmlCharEncoding'/>
<arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
<arg name='buffer' type='const char *' info='a pointer to a char array'/>
<arg name='size' type='int' info='the size of the array'/>
<arg name='URL' type='const char *' info='the base URL to use for the document'/>
<arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
<arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
</function>
@ -6554,9 +6558,9 @@ actually an xmlCharEncoding'/>
<info>Find the userdata specified by the QNames tuple</info>
<return type='void *' info='the pointer to the userdata'/>
<arg name='table' type='xmlHashTablePtr' info='the hash table'/>
<arg name='prefix' type='const xmlChar *' info='the second prefix of the userdata'/>
<arg name='prefix' type='const xmlChar *' info='the prefix of the userdata'/>
<arg name='name' type='const xmlChar *' info='the name of the userdata'/>
<arg name='prefix2' type='const xmlChar *' info=''/>
<arg name='prefix2' type='const xmlChar *' info='the second prefix of the userdata'/>
<arg name='name2' type='const xmlChar *' info='a second name of the userdata'/>
</function>
<function name='xmlHashQLookup3' file='hash'>
@ -8402,6 +8406,7 @@ actually an xmlCharEncoding'/>
<info>parse an XML in-memory document and build a tree.</info>
<return type='xmlDocPtr' info='the resulting document tree'/>
<arg name='cur' type='const xmlChar *' info='a pointer to a zero terminated string'/>
<arg name='URL' type='const char *' info='the base URL to use for the document'/>
<arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
<arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
</function>
@ -8409,6 +8414,7 @@ actually an xmlCharEncoding'/>
<info>parse an XML from a file descriptor and build a tree.</info>
<return type='xmlDocPtr' info='the resulting document tree'/>
<arg name='fd' type='int' info='an open file descriptor'/>
<arg name='URL' type='const char *' info='the base URL to use for the document'/>
<arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
<arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
</function>
@ -8425,6 +8431,7 @@ actually an xmlCharEncoding'/>
<arg name='ioread' type='xmlInputReadCallback' info='an I/O read function'/>
<arg name='ioclose' type='xmlInputCloseCallback' info='an I/O close function'/>
<arg name='ioctx' type='void *' info='an I/O handler'/>
<arg name='URL' type='const char *' info='the base URL to use for the document'/>
<arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
<arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
</function>
@ -8433,6 +8440,7 @@ actually an xmlCharEncoding'/>
<return type='xmlDocPtr' info='the resulting document tree'/>
<arg name='buffer' type='const char *' info='a pointer to a char array'/>
<arg name='size' type='int' info='the size of the array'/>
<arg name='URL' type='const char *' info='the base URL to use for the document'/>
<arg name='encoding' type='const char *' info='the document encoding, or NULL'/>
<arg name='options' type='int' info='a combination of xmlParserOption(s)'/>
</function>

View File

@ -1055,30 +1055,35 @@ XMLPUBFUN int XMLCALL
int options);
XMLPUBFUN xmlDocPtr XMLCALL
xmlReadDoc (const xmlChar *cur,
const char *URL,
const char *encoding,
int options);
XMLPUBFUN xmlDocPtr XMLCALL
xmlReadFile (const char *filename,
xmlReadFile (const char *URL,
const char *encoding,
int options);
XMLPUBFUN xmlDocPtr XMLCALL
xmlReadMemory (const char *buffer,
int size,
const char *URL,
const char *encoding,
int options);
XMLPUBFUN xmlDocPtr XMLCALL
xmlReadFd (int fd,
const char *URL,
const char *encoding,
int options);
XMLPUBFUN xmlDocPtr XMLCALL
xmlReadIO (xmlInputReadCallback ioread,
xmlInputCloseCallback ioclose,
void *ioctx,
const char *URL,
const char *encoding,
int options);
XMLPUBFUN xmlDocPtr XMLCALL
xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
const xmlChar *cur,
const char *URL,
const char *encoding,
int options);
XMLPUBFUN xmlDocPtr XMLCALL
@ -1090,11 +1095,13 @@ XMLPUBFUN xmlDocPtr XMLCALL
xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
const char *buffer,
int size,
const char *URL,
const char *encoding,
int options);
XMLPUBFUN xmlDocPtr XMLCALL
xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
int fd,
const char *URL,
const char *encoding,
int options);
XMLPUBFUN xmlDocPtr XMLCALL
@ -1102,6 +1109,7 @@ XMLPUBFUN xmlDocPtr XMLCALL
xmlInputReadCallback ioread,
xmlInputCloseCallback ioclose,
void *ioctx,
const char *URL,
const char *encoding,
int options);

View File

@ -12102,6 +12102,7 @@ xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
/**
* xmlDoRead:
* @ctxt: an XML parser context
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption(s)
* @reuse: keep the context for reuse
@ -12111,7 +12112,8 @@ xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
* Returns the resulting document tree or NULL
*/
static xmlDocPtr
xmlDoRead(xmlParserCtxtPtr ctxt, const char *encoding, int options, int reuse)
xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding,
int options, int reuse)
{
xmlDocPtr ret;
@ -12123,6 +12125,9 @@ xmlDoRead(xmlParserCtxtPtr ctxt, const char *encoding, int options, int reuse)
if (hdlr != NULL)
xmlSwitchToEncoding(ctxt, hdlr);
}
if ((URL != NULL) && (ctxt->input != NULL) &&
(ctxt->input->filename == NULL))
ctxt->input->filename = (char *) xmlStrdup((const xmlChar *) URL);
xmlParseDocument(ctxt);
if ((ctxt->wellFormed) || ctxt->recovery)
ret = ctxt->myDoc;
@ -12154,6 +12159,7 @@ xmlDoRead(xmlParserCtxtPtr ctxt, const char *encoding, int options, int reuse)
/**
* xmlReadDoc:
* @cur: a pointer to a zero terminated string
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption(s)
*
@ -12162,7 +12168,7 @@ xmlDoRead(xmlParserCtxtPtr ctxt, const char *encoding, int options, int reuse)
* Returns the resulting document tree
*/
xmlDocPtr
xmlReadDoc(const xmlChar * cur, const char *encoding, int options)
xmlReadDoc(const xmlChar * cur, const char *URL, const char *encoding, int options)
{
xmlParserCtxtPtr ctxt;
@ -12172,7 +12178,7 @@ xmlReadDoc(const xmlChar * cur, const char *encoding, int options)
ctxt = xmlCreateDocParserCtxt(cur);
if (ctxt == NULL)
return (NULL);
return (xmlDoRead(ctxt, encoding, options, 0));
return (xmlDoRead(ctxt, URL, encoding, options, 0));
}
/**
@ -12193,13 +12199,14 @@ xmlReadFile(const char *filename, const char *encoding, int options)
ctxt = xmlCreateFileParserCtxt(filename);
if (ctxt == NULL)
return (NULL);
return (xmlDoRead(ctxt, encoding, options, 0));
return (xmlDoRead(ctxt, NULL, encoding, options, 0));
}
/**
* xmlReadMemory:
* @buffer: a pointer to a char array
* @size: the size of the array
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption(s)
*
@ -12208,19 +12215,20 @@ xmlReadFile(const char *filename, const char *encoding, int options)
* Returns the resulting document tree
*/
xmlDocPtr
xmlReadMemory(const char *buffer, int size, const char *encoding, int options)
xmlReadMemory(const char *buffer, int size, const char *URL, const char *encoding, int options)
{
xmlParserCtxtPtr ctxt;
ctxt = xmlCreateMemoryParserCtxt(buffer, size);
if (ctxt == NULL)
return (NULL);
return (xmlDoRead(ctxt, encoding, options, 0));
return (xmlDoRead(ctxt, URL, encoding, options, 0));
}
/**
* xmlReadFd:
* @fd: an open file descriptor
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption(s)
*
@ -12229,7 +12237,7 @@ xmlReadMemory(const char *buffer, int size, const char *encoding, int options)
* Returns the resulting document tree
*/
xmlDocPtr
xmlReadFd(int fd, const char *encoding, int options)
xmlReadFd(int fd, const char *URL, const char *encoding, int options)
{
xmlParserCtxtPtr ctxt;
xmlParserInputBufferPtr input;
@ -12253,7 +12261,7 @@ xmlReadFd(int fd, const char *encoding, int options)
return (NULL);
}
inputPush(ctxt, stream);
return (xmlDoRead(ctxt, encoding, options, 0));
return (xmlDoRead(ctxt, URL, encoding, options, 0));
}
/**
@ -12261,6 +12269,7 @@ xmlReadFd(int fd, const char *encoding, int options)
* @ioread: an I/O read function
* @ioclose: an I/O close function
* @ioctx: an I/O handler
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption(s)
*
@ -12270,7 +12279,7 @@ xmlReadFd(int fd, const char *encoding, int options)
*/
xmlDocPtr
xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
void *ioctx, const char *encoding, int options)
void *ioctx, const char *URL, const char *encoding, int options)
{
xmlParserCtxtPtr ctxt;
xmlParserInputBufferPtr input;
@ -12295,13 +12304,14 @@ xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
return (NULL);
}
inputPush(ctxt, stream);
return (xmlDoRead(ctxt, encoding, options, 0));
return (xmlDoRead(ctxt, URL, encoding, options, 0));
}
/**
* xmlCtxtReadDoc:
* @ctxt: an XML parser context
* @cur: a pointer to a zero terminated string
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption(s)
*
@ -12312,7 +12322,7 @@ xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
*/
xmlDocPtr
xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar * cur,
const char *encoding, int options)
const char *URL, const char *encoding, int options)
{
xmlParserInputPtr stream;
@ -12328,7 +12338,7 @@ xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar * cur,
return (NULL);
}
inputPush(ctxt, stream);
return (xmlDoRead(ctxt, encoding, options, 1));
return (xmlDoRead(ctxt, URL, encoding, options, 1));
}
/**
@ -12361,7 +12371,7 @@ xmlCtxtReadFile(xmlParserCtxtPtr ctxt, const char *filename,
return (NULL);
}
inputPush(ctxt, stream);
return (xmlDoRead(ctxt, encoding, options, 1));
return (xmlDoRead(ctxt, NULL, encoding, options, 1));
}
/**
@ -12369,6 +12379,7 @@ xmlCtxtReadFile(xmlParserCtxtPtr ctxt, const char *filename,
* @ctxt: an XML parser context
* @buffer: a pointer to a char array
* @size: the size of the array
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption(s)
*
@ -12379,7 +12390,7 @@ xmlCtxtReadFile(xmlParserCtxtPtr ctxt, const char *filename,
*/
xmlDocPtr
xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size,
const char *encoding, int options)
const char *URL, const char *encoding, int options)
{
xmlParserInputBufferPtr input;
xmlParserInputPtr stream;
@ -12403,13 +12414,14 @@ xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size,
}
inputPush(ctxt, stream);
return (xmlDoRead(ctxt, encoding, options, 1));
return (xmlDoRead(ctxt, URL, encoding, options, 1));
}
/**
* xmlCtxtReadFd:
* @ctxt: an XML parser context
* @fd: an open file descriptor
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption(s)
*
@ -12419,8 +12431,8 @@ xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size,
* Returns the resulting document tree
*/
xmlDocPtr
xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd, const char *encoding,
int options)
xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd,
const char *URL, const char *encoding, int options)
{
xmlParserInputBufferPtr input;
xmlParserInputPtr stream;
@ -12442,7 +12454,7 @@ xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd, const char *encoding,
return (NULL);
}
inputPush(ctxt, stream);
return (xmlDoRead(ctxt, encoding, options, 1));
return (xmlDoRead(ctxt, URL, encoding, options, 1));
}
/**
@ -12451,6 +12463,7 @@ xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd, const char *encoding,
* @ioread: an I/O read function
* @ioclose: an I/O close function
* @ioctx: an I/O handler
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption(s)
*
@ -12462,6 +12475,7 @@ xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd, const char *encoding,
xmlDocPtr
xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
xmlInputCloseCallback ioclose, void *ioctx,
const char *URL,
const char *encoding, int options)
{
xmlParserInputBufferPtr input;
@ -12484,5 +12498,5 @@ xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
return (NULL);
}
inputPush(ctxt, stream);
return (xmlDoRead(ctxt, encoding, options, 1));
return (xmlDoRead(ctxt, URL, encoding, options, 1));
}

View File

@ -673,6 +673,7 @@ xmlDictFree
xmlDictLookup
xmlDictOwns
xmlDictQLookup
xmlDictReference
xmlDictSize
xmlDocCopyNode
xmlDocDump

View File

@ -806,7 +806,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
}
} else if (testIO) {
if ((filename[0] == '-') && (filename[1] == 0)) {
doc = xmlReadFd(0, NULL, options);
doc = xmlReadFd(0, NULL, NULL, options);
} else {
FILE *f;
@ -815,12 +815,12 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
if (rectxt == NULL)
doc = xmlReadIO((xmlInputReadCallback) myRead,
(xmlInputCloseCallback) myClose, f,
NULL, options);
filename, NULL, options);
else
doc = xmlCtxtReadIO(rectxt,
(xmlInputReadCallback) myRead,
(xmlInputCloseCallback) myClose, f,
NULL, options);
filename, NULL, options);
} else
doc = NULL;
}
@ -858,10 +858,11 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
return;
if (rectxt == NULL)
doc = xmlReadMemory((char *) base, info.st_size, NULL, options);
doc = xmlReadMemory((char *) base, info.st_size,
filename, NULL, options);
else
doc = xmlCtxtReadMemory(rectxt,
(char *) base, info.st_size, NULL, options);
doc = xmlCtxtReadMemory(rectxt, (char *) base, info.st_size,
filename, NULL, options);
munmap((char *) base, info.st_size);
#endif