1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 03:55:04 +03:00

parser: Rename new input API functions

These weren't made public yet.
This commit is contained in:
Nick Wellnhofer 2024-07-06 22:14:21 +02:00
parent d74ca59491
commit 8af55c8d20
14 changed files with 333 additions and 333 deletions

View File

@ -5847,7 +5847,7 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
return(NULL);
encoding = xmlGetCharEncodingName(enc);
input = xmlInputCreatePush(filename, chunk, size);
input = xmlNewPushInput(filename, chunk, size);
if (input == NULL) {
htmlFreeParserCtxt(ctxt);
return(NULL);

View File

@ -521,6 +521,10 @@
<description>Interfaces, constants and types related to the XML parser </description>
<author>Daniel Veillard </author>
<exports symbol='XML_DEFAULT_VERSION' type='macro'/>
<exports symbol='XML_INPUT_BUF_STATIC' type='macro'/>
<exports symbol='XML_INPUT_BUF_ZERO_TERMINATED' type='macro'/>
<exports symbol='XML_INPUT_NETWORK' type='macro'/>
<exports symbol='XML_INPUT_UNZIP' type='macro'/>
<exports symbol='XML_SAX2_MAGIC' type='macro'/>
<exports symbol='XML_STATUS_CATASTROPHIC_ERROR' type='macro'/>
<exports symbol='XML_STATUS_DTD_VALIDATION_FAILED' type='macro'/>
@ -718,10 +722,16 @@
<exports symbol='xmlInitNodeInfoSeq' type='function'/>
<exports symbol='xmlInitParser' type='function'/>
<exports symbol='xmlInitParserCtxt' type='function'/>
<exports symbol='xmlInputSetEncodingHandler' type='function'/>
<exports symbol='xmlKeepBlanksDefault' type='function'/>
<exports symbol='xmlLineNumbersDefault' type='function'/>
<exports symbol='xmlLoadExternalEntity' type='function'/>
<exports symbol='xmlNewIOInputStream' type='function'/>
<exports symbol='xmlNewInputFromFd' type='function'/>
<exports symbol='xmlNewInputFromIO' type='function'/>
<exports symbol='xmlNewInputFromMemory' type='function'/>
<exports symbol='xmlNewInputFromString' type='function'/>
<exports symbol='xmlNewInputFromUrl' type='function'/>
<exports symbol='xmlNewParserCtxt' type='function'/>
<exports symbol='xmlNewSAXParserCtxt' type='function'/>
<exports symbol='xmlParseBalancedChunkMemory' type='function'/>
@ -799,10 +809,6 @@
<exports symbol='IS_LETTER_CH' type='macro'/>
<exports symbol='IS_PUBIDCHAR' type='macro'/>
<exports symbol='IS_PUBIDCHAR_CH' type='macro'/>
<exports symbol='XML_INPUT_BUF_STATIC' type='macro'/>
<exports symbol='XML_INPUT_BUF_ZERO_TERMINATED' type='macro'/>
<exports symbol='XML_INPUT_NETWORK' type='macro'/>
<exports symbol='XML_INPUT_UNZIP' type='macro'/>
<exports symbol='XML_MAX_DICTIONARY_LIMIT' type='macro'/>
<exports symbol='XML_MAX_HUGE_LENGTH' type='macro'/>
<exports symbol='XML_MAX_LOOKUP_LIMIT' type='macro'/>
@ -833,12 +839,6 @@
<exports symbol='xmlCtxtErrMemory' type='function'/>
<exports symbol='xmlCurrentChar' type='function'/>
<exports symbol='xmlFreeInputStream' type='function'/>
<exports symbol='xmlInputCreateFd' type='function'/>
<exports symbol='xmlInputCreateIO' type='function'/>
<exports symbol='xmlInputCreateMemory' type='function'/>
<exports symbol='xmlInputCreateString' type='function'/>
<exports symbol='xmlInputCreateUrl' type='function'/>
<exports symbol='xmlInputSetEncodingHandler' type='function'/>
<exports symbol='xmlIsLetter' type='function'/>
<exports symbol='xmlNewEntityInputStream' type='function'/>
<exports symbol='xmlNewInputFromFile' type='function'/>
@ -3969,13 +3969,13 @@
<macro name='XML_GET_LINE' file='tree'>
<info>Macro to extract the line number of an element node.</info>
</macro>
<macro name='XML_INPUT_BUF_STATIC' file='parserInternals'>
<macro name='XML_INPUT_BUF_STATIC' file='parser'>
</macro>
<macro name='XML_INPUT_BUF_ZERO_TERMINATED' file='parserInternals'>
<macro name='XML_INPUT_BUF_ZERO_TERMINATED' file='parser'>
</macro>
<macro name='XML_INPUT_NETWORK' file='parserInternals'>
<macro name='XML_INPUT_NETWORK' file='parser'>
</macro>
<macro name='XML_INPUT_UNZIP' file='parserInternals'>
<macro name='XML_INPUT_UNZIP' file='parser'>
</macro>
<macro name='XML_LOCAL_NAMESPACE' file='tree'>
<info>A namespace declaration node.</info>
@ -6980,7 +6980,7 @@ crash if you try to modify the tree)'/>
</function>
<function name='htmlCtxtReadFile' file='HTMLparser' module='HTMLparser'>
<cond>defined(LIBXML_HTML_ENABLED)</cond>
<info>Parse an HTML file from the filesystem, the network or a user-defined resource loader. See xmlNewInputURL and htmlCtxtUseOptions for details.</info>
<info>Parse an HTML file from the filesystem, the network or a user-defined resource loader. See htmlCtxtUseOptions for details.</info>
<return type='htmlDocPtr' info='the resulting document tree'/>
<arg name='ctxt' type='htmlParserCtxtPtr' info='an HTML parser context'/>
<arg name='filename' type='const char *' info='a file or URL'/>
@ -6989,7 +6989,7 @@ crash if you try to modify the tree)'/>
</function>
<function name='htmlCtxtReadIO' file='HTMLparser' module='HTMLparser'>
<cond>defined(LIBXML_HTML_ENABLED)</cond>
<info>Parse an HTML document from I/O functions and source and build a tree. See xmlNewInputIO and htmlCtxtUseOptions for details.</info>
<info>Parse an HTML document from I/O functions and source and build a tree. See htmlCtxtUseOptions for details.</info>
<return type='htmlDocPtr' info='the resulting document tree'/>
<arg name='ctxt' type='htmlParserCtxtPtr' info='an HTML parser context'/>
<arg name='ioread' type='xmlInputReadCallback' info='an I/O read function'/>
@ -7163,7 +7163,7 @@ crash if you try to modify the tree)'/>
</function>
<function name='htmlNewParserCtxt' file='HTMLparser' module='HTMLparser'>
<cond>defined(LIBXML_HTML_ENABLED)</cond>
<info>Allocate and initialize a new HTML parser context. This can be used to parse HTML documents into DOM trees with functions like xmlCtxtReadFile or xmlCtxtReadMemory. See htmlCtxtUseOptions for parser options. See xmlCtxtSetErrorHandler for advanced error handling. See xmlNewInputURL, xmlNewInputMemory, xmlNewInputIO and similar functions for advanced input control. See htmlNewSAXParserCtxt for custom SAX parsers.</info>
<info>Allocate and initialize a new HTML parser context. This can be used to parse HTML documents into DOM trees with functions like xmlCtxtReadFile or xmlCtxtReadMemory. See htmlCtxtUseOptions for parser options. See xmlCtxtSetErrorHandler for advanced error handling. See htmlNewSAXParserCtxt for custom SAX parsers.</info>
<return type='htmlParserCtxtPtr' info='the htmlParserCtxtPtr or NULL in case of allocation error'/>
</function>
<function name='htmlNewSAXParserCtxt' file='HTMLparser' module='HTMLparser'>
@ -7268,7 +7268,7 @@ crash if you try to modify the tree)'/>
</function>
<function name='htmlParseFile' file='HTMLparser' module='HTMLparser'>
<cond>defined(LIBXML_HTML_ENABLED)</cond>
<info>Parse an HTML file and build a tree. See xmlNewInputURL for details.</info>
<info>Parse an HTML file and build a tree.</info>
<return type='htmlDocPtr' info='the resulting document tree'/>
<arg name='filename' type='const char *' info='the filename'/>
<arg name='encoding' type='const char *' info='encoding (optional)'/>
@ -10010,44 +10010,6 @@ crash if you try to modify the tree)'/>
<return type='int' info='0 or -1 in case of error'/>
<arg name='context' type='void *' info='an Input context'/>
</functype>
<function name='xmlInputCreateFd' file='parserInternals' module='parserInternals'>
<info>Creates a new parser input to read from a zero-terminated string. @url is used as base to resolve external entities and for error reporting. @fd is closed after parsing has finished. Available since 2.14.0.</info>
<return type='xmlParserInputPtr' info='a new parser input or NULL if a memory allocation failed.'/>
<arg name='url' type='const char *' info='base URL (optional)'/>
<arg name='fd' type='int' info='file descriptor'/>
<arg name='flags' type='int' info='unused, pass 0'/>
</function>
<function name='xmlInputCreateIO' file='parserInternals' module='parserInternals'>
<info>Creates a new parser input to read from input callbacks and cintext. @url is used as base to resolve external entities and for error reporting. @ioRead is called to read new data into a provided buffer. It must return the number of bytes written into the buffer ot a negative xmlParserErrors code on failure. @ioClose is called after parsing has finished. @ioCtxt is an opaque pointer passed to the callbacks. Available since 2.14.0.</info>
<return type='xmlParserInputPtr' info='a new parser input or NULL if a memory allocation failed.'/>
<arg name='url' type='const char *' info='base URL (optional)'/>
<arg name='ioRead' type='xmlInputReadCallback' info='read callback'/>
<arg name='ioClose' type='xmlInputCloseCallback' info='close callback (optional)'/>
<arg name='ioCtxt' type='void *' info='IO context'/>
<arg name='flags' type='int' info='unused, pass 0'/>
</function>
<function name='xmlInputCreateMemory' file='parserInternals' module='parserInternals'>
<info>Creates a new parser input to read from a memory area. @url is used as base to resolve external entities and for error reporting. If the XML_INPUT_BUF_STATIC flag is set, the memory area must stay unchanged until parsing has finished. This can avoid temporary copies. If the XML_INPUT_BUF_ZERO_TERMINATED flag is set, the memory area must contain a zero byte after the buffer at position @size. This can avoid temporary copies. Available since 2.14.0.</info>
<return type='xmlParserInputPtr' info='a new parser input or NULL if a memory allocation failed.'/>
<arg name='url' type='const char *' info='base URL (optional)'/>
<arg name='mem' type='const void *' info='pointer to char array'/>
<arg name='size' type='size_t' info='size of array'/>
<arg name='flags' type='int' info='optimization hints'/>
</function>
<function name='xmlInputCreateString' file='parserInternals' module='parserInternals'>
<info>Creates a new parser input to read from a zero-terminated string. @url is used as base to resolve external entities and for error reporting. If the XML_INPUT_BUF_STATIC flag is set, the string must stay unchanged until parsing has finished. This can avoid temporary copies. Available since 2.14.0.</info>
<return type='xmlParserInputPtr' info='a new parser input or NULL if a memory allocation failed.'/>
<arg name='url' type='const char *' info='base URL (optional)'/>
<arg name='str' type='const char *' info='zero-terminated string'/>
<arg name='flags' type='int' info='optimization hints'/>
</function>
<function name='xmlInputCreateUrl' file='parserInternals' module='parserInternals'>
<info>Create a new input stream based on a file or a URL. The flag XML_INPUT_UNZIP allows decompression. The flag XML_INPUT_NETWORK allows network access. The following resource loaders will be called if they were registered (in order of precedence): - the per-thread xmlParserInputBufferCreateFilenameFunc set with xmlParserInputBufferCreateFilenameDefault (deprecated) - the default loader which will return - the result from a matching global input callback set with xmlRegisterInputCallbacks (deprecated) - a HTTP resource if support is compiled in. - a file opened from the filesystem, with automatic detection of compressed files if support is compiled in. Available since 2.14.0.</info>
<return type='int' info='an xmlParserErrors code.'/>
<arg name='filename' type='const char *' info='the filename to use as entity'/>
<arg name='flags' type='int' info='XML_INPUT flags'/>
<arg name='out' type='xmlParserInputPtr *' info='pointer to new parser input'/>
</function>
<functype name='xmlInputMatchCallback' file='xmlIO' module='xmlIO'>
<info>Callback used in the I/O Input API to detect if the current handler can provide input functionality for this resource.</info>
<return type='int' info='1 if yes and 0 if another Input module should be used'/>
@ -10065,7 +10027,7 @@ crash if you try to modify the tree)'/>
<arg name='buffer' type='char *' info='the buffer to store data read'/>
<arg name='len' type='int' info='the length of the buffer in bytes'/>
</functype>
<function name='xmlInputSetEncodingHandler' file='parserInternals' module='parserInternals'>
<function name='xmlInputSetEncodingHandler' file='parser' module='parserInternals'>
<info>Use encoding handler to decode input data. Closes the handler on error.</info>
<return type='int' info='an xmlParserErrors code.'/>
<arg name='input' type='xmlParserInputPtr' info='the input stream'/>
@ -10778,14 +10740,52 @@ crash if you try to modify the tree)'/>
<arg name='buf' type='xmlParserInputBufferPtr' info='an input buffer'/>
<arg name='enc' type='xmlCharEncoding' info='the charset encoding if known'/>
</function>
<function name='xmlNewInputFromFd' file='parser' module='parserInternals'>
<info>Creates a new parser input to read from a zero-terminated string. @url is used as base to resolve external entities and for error reporting. @fd is closed after parsing has finished. Available since 2.14.0.</info>
<return type='xmlParserInputPtr' info='a new parser input or NULL if a memory allocation failed.'/>
<arg name='url' type='const char *' info='base URL (optional)'/>
<arg name='fd' type='int' info='file descriptor'/>
<arg name='flags' type='int' info='unused, pass 0'/>
</function>
<function name='xmlNewInputFromFile' file='parserInternals' module='parserInternals'>
<info>DEPRECATED: Use xmlInputCreateUrl. Create a new input stream based on a file or an URL.</info>
<info>DEPRECATED: Use xmlNewInputFromUrl. Create a new input stream based on a file or an URL.</info>
<return type='xmlParserInputPtr' info='the new input stream or NULL in case of error'/>
<arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
<arg name='filename' type='const char *' info='the filename to use as entity'/>
</function>
<function name='xmlNewInputFromIO' file='parser' module='parserInternals'>
<info>Creates a new parser input to read from input callbacks and cintext. @url is used as base to resolve external entities and for error reporting. @ioRead is called to read new data into a provided buffer. It must return the number of bytes written into the buffer ot a negative xmlParserErrors code on failure. @ioClose is called after parsing has finished. @ioCtxt is an opaque pointer passed to the callbacks. Available since 2.14.0.</info>
<return type='xmlParserInputPtr' info='a new parser input or NULL if a memory allocation failed.'/>
<arg name='url' type='const char *' info='base URL (optional)'/>
<arg name='ioRead' type='xmlInputReadCallback' info='read callback'/>
<arg name='ioClose' type='xmlInputCloseCallback' info='close callback (optional)'/>
<arg name='ioCtxt' type='void *' info='IO context'/>
<arg name='flags' type='int' info='unused, pass 0'/>
</function>
<function name='xmlNewInputFromMemory' file='parser' module='parserInternals'>
<info>Creates a new parser input to read from a memory area. @url is used as base to resolve external entities and for error reporting. If the XML_INPUT_BUF_STATIC flag is set, the memory area must stay unchanged until parsing has finished. This can avoid temporary copies. If the XML_INPUT_BUF_ZERO_TERMINATED flag is set, the memory area must contain a zero byte after the buffer at position @size. This can avoid temporary copies. Available since 2.14.0.</info>
<return type='xmlParserInputPtr' info='a new parser input or NULL if a memory allocation failed.'/>
<arg name='url' type='const char *' info='base URL (optional)'/>
<arg name='mem' type='const void *' info='pointer to char array'/>
<arg name='size' type='size_t' info='size of array'/>
<arg name='flags' type='int' info='optimization hints'/>
</function>
<function name='xmlNewInputFromString' file='parser' module='parserInternals'>
<info>Creates a new parser input to read from a zero-terminated string. @url is used as base to resolve external entities and for error reporting. If the XML_INPUT_BUF_STATIC flag is set, the string must stay unchanged until parsing has finished. This can avoid temporary copies. Available since 2.14.0.</info>
<return type='xmlParserInputPtr' info='a new parser input or NULL if a memory allocation failed.'/>
<arg name='url' type='const char *' info='base URL (optional)'/>
<arg name='str' type='const char *' info='zero-terminated string'/>
<arg name='flags' type='int' info='optimization hints'/>
</function>
<function name='xmlNewInputFromUrl' file='parser' module='parserInternals'>
<info>Create a new input stream based on a file or a URL. The flag XML_INPUT_UNZIP allows decompression. The flag XML_INPUT_NETWORK allows network access. The following resource loaders will be called if they were registered (in order of precedence): - the per-thread xmlParserInputBufferCreateFilenameFunc set with xmlParserInputBufferCreateFilenameDefault (deprecated) - the default loader which will return - the result from a matching global input callback set with xmlRegisterInputCallbacks (deprecated) - a HTTP resource if support is compiled in. - a file opened from the filesystem, with automatic detection of compressed files if support is compiled in. Available since 2.14.0.</info>
<return type='int' info='an xmlParserErrors code.'/>
<arg name='filename' type='const char *' info='the filename to use as entity'/>
<arg name='flags' type='int' info='XML_INPUT flags'/>
<arg name='out' type='xmlParserInputPtr *' info='pointer to new parser input'/>
</function>
<function name='xmlNewInputStream' file='parserInternals' module='parserInternals'>
<info>DEPRECATED: Use xmlInputCreateUrl or similar functions. Create a new input stream structure.</info>
<info>DEPRECATED: Use xmlNewInputFromUrl or similar functions. Create a new input stream structure.</info>
<return type='xmlParserInputPtr' info='the new input stream or NULL'/>
<arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
</function>
@ -10862,7 +10862,7 @@ crash if you try to modify the tree)'/>
<arg name='userData' type='void *' info='user data'/>
</function>
<function name='xmlNewStringInputStream' file='parserInternals' module='parserInternals'>
<info>DEPRECATED: Use xmlInputCreateString. Create a new input stream based on a memory buffer.</info>
<info>DEPRECATED: Use xmlNewInputFromString. Create a new input stream based on a memory buffer.</info>
<return type='xmlParserInputPtr' info='the new input stream'/>
<arg name='ctxt' type='xmlParserCtxtPtr' info='an XML parser context'/>
<arg name='buffer' type='const xmlChar *' info='an memory buffer'/>

View File

@ -413,9 +413,9 @@ xmlFuzzResourceLoader(void *data ATTRIBUTE_UNUSED, const char *URL,
if (entity == NULL)
return(XML_IO_ENOENT);
input = xmlInputCreateMemory(URL, entity->data, entity->size,
XML_INPUT_BUF_STATIC |
XML_INPUT_BUF_ZERO_TERMINATED);
input = xmlNewInputFromMemory(URL, entity->data, entity->size,
XML_INPUT_BUF_STATIC |
XML_INPUT_BUF_ZERO_TERMINATED);
if (input == NULL)
return(XML_ERR_NO_MEMORY);

View File

@ -64,7 +64,7 @@ fuzzResourceRecorder(void *data ATTRIBUTE_UNUSED, const char *URL,
*out = NULL;
code = xmlInputCreateUrl(URL, flags, &in);
code = xmlNewInputFromUrl(URL, flags, &in);
if (code != XML_ERR_OK)
return(code);
@ -94,7 +94,7 @@ fuzzResourceRecorder(void *data ATTRIBUTE_UNUSED, const char *URL,
xmlHashAddEntry(globalData.entities, (const xmlChar *) URL,
globalData.entities);
return(xmlInputCreateUrl(URL, flags, out));
return(xmlNewInputFromUrl(URL, flags, out));
}
static void

View File

@ -1518,6 +1518,31 @@ XMLPUBFUN xmlDocPtr
const char *encoding,
int options);
/**
* New input API
*/
#define XML_INPUT_BUF_STATIC (1 << 1)
#define XML_INPUT_BUF_ZERO_TERMINATED (1 << 2)
#define XML_INPUT_UNZIP (1 << 3)
#define XML_INPUT_NETWORK (1 << 4)
XMLPUBFUN int
xmlNewInputFromUrl(const char *url, int flags, xmlParserInputPtr *out);
XMLPUBFUN xmlParserInputPtr
xmlNewInputFromMemory(const char *url, const void *mem, size_t size,
int flags);
XMLPUBFUN xmlParserInputPtr
xmlNewInputFromString(const char *url, const char *str, int flags);
XMLPUBFUN xmlParserInputPtr
xmlNewInputFromFd(const char *url, int fd, int flags);
XMLPUBFUN xmlParserInputPtr
xmlNewInputFromIO(const char *url, xmlInputReadCallback ioRead,
xmlInputCloseCallback ioClose, void *ioCtxt, int flags);
XMLPUBFUN int
xmlInputSetEncodingHandler(xmlParserInputPtr input,
xmlCharEncodingHandlerPtr handler);
/*
* Library wide options
*/

View File

@ -354,31 +354,6 @@ XMLPUBFUN xmlParserInputPtr
XMLPUBFUN xmlParserInputPtr
xmlNewInputStream (xmlParserCtxtPtr ctxt);
/**
* New input API
*/
#define XML_INPUT_BUF_STATIC (1 << 1)
#define XML_INPUT_BUF_ZERO_TERMINATED (1 << 2)
#define XML_INPUT_UNZIP (1 << 3)
#define XML_INPUT_NETWORK (1 << 4)
XMLPUBFUN int
xmlInputCreateUrl(const char *url, int flags, xmlParserInputPtr *out);
XMLPUBFUN xmlParserInputPtr
xmlInputCreateMemory(const char *url, const void *mem, size_t size,
int flags);
XMLPUBFUN xmlParserInputPtr
xmlInputCreateString(const char *url, const char *str, int flags);
XMLPUBFUN xmlParserInputPtr
xmlInputCreateFd(const char *url, int fd, int flags);
XMLPUBFUN xmlParserInputPtr
xmlInputCreateIO(const char *url, xmlInputReadCallback ioRead,
xmlInputCloseCallback ioClose, void *ioCtxt, int flags);
XMLPUBFUN int
xmlInputSetEncodingHandler(xmlParserInputPtr input,
xmlCharEncodingHandlerPtr handler);
/**
* Namespaces.
*/

View File

@ -115,7 +115,7 @@ xmlCtxtNewInputFromIO(xmlParserCtxtPtr ctxt, const char *url,
void *ioCtxt,
const char *encoding, int flags);
XML_HIDDEN xmlParserInputPtr
xmlInputCreatePush(const char *url, const char *chunk, int size);
xmlNewPushInput(const char *url, const char *chunk, int size);
XML_HIDDEN xmlChar *
xmlExpandEntitiesInAttValue(xmlParserCtxtPtr ctxt, const xmlChar *str,

View File

@ -11696,7 +11696,7 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
ctxt->options &= ~XML_PARSE_NODICT;
ctxt->dictNames = 1;
input = xmlInputCreatePush(filename, chunk, size);
input = xmlNewPushInput(filename, chunk, size);
if (input == NULL) {
xmlFreeParserCtxt(ctxt);
return(NULL);
@ -13461,7 +13461,7 @@ xmlCtxtResetPush(xmlParserCtxtPtr ctxt, const char *chunk,
xmlCtxtReset(ctxt);
input = xmlInputCreatePush(filename, chunk, size);
input = xmlNewPushInput(filename, chunk, size);
if (input == NULL)
return(1);

View File

@ -1682,7 +1682,7 @@ xmlFreeInputStream(xmlParserInputPtr input) {
* xmlNewInputStream:
* @ctxt: an XML parser context
*
* DEPRECATED: Use xmlInputCreateUrl or similar functions.
* DEPRECATED: Use xmlNewInputFromUrl or similar functions.
*
* Create a new input stream structure.
*
@ -1773,7 +1773,7 @@ xmlNewInputInternal(xmlParserInputBufferPtr buf, const char *filename) {
}
/**
* xmlInputCreateMemory:
* xmlNewInputFromMemory:
* @url: base URL (optional)
* @mem: pointer to char array
* @size: size of array
@ -1797,8 +1797,8 @@ xmlNewInputInternal(xmlParserInputBufferPtr buf, const char *filename) {
* Returns a new parser input or NULL if a memory allocation failed.
*/
xmlParserInputPtr
xmlInputCreateMemory(const char *url, const void *mem, size_t size,
int flags) {
xmlNewInputFromMemory(const char *url, const void *mem, size_t size,
int flags) {
xmlParserInputBufferPtr buf;
if (mem == NULL)
@ -1831,7 +1831,7 @@ xmlCtxtNewInputFromMemory(xmlParserCtxtPtr ctxt, const char *url,
if ((ctxt == NULL) || (mem == NULL))
return(NULL);
input = xmlInputCreateMemory(url, mem, size, flags);
input = xmlNewInputFromMemory(url, mem, size, flags);
if (input == NULL) {
xmlCtxtErrMemory(ctxt);
return(NULL);
@ -1844,7 +1844,7 @@ xmlCtxtNewInputFromMemory(xmlParserCtxtPtr ctxt, const char *url,
}
/**
* xmlInputCreateString:
* xmlNewInputFromString:
* @url: base URL (optional)
* @str: zero-terminated string
* @flags: optimization hints
@ -1863,7 +1863,7 @@ xmlCtxtNewInputFromMemory(xmlParserCtxtPtr ctxt, const char *url,
* Returns a new parser input or NULL if a memory allocation failed.
*/
xmlParserInputPtr
xmlInputCreateString(const char *url, const char *str, int flags) {
xmlNewInputFromString(const char *url, const char *str, int flags) {
xmlParserInputBufferPtr buf;
if (str == NULL)
@ -1894,7 +1894,7 @@ xmlCtxtNewInputFromString(xmlParserCtxtPtr ctxt, const char *url,
if ((ctxt == NULL) || (str == NULL))
return(NULL);
input = xmlInputCreateString(url, str, flags);
input = xmlNewInputFromString(url, str, flags);
if (input == NULL) {
xmlCtxtErrMemory(ctxt);
return(NULL);
@ -1907,7 +1907,7 @@ xmlCtxtNewInputFromString(xmlParserCtxtPtr ctxt, const char *url,
}
/**
* xmlInputCreateFd:
* xmlNewInputFromFd:
* @url: base URL (optional)
* @fd: file descriptor
* @flags: unused, pass 0
@ -1924,7 +1924,7 @@ xmlCtxtNewInputFromString(xmlParserCtxtPtr ctxt, const char *url,
* Returns a new parser input or NULL if a memory allocation failed.
*/
xmlParserInputPtr
xmlInputCreateFd(const char *url, int fd, int flags ATTRIBUTE_UNUSED) {
xmlNewInputFromFd(const char *url, int fd, int flags ATTRIBUTE_UNUSED) {
xmlParserInputBufferPtr buf;
if (fd < 0)
@ -1955,7 +1955,7 @@ xmlCtxtNewInputFromFd(xmlParserCtxtPtr ctxt, const char *url,
if ((ctxt == NULL) || (fd < 0))
return(NULL);
input = xmlInputCreateFd(url, fd, flags);
input = xmlNewInputFromFd(url, fd, flags);
if (input == NULL) {
xmlCtxtErrMemory(ctxt);
return(NULL);
@ -1968,7 +1968,7 @@ xmlCtxtNewInputFromFd(xmlParserCtxtPtr ctxt, const char *url,
}
/**
* xmlInputCreateIO:
* xmlNewInputFromIO:
* @url: base URL (optional)
* @ioRead: read callback
* @ioClose: close callback (optional)
@ -1994,9 +1994,9 @@ xmlCtxtNewInputFromFd(xmlParserCtxtPtr ctxt, const char *url,
* Returns a new parser input or NULL if a memory allocation failed.
*/
xmlParserInputPtr
xmlInputCreateIO(const char *url, xmlInputReadCallback ioRead,
xmlInputCloseCallback ioClose, void *ioCtxt,
int flags ATTRIBUTE_UNUSED) {
xmlNewInputFromIO(const char *url, xmlInputReadCallback ioRead,
xmlInputCloseCallback ioClose, void *ioCtxt,
int flags ATTRIBUTE_UNUSED) {
xmlParserInputBufferPtr buf;
if (ioRead == NULL)
@ -2038,7 +2038,7 @@ xmlCtxtNewInputFromIO(xmlParserCtxtPtr ctxt, const char *url,
if ((ctxt == NULL) || (ioRead == NULL))
return(NULL);
input = xmlInputCreateIO(url, ioRead, ioClose, ioCtxt, flags);
input = xmlNewInputFromIO(url, ioRead, ioClose, ioCtxt, flags);
if (input == NULL) {
xmlCtxtErrMemory(ctxt);
return(NULL);
@ -2051,7 +2051,7 @@ xmlCtxtNewInputFromIO(xmlParserCtxtPtr ctxt, const char *url,
}
/**
* xmlInputCreatePush:
* xmlNewPushInput:
* @url: base URL (optional)
* @chunk: pointer to char array
* @size: size of array
@ -2061,7 +2061,7 @@ xmlCtxtNewInputFromIO(xmlParserCtxtPtr ctxt, const char *url,
* Returns a new parser input or NULL if a memory allocation failed.
*/
xmlParserInputPtr
xmlInputCreatePush(const char *url, const char *chunk, int size) {
xmlNewPushInput(const char *url, const char *chunk, int size) {
xmlParserInputBufferPtr buf;
xmlParserInputPtr input;
@ -2170,7 +2170,7 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr ent) {
* @ctxt: an XML parser context
* @buffer: an memory buffer
*
* DEPRECATED: Use xmlInputCreateString.
* DEPRECATED: Use xmlNewInputFromString.
*
* Create a new input stream based on a memory buffer.
*
@ -2357,7 +2357,7 @@ xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret) {
}
/**
* xmlInputCreateUrl:
* xmlNewInputFromUrl:
* @filename: the filename to use as entity
* @flags: XML_INPUT flags
* @out: pointer to new parser input
@ -2385,7 +2385,7 @@ xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret) {
* Returns an xmlParserErrors code.
*/
int
xmlInputCreateUrl(const char *filename, int flags, xmlParserInputPtr *out) {
xmlNewInputFromUrl(const char *filename, int flags, xmlParserInputPtr *out) {
xmlParserInputBufferPtr buf;
xmlParserInputPtr input;
int code = XML_ERR_OK;
@ -2429,7 +2429,7 @@ xmlInputCreateUrl(const char *filename, int flags, xmlParserInputPtr *out) {
* @ctxt: an XML parser context
* @filename: the filename to use as entity
*
* DEPRECATED: Use xmlInputCreateUrl.
* DEPRECATED: Use xmlNewInputFromUrl.
*
* Create a new input stream based on a file or an URL.
*
@ -2449,7 +2449,7 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
if ((ctxt->options & XML_PARSE_NONET) == 0)
flags |= XML_INPUT_NETWORK;
code = xmlInputCreateUrl(filename, flags, &input);
code = xmlNewInputFromUrl(filename, flags, &input);
if (code != XML_ERR_OK) {
xmlCtxtErrIO(ctxt, code, filename);
return(NULL);

View File

@ -122,14 +122,14 @@ testResourceLoader(void *vctxt ATTRIBUTE_UNUSED, const char *URL,
for (i = 0; i < nb_entities; i++) {
if (!strcmp(testEntitiesName[i], URL)) {
*out = xmlInputCreateString(testEntitiesName[i],
*out = xmlNewInputFromString(testEntitiesName[i],
testEntitiesValue[i],
XML_INPUT_BUF_STATIC);
return(XML_ERR_OK);
}
}
return(xmlInputCreateUrl(URL, 0, out));
return(xmlNewInputFromUrl(URL, 0, out));
}
/*

View File

@ -2105,7 +2105,7 @@ testParseContent(xmlParserCtxtPtr ctxt, xmlDocPtr doc, const char *filename) {
content = dumpNodeList(root->children);
input = xmlInputCreateString(NULL, content, XML_INPUT_BUF_STATIC);
input = xmlNewInputFromString(NULL, content, XML_INPUT_BUF_STATIC);
list = xmlCtxtParseContent(ctxt, input, root, 0);
roundTrip = dumpNodeList(list);
if (strcmp(content, roundTrip) != 0) {

418
testapi.c
View File

@ -12846,6 +12846,45 @@ test_xmlInitParserCtxt(void) {
}
static int
test_xmlInputSetEncodingHandler(void) {
int test_ret = 0;
int mem_base;
int ret_val;
xmlParserInputPtr input; /* the input stream */
int n_input;
xmlCharEncodingHandlerPtr handler; /* the encoding handler */
int n_handler;
for (n_input = 0;n_input < gen_nb_xmlParserInputPtr;n_input++) {
for (n_handler = 0;n_handler < gen_nb_xmlCharEncodingHandlerPtr;n_handler++) {
mem_base = xmlMemBlocks();
input = gen_xmlParserInputPtr(n_input, 0);
handler = gen_xmlCharEncodingHandlerPtr(n_handler, 1);
ret_val = xmlInputSetEncodingHandler(input, handler);
desret_int(ret_val);
call_tests++;
des_xmlParserInputPtr(n_input, input, 0);
des_xmlCharEncodingHandlerPtr(n_handler, handler, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlInputSetEncodingHandler",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_input);
printf(" %d", n_handler);
printf("\n");
}
}
}
function_tests++;
return(test_ret);
}
static int
test_xmlKeepBlanksDefault(void) {
int test_ret = 0;
@ -13003,6 +13042,168 @@ test_xmlNewIOInputStream(void) {
}
static int
test_xmlNewInputFromFd(void) {
int test_ret = 0;
int mem_base;
xmlParserInputPtr ret_val;
const char * url; /* base URL (optional) */
int n_url;
int fd; /* file descriptor */
int n_fd;
int flags; /* unused, pass 0 */
int n_flags;
for (n_url = 0;n_url < gen_nb_filepath;n_url++) {
for (n_fd = 0;n_fd < gen_nb_int;n_fd++) {
for (n_flags = 0;n_flags < gen_nb_int;n_flags++) {
mem_base = xmlMemBlocks();
url = gen_filepath(n_url, 0);
fd = gen_int(n_fd, 1);
flags = gen_int(n_flags, 2);
ret_val = xmlNewInputFromFd(url, fd, flags);
desret_xmlParserInputPtr(ret_val);
call_tests++;
des_filepath(n_url, url, 0);
des_int(n_fd, fd, 1);
des_int(n_flags, flags, 2);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlNewInputFromFd",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_url);
printf(" %d", n_fd);
printf(" %d", n_flags);
printf("\n");
}
}
}
}
function_tests++;
return(test_ret);
}
static int
test_xmlNewInputFromIO(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
static int
test_xmlNewInputFromMemory(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
static int
test_xmlNewInputFromString(void) {
int test_ret = 0;
int mem_base;
xmlParserInputPtr ret_val;
const char * url; /* base URL (optional) */
int n_url;
const char * str; /* zero-terminated string */
int n_str;
int flags; /* optimization hints */
int n_flags;
for (n_url = 0;n_url < gen_nb_filepath;n_url++) {
for (n_str = 0;n_str < gen_nb_const_char_ptr;n_str++) {
for (n_flags = 0;n_flags < gen_nb_int;n_flags++) {
mem_base = xmlMemBlocks();
url = gen_filepath(n_url, 0);
str = gen_const_char_ptr(n_str, 1);
flags = gen_int(n_flags, 2);
ret_val = xmlNewInputFromString(url, str, flags);
desret_xmlParserInputPtr(ret_val);
call_tests++;
des_filepath(n_url, url, 0);
des_const_char_ptr(n_str, str, 1);
des_int(n_flags, flags, 2);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlNewInputFromString",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_url);
printf(" %d", n_str);
printf(" %d", n_flags);
printf("\n");
}
}
}
}
function_tests++;
return(test_ret);
}
#define gen_nb_xmlParserInputPtr_ptr 1
#define gen_xmlParserInputPtr_ptr(no, nr) NULL
#define des_xmlParserInputPtr_ptr(no, val, nr)
static int
test_xmlNewInputFromUrl(void) {
int test_ret = 0;
int mem_base;
int ret_val;
const char * filename; /* the filename to use as entity */
int n_filename;
int flags; /* XML_INPUT flags */
int n_flags;
xmlParserInputPtr * out; /* pointer to new parser input */
int n_out;
for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) {
for (n_flags = 0;n_flags < gen_nb_int;n_flags++) {
for (n_out = 0;n_out < gen_nb_xmlParserInputPtr_ptr;n_out++) {
mem_base = xmlMemBlocks();
filename = gen_filepath(n_filename, 0);
flags = gen_int(n_flags, 1);
out = gen_xmlParserInputPtr_ptr(n_out, 2);
ret_val = xmlNewInputFromUrl(filename, flags, out);
desret_int(ret_val);
call_tests++;
des_filepath(n_filename, filename, 0);
des_int(n_flags, flags, 1);
des_xmlParserInputPtr_ptr(n_out, out, 2);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlNewInputFromUrl",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_filename);
printf(" %d", n_flags);
printf(" %d", n_out);
printf("\n");
}
}
}
}
function_tests++;
return(test_ret);
}
static int
test_xmlNewParserCtxt(void) {
int test_ret = 0;
@ -15134,7 +15335,7 @@ static int
test_parser(void) {
int test_ret = 0;
if (quiet == 0) printf("Testing parser : 82 of 96 functions ...\n");
if (quiet == 0) printf("Testing parser : 86 of 102 functions ...\n");
test_ret += test_xmlByteConsumed();
test_ret += test_xmlCleanupGlobals();
test_ret += test_xmlClearNodeInfoSeq();
@ -15171,10 +15372,16 @@ test_parser(void) {
test_ret += test_xmlInitNodeInfoSeq();
test_ret += test_xmlInitParser();
test_ret += test_xmlInitParserCtxt();
test_ret += test_xmlInputSetEncodingHandler();
test_ret += test_xmlKeepBlanksDefault();
test_ret += test_xmlLineNumbersDefault();
test_ret += test_xmlLoadExternalEntity();
test_ret += test_xmlNewIOInputStream();
test_ret += test_xmlNewInputFromFd();
test_ret += test_xmlNewInputFromIO();
test_ret += test_xmlNewInputFromMemory();
test_ret += test_xmlNewInputFromString();
test_ret += test_xmlNewInputFromUrl();
test_ret += test_xmlNewParserCtxt();
test_ret += test_xmlNewSAXParserCtxt();
test_ret += test_xmlParseBalancedChunkMemory();
@ -15787,207 +15994,6 @@ test_xmlCurrentChar(void) {
}
static int
test_xmlInputCreateFd(void) {
int test_ret = 0;
int mem_base;
xmlParserInputPtr ret_val;
const char * url; /* base URL (optional) */
int n_url;
int fd; /* file descriptor */
int n_fd;
int flags; /* unused, pass 0 */
int n_flags;
for (n_url = 0;n_url < gen_nb_fileoutput;n_url++) {
for (n_fd = 0;n_fd < gen_nb_int;n_fd++) {
for (n_flags = 0;n_flags < gen_nb_int;n_flags++) {
mem_base = xmlMemBlocks();
url = gen_fileoutput(n_url, 0);
fd = gen_int(n_fd, 1);
flags = gen_int(n_flags, 2);
ret_val = xmlInputCreateFd(url, fd, flags);
desret_xmlParserInputPtr(ret_val);
call_tests++;
des_fileoutput(n_url, url, 0);
des_int(n_fd, fd, 1);
des_int(n_flags, flags, 2);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlInputCreateFd",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_url);
printf(" %d", n_fd);
printf(" %d", n_flags);
printf("\n");
}
}
}
}
function_tests++;
return(test_ret);
}
static int
test_xmlInputCreateIO(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
static int
test_xmlInputCreateMemory(void) {
int test_ret = 0;
/* missing type support */
return(test_ret);
}
static int
test_xmlInputCreateString(void) {
int test_ret = 0;
int mem_base;
xmlParserInputPtr ret_val;
const char * url; /* base URL (optional) */
int n_url;
const char * str; /* zero-terminated string */
int n_str;
int flags; /* optimization hints */
int n_flags;
for (n_url = 0;n_url < gen_nb_fileoutput;n_url++) {
for (n_str = 0;n_str < gen_nb_const_char_ptr;n_str++) {
for (n_flags = 0;n_flags < gen_nb_int;n_flags++) {
mem_base = xmlMemBlocks();
url = gen_fileoutput(n_url, 0);
str = gen_const_char_ptr(n_str, 1);
flags = gen_int(n_flags, 2);
ret_val = xmlInputCreateString(url, str, flags);
desret_xmlParserInputPtr(ret_val);
call_tests++;
des_fileoutput(n_url, url, 0);
des_const_char_ptr(n_str, str, 1);
des_int(n_flags, flags, 2);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlInputCreateString",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_url);
printf(" %d", n_str);
printf(" %d", n_flags);
printf("\n");
}
}
}
}
function_tests++;
return(test_ret);
}
#define gen_nb_xmlParserInputPtr_ptr 1
#define gen_xmlParserInputPtr_ptr(no, nr) NULL
#define des_xmlParserInputPtr_ptr(no, val, nr)
static int
test_xmlInputCreateUrl(void) {
int test_ret = 0;
int mem_base;
int ret_val;
const char * filename; /* the filename to use as entity */
int n_filename;
int flags; /* XML_INPUT flags */
int n_flags;
xmlParserInputPtr * out; /* pointer to new parser input */
int n_out;
for (n_filename = 0;n_filename < gen_nb_fileoutput;n_filename++) {
for (n_flags = 0;n_flags < gen_nb_int;n_flags++) {
for (n_out = 0;n_out < gen_nb_xmlParserInputPtr_ptr;n_out++) {
mem_base = xmlMemBlocks();
filename = gen_fileoutput(n_filename, 0);
flags = gen_int(n_flags, 1);
out = gen_xmlParserInputPtr_ptr(n_out, 2);
ret_val = xmlInputCreateUrl(filename, flags, out);
desret_int(ret_val);
call_tests++;
des_fileoutput(n_filename, filename, 0);
des_int(n_flags, flags, 1);
des_xmlParserInputPtr_ptr(n_out, out, 2);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlInputCreateUrl",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_filename);
printf(" %d", n_flags);
printf(" %d", n_out);
printf("\n");
}
}
}
}
function_tests++;
return(test_ret);
}
static int
test_xmlInputSetEncodingHandler(void) {
int test_ret = 0;
int mem_base;
int ret_val;
xmlParserInputPtr input; /* the input stream */
int n_input;
xmlCharEncodingHandlerPtr handler; /* the encoding handler */
int n_handler;
for (n_input = 0;n_input < gen_nb_xmlParserInputPtr;n_input++) {
for (n_handler = 0;n_handler < gen_nb_xmlCharEncodingHandlerPtr;n_handler++) {
mem_base = xmlMemBlocks();
input = gen_xmlParserInputPtr(n_input, 0);
handler = gen_xmlCharEncodingHandlerPtr(n_handler, 1);
ret_val = xmlInputSetEncodingHandler(input, handler);
desret_int(ret_val);
call_tests++;
des_xmlParserInputPtr(n_input, input, 0);
des_xmlCharEncodingHandlerPtr(n_handler, handler, 1);
xmlResetLastError();
if (mem_base != xmlMemBlocks()) {
printf("Leak of %d blocks found in xmlInputSetEncodingHandler",
xmlMemBlocks() - mem_base);
test_ret++;
printf(" %d", n_input);
printf(" %d", n_handler);
printf("\n");
}
}
}
function_tests++;
return(test_ret);
}
static int
test_xmlIsLetter(void) {
int test_ret = 0;
@ -16702,7 +16708,7 @@ static int
test_parserInternals(void) {
int test_ret = 0;
if (quiet == 0) printf("Testing parserInternals : 36 of 85 functions ...\n");
if (quiet == 0) printf("Testing parserInternals : 32 of 79 functions ...\n");
test_ret += test_inputPop();
test_ret += test_inputPush();
test_ret += test_namePop();
@ -16718,12 +16724,6 @@ test_parserInternals(void) {
test_ret += test_xmlCreateURLParserCtxt();
test_ret += test_xmlCtxtErrMemory();
test_ret += test_xmlCurrentChar();
test_ret += test_xmlInputCreateFd();
test_ret += test_xmlInputCreateIO();
test_ret += test_xmlInputCreateMemory();
test_ret += test_xmlInputCreateString();
test_ret += test_xmlInputCreateUrl();
test_ret += test_xmlInputSetEncodingHandler();
test_ret += test_xmlIsLetter();
test_ret += test_xmlNewEntityInputStream();
test_ret += test_xmlNewInputFromFile();

View File

@ -174,8 +174,8 @@ testCtxtParseContent(void) {
for (j = 0; j < 2; j++) {
if (j == 0) {
input = xmlInputCreateString(NULL, content,
XML_INPUT_BUF_STATIC);
input = xmlNewInputFromString(NULL, content,
XML_INPUT_BUF_STATIC);
list = xmlCtxtParseContent(ctxt, input, node, 0);
} else {
xmlParseInNodeContext(node, content, strlen(content), 0,

View File

@ -234,7 +234,7 @@ xmllintResourceLoader(void *ctxt ATTRIBUTE_UNUSED, const char *URL,
if (defaultResourceLoader != NULL)
code = defaultResourceLoader(NULL, URL, ID, type, flags, out);
else
code = xmlInputCreateUrl(URL, flags, out);
code = xmlNewInputFromUrl(URL, flags, out);
if (code != XML_IO_ENOENT) {
if ((load_trace) && (code == XML_ERR_OK)) {
fprintf(ERR_STREAM, "Loaded URL=\"%s\" ID=\"%s\"\n",
@ -254,7 +254,7 @@ xmllintResourceLoader(void *ctxt ATTRIBUTE_UNUSED, const char *URL,
code = defaultResourceLoader(NULL, (const char *) newURL, ID,
type, flags, out);
else
code = xmlInputCreateUrl((const char *) newURL, flags, out);
code = xmlNewInputFromUrl((const char *) newURL, flags, out);
if (code != XML_IO_ENOENT) {
if ((load_trace) && (code == XML_ERR_OK)) {
fprintf(ERR_STREAM, "Loaded URL=\"%s\" ID=\"%s\"\n",