include: Change some return types from int to enum

This also affects some new functions from 2.13.
This commit is contained in:
Nick Wellnhofer 2025-03-14 00:01:11 +01:00
parent fd1b939168
commit b349225952
21 changed files with 172 additions and 165 deletions

View File

@ -337,7 +337,7 @@ htmlIsBooleanAttr(const xmlChar *name)
* * * *
************************************************************************/ ************************************************************************/
static int static xmlParserErrors
htmlFindOutputEncoder(const char *encoding, xmlCharEncodingHandler **out) { htmlFindOutputEncoder(const char *encoding, xmlCharEncodingHandler **out) {
/* /*
* Fallback to HTML if the encoding is unspecified * Fallback to HTML if the encoding is unspecified

4
buf.c
View File

@ -1092,7 +1092,7 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
* Add a string range to an XML buffer. if len == -1, the length of * Add a string range to an XML buffer. if len == -1, the length of
* str is recomputed. * str is recomputed.
* *
* Returns a xmlParserError code. * Returns a xmlParserErrors code.
*/ */
int int
xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) { xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) {
@ -1124,7 +1124,7 @@ xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) {
* Add a string range to the beginning of an XML buffer. * Add a string range to the beginning of an XML buffer.
* if len == -1, the length of @str is recomputed. * if len == -1, the length of @str is recomputed.
* *
* Returns a xmlParserError code. * Returns a xmlParserErrors code.
*/ */
int int
xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len) { xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len) {

View File

@ -7764,14 +7764,14 @@ crash if you try to modify the tree)'/>
</function> </function>
<function name='xmlBufferAdd' file='tree' module='buf'> <function name='xmlBufferAdd' file='tree' module='buf'>
<info>Add a string range to an XML buffer. if len == -1, the length of str is recomputed.</info> <info>Add a string range to an XML buffer. if len == -1, the length of str is recomputed.</info>
<return type='int' info='a xmlParserError code.'/> <return type='int' info='a xmlParserErrors code.'/>
<arg name='buf' type='xmlBufferPtr' info='the buffer to dump'/> <arg name='buf' type='xmlBufferPtr' info='the buffer to dump'/>
<arg name='str' type='const xmlChar *' info='the #xmlChar string'/> <arg name='str' type='const xmlChar *' info='the #xmlChar string'/>
<arg name='len' type='int' info='the number of #xmlChar to add'/> <arg name='len' type='int' info='the number of #xmlChar to add'/>
</function> </function>
<function name='xmlBufferAddHead' file='tree' module='buf'> <function name='xmlBufferAddHead' file='tree' module='buf'>
<info>Add a string range to the beginning of an XML buffer. if len == -1, the length of @str is recomputed.</info> <info>Add a string range to the beginning of an XML buffer. if len == -1, the length of @str is recomputed.</info>
<return type='int' info='a xmlParserError code.'/> <return type='int' info='a xmlParserErrors code.'/>
<arg name='buf' type='xmlBufferPtr' info='the buffer'/> <arg name='buf' type='xmlBufferPtr' info='the buffer'/>
<arg name='str' type='const xmlChar *' info='the #xmlChar string'/> <arg name='str' type='const xmlChar *' info='the #xmlChar string'/>
<arg name='len' type='int' info='the number of #xmlChar to add'/> <arg name='len' type='int' info='the number of #xmlChar to add'/>
@ -8110,7 +8110,7 @@ crash if you try to modify the tree)'/>
</functype> </functype>
<functype name='xmlCharEncConvFunc' file='encoding' module='encoding'> <functype name='xmlCharEncConvFunc' file='encoding' module='encoding'>
<info>Convert between character encodings. The value of @inlen after return is the number of bytes consumed and @outlen is the number of bytes produced. If the converter can consume partial multi-byte sequences, the @flush flag can be used to detect truncated sequences at EOF. Otherwise, the flag can be ignored.</info> <info>Convert between character encodings. The value of @inlen after return is the number of bytes consumed and @outlen is the number of bytes produced. If the converter can consume partial multi-byte sequences, the @flush flag can be used to detect truncated sequences at EOF. Otherwise, the flag can be ignored.</info>
<return type='int' info='a non-negative number on success or an XML_ENC_ERR code.'/> <return type='xmlCharEncError' info='an XML_ENC_ERR code.'/>
<arg name='vctxt' type='void *' info='conversion context'/> <arg name='vctxt' type='void *' info='conversion context'/>
<arg name='out' type='unsigned char *' info='a pointer to an array of bytes to store the result'/> <arg name='out' type='unsigned char *' info='a pointer to an array of bytes to store the result'/>
<arg name='outlen' type='int *' info='the length of @out'/> <arg name='outlen' type='int *' info='the length of @out'/>
@ -8120,7 +8120,7 @@ crash if you try to modify the tree)'/>
</functype> </functype>
<functype name='xmlCharEncConvImpl' file='encoding' module='encoding'> <functype name='xmlCharEncConvImpl' file='encoding' module='encoding'>
<info>If this function returns XML_ERR_OK, it must fill the @out pointer with an encoding handler. The handler can be obtained from xmlCharEncNewCustomHandler. @flags can contain XML_ENC_INPUT, XML_ENC_OUTPUT or both.</info> <info>If this function returns XML_ERR_OK, it must fill the @out pointer with an encoding handler. The handler can be obtained from xmlCharEncNewCustomHandler. @flags can contain XML_ENC_INPUT, XML_ENC_OUTPUT or both.</info>
<return type='int' info='an xmlParserErrors code.'/> <return type='xmlParserErrors' info='an xmlParserErrors code.'/>
<arg name='vctxt' type='void *' info='user data'/> <arg name='vctxt' type='void *' info='user data'/>
<arg name='name' type='const char *' info='encoding name'/> <arg name='name' type='const char *' info='encoding name'/>
<arg name='flags' type='xmlCharEncFlags' info='bit mask of flags'/> <arg name='flags' type='xmlCharEncFlags' info='bit mask of flags'/>
@ -8142,7 +8142,7 @@ crash if you try to modify the tree)'/>
</function> </function>
<function name='xmlCharEncNewCustomHandler' file='encoding' module='encoding'> <function name='xmlCharEncNewCustomHandler' file='encoding' module='encoding'>
<info>Create a custom xmlCharEncodingHandler.</info> <info>Create a custom xmlCharEncodingHandler.</info>
<return type='int' info='an xmlParserError code.'/> <return type='xmlParserErrors' info='an xmlParserErrors code.'/>
<arg name='name' type='const char *' info='the encoding name'/> <arg name='name' type='const char *' info='the encoding name'/>
<arg name='input' type='xmlCharEncConvFunc' info='input callback which converts to UTF-8'/> <arg name='input' type='xmlCharEncConvFunc' info='input callback which converts to UTF-8'/>
<arg name='output' type='xmlCharEncConvFunc' info='output callback which converts from UTF-8'/> <arg name='output' type='xmlCharEncConvFunc' info='output callback which converts from UTF-8'/>
@ -8371,7 +8371,7 @@ crash if you try to modify the tree)'/>
</function> </function>
<function name='xmlCreateCharEncodingHandler' file='encoding' module='encoding'> <function name='xmlCreateCharEncodingHandler' file='encoding' module='encoding'>
<info>Find or create a handler matching the encoding. The following converters are looked up in order: - Built-in handler (UTF-8, UTF-16, ISO-8859-1, ASCII) - Custom implementation if provided - User-registered global handler (deprecated) - iconv if enabled - ICU if enabled The handler must be closed with xmlCharEncCloseFunc. If the encoding is UTF-8, a NULL handler and no error code will be returned. @flags can contain XML_ENC_INPUT, XML_ENC_OUTPUT or both. Available since 2.14.0.</info> <info>Find or create a handler matching the encoding. The following converters are looked up in order: - Built-in handler (UTF-8, UTF-16, ISO-8859-1, ASCII) - Custom implementation if provided - User-registered global handler (deprecated) - iconv if enabled - ICU if enabled The handler must be closed with xmlCharEncCloseFunc. If the encoding is UTF-8, a NULL handler and no error code will be returned. @flags can contain XML_ENC_INPUT, XML_ENC_OUTPUT or both. Available since 2.14.0.</info>
<return type='int' info='XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another xmlParserErrors error code.'/> <return type='xmlParserErrors' info='XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another xmlParserErrors error code.'/>
<arg name='name' type='const char *' info='a string describing the char encoding.'/> <arg name='name' type='const char *' info='a string describing the char encoding.'/>
<arg name='flags' type='xmlCharEncFlags' info='bit mask of flags'/> <arg name='flags' type='xmlCharEncFlags' info='bit mask of flags'/>
<arg name='impl' type='xmlCharEncConvImpl' info='a conversion implementation (optional)'/> <arg name='impl' type='xmlCharEncConvImpl' info='a conversion implementation (optional)'/>
@ -9865,7 +9865,7 @@ crash if you try to modify the tree)'/>
</functype> </functype>
<function name='xmlInputSetEncodingHandler' file='parser' module='parserInternals'> <function name='xmlInputSetEncodingHandler' file='parser' module='parserInternals'>
<info>Use encoding handler to decode input data. Closes the handler on error.</info> <info>Use encoding handler to decode input data. Closes the handler on error.</info>
<return type='int' info='an xmlParserErrors code.'/> <return type='xmlParserErrors' info='an xmlParserErrors code.'/>
<arg name='input' type='xmlParserInputPtr' info='the input stream'/> <arg name='input' type='xmlParserInputPtr' info='the input stream'/>
<arg name='handler' type='xmlCharEncodingHandlerPtr' info='the encoding handler'/> <arg name='handler' type='xmlCharEncodingHandlerPtr' info='the encoding handler'/>
</function> </function>
@ -10168,7 +10168,7 @@ crash if you try to modify the tree)'/>
</function> </function>
<function name='xmlLookupCharEncodingHandler' file='encoding' module='encoding'> <function name='xmlLookupCharEncodingHandler' file='encoding' module='encoding'>
<info>Find or create a handler matching the encoding. The following converters are looked up in order: - Built-in handler (UTF-8, UTF-16, ISO-8859-1, ASCII) - User-registered global handler (deprecated) - iconv if enabled - ICU if enabled The handler must be closed with xmlCharEncCloseFunc. If the encoding is UTF-8, a NULL handler and no error code will be returned. Available since 2.13.0.</info> <info>Find or create a handler matching the encoding. The following converters are looked up in order: - Built-in handler (UTF-8, UTF-16, ISO-8859-1, ASCII) - User-registered global handler (deprecated) - iconv if enabled - ICU if enabled The handler must be closed with xmlCharEncCloseFunc. If the encoding is UTF-8, a NULL handler and no error code will be returned. Available since 2.13.0.</info>
<return type='int' info='XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another xmlParserErrors error code.'/> <return type='xmlParserErrors' info='XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another xmlParserErrors error code.'/>
<arg name='enc' type='xmlCharEncoding' info='an xmlCharEncoding value.'/> <arg name='enc' type='xmlCharEncoding' info='an xmlCharEncoding value.'/>
<arg name='out' type='xmlCharEncodingHandler **' info='pointer to result'/> <arg name='out' type='xmlCharEncodingHandler **' info='pointer to result'/>
</function> </function>
@ -10619,7 +10619,7 @@ crash if you try to modify the tree)'/>
</function> </function>
<function name='xmlNewInputFromUrl' file='parser' module='parserInternals'> <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> <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.'/> <return type='xmlParserErrors' info='an xmlParserErrors code.'/>
<arg name='filename' type='const char *' info='the filename to use as entity'/> <arg name='filename' type='const char *' info='the filename to use as entity'/>
<arg name='flags' type='xmlParserInputFlags' info='XML_INPUT flags'/> <arg name='flags' type='xmlParserInputFlags' info='XML_INPUT flags'/>
<arg name='out' type='xmlParserInputPtr *' info='pointer to new parser input'/> <arg name='out' type='xmlParserInputPtr *' info='pointer to new parser input'/>
@ -10947,7 +10947,7 @@ crash if you try to modify the tree)'/>
</function> </function>
<function name='xmlOpenCharEncodingHandler' file='encoding' module='encoding'> <function name='xmlOpenCharEncodingHandler' file='encoding' module='encoding'>
<info>Find or create a handler matching the encoding. The following converters are looked up in order: - Built-in handler (UTF-8, UTF-16, ISO-8859-1, ASCII) - User-registered global handler (deprecated) - iconv if enabled - ICU if enabled The handler must be closed with xmlCharEncCloseFunc. If the encoding is UTF-8, a NULL handler and no error code will be returned. Available since 2.13.0.</info> <info>Find or create a handler matching the encoding. The following converters are looked up in order: - Built-in handler (UTF-8, UTF-16, ISO-8859-1, ASCII) - User-registered global handler (deprecated) - iconv if enabled - ICU if enabled The handler must be closed with xmlCharEncCloseFunc. If the encoding is UTF-8, a NULL handler and no error code will be returned. Available since 2.13.0.</info>
<return type='int' info='XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another xmlParserErrors error code.'/> <return type='xmlParserErrors' info='XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another xmlParserErrors error code.'/>
<arg name='name' type='const char *' info='a string describing the char encoding.'/> <arg name='name' type='const char *' info='a string describing the char encoding.'/>
<arg name='output' type='int' info='boolean, use handler for output'/> <arg name='output' type='int' info='boolean, use handler for output'/>
<arg name='out' type='xmlCharEncodingHandler **' info='pointer to result'/> <arg name='out' type='xmlCharEncodingHandler **' info='pointer to result'/>
@ -12275,7 +12275,7 @@ crash if you try to modify the tree)'/>
</function> </function>
<functype name='xmlResourceLoader' file='parser' module='parser'> <functype name='xmlResourceLoader' file='parser' module='parser'>
<info>Callback for custom resource loaders. @flags can contain XML_INPUT_UNZIP and XML_INPUT_NETWORK. On success, @out should be set to a new parser input object and XML_ERR_OK should be returned.</info> <info>Callback for custom resource loaders. @flags can contain XML_INPUT_UNZIP and XML_INPUT_NETWORK. On success, @out should be set to a new parser input object and XML_ERR_OK should be returned.</info>
<return type='int' info='an xmlParserError code.'/> <return type='xmlParserErrors' info='an xmlParserErrors code.'/>
<arg name='ctxt' type='void *' info='parser context'/> <arg name='ctxt' type='void *' info='parser context'/>
<arg name='url' type='const char *' info='URL to load'/> <arg name='url' type='const char *' info='URL to load'/>
<arg name='publicId' type='const char *' info='publid ID from DTD (optional)'/> <arg name='publicId' type='const char *' info='publid ID from DTD (optional)'/>
@ -12628,7 +12628,7 @@ crash if you try to modify the tree)'/>
<function name='xmlSaveFinish' file='xmlsave' module='xmlsave'> <function name='xmlSaveFinish' file='xmlsave' module='xmlsave'>
<cond>defined(LIBXML_OUTPUT_ENABLED)</cond> <cond>defined(LIBXML_OUTPUT_ENABLED)</cond>
<info>Close a document saving context, i.e. make sure that all bytes have been output and free the associated data. Available since 2.13.0.</info> <info>Close a document saving context, i.e. make sure that all bytes have been output and free the associated data. Available since 2.13.0.</info>
<return type='int' info='an xmlParserErrors code.'/> <return type='xmlParserErrors' info='an xmlParserErrors code.'/>
<arg name='ctxt' type='xmlSaveCtxtPtr' info='a document saving context'/> <arg name='ctxt' type='xmlSaveCtxtPtr' info='a document saving context'/>
</function> </function>
<function name='xmlSaveFlush' file='xmlsave' module='xmlsave'> <function name='xmlSaveFlush' file='xmlsave' module='xmlsave'>

View File

@ -112,34 +112,34 @@ static const xmlEncTableEntry xmlEncTable[] = {
{ "UTF8", XML_CHAR_ENCODING_UTF8 } { "UTF8", XML_CHAR_ENCODING_UTF8 }
}; };
static int static xmlCharEncError
asciiToAscii(void *vctxt, unsigned char* out, int *outlen, asciiToAscii(void *vctxt, unsigned char* out, int *outlen,
const unsigned char* in, int *inlen, int flush); const unsigned char* in, int *inlen, int flush);
static int static xmlCharEncError
UTF8ToUTF8(void *vctxt, unsigned char* out, int *outlen, UTF8ToUTF8(void *vctxt, unsigned char* out, int *outlen,
const unsigned char* inb, int *inlenb, int flush); const unsigned char* inb, int *inlenb, int flush);
static int static xmlCharEncError
latin1ToUTF8(void *vctxt, unsigned char* out, int *outlen, latin1ToUTF8(void *vctxt, unsigned char* out, int *outlen,
const unsigned char* in, int *inlen, int flush); const unsigned char* in, int *inlen, int flush);
static int static xmlCharEncError
UTF16LEToUTF8(void *vctxt, unsigned char* out, int *outlen, UTF16LEToUTF8(void *vctxt, unsigned char* out, int *outlen,
const unsigned char* inb, int *inlenb, int flush); const unsigned char* inb, int *inlenb, int flush);
static int static xmlCharEncError
UTF16BEToUTF8(void *vctxt, unsigned char* out, int *outlen, UTF16BEToUTF8(void *vctxt, unsigned char* out, int *outlen,
const unsigned char* inb, int *inlenb, int flush); const unsigned char* inb, int *inlenb, int flush);
#ifdef LIBXML_OUTPUT_ENABLED #ifdef LIBXML_OUTPUT_ENABLED
static int static xmlCharEncError
UTF8ToLatin1(void *vctxt, unsigned char* outb, int *outlen, UTF8ToLatin1(void *vctxt, unsigned char* outb, int *outlen,
const unsigned char* in, int *inlen, int flush); const unsigned char* in, int *inlen, int flush);
static int static xmlCharEncError
UTF8ToUTF16(void *vctxt, unsigned char* outb, int *outlen, UTF8ToUTF16(void *vctxt, unsigned char* outb, int *outlen,
const unsigned char* in, int *inlen, int flush); const unsigned char* in, int *inlen, int flush);
static int static xmlCharEncError
UTF8ToUTF16LE(void *vctxt, unsigned char* outb, int *outlen, UTF8ToUTF16LE(void *vctxt, unsigned char* outb, int *outlen,
const unsigned char* in, int *inlen, int flush); const unsigned char* in, int *inlen, int flush);
static int static xmlCharEncError
UTF8ToUTF16BE(void *vctxt, unsigned char* outb, int *outlen, UTF8ToUTF16BE(void *vctxt, unsigned char* outb, int *outlen,
const unsigned char* in, int *inlen, int flush); const unsigned char* in, int *inlen, int flush);
@ -153,7 +153,7 @@ UTF8ToUTF16BE(void *vctxt, unsigned char* outb, int *outlen,
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
#if defined(LIBXML_OUTPUT_ENABLED) && defined(LIBXML_HTML_ENABLED) #if defined(LIBXML_OUTPUT_ENABLED) && defined(LIBXML_HTML_ENABLED)
static int static xmlCharEncError
UTF8ToHtmlWrapper(void *vctxt, unsigned char *out, int *outlen, UTF8ToHtmlWrapper(void *vctxt, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, int flush); const unsigned char *in, int *inlen, int flush);
#else #else
@ -165,10 +165,10 @@ UTF8ToHtmlWrapper(void *vctxt, unsigned char *out, int *outlen,
#include "iso8859x.inc" #include "iso8859x.inc"
static int static xmlCharEncError
ISO8859xToUTF8(void *vctxt, unsigned char* out, int *outlen, ISO8859xToUTF8(void *vctxt, unsigned char* out, int *outlen,
const unsigned char* in, int *inlen, int flush); const unsigned char* in, int *inlen, int flush);
static int static xmlCharEncError
UTF8ToISO8859x(void *vctxt, unsigned char *out, int *outlen, UTF8ToISO8859x(void *vctxt, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, int flush); const unsigned char *in, int *inlen, int flush);
@ -238,13 +238,13 @@ static xmlCharEncodingHandlerPtr *globalHandlers = NULL;
static int nbCharEncodingHandler = 0; static int nbCharEncodingHandler = 0;
#ifdef LIBXML_ICONV_ENABLED #ifdef LIBXML_ICONV_ENABLED
static int static xmlParserErrors
xmlCharEncIconv(const char *name, xmlCharEncFlags flags, xmlCharEncIconv(const char *name, xmlCharEncFlags flags,
xmlCharEncodingHandler **out); xmlCharEncodingHandler **out);
#endif #endif
#ifdef LIBXML_ICU_ENABLED #ifdef LIBXML_ICU_ENABLED
static int static xmlParserErrors
xmlCharEncUconv(const char *name, xmlCharEncFlags flags, xmlCharEncUconv(const char *name, xmlCharEncFlags flags,
xmlCharEncodingHandler **out); xmlCharEncodingHandler **out);
#endif #endif
@ -655,9 +655,9 @@ xmlNewCharEncodingHandler(const char *name,
* *
* Create a custom xmlCharEncodingHandler. * Create a custom xmlCharEncodingHandler.
* *
* Returns an xmlParserError code. * Returns an xmlParserErrors code.
*/ */
int xmlParserErrors
xmlCharEncNewCustomHandler(const char *name, xmlCharEncNewCustomHandler(const char *name,
xmlCharEncConvFunc input, xmlCharEncConvFunc output, xmlCharEncConvFunc input, xmlCharEncConvFunc output,
xmlCharEncConvCtxtDtor ctxtDtor, xmlCharEncConvCtxtDtor ctxtDtor,
@ -805,7 +805,7 @@ free_handler:
* *
* Returns an xmlParserErrors error code. * Returns an xmlParserErrors error code.
*/ */
static int static xmlParserErrors
xmlFindExtraHandler(const char *norig, const char *name, xmlCharEncFlags flags, xmlFindExtraHandler(const char *norig, const char *name, xmlCharEncFlags flags,
xmlCharEncConvImpl impl, void *implCtxt, xmlCharEncConvImpl impl, void *implCtxt,
xmlCharEncodingHandler **out) { xmlCharEncodingHandler **out) {
@ -886,7 +886,7 @@ xmlFindExtraHandler(const char *norig, const char *name, xmlCharEncFlags flags,
* Returns XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another * Returns XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another
* xmlParserErrors error code. * xmlParserErrors error code.
*/ */
int xmlParserErrors
xmlLookupCharEncodingHandler(xmlCharEncoding enc, xmlLookupCharEncodingHandler(xmlCharEncoding enc,
xmlCharEncodingHandler **out) { xmlCharEncodingHandler **out) {
const xmlCharEncodingHandler *handler; const xmlCharEncodingHandler *handler;
@ -969,7 +969,7 @@ xmlGetCharEncodingHandler(xmlCharEncoding enc) {
* Returns XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another * Returns XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another
* xmlParserErrors error code. * xmlParserErrors error code.
*/ */
int xmlParserErrors
xmlCreateCharEncodingHandler(const char *name, xmlCharEncFlags flags, xmlCreateCharEncodingHandler(const char *name, xmlCharEncFlags flags,
xmlCharEncConvImpl impl, void *implCtxt, xmlCharEncConvImpl impl, void *implCtxt,
xmlCharEncodingHandler **out) { xmlCharEncodingHandler **out) {
@ -1031,7 +1031,7 @@ xmlCreateCharEncodingHandler(const char *name, xmlCharEncFlags flags,
* Returns XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another * Returns XML_ERR_OK, XML_ERR_UNSUPPORTED_ENCODING or another
* xmlParserErrors error code. * xmlParserErrors error code.
*/ */
int xmlParserErrors
xmlOpenCharEncodingHandler(const char *name, int output, xmlOpenCharEncodingHandler(const char *name, int output,
xmlCharEncodingHandler **out) { xmlCharEncodingHandler **out) {
xmlCharEncFlags flags = output ? XML_ENC_OUTPUT : XML_ENC_INPUT; xmlCharEncFlags flags = output ? XML_ENC_OUTPUT : XML_ENC_INPUT;
@ -1094,13 +1094,13 @@ typedef struct {
* @inlen: the length of @in * @inlen: the length of @in
* @flush: end of input * @flush: end of input
* *
* Returns an XML_ENC_ERR code.
*
* The value of @inlen after return is the number of octets consumed * The value of @inlen after return is the number of octets consumed
* as the return value is positive, else unpredictable. * as the return value is positive, else unpredictable.
* The value of @outlen after return is the number of octets produced. * The value of @outlen after return is the number of octets produced.
*
* Returns an XML_ENC_ERR code.
*/ */
static int static xmlCharEncError
xmlIconvConvert(void *vctxt, unsigned char *out, int *outlen, xmlIconvConvert(void *vctxt, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, const unsigned char *in, int *inlen,
int flush ATTRIBUTE_UNUSED) { int flush ATTRIBUTE_UNUSED) {
@ -1185,14 +1185,14 @@ xmlEncodingMatch(const char *name1, const char *name2) {
} }
#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */ #endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
static int static xmlParserErrors
xmlCharEncIconv(const char *name, xmlCharEncFlags flags, xmlCharEncIconv(const char *name, xmlCharEncFlags flags,
xmlCharEncodingHandler **out) { xmlCharEncodingHandler **out) {
xmlCharEncConvFunc inFunc = NULL, outFunc = NULL; xmlCharEncConvFunc inFunc = NULL, outFunc = NULL;
xmlIconvCtxt *inputCtxt = NULL, *outputCtxt = NULL; xmlIconvCtxt *inputCtxt = NULL, *outputCtxt = NULL;
iconv_t icv_in; iconv_t icv_in;
iconv_t icv_out; iconv_t icv_out;
int ret; xmlParserErrors ret;
/* /*
* POSIX allows "indicator suffixes" like "//IGNORE" to be * POSIX allows "indicator suffixes" like "//IGNORE" to be
@ -1334,7 +1334,7 @@ struct _uconv_t {
* as the return value is positive, else unpredictable. * as the return value is positive, else unpredictable.
* The value of @outlen after return is the number of octets produced. * The value of @outlen after return is the number of octets produced.
*/ */
static int static xmlCharEncError
xmlUconvConvert(void *vctxt, unsigned char *out, int *outlen, xmlUconvConvert(void *vctxt, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, int flush) { const unsigned char *in, int *inlen, int flush) {
xmlUconvCtxt *cd = vctxt; xmlUconvCtxt *cd = vctxt;
@ -1406,7 +1406,7 @@ xmlUconvConvert(void *vctxt, unsigned char *out, int *outlen,
return(ret); return(ret);
} }
static int static xmlParserErrors
openIcuConverter(const char* name, int isInput, xmlUconvCtxt **out) openIcuConverter(const char* name, int isInput, xmlUconvCtxt **out)
{ {
UErrorCode status; UErrorCode status;
@ -1445,7 +1445,7 @@ openIcuConverter(const char* name, int isInput, xmlUconvCtxt **out)
goto error; goto error;
*out = conv; *out = conv;
return(0); return(XML_ERR_OK);
error: error:
if (conv->uconv) if (conv->uconv)
@ -1474,7 +1474,7 @@ xmlUconvFree(void *vctxt) {
closeIcuConverter(vctxt); closeIcuConverter(vctxt);
} }
static int static xmlParserErrors
xmlCharEncUconv(const char *name, xmlCharEncFlags flags, xmlCharEncUconv(const char *name, xmlCharEncFlags flags,
xmlCharEncodingHandler **out) { xmlCharEncodingHandler **out) {
xmlCharEncConvFunc inFunc = NULL, outFunc = NULL; xmlCharEncConvFunc inFunc = NULL, outFunc = NULL;
@ -1520,9 +1520,9 @@ error:
* *
* Convert XML_ENC_ERR to libxml2 error codes. * Convert XML_ENC_ERR to libxml2 error codes.
*/ */
static int static xmlParserErrors
xmlEncConvertError(int code) { xmlEncConvertError(xmlCharEncError code) {
int ret; xmlParserErrors ret;
switch (code) { switch (code) {
case XML_ENC_ERR_SUCCESS: case XML_ENC_ERR_SUCCESS:
@ -1557,11 +1557,11 @@ xmlEncConvertError(int code) {
* *
* Returns an XML_ENC_ERR code. * Returns an XML_ENC_ERR code.
*/ */
int xmlCharEncError
xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out, xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
int *outlen, const unsigned char *in, int *inlen, int *outlen, const unsigned char *in, int *inlen,
int flush) { int flush) {
int ret; xmlCharEncError ret;
if (handler->flags & XML_HANDLER_LEGACY) { if (handler->flags & XML_HANDLER_LEGACY) {
xmlCharEncodingInputFunc func = handler->input.legacyFunc; xmlCharEncodingInputFunc func = handler->input.legacyFunc;
@ -1613,10 +1613,10 @@ xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
* as the return value is 0, else unpredictable. * as the return value is 0, else unpredictable.
* The value of @outlen after return is the number of octets produced. * The value of @outlen after return is the number of octets produced.
*/ */
static int static xmlCharEncError
xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out, xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
int *outlen, const unsigned char *in, int *inlen) { int *outlen, const unsigned char *in, int *inlen) {
int ret; xmlCharEncError ret;
if (handler->flags & XML_HANDLER_LEGACY) { if (handler->flags & XML_HANDLER_LEGACY) {
xmlCharEncodingOutputFunc func = handler->output.legacyFunc; xmlCharEncodingOutputFunc func = handler->output.legacyFunc;
@ -1675,7 +1675,7 @@ xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
* *
* Returns an XML_ENC_ERR code. * Returns an XML_ENC_ERR code.
*/ */
int xmlCharEncError
xmlCharEncInput(xmlParserInputBufferPtr input, size_t *sizeOut, int flush) xmlCharEncInput(xmlParserInputBufferPtr input, size_t *sizeOut, int flush)
{ {
xmlBufPtr out, in; xmlBufPtr out, in;
@ -1683,7 +1683,7 @@ xmlCharEncInput(xmlParserInputBufferPtr input, size_t *sizeOut, int flush)
size_t availIn; size_t availIn;
size_t maxOut; size_t maxOut;
size_t totalIn, totalOut; size_t totalIn, totalOut;
int ret; xmlCharEncError ret;
out = input->buffer; out = input->buffer;
in = input->raw; in = input->raw;
@ -1763,7 +1763,7 @@ xmlCharEncInput(xmlParserInputBufferPtr input, size_t *sizeOut, int flush)
input->rawconsumed += totalIn; input->rawconsumed += totalIn;
*sizeOut = totalOut; *sizeOut = totalOut;
return(XML_ERR_OK); return(XML_ENC_ERR_SUCCESS);
} }
/** /**
@ -2126,7 +2126,7 @@ xmlByteConsumed(xmlParserCtxtPtr ctxt) {
* * * *
************************************************************************/ ************************************************************************/
static int static xmlCharEncError
asciiToAscii(void *vctxt ATTRIBUTE_UNUSED, asciiToAscii(void *vctxt ATTRIBUTE_UNUSED,
unsigned char* out, int *poutlen, unsigned char* out, int *poutlen,
const unsigned char* in, int *pinlen, const unsigned char* in, int *pinlen,
@ -2171,7 +2171,7 @@ asciiToAscii(void *vctxt ATTRIBUTE_UNUSED,
return(ret); return(ret);
} }
static int static xmlCharEncError
latin1ToUTF8(void *vctxt ATTRIBUTE_UNUSED, latin1ToUTF8(void *vctxt ATTRIBUTE_UNUSED,
unsigned char* out, int *outlen, unsigned char* out, int *outlen,
const unsigned char* in, int *inlen, const unsigned char* in, int *inlen,
@ -2236,7 +2236,7 @@ xmlIsolat1ToUTF8(unsigned char* out, int *outlen,
/* flush */ 0)); /* flush */ 0));
} }
static int static xmlCharEncError
UTF8ToUTF8(void *vctxt ATTRIBUTE_UNUSED, UTF8ToUTF8(void *vctxt ATTRIBUTE_UNUSED,
unsigned char* out, int *outlen, unsigned char* out, int *outlen,
const unsigned char* in, int *inlen, const unsigned char* in, int *inlen,
@ -2267,7 +2267,7 @@ UTF8ToUTF8(void *vctxt ATTRIBUTE_UNUSED,
#ifdef LIBXML_OUTPUT_ENABLED #ifdef LIBXML_OUTPUT_ENABLED
static int static xmlCharEncError
UTF8ToLatin1(void *vctxt ATTRIBUTE_UNUSED, UTF8ToLatin1(void *vctxt ATTRIBUTE_UNUSED,
unsigned char* out, int *outlen, unsigned char* out, int *outlen,
const unsigned char* in, int *inlen, const unsigned char* in, int *inlen,
@ -2346,7 +2346,7 @@ xmlUTF8ToIsolat1(unsigned char* out, int *outlen,
} }
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
static int static xmlCharEncError
UTF16LEToUTF8(void *vctxt ATTRIBUTE_UNUSED, UTF16LEToUTF8(void *vctxt ATTRIBUTE_UNUSED,
unsigned char *out, int *outlen, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, const unsigned char *in, int *inlen,
@ -2416,7 +2416,7 @@ done:
} }
#ifdef LIBXML_OUTPUT_ENABLED #ifdef LIBXML_OUTPUT_ENABLED
static int static xmlCharEncError
UTF8ToUTF16LE(void *vctxt ATTRIBUTE_UNUSED, UTF8ToUTF16LE(void *vctxt ATTRIBUTE_UNUSED,
unsigned char *out, int *outlen, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, const unsigned char *in, int *inlen,
@ -2519,7 +2519,7 @@ done:
return(ret); return(ret);
} }
static int static xmlCharEncError
UTF8ToUTF16(void *vctxt, UTF8ToUTF16(void *vctxt,
unsigned char* outb, int *outlen, unsigned char* outb, int *outlen,
const unsigned char* in, int *inlen, const unsigned char* in, int *inlen,
@ -2543,7 +2543,7 @@ UTF8ToUTF16(void *vctxt,
} }
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
static int static xmlCharEncError
UTF16BEToUTF8(void *vctxt ATTRIBUTE_UNUSED, UTF16BEToUTF8(void *vctxt ATTRIBUTE_UNUSED,
unsigned char *out, int *outlen, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, const unsigned char *in, int *inlen,
@ -2613,7 +2613,7 @@ done:
} }
#ifdef LIBXML_OUTPUT_ENABLED #ifdef LIBXML_OUTPUT_ENABLED
static int static xmlCharEncError
UTF8ToUTF16BE(void *vctxt ATTRIBUTE_UNUSED, UTF8ToUTF16BE(void *vctxt ATTRIBUTE_UNUSED,
unsigned char *out, int *outlen, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, const unsigned char *in, int *inlen,
@ -2717,7 +2717,7 @@ done:
#endif /* LIBXML_OUTPUT_ENABLED */ #endif /* LIBXML_OUTPUT_ENABLED */
#if defined(LIBXML_OUTPUT_ENABLED) && defined(LIBXML_HTML_ENABLED) #if defined(LIBXML_OUTPUT_ENABLED) && defined(LIBXML_HTML_ENABLED)
static int static xmlCharEncError
UTF8ToHtmlWrapper(void *vctxt ATTRIBUTE_UNUSED, UTF8ToHtmlWrapper(void *vctxt ATTRIBUTE_UNUSED,
unsigned char *out, int *outlen, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, const unsigned char *in, int *inlen,
@ -2729,7 +2729,7 @@ UTF8ToHtmlWrapper(void *vctxt ATTRIBUTE_UNUSED,
#if !defined(LIBXML_ICONV_ENABLED) && !defined(LIBXML_ICU_ENABLED) && \ #if !defined(LIBXML_ICONV_ENABLED) && !defined(LIBXML_ICU_ENABLED) && \
defined(LIBXML_ISO8859X_ENABLED) defined(LIBXML_ISO8859X_ENABLED)
static int static xmlCharEncError
UTF8ToISO8859x(void *vctxt, UTF8ToISO8859x(void *vctxt,
unsigned char *out, int *outlen, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, const unsigned char *in, int *inlen,
@ -2811,7 +2811,7 @@ done:
return(ret); return(ret);
} }
static int static xmlCharEncError
ISO8859xToUTF8(void *vctxt, ISO8859xToUTF8(void *vctxt,
unsigned char* out, int *outlen, unsigned char* out, int *outlen,
const unsigned char* in, int *inlen, const unsigned char* in, int *inlen,

View File

@ -30,7 +30,7 @@ typedef struct {
UChar pivot_buf[ICU_PIVOT_BUF_SIZE]; UChar pivot_buf[ICU_PIVOT_BUF_SIZE];
} myConvCtxt; } myConvCtxt;
static int static xmlCharEncError
icuConvert(void *vctxt, unsigned char *out, int *outlen, icuConvert(void *vctxt, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, int flush) { const unsigned char *in, int *inlen, int flush) {
myConvCtxt *cd = vctxt; myConvCtxt *cd = vctxt;
@ -102,7 +102,7 @@ icuConvert(void *vctxt, unsigned char *out, int *outlen,
return ret; return ret;
} }
static int static xmlParserErrors
icuOpen(const char* name, int isInput, myConvCtxt **out) icuOpen(const char* name, int isInput, myConvCtxt **out)
{ {
UErrorCode status; UErrorCode status;
@ -170,13 +170,13 @@ icuConvCtxtDtor(void *vctxt) {
icuClose(vctxt); icuClose(vctxt);
} }
static int static xmlParserErrors
icuConvImpl(void *vctxt, const char *name, xmlCharEncFlags flags, icuConvImpl(void *vctxt, const char *name, xmlCharEncFlags flags,
xmlCharEncodingHandler **result) { xmlCharEncodingHandler **result) {
xmlCharEncConvFunc inFunc = NULL, outFunc = NULL; xmlCharEncConvFunc inFunc = NULL, outFunc = NULL;
myConvCtxt *inputCtxt = NULL; myConvCtxt *inputCtxt = NULL;
myConvCtxt *outputCtxt = NULL; myConvCtxt *outputCtxt = NULL;
int ret; xmlParserErrors ret;
if (flags & XML_ENC_INPUT) { if (flags & XML_ENC_INPUT) {
ret = icuOpen(name, 1, &inputCtxt); ret = icuOpen(name, 1, &inputCtxt);

View File

@ -457,7 +457,7 @@ xmlFuzzSecondaryEntity(size_t *size) {
* *
* The resource loader for fuzz data. * The resource loader for fuzz data.
*/ */
int xmlParserErrors
xmlFuzzResourceLoader(void *data ATTRIBUTE_UNUSED, const char *URL, xmlFuzzResourceLoader(void *data ATTRIBUTE_UNUSED, const char *URL,
const char *ID ATTRIBUTE_UNUSED, const char *ID ATTRIBUTE_UNUSED,
xmlResourceType type ATTRIBUTE_UNUSED, xmlResourceType type ATTRIBUTE_UNUSED,

View File

@ -135,7 +135,7 @@ xmlFuzzSecondaryUrl(void);
const char * const char *
xmlFuzzSecondaryEntity(size_t *size); xmlFuzzSecondaryEntity(size_t *size);
int xmlParserErrors
xmlFuzzResourceLoader(void *data, const char *URL, const char *ID, xmlFuzzResourceLoader(void *data, const char *URL, const char *ID,
xmlResourceType type, xmlParserInputFlags flags, xmlResourceType type, xmlParserInputFlags flags,
xmlParserInputPtr *out); xmlParserInputPtr *out);

View File

@ -54,7 +54,7 @@ static struct {
* A custom resource loader that writes all external DTDs or entities to a * A custom resource loader that writes all external DTDs or entities to a
* single file in the format expected by xmlFuzzResourceLoader. * single file in the format expected by xmlFuzzResourceLoader.
*/ */
static int static xmlParserErrors
fuzzResourceRecorder(void *data ATTRIBUTE_UNUSED, const char *URL, fuzzResourceRecorder(void *data ATTRIBUTE_UNUSED, const char *URL,
const char *ID ATTRIBUTE_UNUSED, const char *ID ATTRIBUTE_UNUSED,
xmlResourceType type ATTRIBUTE_UNUSED, xmlResourceType type ATTRIBUTE_UNUSED,

View File

@ -23,6 +23,7 @@
#define __XML_CHAR_ENCODING_H__ #define __XML_CHAR_ENCODING_H__
#include <libxml/xmlversion.h> #include <libxml/xmlversion.h>
#include <libxml/xmlerror.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -142,9 +143,9 @@ typedef int (*xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,
* @flush flag can be used to detect truncated sequences at EOF. * @flush flag can be used to detect truncated sequences at EOF.
* Otherwise, the flag can be ignored. * Otherwise, the flag can be ignored.
* *
* Returns a non-negative number on success or an XML_ENC_ERR code. * Returns an XML_ENC_ERR code.
*/ */
typedef int typedef xmlCharEncError
(*xmlCharEncConvFunc)(void *vctxt, unsigned char *out, int *outlen, (*xmlCharEncConvFunc)(void *vctxt, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, int flush); const unsigned char *in, int *inlen, int flush);
@ -195,7 +196,7 @@ struct _xmlCharEncodingHandler {
* *
* Returns an xmlParserErrors code. * Returns an xmlParserErrors code.
*/ */
typedef int typedef xmlParserErrors
(*xmlCharEncConvImpl)(void *vctxt, const char *name, xmlCharEncFlags flags, (*xmlCharEncConvImpl)(void *vctxt, const char *name, xmlCharEncFlags flags,
xmlCharEncodingHandler **out); xmlCharEncodingHandler **out);
@ -210,14 +211,14 @@ XMLPUBFUN void
xmlCleanupCharEncodingHandlers (void); xmlCleanupCharEncodingHandlers (void);
XMLPUBFUN void XMLPUBFUN void
xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler); xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler);
XMLPUBFUN int XMLPUBFUN xmlParserErrors
xmlLookupCharEncodingHandler (xmlCharEncoding enc, xmlLookupCharEncodingHandler (xmlCharEncoding enc,
xmlCharEncodingHandlerPtr *out); xmlCharEncodingHandlerPtr *out);
XMLPUBFUN int XMLPUBFUN xmlParserErrors
xmlOpenCharEncodingHandler (const char *name, xmlOpenCharEncodingHandler (const char *name,
int output, int output,
xmlCharEncodingHandlerPtr *out); xmlCharEncodingHandlerPtr *out);
XMLPUBFUN int XMLPUBFUN xmlParserErrors
xmlCreateCharEncodingHandler (const char *name, xmlCreateCharEncodingHandler (const char *name,
xmlCharEncFlags flags, xmlCharEncFlags flags,
xmlCharEncConvImpl impl, xmlCharEncConvImpl impl,
@ -231,7 +232,7 @@ XMLPUBFUN xmlCharEncodingHandlerPtr
xmlNewCharEncodingHandler (const char *name, xmlNewCharEncodingHandler (const char *name,
xmlCharEncodingInputFunc input, xmlCharEncodingInputFunc input,
xmlCharEncodingOutputFunc output); xmlCharEncodingOutputFunc output);
XMLPUBFUN int XMLPUBFUN xmlParserErrors
xmlCharEncNewCustomHandler (const char *name, xmlCharEncNewCustomHandler (const char *name,
xmlCharEncConvFunc input, xmlCharEncConvFunc input,
xmlCharEncConvFunc output, xmlCharEncConvFunc output,

View File

@ -218,9 +218,9 @@ typedef struct _xmlAttrHashBucket xmlAttrHashBucket;
* On success, @out should be set to a new parser input object and * On success, @out should be set to a new parser input object and
* XML_ERR_OK should be returned. * XML_ERR_OK should be returned.
* *
* Returns an xmlParserError code. * Returns an xmlParserErrors code.
*/ */
typedef int typedef xmlParserErrors
(*xmlResourceLoader)(void *ctxt, const char *url, const char *publicId, (*xmlResourceLoader)(void *ctxt, const char *url, const char *publicId,
xmlResourceType type, xmlParserInputFlags flags, xmlResourceType type, xmlParserInputFlags flags,
xmlParserInputPtr *out); xmlParserInputPtr *out);
@ -1555,7 +1555,7 @@ XMLPUBFUN xmlDocPtr
* New input API * New input API
*/ */
XMLPUBFUN int XMLPUBFUN xmlParserErrors
xmlNewInputFromUrl(const char *url, xmlParserInputFlags flags, xmlNewInputFromUrl(const char *url, xmlParserInputFlags flags,
xmlParserInputPtr *out); xmlParserInputPtr *out);
XMLPUBFUN xmlParserInputPtr XMLPUBFUN xmlParserInputPtr
@ -1570,7 +1570,7 @@ XMLPUBFUN xmlParserInputPtr
xmlNewInputFromIO(const char *url, xmlInputReadCallback ioRead, xmlNewInputFromIO(const char *url, xmlInputReadCallback ioRead,
xmlInputCloseCallback ioClose, void *ioCtxt, xmlInputCloseCallback ioClose, void *ioCtxt,
xmlParserInputFlags flags); xmlParserInputFlags flags);
XMLPUBFUN int XMLPUBFUN xmlParserErrors
xmlInputSetEncodingHandler(xmlParserInputPtr input, xmlInputSetEncodingHandler(xmlParserInputPtr input,
xmlCharEncodingHandlerPtr handler); xmlCharEncodingHandlerPtr handler);

View File

@ -77,7 +77,7 @@ XMLPUBFUN int
xmlSaveFlush (xmlSaveCtxtPtr ctxt); xmlSaveFlush (xmlSaveCtxtPtr ctxt);
XMLPUBFUN int XMLPUBFUN int
xmlSaveClose (xmlSaveCtxtPtr ctxt); xmlSaveClose (xmlSaveCtxtPtr ctxt);
XMLPUBFUN int XMLPUBFUN xmlParserErrors
xmlSaveFinish (xmlSaveCtxtPtr ctxt); xmlSaveFinish (xmlSaveCtxtPtr ctxt);
XMLPUBFUN int XMLPUBFUN int
xmlSaveSetIndentString (xmlSaveCtxtPtr ctxt, xmlSaveSetIndentString (xmlSaveCtxtPtr ctxt,

View File

@ -7,11 +7,11 @@
XML_HIDDEN void XML_HIDDEN void
xmlInitEncodingInternal(void); xmlInitEncodingInternal(void);
XML_HIDDEN int XML_HIDDEN xmlCharEncError
xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out, xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
int *outlen, const unsigned char *in, int *inlen, int *outlen, const unsigned char *in, int *inlen,
int flush); int flush);
XML_HIDDEN int XML_HIDDEN xmlCharEncError
xmlCharEncInput(xmlParserInputBufferPtr input, size_t *sizeOut, int flush); xmlCharEncInput(xmlParserInputBufferPtr input, size_t *sizeOut, int flush);
XML_HIDDEN int XML_HIDDEN int
xmlCharEncOutput(xmlOutputBufferPtr output, int init); xmlCharEncOutput(xmlOutputBufferPtr output, int init);

View File

@ -21,7 +21,7 @@ xmlInitIOCallbacks(void);
XML_HIDDEN int XML_HIDDEN int
xmlNoNetExists(const char *filename); xmlNoNetExists(const char *filename);
XML_HIDDEN int XML_HIDDEN xmlParserErrors
xmlParserInputBufferCreateUrl(const char *URI, xmlCharEncoding enc, xmlParserInputBufferCreateUrl(const char *URI, xmlCharEncoding enc,
xmlParserInputFlags flags, xmlParserInputFlags flags,
xmlParserInputBufferPtr *out); xmlParserInputBufferPtr *out);
@ -32,7 +32,7 @@ XML_HIDDEN xmlParserInputBufferPtr
xmlNewInputBufferMemory(const void *mem, size_t size, xmlNewInputBufferMemory(const void *mem, size_t size,
xmlParserInputFlags flags, xmlCharEncoding enc); xmlParserInputFlags flags, xmlCharEncoding enc);
XML_HIDDEN int XML_HIDDEN xmlParserErrors
xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, xmlParserInputFlags flags); xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, xmlParserInputFlags flags);
#ifdef LIBXML_OUTPUT_ENABLED #ifdef LIBXML_OUTPUT_ENABLED

View File

@ -621,14 +621,14 @@ xmlParserCheckEOF(xmlParserCtxtPtr ctxt, xmlParserErrors code) {
if ((buf != NULL) && (buf->encoder != NULL)) { if ((buf != NULL) && (buf->encoder != NULL)) {
size_t curBase = in->cur - in->base; size_t curBase = in->cur - in->base;
size_t sizeOut = 64; size_t sizeOut = 64;
int ret; xmlCharEncError ret;
/* /*
* Check for truncated multi-byte sequence * Check for truncated multi-byte sequence
*/ */
ret = xmlCharEncInput(buf, &sizeOut, /* flush */ 1); ret = xmlCharEncInput(buf, &sizeOut, /* flush */ 1);
xmlBufUpdateInput(buf->buffer, in, curBase); xmlBufUpdateInput(buf->buffer, in, curBase);
if (ret < 0) { if (ret != XML_ENC_ERR_SUCCESS) {
xmlCtxtErrIO(ctxt, buf->error, NULL); xmlCtxtErrIO(ctxt, buf->error, NULL);
return; return;
} }
@ -1129,12 +1129,14 @@ xmlCtxtSetCharEncConvImpl(xmlParserCtxtPtr ctxt, xmlCharEncConvImpl impl,
ctxt->convCtxt = vctxt; ctxt->convCtxt = vctxt;
} }
static int static xmlParserErrors
xmlDetectEBCDIC(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr *hout) { xmlDetectEBCDIC(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr *hout) {
xmlChar out[200]; xmlChar out[200];
xmlParserInputPtr input = ctxt->input; xmlParserInputPtr input = ctxt->input;
xmlCharEncodingHandlerPtr handler; xmlCharEncodingHandlerPtr handler;
int inlen, outlen, res, i; int inlen, outlen, i;
xmlParserErrors code;
xmlCharEncError res;
*hout = NULL; *hout = NULL;
@ -1142,10 +1144,10 @@ xmlDetectEBCDIC(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr *hout) {
* To detect the EBCDIC code page, we convert the first 200 bytes * To detect the EBCDIC code page, we convert the first 200 bytes
* to IBM037 (EBCDIC-US) and try to find the encoding declaration. * to IBM037 (EBCDIC-US) and try to find the encoding declaration.
*/ */
res = xmlCreateCharEncodingHandler("IBM037", XML_ENC_INPUT, code = xmlCreateCharEncodingHandler("IBM037", XML_ENC_INPUT,
ctxt->convImpl, ctxt->convCtxt, &handler); ctxt->convImpl, ctxt->convCtxt, &handler);
if (res != 0) if (code != XML_ERR_OK)
return(res); return(code);
outlen = sizeof(out) - 1; outlen = sizeof(out) - 1;
inlen = input->end - input->cur; inlen = input->end - input->cur;
res = xmlEncInputChunk(handler, out, &outlen, input->cur, &inlen, res = xmlEncInputChunk(handler, out, &outlen, input->cur, &inlen,
@ -1187,13 +1189,13 @@ xmlDetectEBCDIC(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr *hout) {
break; break;
out[i] = 0; out[i] = 0;
xmlCharEncCloseFunc(handler); xmlCharEncCloseFunc(handler);
res = xmlCreateCharEncodingHandler((char *) out + start, code = xmlCreateCharEncodingHandler((char *) out + start,
XML_ENC_INPUT, ctxt->convImpl, ctxt->convCtxt, XML_ENC_INPUT, ctxt->convImpl, ctxt->convCtxt,
&handler); &handler);
if (res != 0) if (code != XML_ERR_OK)
return(res); return(code);
*hout = handler; *hout = handler;
return(0); return(XML_ERR_OK);
} }
} }
@ -1202,12 +1204,12 @@ done:
* Encoding handlers are stateful, so we have to recreate them. * Encoding handlers are stateful, so we have to recreate them.
*/ */
xmlCharEncCloseFunc(handler); xmlCharEncCloseFunc(handler);
res = xmlCreateCharEncodingHandler("IBM037", XML_ENC_INPUT, code = xmlCreateCharEncodingHandler("IBM037", XML_ENC_INPUT,
ctxt->convImpl, ctxt->convCtxt, &handler); ctxt->convImpl, ctxt->convCtxt, &handler);
if (res != 0) if (code != XML_ERR_OK)
return(res); return(code);
*hout = handler; *hout = handler;
return(0); return(XML_ERR_OK);
} }
/** /**
@ -1228,14 +1230,14 @@ xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
{ {
xmlCharEncodingHandlerPtr handler = NULL; xmlCharEncodingHandlerPtr handler = NULL;
int ret; int ret;
int res; xmlParserErrors code;
if ((ctxt == NULL) || (ctxt->input == NULL)) if ((ctxt == NULL) || (ctxt->input == NULL))
return(-1); return(-1);
res = xmlLookupCharEncodingHandler(enc, &handler); code = xmlLookupCharEncodingHandler(enc, &handler);
if (res != 0) { if (code != 0) {
xmlFatalErr(ctxt, res, NULL); xmlFatalErr(ctxt, code, NULL);
return(-1); return(-1);
} }
@ -1260,7 +1262,7 @@ static int
xmlSwitchInputEncodingName(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, xmlSwitchInputEncodingName(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
const char *encoding) { const char *encoding) {
xmlCharEncodingHandlerPtr handler; xmlCharEncodingHandlerPtr handler;
int res; xmlParserErrors res;
if (encoding == NULL) if (encoding == NULL)
return(-1); return(-1);
@ -1319,12 +1321,12 @@ xmlSwitchEncodingName(xmlParserCtxtPtr ctxt, const char *encoding) {
* *
* Returns an xmlParserErrors code. * Returns an xmlParserErrors code.
*/ */
int xmlParserErrors
xmlInputSetEncodingHandler(xmlParserInputPtr input, xmlInputSetEncodingHandler(xmlParserInputPtr input,
xmlCharEncodingHandlerPtr handler) { xmlCharEncodingHandlerPtr handler) {
xmlParserInputBufferPtr in; xmlParserInputBufferPtr in;
xmlBufPtr buf; xmlBufPtr buf;
int code = XML_ERR_OK; xmlParserErrors code = XML_ERR_OK;
if ((input == NULL) || (input->buf == NULL)) { if ((input == NULL) || (input->buf == NULL)) {
xmlCharEncCloseFunc(handler); xmlCharEncCloseFunc(handler);
@ -1377,7 +1379,7 @@ xmlInputSetEncodingHandler(xmlParserInputPtr input,
if (input->end > input->base) { if (input->end > input->base) {
size_t processed; size_t processed;
size_t nbchars; size_t nbchars;
int res; xmlCharEncError res;
/* /*
* Shrink the current input buffer. * Shrink the current input buffer.
@ -1399,7 +1401,7 @@ xmlInputSetEncodingHandler(xmlParserInputPtr input,
else else
nbchars = 4000 /* MINLEN */; nbchars = 4000 /* MINLEN */;
res = xmlCharEncInput(in, &nbchars, /* flush */ 0); res = xmlCharEncInput(in, &nbchars, /* flush */ 0);
if (res < 0) if (res != XML_ENC_ERR_SUCCESS)
code = in->error; code = in->error;
} }
@ -1423,7 +1425,7 @@ xmlInputSetEncodingHandler(xmlParserInputPtr input,
int int
xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input, xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
xmlCharEncodingHandlerPtr handler) { xmlCharEncodingHandlerPtr handler) {
int code = xmlInputSetEncodingHandler(input, handler); xmlParserErrors code = xmlInputSetEncodingHandler(input, handler);
if (code != XML_ERR_OK) { if (code != XML_ERR_OK) {
xmlCtxtErrIO(ctxt, code, NULL); xmlCtxtErrIO(ctxt, code, NULL);
@ -1448,7 +1450,7 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
int int
xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler) xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
{ {
int code; xmlParserErrors code;
if (ctxt == NULL) if (ctxt == NULL)
return(-1); return(-1);
@ -1579,7 +1581,7 @@ xmlDetectEncoding(xmlParserCtxtPtr ctxt) {
if (enc == XML_CHAR_ENCODING_EBCDIC) { if (enc == XML_CHAR_ENCODING_EBCDIC) {
xmlCharEncodingHandlerPtr handler; xmlCharEncodingHandlerPtr handler;
int res; xmlParserErrors res;
res = xmlDetectEBCDIC(ctxt, &handler); res = xmlDetectEBCDIC(ctxt, &handler);
if (res != XML_ERR_OK) { if (res != XML_ERR_OK) {
@ -1610,7 +1612,7 @@ xmlSetDeclaredEncoding(xmlParserCtxtPtr ctxt, xmlChar *encoding) {
if (((ctxt->input->flags & XML_INPUT_HAS_ENCODING) == 0) && if (((ctxt->input->flags & XML_INPUT_HAS_ENCODING) == 0) &&
((ctxt->options & XML_PARSE_IGNORE_ENC) == 0)) { ((ctxt->options & XML_PARSE_IGNORE_ENC) == 0)) {
xmlCharEncodingHandlerPtr handler; xmlCharEncodingHandlerPtr handler;
int res; xmlParserErrors res;
/* /*
* xmlSwitchEncodingName treats unsupported encodings as * xmlSwitchEncodingName treats unsupported encodings as
@ -2018,7 +2020,7 @@ xmlNewInputFromFd(const char *url, int fd, xmlParserInputFlags flags) {
if (buf == NULL) if (buf == NULL)
return(NULL); return(NULL);
if (xmlInputFromFd(buf, fd, flags) < 0) { if (xmlInputFromFd(buf, fd, flags) != XML_ERR_OK) {
xmlFreeParserInputBuffer(buf); xmlFreeParserInputBuffer(buf);
return(NULL); return(NULL);
} }
@ -2367,7 +2369,7 @@ xmlResolveResourceFromCatalog(const char *URL, const char *ID,
#endif #endif
#ifdef LIBXML_HTTP_ENABLED #ifdef LIBXML_HTTP_ENABLED
static int static xmlParserErrors
xmlCheckHTTPInputInternal(xmlParserInputPtr input) { xmlCheckHTTPInputInternal(xmlParserInputPtr input) {
const char *encoding; const char *encoding;
const char *redir; const char *redir;
@ -2391,7 +2393,7 @@ xmlCheckHTTPInputInternal(xmlParserInputPtr input) {
encoding = xmlNanoHTTPEncoding(input->buf->context); encoding = xmlNanoHTTPEncoding(input->buf->context);
if (encoding != NULL) { if (encoding != NULL) {
xmlCharEncodingHandlerPtr handler; xmlCharEncodingHandlerPtr handler;
int res; xmlParserErrors res;
res = xmlOpenCharEncodingHandler(encoding, /* output */ 0, res = xmlOpenCharEncodingHandler(encoding, /* output */ 0,
&handler); &handler);
@ -2478,12 +2480,12 @@ xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret) {
* *
* Returns an xmlParserErrors code. * Returns an xmlParserErrors code.
*/ */
int xmlParserErrors
xmlNewInputFromUrl(const char *filename, xmlParserInputFlags flags, xmlNewInputFromUrl(const char *filename, xmlParserInputFlags flags,
xmlParserInputPtr *out) { xmlParserInputPtr *out) {
xmlParserInputBufferPtr buf; xmlParserInputBufferPtr buf;
xmlParserInputPtr input; xmlParserInputPtr input;
int code = XML_ERR_OK; xmlParserErrors code = XML_ERR_OK;
if (out == NULL) if (out == NULL)
return(XML_ERR_ARGUMENT); return(XML_ERR_ARGUMENT);
@ -2534,7 +2536,7 @@ xmlParserInputPtr
xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) { xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
xmlParserInputPtr input; xmlParserInputPtr input;
xmlParserInputFlags flags = 0; xmlParserInputFlags flags = 0;
int code; xmlParserErrors code;
if ((ctxt == NULL) || (filename == NULL)) if ((ctxt == NULL) || (filename == NULL))
return(NULL); return(NULL);

View File

@ -241,7 +241,7 @@ static int addEntity(char *name, char *content) {
return(0); return(0);
} }
static int static xmlParserErrors
testResourceLoader(void *vctxt ATTRIBUTE_UNUSED, const char *URL, testResourceLoader(void *vctxt ATTRIBUTE_UNUSED, const char *URL,
const char *ID ATTRIBUTE_UNUSED, const char *ID ATTRIBUTE_UNUSED,
xmlResourceType type ATTRIBUTE_UNUSED, xmlResourceType type ATTRIBUTE_UNUSED,

View File

@ -13222,7 +13222,7 @@ test_xmlInputSetEncodingHandler(void) {
int test_ret = 0; int test_ret = 0;
int mem_base; int mem_base;
int ret_val; xmlParserErrors ret_val;
xmlParserInputPtr input; /* the input stream */ xmlParserInputPtr input; /* the input stream */
int n_input; int n_input;
xmlCharEncodingHandlerPtr handler; /* the encoding handler */ xmlCharEncodingHandlerPtr handler; /* the encoding handler */
@ -13235,7 +13235,7 @@ test_xmlInputSetEncodingHandler(void) {
handler = gen_xmlCharEncodingHandlerPtr(n_handler, 1); handler = gen_xmlCharEncodingHandlerPtr(n_handler, 1);
ret_val = xmlInputSetEncodingHandler(input, handler); ret_val = xmlInputSetEncodingHandler(input, handler);
desret_int(ret_val); desret_xmlParserErrors(ret_val);
call_tests++; call_tests++;
des_xmlParserInputPtr(n_input, input, 0); des_xmlParserInputPtr(n_input, input, 0);
des_xmlCharEncodingHandlerPtr(n_handler, handler, 1); des_xmlCharEncodingHandlerPtr(n_handler, handler, 1);
@ -13534,7 +13534,7 @@ test_xmlNewInputFromUrl(void) {
int test_ret = 0; int test_ret = 0;
int mem_base; int mem_base;
int ret_val; xmlParserErrors ret_val;
const char * filename; /* the filename to use as entity */ const char * filename; /* the filename to use as entity */
int n_filename; int n_filename;
xmlParserInputFlags flags; /* XML_INPUT flags */ xmlParserInputFlags flags; /* XML_INPUT flags */
@ -13551,7 +13551,7 @@ test_xmlNewInputFromUrl(void) {
out = gen_xmlParserInputPtr_ptr(n_out, 2); out = gen_xmlParserInputPtr_ptr(n_out, 2);
ret_val = xmlNewInputFromUrl(filename, flags, out); ret_val = xmlNewInputFromUrl(filename, flags, out);
desret_int(ret_val); desret_xmlParserErrors(ret_val);
call_tests++; call_tests++;
des_filepath(n_filename, filename, 0); des_filepath(n_filename, filename, 0);
des_xmlParserInputFlags(n_flags, flags, 1); des_xmlParserInputFlags(n_flags, flags, 1);
@ -33991,7 +33991,7 @@ test_xmlSaveFinish(void) {
#if defined(LIBXML_OUTPUT_ENABLED) #if defined(LIBXML_OUTPUT_ENABLED)
int mem_base; int mem_base;
int ret_val; xmlParserErrors ret_val;
xmlSaveCtxtPtr ctxt; /* a document saving context */ xmlSaveCtxtPtr ctxt; /* a document saving context */
int n_ctxt; int n_ctxt;
@ -34000,7 +34000,7 @@ test_xmlSaveFinish(void) {
ctxt = gen_xmlSaveCtxtPtr(n_ctxt, 0); ctxt = gen_xmlSaveCtxtPtr(n_ctxt, 0);
ret_val = xmlSaveFinish(ctxt); ret_val = xmlSaveFinish(ctxt);
desret_int(ret_val); desret_xmlParserErrors(ret_val);
call_tests++; call_tests++;
des_xmlSaveCtxtPtr(n_ctxt, ctxt, 0); des_xmlSaveCtxtPtr(n_ctxt, ctxt, 0);
xmlResetLastError(); xmlResetLastError();

View File

@ -1030,7 +1030,7 @@ testTruncatedMultiByte(void) {
static int charEncConvImplError; static int charEncConvImplError;
static int static xmlCharEncError
rot13Convert(void *vctxt, unsigned char *out, int *outlen, rot13Convert(void *vctxt, unsigned char *out, int *outlen,
const unsigned char *in, int *inlen, const unsigned char *in, int *inlen,
int flush ATTRIBUTE_UNUSED) { int flush ATTRIBUTE_UNUSED) {
@ -1063,7 +1063,7 @@ rot13ConvCtxtDtor(void *vctxt) {
xmlFree(vctxt); xmlFree(vctxt);
} }
static int static xmlParserErrors
rot13ConvImpl(void *vctxt ATTRIBUTE_UNUSED, const char *name, rot13ConvImpl(void *vctxt ATTRIBUTE_UNUSED, const char *name,
xmlCharEncFlags flags, xmlCharEncodingHandler **out) { xmlCharEncFlags flags, xmlCharEncodingHandler **out) {
int *inputCtxt; int *inputCtxt;

View File

@ -1398,18 +1398,20 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, xmlXIncludeRefPtr ref) {
encoding = xmlXIncludeGetProp(ctxt, ref->elem, XINCLUDE_PARSE_ENCODING); encoding = xmlXIncludeGetProp(ctxt, ref->elem, XINCLUDE_PARSE_ENCODING);
} }
if (encoding != NULL) { if (encoding != NULL) {
res = xmlOpenCharEncodingHandler((const char *) encoding, xmlParserErrors code;
/* output */ 0, &handler);
if (res != 0) { code = xmlOpenCharEncodingHandler((const char *) encoding,
if (res == XML_ERR_NO_MEMORY) { /* output */ 0, &handler);
if (code != XML_ERR_OK) {
if (code == XML_ERR_NO_MEMORY) {
xmlXIncludeErrMemory(ctxt); xmlXIncludeErrMemory(ctxt);
} else if (res == XML_ERR_UNSUPPORTED_ENCODING) { } else if (code == XML_ERR_UNSUPPORTED_ENCODING) {
xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_UNKNOWN_ENCODING, xmlXIncludeErr(ctxt, ref->elem, XML_XINCLUDE_UNKNOWN_ENCODING,
"encoding %s not supported\n", encoding); "encoding %s not supported\n", encoding);
goto error; goto error;
} else { } else {
xmlXIncludeErr(ctxt, ref->elem, res, xmlXIncludeErr(ctxt, ref->elem, code,
"unexpected error from iconv or ICU\n", NULL); "unexpected error from iconv or ICU\n", NULL);
goto error; goto error;
} }

40
xmlIO.c
View File

@ -122,10 +122,10 @@ static int xmlOutputCallbackNr;
* *
* Returns an xmlParserErrors code. * Returns an xmlParserErrors code.
*/ */
static int static xmlParserErrors
xmlIOErr(int err) xmlIOErr(int err)
{ {
int code; xmlParserErrors code;
if (err == 0) code = XML_IO_UNKNOWN; if (err == 0) code = XML_IO_UNKNOWN;
#ifdef EACCES #ifdef EACCES
@ -449,12 +449,12 @@ typedef struct {
* *
* Returns an xmlParserErrors code * Returns an xmlParserErrors code
*/ */
static int static xmlParserErrors
xmlFdOpen(const char *filename, int write, int *out) { xmlFdOpen(const char *filename, int write, int *out) {
char *fromUri = NULL; char *fromUri = NULL;
int flags; int flags;
int fd; int fd;
int ret; xmlParserErrors ret;
*out = -1; *out = -1;
if (filename == NULL) if (filename == NULL)
@ -628,13 +628,13 @@ xmlFileMatch (const char *filename ATTRIBUTE_UNUSED) {
* *
* input from FILE * * input from FILE *
* *
* Returns an I/O context or NULL in case of error * Returns an xmlParserErrors code
*/ */
static int static xmlParserErrors
xmlFileOpenSafe(const char *filename, int write, void **out) { xmlFileOpenSafe(const char *filename, int write, void **out) {
char *fromUri = NULL; char *fromUri = NULL;
FILE *fd; FILE *fd;
int ret = XML_ERR_OK; xmlParserErrors ret = XML_ERR_OK;
*out = NULL; *out = NULL;
if (filename == NULL) if (filename == NULL)
@ -1046,9 +1046,9 @@ xmlIODefaultMatch(const char *filename ATTRIBUTE_UNUSED) {
* Update the buffer to read from @fd. Supports the XML_INPUT_UNZIP * Update the buffer to read from @fd. Supports the XML_INPUT_UNZIP
* flag. * flag.
* *
* Returns an xmlParserError code. * Returns an xmlParserErrors code.
*/ */
int xmlParserErrors
xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, xmlInputFromFd(xmlParserInputBufferPtr buf, int fd,
xmlParserInputFlags flags) { xmlParserInputFlags flags) {
xmlFdIOCtxt *fdctxt; xmlFdIOCtxt *fdctxt;
@ -1160,10 +1160,10 @@ xmlInputFromFd(xmlParserInputBufferPtr buf, int fd,
* *
* Returns an xmlParserErrors code. * Returns an xmlParserErrors code.
*/ */
static int static xmlParserErrors
xmlInputDefaultOpen(xmlParserInputBufferPtr buf, const char *filename, xmlInputDefaultOpen(xmlParserInputBufferPtr buf, const char *filename,
xmlParserInputFlags flags) { xmlParserInputFlags flags) {
int ret; xmlParserErrors ret;
int fd; int fd;
#ifdef LIBXML_HTTP_ENABLED #ifdef LIBXML_HTTP_ENABLED
@ -1205,7 +1205,7 @@ xmlInputDefaultOpen(xmlParserInputBufferPtr buf, const char *filename,
* *
* Returns an xmlParserErrors code. * Returns an xmlParserErrors code.
*/ */
static int static xmlParserErrors
xmlOutputDefaultOpen(xmlOutputBufferPtr buf, const char *filename, xmlOutputDefaultOpen(xmlOutputBufferPtr buf, const char *filename,
int compression) { int compression) {
xmlFdIOCtxt *fdctxt; xmlFdIOCtxt *fdctxt;
@ -1290,7 +1290,7 @@ xmlAllocParserInputBuffer(xmlCharEncoding enc) {
return(NULL); return(NULL);
} }
if (enc != XML_CHAR_ENCODING_NONE) { if (enc != XML_CHAR_ENCODING_NONE) {
if (xmlLookupCharEncodingHandler(enc, &ret->encoder) != 0) { if (xmlLookupCharEncodingHandler(enc, &ret->encoder) != XML_ERR_OK) {
/* We can't handle errors properly here. */ /* We can't handle errors properly here. */
xmlFreeParserInputBuffer(ret); xmlFreeParserInputBuffer(ret);
return(NULL); return(NULL);
@ -1454,12 +1454,12 @@ xmlOutputBufferClose(xmlOutputBufferPtr out)
* *
* Returns an xmlParserErrors code. * Returns an xmlParserErrors code.
*/ */
int xmlParserErrors
xmlParserInputBufferCreateUrl(const char *URI, xmlCharEncoding enc, xmlParserInputBufferCreateUrl(const char *URI, xmlCharEncoding enc,
xmlParserInputFlags flags, xmlParserInputFlags flags,
xmlParserInputBufferPtr *out) { xmlParserInputBufferPtr *out) {
xmlParserInputBufferPtr buf; xmlParserInputBufferPtr buf;
int ret; xmlParserErrors ret;
int i; int i;
xmlInitParser(); xmlInitParser();
@ -1534,7 +1534,7 @@ __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
xmlParserInputBufferPtr xmlParserInputBufferPtr
xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) { xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
xmlParserInputBufferPtr ret; xmlParserInputBufferPtr ret;
int code; xmlParserErrors code;
if (xmlParserInputBufferCreateFilenameValue != NULL) if (xmlParserInputBufferCreateFilenameValue != NULL)
return(xmlParserInputBufferCreateFilenameValue(URI, enc)); return(xmlParserInputBufferCreateFilenameValue(URI, enc));
@ -1601,7 +1601,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
*/ */
for (i = xmlOutputCallbackNr - 1; i >= 0; i--) { for (i = xmlOutputCallbackNr - 1; i >= 0; i--) {
xmlOutputCallback *cb = &xmlOutputCallbackTable[i]; xmlOutputCallback *cb = &xmlOutputCallbackTable[i];
int code; xmlParserErrors code;
if (cb->matchcallback == xmlIODefaultMatch) { if (cb->matchcallback == xmlIODefaultMatch) {
code = xmlOutputDefaultOpen(ret, URI, compression); code = xmlOutputDefaultOpen(ret, URI, compression);
@ -2203,7 +2203,8 @@ xmlParserInputBufferPush(xmlParserInputBufferPtr in,
* convert as much as possible to the parser reading buffer. * convert as much as possible to the parser reading buffer.
*/ */
nbchars = SIZE_MAX; nbchars = SIZE_MAX;
if (xmlCharEncInput(in, &nbchars, /* flush */ 0) < 0) if (xmlCharEncInput(in, &nbchars, /* flush */ 0) !=
XML_ENC_ERR_SUCCESS)
return(-1); return(-1);
if (nbchars > INT_MAX) if (nbchars > INT_MAX)
nbchars = INT_MAX; nbchars = INT_MAX;
@ -2314,7 +2315,8 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
else else
sizeOut = SIZE_MAX; sizeOut = SIZE_MAX;
if (xmlCharEncInput(in, &sizeOut, /* flush */ 0) < 0) if (xmlCharEncInput(in, &sizeOut, /* flush */ 0) !=
XML_ENC_ERR_SUCCESS)
return(-1); return(-1);
res = sizeOut; res = sizeOut;
} }

View File

@ -253,12 +253,12 @@ parsePath(xmllintState *lint, const xmlChar *path) {
} }
} }
static int static xmlParserErrors
xmllintResourceLoader(void *ctxt, const char *URL, xmllintResourceLoader(void *ctxt, const char *URL,
const char *ID, xmlResourceType type, const char *ID, xmlResourceType type,
xmlParserInputFlags flags, xmlParserInputPtr *out) { xmlParserInputFlags flags, xmlParserInputPtr *out) {
xmllintState *lint = ctxt; xmllintState *lint = ctxt;
int code; xmlParserErrors code;
int i; int i;
const char *lastsegment = URL; const char *lastsegment = URL;
const char *iter = URL; const char *iter = URL;

View File

@ -319,7 +319,7 @@ xmlNewSaveCtxt(const char *encoding, int options)
memset(ret, 0, sizeof(xmlSaveCtxt)); memset(ret, 0, sizeof(xmlSaveCtxt));
if (encoding != NULL) { if (encoding != NULL) {
int res; xmlParserErrors res;
res = xmlOpenCharEncodingHandler(encoding, /* output */ 1, res = xmlOpenCharEncodingHandler(encoding, /* output */ 1,
&ret->handler); &ret->handler);
@ -771,7 +771,7 @@ static int xmlSaveSwitchEncoding(xmlSaveCtxtPtr ctxt, const char *encoding) {
if ((encoding != NULL) && (buf->encoder == NULL) && (buf->conv == NULL)) { if ((encoding != NULL) && (buf->encoder == NULL) && (buf->conv == NULL)) {
xmlCharEncodingHandler *handler; xmlCharEncodingHandler *handler;
int res; xmlParserErrors res;
res = xmlOpenCharEncodingHandler(encoding, /* output */ 1, &handler); res = xmlOpenCharEncodingHandler(encoding, /* output */ 1, &handler);
if (res != XML_ERR_OK) { if (res != XML_ERR_OK) {
@ -2196,7 +2196,7 @@ xmlSaveClose(xmlSaveCtxtPtr ctxt)
* *
* Returns an xmlParserErrors code. * Returns an xmlParserErrors code.
*/ */
int xmlParserErrors
xmlSaveFinish(xmlSaveCtxtPtr ctxt) xmlSaveFinish(xmlSaveCtxtPtr ctxt)
{ {
int ret; int ret;
@ -2549,7 +2549,7 @@ xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, xmlChar **doc_txt_ptr,
if (txt_encoding == NULL) if (txt_encoding == NULL)
txt_encoding = (const char *) out_doc->encoding; txt_encoding = (const char *) out_doc->encoding;
if (txt_encoding != NULL) { if (txt_encoding != NULL) {
int res; xmlParserErrors res;
res = xmlOpenCharEncodingHandler(txt_encoding, /* output */ 1, res = xmlOpenCharEncodingHandler(txt_encoding, /* output */ 1,
&conv_hdlr); &conv_hdlr);
@ -2671,7 +2671,7 @@ xmlDocFormatDump(FILE *f, xmlDocPtr cur, int format) {
encoding = (const char *) cur->encoding; encoding = (const char *) cur->encoding;
if (encoding != NULL) { if (encoding != NULL) {
int res; xmlParserErrors res;
res = xmlOpenCharEncodingHandler(encoding, /* output */ 1, &handler); res = xmlOpenCharEncodingHandler(encoding, /* output */ 1, &handler);
if (res != XML_ERR_OK) { if (res != XML_ERR_OK) {
@ -2817,7 +2817,7 @@ xmlSaveFormatFileEnc( const char * filename, xmlDocPtr cur,
encoding = (const char *) cur->encoding; encoding = (const char *) cur->encoding;
if (encoding != NULL) { if (encoding != NULL) {
int res; xmlParserErrors res;
res = xmlOpenCharEncodingHandler(encoding, /* output */ 1, &handler); res = xmlOpenCharEncodingHandler(encoding, /* output */ 1, &handler);
if (res != XML_ERR_OK) if (res != XML_ERR_OK)