mirror of
https://github.com/reactos/reactos.git
synced 2025-06-29 07:39:44 +00:00
[LIBXML2]
- Sync to 2.9.0 - Let's do this more often in the future so it's less of a pain ^^ CORE-6907 #resolve svn path=/trunk/; revision=58300
This commit is contained in:
parent
29f27192d0
commit
026838ba4d
84 changed files with 9417 additions and 1907 deletions
|
@ -184,7 +184,8 @@ typedef enum {
|
||||||
HTML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
|
HTML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
|
||||||
HTML_PARSE_NONET = 1<<11,/* Forbid network access */
|
HTML_PARSE_NONET = 1<<11,/* Forbid network access */
|
||||||
HTML_PARSE_NOIMPLIED= 1<<13,/* Do not add implied html/body... elements */
|
HTML_PARSE_NOIMPLIED= 1<<13,/* Do not add implied html/body... elements */
|
||||||
HTML_PARSE_COMPACT = 1<<16 /* compact small text nodes */
|
HTML_PARSE_COMPACT = 1<<16,/* compact small text nodes */
|
||||||
|
HTML_PARSE_IGNORE_ENC=1<<21 /* ignore internal document encoding hint */
|
||||||
} htmlParserOption;
|
} htmlParserOption;
|
||||||
|
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
|
|
|
@ -63,7 +63,7 @@ XMLPUBFUN void XMLCALL
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
* *
|
* *
|
||||||
* Checking routines *
|
* Checking routines *
|
||||||
* *
|
* *
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ XMLPUBFUN int XMLCALL
|
||||||
|
|
||||||
/****************************************************************
|
/****************************************************************
|
||||||
* *
|
* *
|
||||||
* XML shell helpers *
|
* XML shell helpers *
|
||||||
* *
|
* *
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#ifndef __XML_DICT_H__
|
#ifndef __XML_DICT_H__
|
||||||
#define __XML_DICT_H__
|
#define __XML_DICT_H__
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
#include <libxml/xmlversion.h>
|
#include <libxml/xmlversion.h>
|
||||||
#include <libxml/tree.h>
|
#include <libxml/tree.h>
|
||||||
|
|
||||||
|
@ -24,11 +25,21 @@ extern "C" {
|
||||||
typedef struct _xmlDict xmlDict;
|
typedef struct _xmlDict xmlDict;
|
||||||
typedef xmlDict *xmlDictPtr;
|
typedef xmlDict *xmlDictPtr;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initializer
|
||||||
|
*/
|
||||||
|
XMLPUBFUN int XMLCALL xmlInitializeDict(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructor and destructor.
|
* Constructor and destructor.
|
||||||
*/
|
*/
|
||||||
XMLPUBFUN xmlDictPtr XMLCALL
|
XMLPUBFUN xmlDictPtr XMLCALL
|
||||||
xmlDictCreate (void);
|
xmlDictCreate (void);
|
||||||
|
XMLPUBFUN size_t XMLCALL
|
||||||
|
xmlDictSetLimit (xmlDictPtr dict,
|
||||||
|
size_t limit);
|
||||||
|
XMLPUBFUN size_t XMLCALL
|
||||||
|
xmlDictGetUsage (xmlDictPtr dict);
|
||||||
XMLPUBFUN xmlDictPtr XMLCALL
|
XMLPUBFUN xmlDictPtr XMLCALL
|
||||||
xmlDictCreateSub(xmlDictPtr sub);
|
xmlDictCreateSub(xmlDictPtr sub);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
|
|
|
@ -175,8 +175,8 @@ XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
|
||||||
xmlFindCharEncodingHandler (const char *name);
|
xmlFindCharEncodingHandler (const char *name);
|
||||||
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
|
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
|
||||||
xmlNewCharEncodingHandler (const char *name,
|
xmlNewCharEncodingHandler (const char *name,
|
||||||
xmlCharEncodingInputFunc input,
|
xmlCharEncodingInputFunc input,
|
||||||
xmlCharEncodingOutputFunc output);
|
xmlCharEncodingOutputFunc output);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Interfaces for encoding names and aliases.
|
* Interfaces for encoding names and aliases.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Summary: Chained hash tables
|
* Summary: Chained hash tables
|
||||||
* Description: This module implements the hash table support used in
|
* Description: This module implements the hash table support used in
|
||||||
* various places in the library.
|
* various places in the library.
|
||||||
*
|
*
|
||||||
* Copy: See Copyright for the status of this software.
|
* Copy: See Copyright for the status of this software.
|
||||||
*
|
*
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
* macro used to provide portability of code to windows sockets
|
* macro used to provide portability of code to windows sockets
|
||||||
* the value to be used when the socket is not valid
|
* the value to be used when the socket is not valid
|
||||||
*/
|
*/
|
||||||
|
#undef INVALID_SOCKET
|
||||||
#define INVALID_SOCKET (-1)
|
#define INVALID_SOCKET (-1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -125,9 +125,9 @@ typedef enum {
|
||||||
XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
|
XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
|
||||||
XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
|
XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
|
||||||
XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
|
XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
|
||||||
XML_PARSER_EPILOG, /* the Misc* after the last end tag */
|
XML_PARSER_EPILOG, /* the Misc* after the last end tag */
|
||||||
XML_PARSER_IGNORE, /* within an IGNORED section */
|
XML_PARSER_IGNORE, /* within an IGNORED section */
|
||||||
XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
|
XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
|
||||||
} xmlParserInputState;
|
} xmlParserInputState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -308,6 +308,8 @@ struct _xmlParserCtxt {
|
||||||
int nodeInfoNr; /* Depth of the parsing stack */
|
int nodeInfoNr; /* Depth of the parsing stack */
|
||||||
int nodeInfoMax; /* Max depth of the parsing stack */
|
int nodeInfoMax; /* Max depth of the parsing stack */
|
||||||
xmlParserNodeInfo *nodeInfoTab; /* array of nodeInfos */
|
xmlParserNodeInfo *nodeInfoTab; /* array of nodeInfos */
|
||||||
|
|
||||||
|
int input_id; /* we need to label inputs */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -891,12 +893,12 @@ XMLPUBFUN xmlDocPtr XMLCALL
|
||||||
XMLPUBFUN xmlDocPtr XMLCALL
|
XMLPUBFUN xmlDocPtr XMLCALL
|
||||||
xmlSAXParseMemory (xmlSAXHandlerPtr sax,
|
xmlSAXParseMemory (xmlSAXHandlerPtr sax,
|
||||||
const char *buffer,
|
const char *buffer,
|
||||||
int size,
|
int size,
|
||||||
int recovery);
|
int recovery);
|
||||||
XMLPUBFUN xmlDocPtr XMLCALL
|
XMLPUBFUN xmlDocPtr XMLCALL
|
||||||
xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
|
xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
|
||||||
const char *buffer,
|
const char *buffer,
|
||||||
int size,
|
int size,
|
||||||
int recovery,
|
int recovery,
|
||||||
void *data);
|
void *data);
|
||||||
XMLPUBFUN xmlDocPtr XMLCALL
|
XMLPUBFUN xmlDocPtr XMLCALL
|
||||||
|
@ -1105,8 +1107,10 @@ typedef enum {
|
||||||
crash if you try to modify the tree) */
|
crash if you try to modify the tree) */
|
||||||
XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */
|
XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */
|
||||||
XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */
|
XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */
|
||||||
XML_PARSE_HUGE = 1<<19, /* relax any hardcoded limit from the parser */
|
XML_PARSE_HUGE = 1<<19,/* relax any hardcoded limit from the parser */
|
||||||
XML_PARSE_OLDSAX = 1<<20 /* parse using SAX2 interface from before 2.7.0 */
|
XML_PARSE_OLDSAX = 1<<20,/* parse using SAX2 interface before 2.7.0 */
|
||||||
|
XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */
|
||||||
|
XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */
|
||||||
} xmlParserOption;
|
} xmlParserOption;
|
||||||
|
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
|
@ -1223,6 +1227,7 @@ typedef enum {
|
||||||
XML_WITH_DEBUG_RUN = 30,
|
XML_WITH_DEBUG_RUN = 30,
|
||||||
XML_WITH_ZLIB = 31,
|
XML_WITH_ZLIB = 31,
|
||||||
XML_WITH_ICU = 32,
|
XML_WITH_ICU = 32,
|
||||||
|
XML_WITH_LZMA = 33,
|
||||||
XML_WITH_NONE = 99999 /* just to be sure of allocation size */
|
XML_WITH_NONE = 99999 /* just to be sure of allocation size */
|
||||||
} xmlFeature;
|
} xmlFeature;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Summary: internals routines exported by the parser.
|
* Summary: internals routines and limits exported by the parser.
|
||||||
* Description: this module exports a number of internal parsing routines
|
* Description: this module exports a number of internal parsing routines
|
||||||
* they are not really all intended for applications but
|
* they are not really all intended for applications but
|
||||||
* can prove useful doing low level processing.
|
* can prove useful doing low level processing.
|
||||||
|
@ -36,9 +36,42 @@ XMLPUBVAR unsigned int xmlParserMaxDepth;
|
||||||
* Maximum size allowed for a single text node when building a tree.
|
* Maximum size allowed for a single text node when building a tree.
|
||||||
* This is not a limitation of the parser but a safety boundary feature,
|
* This is not a limitation of the parser but a safety boundary feature,
|
||||||
* use XML_PARSE_HUGE option to override it.
|
* use XML_PARSE_HUGE option to override it.
|
||||||
|
* Introduced in 2.9.0
|
||||||
*/
|
*/
|
||||||
#define XML_MAX_TEXT_LENGTH 10000000
|
#define XML_MAX_TEXT_LENGTH 10000000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XML_MAX_NAME_LENGTH:
|
||||||
|
*
|
||||||
|
* Maximum size allowed for a markup identitier
|
||||||
|
* This is not a limitation of the parser but a safety boundary feature,
|
||||||
|
* use XML_PARSE_HUGE option to override it.
|
||||||
|
* Note that with the use of parsing dictionaries overriding the limit
|
||||||
|
* may result in more runtime memory usage in face of "unfriendly' content
|
||||||
|
* Introduced in 2.9.0
|
||||||
|
*/
|
||||||
|
#define XML_MAX_NAME_LENGTH 50000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XML_MAX_DICTIONARY_LIMIT:
|
||||||
|
*
|
||||||
|
* Maximum size allowed by the parser for a dictionary by default
|
||||||
|
* This is not a limitation of the parser but a safety boundary feature,
|
||||||
|
* use XML_PARSE_HUGE option to override it.
|
||||||
|
* Introduced in 2.9.0
|
||||||
|
*/
|
||||||
|
#define XML_MAX_DICTIONARY_LIMIT 10000000
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XML_MAX_LOOKUP_LIMIT:
|
||||||
|
*
|
||||||
|
* Maximum size allowed by the parser for ahead lookup
|
||||||
|
* This is an upper boundary enforced by the parser to avoid bad
|
||||||
|
* behaviour on "unfriendly' content
|
||||||
|
* Introduced in 2.9.0
|
||||||
|
*/
|
||||||
|
#define XML_MAX_LOOKUP_LIMIT 10000000
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XML_MAX_NAMELEN:
|
* XML_MAX_NAMELEN:
|
||||||
*
|
*
|
||||||
|
@ -57,7 +90,7 @@ XMLPUBVAR unsigned int xmlParserMaxDepth;
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* UNICODE version of the macros. *
|
* UNICODE version of the macros. *
|
||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
/**
|
/**
|
||||||
|
@ -251,7 +284,7 @@ XMLPUBVAR unsigned int xmlParserMaxDepth;
|
||||||
*
|
*
|
||||||
* Skips the end of line chars.
|
* Skips the end of line chars.
|
||||||
*/
|
*/
|
||||||
#define SKIP_EOL(p) \
|
#define SKIP_EOL(p) \
|
||||||
if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; } \
|
if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; } \
|
||||||
if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; }
|
if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; }
|
||||||
|
|
||||||
|
@ -483,7 +516,7 @@ XMLPUBFUN void XMLCALL
|
||||||
*
|
*
|
||||||
* Both general and parameter entities need to be substituted.
|
* Both general and parameter entities need to be substituted.
|
||||||
*/
|
*/
|
||||||
#define XML_SUBSTITUTE_BOTH 3
|
#define XML_SUBSTITUTE_BOTH 3
|
||||||
|
|
||||||
XMLPUBFUN xmlChar * XMLCALL
|
XMLPUBFUN xmlChar * XMLCALL
|
||||||
xmlStringDecodeEntities (xmlParserCtxtPtr ctxt,
|
xmlStringDecodeEntities (xmlParserCtxtPtr ctxt,
|
||||||
|
|
|
@ -127,7 +127,7 @@ XMLPUBFUN int XMLCALL
|
||||||
|
|
||||||
XMLPUBFUN xmlSchematronValidCtxtPtr XMLCALL
|
XMLPUBFUN xmlSchematronValidCtxtPtr XMLCALL
|
||||||
xmlSchematronNewValidCtxt (xmlSchematronPtr schema,
|
xmlSchematronNewValidCtxt (xmlSchematronPtr schema,
|
||||||
int options);
|
int options);
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlSchematronFreeValidCtxt (xmlSchematronValidCtxtPtr ctxt);
|
xmlSchematronFreeValidCtxt (xmlSchematronValidCtxtPtr ctxt);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#define __XML_TREE_H__
|
#define __XML_TREE_H__
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <libxml/xmlversion.h>
|
#include <libxml/xmlversion.h>
|
||||||
#include <libxml/xmlstring.h>
|
#include <libxml/xmlstring.h>
|
||||||
|
|
||||||
|
@ -74,13 +75,15 @@ typedef enum {
|
||||||
XML_BUFFER_ALLOC_DOUBLEIT, /* double each time one need to grow */
|
XML_BUFFER_ALLOC_DOUBLEIT, /* double each time one need to grow */
|
||||||
XML_BUFFER_ALLOC_EXACT, /* grow only to the minimal size */
|
XML_BUFFER_ALLOC_EXACT, /* grow only to the minimal size */
|
||||||
XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer */
|
XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer */
|
||||||
XML_BUFFER_ALLOC_IO /* special allocation scheme used for I/O */
|
XML_BUFFER_ALLOC_IO, /* special allocation scheme used for I/O */
|
||||||
|
XML_BUFFER_ALLOC_HYBRID /* exact up to a threshold, and doubleit thereafter */
|
||||||
} xmlBufferAllocationScheme;
|
} xmlBufferAllocationScheme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlBuffer:
|
* xmlBuffer:
|
||||||
*
|
*
|
||||||
* A buffer structure.
|
* A buffer structure, this old construct is limited to 2GB and
|
||||||
|
* is being deprecated, use API with xmlBuf instead
|
||||||
*/
|
*/
|
||||||
typedef struct _xmlBuffer xmlBuffer;
|
typedef struct _xmlBuffer xmlBuffer;
|
||||||
typedef xmlBuffer *xmlBufferPtr;
|
typedef xmlBuffer *xmlBufferPtr;
|
||||||
|
@ -92,6 +95,41 @@ struct _xmlBuffer {
|
||||||
xmlChar *contentIO; /* in IO mode we may have a different base */
|
xmlChar *contentIO; /* in IO mode we may have a different base */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlBuf:
|
||||||
|
*
|
||||||
|
* A buffer structure, new one, the actual structure internals are not public
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct _xmlBuf xmlBuf;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlBufPtr:
|
||||||
|
*
|
||||||
|
* A pointer to a buffer structure, the actual structure internals are not
|
||||||
|
* public
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef xmlBuf *xmlBufPtr;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A few public routines for xmlBuf. As those are expected to be used
|
||||||
|
* mostly internally the bulk of the routines are internal in buf.h
|
||||||
|
*/
|
||||||
|
XMLPUBFUN xmlChar* XMLCALL xmlBufContent (const xmlBufPtr buf);
|
||||||
|
XMLPUBFUN xmlChar* XMLCALL xmlBufEnd (const xmlBufPtr buf);
|
||||||
|
XMLPUBFUN size_t XMLCALL xmlBufUse (xmlBufPtr buf);
|
||||||
|
XMLPUBFUN size_t XMLCALL xmlBufShrink (xmlBufPtr buf, size_t len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* LIBXML2_NEW_BUFFER:
|
||||||
|
*
|
||||||
|
* Macro used to express that the API use the new buffers for
|
||||||
|
* xmlParserInputBuffer and xmlOutputBuffer. The change was
|
||||||
|
* introduced in 2.9.0.
|
||||||
|
*/
|
||||||
|
#define LIBXML2_NEW_BUFFER
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XML_XML_NAMESPACE:
|
* XML_XML_NAMESPACE:
|
||||||
*
|
*
|
||||||
|
@ -647,7 +685,7 @@ XMLPUBFUN const xmlChar * XMLCALL
|
||||||
int *len);
|
int *len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handling Buffers.
|
* Handling Buffers, the old ones see @xmlBuf for the new ones.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
|
@ -694,6 +732,8 @@ XMLPUBFUN void XMLCALL
|
||||||
xmlBufferEmpty (xmlBufferPtr buf);
|
xmlBufferEmpty (xmlBufferPtr buf);
|
||||||
XMLPUBFUN const xmlChar* XMLCALL
|
XMLPUBFUN const xmlChar* XMLCALL
|
||||||
xmlBufferContent (const xmlBufferPtr buf);
|
xmlBufferContent (const xmlBufferPtr buf);
|
||||||
|
XMLPUBFUN xmlChar* XMLCALL
|
||||||
|
xmlBufferDetach (xmlBufferPtr buf);
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlBufferSetAllocationScheme(xmlBufferPtr buf,
|
xmlBufferSetAllocationScheme(xmlBufferPtr buf,
|
||||||
xmlBufferAllocationScheme scheme);
|
xmlBufferAllocationScheme scheme);
|
||||||
|
@ -1026,9 +1066,14 @@ XMLPUBFUN void XMLCALL
|
||||||
int len);
|
int len);
|
||||||
XMLPUBFUN xmlChar * XMLCALL
|
XMLPUBFUN xmlChar * XMLCALL
|
||||||
xmlNodeGetContent (xmlNodePtr cur);
|
xmlNodeGetContent (xmlNodePtr cur);
|
||||||
|
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlNodeBufGetContent (xmlBufferPtr buffer,
|
xmlNodeBufGetContent (xmlBufferPtr buffer,
|
||||||
xmlNodePtr cur);
|
xmlNodePtr cur);
|
||||||
|
XMLPUBFUN int XMLCALL
|
||||||
|
xmlBufGetNodeContent (xmlBufPtr buf,
|
||||||
|
xmlNodePtr cur);
|
||||||
|
|
||||||
XMLPUBFUN xmlChar * XMLCALL
|
XMLPUBFUN xmlChar * XMLCALL
|
||||||
xmlNodeGetLang (xmlNodePtr cur);
|
xmlNodeGetLang (xmlNodePtr cur);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
|
@ -1136,6 +1181,12 @@ XMLPUBFUN int XMLCALL
|
||||||
xmlSaveFormatFile (const char *filename,
|
xmlSaveFormatFile (const char *filename,
|
||||||
xmlDocPtr cur,
|
xmlDocPtr cur,
|
||||||
int format);
|
int format);
|
||||||
|
XMLPUBFUN size_t XMLCALL
|
||||||
|
xmlBufNodeDump (xmlBufPtr buf,
|
||||||
|
xmlDocPtr doc,
|
||||||
|
xmlNodePtr cur,
|
||||||
|
int level,
|
||||||
|
int format);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlNodeDump (xmlBufferPtr buf,
|
xmlNodeDump (xmlBufferPtr buf,
|
||||||
xmlDocPtr doc,
|
xmlDocPtr doc,
|
||||||
|
|
|
@ -129,8 +129,8 @@ struct _xmlParserInputBuffer {
|
||||||
|
|
||||||
xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
|
xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
|
||||||
|
|
||||||
xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
|
xmlBufPtr buffer; /* Local buffer encoded in UTF-8 */
|
||||||
xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
|
xmlBufPtr raw; /* if encoder != NULL buffer for raw input */
|
||||||
int compressed; /* -1=unknown, 0=not compressed, 1=compressed */
|
int compressed; /* -1=unknown, 0=not compressed, 1=compressed */
|
||||||
int error;
|
int error;
|
||||||
unsigned long rawconsumed;/* amount consumed from raw */
|
unsigned long rawconsumed;/* amount consumed from raw */
|
||||||
|
@ -145,8 +145,8 @@ struct _xmlOutputBuffer {
|
||||||
|
|
||||||
xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
|
xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
|
||||||
|
|
||||||
xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
|
xmlBufPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
|
||||||
xmlBufferPtr conv; /* if encoder != NULL buffer for output */
|
xmlBufPtr conv; /* if encoder != NULL buffer for output */
|
||||||
int written; /* total number of byte written */
|
int written; /* total number of byte written */
|
||||||
int error;
|
int error;
|
||||||
};
|
};
|
||||||
|
@ -245,6 +245,12 @@ XMLPUBFUN xmlOutputBufferPtr XMLCALL
|
||||||
void *ioctx,
|
void *ioctx,
|
||||||
xmlCharEncodingHandlerPtr encoder);
|
xmlCharEncodingHandlerPtr encoder);
|
||||||
|
|
||||||
|
/* Couple of APIs to get the output without digging into the buffers */
|
||||||
|
XMLPUBFUN const xmlChar * XMLCALL
|
||||||
|
xmlOutputBufferGetContent (xmlOutputBufferPtr out);
|
||||||
|
XMLPUBFUN size_t XMLCALL
|
||||||
|
xmlOutputBufferGetSize (xmlOutputBufferPtr out);
|
||||||
|
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlOutputBufferWrite (xmlOutputBufferPtr out,
|
xmlOutputBufferWrite (xmlOutputBufferPtr out,
|
||||||
int len,
|
int len,
|
||||||
|
@ -306,24 +312,24 @@ XMLPUBFUN int XMLCALL
|
||||||
* Default 'file://' protocol callbacks
|
* Default 'file://' protocol callbacks
|
||||||
*/
|
*/
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlFileMatch (const char *filename);
|
xmlFileMatch (const char *filename);
|
||||||
XMLPUBFUN void * XMLCALL
|
XMLPUBFUN void * XMLCALL
|
||||||
xmlFileOpen (const char *filename);
|
xmlFileOpen (const char *filename);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlFileRead (void * context,
|
xmlFileRead (void * context,
|
||||||
char * buffer,
|
char * buffer,
|
||||||
int len);
|
int len);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlFileClose (void * context);
|
xmlFileClose (void * context);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default 'http://' protocol callbacks
|
* Default 'http://' protocol callbacks
|
||||||
*/
|
*/
|
||||||
#ifdef LIBXML_HTTP_ENABLED
|
#ifdef LIBXML_HTTP_ENABLED
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlIOHTTPMatch (const char *filename);
|
xmlIOHTTPMatch (const char *filename);
|
||||||
XMLPUBFUN void * XMLCALL
|
XMLPUBFUN void * XMLCALL
|
||||||
xmlIOHTTPOpen (const char *filename);
|
xmlIOHTTPOpen (const char *filename);
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
#ifdef LIBXML_OUTPUT_ENABLED
|
||||||
XMLPUBFUN void * XMLCALL
|
XMLPUBFUN void * XMLCALL
|
||||||
xmlIOHTTPOpenW (const char * post_uri,
|
xmlIOHTTPOpenW (const char * post_uri,
|
||||||
|
@ -334,7 +340,7 @@ XMLPUBFUN int XMLCALL
|
||||||
char * buffer,
|
char * buffer,
|
||||||
int len);
|
int len);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlIOHTTPClose (void * context);
|
xmlIOHTTPClose (void * context);
|
||||||
#endif /* LIBXML_HTTP_ENABLED */
|
#endif /* LIBXML_HTTP_ENABLED */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -342,15 +348,15 @@ XMLPUBFUN int XMLCALL
|
||||||
*/
|
*/
|
||||||
#ifdef LIBXML_FTP_ENABLED
|
#ifdef LIBXML_FTP_ENABLED
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlIOFTPMatch (const char *filename);
|
xmlIOFTPMatch (const char *filename);
|
||||||
XMLPUBFUN void * XMLCALL
|
XMLPUBFUN void * XMLCALL
|
||||||
xmlIOFTPOpen (const char *filename);
|
xmlIOFTPOpen (const char *filename);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlIOFTPRead (void * context,
|
xmlIOFTPRead (void * context,
|
||||||
char * buffer,
|
char * buffer,
|
||||||
int len);
|
int len);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlIOFTPClose (void * context);
|
xmlIOFTPClose (void * context);
|
||||||
#endif /* LIBXML_FTP_ENABLED */
|
#endif /* LIBXML_FTP_ENABLED */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -62,7 +62,9 @@ typedef enum {
|
||||||
XML_FROM_WRITER, /* The xmlwriter module */
|
XML_FROM_WRITER, /* The xmlwriter module */
|
||||||
XML_FROM_MODULE, /* The dynamically loaded module module*/
|
XML_FROM_MODULE, /* The dynamically loaded module module*/
|
||||||
XML_FROM_I18N, /* The module handling character conversion */
|
XML_FROM_I18N, /* The module handling character conversion */
|
||||||
XML_FROM_SCHEMATRONV /* The Schematron validator module */
|
XML_FROM_SCHEMATRONV,/* The Schematron validator module */
|
||||||
|
XML_FROM_BUFFER, /* The buffers module */
|
||||||
|
XML_FROM_URI /* The URI module */
|
||||||
} xmlErrorDomain;
|
} xmlErrorDomain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -205,6 +207,7 @@ typedef enum {
|
||||||
XML_WAR_ENTITY_REDEFINED, /* 107 */
|
XML_WAR_ENTITY_REDEFINED, /* 107 */
|
||||||
XML_ERR_UNKNOWN_VERSION, /* 108 */
|
XML_ERR_UNKNOWN_VERSION, /* 108 */
|
||||||
XML_ERR_VERSION_MISMATCH, /* 109 */
|
XML_ERR_VERSION_MISMATCH, /* 109 */
|
||||||
|
XML_ERR_NAME_TOO_LONG, /* 110 */
|
||||||
XML_NS_ERR_XML_NAMESPACE = 200,
|
XML_NS_ERR_XML_NAMESPACE = 200,
|
||||||
XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */
|
XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */
|
||||||
XML_NS_ERR_QNAME, /* 202 */
|
XML_NS_ERR_QNAME, /* 202 */
|
||||||
|
@ -825,11 +828,8 @@ typedef enum {
|
||||||
XML_I18N_NO_HANDLER, /* 6001 */
|
XML_I18N_NO_HANDLER, /* 6001 */
|
||||||
XML_I18N_EXCESS_HANDLER, /* 6002 */
|
XML_I18N_EXCESS_HANDLER, /* 6002 */
|
||||||
XML_I18N_CONV_FAILED, /* 6003 */
|
XML_I18N_CONV_FAILED, /* 6003 */
|
||||||
XML_I18N_NO_OUTPUT /* 6004 */
|
XML_I18N_NO_OUTPUT, /* 6004 */
|
||||||
#if 0
|
XML_BUF_OVERFLOW = 7000
|
||||||
XML_CHECK_, /* 5033 */
|
|
||||||
XML_CHECK_X /* 503 */
|
|
||||||
#endif
|
|
||||||
} xmlParserErrors;
|
} xmlParserErrors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -115,7 +115,7 @@
|
||||||
*/
|
*/
|
||||||
#if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
|
#if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
|
||||||
#define XMLPUBFUN __declspec(dllexport)
|
#define XMLPUBFUN __declspec(dllexport)
|
||||||
#define XMLPUBVAR __declspec(dllexport)
|
#define XMLPUBVAR __declspec(dllexport) extern
|
||||||
#else
|
#else
|
||||||
#define XMLPUBFUN
|
#define XMLPUBFUN
|
||||||
#if !defined(LIBXML_STATIC)
|
#if !defined(LIBXML_STATIC)
|
||||||
|
|
|
@ -130,16 +130,16 @@ XMLPUBFUN int XMLCALL
|
||||||
|
|
||||||
#ifdef LIBXML_WRITER_ENABLED
|
#ifdef LIBXML_WRITER_ENABLED
|
||||||
XMLPUBFUN xmlChar * XMLCALL
|
XMLPUBFUN xmlChar * XMLCALL
|
||||||
xmlTextReaderReadInnerXml (xmlTextReaderPtr reader);
|
xmlTextReaderReadInnerXml(xmlTextReaderPtr reader);
|
||||||
|
|
||||||
XMLPUBFUN xmlChar * XMLCALL
|
XMLPUBFUN xmlChar * XMLCALL
|
||||||
xmlTextReaderReadOuterXml (xmlTextReaderPtr reader);
|
xmlTextReaderReadOuterXml(xmlTextReaderPtr reader);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XMLPUBFUN xmlChar * XMLCALL
|
XMLPUBFUN xmlChar * XMLCALL
|
||||||
xmlTextReaderReadString (xmlTextReaderPtr reader);
|
xmlTextReaderReadString (xmlTextReaderPtr reader);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlTextReaderReadAttributeValue (xmlTextReaderPtr reader);
|
xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attributes of the node
|
* Attributes of the node
|
||||||
|
@ -284,6 +284,11 @@ XMLPUBFUN int XMLCALL
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader,
|
xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader,
|
||||||
const char *rng);
|
const char *rng);
|
||||||
|
XMLPUBFUN int XMLCALL
|
||||||
|
xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader,
|
||||||
|
xmlRelaxNGValidCtxtPtr ctxt,
|
||||||
|
int options);
|
||||||
|
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,
|
xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,
|
||||||
xmlRelaxNGPtr schema);
|
xmlRelaxNGPtr schema);
|
||||||
|
@ -392,27 +397,26 @@ typedef void * xmlTextReaderLocatorPtr;
|
||||||
*
|
*
|
||||||
* Signature of an error callback from a reader parser
|
* Signature of an error callback from a reader parser
|
||||||
*/
|
*/
|
||||||
typedef void (XMLCALL *xmlTextReaderErrorFunc)(void *arg,
|
typedef void (XMLCALL *xmlTextReaderErrorFunc)(void *arg,
|
||||||
const char *msg,
|
const char *msg,
|
||||||
xmlParserSeverities severity,
|
xmlParserSeverities severity,
|
||||||
xmlTextReaderLocatorPtr locator);
|
xmlTextReaderLocatorPtr locator);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator);
|
xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator);
|
||||||
/*int xmlTextReaderLocatorLinePosition(xmlTextReaderLocatorPtr locator);*/
|
|
||||||
XMLPUBFUN xmlChar * XMLCALL
|
XMLPUBFUN xmlChar * XMLCALL
|
||||||
xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator);
|
xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator);
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
|
xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
|
||||||
xmlTextReaderErrorFunc f,
|
xmlTextReaderErrorFunc f,
|
||||||
void *arg);
|
void *arg);
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
|
xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
|
||||||
xmlStructuredErrorFunc f,
|
xmlStructuredErrorFunc f,
|
||||||
void *arg);
|
void *arg);
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
|
xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
|
||||||
xmlTextReaderErrorFunc *f,
|
xmlTextReaderErrorFunc *f,
|
||||||
void **arg);
|
void **arg);
|
||||||
|
|
||||||
#endif /* LIBXML_READER_ENABLED */
|
#endif /* LIBXML_READER_ENABLED */
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,8 @@ typedef xmlSchema *xmlSchemaPtr;
|
||||||
*
|
*
|
||||||
* Signature of an error callback from an XSD validation
|
* Signature of an error callback from an XSD validation
|
||||||
*/
|
*/
|
||||||
typedef void (XMLCDECL *xmlSchemaValidityErrorFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
|
typedef void (XMLCDECL *xmlSchemaValidityErrorFunc)
|
||||||
|
(void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlSchemaValidityWarningFunc:
|
* xmlSchemaValidityWarningFunc:
|
||||||
|
@ -102,7 +103,8 @@ typedef void (XMLCDECL *xmlSchemaValidityErrorFunc) (void *ctx, const char *msg,
|
||||||
*
|
*
|
||||||
* Signature of a warning callback from an XSD validation
|
* Signature of a warning callback from an XSD validation
|
||||||
*/
|
*/
|
||||||
typedef void (XMLCDECL *xmlSchemaValidityWarningFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
|
typedef void (XMLCDECL *xmlSchemaValidityWarningFunc)
|
||||||
|
(void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A schemas validation context
|
* A schemas validation context
|
||||||
|
@ -113,6 +115,22 @@ typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;
|
||||||
typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;
|
typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;
|
||||||
typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
|
typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlSchemaValidityLocatorFunc:
|
||||||
|
* @ctx: user provided context
|
||||||
|
* @file: returned file information
|
||||||
|
* @line: returned line information
|
||||||
|
*
|
||||||
|
* A schemas validation locator, a callback called by the validator.
|
||||||
|
* This is used when file or node informations are not available
|
||||||
|
* to find out what file and line number are affected
|
||||||
|
*
|
||||||
|
* Returns: 0 in case of success and -1 in case of error
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef int (XMLCDECL *xmlSchemaValidityLocatorFunc) (void *ctx,
|
||||||
|
const char **file, unsigned long *line);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Interfaces for parsing.
|
* Interfaces for parsing.
|
||||||
*/
|
*/
|
||||||
|
@ -171,6 +189,9 @@ XMLPUBFUN int XMLCALL
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt,
|
xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt,
|
||||||
int options);
|
int options);
|
||||||
|
XMLPUBFUN void XMLCALL
|
||||||
|
xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt,
|
||||||
|
const char *filename);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
|
xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
|
||||||
|
|
||||||
|
@ -210,6 +231,13 @@ XMLPUBFUN xmlSchemaSAXPlugPtr XMLCALL
|
||||||
void **user_data);
|
void **user_data);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug);
|
xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug);
|
||||||
|
|
||||||
|
|
||||||
|
XMLPUBFUN void XMLCALL
|
||||||
|
xmlSchemaValidateSetLocator (xmlSchemaValidCtxtPtr vctxt,
|
||||||
|
xmlSchemaValidityLocatorFunc f,
|
||||||
|
void *ctxt);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,7 +31,7 @@ typedef enum {
|
||||||
} xmlSchemaWhitespaceValueType;
|
} xmlSchemaWhitespaceValueType;
|
||||||
|
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlSchemaInitTypes (void);
|
xmlSchemaInitTypes (void);
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlSchemaCleanupTypes (void);
|
xmlSchemaCleanupTypes (void);
|
||||||
XMLPUBFUN xmlSchemaTypePtr XMLCALL
|
XMLPUBFUN xmlSchemaTypePtr XMLCALL
|
||||||
|
|
|
@ -29,28 +29,28 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
|
||||||
*
|
*
|
||||||
* the version string like "1.2.3"
|
* the version string like "1.2.3"
|
||||||
*/
|
*/
|
||||||
#define LIBXML_DOTTED_VERSION "2.7.8"
|
#define LIBXML_DOTTED_VERSION "2.9.0"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LIBXML_VERSION:
|
* LIBXML_VERSION:
|
||||||
*
|
*
|
||||||
* the version number: 1.2.3 value is 10203
|
* the version number: 1.2.3 value is 10203
|
||||||
*/
|
*/
|
||||||
#define LIBXML_VERSION 20708
|
#define LIBXML_VERSION 20900
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LIBXML_VERSION_STRING:
|
* LIBXML_VERSION_STRING:
|
||||||
*
|
*
|
||||||
* the version number string, 1.2.3 value is "10203"
|
* the version number string, 1.2.3 value is "10203"
|
||||||
*/
|
*/
|
||||||
#define LIBXML_VERSION_STRING "20708"
|
#define LIBXML_VERSION_STRING "20900"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LIBXML_VERSION_EXTRA:
|
* LIBXML_VERSION_EXTRA:
|
||||||
*
|
*
|
||||||
* extra version information, used to show a CVS compilation
|
* extra version information, used to show a CVS compilation
|
||||||
*/
|
*/
|
||||||
#define LIBXML_VERSION_EXTRA "-GITv2.7.7-40-g82143f4"
|
#define LIBXML_VERSION_EXTRA "-GITv2.9.0-rc2-5-g7651606"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LIBXML_TEST_VERSION:
|
* LIBXML_TEST_VERSION:
|
||||||
|
@ -58,7 +58,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
|
||||||
* Macro to check that the libxml version in use is compatible with
|
* Macro to check that the libxml version in use is compatible with
|
||||||
* the version the software has been compiled against
|
* the version the software has been compiled against
|
||||||
*/
|
*/
|
||||||
#define LIBXML_TEST_VERSION xmlCheckVersion(20708);
|
#define LIBXML_TEST_VERSION xmlCheckVersion(20900);
|
||||||
|
|
||||||
#ifndef VMS
|
#ifndef VMS
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -379,7 +379,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
|
||||||
*
|
*
|
||||||
* the string suffix used by dynamic modules (usually shared libraries)
|
* the string suffix used by dynamic modules (usually shared libraries)
|
||||||
*/
|
*/
|
||||||
#define LIBXML_MODULE_EXTENSION ".so"
|
#define LIBXML_MODULE_EXTENSION ".so"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -391,6 +391,15 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
|
||||||
#define LIBXML_ZLIB_ENABLED
|
#define LIBXML_ZLIB_ENABLED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_LZMA_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the Lzma support is compiled in
|
||||||
|
*/
|
||||||
|
#if 0
|
||||||
|
#define LIBXML_LZMA_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#ifdef HAVE_ANSIDECL_H
|
#ifdef HAVE_ANSIDECL_H
|
||||||
#include <ansidecl.h>
|
#include <ansidecl.h>
|
||||||
|
@ -403,7 +412,11 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ATTRIBUTE_UNUSED
|
#ifndef ATTRIBUTE_UNUSED
|
||||||
#define ATTRIBUTE_UNUSED __attribute__((unused))
|
# if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
|
||||||
|
# define ATTRIBUTE_UNUSED __attribute__((unused))
|
||||||
|
# else
|
||||||
|
# define ATTRIBUTE_UNUSED
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -379,7 +379,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
|
||||||
*
|
*
|
||||||
* the string suffix used by dynamic modules (usually shared libraries)
|
* the string suffix used by dynamic modules (usually shared libraries)
|
||||||
*/
|
*/
|
||||||
#define LIBXML_MODULE_EXTENSION "@MODULE_EXTENSION@"
|
#define LIBXML_MODULE_EXTENSION "@MODULE_EXTENSION@"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -391,6 +391,15 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
|
||||||
#define LIBXML_ZLIB_ENABLED
|
#define LIBXML_ZLIB_ENABLED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LIBXML_LZMA_ENABLED:
|
||||||
|
*
|
||||||
|
* Whether the Lzma support is compiled in
|
||||||
|
*/
|
||||||
|
#if @WITH_LZMA@
|
||||||
|
#define LIBXML_LZMA_ENABLED
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#ifdef HAVE_ANSIDECL_H
|
#ifdef HAVE_ANSIDECL_H
|
||||||
#include <ansidecl.h>
|
#include <ansidecl.h>
|
||||||
|
@ -403,7 +412,11 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ATTRIBUTE_UNUSED
|
#ifndef ATTRIBUTE_UNUSED
|
||||||
#define ATTRIBUTE_UNUSED __attribute__((unused))
|
# if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
|
||||||
|
# define ATTRIBUTE_UNUSED __attribute__((unused))
|
||||||
|
# else
|
||||||
|
# define ATTRIBUTE_UNUSED
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Summary: text writing API for XML
|
* Summary: text writing API for XML
|
||||||
* Description: text writing API for XML
|
* Description: text writing API for XML
|
||||||
|
@ -471,6 +470,10 @@ extern "C" {
|
||||||
xmlTextWriterSetIndentString(xmlTextWriterPtr writer,
|
xmlTextWriterSetIndentString(xmlTextWriterPtr writer,
|
||||||
const xmlChar * str);
|
const xmlChar * str);
|
||||||
|
|
||||||
|
XMLPUBFUN int XMLCALL
|
||||||
|
xmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* misc
|
* misc
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -68,7 +68,9 @@ typedef enum {
|
||||||
XPATH_UNDEF_PREFIX_ERROR,
|
XPATH_UNDEF_PREFIX_ERROR,
|
||||||
XPATH_ENCODING_ERROR,
|
XPATH_ENCODING_ERROR,
|
||||||
XPATH_INVALID_CHAR_ERROR,
|
XPATH_INVALID_CHAR_ERROR,
|
||||||
XPATH_INVALID_CTXT
|
XPATH_INVALID_CTXT,
|
||||||
|
XPATH_STACK_ERROR,
|
||||||
|
XPATH_FORBID_VARIABLE_ERROR
|
||||||
} xmlXPathError;
|
} xmlXPathError;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -380,6 +382,8 @@ struct _xmlXPathParserContext {
|
||||||
xmlXPathCompExprPtr comp; /* the precompiled expression */
|
xmlXPathCompExprPtr comp; /* the precompiled expression */
|
||||||
int xptr; /* it this an XPointer expression */
|
int xptr; /* it this an XPointer expression */
|
||||||
xmlNodePtr ancestor; /* used for walking preceding axis */
|
xmlNodePtr ancestor; /* used for walking preceding axis */
|
||||||
|
|
||||||
|
int valueFrame; /* used to limit Pop on the stack */
|
||||||
};
|
};
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
@ -417,7 +421,7 @@ XMLPUBVAR double xmlXPathNINF;
|
||||||
* @index is out of range (0 to length-1)
|
* @index is out of range (0 to length-1)
|
||||||
*/
|
*/
|
||||||
#define xmlXPathNodeSetItem(ns, index) \
|
#define xmlXPathNodeSetItem(ns, index) \
|
||||||
((((ns) != NULL) && \
|
((((ns) != NULL) && \
|
||||||
((index) >= 0) && ((index) < (ns)->nodeNr)) ? \
|
((index) >= 0) && ((index) < (ns)->nodeNr)) ? \
|
||||||
(ns)->nodeTab[(index)] \
|
(ns)->nodeTab[(index)] \
|
||||||
: NULL)
|
: NULL)
|
||||||
|
@ -520,7 +524,7 @@ XMLPUBFUN xmlXPathCompExprPtr XMLCALL
|
||||||
xmlXPathCompile (const xmlChar *str);
|
xmlXPathCompile (const xmlChar *str);
|
||||||
XMLPUBFUN xmlXPathCompExprPtr XMLCALL
|
XMLPUBFUN xmlXPathCompExprPtr XMLCALL
|
||||||
xmlXPathCtxtCompile (xmlXPathContextPtr ctxt,
|
xmlXPathCtxtCompile (xmlXPathContextPtr ctxt,
|
||||||
const xmlChar *str);
|
const xmlChar *str);
|
||||||
XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
||||||
xmlXPathCompiledEval (xmlXPathCompExprPtr comp,
|
xmlXPathCompiledEval (xmlXPathCompExprPtr comp,
|
||||||
xmlXPathContextPtr ctx);
|
xmlXPathContextPtr ctx);
|
||||||
|
|
|
@ -103,13 +103,13 @@ extern "C" {
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt);
|
xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt);
|
||||||
XMLPUBFUN double XMLCALL
|
XMLPUBFUN double XMLCALL
|
||||||
xmlXPathPopNumber (xmlXPathParserContextPtr ctxt);
|
xmlXPathPopNumber (xmlXPathParserContextPtr ctxt);
|
||||||
XMLPUBFUN xmlChar * XMLCALL
|
XMLPUBFUN xmlChar * XMLCALL
|
||||||
xmlXPathPopString (xmlXPathParserContextPtr ctxt);
|
xmlXPathPopString (xmlXPathParserContextPtr ctxt);
|
||||||
XMLPUBFUN xmlNodeSetPtr XMLCALL
|
XMLPUBFUN xmlNodeSetPtr XMLCALL
|
||||||
xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt);
|
xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt);
|
||||||
XMLPUBFUN void * XMLCALL
|
XMLPUBFUN void * XMLCALL
|
||||||
xmlXPathPopExternal (xmlXPathParserContextPtr ctxt);
|
xmlXPathPopExternal (xmlXPathParserContextPtr ctxt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlXPathReturnBoolean:
|
* xmlXPathReturnBoolean:
|
||||||
|
@ -296,7 +296,9 @@ XMLPUBFUN void * XMLCALL
|
||||||
#define CHECK_ARITY(x) \
|
#define CHECK_ARITY(x) \
|
||||||
if (ctxt == NULL) return; \
|
if (ctxt == NULL) return; \
|
||||||
if (nargs != (x)) \
|
if (nargs != (x)) \
|
||||||
XP_ERROR(XPATH_INVALID_ARITY);
|
XP_ERROR(XPATH_INVALID_ARITY); \
|
||||||
|
if (ctxt->valueNr < ctxt->valueFrame + (x)) \
|
||||||
|
XP_ERROR(XPATH_STACK_ERROR);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CAST_TO_STRING:
|
* CAST_TO_STRING:
|
||||||
|
@ -471,7 +473,7 @@ XMLPUBFUN void XMLCALL
|
||||||
*/
|
*/
|
||||||
XMLPUBFUN xmlXPathParserContextPtr XMLCALL
|
XMLPUBFUN xmlXPathParserContextPtr XMLCALL
|
||||||
xmlXPathNewParserContext (const xmlChar *str,
|
xmlXPathNewParserContext (const xmlChar *str,
|
||||||
xmlXPathContextPtr ctxt);
|
xmlXPathContextPtr ctxt);
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt);
|
xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt);
|
||||||
|
|
||||||
|
@ -480,7 +482,7 @@ XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
||||||
valuePop (xmlXPathParserContextPtr ctxt);
|
valuePop (xmlXPathParserContextPtr ctxt);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
valuePush (xmlXPathParserContextPtr ctxt,
|
valuePush (xmlXPathParserContextPtr ctxt,
|
||||||
xmlXPathObjectPtr value);
|
xmlXPathObjectPtr value);
|
||||||
|
|
||||||
XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
||||||
xmlXPathNewString (const xmlChar *val);
|
xmlXPathNewString (const xmlChar *val);
|
||||||
|
@ -498,13 +500,13 @@ XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
||||||
xmlXPathNewNodeSet (xmlNodePtr val);
|
xmlXPathNewNodeSet (xmlNodePtr val);
|
||||||
XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
||||||
xmlXPathNewValueTree (xmlNodePtr val);
|
xmlXPathNewValueTree (xmlNodePtr val);
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
|
xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
|
||||||
xmlNodePtr val);
|
xmlNodePtr val);
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur,
|
xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur,
|
||||||
xmlNodePtr val);
|
xmlNodePtr val);
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlXPathNodeSetAddNs (xmlNodeSetPtr cur,
|
xmlXPathNodeSetAddNs (xmlNodeSetPtr cur,
|
||||||
xmlNodePtr node,
|
xmlNodePtr node,
|
||||||
xmlNsPtr ns);
|
xmlNsPtr ns);
|
||||||
|
|
|
@ -101,7 +101,7 @@ XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
||||||
xmlXPathContextPtr ctx);
|
xmlXPathContextPtr ctx);
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt,
|
xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt,
|
||||||
int nargs);
|
int nargs);
|
||||||
XMLPUBFUN xmlNodePtr XMLCALL
|
XMLPUBFUN xmlNodePtr XMLCALL
|
||||||
xmlXPtrBuildNodeList (xmlXPathObjectPtr obj);
|
xmlXPtrBuildNodeList (xmlXPathObjectPtr obj);
|
||||||
XMLPUBFUN void XMLCALL
|
XMLPUBFUN void XMLCALL
|
||||||
|
|
1
reactos/lib/3rdparty/libxml2/CMakeLists.txt
vendored
1
reactos/lib/3rdparty/libxml2/CMakeLists.txt
vendored
|
@ -13,6 +13,7 @@ add_definitions(
|
||||||
-D_DLL -D__USE_CRTIMP)
|
-D_DLL -D__USE_CRTIMP)
|
||||||
|
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
|
buf.c
|
||||||
c14n.c
|
c14n.c
|
||||||
catalog.c
|
catalog.c
|
||||||
chvalid.c
|
chvalid.c
|
||||||
|
|
264
reactos/lib/3rdparty/libxml2/HTMLparser.c
vendored
264
reactos/lib/3rdparty/libxml2/HTMLparser.c
vendored
|
@ -44,6 +44,9 @@
|
||||||
#include <libxml/globals.h>
|
#include <libxml/globals.h>
|
||||||
#include <libxml/uri.h>
|
#include <libxml/uri.h>
|
||||||
|
|
||||||
|
#include "buf.h"
|
||||||
|
#include "enc.h"
|
||||||
|
|
||||||
#define HTML_MAX_NAMELEN 1000
|
#define HTML_MAX_NAMELEN 1000
|
||||||
#define HTML_PARSER_BIG_BUFFER_SIZE 1000
|
#define HTML_PARSER_BIG_BUFFER_SIZE 1000
|
||||||
#define HTML_PARSER_BUFFER_SIZE 100
|
#define HTML_PARSER_BUFFER_SIZE 100
|
||||||
|
@ -727,7 +730,7 @@ static const char* const map_contents[] = { BLOCK, "area", NULL } ;
|
||||||
static const char* const name_attr[] = { "name", NULL } ;
|
static const char* const name_attr[] = { "name", NULL } ;
|
||||||
static const char* const action_attr[] = { "action", NULL } ;
|
static const char* const action_attr[] = { "action", NULL } ;
|
||||||
static const char* const blockli_elt[] = { BLOCK, "li", NULL } ;
|
static const char* const blockli_elt[] = { BLOCK, "li", NULL } ;
|
||||||
static const char* const meta_attrs[] = { I18N, "http-equiv", "name", "scheme", NULL } ;
|
static const char* const meta_attrs[] = { I18N, "http-equiv", "name", "scheme", "charset", NULL } ;
|
||||||
static const char* const content_attr[] = { "content", NULL } ;
|
static const char* const content_attr[] = { "content", NULL } ;
|
||||||
static const char* const type_attr[] = { "type", NULL } ;
|
static const char* const type_attr[] = { "type", NULL } ;
|
||||||
static const char* const noframes_content[] = { "body", FLOW MODIFIER, NULL } ;
|
static const char* const noframes_content[] = { "body", FLOW MODIFIER, NULL } ;
|
||||||
|
@ -1080,9 +1083,9 @@ static const char * const htmlStartClose[] = {
|
||||||
"menu", "p", "head", "ul", NULL,
|
"menu", "p", "head", "ul", NULL,
|
||||||
"p", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6", FONTSTYLE, NULL,
|
"p", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6", FONTSTYLE, NULL,
|
||||||
"div", "p", "head", NULL,
|
"div", "p", "head", NULL,
|
||||||
"noscript", "p", "head", NULL,
|
"noscript", "p", NULL,
|
||||||
"center", "font", "b", "i", "p", "head", NULL,
|
"center", "font", "b", "i", "p", "head", NULL,
|
||||||
"a", "a", NULL,
|
"a", "a", "head", NULL,
|
||||||
"caption", "p", NULL,
|
"caption", "p", NULL,
|
||||||
"colgroup", "caption", "colgroup", "col", "p", NULL,
|
"colgroup", "caption", "colgroup", "col", "p", NULL,
|
||||||
"col", "caption", "col", "p", NULL,
|
"col", "caption", "col", "p", NULL,
|
||||||
|
@ -1100,6 +1103,43 @@ static const char * const htmlStartClose[] = {
|
||||||
"option", "option", NULL,
|
"option", "option", NULL,
|
||||||
"fieldset", "legend", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6",
|
"fieldset", "legend", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6",
|
||||||
"pre", "listing", "xmp", "a", NULL,
|
"pre", "listing", "xmp", "a", NULL,
|
||||||
|
/* most tags in in FONTSTYLE, PHRASE and SPECIAL should close <head> */
|
||||||
|
"tt", "head", NULL,
|
||||||
|
"i", "head", NULL,
|
||||||
|
"b", "head", NULL,
|
||||||
|
"u", "head", NULL,
|
||||||
|
"s", "head", NULL,
|
||||||
|
"strike", "head", NULL,
|
||||||
|
"big", "head", NULL,
|
||||||
|
"small", "head", NULL,
|
||||||
|
|
||||||
|
"em", "head", NULL,
|
||||||
|
"strong", "head", NULL,
|
||||||
|
"dfn", "head", NULL,
|
||||||
|
"code", "head", NULL,
|
||||||
|
"samp", "head", NULL,
|
||||||
|
"kbd", "head", NULL,
|
||||||
|
"var", "head", NULL,
|
||||||
|
"cite", "head", NULL,
|
||||||
|
"abbr", "head", NULL,
|
||||||
|
"acronym", "head", NULL,
|
||||||
|
|
||||||
|
/* "a" */
|
||||||
|
"img", "head", NULL,
|
||||||
|
/* "applet" */
|
||||||
|
/* "embed" */
|
||||||
|
/* "object" */
|
||||||
|
"font", "head", NULL,
|
||||||
|
/* "basefont" */
|
||||||
|
"br", "head", NULL,
|
||||||
|
/* "script" */
|
||||||
|
"map", "head", NULL,
|
||||||
|
"q", "head", NULL,
|
||||||
|
"sub", "head", NULL,
|
||||||
|
"sup", "head", NULL,
|
||||||
|
"span", "head", NULL,
|
||||||
|
"bdo", "head", NULL,
|
||||||
|
"iframe", "head", NULL,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2941,9 +2981,14 @@ htmlParseCharData(htmlParserCtxtPtr ctxt) {
|
||||||
*/
|
*/
|
||||||
if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
|
if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
|
||||||
if (areBlanks(ctxt, buf, nbchar)) {
|
if (areBlanks(ctxt, buf, nbchar)) {
|
||||||
if (ctxt->sax->ignorableWhitespace != NULL)
|
if (ctxt->keepBlanks) {
|
||||||
ctxt->sax->ignorableWhitespace(ctxt->userData,
|
if (ctxt->sax->characters != NULL)
|
||||||
buf, nbchar);
|
ctxt->sax->characters(ctxt->userData, buf, nbchar);
|
||||||
|
} else {
|
||||||
|
if (ctxt->sax->ignorableWhitespace != NULL)
|
||||||
|
ctxt->sax->ignorableWhitespace(ctxt->userData,
|
||||||
|
buf, nbchar);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
htmlCheckParagraph(ctxt);
|
htmlCheckParagraph(ctxt);
|
||||||
if (ctxt->sax->characters != NULL)
|
if (ctxt->sax->characters != NULL)
|
||||||
|
@ -2974,8 +3019,14 @@ htmlParseCharData(htmlParserCtxtPtr ctxt) {
|
||||||
*/
|
*/
|
||||||
if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
|
if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
|
||||||
if (areBlanks(ctxt, buf, nbchar)) {
|
if (areBlanks(ctxt, buf, nbchar)) {
|
||||||
if (ctxt->sax->ignorableWhitespace != NULL)
|
if (ctxt->keepBlanks) {
|
||||||
ctxt->sax->ignorableWhitespace(ctxt->userData, buf, nbchar);
|
if (ctxt->sax->characters != NULL)
|
||||||
|
ctxt->sax->characters(ctxt->userData, buf, nbchar);
|
||||||
|
} else {
|
||||||
|
if (ctxt->sax->ignorableWhitespace != NULL)
|
||||||
|
ctxt->sax->ignorableWhitespace(ctxt->userData,
|
||||||
|
buf, nbchar);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
htmlCheckParagraph(ctxt);
|
htmlCheckParagraph(ctxt);
|
||||||
if (ctxt->sax->characters != NULL)
|
if (ctxt->sax->characters != NULL)
|
||||||
|
@ -3435,34 +3486,26 @@ htmlParseAttribute(htmlParserCtxtPtr ctxt, xmlChar **value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* htmlCheckEncoding:
|
* htmlCheckEncodingDirect:
|
||||||
* @ctxt: an HTML parser context
|
* @ctxt: an HTML parser context
|
||||||
* @attvalue: the attribute value
|
* @attvalue: the attribute value
|
||||||
*
|
*
|
||||||
* Checks an http-equiv attribute from a Meta tag to detect
|
* Checks an attribute value to detect
|
||||||
* the encoding
|
* the encoding
|
||||||
* If a new encoding is detected the parser is switched to decode
|
* If a new encoding is detected the parser is switched to decode
|
||||||
* it and pass UTF8
|
* it and pass UTF8
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
|
htmlCheckEncodingDirect(htmlParserCtxtPtr ctxt, const xmlChar *encoding) {
|
||||||
const xmlChar *encoding;
|
|
||||||
|
|
||||||
if ((ctxt == NULL) || (attvalue == NULL))
|
if ((ctxt == NULL) || (encoding == NULL) ||
|
||||||
|
(ctxt->options & HTML_PARSE_IGNORE_ENC))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* do not change encoding */
|
/* do not change encoding */
|
||||||
if (ctxt->input->encoding != NULL)
|
if (ctxt->input->encoding != NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
encoding = xmlStrcasestr(attvalue, BAD_CAST"charset=");
|
|
||||||
if (encoding != NULL) {
|
|
||||||
encoding += 8;
|
|
||||||
} else {
|
|
||||||
encoding = xmlStrcasestr(attvalue, BAD_CAST"charset =");
|
|
||||||
if (encoding != NULL)
|
|
||||||
encoding += 9;
|
|
||||||
}
|
|
||||||
if (encoding != NULL) {
|
if (encoding != NULL) {
|
||||||
xmlCharEncoding enc;
|
xmlCharEncoding enc;
|
||||||
xmlCharEncodingHandlerPtr handler;
|
xmlCharEncodingHandlerPtr handler;
|
||||||
|
@ -3500,7 +3543,9 @@ htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
|
||||||
xmlSwitchToEncoding(ctxt, handler);
|
xmlSwitchToEncoding(ctxt, handler);
|
||||||
ctxt->charset = XML_CHAR_ENCODING_UTF8;
|
ctxt->charset = XML_CHAR_ENCODING_UTF8;
|
||||||
} else {
|
} else {
|
||||||
ctxt->errNo = XML_ERR_UNSUPPORTED_ENCODING;
|
htmlParseErr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
|
||||||
|
"htmlCheckEncoding: unknown encoding %s\n",
|
||||||
|
encoding, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3515,23 +3560,50 @@ htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
|
||||||
* convert as much as possible to the parser reading buffer.
|
* convert as much as possible to the parser reading buffer.
|
||||||
*/
|
*/
|
||||||
processed = ctxt->input->cur - ctxt->input->base;
|
processed = ctxt->input->cur - ctxt->input->base;
|
||||||
xmlBufferShrink(ctxt->input->buf->buffer, processed);
|
xmlBufShrink(ctxt->input->buf->buffer, processed);
|
||||||
nbchars = xmlCharEncInFunc(ctxt->input->buf->encoder,
|
nbchars = xmlCharEncInput(ctxt->input->buf);
|
||||||
ctxt->input->buf->buffer,
|
|
||||||
ctxt->input->buf->raw);
|
|
||||||
if (nbchars < 0) {
|
if (nbchars < 0) {
|
||||||
htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
|
htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
|
||||||
"htmlCheckEncoding: encoder error\n",
|
"htmlCheckEncoding: encoder error\n",
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
ctxt->input->base =
|
xmlBufResetInput(ctxt->input->buf->buffer, ctxt->input);
|
||||||
ctxt->input->cur = ctxt->input->buf->buffer->content;
|
|
||||||
ctxt->input->end =
|
|
||||||
&ctxt->input->base[ctxt->input->buf->buffer->use];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* htmlCheckEncoding:
|
||||||
|
* @ctxt: an HTML parser context
|
||||||
|
* @attvalue: the attribute value
|
||||||
|
*
|
||||||
|
* Checks an http-equiv attribute from a Meta tag to detect
|
||||||
|
* the encoding
|
||||||
|
* If a new encoding is detected the parser is switched to decode
|
||||||
|
* it and pass UTF8
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
|
||||||
|
const xmlChar *encoding;
|
||||||
|
|
||||||
|
if (!attvalue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
encoding = xmlStrcasestr(attvalue, BAD_CAST"charset");
|
||||||
|
if (encoding != NULL) {
|
||||||
|
encoding += 7;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* skip blank
|
||||||
|
*/
|
||||||
|
if (encoding && IS_BLANK_CH(*encoding))
|
||||||
|
encoding = xmlStrcasestr(attvalue, BAD_CAST"=");
|
||||||
|
if (encoding && *encoding == '=') {
|
||||||
|
encoding ++;
|
||||||
|
htmlCheckEncodingDirect(ctxt, encoding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* htmlCheckMeta:
|
* htmlCheckMeta:
|
||||||
* @ctxt: an HTML parser context
|
* @ctxt: an HTML parser context
|
||||||
|
@ -3556,6 +3628,8 @@ htmlCheckMeta(htmlParserCtxtPtr ctxt, const xmlChar **atts) {
|
||||||
if ((value != NULL) && (!xmlStrcasecmp(att, BAD_CAST"http-equiv"))
|
if ((value != NULL) && (!xmlStrcasecmp(att, BAD_CAST"http-equiv"))
|
||||||
&& (!xmlStrcasecmp(value, BAD_CAST"Content-Type")))
|
&& (!xmlStrcasecmp(value, BAD_CAST"Content-Type")))
|
||||||
http = 1;
|
http = 1;
|
||||||
|
else if ((value != NULL) && (!xmlStrcasecmp(att, BAD_CAST"charset")))
|
||||||
|
htmlCheckEncodingDirect(ctxt, value);
|
||||||
else if ((value != NULL) && (!xmlStrcasecmp(att, BAD_CAST"content")))
|
else if ((value != NULL) && (!xmlStrcasecmp(att, BAD_CAST"content")))
|
||||||
content = value;
|
content = value;
|
||||||
att = atts[i++];
|
att = atts[i++];
|
||||||
|
@ -3885,6 +3959,7 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt)
|
||||||
if ((oldname != NULL) && (xmlStrEqual(oldname, name))) {
|
if ((oldname != NULL) && (xmlStrEqual(oldname, name))) {
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
|
if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
|
||||||
ctxt->sax->endElement(ctxt->userData, name);
|
ctxt->sax->endElement(ctxt->userData, name);
|
||||||
|
htmlNodeInfoPop(ctxt);
|
||||||
htmlnamePop(ctxt);
|
htmlnamePop(ctxt);
|
||||||
ret = 1;
|
ret = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -4877,9 +4952,7 @@ htmlCreateMemoryParserCtxt(const char *buffer, int size) {
|
||||||
|
|
||||||
input->filename = NULL;
|
input->filename = NULL;
|
||||||
input->buf = buf;
|
input->buf = buf;
|
||||||
input->base = input->buf->buffer->content;
|
xmlBufResetInput(buf->buffer, input);
|
||||||
input->cur = input->buf->buffer->content;
|
|
||||||
input->end = &input->buf->buffer->content[input->buf->buffer->use];
|
|
||||||
|
|
||||||
inputPush(ctxt, input);
|
inputPush(ctxt, input);
|
||||||
return(ctxt);
|
return(ctxt);
|
||||||
|
@ -4996,8 +5069,8 @@ htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
|
||||||
buf = in->base;
|
buf = in->base;
|
||||||
len = in->length;
|
len = in->length;
|
||||||
} else {
|
} else {
|
||||||
buf = in->buf->buffer->content;
|
buf = xmlBufContent(in->buf->buffer);
|
||||||
len = in->buf->buffer->use;
|
len = xmlBufUse(in->buf->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* take into account the sequence length */
|
/* take into account the sequence length */
|
||||||
|
@ -5123,8 +5196,8 @@ htmlParseLookupChars(htmlParserCtxtPtr ctxt, const xmlChar * stop,
|
||||||
buf = in->base;
|
buf = in->base;
|
||||||
len = in->length;
|
len = in->length;
|
||||||
} else {
|
} else {
|
||||||
buf = in->buf->buffer->content;
|
buf = xmlBufContent(in->buf->buffer);
|
||||||
len = in->buf->buffer->use;
|
len = xmlBufUse(in->buf->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; base < len; base++) {
|
for (; base < len; base++) {
|
||||||
|
@ -5173,6 +5246,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||||
int avail = 0;
|
int avail = 0;
|
||||||
xmlChar cur, next;
|
xmlChar cur, next;
|
||||||
|
|
||||||
|
htmlParserNodeInfo node_info;
|
||||||
|
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
switch (ctxt->instate) {
|
switch (ctxt->instate) {
|
||||||
case XML_PARSER_EOF:
|
case XML_PARSER_EOF:
|
||||||
|
@ -5233,7 +5308,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||||
if (in->buf == NULL)
|
if (in->buf == NULL)
|
||||||
avail = in->length - (in->cur - in->base);
|
avail = in->length - (in->cur - in->base);
|
||||||
else
|
else
|
||||||
avail = in->buf->buffer->use - (in->cur - in->base);
|
avail = xmlBufUse(in->buf->buffer) - (in->cur - in->base);
|
||||||
if ((avail == 0) && (terminate)) {
|
if ((avail == 0) && (terminate)) {
|
||||||
htmlAutoCloseOnEnd(ctxt);
|
htmlAutoCloseOnEnd(ctxt);
|
||||||
if ((ctxt->nameNr == 0) && (ctxt->instate != XML_PARSER_EOF)) {
|
if ((ctxt->nameNr == 0) && (ctxt->instate != XML_PARSER_EOF)) {
|
||||||
|
@ -5269,7 +5344,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||||
if (in->buf == NULL)
|
if (in->buf == NULL)
|
||||||
avail = in->length - (in->cur - in->base);
|
avail = in->length - (in->cur - in->base);
|
||||||
else
|
else
|
||||||
avail = in->buf->buffer->use - (in->cur - in->base);
|
avail = xmlBufUse(in->buf->buffer) - (in->cur - in->base);
|
||||||
}
|
}
|
||||||
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
|
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
|
||||||
ctxt->sax->setDocumentLocator(ctxt->userData,
|
ctxt->sax->setDocumentLocator(ctxt->userData,
|
||||||
|
@ -5311,11 +5386,24 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||||
if (in->buf == NULL)
|
if (in->buf == NULL)
|
||||||
avail = in->length - (in->cur - in->base);
|
avail = in->length - (in->cur - in->base);
|
||||||
else
|
else
|
||||||
avail = in->buf->buffer->use - (in->cur - in->base);
|
avail = xmlBufUse(in->buf->buffer) - (in->cur - in->base);
|
||||||
if (avail < 2)
|
/*
|
||||||
|
* no chars in buffer
|
||||||
|
*/
|
||||||
|
if (avail < 1)
|
||||||
goto done;
|
goto done;
|
||||||
|
/*
|
||||||
|
* not enouth chars in buffer
|
||||||
|
*/
|
||||||
|
if (avail < 2) {
|
||||||
|
if (!terminate)
|
||||||
|
goto done;
|
||||||
|
else
|
||||||
|
next = ' ';
|
||||||
|
} else {
|
||||||
|
next = in->cur[1];
|
||||||
|
}
|
||||||
cur = in->cur[0];
|
cur = in->cur[0];
|
||||||
next = in->cur[1];
|
|
||||||
if ((cur == '<') && (next == '!') &&
|
if ((cur == '<') && (next == '!') &&
|
||||||
(in->cur[2] == '-') && (in->cur[3] == '-')) {
|
(in->cur[2] == '-') && (in->cur[3] == '-')) {
|
||||||
if ((!terminate) &&
|
if ((!terminate) &&
|
||||||
|
@ -5371,7 +5459,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||||
if (in->buf == NULL)
|
if (in->buf == NULL)
|
||||||
avail = in->length - (in->cur - in->base);
|
avail = in->length - (in->cur - in->base);
|
||||||
else
|
else
|
||||||
avail = in->buf->buffer->use - (in->cur - in->base);
|
avail = xmlBufUse(in->buf->buffer) - (in->cur - in->base);
|
||||||
if (avail < 2)
|
if (avail < 2)
|
||||||
goto done;
|
goto done;
|
||||||
cur = in->cur[0];
|
cur = in->cur[0];
|
||||||
|
@ -5412,7 +5500,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||||
if (in->buf == NULL)
|
if (in->buf == NULL)
|
||||||
avail = in->length - (in->cur - in->base);
|
avail = in->length - (in->cur - in->base);
|
||||||
else
|
else
|
||||||
avail = in->buf->buffer->use - (in->cur - in->base);
|
avail = xmlBufUse(in->buf->buffer) - (in->cur - in->base);
|
||||||
if (avail < 1)
|
if (avail < 1)
|
||||||
goto done;
|
goto done;
|
||||||
cur = in->cur[0];
|
cur = in->cur[0];
|
||||||
|
@ -5465,8 +5553,22 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||||
int failed;
|
int failed;
|
||||||
const htmlElemDesc * info;
|
const htmlElemDesc * info;
|
||||||
|
|
||||||
if (avail < 2)
|
/*
|
||||||
|
* no chars in buffer
|
||||||
|
*/
|
||||||
|
if (avail < 1)
|
||||||
goto done;
|
goto done;
|
||||||
|
/*
|
||||||
|
* not enouth chars in buffer
|
||||||
|
*/
|
||||||
|
if (avail < 2) {
|
||||||
|
if (!terminate)
|
||||||
|
goto done;
|
||||||
|
else
|
||||||
|
next = ' ';
|
||||||
|
} else {
|
||||||
|
next = in->cur[1];
|
||||||
|
}
|
||||||
cur = in->cur[0];
|
cur = in->cur[0];
|
||||||
if (cur != '<') {
|
if (cur != '<') {
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
|
@ -5476,7 +5578,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (in->cur[1] == '/') {
|
if (next == '/') {
|
||||||
ctxt->instate = XML_PARSER_END_TAG;
|
ctxt->instate = XML_PARSER_END_TAG;
|
||||||
ctxt->checkIndex = 0;
|
ctxt->checkIndex = 0;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
|
@ -5489,6 +5591,14 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||||
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
|
(htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
/* Capture start position */
|
||||||
|
if (ctxt->record_info) {
|
||||||
|
node_info.begin_pos = ctxt->input->consumed +
|
||||||
|
(CUR_PTR - ctxt->input->base);
|
||||||
|
node_info.begin_line = ctxt->input->line;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
failed = htmlParseStartTag(ctxt);
|
failed = htmlParseStartTag(ctxt);
|
||||||
name = ctxt->name;
|
name = ctxt->name;
|
||||||
if ((failed == -1) ||
|
if ((failed == -1) ||
|
||||||
|
@ -5538,6 +5648,9 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||||
htmlnamePop(ctxt);
|
htmlnamePop(ctxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctxt->record_info)
|
||||||
|
htmlNodeInfoPush(ctxt, &node_info);
|
||||||
|
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
@ -5554,6 +5667,10 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||||
ctxt->sax->endElement(ctxt->userData, name);
|
ctxt->sax->endElement(ctxt->userData, name);
|
||||||
htmlnamePop(ctxt);
|
htmlnamePop(ctxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctxt->record_info)
|
||||||
|
htmlNodeInfoPush(ctxt, &node_info);
|
||||||
|
|
||||||
ctxt->instate = XML_PARSER_CONTENT;
|
ctxt->instate = XML_PARSER_CONTENT;
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
@ -5581,9 +5698,15 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||||
if ((cur != '<') && (cur != '&')) {
|
if ((cur != '<') && (cur != '&')) {
|
||||||
if (ctxt->sax != NULL) {
|
if (ctxt->sax != NULL) {
|
||||||
if (IS_BLANK_CH(cur)) {
|
if (IS_BLANK_CH(cur)) {
|
||||||
if (ctxt->sax->ignorableWhitespace != NULL)
|
if (ctxt->keepBlanks) {
|
||||||
ctxt->sax->ignorableWhitespace(
|
if (ctxt->sax->characters != NULL)
|
||||||
ctxt->userData, &cur, 1);
|
ctxt->sax->characters(
|
||||||
|
ctxt->userData, &cur, 1);
|
||||||
|
} else {
|
||||||
|
if (ctxt->sax->ignorableWhitespace != NULL)
|
||||||
|
ctxt->sax->ignorableWhitespace(
|
||||||
|
ctxt->userData, &cur, 1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
htmlCheckParagraph(ctxt);
|
htmlCheckParagraph(ctxt);
|
||||||
if (ctxt->sax->characters != NULL)
|
if (ctxt->sax->characters != NULL)
|
||||||
|
@ -5906,8 +6029,8 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
|
||||||
}
|
}
|
||||||
if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
|
if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
|
||||||
(ctxt->input->buf != NULL) && (ctxt->instate != XML_PARSER_EOF)) {
|
(ctxt->input->buf != NULL) && (ctxt->instate != XML_PARSER_EOF)) {
|
||||||
int base = ctxt->input->base - ctxt->input->buf->buffer->content;
|
size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
|
||||||
int cur = ctxt->input->cur - ctxt->input->base;
|
size_t cur = ctxt->input->cur - ctxt->input->base;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
|
res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
|
||||||
|
@ -5916,10 +6039,7 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
|
||||||
ctxt->disableSAX = 1;
|
ctxt->disableSAX = 1;
|
||||||
return (XML_PARSER_EOF);
|
return (XML_PARSER_EOF);
|
||||||
}
|
}
|
||||||
ctxt->input->base = ctxt->input->buf->buffer->content + base;
|
xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
|
||||||
ctxt->input->cur = ctxt->input->base + cur;
|
|
||||||
ctxt->input->end =
|
|
||||||
&ctxt->input->buf->buffer->content[ctxt->input->buf->buffer->use];
|
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size);
|
xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size);
|
||||||
#endif
|
#endif
|
||||||
|
@ -5935,7 +6055,7 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
|
||||||
(in->raw != NULL)) {
|
(in->raw != NULL)) {
|
||||||
int nbchars;
|
int nbchars;
|
||||||
|
|
||||||
nbchars = xmlCharEncInFunc(in->encoder, in->buffer, in->raw);
|
nbchars = xmlCharEncInput(in);
|
||||||
if (nbchars < 0) {
|
if (nbchars < 0) {
|
||||||
htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
|
htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
|
||||||
"encoder error\n", NULL, NULL);
|
"encoder error\n", NULL, NULL);
|
||||||
|
@ -6034,24 +6154,18 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
|
||||||
inputStream->filename = (char *)
|
inputStream->filename = (char *)
|
||||||
xmlCanonicPath((const xmlChar *) filename);
|
xmlCanonicPath((const xmlChar *) filename);
|
||||||
inputStream->buf = buf;
|
inputStream->buf = buf;
|
||||||
inputStream->base = inputStream->buf->buffer->content;
|
xmlBufResetInput(buf->buffer, inputStream);
|
||||||
inputStream->cur = inputStream->buf->buffer->content;
|
|
||||||
inputStream->end =
|
|
||||||
&inputStream->buf->buffer->content[inputStream->buf->buffer->use];
|
|
||||||
|
|
||||||
inputPush(ctxt, inputStream);
|
inputPush(ctxt, inputStream);
|
||||||
|
|
||||||
if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
|
if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
|
||||||
(ctxt->input->buf != NULL)) {
|
(ctxt->input->buf != NULL)) {
|
||||||
int base = ctxt->input->base - ctxt->input->buf->buffer->content;
|
size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
|
||||||
int cur = ctxt->input->cur - ctxt->input->base;
|
size_t cur = ctxt->input->cur - ctxt->input->base;
|
||||||
|
|
||||||
xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
|
xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
|
||||||
|
|
||||||
ctxt->input->base = ctxt->input->buf->buffer->content + base;
|
xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
|
||||||
ctxt->input->cur = ctxt->input->base + cur;
|
|
||||||
ctxt->input->end =
|
|
||||||
&ctxt->input->buf->buffer->content[ctxt->input->buf->buffer->use];
|
|
||||||
#ifdef DEBUG_PUSH
|
#ifdef DEBUG_PUSH
|
||||||
xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size);
|
xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size);
|
||||||
#endif
|
#endif
|
||||||
|
@ -6537,6 +6651,14 @@ htmlCtxtUseOptions(htmlParserCtxtPtr ctxt, int options)
|
||||||
ctxt->options |= HTML_PARSE_NODEFDTD;
|
ctxt->options |= HTML_PARSE_NODEFDTD;
|
||||||
options -= HTML_PARSE_NODEFDTD;
|
options -= HTML_PARSE_NODEFDTD;
|
||||||
}
|
}
|
||||||
|
if (options & HTML_PARSE_IGNORE_ENC) {
|
||||||
|
ctxt->options |= HTML_PARSE_IGNORE_ENC;
|
||||||
|
options -= HTML_PARSE_IGNORE_ENC;
|
||||||
|
}
|
||||||
|
if (options & HTML_PARSE_NOIMPLIED) {
|
||||||
|
ctxt->options |= HTML_PARSE_NOIMPLIED;
|
||||||
|
options -= HTML_PARSE_NOIMPLIED;
|
||||||
|
}
|
||||||
ctxt->dictNames = 0;
|
ctxt->dictNames = 0;
|
||||||
return (options);
|
return (options);
|
||||||
}
|
}
|
||||||
|
@ -6730,8 +6852,11 @@ htmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
|
||||||
|
|
||||||
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
|
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
|
||||||
XML_CHAR_ENCODING_NONE);
|
XML_CHAR_ENCODING_NONE);
|
||||||
if (input == NULL)
|
if (input == NULL) {
|
||||||
|
if (ioclose != NULL)
|
||||||
|
ioclose(ioctx);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
}
|
||||||
ctxt = htmlNewParserCtxt();
|
ctxt = htmlNewParserCtxt();
|
||||||
if (ctxt == NULL) {
|
if (ctxt == NULL) {
|
||||||
xmlFreeParserInputBuffer(input);
|
xmlFreeParserInputBuffer(input);
|
||||||
|
@ -6930,8 +7055,11 @@ htmlCtxtReadIO(htmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
|
||||||
|
|
||||||
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
|
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
|
||||||
XML_CHAR_ENCODING_NONE);
|
XML_CHAR_ENCODING_NONE);
|
||||||
if (input == NULL)
|
if (input == NULL) {
|
||||||
|
if (ioclose != NULL)
|
||||||
|
ioclose(ioctx);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
}
|
||||||
stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);
|
stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);
|
||||||
if (stream == NULL) {
|
if (stream == NULL) {
|
||||||
xmlFreeParserInputBuffer(input);
|
xmlFreeParserInputBuffer(input);
|
||||||
|
|
98
reactos/lib/3rdparty/libxml2/HTMLtree.c
vendored
98
reactos/lib/3rdparty/libxml2/HTMLtree.c
vendored
|
@ -30,6 +30,8 @@
|
||||||
#include <libxml/globals.h>
|
#include <libxml/globals.h>
|
||||||
#include <libxml/uri.h>
|
#include <libxml/uri.h>
|
||||||
|
|
||||||
|
#include "buf.h"
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* Getting/Setting encoding meta tags *
|
* Getting/Setting encoding meta tags *
|
||||||
|
@ -164,6 +166,7 @@ htmlSetMetaEncoding(htmlDocPtr doc, const xmlChar *encoding) {
|
||||||
const xmlChar *content = NULL;
|
const xmlChar *content = NULL;
|
||||||
char newcontent[100];
|
char newcontent[100];
|
||||||
|
|
||||||
|
newcontent[0] = 0;
|
||||||
|
|
||||||
if (doc == NULL)
|
if (doc == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
|
@ -278,8 +281,13 @@ create:
|
||||||
xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent);
|
xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
/* remove the meta tag if NULL is passed */
|
||||||
|
if (encoding == NULL) {
|
||||||
|
xmlUnlinkNode(meta);
|
||||||
|
xmlFreeNode(meta);
|
||||||
|
}
|
||||||
/* change the document only if there is a real encoding change */
|
/* change the document only if there is a real encoding change */
|
||||||
if (xmlStrcasestr(content, encoding) == NULL) {
|
else if (xmlStrcasestr(content, encoding) == NULL) {
|
||||||
xmlSetProp(meta, BAD_CAST"content", BAD_CAST newcontent);
|
xmlSetProp(meta, BAD_CAST"content", BAD_CAST newcontent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -385,13 +393,9 @@ htmlSaveErr(int code, xmlNodePtr node, const char *extra)
|
||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
static int
|
|
||||||
htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
|
|
||||||
int format);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* htmlNodeDumpFormat:
|
* htmlBufNodeDumpFormat:
|
||||||
* @buf: the HTML buffer output
|
* @buf: the xmlBufPtr output
|
||||||
* @doc: the document
|
* @doc: the document
|
||||||
* @cur: the current node
|
* @cur: the current node
|
||||||
* @format: should formatting spaces been added
|
* @format: should formatting spaces been added
|
||||||
|
@ -400,10 +404,10 @@ htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
|
||||||
*
|
*
|
||||||
* Returns the number of byte written or -1 in case of error
|
* Returns the number of byte written or -1 in case of error
|
||||||
*/
|
*/
|
||||||
static int
|
static size_t
|
||||||
htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
|
htmlBufNodeDumpFormat(xmlBufPtr buf, xmlDocPtr doc, xmlNodePtr cur,
|
||||||
int format) {
|
int format) {
|
||||||
unsigned int use;
|
size_t use;
|
||||||
int ret;
|
int ret;
|
||||||
xmlOutputBufferPtr outbuf;
|
xmlOutputBufferPtr outbuf;
|
||||||
|
|
||||||
|
@ -426,10 +430,10 @@ htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
|
||||||
outbuf->context = NULL;
|
outbuf->context = NULL;
|
||||||
outbuf->written = 0;
|
outbuf->written = 0;
|
||||||
|
|
||||||
use = buf->use;
|
use = xmlBufUse(buf);
|
||||||
htmlNodeDumpFormatOutput(outbuf, doc, cur, NULL, format);
|
htmlNodeDumpFormatOutput(outbuf, doc, cur, NULL, format);
|
||||||
xmlFree(outbuf);
|
xmlFree(outbuf);
|
||||||
ret = buf->use - use;
|
ret = xmlBufUse(buf) - use;
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,9 +450,24 @@ htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
|
htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
|
||||||
xmlInitParser();
|
xmlBufPtr buffer;
|
||||||
|
size_t ret;
|
||||||
|
|
||||||
return(htmlNodeDumpFormat(buf, doc, cur, 1));
|
if ((buf == NULL) || (cur == NULL))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
xmlInitParser();
|
||||||
|
buffer = xmlBufFromBuffer(buf);
|
||||||
|
if (buffer == NULL)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
ret = htmlBufNodeDumpFormat(buffer, doc, cur, 1);
|
||||||
|
|
||||||
|
xmlBufBackToBuffer(buffer);
|
||||||
|
|
||||||
|
if (ret > INT_MAX)
|
||||||
|
return(-1);
|
||||||
|
return((int) ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -481,7 +500,7 @@ htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc,
|
||||||
if (enc != XML_CHAR_ENCODING_UTF8) {
|
if (enc != XML_CHAR_ENCODING_UTF8) {
|
||||||
handler = xmlFindCharEncodingHandler(encoding);
|
handler = xmlFindCharEncodingHandler(encoding);
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
return(-1);
|
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,11 +581,9 @@ htmlDocDumpMemoryFormat(xmlDocPtr cur, xmlChar**mem, int *size, int format) {
|
||||||
}
|
}
|
||||||
|
|
||||||
handler = xmlFindCharEncodingHandler(encoding);
|
handler = xmlFindCharEncodingHandler(encoding);
|
||||||
if (handler == NULL) {
|
if (handler == NULL)
|
||||||
*mem = NULL;
|
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
|
||||||
*size = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
handler = xmlFindCharEncodingHandler(encoding);
|
handler = xmlFindCharEncodingHandler(encoding);
|
||||||
}
|
}
|
||||||
|
@ -587,15 +604,15 @@ htmlDocDumpMemoryFormat(xmlDocPtr cur, xmlChar**mem, int *size, int format) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
htmlDocContentDumpFormatOutput(buf, cur, NULL, format);
|
htmlDocContentDumpFormatOutput(buf, cur, NULL, format);
|
||||||
|
|
||||||
xmlOutputBufferFlush(buf);
|
xmlOutputBufferFlush(buf);
|
||||||
if (buf->conv != NULL) {
|
if (buf->conv != NULL) {
|
||||||
*size = buf->conv->use;
|
*size = xmlBufUse(buf->conv);
|
||||||
*mem = xmlStrndup(buf->conv->content, *size);
|
*mem = xmlStrndup(xmlBufContent(buf->conv), *size);
|
||||||
} else {
|
} else {
|
||||||
*size = buf->buffer->use;
|
*size = xmlBufUse(buf->buffer);
|
||||||
*mem = xmlStrndup(buf->buffer->content, *size);
|
*mem = xmlStrndup(xmlBufContent(buf->buffer), *size);
|
||||||
}
|
}
|
||||||
(void)xmlOutputBufferClose(buf);
|
(void)xmlOutputBufferClose(buf);
|
||||||
}
|
}
|
||||||
|
@ -646,14 +663,14 @@ htmlDtdDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
|
||||||
xmlOutputBufferWriteString(buf, (const char *)cur->name);
|
xmlOutputBufferWriteString(buf, (const char *)cur->name);
|
||||||
if (cur->ExternalID != NULL) {
|
if (cur->ExternalID != NULL) {
|
||||||
xmlOutputBufferWriteString(buf, " PUBLIC ");
|
xmlOutputBufferWriteString(buf, " PUBLIC ");
|
||||||
xmlBufferWriteQuotedString(buf->buffer, cur->ExternalID);
|
xmlBufWriteQuotedString(buf->buffer, cur->ExternalID);
|
||||||
if (cur->SystemID != NULL) {
|
if (cur->SystemID != NULL) {
|
||||||
xmlOutputBufferWriteString(buf, " ");
|
xmlOutputBufferWriteString(buf, " ");
|
||||||
xmlBufferWriteQuotedString(buf->buffer, cur->SystemID);
|
xmlBufWriteQuotedString(buf->buffer, cur->SystemID);
|
||||||
}
|
}
|
||||||
} else if (cur->SystemID != NULL) {
|
} else if (cur->SystemID != NULL) {
|
||||||
xmlOutputBufferWriteString(buf, " SYSTEM ");
|
xmlOutputBufferWriteString(buf, " SYSTEM ");
|
||||||
xmlBufferWriteQuotedString(buf->buffer, cur->SystemID);
|
xmlBufWriteQuotedString(buf->buffer, cur->SystemID);
|
||||||
}
|
}
|
||||||
xmlOutputBufferWriteString(buf, ">\n");
|
xmlOutputBufferWriteString(buf, ">\n");
|
||||||
}
|
}
|
||||||
|
@ -673,9 +690,10 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
|
||||||
xmlChar *value;
|
xmlChar *value;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: The html output method should not escape a & character
|
* The html output method should not escape a & character
|
||||||
* occurring in an attribute value immediately followed by
|
* occurring in an attribute value immediately followed by
|
||||||
* a { character (see Section B.7.1 of the HTML 4.0 Recommendation).
|
* a { character (see Section B.7.1 of the HTML 4.0 Recommendation).
|
||||||
|
* This is implemented in xmlEncodeEntitiesReentrant
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
|
@ -703,15 +721,19 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
|
||||||
|
|
||||||
while (IS_BLANK_CH(*tmp)) tmp++;
|
while (IS_BLANK_CH(*tmp)) tmp++;
|
||||||
|
|
||||||
escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%&,+");
|
/*
|
||||||
|
* the < and > have already been escaped at the entity level
|
||||||
|
* And doing so here breaks server side includes
|
||||||
|
*/
|
||||||
|
escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%&,+<>");
|
||||||
if (escaped != NULL) {
|
if (escaped != NULL) {
|
||||||
xmlBufferWriteQuotedString(buf->buffer, escaped);
|
xmlBufWriteQuotedString(buf->buffer, escaped);
|
||||||
xmlFree(escaped);
|
xmlFree(escaped);
|
||||||
} else {
|
} else {
|
||||||
xmlBufferWriteQuotedString(buf->buffer, value);
|
xmlBufWriteQuotedString(buf->buffer, value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
xmlBufferWriteQuotedString(buf->buffer, value);
|
xmlBufWriteQuotedString(buf->buffer, value);
|
||||||
}
|
}
|
||||||
xmlFree(value);
|
xmlFree(value);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1061,7 +1083,7 @@ htmlDocDump(FILE *f, xmlDocPtr cur) {
|
||||||
|
|
||||||
handler = xmlFindCharEncodingHandler(encoding);
|
handler = xmlFindCharEncodingHandler(encoding);
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
return(-1);
|
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
|
||||||
} else {
|
} else {
|
||||||
handler = xmlFindCharEncodingHandler(encoding);
|
handler = xmlFindCharEncodingHandler(encoding);
|
||||||
}
|
}
|
||||||
|
@ -1120,7 +1142,7 @@ htmlSaveFile(const char *filename, xmlDocPtr cur) {
|
||||||
|
|
||||||
handler = xmlFindCharEncodingHandler(encoding);
|
handler = xmlFindCharEncodingHandler(encoding);
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
return(-1);
|
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1181,7 +1203,7 @@ htmlSaveFileFormat(const char *filename, xmlDocPtr cur,
|
||||||
|
|
||||||
handler = xmlFindCharEncodingHandler(encoding);
|
handler = xmlFindCharEncodingHandler(encoding);
|
||||||
if (handler == NULL)
|
if (handler == NULL)
|
||||||
return(-1);
|
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
|
||||||
}
|
}
|
||||||
htmlSetMetaEncoding(cur, (const xmlChar *) encoding);
|
htmlSetMetaEncoding(cur, (const xmlChar *) encoding);
|
||||||
} else {
|
} else {
|
||||||
|
|
105
reactos/lib/3rdparty/libxml2/SAX2.c
vendored
105
reactos/lib/3rdparty/libxml2/SAX2.c
vendored
|
@ -57,12 +57,29 @@
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) {
|
xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) {
|
||||||
|
xmlStructuredErrorFunc schannel = NULL;
|
||||||
|
const char *str1 = "out of memory\n";
|
||||||
|
|
||||||
if (ctxt != NULL) {
|
if (ctxt != NULL) {
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
|
ctxt->errNo = XML_ERR_NO_MEMORY;
|
||||||
ctxt->sax->error(ctxt->userData, "%s: out of memory\n", msg);
|
if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC))
|
||||||
|
schannel = ctxt->sax->serror;
|
||||||
|
__xmlRaiseError(schannel,
|
||||||
|
ctxt->vctxt.error, ctxt->vctxt.userData,
|
||||||
|
ctxt, NULL, XML_FROM_PARSER, XML_ERR_NO_MEMORY,
|
||||||
|
XML_ERR_ERROR, NULL, 0, (const char *) str1,
|
||||||
|
NULL, NULL, 0, 0,
|
||||||
|
msg, (const char *) str1, NULL);
|
||||||
ctxt->errNo = XML_ERR_NO_MEMORY;
|
ctxt->errNo = XML_ERR_NO_MEMORY;
|
||||||
ctxt->instate = XML_PARSER_EOF;
|
ctxt->instate = XML_PARSER_EOF;
|
||||||
ctxt->disableSAX = 1;
|
ctxt->disableSAX = 1;
|
||||||
|
} else {
|
||||||
|
__xmlRaiseError(schannel,
|
||||||
|
NULL, NULL,
|
||||||
|
ctxt, NULL, XML_FROM_PARSER, XML_ERR_NO_MEMORY,
|
||||||
|
XML_ERR_ERROR, NULL, 0, (const char *) str1,
|
||||||
|
NULL, NULL, 0, 0,
|
||||||
|
msg, (const char *) str1, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1756,7 +1773,6 @@ void
|
||||||
xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
|
xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||||
xmlParserNodeInfo node_info;
|
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
|
|
||||||
if (ctx == NULL) return;
|
if (ctx == NULL) return;
|
||||||
|
@ -1770,10 +1786,10 @@ xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
|
||||||
|
|
||||||
/* Capture end position and add node */
|
/* Capture end position and add node */
|
||||||
if (cur != NULL && ctxt->record_info) {
|
if (cur != NULL && ctxt->record_info) {
|
||||||
node_info.end_pos = ctxt->input->cur - ctxt->input->base;
|
ctxt->nodeInfo->end_pos = ctxt->input->cur - ctxt->input->base;
|
||||||
node_info.end_line = ctxt->input->line;
|
ctxt->nodeInfo->end_line = ctxt->input->line;
|
||||||
node_info.node = cur;
|
ctxt->nodeInfo->node = cur;
|
||||||
xmlParserAddNodeInfo(ctxt, &node_info);
|
xmlParserAddNodeInfo(ctxt, ctxt->nodeInfo);
|
||||||
}
|
}
|
||||||
ctxt->nodemem = -1;
|
ctxt->nodemem = -1;
|
||||||
|
|
||||||
|
@ -1801,7 +1817,7 @@ xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
|
||||||
* @str: the input string
|
* @str: the input string
|
||||||
* @len: the string length
|
* @len: the string length
|
||||||
*
|
*
|
||||||
* Remove the entities from an attribute value
|
* Callback for a text node
|
||||||
*
|
*
|
||||||
* Returns the newly allocated string or NULL if not needed or error
|
* Returns the newly allocated string or NULL if not needed or error
|
||||||
*/
|
*/
|
||||||
|
@ -1834,7 +1850,7 @@ xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
|
||||||
|
|
||||||
if ((len < (int) (2 * sizeof(void *))) &&
|
if ((len < (int) (2 * sizeof(void *))) &&
|
||||||
(ctxt->options & XML_PARSE_COMPACT)) {
|
(ctxt->options & XML_PARSE_COMPACT)) {
|
||||||
/* store the string in the node overrithing properties and nsDef */
|
/* store the string in the node overriding properties and nsDef */
|
||||||
xmlChar *tmp = (xmlChar *) &(ret->properties);
|
xmlChar *tmp = (xmlChar *) &(ret->properties);
|
||||||
memcpy(tmp, str, len);
|
memcpy(tmp, str, len);
|
||||||
tmp[len] = 0;
|
tmp[len] = 0;
|
||||||
|
@ -1866,8 +1882,17 @@ skip:
|
||||||
} else
|
} else
|
||||||
ret->content = (xmlChar *) intern;
|
ret->content = (xmlChar *) intern;
|
||||||
|
|
||||||
if (ctxt->input != NULL)
|
if (ctxt->linenumbers) {
|
||||||
ret->line = ctxt->input->line;
|
if (ctxt->input != NULL) {
|
||||||
|
if (ctxt->input->line < 65535)
|
||||||
|
ret->line = (short) ctxt->input->line;
|
||||||
|
else {
|
||||||
|
ret->line = 65535;
|
||||||
|
if (ctxt->options & XML_PARSE_BIG_LINES)
|
||||||
|
ret->psvi = (void *) (long) ctxt->input->line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
|
if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
|
||||||
xmlRegisterNodeDefaultValue(ret);
|
xmlRegisterNodeDefaultValue(ret);
|
||||||
|
@ -2163,6 +2188,7 @@ xmlSAX2StartElementNs(void *ctx,
|
||||||
xmlNodePtr parent;
|
xmlNodePtr parent;
|
||||||
xmlNsPtr last = NULL, ns;
|
xmlNsPtr last = NULL, ns;
|
||||||
const xmlChar *uri, *pref;
|
const xmlChar *uri, *pref;
|
||||||
|
xmlChar *lname = NULL;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
if (ctx == NULL) return;
|
if (ctx == NULL) return;
|
||||||
|
@ -2181,6 +2207,20 @@ xmlSAX2StartElementNs(void *ctx,
|
||||||
ctxt->validate = 0;
|
ctxt->validate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Take care of the rare case of an undefined namespace prefix
|
||||||
|
*/
|
||||||
|
if ((prefix != NULL) && (URI == NULL)) {
|
||||||
|
if (ctxt->dictNames) {
|
||||||
|
const xmlChar *fullname;
|
||||||
|
|
||||||
|
fullname = xmlDictQLookup(ctxt->dict, prefix, localname);
|
||||||
|
if (fullname != NULL)
|
||||||
|
localname = fullname;
|
||||||
|
} else {
|
||||||
|
lname = xmlBuildQName(localname, prefix, NULL, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* allocate the node
|
* allocate the node
|
||||||
*/
|
*/
|
||||||
|
@ -2194,7 +2234,10 @@ xmlSAX2StartElementNs(void *ctx,
|
||||||
if (ctxt->dictNames)
|
if (ctxt->dictNames)
|
||||||
ret->name = localname;
|
ret->name = localname;
|
||||||
else {
|
else {
|
||||||
ret->name = xmlStrdup(localname);
|
if (lname == NULL)
|
||||||
|
ret->name = xmlStrdup(localname);
|
||||||
|
else
|
||||||
|
ret->name = lname;
|
||||||
if (ret->name == NULL) {
|
if (ret->name == NULL) {
|
||||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
|
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
|
||||||
return;
|
return;
|
||||||
|
@ -2206,8 +2249,11 @@ xmlSAX2StartElementNs(void *ctx,
|
||||||
if (ctxt->dictNames)
|
if (ctxt->dictNames)
|
||||||
ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
|
ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
|
||||||
(xmlChar *) localname, NULL);
|
(xmlChar *) localname, NULL);
|
||||||
else
|
else if (lname == NULL)
|
||||||
ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);
|
ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);
|
||||||
|
else
|
||||||
|
ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
|
||||||
|
(xmlChar *) lname, NULL);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
|
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
|
||||||
return;
|
return;
|
||||||
|
@ -2222,7 +2268,7 @@ xmlSAX2StartElementNs(void *ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
|
if (parent == NULL) {
|
||||||
xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
|
xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -2314,8 +2360,33 @@ xmlSAX2StartElementNs(void *ctx,
|
||||||
*/
|
*/
|
||||||
if (nb_attributes > 0) {
|
if (nb_attributes > 0) {
|
||||||
for (j = 0,i = 0;i < nb_attributes;i++,j+=5) {
|
for (j = 0,i = 0;i < nb_attributes;i++,j+=5) {
|
||||||
|
/*
|
||||||
|
* Handle the rare case of an undefined atribute prefix
|
||||||
|
*/
|
||||||
|
if ((attributes[j+1] != NULL) && (attributes[j+2] == NULL)) {
|
||||||
|
if (ctxt->dictNames) {
|
||||||
|
const xmlChar *fullname;
|
||||||
|
|
||||||
|
fullname = xmlDictQLookup(ctxt->dict, attributes[j+1],
|
||||||
|
attributes[j]);
|
||||||
|
if (fullname != NULL) {
|
||||||
|
xmlSAX2AttributeNs(ctxt, fullname, NULL,
|
||||||
|
attributes[j+3], attributes[j+4]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lname = xmlBuildQName(attributes[j], attributes[j+1],
|
||||||
|
NULL, 0);
|
||||||
|
if (lname != NULL) {
|
||||||
|
xmlSAX2AttributeNs(ctxt, lname, NULL,
|
||||||
|
attributes[j+3], attributes[j+4]);
|
||||||
|
xmlFree(lname);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1],
|
xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1],
|
||||||
attributes[j+3], attributes[j+4]);
|
attributes[j+3], attributes[j+4]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2595,7 +2666,7 @@ xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target,
|
||||||
xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret);
|
xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
|
if (parent == NULL) {
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"Setting PI %s as root\n", target);
|
"Setting PI %s as root\n", target);
|
||||||
|
@ -2656,7 +2727,7 @@ xmlSAX2Comment(void *ctx, const xmlChar *value)
|
||||||
xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret);
|
xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
|
if (parent == NULL) {
|
||||||
#ifdef DEBUG_SAX_TREE
|
#ifdef DEBUG_SAX_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"Setting xmlSAX2Comment as root\n");
|
"Setting xmlSAX2Comment as root\n");
|
||||||
|
|
16
reactos/lib/3rdparty/libxml2/acconfig.h
vendored
16
reactos/lib/3rdparty/libxml2/acconfig.h
vendored
|
@ -1,16 +0,0 @@
|
||||||
#undef PACKAGE
|
|
||||||
#undef VERSION
|
|
||||||
#undef HAVE_LIBZ
|
|
||||||
#undef HAVE_LIBM
|
|
||||||
#undef HAVE_ISINF
|
|
||||||
#undef HAVE_ISNAN
|
|
||||||
#undef HAVE_LIBHISTORY
|
|
||||||
#undef HAVE_LIBREADLINE
|
|
||||||
#undef HAVE_LIBPTHREAD
|
|
||||||
#undef HAVE_PTHREAD_H
|
|
||||||
|
|
||||||
/* Define if IPV6 support is there */
|
|
||||||
#undef SUPPORT_IP6
|
|
||||||
|
|
||||||
/* Define if getaddrinfo is there */
|
|
||||||
#undef HAVE_GETADDRINFO
|
|
1301
reactos/lib/3rdparty/libxml2/buf.c
vendored
Normal file
1301
reactos/lib/3rdparty/libxml2/buf.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
72
reactos/lib/3rdparty/libxml2/buf.h
vendored
Normal file
72
reactos/lib/3rdparty/libxml2/buf.h
vendored
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Summary: Internal Interfaces for memory buffers in libxml2
|
||||||
|
* Description: this module describes most of the new xmlBuf buffer
|
||||||
|
* entry points, those are private routines, with a
|
||||||
|
* few exceptions exported in tree.h. This was added
|
||||||
|
* in 2.9.0.
|
||||||
|
*
|
||||||
|
* Copy: See Copyright for the status of this software.
|
||||||
|
*
|
||||||
|
* Author: Daniel Veillard
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XML_BUF_H__
|
||||||
|
#define __XML_BUF_H__
|
||||||
|
|
||||||
|
#include <libxml/tree.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
xmlBufPtr xmlBufCreate(void);
|
||||||
|
xmlBufPtr xmlBufCreateSize(size_t size);
|
||||||
|
xmlBufPtr xmlBufCreateStatic(void *mem, size_t size);
|
||||||
|
|
||||||
|
int xmlBufSetAllocationScheme(xmlBufPtr buf,
|
||||||
|
xmlBufferAllocationScheme scheme);
|
||||||
|
int xmlBufGetAllocationScheme(xmlBufPtr buf);
|
||||||
|
|
||||||
|
void xmlBufFree(xmlBufPtr buf);
|
||||||
|
void xmlBufEmpty(xmlBufPtr buf);
|
||||||
|
|
||||||
|
/* size_t xmlBufShrink(xmlBufPtr buf, size_t len); */
|
||||||
|
int xmlBufGrow(xmlBufPtr buf, int len);
|
||||||
|
int xmlBufInflate(xmlBufPtr buf, size_t len);
|
||||||
|
int xmlBufResize(xmlBufPtr buf, size_t len);
|
||||||
|
|
||||||
|
int xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len);
|
||||||
|
int xmlBufAddHead(xmlBufPtr buf, const xmlChar *str, int len);
|
||||||
|
int xmlBufCat(xmlBufPtr buf, const xmlChar *str);
|
||||||
|
int xmlBufCCat(xmlBufPtr buf, const char *str);
|
||||||
|
int xmlBufWriteCHAR(xmlBufPtr buf, const xmlChar *string);
|
||||||
|
int xmlBufWriteChar(xmlBufPtr buf, const char *string);
|
||||||
|
int xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string);
|
||||||
|
|
||||||
|
size_t xmlBufAvail(const xmlBufPtr buf);
|
||||||
|
size_t xmlBufLength(const xmlBufPtr buf);
|
||||||
|
/* size_t xmlBufUse(const xmlBufPtr buf); */
|
||||||
|
int xmlBufIsEmpty(const xmlBufPtr buf);
|
||||||
|
int xmlBufAddLen(xmlBufPtr buf, size_t len);
|
||||||
|
int xmlBufErase(xmlBufPtr buf, size_t len);
|
||||||
|
|
||||||
|
/* const xmlChar * xmlBufContent(const xmlBufPtr buf); */
|
||||||
|
/* const xmlChar * xmlBufEnd(const xmlBufPtr buf); */
|
||||||
|
|
||||||
|
xmlChar * xmlBufDetach(xmlBufPtr buf);
|
||||||
|
|
||||||
|
size_t xmlBufDump(FILE *file, xmlBufPtr buf);
|
||||||
|
|
||||||
|
xmlBufPtr xmlBufFromBuffer(xmlBufferPtr buffer);
|
||||||
|
xmlBufferPtr xmlBufBackToBuffer(xmlBufPtr buf);
|
||||||
|
int xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer);
|
||||||
|
|
||||||
|
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input);
|
||||||
|
size_t xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input);
|
||||||
|
int xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input,
|
||||||
|
size_t base, size_t cur);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* __XML_BUF_H__ */
|
||||||
|
|
6
reactos/lib/3rdparty/libxml2/c14n.c
vendored
6
reactos/lib/3rdparty/libxml2/c14n.c
vendored
|
@ -27,6 +27,8 @@
|
||||||
#include <libxml/xpathInternals.h>
|
#include <libxml/xpathInternals.h>
|
||||||
#include <libxml/c14n.h>
|
#include <libxml/c14n.h>
|
||||||
|
|
||||||
|
#include "buf.h"
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* Some declaration better left private ATM *
|
* Some declaration better left private ATM *
|
||||||
|
@ -2033,9 +2035,9 @@ xmlC14NDocDumpMemory(xmlDocPtr doc, xmlNodeSetPtr nodes,
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = buf->buffer->use;
|
ret = xmlBufUse(buf->buffer);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
*doc_txt_ptr = xmlStrndup(buf->buffer->content, ret);
|
*doc_txt_ptr = xmlStrndup(xmlBufContent(buf->buffer), ret);
|
||||||
}
|
}
|
||||||
(void) xmlOutputBufferClose(buf);
|
(void) xmlOutputBufferClose(buf);
|
||||||
|
|
||||||
|
|
9
reactos/lib/3rdparty/libxml2/catalog.c
vendored
9
reactos/lib/3rdparty/libxml2/catalog.c
vendored
|
@ -41,6 +41,8 @@
|
||||||
#include <libxml/threads.h>
|
#include <libxml/threads.h>
|
||||||
#include <libxml/globals.h>
|
#include <libxml/globals.h>
|
||||||
|
|
||||||
|
#include "buf.h"
|
||||||
|
|
||||||
#define MAX_DELEGATE 50
|
#define MAX_DELEGATE 50
|
||||||
#define MAX_CATAL_DEPTH 50
|
#define MAX_CATAL_DEPTH 50
|
||||||
|
|
||||||
|
@ -912,10 +914,7 @@ xmlParseCatalogFile(const char *filename) {
|
||||||
|
|
||||||
inputStream->filename = (char *) xmlCanonicPath((const xmlChar *)filename);
|
inputStream->filename = (char *) xmlCanonicPath((const xmlChar *)filename);
|
||||||
inputStream->buf = buf;
|
inputStream->buf = buf;
|
||||||
inputStream->base = inputStream->buf->buffer->content;
|
xmlBufResetInput(buf->buffer, inputStream);
|
||||||
inputStream->cur = inputStream->buf->buffer->content;
|
|
||||||
inputStream->end =
|
|
||||||
&inputStream->buf->buffer->content[inputStream->buf->buffer->use];
|
|
||||||
|
|
||||||
inputPush(ctxt, inputStream);
|
inputPush(ctxt, inputStream);
|
||||||
if ((ctxt->directory == NULL) && (directory == NULL))
|
if ((ctxt->directory == NULL) && (directory == NULL))
|
||||||
|
@ -1407,8 +1406,6 @@ xmlFetchXMLCatalogFile(xmlCatalogEntryPtr catal) {
|
||||||
return(-1);
|
return(-1);
|
||||||
if (catal->URL == NULL)
|
if (catal->URL == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
if (catal->children != NULL)
|
|
||||||
return(-1);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lock the whole catalog for modification
|
* lock the whole catalog for modification
|
||||||
|
|
107
reactos/lib/3rdparty/libxml2/config.h
vendored
107
reactos/lib/3rdparty/libxml2/config.h
vendored
|
@ -1,24 +1,8 @@
|
||||||
/* config.h. Generated by configure. */
|
/* config.h. Generated from config.h.in by configure. */
|
||||||
/* config.h.in. Generated from configure.in by autoheader. */
|
/* config.h.in. Generated from configure.in by autoheader. */
|
||||||
#define PACKAGE "libxml2"
|
|
||||||
#define VERSION "2.7.7"
|
|
||||||
/* #undef HAVE_LIBZ */
|
|
||||||
/* #undef HAVE_LIBM */
|
|
||||||
/* #undef HAVE_ISINF */
|
|
||||||
#define HAVE_ISNAN
|
|
||||||
/* #undef HAVE_LIBHISTORY */
|
|
||||||
/* #undef HAVE_LIBREADLINE */
|
|
||||||
/* #undef HAVE_LIBPTHREAD */
|
|
||||||
/* #undef HAVE_PTHREAD_H */
|
|
||||||
|
|
||||||
/* Define if IPV6 support is there */
|
|
||||||
/* #undef SUPPORT_IP6 */
|
|
||||||
|
|
||||||
/* Define if getaddrinfo is there */
|
|
||||||
/* #undef HAVE_GETADDRINFO */
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <ansidecl.h> header file. */
|
/* Define to 1 if you have the <ansidecl.h> header file. */
|
||||||
/* #undef HAVE_ANSICDECL_H */
|
/* #undef HAVE_ANSIDECL_H */
|
||||||
|
|
||||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||||
/* #undef HAVE_ARPA_INET_H */
|
/* #undef HAVE_ARPA_INET_H */
|
||||||
|
@ -86,11 +70,14 @@
|
||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
#define HAVE_INTTYPES_H 1
|
#define HAVE_INTTYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `isascii' function. */
|
||||||
|
/* #undef HAVE_ISASCII */
|
||||||
|
|
||||||
/* Define if isinf is there */
|
/* Define if isinf is there */
|
||||||
/* #undef HAVE_ISINF */
|
/* #undef HAVE_ISINF */
|
||||||
|
|
||||||
/* Define if isnan is there */
|
/* Define if isnan is there */
|
||||||
#define HAVE_ISNAN
|
#define HAVE_ISNAN /**/
|
||||||
|
|
||||||
/* Define to 1 if you have the `isnand' function. */
|
/* Define to 1 if you have the `isnand' function. */
|
||||||
/* #undef HAVE_ISNAND */
|
/* #undef HAVE_ISNAND */
|
||||||
|
@ -98,14 +85,8 @@
|
||||||
/* Define if history library is there (-lhistory) */
|
/* Define if history library is there (-lhistory) */
|
||||||
/* #undef HAVE_LIBHISTORY */
|
/* #undef HAVE_LIBHISTORY */
|
||||||
|
|
||||||
/* Define to 1 if you have the `inet' library (-linet). */
|
/* Have compression library */
|
||||||
/* #undef HAVE_LIBINET */
|
/* #undef HAVE_LIBLZMA */
|
||||||
|
|
||||||
/* Define to 1 if you have the `net' library (-lnet). */
|
|
||||||
/* #undef HAVE_LIBNET */
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `nsl' library (-lnsl). */
|
|
||||||
/* #undef HAVE_LIBNSL */
|
|
||||||
|
|
||||||
/* Define if pthread library is there (-lpthread) */
|
/* Define if pthread library is there (-lpthread) */
|
||||||
/* #undef HAVE_LIBPTHREAD */
|
/* #undef HAVE_LIBPTHREAD */
|
||||||
|
@ -113,9 +94,6 @@
|
||||||
/* Define if readline library is there (-lreadline) */
|
/* Define if readline library is there (-lreadline) */
|
||||||
/* #undef HAVE_LIBREADLINE */
|
/* #undef HAVE_LIBREADLINE */
|
||||||
|
|
||||||
/* Define to 1 if you have the `socket' library (-lsocket). */
|
|
||||||
/* #undef HAVE_LIBSOCKET */
|
|
||||||
|
|
||||||
/* Have compression library */
|
/* Have compression library */
|
||||||
/* #undef HAVE_LIBZ */
|
/* #undef HAVE_LIBZ */
|
||||||
|
|
||||||
|
@ -125,6 +103,9 @@
|
||||||
/* Define to 1 if you have the `localtime' function. */
|
/* Define to 1 if you have the `localtime' function. */
|
||||||
#define HAVE_LOCALTIME 1
|
#define HAVE_LOCALTIME 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <lzma.h> header file. */
|
||||||
|
/* #undef HAVE_LZMA_H */
|
||||||
|
|
||||||
/* Define to 1 if you have the <malloc.h> header file. */
|
/* Define to 1 if you have the <malloc.h> header file. */
|
||||||
#define HAVE_MALLOC_H 1
|
#define HAVE_MALLOC_H 1
|
||||||
|
|
||||||
|
@ -134,6 +115,17 @@
|
||||||
/* Define to 1 if you have the <memory.h> header file. */
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
#define HAVE_MEMORY_H 1
|
#define HAVE_MEMORY_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `mmap' function. */
|
||||||
|
/* #undef HAVE_MMAP */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `munmap' function. */
|
||||||
|
/* #undef HAVE_MUNMAP */
|
||||||
|
|
||||||
|
/* mmap() is no good without munmap() */
|
||||||
|
#if defined(HAVE_MMAP) && !defined(HAVE_MUNMAP)
|
||||||
|
# undef /**/ HAVE_MMAP
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Define to 1 if you have the <nan.h> header file. */
|
/* Define to 1 if you have the <nan.h> header file. */
|
||||||
/* #undef HAVE_NAN_H */
|
/* #undef HAVE_NAN_H */
|
||||||
|
|
||||||
|
@ -146,12 +138,24 @@
|
||||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||||
/* #undef HAVE_NETINET_IN_H */
|
/* #undef HAVE_NETINET_IN_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <poll.h> header file. */
|
||||||
|
/* #undef HAVE_POLL_H */
|
||||||
|
|
||||||
/* Define to 1 if you have the `printf' function. */
|
/* Define to 1 if you have the `printf' function. */
|
||||||
#define HAVE_PRINTF 1
|
#define HAVE_PRINTF 1
|
||||||
|
|
||||||
/* Define if <pthread.h> is there */
|
/* Define if <pthread.h> is there */
|
||||||
/* #undef HAVE_PTHREAD_H */
|
/* #undef HAVE_PTHREAD_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `putenv' function. */
|
||||||
|
/* #undef HAVE_PUTENV */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `rand' function. */
|
||||||
|
#define HAVE_RAND 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `rand_r' function. */
|
||||||
|
/* #undef HAVE_RAND_R */
|
||||||
|
|
||||||
/* Define to 1 if you have the <resolv.h> header file. */
|
/* Define to 1 if you have the <resolv.h> header file. */
|
||||||
/* #undef HAVE_RESOLV_H */
|
/* #undef HAVE_RESOLV_H */
|
||||||
|
|
||||||
|
@ -170,6 +174,9 @@
|
||||||
/* Define to 1 if you have the `sprintf' function. */
|
/* Define to 1 if you have the `sprintf' function. */
|
||||||
#define HAVE_SPRINTF 1
|
#define HAVE_SPRINTF 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `srand' function. */
|
||||||
|
#define HAVE_SRAND 1
|
||||||
|
|
||||||
/* Define to 1 if you have the `sscanf' function. */
|
/* Define to 1 if you have the `sscanf' function. */
|
||||||
#define HAVE_SSCANF 1
|
#define HAVE_SSCANF 1
|
||||||
|
|
||||||
|
@ -232,12 +239,18 @@
|
||||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
#define HAVE_SYS_TYPES_H 1
|
#define HAVE_SYS_TYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `time' function. */
|
||||||
|
#define HAVE_TIME 1
|
||||||
|
|
||||||
/* Define to 1 if you have the <time.h> header file. */
|
/* Define to 1 if you have the <time.h> header file. */
|
||||||
#define HAVE_TIME_H 1
|
#define HAVE_TIME_H 1
|
||||||
|
|
||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
#define HAVE_UNISTD_H 1
|
#define HAVE_UNISTD_H 1
|
||||||
|
|
||||||
|
/* Whether va_copy() is available */
|
||||||
|
#define HAVE_VA_COPY 1
|
||||||
|
|
||||||
/* Define to 1 if you have the `vfprintf' function. */
|
/* Define to 1 if you have the `vfprintf' function. */
|
||||||
#define HAVE_VFPRINTF 1
|
#define HAVE_VFPRINTF 1
|
||||||
|
|
||||||
|
@ -253,6 +266,16 @@
|
||||||
/* Define to 1 if you have the `_stat' function. */
|
/* Define to 1 if you have the `_stat' function. */
|
||||||
#define HAVE__STAT 1
|
#define HAVE__STAT 1
|
||||||
|
|
||||||
|
/* Whether __va_copy() is available */
|
||||||
|
/* #undef HAVE___VA_COPY */
|
||||||
|
|
||||||
|
/* Define as const if the declaration of iconv() needs const. */
|
||||||
|
/* #undef ICONV_CONST */
|
||||||
|
|
||||||
|
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||||
|
*/
|
||||||
|
/* #undef LT_OBJDIR */
|
||||||
|
|
||||||
/* Name of package */
|
/* Name of package */
|
||||||
#define PACKAGE "libxml2"
|
#define PACKAGE "libxml2"
|
||||||
|
|
||||||
|
@ -268,12 +291,12 @@
|
||||||
/* Define to the one symbol short name of this package. */
|
/* Define to the one symbol short name of this package. */
|
||||||
#define PACKAGE_TARNAME ""
|
#define PACKAGE_TARNAME ""
|
||||||
|
|
||||||
|
/* Define to the home page for this package. */
|
||||||
|
#define PACKAGE_URL ""
|
||||||
|
|
||||||
/* Define to the version of this package. */
|
/* Define to the version of this package. */
|
||||||
#define PACKAGE_VERSION ""
|
#define PACKAGE_VERSION ""
|
||||||
|
|
||||||
/* Define to 1 if the C compiler supports function prototypes. */
|
|
||||||
#define PROTOTYPES 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the ANSI C header files. */
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
#define STDC_HEADERS 1
|
#define STDC_HEADERS 1
|
||||||
|
|
||||||
|
@ -281,26 +304,26 @@
|
||||||
/* #undef SUPPORT_IP6 */
|
/* #undef SUPPORT_IP6 */
|
||||||
|
|
||||||
/* Version number of package */
|
/* Version number of package */
|
||||||
#define VERSION "2.7.7"
|
#define VERSION "2.9.0"
|
||||||
|
|
||||||
/* Determine what socket length (socklen_t) data type is */
|
/* Determine what socket length (socklen_t) data type is */
|
||||||
#define XML_SOCKLEN_T int
|
#define XML_SOCKLEN_T int
|
||||||
|
|
||||||
|
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
|
||||||
|
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||||
|
#define below would cause a syntax error. */
|
||||||
|
/* #undef _UINT32_T */
|
||||||
|
|
||||||
/* Using the Win32 Socket implementation */
|
/* Using the Win32 Socket implementation */
|
||||||
//#define _WINSOCKAPI_ 1
|
//#define _WINSOCKAPI_ 1
|
||||||
|
|
||||||
/* Define like PROTOTYPES; this can be used by system headers. */
|
|
||||||
#define __PROTOTYPES 1
|
|
||||||
|
|
||||||
/* Win32 Std C name mangling work-around */
|
|
||||||
#define snprintf _snprintf
|
|
||||||
|
|
||||||
/* ss_family is not defined here, use __ss_family instead */
|
/* ss_family is not defined here, use __ss_family instead */
|
||||||
/* #undef ss_family */
|
/* #undef ss_family */
|
||||||
|
|
||||||
#if !defined(__MINGW32__) || defined(__NO_ISOCEXT)
|
/* Define to the type of an unsigned integer type of width exactly 32 bits if
|
||||||
#define vsnprintf _vsnprintf
|
such a type exists and the standard includes do not define it. */
|
||||||
#endif
|
/* #undef uint32_t */
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#define GetModuleHandleA GetModuleHandleA_
|
#define GetModuleHandleA GetModuleHandleA_
|
||||||
|
|
71
reactos/lib/3rdparty/libxml2/config.h.in
vendored
71
reactos/lib/3rdparty/libxml2/config.h.in
vendored
|
@ -1,20 +1,4 @@
|
||||||
/* config.h.in. Generated from configure.in by autoheader. */
|
/* config.h.in. Generated from configure.in by autoheader. */
|
||||||
#undef PACKAGE
|
|
||||||
#undef VERSION
|
|
||||||
#undef HAVE_LIBZ
|
|
||||||
#undef HAVE_LIBM
|
|
||||||
#undef HAVE_ISINF
|
|
||||||
#undef HAVE_ISNAN
|
|
||||||
#undef HAVE_LIBHISTORY
|
|
||||||
#undef HAVE_LIBREADLINE
|
|
||||||
#undef HAVE_LIBPTHREAD
|
|
||||||
#undef HAVE_PTHREAD_H
|
|
||||||
|
|
||||||
/* Define if IPV6 support is there */
|
|
||||||
#undef SUPPORT_IP6
|
|
||||||
|
|
||||||
/* Define if getaddrinfo is there */
|
|
||||||
#undef HAVE_GETADDRINFO
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <ansidecl.h> header file. */
|
/* Define to 1 if you have the <ansidecl.h> header file. */
|
||||||
#undef HAVE_ANSIDECL_H
|
#undef HAVE_ANSIDECL_H
|
||||||
|
@ -85,8 +69,8 @@
|
||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
#undef HAVE_INTTYPES_H
|
#undef HAVE_INTTYPES_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <inttypes.h.h> header file. */
|
/* Define to 1 if you have the `isascii' function. */
|
||||||
#undef HAVE_INTTYPES_H_H
|
#undef HAVE_ISASCII
|
||||||
|
|
||||||
/* Define if isinf is there */
|
/* Define if isinf is there */
|
||||||
#undef HAVE_ISINF
|
#undef HAVE_ISINF
|
||||||
|
@ -100,6 +84,9 @@
|
||||||
/* Define if history library is there (-lhistory) */
|
/* Define if history library is there (-lhistory) */
|
||||||
#undef HAVE_LIBHISTORY
|
#undef HAVE_LIBHISTORY
|
||||||
|
|
||||||
|
/* Have compression library */
|
||||||
|
#undef HAVE_LIBLZMA
|
||||||
|
|
||||||
/* Define if pthread library is there (-lpthread) */
|
/* Define if pthread library is there (-lpthread) */
|
||||||
#undef HAVE_LIBPTHREAD
|
#undef HAVE_LIBPTHREAD
|
||||||
|
|
||||||
|
@ -115,6 +102,9 @@
|
||||||
/* Define to 1 if you have the `localtime' function. */
|
/* Define to 1 if you have the `localtime' function. */
|
||||||
#undef HAVE_LOCALTIME
|
#undef HAVE_LOCALTIME
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <lzma.h> header file. */
|
||||||
|
#undef HAVE_LZMA_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <malloc.h> header file. */
|
/* Define to 1 if you have the <malloc.h> header file. */
|
||||||
#undef HAVE_MALLOC_H
|
#undef HAVE_MALLOC_H
|
||||||
|
|
||||||
|
@ -124,6 +114,17 @@
|
||||||
/* Define to 1 if you have the <memory.h> header file. */
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
#undef HAVE_MEMORY_H
|
#undef HAVE_MEMORY_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `mmap' function. */
|
||||||
|
#undef HAVE_MMAP
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `munmap' function. */
|
||||||
|
#undef HAVE_MUNMAP
|
||||||
|
|
||||||
|
/* mmap() is no good without munmap() */
|
||||||
|
#if defined(HAVE_MMAP) && !defined(HAVE_MUNMAP)
|
||||||
|
# undef /**/ HAVE_MMAP
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Define to 1 if you have the <nan.h> header file. */
|
/* Define to 1 if you have the <nan.h> header file. */
|
||||||
#undef HAVE_NAN_H
|
#undef HAVE_NAN_H
|
||||||
|
|
||||||
|
@ -145,6 +146,15 @@
|
||||||
/* Define if <pthread.h> is there */
|
/* Define if <pthread.h> is there */
|
||||||
#undef HAVE_PTHREAD_H
|
#undef HAVE_PTHREAD_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `putenv' function. */
|
||||||
|
#undef HAVE_PUTENV
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `rand' function. */
|
||||||
|
#undef HAVE_RAND
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `rand_r' function. */
|
||||||
|
#undef HAVE_RAND_R
|
||||||
|
|
||||||
/* Define to 1 if you have the <resolv.h> header file. */
|
/* Define to 1 if you have the <resolv.h> header file. */
|
||||||
#undef HAVE_RESOLV_H
|
#undef HAVE_RESOLV_H
|
||||||
|
|
||||||
|
@ -163,6 +173,9 @@
|
||||||
/* Define to 1 if you have the `sprintf' function. */
|
/* Define to 1 if you have the `sprintf' function. */
|
||||||
#undef HAVE_SPRINTF
|
#undef HAVE_SPRINTF
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `srand' function. */
|
||||||
|
#undef HAVE_SRAND
|
||||||
|
|
||||||
/* Define to 1 if you have the `sscanf' function. */
|
/* Define to 1 if you have the `sscanf' function. */
|
||||||
#undef HAVE_SSCANF
|
#undef HAVE_SSCANF
|
||||||
|
|
||||||
|
@ -225,6 +238,9 @@
|
||||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
#undef HAVE_SYS_TYPES_H
|
#undef HAVE_SYS_TYPES_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `time' function. */
|
||||||
|
#undef HAVE_TIME
|
||||||
|
|
||||||
/* Define to 1 if you have the <time.h> header file. */
|
/* Define to 1 if you have the <time.h> header file. */
|
||||||
#undef HAVE_TIME_H
|
#undef HAVE_TIME_H
|
||||||
|
|
||||||
|
@ -280,9 +296,6 @@
|
||||||
/* Define to the version of this package. */
|
/* Define to the version of this package. */
|
||||||
#undef PACKAGE_VERSION
|
#undef PACKAGE_VERSION
|
||||||
|
|
||||||
/* Define to 1 if the C compiler supports function prototypes. */
|
|
||||||
#undef PROTOTYPES
|
|
||||||
|
|
||||||
/* Define to 1 if you have the ANSI C header files. */
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
#undef STDC_HEADERS
|
#undef STDC_HEADERS
|
||||||
|
|
||||||
|
@ -295,17 +308,17 @@
|
||||||
/* Determine what socket length (socklen_t) data type is */
|
/* Determine what socket length (socklen_t) data type is */
|
||||||
#undef XML_SOCKLEN_T
|
#undef XML_SOCKLEN_T
|
||||||
|
|
||||||
|
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
|
||||||
|
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||||
|
#define below would cause a syntax error. */
|
||||||
|
#undef _UINT32_T
|
||||||
|
|
||||||
/* Using the Win32 Socket implementation */
|
/* Using the Win32 Socket implementation */
|
||||||
#undef _WINSOCKAPI_
|
#undef _WINSOCKAPI_
|
||||||
|
|
||||||
/* Define like PROTOTYPES; this can be used by system headers. */
|
|
||||||
#undef __PROTOTYPES
|
|
||||||
|
|
||||||
/* Win32 Std C name mangling work-around */
|
|
||||||
#undef snprintf
|
|
||||||
|
|
||||||
/* ss_family is not defined here, use __ss_family instead */
|
/* ss_family is not defined here, use __ss_family instead */
|
||||||
#undef ss_family
|
#undef ss_family
|
||||||
|
|
||||||
/* Win32 Std C name mangling work-around */
|
/* Define to the type of an unsigned integer type of width exactly 32 bits if
|
||||||
#undef vsnprintf
|
such a type exists and the standard includes do not define it. */
|
||||||
|
#undef uint32_t
|
||||||
|
|
163
reactos/lib/3rdparty/libxml2/debugXML.c
vendored
163
reactos/lib/3rdparty/libxml2/debugXML.c
vendored
|
@ -1724,8 +1724,11 @@ xmlLsOneNode(FILE *output, xmlNodePtr node) {
|
||||||
|
|
||||||
switch (node->type) {
|
switch (node->type) {
|
||||||
case XML_ELEMENT_NODE:
|
case XML_ELEMENT_NODE:
|
||||||
if (node->name != NULL)
|
if (node->name != NULL) {
|
||||||
|
if ((node->ns != NULL) && (node->ns->prefix != NULL))
|
||||||
|
fprintf(output, "%s:", node->ns->prefix);
|
||||||
fprintf(output, "%s", (const char *) node->name);
|
fprintf(output, "%s", (const char *) node->name);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case XML_ATTRIBUTE_NODE:
|
case XML_ATTRIBUTE_NODE:
|
||||||
if (node->name != NULL)
|
if (node->name != NULL)
|
||||||
|
@ -2696,6 +2699,8 @@ xmlShellDu(xmlShellCtxtPtr ctxt,
|
||||||
} else if (node->type == XML_ELEMENT_NODE) {
|
} else if (node->type == XML_ELEMENT_NODE) {
|
||||||
for (i = 0; i < indent; i++)
|
for (i = 0; i < indent; i++)
|
||||||
fprintf(ctxt->output, " ");
|
fprintf(ctxt->output, " ");
|
||||||
|
if ((node->ns) && (node->ns->prefix))
|
||||||
|
fprintf(ctxt->output, "%s:", node->ns->prefix);
|
||||||
fprintf(ctxt->output, "%s\n", node->name);
|
fprintf(ctxt->output, "%s\n", node->name);
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
|
@ -2837,6 +2842,10 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
|
||||||
while (1) {
|
while (1) {
|
||||||
if (ctxt->node == (xmlNodePtr) ctxt->doc)
|
if (ctxt->node == (xmlNodePtr) ctxt->doc)
|
||||||
snprintf(prompt, sizeof(prompt), "%s > ", "/");
|
snprintf(prompt, sizeof(prompt), "%s > ", "/");
|
||||||
|
else if ((ctxt->node != NULL) && (ctxt->node->name) &&
|
||||||
|
(ctxt->node->ns) && (ctxt->node->ns->prefix))
|
||||||
|
snprintf(prompt, sizeof(prompt), "%s:%s > ",
|
||||||
|
(ctxt->node->ns->prefix), ctxt->node->name);
|
||||||
else if ((ctxt->node != NULL) && (ctxt->node->name))
|
else if ((ctxt->node != NULL) && (ctxt->node->name))
|
||||||
snprintf(prompt, sizeof(prompt), "%s > ", ctxt->node->name);
|
snprintf(prompt, sizeof(prompt), "%s > ", ctxt->node->name);
|
||||||
else
|
else
|
||||||
|
@ -2911,6 +2920,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
|
||||||
fprintf(ctxt->output, "\t the default namespace if any uses 'defaultns' prefix\n");
|
fprintf(ctxt->output, "\t the default namespace if any uses 'defaultns' prefix\n");
|
||||||
#endif /* LIBXML_XPATH_ENABLED */
|
#endif /* LIBXML_XPATH_ENABLED */
|
||||||
fprintf(ctxt->output, "\tpwd display current working directory\n");
|
fprintf(ctxt->output, "\tpwd display current working directory\n");
|
||||||
|
fprintf(ctxt->output, "\twhereis display absolute path of [path] or current working directory\n");
|
||||||
fprintf(ctxt->output, "\tquit leave shell\n");
|
fprintf(ctxt->output, "\tquit leave shell\n");
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
#ifdef LIBXML_OUTPUT_ENABLED
|
||||||
fprintf(ctxt->output, "\tsave [name] save this document to name or the original name\n");
|
fprintf(ctxt->output, "\tsave [name] save this document to name or the original name\n");
|
||||||
|
@ -2960,7 +2970,79 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
|
||||||
if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL))
|
if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL))
|
||||||
fprintf(ctxt->output, "%s\n", dir);
|
fprintf(ctxt->output, "%s\n", dir);
|
||||||
} else if (!strcmp(command, "du")) {
|
} else if (!strcmp(command, "du")) {
|
||||||
xmlShellDu(ctxt, NULL, ctxt->node, NULL);
|
if (arg[0] == 0) {
|
||||||
|
xmlShellDu(ctxt, NULL, ctxt->node, NULL);
|
||||||
|
} else {
|
||||||
|
ctxt->pctxt->node = ctxt->node;
|
||||||
|
#ifdef LIBXML_XPATH_ENABLED
|
||||||
|
ctxt->pctxt->node = ctxt->node;
|
||||||
|
list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
|
||||||
|
#else
|
||||||
|
list = NULL;
|
||||||
|
#endif /* LIBXML_XPATH_ENABLED */
|
||||||
|
if (list != NULL) {
|
||||||
|
switch (list->type) {
|
||||||
|
case XPATH_UNDEFINED:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s: no such node\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_NODESET:{
|
||||||
|
int indx;
|
||||||
|
|
||||||
|
if (list->nodesetval == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
for (indx = 0;
|
||||||
|
indx < list->nodesetval->nodeNr;
|
||||||
|
indx++)
|
||||||
|
xmlShellDu(ctxt, NULL,
|
||||||
|
list->nodesetval->
|
||||||
|
nodeTab[indx], NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case XPATH_BOOLEAN:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a Boolean\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_NUMBER:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a number\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_STRING:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a string\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_POINT:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a point\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_RANGE:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a range\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_LOCATIONSET:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a range\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_USERS:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is user-defined\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_XSLT_TREE:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is an XSLT value tree\n",
|
||||||
|
arg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#ifdef LIBXML_XPATH_ENABLED
|
||||||
|
xmlXPathFreeObject(list);
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s: no such node\n", arg);
|
||||||
|
}
|
||||||
|
ctxt->pctxt->node = NULL;
|
||||||
|
}
|
||||||
} else if (!strcmp(command, "base")) {
|
} else if (!strcmp(command, "base")) {
|
||||||
xmlShellBase(ctxt, NULL, ctxt->node, NULL);
|
xmlShellBase(ctxt, NULL, ctxt->node, NULL);
|
||||||
} else if (!strcmp(command, "set")) {
|
} else if (!strcmp(command, "set")) {
|
||||||
|
@ -3071,6 +3153,83 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
|
||||||
}
|
}
|
||||||
#ifdef LIBXML_XPATH_ENABLED
|
#ifdef LIBXML_XPATH_ENABLED
|
||||||
xmlXPathFreeObject(list);
|
xmlXPathFreeObject(list);
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s: no such node\n", arg);
|
||||||
|
}
|
||||||
|
ctxt->pctxt->node = NULL;
|
||||||
|
}
|
||||||
|
} else if (!strcmp(command, "whereis")) {
|
||||||
|
char dir[500];
|
||||||
|
|
||||||
|
if (arg[0] == 0) {
|
||||||
|
if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL))
|
||||||
|
fprintf(ctxt->output, "%s\n", dir);
|
||||||
|
} else {
|
||||||
|
ctxt->pctxt->node = ctxt->node;
|
||||||
|
#ifdef LIBXML_XPATH_ENABLED
|
||||||
|
list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
|
||||||
|
#else
|
||||||
|
list = NULL;
|
||||||
|
#endif /* LIBXML_XPATH_ENABLED */
|
||||||
|
if (list != NULL) {
|
||||||
|
switch (list->type) {
|
||||||
|
case XPATH_UNDEFINED:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s: no such node\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_NODESET:{
|
||||||
|
int indx;
|
||||||
|
|
||||||
|
if (list->nodesetval == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
for (indx = 0;
|
||||||
|
indx < list->nodesetval->nodeNr;
|
||||||
|
indx++) {
|
||||||
|
if (!xmlShellPwd(ctxt, dir, list->nodesetval->
|
||||||
|
nodeTab[indx], NULL))
|
||||||
|
fprintf(ctxt->output, "%s\n", dir);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case XPATH_BOOLEAN:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a Boolean\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_NUMBER:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a number\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_STRING:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a string\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_POINT:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a point\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_RANGE:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a range\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_LOCATIONSET:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is a range\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_USERS:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is user-defined\n", arg);
|
||||||
|
break;
|
||||||
|
case XPATH_XSLT_TREE:
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"%s is an XSLT value tree\n",
|
||||||
|
arg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#ifdef LIBXML_XPATH_ENABLED
|
||||||
|
xmlXPathFreeObject(list);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
|
308
reactos/lib/3rdparty/libxml2/dict.c
vendored
308
reactos/lib/3rdparty/libxml2/dict.c
vendored
|
@ -2,7 +2,7 @@
|
||||||
* dict.c: dictionary of reusable strings, just used to avoid allocation
|
* dict.c: dictionary of reusable strings, just used to avoid allocation
|
||||||
* and freeing operations.
|
* and freeing operations.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2003 Daniel Veillard.
|
* Copyright (C) 2003-2012 Daniel Veillard.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -19,6 +19,29 @@
|
||||||
#define IN_LIBXML
|
#define IN_LIBXML
|
||||||
#include "libxml.h"
|
#include "libxml.h"
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_TIME_H
|
||||||
|
#include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Following http://www.ocert.org/advisories/ocert-2011-003.html
|
||||||
|
* it seems that having hash randomization might be a good idea
|
||||||
|
* when using XML with untrusted data
|
||||||
|
* Note1: that it works correctly only if compiled with WITH_BIG_KEY
|
||||||
|
* which is the default.
|
||||||
|
* Note2: the fast function used for a small dict won't protect very
|
||||||
|
* well but since the attack is based on growing a very big hash
|
||||||
|
* list we will use the BigKey algo as soon as the hash size grows
|
||||||
|
* over MIN_DICT_SIZE so this actually works
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME)
|
||||||
|
#define DICT_RANDOMIZATION
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifdef HAVE_STDINT_H
|
#ifdef HAVE_STDINT_H
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -44,23 +67,23 @@ typedef unsigned __int32 uint32_t;
|
||||||
#define WITH_BIG_KEY
|
#define WITH_BIG_KEY
|
||||||
|
|
||||||
#ifdef WITH_BIG_KEY
|
#ifdef WITH_BIG_KEY
|
||||||
#define xmlDictComputeKey(dict, name, len) \
|
#define xmlDictComputeKey(dict, name, len) \
|
||||||
(((dict)->size == MIN_DICT_SIZE) ? \
|
(((dict)->size == MIN_DICT_SIZE) ? \
|
||||||
xmlDictComputeFastKey(name, len) : \
|
xmlDictComputeFastKey(name, len, (dict)->seed) : \
|
||||||
xmlDictComputeBigKey(name, len))
|
xmlDictComputeBigKey(name, len, (dict)->seed))
|
||||||
|
|
||||||
#define xmlDictComputeQKey(dict, prefix, plen, name, len) \
|
#define xmlDictComputeQKey(dict, prefix, plen, name, len) \
|
||||||
(((prefix) == NULL) ? \
|
(((prefix) == NULL) ? \
|
||||||
(xmlDictComputeKey(dict, name, len)) : \
|
(xmlDictComputeKey(dict, name, len)) : \
|
||||||
(((dict)->size == MIN_DICT_SIZE) ? \
|
(((dict)->size == MIN_DICT_SIZE) ? \
|
||||||
xmlDictComputeFastQKey(prefix, plen, name, len) : \
|
xmlDictComputeFastQKey(prefix, plen, name, len, (dict)->seed) : \
|
||||||
xmlDictComputeBigQKey(prefix, plen, name, len)))
|
xmlDictComputeBigQKey(prefix, plen, name, len, (dict)->seed)))
|
||||||
|
|
||||||
#else /* !WITH_BIG_KEY */
|
#else /* !WITH_BIG_KEY */
|
||||||
#define xmlDictComputeKey(dict, name, len) \
|
#define xmlDictComputeKey(dict, name, len) \
|
||||||
xmlDictComputeFastKey(name, len)
|
xmlDictComputeFastKey(name, len, (dict)->seed)
|
||||||
#define xmlDictComputeQKey(dict, prefix, plen, name, len) \
|
#define xmlDictComputeQKey(dict, prefix, plen, name, len) \
|
||||||
xmlDictComputeFastQKey(prefix, plen, name, len)
|
xmlDictComputeFastQKey(prefix, plen, name, len, (dict)->seed)
|
||||||
#endif /* WITH_BIG_KEY */
|
#endif /* WITH_BIG_KEY */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -71,7 +94,7 @@ typedef xmlDictEntry *xmlDictEntryPtr;
|
||||||
struct _xmlDictEntry {
|
struct _xmlDictEntry {
|
||||||
struct _xmlDictEntry *next;
|
struct _xmlDictEntry *next;
|
||||||
const xmlChar *name;
|
const xmlChar *name;
|
||||||
int len;
|
unsigned int len;
|
||||||
int valid;
|
int valid;
|
||||||
unsigned long okey;
|
unsigned long okey;
|
||||||
};
|
};
|
||||||
|
@ -82,8 +105,8 @@ struct _xmlDictStrings {
|
||||||
xmlDictStringsPtr next;
|
xmlDictStringsPtr next;
|
||||||
xmlChar *free;
|
xmlChar *free;
|
||||||
xmlChar *end;
|
xmlChar *end;
|
||||||
int size;
|
size_t size;
|
||||||
int nbStrings;
|
size_t nbStrings;
|
||||||
xmlChar array[1];
|
xmlChar array[1];
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
|
@ -93,11 +116,15 @@ struct _xmlDict {
|
||||||
int ref_counter;
|
int ref_counter;
|
||||||
|
|
||||||
struct _xmlDictEntry *dict;
|
struct _xmlDictEntry *dict;
|
||||||
int size;
|
size_t size;
|
||||||
int nbElems;
|
unsigned int nbElems;
|
||||||
xmlDictStringsPtr strings;
|
xmlDictStringsPtr strings;
|
||||||
|
|
||||||
struct _xmlDict *subdict;
|
struct _xmlDict *subdict;
|
||||||
|
/* used for randomization */
|
||||||
|
int seed;
|
||||||
|
/* used to impose a limit on size */
|
||||||
|
size_t limit;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -111,28 +138,69 @@ static xmlRMutexPtr xmlDictMutex = NULL;
|
||||||
*/
|
*/
|
||||||
static int xmlDictInitialized = 0;
|
static int xmlDictInitialized = 0;
|
||||||
|
|
||||||
|
#ifdef DICT_RANDOMIZATION
|
||||||
|
#ifdef HAVE_RAND_R
|
||||||
|
/*
|
||||||
|
* Internal data for random function, protected by xmlDictMutex
|
||||||
|
*/
|
||||||
|
unsigned int rand_seed = 0;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlInitializeDict:
|
* xmlInitializeDict:
|
||||||
*
|
*
|
||||||
* Do the dictionary mutex initialization.
|
* Do the dictionary mutex initialization.
|
||||||
* this function is not thread safe, initialization should
|
* this function is not thread safe, initialization should
|
||||||
* preferably be done once at startup
|
* preferably be done once at startup
|
||||||
|
*
|
||||||
|
* Returns 0 if initialization was already done, and 1 if that
|
||||||
|
* call led to the initialization
|
||||||
*/
|
*/
|
||||||
static int xmlInitializeDict(void) {
|
int xmlInitializeDict(void) {
|
||||||
if (xmlDictInitialized)
|
if (xmlDictInitialized)
|
||||||
return(1);
|
return(1);
|
||||||
|
|
||||||
if ((xmlDictMutex = xmlNewRMutex()) == NULL)
|
if ((xmlDictMutex = xmlNewRMutex()) == NULL)
|
||||||
return(0);
|
return(0);
|
||||||
|
xmlRMutexLock(xmlDictMutex);
|
||||||
|
|
||||||
|
#ifdef DICT_RANDOMIZATION
|
||||||
|
#ifdef HAVE_RAND_R
|
||||||
|
rand_seed = time(NULL);
|
||||||
|
rand_r(& rand_seed);
|
||||||
|
#else
|
||||||
|
srand(time(NULL));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
xmlDictInitialized = 1;
|
xmlDictInitialized = 1;
|
||||||
|
xmlRMutexUnlock(xmlDictMutex);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DICT_RANDOMIZATION
|
||||||
|
int __xmlRandom(void) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (xmlDictInitialized == 0)
|
||||||
|
xmlInitializeDict();
|
||||||
|
|
||||||
|
xmlRMutexLock(xmlDictMutex);
|
||||||
|
#ifdef HAVE_RAND_R
|
||||||
|
ret = rand_r(& rand_seed);
|
||||||
|
#else
|
||||||
|
ret = rand();
|
||||||
|
#endif
|
||||||
|
xmlRMutexUnlock(xmlDictMutex);
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlDictCleanup:
|
* xmlDictCleanup:
|
||||||
*
|
*
|
||||||
* Free the dictionary mutex.
|
* Free the dictionary mutex. Do not call unless sure the library
|
||||||
|
* is not in use anymore !
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xmlDictCleanup(void) {
|
xmlDictCleanup(void) {
|
||||||
|
@ -148,17 +216,18 @@ xmlDictCleanup(void) {
|
||||||
* xmlDictAddString:
|
* xmlDictAddString:
|
||||||
* @dict: the dictionnary
|
* @dict: the dictionnary
|
||||||
* @name: the name of the userdata
|
* @name: the name of the userdata
|
||||||
* @len: the length of the name, if -1 it is recomputed
|
* @len: the length of the name
|
||||||
*
|
*
|
||||||
* Add the string to the array[s]
|
* Add the string to the array[s]
|
||||||
*
|
*
|
||||||
* Returns the pointer of the local string, or NULL in case of error.
|
* Returns the pointer of the local string, or NULL in case of error.
|
||||||
*/
|
*/
|
||||||
static const xmlChar *
|
static const xmlChar *
|
||||||
xmlDictAddString(xmlDictPtr dict, const xmlChar *name, int namelen) {
|
xmlDictAddString(xmlDictPtr dict, const xmlChar *name, unsigned int namelen) {
|
||||||
xmlDictStringsPtr pool;
|
xmlDictStringsPtr pool;
|
||||||
const xmlChar *ret;
|
const xmlChar *ret;
|
||||||
int size = 0; /* + sizeof(_xmlDictStrings) == 1024 */
|
size_t size = 0; /* + sizeof(_xmlDictStrings) == 1024 */
|
||||||
|
size_t limit = 0;
|
||||||
|
|
||||||
#ifdef DICT_DEBUG_PATTERNS
|
#ifdef DICT_DEBUG_PATTERNS
|
||||||
fprintf(stderr, "-");
|
fprintf(stderr, "-");
|
||||||
|
@ -168,12 +237,17 @@ xmlDictAddString(xmlDictPtr dict, const xmlChar *name, int namelen) {
|
||||||
if (pool->end - pool->free > namelen)
|
if (pool->end - pool->free > namelen)
|
||||||
goto found_pool;
|
goto found_pool;
|
||||||
if (pool->size > size) size = pool->size;
|
if (pool->size > size) size = pool->size;
|
||||||
|
limit += pool->size;
|
||||||
pool = pool->next;
|
pool = pool->next;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Not found, need to allocate
|
* Not found, need to allocate
|
||||||
*/
|
*/
|
||||||
if (pool == NULL) {
|
if (pool == NULL) {
|
||||||
|
if ((dict->limit > 0) && (limit > dict->limit)) {
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if (size == 0) size = 1000;
|
if (size == 0) size = 1000;
|
||||||
else size *= 4; /* exponential growth */
|
else size *= 4; /* exponential growth */
|
||||||
if (size < 4 * namelen)
|
if (size < 4 * namelen)
|
||||||
|
@ -206,19 +280,20 @@ found_pool:
|
||||||
* @prefix: the prefix of the userdata
|
* @prefix: the prefix of the userdata
|
||||||
* @plen: the prefix length
|
* @plen: the prefix length
|
||||||
* @name: the name of the userdata
|
* @name: the name of the userdata
|
||||||
* @len: the length of the name, if -1 it is recomputed
|
* @len: the length of the name
|
||||||
*
|
*
|
||||||
* Add the QName to the array[s]
|
* Add the QName to the array[s]
|
||||||
*
|
*
|
||||||
* Returns the pointer of the local string, or NULL in case of error.
|
* Returns the pointer of the local string, or NULL in case of error.
|
||||||
*/
|
*/
|
||||||
static const xmlChar *
|
static const xmlChar *
|
||||||
xmlDictAddQString(xmlDictPtr dict, const xmlChar *prefix, int plen,
|
xmlDictAddQString(xmlDictPtr dict, const xmlChar *prefix, unsigned int plen,
|
||||||
const xmlChar *name, int namelen)
|
const xmlChar *name, unsigned int namelen)
|
||||||
{
|
{
|
||||||
xmlDictStringsPtr pool;
|
xmlDictStringsPtr pool;
|
||||||
const xmlChar *ret;
|
const xmlChar *ret;
|
||||||
int size = 0; /* + sizeof(_xmlDictStrings) == 1024 */
|
size_t size = 0; /* + sizeof(_xmlDictStrings) == 1024 */
|
||||||
|
size_t limit = 0;
|
||||||
|
|
||||||
if (prefix == NULL) return(xmlDictAddString(dict, name, namelen));
|
if (prefix == NULL) return(xmlDictAddString(dict, name, namelen));
|
||||||
|
|
||||||
|
@ -230,12 +305,17 @@ xmlDictAddQString(xmlDictPtr dict, const xmlChar *prefix, int plen,
|
||||||
if (pool->end - pool->free > namelen + plen + 1)
|
if (pool->end - pool->free > namelen + plen + 1)
|
||||||
goto found_pool;
|
goto found_pool;
|
||||||
if (pool->size > size) size = pool->size;
|
if (pool->size > size) size = pool->size;
|
||||||
|
limit += pool->size;
|
||||||
pool = pool->next;
|
pool = pool->next;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Not found, need to allocate
|
* Not found, need to allocate
|
||||||
*/
|
*/
|
||||||
if (pool == NULL) {
|
if (pool == NULL) {
|
||||||
|
if ((dict->limit > 0) && (limit > dict->limit)) {
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if (size == 0) size = 1000;
|
if (size == 0) size = 1000;
|
||||||
else size *= 4; /* exponential growth */
|
else size *= 4; /* exponential growth */
|
||||||
if (size < 4 * (namelen + plen + 1))
|
if (size < 4 * (namelen + plen + 1))
|
||||||
|
@ -277,13 +357,13 @@ found_pool:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static uint32_t
|
static uint32_t
|
||||||
xmlDictComputeBigKey(const xmlChar* data, int namelen) {
|
xmlDictComputeBigKey(const xmlChar* data, int namelen, int seed) {
|
||||||
uint32_t hash;
|
uint32_t hash;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (namelen <= 0 || data == NULL) return(0);
|
if (namelen <= 0 || data == NULL) return(0);
|
||||||
|
|
||||||
hash = 0;
|
hash = seed;
|
||||||
|
|
||||||
for (i = 0;i < namelen; i++) {
|
for (i = 0;i < namelen; i++) {
|
||||||
hash += data[i];
|
hash += data[i];
|
||||||
|
@ -310,12 +390,12 @@ xmlDictComputeBigKey(const xmlChar* data, int namelen) {
|
||||||
*/
|
*/
|
||||||
static unsigned long
|
static unsigned long
|
||||||
xmlDictComputeBigQKey(const xmlChar *prefix, int plen,
|
xmlDictComputeBigQKey(const xmlChar *prefix, int plen,
|
||||||
const xmlChar *name, int len)
|
const xmlChar *name, int len, int seed)
|
||||||
{
|
{
|
||||||
uint32_t hash;
|
uint32_t hash;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
hash = 0;
|
hash = seed;
|
||||||
|
|
||||||
for (i = 0;i < plen; i++) {
|
for (i = 0;i < plen; i++) {
|
||||||
hash += prefix[i];
|
hash += prefix[i];
|
||||||
|
@ -346,8 +426,8 @@ xmlDictComputeBigQKey(const xmlChar *prefix, int plen,
|
||||||
* for low hash table fill.
|
* for low hash table fill.
|
||||||
*/
|
*/
|
||||||
static unsigned long
|
static unsigned long
|
||||||
xmlDictComputeFastKey(const xmlChar *name, int namelen) {
|
xmlDictComputeFastKey(const xmlChar *name, int namelen, int seed) {
|
||||||
unsigned long value = 0L;
|
unsigned long value = seed;
|
||||||
|
|
||||||
if (name == NULL) return(0);
|
if (name == NULL) return(0);
|
||||||
value = *name;
|
value = *name;
|
||||||
|
@ -381,9 +461,9 @@ xmlDictComputeFastKey(const xmlChar *name, int namelen) {
|
||||||
*/
|
*/
|
||||||
static unsigned long
|
static unsigned long
|
||||||
xmlDictComputeFastQKey(const xmlChar *prefix, int plen,
|
xmlDictComputeFastQKey(const xmlChar *prefix, int plen,
|
||||||
const xmlChar *name, int len)
|
const xmlChar *name, int len, int seed)
|
||||||
{
|
{
|
||||||
unsigned long value = 0L;
|
unsigned long value = (unsigned long) seed;
|
||||||
|
|
||||||
if (plen == 0)
|
if (plen == 0)
|
||||||
value += 30 * (unsigned long) ':';
|
value += 30 * (unsigned long) ':';
|
||||||
|
@ -452,6 +532,7 @@ xmlDictCreate(void) {
|
||||||
dict = xmlMalloc(sizeof(xmlDict));
|
dict = xmlMalloc(sizeof(xmlDict));
|
||||||
if (dict) {
|
if (dict) {
|
||||||
dict->ref_counter = 1;
|
dict->ref_counter = 1;
|
||||||
|
dict->limit = 0;
|
||||||
|
|
||||||
dict->size = MIN_DICT_SIZE;
|
dict->size = MIN_DICT_SIZE;
|
||||||
dict->nbElems = 0;
|
dict->nbElems = 0;
|
||||||
|
@ -460,6 +541,11 @@ xmlDictCreate(void) {
|
||||||
dict->subdict = NULL;
|
dict->subdict = NULL;
|
||||||
if (dict->dict) {
|
if (dict->dict) {
|
||||||
memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry));
|
memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry));
|
||||||
|
#ifdef DICT_RANDOMIZATION
|
||||||
|
dict->seed = __xmlRandom();
|
||||||
|
#else
|
||||||
|
dict->seed = 0;
|
||||||
|
#endif
|
||||||
return(dict);
|
return(dict);
|
||||||
}
|
}
|
||||||
xmlFree(dict);
|
xmlFree(dict);
|
||||||
|
@ -486,6 +572,7 @@ xmlDictCreateSub(xmlDictPtr sub) {
|
||||||
#ifdef DICT_DEBUG_PATTERNS
|
#ifdef DICT_DEBUG_PATTERNS
|
||||||
fprintf(stderr, "R");
|
fprintf(stderr, "R");
|
||||||
#endif
|
#endif
|
||||||
|
dict->seed = sub->seed;
|
||||||
dict->subdict = sub;
|
dict->subdict = sub;
|
||||||
xmlDictReference(dict->subdict);
|
xmlDictReference(dict->subdict);
|
||||||
}
|
}
|
||||||
|
@ -523,9 +610,9 @@ xmlDictReference(xmlDictPtr dict) {
|
||||||
* Returns 0 in case of success, -1 in case of failure
|
* Returns 0 in case of success, -1 in case of failure
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xmlDictGrow(xmlDictPtr dict, int size) {
|
xmlDictGrow(xmlDictPtr dict, size_t size) {
|
||||||
unsigned long key, okey;
|
unsigned long key, okey;
|
||||||
int oldsize, i;
|
size_t oldsize, i;
|
||||||
xmlDictEntryPtr iter, next;
|
xmlDictEntryPtr iter, next;
|
||||||
struct _xmlDictEntry *olddict;
|
struct _xmlDictEntry *olddict;
|
||||||
#ifdef DEBUG_GROW
|
#ifdef DEBUG_GROW
|
||||||
|
@ -642,7 +729,7 @@ xmlDictGrow(xmlDictPtr dict, int size) {
|
||||||
|
|
||||||
#ifdef DEBUG_GROW
|
#ifdef DEBUG_GROW
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlDictGrow : from %d to %d, %d elems\n", oldsize, size, nbElem);
|
"xmlDictGrow : from %lu to %lu, %u elems\n", oldsize, size, nbElem);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return(ret);
|
return(ret);
|
||||||
|
@ -657,7 +744,7 @@ xmlDictGrow(xmlDictPtr dict, int size) {
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xmlDictFree(xmlDictPtr dict) {
|
xmlDictFree(xmlDictPtr dict) {
|
||||||
int i;
|
size_t i;
|
||||||
xmlDictEntryPtr iter;
|
xmlDictEntryPtr iter;
|
||||||
xmlDictEntryPtr next;
|
xmlDictEntryPtr next;
|
||||||
int inside_dict = 0;
|
int inside_dict = 0;
|
||||||
|
@ -726,17 +813,24 @@ xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len) {
|
||||||
xmlDictEntryPtr entry;
|
xmlDictEntryPtr entry;
|
||||||
xmlDictEntryPtr insert;
|
xmlDictEntryPtr insert;
|
||||||
const xmlChar *ret;
|
const xmlChar *ret;
|
||||||
|
unsigned int l;
|
||||||
|
|
||||||
if ((dict == NULL) || (name == NULL))
|
if ((dict == NULL) || (name == NULL))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
len = strlen((const char *) name);
|
l = strlen((const char *) name);
|
||||||
|
else
|
||||||
|
l = len;
|
||||||
|
|
||||||
|
if (((dict->limit > 0) && (l >= dict->limit)) ||
|
||||||
|
(l > INT_MAX / 2))
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for duplicate and insertion location.
|
* Check for duplicate and insertion location.
|
||||||
*/
|
*/
|
||||||
okey = xmlDictComputeKey(dict, name, len);
|
okey = xmlDictComputeKey(dict, name, l);
|
||||||
key = okey % dict->size;
|
key = okey % dict->size;
|
||||||
if (dict->dict[key].valid == 0) {
|
if (dict->dict[key].valid == 0) {
|
||||||
insert = NULL;
|
insert = NULL;
|
||||||
|
@ -744,25 +838,25 @@ xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len) {
|
||||||
for (insert = &(dict->dict[key]); insert->next != NULL;
|
for (insert = &(dict->dict[key]); insert->next != NULL;
|
||||||
insert = insert->next) {
|
insert = insert->next) {
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
if ((insert->okey == okey) && (insert->len == len)) {
|
if ((insert->okey == okey) && (insert->len == l)) {
|
||||||
if (!memcmp(insert->name, name, len))
|
if (!memcmp(insert->name, name, l))
|
||||||
return(insert->name);
|
return(insert->name);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((insert->okey == okey) && (insert->len == len) &&
|
if ((insert->okey == okey) && (insert->len == l) &&
|
||||||
(!xmlStrncmp(insert->name, name, len)))
|
(!xmlStrncmp(insert->name, name, l)))
|
||||||
return(insert->name);
|
return(insert->name);
|
||||||
#endif
|
#endif
|
||||||
nbi++;
|
nbi++;
|
||||||
}
|
}
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
if ((insert->okey == okey) && (insert->len == len)) {
|
if ((insert->okey == okey) && (insert->len == l)) {
|
||||||
if (!memcmp(insert->name, name, len))
|
if (!memcmp(insert->name, name, l))
|
||||||
return(insert->name);
|
return(insert->name);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((insert->okey == okey) && (insert->len == len) &&
|
if ((insert->okey == okey) && (insert->len == l) &&
|
||||||
(!xmlStrncmp(insert->name, name, len)))
|
(!xmlStrncmp(insert->name, name, l)))
|
||||||
return(insert->name);
|
return(insert->name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -775,7 +869,7 @@ xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len) {
|
||||||
(dict->subdict->size != MIN_DICT_SIZE)) ||
|
(dict->subdict->size != MIN_DICT_SIZE)) ||
|
||||||
((dict->size != MIN_DICT_SIZE) &&
|
((dict->size != MIN_DICT_SIZE) &&
|
||||||
(dict->subdict->size == MIN_DICT_SIZE)))
|
(dict->subdict->size == MIN_DICT_SIZE)))
|
||||||
skey = xmlDictComputeKey(dict->subdict, name, len);
|
skey = xmlDictComputeKey(dict->subdict, name, l);
|
||||||
else
|
else
|
||||||
skey = okey;
|
skey = okey;
|
||||||
|
|
||||||
|
@ -786,32 +880,32 @@ xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len) {
|
||||||
for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
|
for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
|
||||||
tmp = tmp->next) {
|
tmp = tmp->next) {
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
if ((tmp->okey == skey) && (tmp->len == len)) {
|
if ((tmp->okey == skey) && (tmp->len == l)) {
|
||||||
if (!memcmp(tmp->name, name, len))
|
if (!memcmp(tmp->name, name, l))
|
||||||
return(tmp->name);
|
return(tmp->name);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((tmp->okey == skey) && (tmp->len == len) &&
|
if ((tmp->okey == skey) && (tmp->len == l) &&
|
||||||
(!xmlStrncmp(tmp->name, name, len)))
|
(!xmlStrncmp(tmp->name, name, l)))
|
||||||
return(tmp->name);
|
return(tmp->name);
|
||||||
#endif
|
#endif
|
||||||
nbi++;
|
nbi++;
|
||||||
}
|
}
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
if ((tmp->okey == skey) && (tmp->len == len)) {
|
if ((tmp->okey == skey) && (tmp->len == l)) {
|
||||||
if (!memcmp(tmp->name, name, len))
|
if (!memcmp(tmp->name, name, l))
|
||||||
return(tmp->name);
|
return(tmp->name);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((tmp->okey == skey) && (tmp->len == len) &&
|
if ((tmp->okey == skey) && (tmp->len == l) &&
|
||||||
(!xmlStrncmp(tmp->name, name, len)))
|
(!xmlStrncmp(tmp->name, name, l)))
|
||||||
return(tmp->name);
|
return(tmp->name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
key = okey % dict->size;
|
key = okey % dict->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = xmlDictAddString(dict, name, len);
|
ret = xmlDictAddString(dict, name, l);
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
return(NULL);
|
return(NULL);
|
||||||
if (insert == NULL) {
|
if (insert == NULL) {
|
||||||
|
@ -822,7 +916,7 @@ xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
entry->name = ret;
|
entry->name = ret;
|
||||||
entry->len = len;
|
entry->len = l;
|
||||||
entry->next = NULL;
|
entry->next = NULL;
|
||||||
entry->valid = 1;
|
entry->valid = 1;
|
||||||
entry->okey = okey;
|
entry->okey = okey;
|
||||||
|
@ -857,17 +951,23 @@ const xmlChar *
|
||||||
xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) {
|
xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) {
|
||||||
unsigned long key, okey, nbi = 0;
|
unsigned long key, okey, nbi = 0;
|
||||||
xmlDictEntryPtr insert;
|
xmlDictEntryPtr insert;
|
||||||
|
unsigned int l;
|
||||||
|
|
||||||
if ((dict == NULL) || (name == NULL))
|
if ((dict == NULL) || (name == NULL))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
len = strlen((const char *) name);
|
l = strlen((const char *) name);
|
||||||
|
else
|
||||||
|
l = len;
|
||||||
|
if (((dict->limit > 0) && (l >= dict->limit)) ||
|
||||||
|
(l > INT_MAX / 2))
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for duplicate and insertion location.
|
* Check for duplicate and insertion location.
|
||||||
*/
|
*/
|
||||||
okey = xmlDictComputeKey(dict, name, len);
|
okey = xmlDictComputeKey(dict, name, l);
|
||||||
key = okey % dict->size;
|
key = okey % dict->size;
|
||||||
if (dict->dict[key].valid == 0) {
|
if (dict->dict[key].valid == 0) {
|
||||||
insert = NULL;
|
insert = NULL;
|
||||||
|
@ -875,25 +975,25 @@ xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) {
|
||||||
for (insert = &(dict->dict[key]); insert->next != NULL;
|
for (insert = &(dict->dict[key]); insert->next != NULL;
|
||||||
insert = insert->next) {
|
insert = insert->next) {
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
if ((insert->okey == okey) && (insert->len == len)) {
|
if ((insert->okey == okey) && (insert->len == l)) {
|
||||||
if (!memcmp(insert->name, name, len))
|
if (!memcmp(insert->name, name, l))
|
||||||
return(insert->name);
|
return(insert->name);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((insert->okey == okey) && (insert->len == len) &&
|
if ((insert->okey == okey) && (insert->len == l) &&
|
||||||
(!xmlStrncmp(insert->name, name, len)))
|
(!xmlStrncmp(insert->name, name, l)))
|
||||||
return(insert->name);
|
return(insert->name);
|
||||||
#endif
|
#endif
|
||||||
nbi++;
|
nbi++;
|
||||||
}
|
}
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
if ((insert->okey == okey) && (insert->len == len)) {
|
if ((insert->okey == okey) && (insert->len == l)) {
|
||||||
if (!memcmp(insert->name, name, len))
|
if (!memcmp(insert->name, name, l))
|
||||||
return(insert->name);
|
return(insert->name);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((insert->okey == okey) && (insert->len == len) &&
|
if ((insert->okey == okey) && (insert->len == l) &&
|
||||||
(!xmlStrncmp(insert->name, name, len)))
|
(!xmlStrncmp(insert->name, name, l)))
|
||||||
return(insert->name);
|
return(insert->name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -906,7 +1006,7 @@ xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) {
|
||||||
(dict->subdict->size != MIN_DICT_SIZE)) ||
|
(dict->subdict->size != MIN_DICT_SIZE)) ||
|
||||||
((dict->size != MIN_DICT_SIZE) &&
|
((dict->size != MIN_DICT_SIZE) &&
|
||||||
(dict->subdict->size == MIN_DICT_SIZE)))
|
(dict->subdict->size == MIN_DICT_SIZE)))
|
||||||
skey = xmlDictComputeKey(dict->subdict, name, len);
|
skey = xmlDictComputeKey(dict->subdict, name, l);
|
||||||
else
|
else
|
||||||
skey = okey;
|
skey = okey;
|
||||||
|
|
||||||
|
@ -917,25 +1017,25 @@ xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) {
|
||||||
for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
|
for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
|
||||||
tmp = tmp->next) {
|
tmp = tmp->next) {
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
if ((tmp->okey == skey) && (tmp->len == len)) {
|
if ((tmp->okey == skey) && (tmp->len == l)) {
|
||||||
if (!memcmp(tmp->name, name, len))
|
if (!memcmp(tmp->name, name, l))
|
||||||
return(tmp->name);
|
return(tmp->name);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((tmp->okey == skey) && (tmp->len == len) &&
|
if ((tmp->okey == skey) && (tmp->len == l) &&
|
||||||
(!xmlStrncmp(tmp->name, name, len)))
|
(!xmlStrncmp(tmp->name, name, l)))
|
||||||
return(tmp->name);
|
return(tmp->name);
|
||||||
#endif
|
#endif
|
||||||
nbi++;
|
nbi++;
|
||||||
}
|
}
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
if ((tmp->okey == skey) && (tmp->len == len)) {
|
if ((tmp->okey == skey) && (tmp->len == l)) {
|
||||||
if (!memcmp(tmp->name, name, len))
|
if (!memcmp(tmp->name, name, l))
|
||||||
return(tmp->name);
|
return(tmp->name);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if ((tmp->okey == skey) && (tmp->len == len) &&
|
if ((tmp->okey == skey) && (tmp->len == l) &&
|
||||||
(!xmlStrncmp(tmp->name, name, len)))
|
(!xmlStrncmp(tmp->name, name, l)))
|
||||||
return(tmp->name);
|
return(tmp->name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -961,7 +1061,7 @@ xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) {
|
||||||
xmlDictEntryPtr entry;
|
xmlDictEntryPtr entry;
|
||||||
xmlDictEntryPtr insert;
|
xmlDictEntryPtr insert;
|
||||||
const xmlChar *ret;
|
const xmlChar *ret;
|
||||||
int len, plen, l;
|
unsigned int len, plen, l;
|
||||||
|
|
||||||
if ((dict == NULL) || (name == NULL))
|
if ((dict == NULL) || (name == NULL))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
@ -1095,6 +1195,50 @@ xmlDictSize(xmlDictPtr dict) {
|
||||||
return(dict->nbElems);
|
return(dict->nbElems);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlDictSetLimit:
|
||||||
|
* @dict: the dictionnary
|
||||||
|
* @limit: the limit in bytes
|
||||||
|
*
|
||||||
|
* Set a size limit for the dictionary
|
||||||
|
* Added in 2.9.0
|
||||||
|
*
|
||||||
|
* Returns the previous limit of the dictionary or 0
|
||||||
|
*/
|
||||||
|
size_t
|
||||||
|
xmlDictSetLimit(xmlDictPtr dict, size_t limit) {
|
||||||
|
size_t ret;
|
||||||
|
|
||||||
|
if (dict == NULL)
|
||||||
|
return(0);
|
||||||
|
ret = dict->limit;
|
||||||
|
dict->limit = limit;
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlDictGetUsage:
|
||||||
|
* @dict: the dictionnary
|
||||||
|
*
|
||||||
|
* Get how much memory is used by a dictionary for strings
|
||||||
|
* Added in 2.9.0
|
||||||
|
*
|
||||||
|
* Returns the amount of strings allocated
|
||||||
|
*/
|
||||||
|
size_t
|
||||||
|
xmlDictGetUsage(xmlDictPtr dict) {
|
||||||
|
xmlDictStringsPtr pool;
|
||||||
|
size_t limit = 0;
|
||||||
|
|
||||||
|
if (dict == NULL)
|
||||||
|
return(0);
|
||||||
|
pool = dict->strings;
|
||||||
|
while (pool != NULL) {
|
||||||
|
limit += pool->size;
|
||||||
|
pool = pool->next;
|
||||||
|
}
|
||||||
|
return(limit);
|
||||||
|
}
|
||||||
|
|
||||||
#define bottom_dict
|
#define bottom_dict
|
||||||
#include "elfgcchack.h"
|
#include "elfgcchack.h"
|
||||||
|
|
32
reactos/lib/3rdparty/libxml2/enc.h
vendored
Normal file
32
reactos/lib/3rdparty/libxml2/enc.h
vendored
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Summary: Internal Interfaces for encoding in libxml2
|
||||||
|
* Description: this module describes a few interfaces which were
|
||||||
|
* addded along with the API changes in 2.9.0
|
||||||
|
* those are private routines at this point
|
||||||
|
*
|
||||||
|
* Copy: See Copyright for the status of this software.
|
||||||
|
*
|
||||||
|
* Author: Daniel Veillard
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XML_ENC_H__
|
||||||
|
#define __XML_ENC_H__
|
||||||
|
|
||||||
|
#include <libxml/tree.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
|
||||||
|
xmlBufferPtr in, int len);
|
||||||
|
int xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len);
|
||||||
|
int xmlCharEncInput(xmlParserInputBufferPtr input);
|
||||||
|
int xmlCharEncOutput(xmlOutputBufferPtr output, int init);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* __XML_ENC_H__ */
|
||||||
|
|
||||||
|
|
507
reactos/lib/3rdparty/libxml2/encoding.c
vendored
507
reactos/lib/3rdparty/libxml2/encoding.c
vendored
|
@ -24,6 +24,7 @@
|
||||||
#include "libxml.h"
|
#include "libxml.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#ifdef HAVE_CTYPE_H
|
#ifdef HAVE_CTYPE_H
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -44,6 +45,9 @@
|
||||||
#include <libxml/globals.h>
|
#include <libxml/globals.h>
|
||||||
#include <libxml/xmlerror.h>
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
|
#include "buf.h"
|
||||||
|
#include "enc.h"
|
||||||
|
|
||||||
static xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;
|
static xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;
|
||||||
static xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;
|
static xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;
|
||||||
|
|
||||||
|
@ -1897,9 +1901,6 @@ xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen,
|
||||||
* The real API used by libxml for on-the-fly conversion *
|
* The real API used by libxml for on-the-fly conversion *
|
||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
int
|
|
||||||
xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
|
|
||||||
xmlBufferPtr in, int len);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlCharEncFirstLineInt:
|
* xmlCharEncFirstLineInt:
|
||||||
|
@ -1928,7 +1929,7 @@ xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
|
||||||
if (in == NULL) return(-1);
|
if (in == NULL) return(-1);
|
||||||
|
|
||||||
/* calculate space available */
|
/* calculate space available */
|
||||||
written = out->size - out->use;
|
written = out->size - out->use - 1; /* count '\0' */
|
||||||
toconv = in->use;
|
toconv = in->use;
|
||||||
/*
|
/*
|
||||||
* echo '<?xml version="1.0" encoding="UCS4"?>' | wc -c => 38
|
* echo '<?xml version="1.0" encoding="UCS4"?>' | wc -c => 38
|
||||||
|
@ -1946,7 +1947,7 @@ xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
|
||||||
toconv = 180;
|
toconv = 180;
|
||||||
}
|
}
|
||||||
if (toconv * 2 >= written) {
|
if (toconv * 2 >= written) {
|
||||||
xmlBufferGrow(out, toconv);
|
xmlBufferGrow(out, toconv * 2);
|
||||||
written = out->size - out->use - 1;
|
written = out->size - out->use - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2028,6 +2029,251 @@ xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
|
||||||
return(xmlCharEncFirstLineInt(handler, out, in, -1));
|
return(xmlCharEncFirstLineInt(handler, out, in, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlCharEncFirstLineInput:
|
||||||
|
* @input: a parser input buffer
|
||||||
|
* @len: number of bytes to convert for the first line, or -1
|
||||||
|
*
|
||||||
|
* Front-end for the encoding handler input function, but handle only
|
||||||
|
* the very first line. Point is that this is based on autodetection
|
||||||
|
* of the encoding and once that first line is converted we may find
|
||||||
|
* out that a different decoder is needed to process the input.
|
||||||
|
*
|
||||||
|
* Returns the number of byte written if success, or
|
||||||
|
* -1 general error
|
||||||
|
* -2 if the transcoding fails (for *in is not valid utf8 string or
|
||||||
|
* the result of transformation can't fit into the encoding we want), or
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len)
|
||||||
|
{
|
||||||
|
int ret = -2;
|
||||||
|
size_t written;
|
||||||
|
size_t toconv;
|
||||||
|
int c_in;
|
||||||
|
int c_out;
|
||||||
|
xmlBufPtr in;
|
||||||
|
xmlBufPtr out;
|
||||||
|
|
||||||
|
if ((input == NULL) || (input->encoder == NULL) ||
|
||||||
|
(input->buffer == NULL) || (input->raw == NULL))
|
||||||
|
return (-1);
|
||||||
|
out = input->buffer;
|
||||||
|
in = input->raw;
|
||||||
|
|
||||||
|
toconv = xmlBufUse(in);
|
||||||
|
if (toconv == 0)
|
||||||
|
return (0);
|
||||||
|
written = xmlBufAvail(out) - 1; /* count '\0' */
|
||||||
|
/*
|
||||||
|
* echo '<?xml version="1.0" encoding="UCS4"?>' | wc -c => 38
|
||||||
|
* 45 chars should be sufficient to reach the end of the encoding
|
||||||
|
* declaration without going too far inside the document content.
|
||||||
|
* on UTF-16 this means 90bytes, on UCS4 this means 180
|
||||||
|
* The actual value depending on guessed encoding is passed as @len
|
||||||
|
* if provided
|
||||||
|
*/
|
||||||
|
if (len >= 0) {
|
||||||
|
if (toconv > (unsigned int) len)
|
||||||
|
toconv = len;
|
||||||
|
} else {
|
||||||
|
if (toconv > 180)
|
||||||
|
toconv = 180;
|
||||||
|
}
|
||||||
|
if (toconv * 2 >= written) {
|
||||||
|
xmlBufGrow(out, toconv * 2);
|
||||||
|
written = xmlBufAvail(out) - 1;
|
||||||
|
}
|
||||||
|
if (written > 360)
|
||||||
|
written = 360;
|
||||||
|
|
||||||
|
c_in = toconv;
|
||||||
|
c_out = written;
|
||||||
|
if (input->encoder->input != NULL) {
|
||||||
|
ret = input->encoder->input(xmlBufEnd(out), &c_out,
|
||||||
|
xmlBufContent(in), &c_in);
|
||||||
|
xmlBufShrink(in, c_in);
|
||||||
|
xmlBufAddLen(out, c_out);
|
||||||
|
}
|
||||||
|
#ifdef LIBXML_ICONV_ENABLED
|
||||||
|
else if (input->encoder->iconv_in != NULL) {
|
||||||
|
ret = xmlIconvWrapper(input->encoder->iconv_in, xmlBufEnd(out),
|
||||||
|
&c_out, xmlBufContent(in), &c_in);
|
||||||
|
xmlBufShrink(in, c_in);
|
||||||
|
xmlBufAddLen(out, c_out);
|
||||||
|
if (ret == -1)
|
||||||
|
ret = -3;
|
||||||
|
}
|
||||||
|
#endif /* LIBXML_ICONV_ENABLED */
|
||||||
|
#ifdef LIBXML_ICU_ENABLED
|
||||||
|
else if (input->encoder->uconv_in != NULL) {
|
||||||
|
ret = xmlUconvWrapper(input->encoder->uconv_in, 1, xmlBufEnd(out),
|
||||||
|
&c_out, xmlBufContent(in), &c_in);
|
||||||
|
xmlBufShrink(in, c_in);
|
||||||
|
xmlBufAddLen(out, c_out);
|
||||||
|
if (ret == -1)
|
||||||
|
ret = -3;
|
||||||
|
}
|
||||||
|
#endif /* LIBXML_ICU_ENABLED */
|
||||||
|
switch (ret) {
|
||||||
|
case 0:
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"converted %d bytes to %d bytes of input\n",
|
||||||
|
c_in, c_out);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"converted %d bytes to %d bytes of input, %d left\n",
|
||||||
|
c_in, c_out, (int)xmlBufUse(in));
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case -3:
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"converted %d bytes to %d bytes of input, %d left\n",
|
||||||
|
c_in, c_out, (int)xmlBufUse(in));
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case -2: {
|
||||||
|
char buf[50];
|
||||||
|
const xmlChar *content = xmlBufContent(in);
|
||||||
|
|
||||||
|
snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
|
||||||
|
content[0], content[1],
|
||||||
|
content[2], content[3]);
|
||||||
|
buf[49] = 0;
|
||||||
|
xmlEncodingErr(XML_I18N_CONV_FAILED,
|
||||||
|
"input conversion failed due to input error, bytes %s\n",
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Ignore when input buffer is not on a boundary
|
||||||
|
*/
|
||||||
|
if (ret == -3) ret = 0;
|
||||||
|
if (ret == -1) ret = 0;
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlCharEncInput:
|
||||||
|
* @input: a parser input buffer
|
||||||
|
*
|
||||||
|
* Generic front-end for the encoding handler on parser input
|
||||||
|
*
|
||||||
|
* Returns the number of byte written if success, or
|
||||||
|
* -1 general error
|
||||||
|
* -2 if the transcoding fails (for *in is not valid utf8 string or
|
||||||
|
* the result of transformation can't fit into the encoding we want), or
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xmlCharEncInput(xmlParserInputBufferPtr input)
|
||||||
|
{
|
||||||
|
int ret = -2;
|
||||||
|
size_t written;
|
||||||
|
size_t toconv;
|
||||||
|
int c_in;
|
||||||
|
int c_out;
|
||||||
|
xmlBufPtr in;
|
||||||
|
xmlBufPtr out;
|
||||||
|
|
||||||
|
if ((input == NULL) || (input->encoder == NULL) ||
|
||||||
|
(input->buffer == NULL) || (input->raw == NULL))
|
||||||
|
return (-1);
|
||||||
|
out = input->buffer;
|
||||||
|
in = input->raw;
|
||||||
|
|
||||||
|
toconv = xmlBufUse(in);
|
||||||
|
if (toconv == 0)
|
||||||
|
return (0);
|
||||||
|
if (toconv > 64 * 1024)
|
||||||
|
toconv = 64 * 1024;
|
||||||
|
written = xmlBufAvail(out);
|
||||||
|
if (written > 0)
|
||||||
|
written--; /* count '\0' */
|
||||||
|
if (toconv * 2 >= written) {
|
||||||
|
xmlBufGrow(out, toconv * 2);
|
||||||
|
written = xmlBufAvail(out);
|
||||||
|
if (written > 0)
|
||||||
|
written--; /* count '\0' */
|
||||||
|
}
|
||||||
|
if (written > 128 * 1024)
|
||||||
|
written = 128 * 1024;
|
||||||
|
|
||||||
|
c_in = toconv;
|
||||||
|
c_out = written;
|
||||||
|
if (input->encoder->input != NULL) {
|
||||||
|
ret = input->encoder->input(xmlBufEnd(out), &c_out,
|
||||||
|
xmlBufContent(in), &c_in);
|
||||||
|
xmlBufShrink(in, c_in);
|
||||||
|
xmlBufAddLen(out, c_out);
|
||||||
|
}
|
||||||
|
#ifdef LIBXML_ICONV_ENABLED
|
||||||
|
else if (input->encoder->iconv_in != NULL) {
|
||||||
|
ret = xmlIconvWrapper(input->encoder->iconv_in, xmlBufEnd(out),
|
||||||
|
&c_out, xmlBufContent(in), &c_in);
|
||||||
|
xmlBufShrink(in, c_in);
|
||||||
|
xmlBufAddLen(out, c_out);
|
||||||
|
if (ret == -1)
|
||||||
|
ret = -3;
|
||||||
|
}
|
||||||
|
#endif /* LIBXML_ICONV_ENABLED */
|
||||||
|
#ifdef LIBXML_ICU_ENABLED
|
||||||
|
else if (input->encoder->uconv_in != NULL) {
|
||||||
|
ret = xmlUconvWrapper(input->encoder->uconv_in, 1, xmlBufEnd(out),
|
||||||
|
&c_out, xmlBufContent(in), &c_in);
|
||||||
|
xmlBufShrink(in, c_in);
|
||||||
|
xmlBufAddLen(out, c_out);
|
||||||
|
if (ret == -1)
|
||||||
|
ret = -3;
|
||||||
|
}
|
||||||
|
#endif /* LIBXML_ICU_ENABLED */
|
||||||
|
switch (ret) {
|
||||||
|
case 0:
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"converted %d bytes to %d bytes of input\n",
|
||||||
|
c_in, c_out);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"converted %d bytes to %d bytes of input, %d left\n",
|
||||||
|
c_in, c_out, (int)xmlBufUse(in));
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case -3:
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"converted %d bytes to %d bytes of input, %d left\n",
|
||||||
|
c_in, c_out, (int)xmlBufUse(in));
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case -2: {
|
||||||
|
char buf[50];
|
||||||
|
const xmlChar *content = xmlBufContent(in);
|
||||||
|
|
||||||
|
snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
|
||||||
|
content[0], content[1],
|
||||||
|
content[2], content[3]);
|
||||||
|
buf[49] = 0;
|
||||||
|
xmlEncodingErr(XML_I18N_CONV_FAILED,
|
||||||
|
"input conversion failed due to input error, bytes %s\n",
|
||||||
|
buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Ignore when input buffer is not on a boundary
|
||||||
|
*/
|
||||||
|
if (ret == -3)
|
||||||
|
ret = 0;
|
||||||
|
return (c_out? c_out : ret);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlCharEncInFunc:
|
* xmlCharEncInFunc:
|
||||||
* @handler: char encoding transformation data structure
|
* @handler: char encoding transformation data structure
|
||||||
|
@ -2059,7 +2305,7 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
|
||||||
toconv = in->use;
|
toconv = in->use;
|
||||||
if (toconv == 0)
|
if (toconv == 0)
|
||||||
return (0);
|
return (0);
|
||||||
written = out->size - out->use;
|
written = out->size - out->use -1; /* count '\0' */
|
||||||
if (toconv * 2 >= written) {
|
if (toconv * 2 >= written) {
|
||||||
xmlBufferGrow(out, out->size + toconv * 2);
|
xmlBufferGrow(out, out->size + toconv * 2);
|
||||||
written = out->size - out->use - 1;
|
written = out->size - out->use - 1;
|
||||||
|
@ -2135,6 +2381,235 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
|
||||||
return (written? written : ret);
|
return (written? written : ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlCharEncOutput:
|
||||||
|
* @output: a parser output buffer
|
||||||
|
* @init: is this an initialization call without data
|
||||||
|
*
|
||||||
|
* Generic front-end for the encoding handler on parser output
|
||||||
|
* a first call with @init == 1 has to be made first to initiate the
|
||||||
|
* output in case of non-stateless encoding needing to initiate their
|
||||||
|
* state or the output (like the BOM in UTF16).
|
||||||
|
* In case of UTF8 sequence conversion errors for the given encoder,
|
||||||
|
* the content will be automatically remapped to a CharRef sequence.
|
||||||
|
*
|
||||||
|
* Returns the number of byte written if success, or
|
||||||
|
* -1 general error
|
||||||
|
* -2 if the transcoding fails (for *in is not valid utf8 string or
|
||||||
|
* the result of transformation can't fit into the encoding we want), or
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xmlCharEncOutput(xmlOutputBufferPtr output, int init)
|
||||||
|
{
|
||||||
|
int ret = -2;
|
||||||
|
size_t written;
|
||||||
|
size_t writtentot = 0;
|
||||||
|
size_t toconv;
|
||||||
|
int c_in;
|
||||||
|
int c_out;
|
||||||
|
xmlBufPtr in;
|
||||||
|
xmlBufPtr out;
|
||||||
|
int charref_len = 0;
|
||||||
|
|
||||||
|
if ((output == NULL) || (output->encoder == NULL) ||
|
||||||
|
(output->buffer == NULL) || (output->conv == NULL))
|
||||||
|
return (-1);
|
||||||
|
out = output->conv;
|
||||||
|
in = output->buffer;
|
||||||
|
|
||||||
|
retry:
|
||||||
|
|
||||||
|
written = xmlBufAvail(out);
|
||||||
|
if (written > 0)
|
||||||
|
written--; /* count '\0' */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First specific handling of the initialization call
|
||||||
|
*/
|
||||||
|
if (init) {
|
||||||
|
c_in = 0;
|
||||||
|
c_out = written;
|
||||||
|
if (output->encoder->output != NULL) {
|
||||||
|
ret = output->encoder->output(xmlBufEnd(out), &c_out,
|
||||||
|
NULL, &c_in);
|
||||||
|
if (ret > 0) /* Gennady: check return value */
|
||||||
|
xmlBufAddLen(out, c_out);
|
||||||
|
}
|
||||||
|
#ifdef LIBXML_ICONV_ENABLED
|
||||||
|
else if (output->encoder->iconv_out != NULL) {
|
||||||
|
ret = xmlIconvWrapper(output->encoder->iconv_out, xmlBufEnd(out),
|
||||||
|
&c_out, NULL, &c_in);
|
||||||
|
xmlBufAddLen(out, c_out);
|
||||||
|
}
|
||||||
|
#endif /* LIBXML_ICONV_ENABLED */
|
||||||
|
#ifdef LIBXML_ICU_ENABLED
|
||||||
|
else if (output->encoder->uconv_out != NULL) {
|
||||||
|
ret = xmlUconvWrapper(output->encoder->uconv_out, 0, xmlBufEnd(out),
|
||||||
|
&c_out, NULL, &c_in);
|
||||||
|
xmlBufAddLen(out, c_out);
|
||||||
|
}
|
||||||
|
#endif /* LIBXML_ICU_ENABLED */
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"initialized encoder\n");
|
||||||
|
#endif
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Conversion itself.
|
||||||
|
*/
|
||||||
|
toconv = xmlBufUse(in);
|
||||||
|
if (toconv == 0)
|
||||||
|
return (0);
|
||||||
|
if (toconv > 64 * 1024)
|
||||||
|
toconv = 64 * 1024;
|
||||||
|
if (toconv * 4 >= written) {
|
||||||
|
xmlBufGrow(out, toconv * 4);
|
||||||
|
written = xmlBufAvail(out) - 1;
|
||||||
|
}
|
||||||
|
if (written > 256 * 1024)
|
||||||
|
written = 256 * 1024;
|
||||||
|
|
||||||
|
c_in = toconv;
|
||||||
|
c_out = written;
|
||||||
|
if (output->encoder->output != NULL) {
|
||||||
|
ret = output->encoder->output(xmlBufEnd(out), &c_out,
|
||||||
|
xmlBufContent(in), &c_in);
|
||||||
|
if (c_out > 0) {
|
||||||
|
xmlBufShrink(in, c_in);
|
||||||
|
xmlBufAddLen(out, c_out);
|
||||||
|
writtentot += c_out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef LIBXML_ICONV_ENABLED
|
||||||
|
else if (output->encoder->iconv_out != NULL) {
|
||||||
|
ret = xmlIconvWrapper(output->encoder->iconv_out, xmlBufEnd(out),
|
||||||
|
&c_out, xmlBufContent(in), &c_in);
|
||||||
|
xmlBufShrink(in, c_in);
|
||||||
|
xmlBufAddLen(out, c_out);
|
||||||
|
writtentot += c_out;
|
||||||
|
if (ret == -1) {
|
||||||
|
if (c_out > 0) {
|
||||||
|
/*
|
||||||
|
* Can be a limitation of iconv
|
||||||
|
*/
|
||||||
|
charref_len = 0;
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
ret = -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* LIBXML_ICONV_ENABLED */
|
||||||
|
#ifdef LIBXML_ICU_ENABLED
|
||||||
|
else if (output->encoder->uconv_out != NULL) {
|
||||||
|
ret = xmlUconvWrapper(output->encoder->uconv_out, 0, xmlBufEnd(out),
|
||||||
|
&c_out, xmlBufContent(in), &c_in);
|
||||||
|
xmlBufShrink(in, c_in);
|
||||||
|
xmlBufAddLen(out, c_out);
|
||||||
|
writtentot += c_out;
|
||||||
|
if (ret == -1) {
|
||||||
|
if (c_out > 0) {
|
||||||
|
/*
|
||||||
|
* Can be a limitation of uconv
|
||||||
|
*/
|
||||||
|
charref_len = 0;
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
ret = -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* LIBXML_ICU_ENABLED */
|
||||||
|
else {
|
||||||
|
xmlEncodingErr(XML_I18N_NO_OUTPUT,
|
||||||
|
"xmlCharEncOutFunc: no output function !\n", NULL);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret >= 0) output += ret;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Attempt to handle error cases
|
||||||
|
*/
|
||||||
|
switch (ret) {
|
||||||
|
case 0:
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"converted %d bytes to %d bytes of output\n",
|
||||||
|
c_in, c_out);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"output conversion failed by lack of space\n");
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case -3:
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
|
xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of output %d left\n",
|
||||||
|
c_in, c_out, (int) xmlBufUse(in));
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case -2: {
|
||||||
|
int len = (int) xmlBufUse(in);
|
||||||
|
xmlChar *content = xmlBufContent(in);
|
||||||
|
int cur;
|
||||||
|
|
||||||
|
cur = xmlGetUTF8Char(content, &len);
|
||||||
|
if ((charref_len != 0) && (c_out < charref_len)) {
|
||||||
|
/*
|
||||||
|
* We attempted to insert a character reference and failed.
|
||||||
|
* Undo what was written and skip the remaining charref.
|
||||||
|
*/
|
||||||
|
xmlBufErase(out, c_out);
|
||||||
|
writtentot -= c_out;
|
||||||
|
xmlBufShrink(in, charref_len - c_out);
|
||||||
|
charref_len = 0;
|
||||||
|
|
||||||
|
ret = -1;
|
||||||
|
break;
|
||||||
|
} else if (cur > 0) {
|
||||||
|
xmlChar charref[20];
|
||||||
|
|
||||||
|
#ifdef DEBUG_ENCODING
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"handling output conversion error\n");
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
|
||||||
|
content[0], content[1],
|
||||||
|
content[2], content[3]);
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Removes the UTF8 sequence, and replace it by a charref
|
||||||
|
* and continue the transcoding phase, hoping the error
|
||||||
|
* did not mangle the encoder state.
|
||||||
|
*/
|
||||||
|
charref_len = snprintf((char *) &charref[0], sizeof(charref),
|
||||||
|
"&#%d;", cur);
|
||||||
|
xmlBufShrink(in, len);
|
||||||
|
xmlBufAddHead(in, charref, -1);
|
||||||
|
|
||||||
|
goto retry;
|
||||||
|
} else {
|
||||||
|
char buf[50];
|
||||||
|
|
||||||
|
snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
|
||||||
|
content[0], content[1],
|
||||||
|
content[2], content[3]);
|
||||||
|
buf[49] = 0;
|
||||||
|
xmlEncodingErr(XML_I18N_CONV_FAILED,
|
||||||
|
"output conversion failed due to conv error, bytes %s\n",
|
||||||
|
buf);
|
||||||
|
if (xmlBufGetAllocationScheme(in) != XML_BUFFER_ALLOC_IMMUTABLE)
|
||||||
|
content[0] = ' ';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlCharEncOutFunc:
|
* xmlCharEncOutFunc:
|
||||||
* @handler: char enconding transformation data structure
|
* @handler: char enconding transformation data structure
|
||||||
|
@ -2161,6 +2636,7 @@ xmlCharEncOutFunc(xmlCharEncodingHandler *handler, xmlBufferPtr out,
|
||||||
int writtentot = 0;
|
int writtentot = 0;
|
||||||
int toconv;
|
int toconv;
|
||||||
int output = 0;
|
int output = 0;
|
||||||
|
int charref_len = 0;
|
||||||
|
|
||||||
if (handler == NULL) return(-1);
|
if (handler == NULL) return(-1);
|
||||||
if (out == NULL) return(-1);
|
if (out == NULL) return(-1);
|
||||||
|
@ -2242,6 +2718,7 @@ retry:
|
||||||
/*
|
/*
|
||||||
* Can be a limitation of iconv
|
* Can be a limitation of iconv
|
||||||
*/
|
*/
|
||||||
|
charref_len = 0;
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
ret = -3;
|
ret = -3;
|
||||||
|
@ -2262,6 +2739,7 @@ retry:
|
||||||
/*
|
/*
|
||||||
* Can be a limitation of iconv
|
* Can be a limitation of iconv
|
||||||
*/
|
*/
|
||||||
|
charref_len = 0;
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
ret = -3;
|
ret = -3;
|
||||||
|
@ -2305,7 +2783,19 @@ retry:
|
||||||
int cur;
|
int cur;
|
||||||
|
|
||||||
cur = xmlGetUTF8Char(utf, &len);
|
cur = xmlGetUTF8Char(utf, &len);
|
||||||
if (cur > 0) {
|
if ((charref_len != 0) && (written < charref_len)) {
|
||||||
|
/*
|
||||||
|
* We attempted to insert a character reference and failed.
|
||||||
|
* Undo what was written and skip the remaining charref.
|
||||||
|
*/
|
||||||
|
out->use -= written;
|
||||||
|
writtentot -= written;
|
||||||
|
xmlBufferShrink(in, charref_len - written);
|
||||||
|
charref_len = 0;
|
||||||
|
|
||||||
|
ret = -1;
|
||||||
|
break;
|
||||||
|
} else if (cur > 0) {
|
||||||
xmlChar charref[20];
|
xmlChar charref[20];
|
||||||
|
|
||||||
#ifdef DEBUG_ENCODING
|
#ifdef DEBUG_ENCODING
|
||||||
|
@ -2321,7 +2811,8 @@ retry:
|
||||||
* and continue the transcoding phase, hoping the error
|
* and continue the transcoding phase, hoping the error
|
||||||
* did not mangle the encoder state.
|
* did not mangle the encoder state.
|
||||||
*/
|
*/
|
||||||
snprintf((char *) &charref[0], sizeof(charref), "&#%d;", cur);
|
charref_len = snprintf((char *) &charref[0], sizeof(charref),
|
||||||
|
"&#%d;", cur);
|
||||||
xmlBufferShrink(in, len);
|
xmlBufferShrink(in, len);
|
||||||
xmlBufferAddHead(in, charref, -1);
|
xmlBufferAddHead(in, charref, -1);
|
||||||
|
|
||||||
|
|
123
reactos/lib/3rdparty/libxml2/entities.c
vendored
123
reactos/lib/3rdparty/libxml2/entities.c
vendored
|
@ -22,6 +22,8 @@
|
||||||
#include <libxml/globals.h>
|
#include <libxml/globals.h>
|
||||||
#include <libxml/dict.h>
|
#include <libxml/dict.h>
|
||||||
|
|
||||||
|
#include "save.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The XML predefined entities.
|
* The XML predefined entities.
|
||||||
*/
|
*/
|
||||||
|
@ -528,20 +530,20 @@ xmlGetDocEntity(xmlDocPtr doc, const xmlChar *name) {
|
||||||
* Macro used to grow the current buffer.
|
* Macro used to grow the current buffer.
|
||||||
*/
|
*/
|
||||||
#define growBufferReentrant() { \
|
#define growBufferReentrant() { \
|
||||||
buffer_size *= 2; \
|
xmlChar *tmp; \
|
||||||
buffer = (xmlChar *) \
|
size_t new_size = buffer_size * 2; \
|
||||||
xmlRealloc(buffer, buffer_size * sizeof(xmlChar)); \
|
if (new_size < buffer_size) goto mem_error; \
|
||||||
if (buffer == NULL) { \
|
tmp = (xmlChar *) xmlRealloc(buffer, new_size); \
|
||||||
xmlEntitiesErrMemory("xmlEncodeEntitiesReentrant: realloc failed");\
|
if (tmp == NULL) goto mem_error; \
|
||||||
return(NULL); \
|
buffer = tmp; \
|
||||||
} \
|
buffer_size = new_size; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlEncodeEntitiesReentrant:
|
* xmlEncodeEntitiesInternal:
|
||||||
* @doc: the document containing the string
|
* @doc: the document containing the string
|
||||||
* @input: A string to convert to XML.
|
* @input: A string to convert to XML.
|
||||||
|
* @attr: are we handling an atrbute value
|
||||||
*
|
*
|
||||||
* Do a global encoding of a string, replacing the predefined entities
|
* Do a global encoding of a string, replacing the predefined entities
|
||||||
* and non ASCII values with their entities and CharRef counterparts.
|
* and non ASCII values with their entities and CharRef counterparts.
|
||||||
|
@ -550,12 +552,12 @@ xmlGetDocEntity(xmlDocPtr doc, const xmlChar *name) {
|
||||||
*
|
*
|
||||||
* Returns A newly allocated string with the substitution done.
|
* Returns A newly allocated string with the substitution done.
|
||||||
*/
|
*/
|
||||||
xmlChar *
|
static xmlChar *
|
||||||
xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
|
xmlEncodeEntitiesInternal(xmlDocPtr doc, const xmlChar *input, int attr) {
|
||||||
const xmlChar *cur = input;
|
const xmlChar *cur = input;
|
||||||
xmlChar *buffer = NULL;
|
xmlChar *buffer = NULL;
|
||||||
xmlChar *out = NULL;
|
xmlChar *out = NULL;
|
||||||
int buffer_size = 0;
|
size_t buffer_size = 0;
|
||||||
int html = 0;
|
int html = 0;
|
||||||
|
|
||||||
if (input == NULL) return(NULL);
|
if (input == NULL) return(NULL);
|
||||||
|
@ -568,14 +570,14 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
|
||||||
buffer_size = 1000;
|
buffer_size = 1000;
|
||||||
buffer = (xmlChar *) xmlMalloc(buffer_size * sizeof(xmlChar));
|
buffer = (xmlChar *) xmlMalloc(buffer_size * sizeof(xmlChar));
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
xmlEntitiesErrMemory("xmlEncodeEntitiesReentrant: malloc failed");
|
xmlEntitiesErrMemory("xmlEncodeEntities: malloc failed");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
out = buffer;
|
out = buffer;
|
||||||
|
|
||||||
while (*cur != '\0') {
|
while (*cur != '\0') {
|
||||||
if (out - buffer > buffer_size - 100) {
|
size_t indx = out - buffer;
|
||||||
int indx = out - buffer;
|
if (indx + 100 > buffer_size) {
|
||||||
|
|
||||||
growBufferReentrant();
|
growBufferReentrant();
|
||||||
out = &buffer[indx];
|
out = &buffer[indx];
|
||||||
|
@ -585,6 +587,27 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
|
||||||
* By default one have to encode at least '<', '>', '"' and '&' !
|
* By default one have to encode at least '<', '>', '"' and '&' !
|
||||||
*/
|
*/
|
||||||
if (*cur == '<') {
|
if (*cur == '<') {
|
||||||
|
const xmlChar *end;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Special handling of server side include in HTML attributes
|
||||||
|
*/
|
||||||
|
if (html && attr &&
|
||||||
|
(cur[1] == '!') && (cur[2] == '-') && (cur[3] == '-') &&
|
||||||
|
((end = xmlStrstr(cur, BAD_CAST "-->")) != NULL)) {
|
||||||
|
while (cur != end) {
|
||||||
|
*out++ = *cur++;
|
||||||
|
indx = out - buffer;
|
||||||
|
if (indx + 100 > buffer_size) {
|
||||||
|
growBufferReentrant();
|
||||||
|
out = &buffer[indx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*out++ = *cur++;
|
||||||
|
*out++ = *cur++;
|
||||||
|
*out++ = *cur++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
*out++ = '&';
|
*out++ = '&';
|
||||||
*out++ = 'l';
|
*out++ = 'l';
|
||||||
*out++ = 't';
|
*out++ = 't';
|
||||||
|
@ -595,6 +618,23 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
|
||||||
*out++ = 't';
|
*out++ = 't';
|
||||||
*out++ = ';';
|
*out++ = ';';
|
||||||
} else if (*cur == '&') {
|
} else if (*cur == '&') {
|
||||||
|
/*
|
||||||
|
* Special handling of &{...} construct from HTML 4, see
|
||||||
|
* http://www.w3.org/TR/html401/appendix/notes.html#h-B.7.1
|
||||||
|
*/
|
||||||
|
if (html && attr && (cur[1] == '{') &&
|
||||||
|
(strchr((const char *) cur, '}'))) {
|
||||||
|
while (*cur != '}') {
|
||||||
|
*out++ = *cur++;
|
||||||
|
indx = out - buffer;
|
||||||
|
if (indx + 100 > buffer_size) {
|
||||||
|
growBufferReentrant();
|
||||||
|
out = &buffer[indx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*out++ = *cur++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
*out++ = '&';
|
*out++ = '&';
|
||||||
*out++ = 'a';
|
*out++ = 'a';
|
||||||
*out++ = 'm';
|
*out++ = 'm';
|
||||||
|
@ -627,7 +667,7 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
|
||||||
|
|
||||||
if (*cur < 0xC0) {
|
if (*cur < 0xC0) {
|
||||||
xmlEntitiesErr(XML_CHECK_NOT_UTF8,
|
xmlEntitiesErr(XML_CHECK_NOT_UTF8,
|
||||||
"xmlEncodeEntitiesReentrant : input not UTF-8");
|
"xmlEncodeEntities: input not UTF-8");
|
||||||
if (doc != NULL)
|
if (doc != NULL)
|
||||||
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
||||||
snprintf(buf, sizeof(buf), "&#%d;", *cur);
|
snprintf(buf, sizeof(buf), "&#%d;", *cur);
|
||||||
|
@ -660,7 +700,7 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
|
||||||
}
|
}
|
||||||
if ((l == 1) || (!IS_CHAR(val))) {
|
if ((l == 1) || (!IS_CHAR(val))) {
|
||||||
xmlEntitiesErr(XML_ERR_INVALID_CHAR,
|
xmlEntitiesErr(XML_ERR_INVALID_CHAR,
|
||||||
"xmlEncodeEntitiesReentrant : char out of range\n");
|
"xmlEncodeEntities: char out of range\n");
|
||||||
if (doc != NULL)
|
if (doc != NULL)
|
||||||
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
||||||
snprintf(buf, sizeof(buf), "&#%d;", *cur);
|
snprintf(buf, sizeof(buf), "&#%d;", *cur);
|
||||||
|
@ -692,6 +732,44 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
|
||||||
}
|
}
|
||||||
*out = 0;
|
*out = 0;
|
||||||
return(buffer);
|
return(buffer);
|
||||||
|
|
||||||
|
mem_error:
|
||||||
|
xmlEntitiesErrMemory("xmlEncodeEntities: realloc failed");
|
||||||
|
xmlFree(buffer);
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlEncodeAttributeEntities:
|
||||||
|
* @doc: the document containing the string
|
||||||
|
* @input: A string to convert to XML.
|
||||||
|
*
|
||||||
|
* Do a global encoding of a string, replacing the predefined entities
|
||||||
|
* and non ASCII values with their entities and CharRef counterparts for
|
||||||
|
* attribute values.
|
||||||
|
*
|
||||||
|
* Returns A newly allocated string with the substitution done.
|
||||||
|
*/
|
||||||
|
xmlChar *
|
||||||
|
xmlEncodeAttributeEntities(xmlDocPtr doc, const xmlChar *input) {
|
||||||
|
return xmlEncodeEntitiesInternal(doc, input, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlEncodeEntitiesReentrant:
|
||||||
|
* @doc: the document containing the string
|
||||||
|
* @input: A string to convert to XML.
|
||||||
|
*
|
||||||
|
* Do a global encoding of a string, replacing the predefined entities
|
||||||
|
* and non ASCII values with their entities and CharRef counterparts.
|
||||||
|
* Contrary to xmlEncodeEntities, this routine is reentrant, and result
|
||||||
|
* must be deallocated.
|
||||||
|
*
|
||||||
|
* Returns A newly allocated string with the substitution done.
|
||||||
|
*/
|
||||||
|
xmlChar *
|
||||||
|
xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
|
||||||
|
return xmlEncodeEntitiesInternal(doc, input, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -709,7 +787,7 @@ xmlEncodeSpecialChars(xmlDocPtr doc ATTRIBUTE_UNUSED, const xmlChar *input) {
|
||||||
const xmlChar *cur = input;
|
const xmlChar *cur = input;
|
||||||
xmlChar *buffer = NULL;
|
xmlChar *buffer = NULL;
|
||||||
xmlChar *out = NULL;
|
xmlChar *out = NULL;
|
||||||
int buffer_size = 0;
|
size_t buffer_size = 0;
|
||||||
if (input == NULL) return(NULL);
|
if (input == NULL) return(NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -724,8 +802,8 @@ xmlEncodeSpecialChars(xmlDocPtr doc ATTRIBUTE_UNUSED, const xmlChar *input) {
|
||||||
out = buffer;
|
out = buffer;
|
||||||
|
|
||||||
while (*cur != '\0') {
|
while (*cur != '\0') {
|
||||||
if (out - buffer > buffer_size - 10) {
|
size_t indx = out - buffer;
|
||||||
int indx = out - buffer;
|
if (indx + 10 > buffer_size) {
|
||||||
|
|
||||||
growBufferReentrant();
|
growBufferReentrant();
|
||||||
out = &buffer[indx];
|
out = &buffer[indx];
|
||||||
|
@ -774,6 +852,11 @@ xmlEncodeSpecialChars(xmlDocPtr doc ATTRIBUTE_UNUSED, const xmlChar *input) {
|
||||||
}
|
}
|
||||||
*out = 0;
|
*out = 0;
|
||||||
return(buffer);
|
return(buffer);
|
||||||
|
|
||||||
|
mem_error:
|
||||||
|
xmlEntitiesErrMemory("xmlEncodeSpecialChars: realloc failed");
|
||||||
|
xmlFree(buffer);
|
||||||
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
53
reactos/lib/3rdparty/libxml2/error.c
vendored
53
reactos/lib/3rdparty/libxml2/error.c
vendored
|
@ -292,7 +292,10 @@ xmlReportError(xmlErrorPtr err, xmlParserCtxtPtr ctxt, const char *str,
|
||||||
} else {
|
} else {
|
||||||
if (file != NULL)
|
if (file != NULL)
|
||||||
channel(data, "%s:%d: ", file, line);
|
channel(data, "%s:%d: ", file, line);
|
||||||
else if ((line != 0) && (domain == XML_FROM_PARSER))
|
else if ((line != 0) &&
|
||||||
|
((domain == XML_FROM_PARSER) || (domain == XML_FROM_SCHEMASV)||
|
||||||
|
(domain == XML_FROM_SCHEMASP)||(domain == XML_FROM_DTD) ||
|
||||||
|
(domain == XML_FROM_RELAXNGP)||(domain == XML_FROM_RELAXNGV)))
|
||||||
channel(data, "Entity: line %d: ", line);
|
channel(data, "Entity: line %d: ", line);
|
||||||
}
|
}
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
|
@ -360,6 +363,15 @@ xmlReportError(xmlErrorPtr err, xmlParserCtxtPtr ctxt, const char *str,
|
||||||
case XML_FROM_I18N:
|
case XML_FROM_I18N:
|
||||||
channel(data, "encoding ");
|
channel(data, "encoding ");
|
||||||
break;
|
break;
|
||||||
|
case XML_FROM_SCHEMATRONV:
|
||||||
|
channel(data, "schematron ");
|
||||||
|
break;
|
||||||
|
case XML_FROM_BUFFER:
|
||||||
|
channel(data, "internal buffer ");
|
||||||
|
break;
|
||||||
|
case XML_FROM_URI:
|
||||||
|
channel(data, "URI ");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -452,6 +464,8 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
|
||||||
xmlErrorPtr to = &xmlLastError;
|
xmlErrorPtr to = &xmlLastError;
|
||||||
xmlNodePtr baseptr = NULL;
|
xmlNodePtr baseptr = NULL;
|
||||||
|
|
||||||
|
if (code == XML_ERR_OK)
|
||||||
|
return;
|
||||||
if ((xmlGetWarningsDefaultValue == 0) && (level == XML_ERR_WARNING))
|
if ((xmlGetWarningsDefaultValue == 0) && (level == XML_ERR_WARNING))
|
||||||
return;
|
return;
|
||||||
if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) ||
|
if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) ||
|
||||||
|
@ -459,8 +473,11 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
|
||||||
(domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) {
|
(domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) {
|
||||||
ctxt = (xmlParserCtxtPtr) ctx;
|
ctxt = (xmlParserCtxtPtr) ctx;
|
||||||
if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
|
if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
|
||||||
(ctxt->sax->initialized == XML_SAX2_MAGIC))
|
(ctxt->sax->initialized == XML_SAX2_MAGIC) &&
|
||||||
|
(ctxt->sax->serror != NULL)) {
|
||||||
schannel = ctxt->sax->serror;
|
schannel = ctxt->sax->serror;
|
||||||
|
data = ctxt->userData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Check if structured error handler set
|
* Check if structured error handler set
|
||||||
|
@ -473,16 +490,6 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
|
||||||
if (schannel != NULL)
|
if (schannel != NULL)
|
||||||
data = xmlStructuredErrorContext;
|
data = xmlStructuredErrorContext;
|
||||||
}
|
}
|
||||||
if ((domain == XML_FROM_VALID) &&
|
|
||||||
((channel == xmlParserValidityError) ||
|
|
||||||
(channel == xmlParserValidityWarning))) {
|
|
||||||
ctxt = (xmlParserCtxtPtr) ctx;
|
|
||||||
if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
|
|
||||||
(ctxt->sax->initialized == XML_SAX2_MAGIC))
|
|
||||||
schannel = ctxt->sax->serror;
|
|
||||||
}
|
|
||||||
if (code == XML_ERR_OK)
|
|
||||||
return;
|
|
||||||
/*
|
/*
|
||||||
* Formatting the message
|
* Formatting the message
|
||||||
*/
|
*/
|
||||||
|
@ -526,6 +533,8 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
|
||||||
|
|
||||||
if ((node != NULL) && (node->type == XML_ELEMENT_NODE))
|
if ((node != NULL) && (node->type == XML_ELEMENT_NODE))
|
||||||
line = node->line;
|
line = node->line;
|
||||||
|
if ((line == 0) || (line == 65535))
|
||||||
|
line = xmlGetLineNo(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -589,6 +598,11 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
|
||||||
if (to != &xmlLastError)
|
if (to != &xmlLastError)
|
||||||
xmlCopyError(to,&xmlLastError);
|
xmlCopyError(to,&xmlLastError);
|
||||||
|
|
||||||
|
if (schannel != NULL) {
|
||||||
|
schannel(data, to);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the callback channel if channel param is NULL
|
* Find the callback channel if channel param is NULL
|
||||||
*/
|
*/
|
||||||
|
@ -600,20 +614,13 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
|
||||||
channel = ctxt->sax->error;
|
channel = ctxt->sax->error;
|
||||||
data = ctxt->userData;
|
data = ctxt->userData;
|
||||||
} else if (channel == NULL) {
|
} else if (channel == NULL) {
|
||||||
if ((schannel == NULL) && (xmlStructuredError != NULL)) {
|
channel = xmlGenericError;
|
||||||
schannel = xmlStructuredError;
|
if (ctxt != NULL) {
|
||||||
data = xmlStructuredErrorContext;
|
data = ctxt;
|
||||||
} else {
|
} else {
|
||||||
channel = xmlGenericError;
|
data = xmlGenericErrorContext;
|
||||||
if (!data) {
|
|
||||||
data = xmlGenericErrorContext;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (schannel != NULL) {
|
|
||||||
schannel(data, to);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (channel == NULL)
|
if (channel == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
2
reactos/lib/3rdparty/libxml2/globals.c
vendored
2
reactos/lib/3rdparty/libxml2/globals.c
vendored
|
@ -509,7 +509,7 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
|
||||||
#if defined(LIBXML_DOCB_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
|
#if defined(LIBXML_DOCB_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
|
||||||
initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
|
initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
|
||||||
#endif
|
#endif
|
||||||
#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED)
|
#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
|
||||||
inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
|
inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
30
reactos/lib/3rdparty/libxml2/hash.c
vendored
30
reactos/lib/3rdparty/libxml2/hash.c
vendored
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Reference: Your favorite introductory book on algorithms
|
* Reference: Your favorite introductory book on algorithms
|
||||||
*
|
*
|
||||||
* Copyright (C) 2000 Bjorn Reese and Daniel Veillard.
|
* Copyright (C) 2000,2012 Bjorn Reese and Daniel Veillard.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -21,6 +21,22 @@
|
||||||
#include "libxml.h"
|
#include "libxml.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_TIME_H
|
||||||
|
#include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Following http://www.ocert.org/advisories/ocert-2011-003.html
|
||||||
|
* it seems that having hash randomization might be a good idea
|
||||||
|
* when using XML with untrusted data
|
||||||
|
*/
|
||||||
|
#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME)
|
||||||
|
#define HASH_RANDOMIZATION
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
#include <libxml/hash.h>
|
#include <libxml/hash.h>
|
||||||
#include <libxml/xmlmemory.h>
|
#include <libxml/xmlmemory.h>
|
||||||
|
@ -53,6 +69,9 @@ struct _xmlHashTable {
|
||||||
int size;
|
int size;
|
||||||
int nbElems;
|
int nbElems;
|
||||||
xmlDictPtr dict;
|
xmlDictPtr dict;
|
||||||
|
#ifdef HASH_RANDOMIZATION
|
||||||
|
int random_seed;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -65,6 +84,9 @@ xmlHashComputeKey(xmlHashTablePtr table, const xmlChar *name,
|
||||||
unsigned long value = 0L;
|
unsigned long value = 0L;
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
|
#ifdef HASH_RANDOMIZATION
|
||||||
|
value = table->random_seed;
|
||||||
|
#endif
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
value += 30 * (*name);
|
value += 30 * (*name);
|
||||||
while ((ch = *name++) != 0) {
|
while ((ch = *name++) != 0) {
|
||||||
|
@ -92,6 +114,9 @@ xmlHashComputeQKey(xmlHashTablePtr table,
|
||||||
unsigned long value = 0L;
|
unsigned long value = 0L;
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
|
#ifdef HASH_RANDOMIZATION
|
||||||
|
value = table->random_seed;
|
||||||
|
#endif
|
||||||
if (prefix != NULL)
|
if (prefix != NULL)
|
||||||
value += 30 * (*prefix);
|
value += 30 * (*prefix);
|
||||||
else
|
else
|
||||||
|
@ -156,6 +181,9 @@ xmlHashCreate(int size) {
|
||||||
table->table = xmlMalloc(size * sizeof(xmlHashEntry));
|
table->table = xmlMalloc(size * sizeof(xmlHashEntry));
|
||||||
if (table->table) {
|
if (table->table) {
|
||||||
memset(table->table, 0, size * sizeof(xmlHashEntry));
|
memset(table->table, 0, size * sizeof(xmlHashEntry));
|
||||||
|
#ifdef HASH_RANDOMIZATION
|
||||||
|
table->random_seed = __xmlRandom();
|
||||||
|
#endif
|
||||||
return(table);
|
return(table);
|
||||||
}
|
}
|
||||||
xmlFree(table);
|
xmlFree(table);
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __MINGW32__
|
#if defined( __MINGW32__ ) || defined( _MSC_VER )
|
||||||
/* Include <errno.h> here to ensure that it doesn't get included later
|
/* Include <errno.h> here to ensure that it doesn't get included later
|
||||||
* (e.g. by iconv.h) and overwrites the definition of EWOULDBLOCK. */
|
* (e.g. by iconv.h) and overwrites the definition of EWOULDBLOCK. */
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -39,6 +39,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define EWOULDBLOCK WSAEWOULDBLOCK
|
#define EWOULDBLOCK WSAEWOULDBLOCK
|
||||||
|
#define ESHUTDOWN WSAESHUTDOWN
|
||||||
|
|
||||||
|
#if (!defined(_MSC_VER) || (_MSC_VER < 1600)) || defined(__REACTOS__)
|
||||||
#define EINPROGRESS WSAEINPROGRESS
|
#define EINPROGRESS WSAEINPROGRESS
|
||||||
#define EALREADY WSAEALREADY
|
#define EALREADY WSAEALREADY
|
||||||
#define ENOTSOCK WSAENOTSOCK
|
#define ENOTSOCK WSAENOTSOCK
|
||||||
|
@ -61,7 +64,6 @@
|
||||||
#define ENOBUFS WSAENOBUFS
|
#define ENOBUFS WSAENOBUFS
|
||||||
#define EISCONN WSAEISCONN
|
#define EISCONN WSAEISCONN
|
||||||
#define ENOTCONN WSAENOTCONN
|
#define ENOTCONN WSAENOTCONN
|
||||||
#define ESHUTDOWN WSAESHUTDOWN
|
|
||||||
#define ETOOMANYREFS WSAETOOMANYREFS
|
#define ETOOMANYREFS WSAETOOMANYREFS
|
||||||
#define ETIMEDOUT WSAETIMEDOUT
|
#define ETIMEDOUT WSAETIMEDOUT
|
||||||
#define ECONNREFUSED WSAECONNREFUSED
|
#define ECONNREFUSED WSAECONNREFUSED
|
||||||
|
@ -73,11 +75,12 @@
|
||||||
#define EDQUOT WSAEDQUOT
|
#define EDQUOT WSAEDQUOT
|
||||||
#define ESTALE WSAESTALE
|
#define ESTALE WSAESTALE
|
||||||
#define EREMOTE WSAEREMOTE
|
#define EREMOTE WSAEREMOTE
|
||||||
/* These cause conflicts with the codes from errno.h. Since they are
|
/* These cause conflicts with the codes from errno.h. Since they are
|
||||||
not used in the relevant code (nanoftp, nanohttp), we can leave
|
not used in the relevant code (nanoftp, nanohttp), we can leave
|
||||||
them disabled.
|
them disabled.
|
||||||
#define ENAMETOOLONG WSAENAMETOOLONG
|
#define ENAMETOOLONG WSAENAMETOOLONG
|
||||||
#define ENOTEMPTY WSAENOTEMPTY
|
#define ENOTEMPTY WSAENOTEMPTY
|
||||||
*/
|
*/
|
||||||
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
#endif /* __XML_WSOCKCOMPAT_H__ */
|
#endif /* __XML_WSOCKCOMPAT_H__ */
|
||||||
|
|
15
reactos/lib/3rdparty/libxml2/libxml.h
vendored
15
reactos/lib/3rdparty/libxml2/libxml.h
vendored
|
@ -29,6 +29,11 @@
|
||||||
#include <win32config.h>
|
#include <win32config.h>
|
||||||
#include <libxml/xmlversion.h>
|
#include <libxml/xmlversion.h>
|
||||||
#else
|
#else
|
||||||
|
/*
|
||||||
|
* Currently supported platforms use either autoconf or
|
||||||
|
* copy to config.h own "preset" configuration file.
|
||||||
|
* As result ifdef HAVE_CONFIG_H is omited here.
|
||||||
|
*/
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <libxml/xmlversion.h>
|
#include <libxml/xmlversion.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -79,6 +84,13 @@ void __xmlGlobalInitMutexLock(void);
|
||||||
void __xmlGlobalInitMutexUnlock(void);
|
void __xmlGlobalInitMutexUnlock(void);
|
||||||
void __xmlGlobalInitMutexDestroy(void);
|
void __xmlGlobalInitMutexDestroy(void);
|
||||||
|
|
||||||
|
#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME)
|
||||||
|
/*
|
||||||
|
* internal thread safe random function
|
||||||
|
*/
|
||||||
|
int __xmlRandom(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef IN_LIBXML
|
#ifdef IN_LIBXML
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#ifdef PIC
|
#ifdef PIC
|
||||||
|
@ -90,4 +102,7 @@ void __xmlGlobalInitMutexDestroy(void);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined(PIC) && !defined(NOLIBTOOL) && !defined(LIBXML_STATIC)
|
||||||
|
# define LIBXML_STATIC
|
||||||
|
#endif
|
||||||
#endif /* ! __XML_LIBXML_H__ */
|
#endif /* ! __XML_LIBXML_H__ */
|
||||||
|
|
3
reactos/lib/3rdparty/libxml2/nanoftp.c
vendored
3
reactos/lib/3rdparty/libxml2/nanoftp.c
vendored
|
@ -947,7 +947,8 @@ xmlNanoFTPConnect(void *ctx) {
|
||||||
((struct sockaddr_in *)&ctxt->ftpAddr)->sin_family = AF_INET;
|
((struct sockaddr_in *)&ctxt->ftpAddr)->sin_family = AF_INET;
|
||||||
memcpy (&((struct sockaddr_in *)&ctxt->ftpAddr)->sin_addr,
|
memcpy (&((struct sockaddr_in *)&ctxt->ftpAddr)->sin_addr,
|
||||||
hp->h_addr_list[0], hp->h_length);
|
hp->h_addr_list[0], hp->h_length);
|
||||||
((struct sockaddr_in *)&ctxt->ftpAddr)->sin_port = (u_short)htons ((unsigned short)port);
|
((struct sockaddr_in *)&ctxt->ftpAddr)->sin_port =
|
||||||
|
(unsigned short)htons ((unsigned short)port);
|
||||||
ctxt->controlFd = socket (AF_INET, SOCK_STREAM, 0);
|
ctxt->controlFd = socket (AF_INET, SOCK_STREAM, 0);
|
||||||
addrlen = sizeof (struct sockaddr_in);
|
addrlen = sizeof (struct sockaddr_in);
|
||||||
}
|
}
|
||||||
|
|
21
reactos/lib/3rdparty/libxml2/nanohttp.c
vendored
21
reactos/lib/3rdparty/libxml2/nanohttp.c
vendored
|
@ -64,9 +64,6 @@
|
||||||
#ifdef HAVE_STRINGS_H
|
#ifdef HAVE_STRINGS_H
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef SUPPORT_IP6
|
|
||||||
#include <resolv.h>
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ZLIB_H
|
#ifdef HAVE_ZLIB_H
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -1140,10 +1137,12 @@ xmlNanoHTTPConnectHost(const char *host, int port)
|
||||||
"Non-recoverable errors: FORMERR, REFUSED, or NOTIMP.";
|
"Non-recoverable errors: FORMERR, REFUSED, or NOTIMP.";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef NO_ADDRESS
|
||||||
case NO_ADDRESS:
|
case NO_ADDRESS:
|
||||||
h_err_txt =
|
h_err_txt =
|
||||||
"Valid name, no data record of requested type.";
|
"Valid name, no data record of requested type.";
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
h_err_txt = "No error text defined.";
|
h_err_txt = "No error text defined.";
|
||||||
|
@ -1166,7 +1165,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
|
||||||
memcpy (&ia, h->h_addr_list[i], h->h_length);
|
memcpy (&ia, h->h_addr_list[i], h->h_length);
|
||||||
sockin.sin_family = h->h_addrtype;
|
sockin.sin_family = h->h_addrtype;
|
||||||
sockin.sin_addr = ia;
|
sockin.sin_addr = ia;
|
||||||
sockin.sin_port = (u_short)htons ((unsigned short)port);
|
sockin.sin_port = (unsigned short)htons ((unsigned short)port);
|
||||||
addr = (struct sockaddr *) &sockin;
|
addr = (struct sockaddr *) &sockin;
|
||||||
#ifdef SUPPORT_IP6
|
#ifdef SUPPORT_IP6
|
||||||
} else if (have_ipv6 () && (h->h_addrtype == AF_INET6)) {
|
} else if (have_ipv6 () && (h->h_addrtype == AF_INET6)) {
|
||||||
|
@ -1615,6 +1614,7 @@ xmlNanoHTTPFetch(const char *URL, const char *filename, char **contentType) {
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
int fd;
|
int fd;
|
||||||
int len;
|
int len;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if (filename == NULL) return(-1);
|
if (filename == NULL) return(-1);
|
||||||
ctxt = xmlNanoHTTPOpen(URL, contentType);
|
ctxt = xmlNanoHTTPOpen(URL, contentType);
|
||||||
|
@ -1636,12 +1636,14 @@ xmlNanoHTTPFetch(const char *URL, const char *filename, char **contentType) {
|
||||||
|
|
||||||
xmlNanoHTTPFetchContent( ctxt, &buf, &len );
|
xmlNanoHTTPFetchContent( ctxt, &buf, &len );
|
||||||
if ( len > 0 ) {
|
if ( len > 0 ) {
|
||||||
write(fd, buf, len);
|
if (write(fd, buf, len) == -1) {
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlNanoHTTPClose(ctxt);
|
xmlNanoHTTPClose(ctxt);
|
||||||
close(fd);
|
close(fd);
|
||||||
return(0);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
#ifdef LIBXML_OUTPUT_ENABLED
|
||||||
|
@ -1660,6 +1662,7 @@ xmlNanoHTTPSave(void *ctxt, const char *filename) {
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
int fd;
|
int fd;
|
||||||
int len;
|
int len;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if ((ctxt == NULL) || (filename == NULL)) return(-1);
|
if ((ctxt == NULL) || (filename == NULL)) return(-1);
|
||||||
|
|
||||||
|
@ -1675,12 +1678,14 @@ xmlNanoHTTPSave(void *ctxt, const char *filename) {
|
||||||
|
|
||||||
xmlNanoHTTPFetchContent( ctxt, &buf, &len );
|
xmlNanoHTTPFetchContent( ctxt, &buf, &len );
|
||||||
if ( len > 0 ) {
|
if ( len > 0 ) {
|
||||||
write(fd, buf, len);
|
if (write(fd, buf, len) == -1) {
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlNanoHTTPClose(ctxt);
|
xmlNanoHTTPClose(ctxt);
|
||||||
close(fd);
|
close(fd);
|
||||||
return(0);
|
return(ret);
|
||||||
}
|
}
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||||
|
|
||||||
|
|
912
reactos/lib/3rdparty/libxml2/parser.c
vendored
912
reactos/lib/3rdparty/libxml2/parser.c
vendored
File diff suppressed because it is too large
Load diff
161
reactos/lib/3rdparty/libxml2/parserInternals.c
vendored
161
reactos/lib/3rdparty/libxml2/parserInternals.c
vendored
|
@ -55,6 +55,9 @@
|
||||||
#include <libxml/globals.h>
|
#include <libxml/globals.h>
|
||||||
#include <libxml/chvalid.h>
|
#include <libxml/chvalid.h>
|
||||||
|
|
||||||
|
#include "buf.h"
|
||||||
|
#include "enc.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Various global defaults for parsing
|
* Various global defaults for parsing
|
||||||
*/
|
*/
|
||||||
|
@ -242,7 +245,7 @@ xmlIsLetter(int c) {
|
||||||
|
|
||||||
static
|
static
|
||||||
void check_buffer(xmlParserInputPtr in) {
|
void check_buffer(xmlParserInputPtr in) {
|
||||||
if (in->base != in->buf->buffer->content) {
|
if (in->base != xmlBufContent(in->buf->buffer)) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlParserInput: base mismatch problem\n");
|
"xmlParserInput: base mismatch problem\n");
|
||||||
}
|
}
|
||||||
|
@ -250,13 +253,13 @@ void check_buffer(xmlParserInputPtr in) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlParserInput: cur < base problem\n");
|
"xmlParserInput: cur < base problem\n");
|
||||||
}
|
}
|
||||||
if (in->cur > in->base + in->buf->buffer->use) {
|
if (in->cur > in->base + xmlBufUse(in->buf->buffer)) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlParserInput: cur > base + use problem\n");
|
"xmlParserInput: cur > base + use problem\n");
|
||||||
}
|
}
|
||||||
xmlGenericError(xmlGenericErrorContext,"buffer %x : content %x, cur %d, use %d, size %d\n",
|
xmlGenericError(xmlGenericErrorContext,"buffer %x : content %x, cur %d, use %d\n",
|
||||||
(int) in, (int) in->buf->buffer->content, in->cur - in->base,
|
(int) in, (int) xmlBufContent(in->buf->buffer), in->cur - in->base,
|
||||||
in->buf->buffer->use, in->buf->buffer->size);
|
xmlBufUse(in->buf->buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -269,50 +272,13 @@ void check_buffer(xmlParserInputPtr in) {
|
||||||
* @in: an XML parser input
|
* @in: an XML parser input
|
||||||
* @len: an indicative size for the lookahead
|
* @len: an indicative size for the lookahead
|
||||||
*
|
*
|
||||||
* This function refresh the input for the parser. It doesn't try to
|
* This function was internal and is deprecated.
|
||||||
* preserve pointers to the input buffer, and discard already read data
|
|
||||||
*
|
*
|
||||||
* Returns the number of xmlChars read, or -1 in case of error, 0 indicate the
|
* Returns -1 as this is an error to use it.
|
||||||
* end of this entity
|
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xmlParserInputRead(xmlParserInputPtr in, int len) {
|
xmlParserInputRead(xmlParserInputPtr in ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUSED) {
|
||||||
int ret;
|
return(-1);
|
||||||
int used;
|
|
||||||
int indx;
|
|
||||||
|
|
||||||
if (in == NULL) return(-1);
|
|
||||||
#ifdef DEBUG_INPUT
|
|
||||||
xmlGenericError(xmlGenericErrorContext, "Read\n");
|
|
||||||
#endif
|
|
||||||
if (in->buf == NULL) return(-1);
|
|
||||||
if (in->base == NULL) return(-1);
|
|
||||||
if (in->cur == NULL) return(-1);
|
|
||||||
if (in->buf->buffer == NULL) return(-1);
|
|
||||||
if (in->buf->readcallback == NULL) return(-1);
|
|
||||||
|
|
||||||
CHECK_BUFFER(in);
|
|
||||||
|
|
||||||
used = in->cur - in->buf->buffer->content;
|
|
||||||
ret = xmlBufferShrink(in->buf->buffer, used);
|
|
||||||
if (ret > 0) {
|
|
||||||
in->cur -= ret;
|
|
||||||
in->consumed += ret;
|
|
||||||
}
|
|
||||||
ret = xmlParserInputBufferRead(in->buf, len);
|
|
||||||
if (in->base != in->buf->buffer->content) {
|
|
||||||
/*
|
|
||||||
* the buffer has been reallocated
|
|
||||||
*/
|
|
||||||
indx = in->cur - in->base;
|
|
||||||
in->base = in->buf->buffer->content;
|
|
||||||
in->cur = &in->buf->buffer->content[indx];
|
|
||||||
}
|
|
||||||
in->end = &in->buf->buffer->content[in->buf->buffer->use];
|
|
||||||
|
|
||||||
CHECK_BUFFER(in);
|
|
||||||
|
|
||||||
return(ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -323,15 +289,16 @@ xmlParserInputRead(xmlParserInputPtr in, int len) {
|
||||||
* This function increase the input for the parser. It tries to
|
* This function increase the input for the parser. It tries to
|
||||||
* preserve pointers to the input buffer, and keep already read data
|
* preserve pointers to the input buffer, and keep already read data
|
||||||
*
|
*
|
||||||
* Returns the number of xmlChars read, or -1 in case of error, 0 indicate the
|
* Returns the amount of char read, or -1 in case of error, 0 indicate the
|
||||||
* end of this entity
|
* end of this entity
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
||||||
int ret;
|
size_t ret;
|
||||||
int indx;
|
size_t indx;
|
||||||
|
const xmlChar *content;
|
||||||
|
|
||||||
if (in == NULL) return(-1);
|
if ((in == NULL) || (len < 0)) return(-1);
|
||||||
#ifdef DEBUG_INPUT
|
#ifdef DEBUG_INPUT
|
||||||
xmlGenericError(xmlGenericErrorContext, "Grow\n");
|
xmlGenericError(xmlGenericErrorContext, "Grow\n");
|
||||||
#endif
|
#endif
|
||||||
|
@ -343,15 +310,15 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
||||||
CHECK_BUFFER(in);
|
CHECK_BUFFER(in);
|
||||||
|
|
||||||
indx = in->cur - in->base;
|
indx = in->cur - in->base;
|
||||||
if (in->buf->buffer->use > (unsigned int) indx + INPUT_CHUNK) {
|
if (xmlBufUse(in->buf->buffer) > (unsigned int) indx + INPUT_CHUNK) {
|
||||||
|
|
||||||
CHECK_BUFFER(in);
|
CHECK_BUFFER(in);
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
if (in->buf->readcallback != NULL)
|
if (in->buf->readcallback != NULL) {
|
||||||
ret = xmlParserInputBufferGrow(in->buf, len);
|
ret = xmlParserInputBufferGrow(in->buf, len);
|
||||||
else
|
} else
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -360,15 +327,17 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
||||||
* pointer arithmetic. Insure will raise it as a bug but in
|
* pointer arithmetic. Insure will raise it as a bug but in
|
||||||
* that specific case, that's not !
|
* that specific case, that's not !
|
||||||
*/
|
*/
|
||||||
if (in->base != in->buf->buffer->content) {
|
|
||||||
|
content = xmlBufContent(in->buf->buffer);
|
||||||
|
if (in->base != content) {
|
||||||
/*
|
/*
|
||||||
* the buffer has been reallocated
|
* the buffer has been reallocated
|
||||||
*/
|
*/
|
||||||
indx = in->cur - in->base;
|
indx = in->cur - in->base;
|
||||||
in->base = in->buf->buffer->content;
|
in->base = content;
|
||||||
in->cur = &in->buf->buffer->content[indx];
|
in->cur = &content[indx];
|
||||||
}
|
}
|
||||||
in->end = &in->buf->buffer->content[in->buf->buffer->use];
|
in->end = xmlBufEnd(in->buf->buffer);
|
||||||
|
|
||||||
CHECK_BUFFER(in);
|
CHECK_BUFFER(in);
|
||||||
|
|
||||||
|
@ -383,9 +352,10 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xmlParserInputShrink(xmlParserInputPtr in) {
|
xmlParserInputShrink(xmlParserInputPtr in) {
|
||||||
int used;
|
size_t used;
|
||||||
int ret;
|
size_t ret;
|
||||||
int indx;
|
size_t indx;
|
||||||
|
const xmlChar *content;
|
||||||
|
|
||||||
#ifdef DEBUG_INPUT
|
#ifdef DEBUG_INPUT
|
||||||
xmlGenericError(xmlGenericErrorContext, "Shrink\n");
|
xmlGenericError(xmlGenericErrorContext, "Shrink\n");
|
||||||
|
@ -398,35 +368,36 @@ xmlParserInputShrink(xmlParserInputPtr in) {
|
||||||
|
|
||||||
CHECK_BUFFER(in);
|
CHECK_BUFFER(in);
|
||||||
|
|
||||||
used = in->cur - in->buf->buffer->content;
|
used = in->cur - xmlBufContent(in->buf->buffer);
|
||||||
/*
|
/*
|
||||||
* Do not shrink on large buffers whose only a tiny fraction
|
* Do not shrink on large buffers whose only a tiny fraction
|
||||||
* was consumed
|
* was consumed
|
||||||
*/
|
*/
|
||||||
if (used > INPUT_CHUNK) {
|
if (used > INPUT_CHUNK) {
|
||||||
ret = xmlBufferShrink(in->buf->buffer, used - LINE_LEN);
|
ret = xmlBufShrink(in->buf->buffer, used - LINE_LEN);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
in->cur -= ret;
|
in->cur -= ret;
|
||||||
in->consumed += ret;
|
in->consumed += ret;
|
||||||
}
|
}
|
||||||
in->end = &in->buf->buffer->content[in->buf->buffer->use];
|
in->end = xmlBufEnd(in->buf->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_BUFFER(in);
|
CHECK_BUFFER(in);
|
||||||
|
|
||||||
if (in->buf->buffer->use > INPUT_CHUNK) {
|
if (xmlBufUse(in->buf->buffer) > INPUT_CHUNK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
xmlParserInputBufferRead(in->buf, 2 * INPUT_CHUNK);
|
xmlParserInputBufferRead(in->buf, 2 * INPUT_CHUNK);
|
||||||
if (in->base != in->buf->buffer->content) {
|
content = xmlBufContent(in->buf->buffer);
|
||||||
|
if (in->base != content) {
|
||||||
/*
|
/*
|
||||||
* the buffer has been reallocated
|
* the buffer has been reallocated
|
||||||
*/
|
*/
|
||||||
indx = in->cur - in->base;
|
indx = in->cur - in->base;
|
||||||
in->base = in->buf->buffer->content;
|
in->base = content;
|
||||||
in->cur = &in->buf->buffer->content[indx];
|
in->cur = &content[indx];
|
||||||
}
|
}
|
||||||
in->end = &in->buf->buffer->content[in->buf->buffer->use];
|
in->end = xmlBufEnd(in->buf->buffer);
|
||||||
|
|
||||||
CHECK_BUFFER(in);
|
CHECK_BUFFER(in);
|
||||||
}
|
}
|
||||||
|
@ -945,11 +916,6 @@ xmlCopyChar(int len ATTRIBUTE_UNUSED, xmlChar *out, int val) {
|
||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
/* defined in encoding.c, not public */
|
|
||||||
int
|
|
||||||
xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
|
|
||||||
xmlBufferPtr in, int len);
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt,
|
xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt,
|
||||||
xmlCharEncodingHandlerPtr handler, int len);
|
xmlCharEncodingHandlerPtr handler, int len);
|
||||||
|
@ -1189,7 +1155,7 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
|
||||||
/*
|
/*
|
||||||
* Is there already some content down the pipe to convert ?
|
* Is there already some content down the pipe to convert ?
|
||||||
*/
|
*/
|
||||||
if ((input->buf->buffer != NULL) && (input->buf->buffer->use > 0)) {
|
if (xmlBufIsEmpty(input->buf->buffer) == 0) {
|
||||||
int processed;
|
int processed;
|
||||||
unsigned int use;
|
unsigned int use;
|
||||||
|
|
||||||
|
@ -1225,19 +1191,17 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
|
||||||
* Move it as the raw buffer and create a new input buffer
|
* Move it as the raw buffer and create a new input buffer
|
||||||
*/
|
*/
|
||||||
processed = input->cur - input->base;
|
processed = input->cur - input->base;
|
||||||
xmlBufferShrink(input->buf->buffer, processed);
|
xmlBufShrink(input->buf->buffer, processed);
|
||||||
input->buf->raw = input->buf->buffer;
|
input->buf->raw = input->buf->buffer;
|
||||||
input->buf->buffer = xmlBufferCreate();
|
input->buf->buffer = xmlBufCreate();
|
||||||
input->buf->rawconsumed = processed;
|
input->buf->rawconsumed = processed;
|
||||||
use = input->buf->raw->use;
|
use = xmlBufUse(input->buf->raw);
|
||||||
|
|
||||||
if (ctxt->html) {
|
if (ctxt->html) {
|
||||||
/*
|
/*
|
||||||
* convert as much as possible of the buffer
|
* convert as much as possible of the buffer
|
||||||
*/
|
*/
|
||||||
nbchars = xmlCharEncInFunc(input->buf->encoder,
|
nbchars = xmlCharEncInput(input->buf);
|
||||||
input->buf->buffer,
|
|
||||||
input->buf->raw);
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* convert just enough to get
|
* convert just enough to get
|
||||||
|
@ -1245,10 +1209,7 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
|
||||||
* parsed with the autodetected encoding
|
* parsed with the autodetected encoding
|
||||||
* into the parser reading buffer.
|
* into the parser reading buffer.
|
||||||
*/
|
*/
|
||||||
nbchars = xmlCharEncFirstLineInt(input->buf->encoder,
|
nbchars = xmlCharEncFirstLineInput(input->buf, len);
|
||||||
input->buf->buffer,
|
|
||||||
input->buf->raw,
|
|
||||||
len);
|
|
||||||
}
|
}
|
||||||
if (nbchars < 0) {
|
if (nbchars < 0) {
|
||||||
xmlErrInternal(ctxt,
|
xmlErrInternal(ctxt,
|
||||||
|
@ -1256,10 +1217,8 @@ xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
|
||||||
NULL);
|
NULL);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
input->buf->rawconsumed += use - input->buf->raw->use;
|
input->buf->rawconsumed += use - xmlBufUse(input->buf->raw);
|
||||||
input->base = input->cur = input->buf->buffer->content;
|
xmlBufResetInput(input->buf->buffer, input);
|
||||||
input->end = &input->base[input->buf->buffer->use];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
} else if (input->length == 0) {
|
} else if (input->length == 0) {
|
||||||
|
@ -1372,13 +1331,13 @@ xmlFreeInputStream(xmlParserInputPtr input) {
|
||||||
* xmlNewInputStream:
|
* xmlNewInputStream:
|
||||||
* @ctxt: an XML parser context
|
* @ctxt: an XML parser context
|
||||||
*
|
*
|
||||||
* Create a new input stream structure
|
* Create a new input stream structure.
|
||||||
|
*
|
||||||
* Returns the new input stream or NULL
|
* Returns the new input stream or NULL
|
||||||
*/
|
*/
|
||||||
xmlParserInputPtr
|
xmlParserInputPtr
|
||||||
xmlNewInputStream(xmlParserCtxtPtr ctxt) {
|
xmlNewInputStream(xmlParserCtxtPtr ctxt) {
|
||||||
xmlParserInputPtr input;
|
xmlParserInputPtr input;
|
||||||
static int id = 0;
|
|
||||||
|
|
||||||
input = (xmlParserInputPtr) xmlMalloc(sizeof(xmlParserInput));
|
input = (xmlParserInputPtr) xmlMalloc(sizeof(xmlParserInput));
|
||||||
if (input == NULL) {
|
if (input == NULL) {
|
||||||
|
@ -1389,11 +1348,15 @@ xmlNewInputStream(xmlParserCtxtPtr ctxt) {
|
||||||
input->line = 1;
|
input->line = 1;
|
||||||
input->col = 1;
|
input->col = 1;
|
||||||
input->standalone = -1;
|
input->standalone = -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* we don't care about thread reentrancy unicity for a single
|
* If the context is NULL the id cannot be initialized, but that
|
||||||
* parser context (and hence thread) is sufficient.
|
* should not happen while parsing which is the situation where
|
||||||
|
* the id is actually needed.
|
||||||
*/
|
*/
|
||||||
input->id = id++;
|
if (ctxt != NULL)
|
||||||
|
input->id = ctxt->input_id++;
|
||||||
|
|
||||||
return(input);
|
return(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1422,9 +1385,8 @@ xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input,
|
||||||
}
|
}
|
||||||
inputStream->filename = NULL;
|
inputStream->filename = NULL;
|
||||||
inputStream->buf = input;
|
inputStream->buf = input;
|
||||||
inputStream->base = inputStream->buf->buffer->content;
|
xmlBufResetInput(inputStream->buf->buffer, inputStream);
|
||||||
inputStream->cur = inputStream->buf->buffer->content;
|
|
||||||
inputStream->end = &inputStream->base[inputStream->buf->buffer->use];
|
|
||||||
if (enc != XML_CHAR_ENCODING_NONE) {
|
if (enc != XML_CHAR_ENCODING_NONE) {
|
||||||
xmlSwitchEncoding(ctxt, enc);
|
xmlSwitchEncoding(ctxt, enc);
|
||||||
}
|
}
|
||||||
|
@ -1577,9 +1539,7 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
|
||||||
if (URI != NULL) xmlFree((char *) URI);
|
if (URI != NULL) xmlFree((char *) URI);
|
||||||
inputStream->directory = directory;
|
inputStream->directory = directory;
|
||||||
|
|
||||||
inputStream->base = inputStream->buf->buffer->content;
|
xmlBufResetInput(inputStream->buf->buffer, inputStream);
|
||||||
inputStream->cur = inputStream->buf->buffer->content;
|
|
||||||
inputStream->end = &inputStream->base[inputStream->buf->buffer->use];
|
|
||||||
if ((ctxt->directory == NULL) && (directory != NULL))
|
if ((ctxt->directory == NULL) && (directory != NULL))
|
||||||
ctxt->directory = (char *) xmlStrdup((const xmlChar *) directory);
|
ctxt->directory = (char *) xmlStrdup((const xmlChar *) directory);
|
||||||
return(inputStream);
|
return(inputStream);
|
||||||
|
@ -1618,6 +1578,8 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
|
||||||
xmlErrMemory(NULL, "cannot initialize parser context\n");
|
xmlErrMemory(NULL, "cannot initialize parser context\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
xmlDictSetLimit(ctxt->dict, XML_MAX_DICTIONARY_LIMIT);
|
||||||
|
|
||||||
if (ctxt->sax == NULL)
|
if (ctxt->sax == NULL)
|
||||||
ctxt->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
|
ctxt->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
|
||||||
if (ctxt->sax == NULL) {
|
if (ctxt->sax == NULL) {
|
||||||
|
@ -1757,6 +1719,7 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
|
||||||
ctxt->charset = XML_CHAR_ENCODING_UTF8;
|
ctxt->charset = XML_CHAR_ENCODING_UTF8;
|
||||||
ctxt->catalogs = NULL;
|
ctxt->catalogs = NULL;
|
||||||
ctxt->nbentities = 0;
|
ctxt->nbentities = 0;
|
||||||
|
ctxt->input_id = 1;
|
||||||
xmlInitNodeInfoSeq(&ctxt->node_seq);
|
xmlInitNodeInfoSeq(&ctxt->node_seq);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
6
reactos/lib/3rdparty/libxml2/pattern.c
vendored
6
reactos/lib/3rdparty/libxml2/pattern.c
vendored
|
@ -39,6 +39,9 @@
|
||||||
|
|
||||||
/* #define DEBUG_STREAMING */
|
/* #define DEBUG_STREAMING */
|
||||||
|
|
||||||
|
#ifdef ERROR
|
||||||
|
#undef ERROR
|
||||||
|
#endif
|
||||||
#define ERROR(a, b, c, d)
|
#define ERROR(a, b, c, d)
|
||||||
#define ERROR5(a, b, c, d, e)
|
#define ERROR5(a, b, c, d, e)
|
||||||
|
|
||||||
|
@ -305,7 +308,8 @@ xmlNewPatParserContext(const xmlChar *pattern, xmlDictPtr dict,
|
||||||
cur->base = pattern;
|
cur->base = pattern;
|
||||||
if (namespaces != NULL) {
|
if (namespaces != NULL) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0;namespaces[2 * i] != NULL;i++);
|
for (i = 0;namespaces[2 * i] != NULL;i++)
|
||||||
|
;
|
||||||
cur->nb_namespaces = i;
|
cur->nb_namespaces = i;
|
||||||
} else {
|
} else {
|
||||||
cur->nb_namespaces = 0;
|
cur->nb_namespaces = 0;
|
||||||
|
|
42
reactos/lib/3rdparty/libxml2/relaxng.c
vendored
42
reactos/lib/3rdparty/libxml2/relaxng.c
vendored
|
@ -39,9 +39,10 @@
|
||||||
static const xmlChar *xmlRelaxNGNs = (const xmlChar *)
|
static const xmlChar *xmlRelaxNGNs = (const xmlChar *)
|
||||||
"http://relaxng.org/ns/structure/1.0";
|
"http://relaxng.org/ns/structure/1.0";
|
||||||
|
|
||||||
#define IS_RELAXNG(node, type) \
|
#define IS_RELAXNG(node, typ) \
|
||||||
((node != NULL) && (node->ns != NULL) && \
|
((node != NULL) && (node->ns != NULL) && \
|
||||||
(xmlStrEqual(node->name, (const xmlChar *) type)) && \
|
(node->type == XML_ELEMENT_NODE) && \
|
||||||
|
(xmlStrEqual(node->name, (const xmlChar *) typ)) && \
|
||||||
(xmlStrEqual(node->ns->href, xmlRelaxNGNs)))
|
(xmlStrEqual(node->ns->href, xmlRelaxNGNs)))
|
||||||
|
|
||||||
|
|
||||||
|
@ -1561,8 +1562,8 @@ xmlRelaxNGRemoveRedefine(xmlRelaxNGParserCtxtPtr ctxt,
|
||||||
href = xmlGetProp(tmp, BAD_CAST "href");
|
href = xmlGetProp(tmp, BAD_CAST "href");
|
||||||
#endif
|
#endif
|
||||||
if (xmlRelaxNGRemoveRedefine(ctxt, href,
|
if (xmlRelaxNGRemoveRedefine(ctxt, href,
|
||||||
inc->doc->children->
|
xmlDocGetRootElement(inc->doc)->children,
|
||||||
children, name) == 1) {
|
name) == 1) {
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_INCLUDE
|
#ifdef DEBUG_INCLUDE
|
||||||
|
@ -3059,8 +3060,8 @@ xmlRelaxNGCompile(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def)
|
||||||
list = list->next;
|
list = list->next;
|
||||||
}
|
}
|
||||||
xmlAutomataSetFinalState(ctxt->am, ctxt->state);
|
xmlAutomataSetFinalState(ctxt->am, ctxt->state);
|
||||||
def->contModel = xmlAutomataCompile(ctxt->am);
|
if (xmlAutomataIsDeterminist(ctxt->am))
|
||||||
xmlRegexpIsDeterminist(def->contModel);
|
def->contModel = xmlAutomataCompile(ctxt->am);
|
||||||
|
|
||||||
xmlFreeAutomata(ctxt->am);
|
xmlFreeAutomata(ctxt->am);
|
||||||
ctxt->state = oldstate;
|
ctxt->state = oldstate;
|
||||||
|
@ -8884,6 +8885,11 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
|
||||||
case XML_RELAXNG_ZEROORMORE:{
|
case XML_RELAXNG_ZEROORMORE:{
|
||||||
xmlChar *cur, *temp;
|
xmlChar *cur, *temp;
|
||||||
|
|
||||||
|
if ((ctxt->state->value == NULL) ||
|
||||||
|
(*ctxt->state->value == 0)) {
|
||||||
|
ret = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
oldflags = ctxt->flags;
|
oldflags = ctxt->flags;
|
||||||
ctxt->flags |= FLAGS_IGNORABLE;
|
ctxt->flags |= FLAGS_IGNORABLE;
|
||||||
cur = ctxt->state->value;
|
cur = ctxt->state->value;
|
||||||
|
@ -8905,6 +8911,30 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
|
||||||
xmlRelaxNGPopErrors(ctxt, 0);
|
xmlRelaxNGPopErrors(ctxt, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case XML_RELAXNG_OPTIONAL:{
|
||||||
|
xmlChar *temp;
|
||||||
|
|
||||||
|
if ((ctxt->state->value == NULL) ||
|
||||||
|
(*ctxt->state->value == 0)) {
|
||||||
|
ret = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
oldflags = ctxt->flags;
|
||||||
|
ctxt->flags |= FLAGS_IGNORABLE;
|
||||||
|
temp = ctxt->state->value;
|
||||||
|
ret = xmlRelaxNGValidateValue(ctxt, define->content);
|
||||||
|
ctxt->flags = oldflags;
|
||||||
|
if (ret != 0) {
|
||||||
|
ctxt->state->value = temp;
|
||||||
|
if (ctxt->errNr > 0)
|
||||||
|
xmlRelaxNGPopErrors(ctxt, 0);
|
||||||
|
ret = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ctxt->errNr > 0)
|
||||||
|
xmlRelaxNGPopErrors(ctxt, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case XML_RELAXNG_EXCEPT:{
|
case XML_RELAXNG_EXCEPT:{
|
||||||
xmlRelaxNGDefinePtr list;
|
xmlRelaxNGDefinePtr list;
|
||||||
|
|
||||||
|
|
12
reactos/lib/3rdparty/libxml2/runsuite.c
vendored
12
reactos/lib/3rdparty/libxml2/runsuite.c
vendored
|
@ -6,11 +6,8 @@
|
||||||
* daniel@veillard.com
|
* daniel@veillard.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "libxml.h"
|
#include "libxml.h"
|
||||||
#else
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -39,15 +36,6 @@ static FILE *logfile = NULL;
|
||||||
static int verbose = 0;
|
static int verbose = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
|
|
||||||
#define vsnprintf _vsnprintf
|
|
||||||
|
|
||||||
#define snprintf _snprintf
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* File name and path utilities *
|
* File name and path utilities *
|
||||||
|
|
116
reactos/lib/3rdparty/libxml2/runtest.c
vendored
116
reactos/lib/3rdparty/libxml2/runtest.c
vendored
|
@ -11,11 +11,8 @@
|
||||||
* daniel@veillard.com
|
* daniel@veillard.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "libxml.h"
|
#include "libxml.h"
|
||||||
#else
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -194,8 +191,7 @@ static void globfree(glob_t *pglob) {
|
||||||
free(pglob->gl_pathv[i]);
|
free(pglob->gl_pathv[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#define vsnprintf _vsnprintf
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#else
|
#else
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -2728,7 +2724,7 @@ static const char *urip_testURLs[] = {
|
||||||
"file:///path/to/a%20b.html",
|
"file:///path/to/a%20b.html",
|
||||||
"/path/to/a b.html",
|
"/path/to/a b.html",
|
||||||
"/path/to/a%20b.html",
|
"/path/to/a%20b.html",
|
||||||
"urip://example.com/résumé.html",
|
"urip://example.com/r" "\xe9" "sum" "\xe9" ".html",
|
||||||
"urip://example.com/test?a=1&b=2%263&c=4#foo",
|
"urip://example.com/test?a=1&b=2%263&c=4#foo",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
@ -3936,60 +3932,7 @@ thread_specific_data(void *private_data)
|
||||||
return ((void *) Okay);
|
return ((void *) Okay);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(linux) || defined(__sun) || defined(__APPLE_CC__)
|
#if defined WIN32
|
||||||
|
|
||||||
#include <pthread.h>
|
|
||||||
|
|
||||||
static pthread_t tid[MAX_ARGC];
|
|
||||||
|
|
||||||
static int
|
|
||||||
testThread(void)
|
|
||||||
{
|
|
||||||
unsigned int i, repeat;
|
|
||||||
unsigned int num_threads = sizeof(testfiles) / sizeof(testfiles[0]);
|
|
||||||
void *results[MAX_ARGC];
|
|
||||||
int ret;
|
|
||||||
int res = 0;
|
|
||||||
|
|
||||||
xmlInitParser();
|
|
||||||
|
|
||||||
for (repeat = 0; repeat < 500; repeat++) {
|
|
||||||
xmlLoadCatalog(catalog);
|
|
||||||
nb_tests++;
|
|
||||||
|
|
||||||
for (i = 0; i < num_threads; i++) {
|
|
||||||
results[i] = NULL;
|
|
||||||
tid[i] = (pthread_t) - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < num_threads; i++) {
|
|
||||||
ret = pthread_create(&tid[i], 0, thread_specific_data,
|
|
||||||
(void *) testfiles[i]);
|
|
||||||
if (ret != 0) {
|
|
||||||
fprintf(stderr, "pthread_create failed\n");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (i = 0; i < num_threads; i++) {
|
|
||||||
ret = pthread_join(tid[i], &results[i]);
|
|
||||||
if (ret != 0) {
|
|
||||||
fprintf(stderr, "pthread_join failed\n");
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
xmlCatalogCleanup();
|
|
||||||
for (i = 0; i < num_threads; i++)
|
|
||||||
if (results[i] != (void *) Okay) {
|
|
||||||
fprintf(stderr, "Thread %d handling %s failed\n",
|
|
||||||
i, testfiles[i]);
|
|
||||||
res = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (res);
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined WIN32
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -4115,6 +4058,59 @@ testThread(void)
|
||||||
return(1);
|
return(1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif defined HAVE_PTHREAD_H
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
|
static pthread_t tid[MAX_ARGC];
|
||||||
|
|
||||||
|
static int
|
||||||
|
testThread(void)
|
||||||
|
{
|
||||||
|
unsigned int i, repeat;
|
||||||
|
unsigned int num_threads = sizeof(testfiles) / sizeof(testfiles[0]);
|
||||||
|
void *results[MAX_ARGC];
|
||||||
|
int ret;
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
xmlInitParser();
|
||||||
|
|
||||||
|
for (repeat = 0; repeat < 500; repeat++) {
|
||||||
|
xmlLoadCatalog(catalog);
|
||||||
|
nb_tests++;
|
||||||
|
|
||||||
|
for (i = 0; i < num_threads; i++) {
|
||||||
|
results[i] = NULL;
|
||||||
|
tid[i] = (pthread_t) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < num_threads; i++) {
|
||||||
|
ret = pthread_create(&tid[i], 0, thread_specific_data,
|
||||||
|
(void *) testfiles[i]);
|
||||||
|
if (ret != 0) {
|
||||||
|
fprintf(stderr, "pthread_create failed\n");
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = 0; i < num_threads; i++) {
|
||||||
|
ret = pthread_join(tid[i], &results[i]);
|
||||||
|
if (ret != 0) {
|
||||||
|
fprintf(stderr, "pthread_join failed\n");
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xmlCatalogCleanup();
|
||||||
|
for (i = 0; i < num_threads; i++)
|
||||||
|
if (results[i] != (void *) Okay) {
|
||||||
|
fprintf(stderr, "Thread %d handling %s failed\n",
|
||||||
|
i, testfiles[i]);
|
||||||
|
res = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (res);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
static int
|
static int
|
||||||
testThread(void)
|
testThread(void)
|
||||||
|
|
12
reactos/lib/3rdparty/libxml2/runxmlconf.c
vendored
12
reactos/lib/3rdparty/libxml2/runxmlconf.c
vendored
|
@ -6,11 +6,8 @@
|
||||||
* daniel@veillard.com
|
* daniel@veillard.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "libxml.h"
|
#include "libxml.h"
|
||||||
#else
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LIBXML_XPATH_ENABLED
|
#ifdef LIBXML_XPATH_ENABLED
|
||||||
|
|
||||||
|
@ -37,13 +34,6 @@ static int verbose = 0;
|
||||||
|
|
||||||
#define NB_EXPECTED_ERRORS 15
|
#define NB_EXPECTED_ERRORS 15
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
|
|
||||||
#define vsnprintf _vsnprintf
|
|
||||||
|
|
||||||
#define snprintf _snprintf
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const char *skipped_tests[] = {
|
const char *skipped_tests[] = {
|
||||||
/* http://lists.w3.org/Archives/Public/public-xml-testsuite/2008Jul/0000.html */
|
/* http://lists.w3.org/Archives/Public/public-xml-testsuite/2008Jul/0000.html */
|
||||||
|
@ -516,7 +506,7 @@ static void
|
||||||
xmlconfInfo(void) {
|
xmlconfInfo(void) {
|
||||||
fprintf(stderr, " you need to fetch and extract the\n");
|
fprintf(stderr, " you need to fetch and extract the\n");
|
||||||
fprintf(stderr, " latest XML Conformance Test Suites\n");
|
fprintf(stderr, " latest XML Conformance Test Suites\n");
|
||||||
fprintf(stderr, " http://www.w3.org/XML/Test/xmlts20080205.tar.gz\n");
|
fprintf(stderr, " http://www.w3.org/XML/Test/xmlts20080827.tar.gz\n");
|
||||||
fprintf(stderr, " see http://www.w3.org/XML/Test/ for informations\n");
|
fprintf(stderr, " see http://www.w3.org/XML/Test/ for informations\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
35
reactos/lib/3rdparty/libxml2/save.h
vendored
Normal file
35
reactos/lib/3rdparty/libxml2/save.h
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Summary: Internal Interfaces for saving in libxml2
|
||||||
|
* Description: this module describes a few interfaces which were
|
||||||
|
* addded along with the API changes in 2.9.0
|
||||||
|
* those are private routines at this point
|
||||||
|
*
|
||||||
|
* Copy: See Copyright for the status of this software.
|
||||||
|
*
|
||||||
|
* Author: Daniel Veillard
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __XML_SAVE_H__
|
||||||
|
#define __XML_SAVE_H__
|
||||||
|
|
||||||
|
#include <libxml/tree.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LIBXML_OUTPUT_ENABLED
|
||||||
|
void xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc,
|
||||||
|
xmlAttrPtr attr, const xmlChar * string);
|
||||||
|
void xmlBufDumpNotationTable(xmlBufPtr buf, xmlNotationTablePtr table);
|
||||||
|
void xmlBufDumpElementDecl(xmlBufPtr buf, xmlElementPtr elem);
|
||||||
|
void xmlBufDumpAttributeDecl(xmlBufPtr buf, xmlAttributePtr attr);
|
||||||
|
void xmlBufDumpEntityDecl(xmlBufPtr buf, xmlEntityPtr ent);
|
||||||
|
xmlChar *xmlEncodeAttributeEntities(xmlDocPtr doc, const xmlChar *input);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* __XML_SAVE_H__ */
|
||||||
|
|
8
reactos/lib/3rdparty/libxml2/testC14N.c
vendored
8
reactos/lib/3rdparty/libxml2/testC14N.c
vendored
|
@ -11,8 +11,12 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#ifndef STDOUT_FILENO
|
||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#else
|
||||||
|
#define STDOUT_FILENO fileno(stdout)
|
||||||
|
#endif /* HAVE_UNISTD_H */
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_STDLIB_H
|
#ifdef HAVE_STDLIB_H
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -104,7 +108,9 @@ test_c14n(const char* xml_filename, int with_comments, int mode,
|
||||||
with_comments, &result);
|
with_comments, &result);
|
||||||
if(ret >= 0) {
|
if(ret >= 0) {
|
||||||
if(result != NULL) {
|
if(result != NULL) {
|
||||||
write(1, result, ret);
|
if (write(STDOUT_FILENO, result, ret) == -1) {
|
||||||
|
fprintf(stderr, "Can't write data\n");
|
||||||
|
}
|
||||||
xmlFree(result);
|
xmlFree(result);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
8
reactos/lib/3rdparty/libxml2/testRelax.c
vendored
8
reactos/lib/3rdparty/libxml2/testRelax.c
vendored
|
@ -49,7 +49,7 @@ static int debug = 0;
|
||||||
#endif
|
#endif
|
||||||
static int noout = 0;
|
static int noout = 0;
|
||||||
static int tree = 0;
|
static int tree = 0;
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
static int memory = 0;
|
static int memory = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ int main(int argc, char **argv) {
|
||||||
debug++;
|
debug++;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) {
|
if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) {
|
||||||
memory++;
|
memory++;
|
||||||
} else
|
} else
|
||||||
|
@ -84,7 +84,7 @@ int main(int argc, char **argv) {
|
||||||
if (schema == NULL) {
|
if (schema == NULL) {
|
||||||
xmlRelaxNGParserCtxtPtr ctxt;
|
xmlRelaxNGParserCtxtPtr ctxt;
|
||||||
|
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
if (memory) {
|
if (memory) {
|
||||||
int fd;
|
int fd;
|
||||||
struct stat info;
|
struct stat info;
|
||||||
|
@ -174,7 +174,7 @@ int main(int argc, char **argv) {
|
||||||
#endif
|
#endif
|
||||||
printf("\t--noout : do not print the result\n");
|
printf("\t--noout : do not print the result\n");
|
||||||
printf("\t--tree : print the intermediate Relax-NG document tree\n");
|
printf("\t--tree : print the intermediate Relax-NG document tree\n");
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
printf("\t--memory : test the schemas in memory parsing\n");
|
printf("\t--memory : test the schemas in memory parsing\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
8
reactos/lib/3rdparty/libxml2/testSchemas.c
vendored
8
reactos/lib/3rdparty/libxml2/testSchemas.c
vendored
|
@ -49,7 +49,7 @@
|
||||||
static int debug = 0;
|
static int debug = 0;
|
||||||
#endif
|
#endif
|
||||||
static int noout = 0;
|
static int noout = 0;
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
static int memory = 0;
|
static int memory = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ int main(int argc, char **argv) {
|
||||||
debug++;
|
debug++;
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) {
|
if ((!strcmp(argv[i], "-memory")) || (!strcmp(argv[i], "--memory"))) {
|
||||||
memory++;
|
memory++;
|
||||||
} else
|
} else
|
||||||
|
@ -80,7 +80,7 @@ int main(int argc, char **argv) {
|
||||||
if (schema == NULL) {
|
if (schema == NULL) {
|
||||||
xmlSchemaParserCtxtPtr ctxt;
|
xmlSchemaParserCtxtPtr ctxt;
|
||||||
|
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
if (memory) {
|
if (memory) {
|
||||||
int fd;
|
int fd;
|
||||||
struct stat info;
|
struct stat info;
|
||||||
|
@ -164,7 +164,7 @@ int main(int argc, char **argv) {
|
||||||
printf("\t--debug : dump a debug tree of the in-memory document\n");
|
printf("\t--debug : dump a debug tree of the in-memory document\n");
|
||||||
#endif
|
#endif
|
||||||
printf("\t--noout : do not print the result\n");
|
printf("\t--noout : do not print the result\n");
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
printf("\t--memory : test the schemas in memory parsing\n");
|
printf("\t--memory : test the schemas in memory parsing\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
6
reactos/lib/3rdparty/libxml2/testThreads.c
vendored
6
reactos/lib/3rdparty/libxml2/testThreads.c
vendored
|
@ -105,10 +105,8 @@ main(void)
|
||||||
for (repeat = 0;repeat < 500;repeat++) {
|
for (repeat = 0;repeat < 500;repeat++) {
|
||||||
xmlLoadCatalog(catalog);
|
xmlLoadCatalog(catalog);
|
||||||
|
|
||||||
for (i = 0; i < num_threads; i++) {
|
memset(results, 0, sizeof(*results)*num_threads);
|
||||||
results[i] = NULL;
|
memset(tid, 0xff, sizeof(*tid)*num_threads);
|
||||||
tid[i] = (pthread_t) -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < num_threads; i++) {
|
for (i = 0; i < num_threads; i++) {
|
||||||
ret = pthread_create(&tid[i], NULL, thread_specific_data,
|
ret = pthread_create(&tid[i], NULL, thread_specific_data,
|
||||||
|
|
2
reactos/lib/3rdparty/libxml2/testXPath.c
vendored
2
reactos/lib/3rdparty/libxml2/testXPath.c
vendored
|
@ -172,10 +172,12 @@ int main(int argc, char **argv) {
|
||||||
xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS;
|
xmlLoadExtDtdDefaultValue |= XML_DETECT_IDS;
|
||||||
xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
|
xmlLoadExtDtdDefaultValue |= XML_COMPLETE_ATTRS;
|
||||||
xmlSubstituteEntitiesDefaultValue = 1;
|
xmlSubstituteEntitiesDefaultValue = 1;
|
||||||
|
#ifdef LIBXML_SAX1_ENABLED
|
||||||
if (nocdata != 0) {
|
if (nocdata != 0) {
|
||||||
xmlDefaultSAXHandlerInit();
|
xmlDefaultSAXHandlerInit();
|
||||||
xmlDefaultSAXHandler.cdataBlock = NULL;
|
xmlDefaultSAXHandler.cdataBlock = NULL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (document == NULL) {
|
if (document == NULL) {
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
document = xmlReadDoc(buffer,NULL,NULL,XML_PARSE_COMPACT);
|
document = xmlReadDoc(buffer,NULL,NULL,XML_PARSE_COMPACT);
|
||||||
|
|
472
reactos/lib/3rdparty/libxml2/testapi.c
vendored
472
reactos/lib/3rdparty/libxml2/testapi.c
vendored
|
@ -8,20 +8,14 @@
|
||||||
* daniel@veillard.com
|
* daniel@veillard.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "libxml.h"
|
#include "libxml.h"
|
||||||
#else
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h> /* for putenv() */
|
#include <stdlib.h> /* for putenv() */
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <libxml/xmlerror.h>
|
#include <libxml/xmlerror.h>
|
||||||
#include <libxml/relaxng.h>
|
#include <libxml/relaxng.h>
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int testlibxml2(void);
|
static int testlibxml2(void);
|
||||||
static int test_module(const char *module);
|
static int test_module(const char *module);
|
||||||
|
@ -127,8 +121,10 @@ int main(int argc, char **argv) {
|
||||||
int ret;
|
int ret;
|
||||||
int blocks, mem;
|
int blocks, mem;
|
||||||
|
|
||||||
|
#ifdef HAVE_PUTENV
|
||||||
/* access to the proxy can slow up regression tests a lot */
|
/* access to the proxy can slow up regression tests a lot */
|
||||||
putenv((char *) "http_proxy=");
|
putenv((char *) "http_proxy=");
|
||||||
|
#endif
|
||||||
|
|
||||||
memset(chartab, 0, sizeof(chartab));
|
memset(chartab, 0, sizeof(chartab));
|
||||||
strncpy((char *) chartab, " chartab\n", 20);
|
strncpy((char *) chartab, " chartab\n", 20);
|
||||||
|
@ -291,7 +287,7 @@ static void des_long(int no ATTRIBUTE_UNUSED, long val ATTRIBUTE_UNUSED, int nr
|
||||||
static xmlChar gen_xmlChar(int no, int nr ATTRIBUTE_UNUSED) {
|
static xmlChar gen_xmlChar(int no, int nr ATTRIBUTE_UNUSED) {
|
||||||
if (no == 0) return('a');
|
if (no == 0) return('a');
|
||||||
if (no == 1) return(' ');
|
if (no == 1) return(' ');
|
||||||
if (no == 2) return((xmlChar) 'ø');
|
if (no == 2) return((xmlChar) '\xf8');
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,7 +395,7 @@ static void des_debug_FILE_ptr(int no ATTRIBUTE_UNUSED, FILE *val, int nr ATTRIB
|
||||||
static xmlChar *gen_const_xmlChar_ptr(int no, int nr ATTRIBUTE_UNUSED) {
|
static xmlChar *gen_const_xmlChar_ptr(int no, int nr ATTRIBUTE_UNUSED) {
|
||||||
if (no == 0) return((xmlChar *) "foo");
|
if (no == 0) return((xmlChar *) "foo");
|
||||||
if (no == 1) return((xmlChar *) "<foo/>");
|
if (no == 1) return((xmlChar *) "<foo/>");
|
||||||
if (no == 2) return((xmlChar *) "nøne");
|
if (no == 2) return((xmlChar *) "n" "\xf8" "ne");
|
||||||
if (no == 3) return((xmlChar *) " 2ab ");
|
if (no == 3) return((xmlChar *) " 2ab ");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
@ -599,7 +595,7 @@ static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define gen_nb_xmlBufferPtr 3
|
#define gen_nb_xmlBufferPtr 3
|
||||||
static const char *static_buf_content = "a static buffer";
|
static const xmlChar *static_buf_content = (xmlChar *)"a static buffer";
|
||||||
static xmlBufferPtr gen_xmlBufferPtr(int no, int nr ATTRIBUTE_UNUSED) {
|
static xmlBufferPtr gen_xmlBufferPtr(int no, int nr ATTRIBUTE_UNUSED) {
|
||||||
if (no == 0) return(xmlBufferCreate());
|
if (no == 0) return(xmlBufferCreate());
|
||||||
if (no == 1) return(xmlBufferCreateStatic((void *)static_buf_content, 13));
|
if (no == 1) return(xmlBufferCreateStatic((void *)static_buf_content, 13));
|
||||||
|
@ -1040,8 +1036,8 @@ static void des_xmlAttributeType(int no ATTRIBUTE_UNUSED, xmlAttributeType val A
|
||||||
static xmlBufferAllocationScheme gen_xmlBufferAllocationScheme(int no, int nr ATTRIBUTE_UNUSED) {
|
static xmlBufferAllocationScheme gen_xmlBufferAllocationScheme(int no, int nr ATTRIBUTE_UNUSED) {
|
||||||
if (no == 1) return(XML_BUFFER_ALLOC_DOUBLEIT);
|
if (no == 1) return(XML_BUFFER_ALLOC_DOUBLEIT);
|
||||||
if (no == 2) return(XML_BUFFER_ALLOC_EXACT);
|
if (no == 2) return(XML_BUFFER_ALLOC_EXACT);
|
||||||
if (no == 3) return(XML_BUFFER_ALLOC_IMMUTABLE);
|
if (no == 3) return(XML_BUFFER_ALLOC_HYBRID);
|
||||||
if (no == 4) return(XML_BUFFER_ALLOC_IO);
|
if (no == 4) return(XML_BUFFER_ALLOC_IMMUTABLE);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8251,6 +8247,16 @@ test_xmlDictExists(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlDictGetUsage(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* missing type support */
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_xmlDictLookup(void) {
|
test_xmlDictLookup(void) {
|
||||||
int test_ret = 0;
|
int test_ret = 0;
|
||||||
|
@ -8415,6 +8421,16 @@ test_xmlDictReference(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlDictSetLimit(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* missing type support */
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_xmlDictSize(void) {
|
test_xmlDictSize(void) {
|
||||||
int test_ret = 0;
|
int test_ret = 0;
|
||||||
|
@ -8446,20 +8462,48 @@ test_xmlDictSize(void) {
|
||||||
return(test_ret);
|
return(test_ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlInitializeDict(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
int mem_base;
|
||||||
|
int ret_val;
|
||||||
|
|
||||||
|
mem_base = xmlMemBlocks();
|
||||||
|
|
||||||
|
ret_val = xmlInitializeDict();
|
||||||
|
desret_int(ret_val);
|
||||||
|
call_tests++;
|
||||||
|
xmlResetLastError();
|
||||||
|
if (mem_base != xmlMemBlocks()) {
|
||||||
|
printf("Leak of %d blocks found in xmlInitializeDict",
|
||||||
|
xmlMemBlocks() - mem_base);
|
||||||
|
test_ret++;
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
function_tests++;
|
||||||
|
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_dict(void) {
|
test_dict(void) {
|
||||||
int test_ret = 0;
|
int test_ret = 0;
|
||||||
|
|
||||||
if (quiet == 0) printf("Testing dict : 9 of 10 functions ...\n");
|
if (quiet == 0) printf("Testing dict : 10 of 13 functions ...\n");
|
||||||
test_ret += test_xmlDictCleanup();
|
test_ret += test_xmlDictCleanup();
|
||||||
test_ret += test_xmlDictCreate();
|
test_ret += test_xmlDictCreate();
|
||||||
test_ret += test_xmlDictCreateSub();
|
test_ret += test_xmlDictCreateSub();
|
||||||
test_ret += test_xmlDictExists();
|
test_ret += test_xmlDictExists();
|
||||||
|
test_ret += test_xmlDictGetUsage();
|
||||||
test_ret += test_xmlDictLookup();
|
test_ret += test_xmlDictLookup();
|
||||||
test_ret += test_xmlDictOwns();
|
test_ret += test_xmlDictOwns();
|
||||||
test_ret += test_xmlDictQLookup();
|
test_ret += test_xmlDictQLookup();
|
||||||
test_ret += test_xmlDictReference();
|
test_ret += test_xmlDictReference();
|
||||||
|
test_ret += test_xmlDictSetLimit();
|
||||||
test_ret += test_xmlDictSize();
|
test_ret += test_xmlDictSize();
|
||||||
|
test_ret += test_xmlInitializeDict();
|
||||||
|
|
||||||
if (test_ret != 0)
|
if (test_ret != 0)
|
||||||
printf("Module dict: %d errors\n", test_ret);
|
printf("Module dict: %d errors\n", test_ret);
|
||||||
|
@ -13508,7 +13552,7 @@ test_xmlParseBalancedChunkMemory(void) {
|
||||||
depth = gen_int(n_depth, 3);
|
depth = gen_int(n_depth, 3);
|
||||||
string = gen_const_xmlChar_ptr(n_string, 4);
|
string = gen_const_xmlChar_ptr(n_string, 4);
|
||||||
lst = gen_xmlNodePtr_ptr(n_lst, 5);
|
lst = gen_xmlNodePtr_ptr(n_lst, 5);
|
||||||
|
|
||||||
#ifdef LIBXML_SAX1_ENABLED
|
#ifdef LIBXML_SAX1_ENABLED
|
||||||
if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;
|
if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
@ -13588,7 +13632,7 @@ test_xmlParseBalancedChunkMemoryRecover(void) {
|
||||||
string = gen_const_xmlChar_ptr(n_string, 4);
|
string = gen_const_xmlChar_ptr(n_string, 4);
|
||||||
lst = gen_xmlNodePtr_ptr(n_lst, 5);
|
lst = gen_xmlNodePtr_ptr(n_lst, 5);
|
||||||
recover = gen_int(n_recover, 6);
|
recover = gen_int(n_recover, 6);
|
||||||
|
|
||||||
#ifdef LIBXML_SAX1_ENABLED
|
#ifdef LIBXML_SAX1_ENABLED
|
||||||
if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;
|
if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
@ -15067,7 +15111,7 @@ test_xmlSAXUserParseFile(void) {
|
||||||
sax = gen_xmlSAXHandlerPtr(n_sax, 0);
|
sax = gen_xmlSAXHandlerPtr(n_sax, 0);
|
||||||
user_data = gen_userdata(n_user_data, 1);
|
user_data = gen_userdata(n_user_data, 1);
|
||||||
filename = gen_filepath(n_filename, 2);
|
filename = gen_filepath(n_filename, 2);
|
||||||
|
|
||||||
#ifdef LIBXML_SAX1_ENABLED
|
#ifdef LIBXML_SAX1_ENABLED
|
||||||
if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;
|
if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
@ -15126,7 +15170,7 @@ test_xmlSAXUserParseMemory(void) {
|
||||||
user_data = gen_userdata(n_user_data, 1);
|
user_data = gen_userdata(n_user_data, 1);
|
||||||
buffer = gen_const_char_ptr(n_buffer, 2);
|
buffer = gen_const_char_ptr(n_buffer, 2);
|
||||||
size = gen_int(n_size, 3);
|
size = gen_int(n_size, 3);
|
||||||
|
|
||||||
#ifdef LIBXML_SAX1_ENABLED
|
#ifdef LIBXML_SAX1_ENABLED
|
||||||
if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;
|
if (sax == (xmlSAXHandlerPtr)&xmlDefaultSAXHandler) user_data = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
@ -18359,6 +18403,153 @@ test_xmlAttrSerializeTxtContent(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define gen_nb_const_xmlBufPtr 1
|
||||||
|
static xmlBufPtr gen_const_xmlBufPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
static void des_const_xmlBufPtr(int no ATTRIBUTE_UNUSED, const xmlBufPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlBufContent(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
int mem_base;
|
||||||
|
xmlChar * ret_val;
|
||||||
|
xmlBufPtr buf; /* the buffer */
|
||||||
|
int n_buf;
|
||||||
|
|
||||||
|
for (n_buf = 0;n_buf < gen_nb_const_xmlBufPtr;n_buf++) {
|
||||||
|
mem_base = xmlMemBlocks();
|
||||||
|
buf = gen_const_xmlBufPtr(n_buf, 0);
|
||||||
|
|
||||||
|
ret_val = xmlBufContent((const xmlBufPtr)buf);
|
||||||
|
desret_xmlChar_ptr(ret_val);
|
||||||
|
call_tests++;
|
||||||
|
des_const_xmlBufPtr(n_buf, (const xmlBufPtr)buf, 0);
|
||||||
|
xmlResetLastError();
|
||||||
|
if (mem_base != xmlMemBlocks()) {
|
||||||
|
printf("Leak of %d blocks found in xmlBufContent",
|
||||||
|
xmlMemBlocks() - mem_base);
|
||||||
|
test_ret++;
|
||||||
|
printf(" %d", n_buf);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function_tests++;
|
||||||
|
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlBufEnd(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
int mem_base;
|
||||||
|
xmlChar * ret_val;
|
||||||
|
xmlBufPtr buf; /* the buffer */
|
||||||
|
int n_buf;
|
||||||
|
|
||||||
|
for (n_buf = 0;n_buf < gen_nb_const_xmlBufPtr;n_buf++) {
|
||||||
|
mem_base = xmlMemBlocks();
|
||||||
|
buf = gen_const_xmlBufPtr(n_buf, 0);
|
||||||
|
|
||||||
|
ret_val = xmlBufEnd((const xmlBufPtr)buf);
|
||||||
|
desret_xmlChar_ptr(ret_val);
|
||||||
|
call_tests++;
|
||||||
|
des_const_xmlBufPtr(n_buf, (const xmlBufPtr)buf, 0);
|
||||||
|
xmlResetLastError();
|
||||||
|
if (mem_base != xmlMemBlocks()) {
|
||||||
|
printf("Leak of %d blocks found in xmlBufEnd",
|
||||||
|
xmlMemBlocks() - mem_base);
|
||||||
|
test_ret++;
|
||||||
|
printf(" %d", n_buf);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function_tests++;
|
||||||
|
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define gen_nb_xmlBufPtr 1
|
||||||
|
static xmlBufPtr gen_xmlBufPtr(int no ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
static void des_xmlBufPtr(int no ATTRIBUTE_UNUSED, xmlBufPtr val ATTRIBUTE_UNUSED, int nr ATTRIBUTE_UNUSED) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlBufGetNodeContent(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
int mem_base;
|
||||||
|
int ret_val;
|
||||||
|
xmlBufPtr buf; /* a buffer xmlBufPtr */
|
||||||
|
int n_buf;
|
||||||
|
xmlNodePtr cur; /* the node being read */
|
||||||
|
int n_cur;
|
||||||
|
|
||||||
|
for (n_buf = 0;n_buf < gen_nb_xmlBufPtr;n_buf++) {
|
||||||
|
for (n_cur = 0;n_cur < gen_nb_xmlNodePtr;n_cur++) {
|
||||||
|
mem_base = xmlMemBlocks();
|
||||||
|
buf = gen_xmlBufPtr(n_buf, 0);
|
||||||
|
cur = gen_xmlNodePtr(n_cur, 1);
|
||||||
|
|
||||||
|
ret_val = xmlBufGetNodeContent(buf, cur);
|
||||||
|
desret_int(ret_val);
|
||||||
|
call_tests++;
|
||||||
|
des_xmlBufPtr(n_buf, buf, 0);
|
||||||
|
des_xmlNodePtr(n_cur, cur, 1);
|
||||||
|
xmlResetLastError();
|
||||||
|
if (mem_base != xmlMemBlocks()) {
|
||||||
|
printf("Leak of %d blocks found in xmlBufGetNodeContent",
|
||||||
|
xmlMemBlocks() - mem_base);
|
||||||
|
test_ret++;
|
||||||
|
printf(" %d", n_buf);
|
||||||
|
printf(" %d", n_cur);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function_tests++;
|
||||||
|
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlBufNodeDump(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* missing type support */
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlBufShrink(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* missing type support */
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlBufUse(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* missing type support */
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_xmlBufferAdd(void) {
|
test_xmlBufferAdd(void) {
|
||||||
int test_ret = 0;
|
int test_ret = 0;
|
||||||
|
@ -18613,6 +18804,38 @@ test_xmlBufferCreateStatic(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlBufferDetach(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
int mem_base;
|
||||||
|
xmlChar * ret_val;
|
||||||
|
xmlBufferPtr buf; /* the buffer */
|
||||||
|
int n_buf;
|
||||||
|
|
||||||
|
for (n_buf = 0;n_buf < gen_nb_xmlBufferPtr;n_buf++) {
|
||||||
|
mem_base = xmlMemBlocks();
|
||||||
|
buf = gen_xmlBufferPtr(n_buf, 0);
|
||||||
|
|
||||||
|
ret_val = xmlBufferDetach(buf);
|
||||||
|
desret_xmlChar_ptr(ret_val);
|
||||||
|
call_tests++;
|
||||||
|
des_xmlBufferPtr(n_buf, buf, 0);
|
||||||
|
xmlResetLastError();
|
||||||
|
if (mem_base != xmlMemBlocks()) {
|
||||||
|
printf("Leak of %d blocks found in xmlBufferDetach",
|
||||||
|
xmlMemBlocks() - mem_base);
|
||||||
|
test_ret++;
|
||||||
|
printf(" %d", n_buf);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function_tests++;
|
||||||
|
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_xmlBufferEmpty(void) {
|
test_xmlBufferEmpty(void) {
|
||||||
int test_ret = 0;
|
int test_ret = 0;
|
||||||
|
@ -23957,13 +24180,19 @@ static int
|
||||||
test_tree(void) {
|
test_tree(void) {
|
||||||
int test_ret = 0;
|
int test_ret = 0;
|
||||||
|
|
||||||
if (quiet == 0) printf("Testing tree : 138 of 157 functions ...\n");
|
if (quiet == 0) printf("Testing tree : 142 of 164 functions ...\n");
|
||||||
test_ret += test_xmlAddChild();
|
test_ret += test_xmlAddChild();
|
||||||
test_ret += test_xmlAddChildList();
|
test_ret += test_xmlAddChildList();
|
||||||
test_ret += test_xmlAddNextSibling();
|
test_ret += test_xmlAddNextSibling();
|
||||||
test_ret += test_xmlAddPrevSibling();
|
test_ret += test_xmlAddPrevSibling();
|
||||||
test_ret += test_xmlAddSibling();
|
test_ret += test_xmlAddSibling();
|
||||||
test_ret += test_xmlAttrSerializeTxtContent();
|
test_ret += test_xmlAttrSerializeTxtContent();
|
||||||
|
test_ret += test_xmlBufContent();
|
||||||
|
test_ret += test_xmlBufEnd();
|
||||||
|
test_ret += test_xmlBufGetNodeContent();
|
||||||
|
test_ret += test_xmlBufNodeDump();
|
||||||
|
test_ret += test_xmlBufShrink();
|
||||||
|
test_ret += test_xmlBufUse();
|
||||||
test_ret += test_xmlBufferAdd();
|
test_ret += test_xmlBufferAdd();
|
||||||
test_ret += test_xmlBufferAddHead();
|
test_ret += test_xmlBufferAddHead();
|
||||||
test_ret += test_xmlBufferCCat();
|
test_ret += test_xmlBufferCCat();
|
||||||
|
@ -23972,6 +24201,7 @@ test_tree(void) {
|
||||||
test_ret += test_xmlBufferCreate();
|
test_ret += test_xmlBufferCreate();
|
||||||
test_ret += test_xmlBufferCreateSize();
|
test_ret += test_xmlBufferCreateSize();
|
||||||
test_ret += test_xmlBufferCreateStatic();
|
test_ret += test_xmlBufferCreateStatic();
|
||||||
|
test_ret += test_xmlBufferDetach();
|
||||||
test_ret += test_xmlBufferEmpty();
|
test_ret += test_xmlBufferEmpty();
|
||||||
test_ret += test_xmlBufferGrow();
|
test_ret += test_xmlBufferGrow();
|
||||||
test_ret += test_xmlBufferLength();
|
test_ret += test_xmlBufferLength();
|
||||||
|
@ -28345,6 +28575,50 @@ test_xmlOutputBufferFlush(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlOutputBufferGetContent(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
#if defined(LIBXML_OUTPUT_ENABLED)
|
||||||
|
int mem_base;
|
||||||
|
const xmlChar * ret_val;
|
||||||
|
xmlOutputBufferPtr out; /* an xmlOutputBufferPtr */
|
||||||
|
int n_out;
|
||||||
|
|
||||||
|
for (n_out = 0;n_out < gen_nb_xmlOutputBufferPtr;n_out++) {
|
||||||
|
mem_base = xmlMemBlocks();
|
||||||
|
out = gen_xmlOutputBufferPtr(n_out, 0);
|
||||||
|
|
||||||
|
ret_val = xmlOutputBufferGetContent(out);
|
||||||
|
desret_const_xmlChar_ptr(ret_val);
|
||||||
|
call_tests++;
|
||||||
|
des_xmlOutputBufferPtr(n_out, out, 0);
|
||||||
|
xmlResetLastError();
|
||||||
|
if (mem_base != xmlMemBlocks()) {
|
||||||
|
printf("Leak of %d blocks found in xmlOutputBufferGetContent",
|
||||||
|
xmlMemBlocks() - mem_base);
|
||||||
|
test_ret++;
|
||||||
|
printf(" %d", n_out);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function_tests++;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlOutputBufferGetSize(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* missing type support */
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_xmlOutputBufferWrite(void) {
|
test_xmlOutputBufferWrite(void) {
|
||||||
int test_ret = 0;
|
int test_ret = 0;
|
||||||
|
@ -28889,7 +29163,7 @@ static int
|
||||||
test_xmlIO(void) {
|
test_xmlIO(void) {
|
||||||
int test_ret = 0;
|
int test_ret = 0;
|
||||||
|
|
||||||
if (quiet == 0) printf("Testing xmlIO : 39 of 48 functions ...\n");
|
if (quiet == 0) printf("Testing xmlIO : 40 of 50 functions ...\n");
|
||||||
test_ret += test_xmlAllocOutputBuffer();
|
test_ret += test_xmlAllocOutputBuffer();
|
||||||
test_ret += test_xmlAllocParserInputBuffer();
|
test_ret += test_xmlAllocParserInputBuffer();
|
||||||
test_ret += test_xmlCheckFilename();
|
test_ret += test_xmlCheckFilename();
|
||||||
|
@ -28915,6 +29189,8 @@ test_xmlIO(void) {
|
||||||
test_ret += test_xmlOutputBufferCreateFile();
|
test_ret += test_xmlOutputBufferCreateFile();
|
||||||
test_ret += test_xmlOutputBufferCreateFilename();
|
test_ret += test_xmlOutputBufferCreateFilename();
|
||||||
test_ret += test_xmlOutputBufferFlush();
|
test_ret += test_xmlOutputBufferFlush();
|
||||||
|
test_ret += test_xmlOutputBufferGetContent();
|
||||||
|
test_ret += test_xmlOutputBufferGetSize();
|
||||||
test_ret += test_xmlOutputBufferWrite();
|
test_ret += test_xmlOutputBufferWrite();
|
||||||
test_ret += test_xmlOutputBufferWriteEscape();
|
test_ret += test_xmlOutputBufferWriteEscape();
|
||||||
test_ret += test_xmlOutputBufferWriteString();
|
test_ret += test_xmlOutputBufferWriteString();
|
||||||
|
@ -32274,6 +32550,54 @@ test_xmlTextReaderRelaxNGValidate(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlTextReaderRelaxNGValidateCtxt(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)
|
||||||
|
int mem_base;
|
||||||
|
int ret_val;
|
||||||
|
xmlTextReaderPtr reader; /* the xmlTextReaderPtr used */
|
||||||
|
int n_reader;
|
||||||
|
xmlRelaxNGValidCtxtPtr ctxt; /* the RelaxNG schema validation context or NULL */
|
||||||
|
int n_ctxt;
|
||||||
|
int options; /* options (not used yet) */
|
||||||
|
int n_options;
|
||||||
|
|
||||||
|
for (n_reader = 0;n_reader < gen_nb_xmlTextReaderPtr;n_reader++) {
|
||||||
|
for (n_ctxt = 0;n_ctxt < gen_nb_xmlRelaxNGValidCtxtPtr;n_ctxt++) {
|
||||||
|
for (n_options = 0;n_options < gen_nb_parseroptions;n_options++) {
|
||||||
|
mem_base = xmlMemBlocks();
|
||||||
|
reader = gen_xmlTextReaderPtr(n_reader, 0);
|
||||||
|
ctxt = gen_xmlRelaxNGValidCtxtPtr(n_ctxt, 1);
|
||||||
|
options = gen_parseroptions(n_options, 2);
|
||||||
|
|
||||||
|
ret_val = xmlTextReaderRelaxNGValidateCtxt(reader, ctxt, options);
|
||||||
|
desret_int(ret_val);
|
||||||
|
call_tests++;
|
||||||
|
des_xmlTextReaderPtr(n_reader, reader, 0);
|
||||||
|
des_xmlRelaxNGValidCtxtPtr(n_ctxt, ctxt, 1);
|
||||||
|
des_parseroptions(n_options, options, 2);
|
||||||
|
xmlResetLastError();
|
||||||
|
if (mem_base != xmlMemBlocks()) {
|
||||||
|
printf("Leak of %d blocks found in xmlTextReaderRelaxNGValidateCtxt",
|
||||||
|
xmlMemBlocks() - mem_base);
|
||||||
|
test_ret++;
|
||||||
|
printf(" %d", n_reader);
|
||||||
|
printf(" %d", n_ctxt);
|
||||||
|
printf(" %d", n_options);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function_tests++;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_xmlTextReaderSchemaValidate(void) {
|
test_xmlTextReaderSchemaValidate(void) {
|
||||||
int test_ret = 0;
|
int test_ret = 0;
|
||||||
|
@ -32628,7 +32952,7 @@ static int
|
||||||
test_xmlreader(void) {
|
test_xmlreader(void) {
|
||||||
int test_ret = 0;
|
int test_ret = 0;
|
||||||
|
|
||||||
if (quiet == 0) printf("Testing xmlreader : 75 of 85 functions ...\n");
|
if (quiet == 0) printf("Testing xmlreader : 76 of 86 functions ...\n");
|
||||||
test_ret += test_xmlNewTextReader();
|
test_ret += test_xmlNewTextReader();
|
||||||
test_ret += test_xmlNewTextReaderFilename();
|
test_ret += test_xmlNewTextReaderFilename();
|
||||||
test_ret += test_xmlReaderForDoc();
|
test_ret += test_xmlReaderForDoc();
|
||||||
|
@ -32696,6 +33020,7 @@ test_xmlreader(void) {
|
||||||
test_ret += test_xmlTextReaderReadState();
|
test_ret += test_xmlTextReaderReadState();
|
||||||
test_ret += test_xmlTextReaderRelaxNGSetSchema();
|
test_ret += test_xmlTextReaderRelaxNGSetSchema();
|
||||||
test_ret += test_xmlTextReaderRelaxNGValidate();
|
test_ret += test_xmlTextReaderRelaxNGValidate();
|
||||||
|
test_ret += test_xmlTextReaderRelaxNGValidateCtxt();
|
||||||
test_ret += test_xmlTextReaderSchemaValidate();
|
test_ret += test_xmlTextReaderSchemaValidate();
|
||||||
test_ret += test_xmlTextReaderSchemaValidateCtxt();
|
test_ret += test_xmlTextReaderSchemaValidateCtxt();
|
||||||
test_ret += test_xmlTextReaderSetErrorHandler();
|
test_ret += test_xmlTextReaderSetErrorHandler();
|
||||||
|
@ -34495,6 +34820,55 @@ test_xmlSchemaValidateOneElement(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlSchemaValidateSetFilename(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
#if defined(LIBXML_SCHEMAS_ENABLED)
|
||||||
|
int mem_base;
|
||||||
|
xmlSchemaValidCtxtPtr vctxt; /* the schema validation context */
|
||||||
|
int n_vctxt;
|
||||||
|
const char * filename; /* the file name */
|
||||||
|
int n_filename;
|
||||||
|
|
||||||
|
for (n_vctxt = 0;n_vctxt < gen_nb_xmlSchemaValidCtxtPtr;n_vctxt++) {
|
||||||
|
for (n_filename = 0;n_filename < gen_nb_filepath;n_filename++) {
|
||||||
|
mem_base = xmlMemBlocks();
|
||||||
|
vctxt = gen_xmlSchemaValidCtxtPtr(n_vctxt, 0);
|
||||||
|
filename = gen_filepath(n_filename, 1);
|
||||||
|
|
||||||
|
xmlSchemaValidateSetFilename(vctxt, filename);
|
||||||
|
call_tests++;
|
||||||
|
des_xmlSchemaValidCtxtPtr(n_vctxt, vctxt, 0);
|
||||||
|
des_filepath(n_filename, filename, 1);
|
||||||
|
xmlResetLastError();
|
||||||
|
if (mem_base != xmlMemBlocks()) {
|
||||||
|
printf("Leak of %d blocks found in xmlSchemaValidateSetFilename",
|
||||||
|
xmlMemBlocks() - mem_base);
|
||||||
|
test_ret++;
|
||||||
|
printf(" %d", n_vctxt);
|
||||||
|
printf(" %d", n_filename);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function_tests++;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlSchemaValidateSetLocator(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* missing type support */
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_xmlSchemaValidateStream(void) {
|
test_xmlSchemaValidateStream(void) {
|
||||||
int test_ret = 0;
|
int test_ret = 0;
|
||||||
|
@ -34560,7 +34934,7 @@ static int
|
||||||
test_xmlschemas(void) {
|
test_xmlschemas(void) {
|
||||||
int test_ret = 0;
|
int test_ret = 0;
|
||||||
|
|
||||||
if (quiet == 0) printf("Testing xmlschemas : 15 of 25 functions ...\n");
|
if (quiet == 0) printf("Testing xmlschemas : 16 of 27 functions ...\n");
|
||||||
test_ret += test_xmlSchemaDump();
|
test_ret += test_xmlSchemaDump();
|
||||||
test_ret += test_xmlSchemaGetParserErrors();
|
test_ret += test_xmlSchemaGetParserErrors();
|
||||||
test_ret += test_xmlSchemaGetValidErrors();
|
test_ret += test_xmlSchemaGetValidErrors();
|
||||||
|
@ -34582,6 +34956,8 @@ test_xmlschemas(void) {
|
||||||
test_ret += test_xmlSchemaValidateDoc();
|
test_ret += test_xmlSchemaValidateDoc();
|
||||||
test_ret += test_xmlSchemaValidateFile();
|
test_ret += test_xmlSchemaValidateFile();
|
||||||
test_ret += test_xmlSchemaValidateOneElement();
|
test_ret += test_xmlSchemaValidateOneElement();
|
||||||
|
test_ret += test_xmlSchemaValidateSetFilename();
|
||||||
|
test_ret += test_xmlSchemaValidateSetLocator();
|
||||||
test_ret += test_xmlSchemaValidateStream();
|
test_ret += test_xmlSchemaValidateStream();
|
||||||
|
|
||||||
if (test_ret != 0)
|
if (test_ret != 0)
|
||||||
|
@ -43462,6 +43838,47 @@ test_xmlTextWriterSetIndentString(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_xmlTextWriterSetQuoteChar(void) {
|
||||||
|
int test_ret = 0;
|
||||||
|
|
||||||
|
#if defined(LIBXML_WRITER_ENABLED)
|
||||||
|
int mem_base;
|
||||||
|
int ret_val;
|
||||||
|
xmlTextWriterPtr writer; /* the xmlTextWriterPtr */
|
||||||
|
int n_writer;
|
||||||
|
xmlChar quotechar; /* the quote character */
|
||||||
|
int n_quotechar;
|
||||||
|
|
||||||
|
for (n_writer = 0;n_writer < gen_nb_xmlTextWriterPtr;n_writer++) {
|
||||||
|
for (n_quotechar = 0;n_quotechar < gen_nb_xmlChar;n_quotechar++) {
|
||||||
|
mem_base = xmlMemBlocks();
|
||||||
|
writer = gen_xmlTextWriterPtr(n_writer, 0);
|
||||||
|
quotechar = gen_xmlChar(n_quotechar, 1);
|
||||||
|
|
||||||
|
ret_val = xmlTextWriterSetQuoteChar(writer, quotechar);
|
||||||
|
desret_int(ret_val);
|
||||||
|
call_tests++;
|
||||||
|
des_xmlTextWriterPtr(n_writer, writer, 0);
|
||||||
|
des_xmlChar(n_quotechar, quotechar, 1);
|
||||||
|
xmlResetLastError();
|
||||||
|
if (mem_base != xmlMemBlocks()) {
|
||||||
|
printf("Leak of %d blocks found in xmlTextWriterSetQuoteChar",
|
||||||
|
xmlMemBlocks() - mem_base);
|
||||||
|
test_ret++;
|
||||||
|
printf(" %d", n_writer);
|
||||||
|
printf(" %d", n_quotechar);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function_tests++;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return(test_ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_xmlTextWriterStartAttribute(void) {
|
test_xmlTextWriterStartAttribute(void) {
|
||||||
int test_ret = 0;
|
int test_ret = 0;
|
||||||
|
@ -45324,7 +45741,7 @@ static int
|
||||||
test_xmlwriter(void) {
|
test_xmlwriter(void) {
|
||||||
int test_ret = 0;
|
int test_ret = 0;
|
||||||
|
|
||||||
if (quiet == 0) printf("Testing xmlwriter : 51 of 79 functions ...\n");
|
if (quiet == 0) printf("Testing xmlwriter : 52 of 80 functions ...\n");
|
||||||
test_ret += test_xmlNewTextWriter();
|
test_ret += test_xmlNewTextWriter();
|
||||||
test_ret += test_xmlNewTextWriterFilename();
|
test_ret += test_xmlNewTextWriterFilename();
|
||||||
test_ret += test_xmlNewTextWriterMemory();
|
test_ret += test_xmlNewTextWriterMemory();
|
||||||
|
@ -45344,6 +45761,7 @@ test_xmlwriter(void) {
|
||||||
test_ret += test_xmlTextWriterFullEndElement();
|
test_ret += test_xmlTextWriterFullEndElement();
|
||||||
test_ret += test_xmlTextWriterSetIndent();
|
test_ret += test_xmlTextWriterSetIndent();
|
||||||
test_ret += test_xmlTextWriterSetIndentString();
|
test_ret += test_xmlTextWriterSetIndentString();
|
||||||
|
test_ret += test_xmlTextWriterSetQuoteChar();
|
||||||
test_ret += test_xmlTextWriterStartAttribute();
|
test_ret += test_xmlTextWriterStartAttribute();
|
||||||
test_ret += test_xmlTextWriterStartAttributeNS();
|
test_ret += test_xmlTextWriterStartAttributeNS();
|
||||||
test_ret += test_xmlTextWriterStartCDATA();
|
test_ret += test_xmlTextWriterStartCDATA();
|
||||||
|
@ -48707,6 +49125,7 @@ test_xmlXPathNodeSetAdd(void) {
|
||||||
|
|
||||||
#if defined(LIBXML_XPATH_ENABLED)
|
#if defined(LIBXML_XPATH_ENABLED)
|
||||||
int mem_base;
|
int mem_base;
|
||||||
|
int ret_val;
|
||||||
xmlNodeSetPtr cur; /* the initial node set */
|
xmlNodeSetPtr cur; /* the initial node set */
|
||||||
int n_cur;
|
int n_cur;
|
||||||
xmlNodePtr val; /* a new xmlNodePtr */
|
xmlNodePtr val; /* a new xmlNodePtr */
|
||||||
|
@ -48718,7 +49137,8 @@ test_xmlXPathNodeSetAdd(void) {
|
||||||
cur = gen_xmlNodeSetPtr(n_cur, 0);
|
cur = gen_xmlNodeSetPtr(n_cur, 0);
|
||||||
val = gen_xmlNodePtr(n_val, 1);
|
val = gen_xmlNodePtr(n_val, 1);
|
||||||
|
|
||||||
xmlXPathNodeSetAdd(cur, val);
|
ret_val = xmlXPathNodeSetAdd(cur, val);
|
||||||
|
desret_int(ret_val);
|
||||||
call_tests++;
|
call_tests++;
|
||||||
des_xmlNodeSetPtr(n_cur, cur, 0);
|
des_xmlNodeSetPtr(n_cur, cur, 0);
|
||||||
des_xmlNodePtr(n_val, val, 1);
|
des_xmlNodePtr(n_val, val, 1);
|
||||||
|
@ -48746,6 +49166,7 @@ test_xmlXPathNodeSetAddNs(void) {
|
||||||
|
|
||||||
#if defined(LIBXML_XPATH_ENABLED)
|
#if defined(LIBXML_XPATH_ENABLED)
|
||||||
int mem_base;
|
int mem_base;
|
||||||
|
int ret_val;
|
||||||
xmlNodeSetPtr cur; /* the initial node set */
|
xmlNodeSetPtr cur; /* the initial node set */
|
||||||
int n_cur;
|
int n_cur;
|
||||||
xmlNodePtr node; /* the hosting node */
|
xmlNodePtr node; /* the hosting node */
|
||||||
|
@ -48761,7 +49182,8 @@ test_xmlXPathNodeSetAddNs(void) {
|
||||||
node = gen_xmlNodePtr(n_node, 1);
|
node = gen_xmlNodePtr(n_node, 1);
|
||||||
ns = gen_xmlNsPtr(n_ns, 2);
|
ns = gen_xmlNsPtr(n_ns, 2);
|
||||||
|
|
||||||
xmlXPathNodeSetAddNs(cur, node, ns);
|
ret_val = xmlXPathNodeSetAddNs(cur, node, ns);
|
||||||
|
desret_int(ret_val);
|
||||||
call_tests++;
|
call_tests++;
|
||||||
des_xmlNodeSetPtr(n_cur, cur, 0);
|
des_xmlNodeSetPtr(n_cur, cur, 0);
|
||||||
des_xmlNodePtr(n_node, node, 1);
|
des_xmlNodePtr(n_node, node, 1);
|
||||||
|
@ -48792,6 +49214,7 @@ test_xmlXPathNodeSetAddUnique(void) {
|
||||||
|
|
||||||
#if defined(LIBXML_XPATH_ENABLED)
|
#if defined(LIBXML_XPATH_ENABLED)
|
||||||
int mem_base;
|
int mem_base;
|
||||||
|
int ret_val;
|
||||||
xmlNodeSetPtr cur; /* the initial node set */
|
xmlNodeSetPtr cur; /* the initial node set */
|
||||||
int n_cur;
|
int n_cur;
|
||||||
xmlNodePtr val; /* a new xmlNodePtr */
|
xmlNodePtr val; /* a new xmlNodePtr */
|
||||||
|
@ -48803,7 +49226,8 @@ test_xmlXPathNodeSetAddUnique(void) {
|
||||||
cur = gen_xmlNodeSetPtr(n_cur, 0);
|
cur = gen_xmlNodeSetPtr(n_cur, 0);
|
||||||
val = gen_xmlNodePtr(n_val, 1);
|
val = gen_xmlNodePtr(n_val, 1);
|
||||||
|
|
||||||
xmlXPathNodeSetAddUnique(cur, val);
|
ret_val = xmlXPathNodeSetAddUnique(cur, val);
|
||||||
|
desret_int(ret_val);
|
||||||
call_tests++;
|
call_tests++;
|
||||||
des_xmlNodeSetPtr(n_cur, cur, 0);
|
des_xmlNodeSetPtr(n_cur, cur, 0);
|
||||||
des_xmlNodePtr(n_val, val, 1);
|
des_xmlNodePtr(n_val, val, 1);
|
||||||
|
|
8
reactos/lib/3rdparty/libxml2/testchar.c
vendored
8
reactos/lib/3rdparty/libxml2/testchar.c
vendored
|
@ -10,6 +10,8 @@
|
||||||
#include <libxml/parser.h>
|
#include <libxml/parser.h>
|
||||||
#include <libxml/parserInternals.h>
|
#include <libxml/parserInternals.h>
|
||||||
|
|
||||||
|
#include "buf.h"
|
||||||
|
|
||||||
int lastError;
|
int lastError;
|
||||||
|
|
||||||
static void errorHandler(void *unused, xmlErrorPtr err) {
|
static void errorHandler(void *unused, xmlErrorPtr err) {
|
||||||
|
@ -558,9 +560,9 @@ static void testCharRanges(void) {
|
||||||
}
|
}
|
||||||
input->filename = NULL;
|
input->filename = NULL;
|
||||||
input->buf = buf;
|
input->buf = buf;
|
||||||
input->base = input->buf->buffer->content;
|
input->cur =
|
||||||
input->cur = input->buf->buffer->content;
|
input->base = xmlBufContent(input->buf->buffer);
|
||||||
input->end = &input->buf->buffer->content[4];
|
input->end = input->base + 4;
|
||||||
inputPush(ctxt, input);
|
inputPush(ctxt, input);
|
||||||
|
|
||||||
printf("testing char range: 1");
|
printf("testing char range: 1");
|
||||||
|
|
1634
reactos/lib/3rdparty/libxml2/testlimits.c
vendored
Normal file
1634
reactos/lib/3rdparty/libxml2/testlimits.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
10
reactos/lib/3rdparty/libxml2/testrecurse.c
vendored
10
reactos/lib/3rdparty/libxml2/testrecurse.c
vendored
|
@ -10,11 +10,8 @@
|
||||||
* daniel@veillard.com
|
* daniel@veillard.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "libxml.h"
|
#include "libxml.h"
|
||||||
#else
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -148,8 +145,7 @@ static void globfree(glob_t *pglob) {
|
||||||
free(pglob->gl_pathv[i]);
|
free(pglob->gl_pathv[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#define vsnprintf _vsnprintf
|
|
||||||
#define snprintf _snprintf
|
|
||||||
#else
|
#else
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -684,12 +680,10 @@ recursiveDetectTest(const char *filename,
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
xmlParserCtxtPtr ctxt;
|
xmlParserCtxtPtr ctxt;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
int mem;
|
|
||||||
|
|
||||||
nb_tests++;
|
nb_tests++;
|
||||||
|
|
||||||
ctxt = xmlNewParserCtxt();
|
ctxt = xmlNewParserCtxt();
|
||||||
mem = xmlMemUsed();
|
|
||||||
/*
|
/*
|
||||||
* base of the test, parse with the old API
|
* base of the test, parse with the old API
|
||||||
*/
|
*/
|
||||||
|
@ -725,12 +719,10 @@ notRecursiveDetectTest(const char *filename,
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
xmlParserCtxtPtr ctxt;
|
xmlParserCtxtPtr ctxt;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
int mem;
|
|
||||||
|
|
||||||
nb_tests++;
|
nb_tests++;
|
||||||
|
|
||||||
ctxt = xmlNewParserCtxt();
|
ctxt = xmlNewParserCtxt();
|
||||||
mem = xmlMemUsed();
|
|
||||||
/*
|
/*
|
||||||
* base of the test, parse with the old API
|
* base of the test, parse with the old API
|
||||||
*/
|
*/
|
||||||
|
|
5
reactos/lib/3rdparty/libxml2/threads.c
vendored
5
reactos/lib/3rdparty/libxml2/threads.c
vendored
|
@ -439,7 +439,7 @@ __xmlGlobalInitMutexLock(void)
|
||||||
/* Make sure the global init lock is initialized and then lock it. */
|
/* Make sure the global init lock is initialized and then lock it. */
|
||||||
#ifdef HAVE_PTHREAD_H
|
#ifdef HAVE_PTHREAD_H
|
||||||
/* The mutex is statically initialized, so we just lock it. */
|
/* The mutex is statically initialized, so we just lock it. */
|
||||||
if (pthread_mutex_lock)
|
if (pthread_mutex_lock != NULL)
|
||||||
pthread_mutex_lock(&global_init_lock);
|
pthread_mutex_lock(&global_init_lock);
|
||||||
#elif defined HAVE_WIN32_THREADS
|
#elif defined HAVE_WIN32_THREADS
|
||||||
LPCRITICAL_SECTION cs;
|
LPCRITICAL_SECTION cs;
|
||||||
|
@ -509,7 +509,7 @@ void
|
||||||
__xmlGlobalInitMutexUnlock(void)
|
__xmlGlobalInitMutexUnlock(void)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_PTHREAD_H
|
#ifdef HAVE_PTHREAD_H
|
||||||
if (pthread_mutex_unlock)
|
if (pthread_mutex_unlock != NULL)
|
||||||
pthread_mutex_unlock(&global_init_lock);
|
pthread_mutex_unlock(&global_init_lock);
|
||||||
#elif defined HAVE_WIN32_THREADS
|
#elif defined HAVE_WIN32_THREADS
|
||||||
if (global_init_lock != NULL) {
|
if (global_init_lock != NULL) {
|
||||||
|
@ -915,6 +915,7 @@ xmlCleanupThreads(void)
|
||||||
#ifdef HAVE_PTHREAD_H
|
#ifdef HAVE_PTHREAD_H
|
||||||
if ((libxml_is_threaded) && (pthread_key_delete != NULL))
|
if ((libxml_is_threaded) && (pthread_key_delete != NULL))
|
||||||
pthread_key_delete(globalkey);
|
pthread_key_delete(globalkey);
|
||||||
|
once_control = PTHREAD_ONCE_INIT;
|
||||||
#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
|
#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
|
||||||
if (globalkey != TLS_OUT_OF_INDEXES) {
|
if (globalkey != TLS_OUT_OF_INDEXES) {
|
||||||
xmlGlobalStateCleanupHelperParams *p;
|
xmlGlobalStateCleanupHelperParams *p;
|
||||||
|
|
506
reactos/lib/3rdparty/libxml2/timsort.h
vendored
Normal file
506
reactos/lib/3rdparty/libxml2/timsort.h
vendored
Normal file
|
@ -0,0 +1,506 @@
|
||||||
|
/*
|
||||||
|
* taken from https://github.com/swenson/sort
|
||||||
|
* Kept as is for the moment to be able to apply upstream patches for that
|
||||||
|
* code, currently used only to speed up XPath node sorting, see xpath.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* All code in this header, unless otherwise specified, is hereby licensed under the MIT Public License:
|
||||||
|
|
||||||
|
Copyright (c) 2010 Christopher Swenson
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#ifdef HAVE_STDINT_H
|
||||||
|
#include <stdint.h>
|
||||||
|
#else
|
||||||
|
#ifdef HAVE_INTTYPES_H
|
||||||
|
#include <inttypes.h>
|
||||||
|
#elif defined(WIN32)
|
||||||
|
typedef __int64 int64_t;
|
||||||
|
typedef unsigned __int64 uint64_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAX
|
||||||
|
#define MAX(x,y) (((x) > (y) ? (x) : (y)))
|
||||||
|
#endif
|
||||||
|
#ifndef MIN
|
||||||
|
#define MIN(x,y) (((x) < (y) ? (x) : (y)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int compute_minrun(const uint64_t);
|
||||||
|
|
||||||
|
#ifndef CLZ
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define CLZ __builtin_clzll
|
||||||
|
#else
|
||||||
|
|
||||||
|
int clzll(uint64_t);
|
||||||
|
|
||||||
|
/* adapted from Hacker's Delight */
|
||||||
|
int clzll(uint64_t x) /* {{{ */
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
|
if (x == 0) return(64);
|
||||||
|
n = 0;
|
||||||
|
if (x <= 0x00000000FFFFFFFFL) {n = n + 32; x = x << 32;}
|
||||||
|
if (x <= 0x0000FFFFFFFFFFFFL) {n = n + 16; x = x << 16;}
|
||||||
|
if (x <= 0x00FFFFFFFFFFFFFFL) {n = n + 8; x = x << 8;}
|
||||||
|
if (x <= 0x0FFFFFFFFFFFFFFFL) {n = n + 4; x = x << 4;}
|
||||||
|
if (x <= 0x3FFFFFFFFFFFFFFFL) {n = n + 2; x = x << 2;}
|
||||||
|
if (x <= 0x7FFFFFFFFFFFFFFFL) {n = n + 1;}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
#define CLZ clzll
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int compute_minrun(const uint64_t size) /* {{{ */
|
||||||
|
{
|
||||||
|
const int top_bit = 64 - CLZ(size);
|
||||||
|
const int shift = MAX(top_bit, 6) - 6;
|
||||||
|
const int minrun = size >> shift;
|
||||||
|
const uint64_t mask = (1ULL << shift) - 1;
|
||||||
|
if (mask & size) return minrun + 1;
|
||||||
|
return minrun;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
#ifndef SORT_NAME
|
||||||
|
#error "Must declare SORT_NAME"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SORT_TYPE
|
||||||
|
#error "Must declare SORT_TYPE"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SORT_CMP
|
||||||
|
#define SORT_CMP(x, y) ((x) < (y) ? -1 : ((x) == (y) ? 0 : 1))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define SORT_SWAP(x,y) {SORT_TYPE __SORT_SWAP_t = (x); (x) = (y); (y) = __SORT_SWAP_t;}
|
||||||
|
|
||||||
|
#define SORT_CONCAT(x, y) x ## _ ## y
|
||||||
|
#define SORT_MAKE_STR1(x, y) SORT_CONCAT(x,y)
|
||||||
|
#define SORT_MAKE_STR(x) SORT_MAKE_STR1(SORT_NAME,x)
|
||||||
|
|
||||||
|
#define BINARY_INSERTION_FIND SORT_MAKE_STR(binary_insertion_find)
|
||||||
|
#define BINARY_INSERTION_SORT_START SORT_MAKE_STR(binary_insertion_sort_start)
|
||||||
|
#define BINARY_INSERTION_SORT SORT_MAKE_STR(binary_insertion_sort)
|
||||||
|
#define REVERSE_ELEMENTS SORT_MAKE_STR(reverse_elements)
|
||||||
|
#define COUNT_RUN SORT_MAKE_STR(count_run)
|
||||||
|
#define CHECK_INVARIANT SORT_MAKE_STR(check_invariant)
|
||||||
|
#define TIM_SORT SORT_MAKE_STR(tim_sort)
|
||||||
|
#define TIM_SORT_RESIZE SORT_MAKE_STR(tim_sort_resize)
|
||||||
|
#define TIM_SORT_MERGE SORT_MAKE_STR(tim_sort_merge)
|
||||||
|
#define TIM_SORT_COLLAPSE SORT_MAKE_STR(tim_sort_collapse)
|
||||||
|
|
||||||
|
#define TIM_SORT_RUN_T SORT_MAKE_STR(tim_sort_run_t)
|
||||||
|
#define TEMP_STORAGE_T SORT_MAKE_STR(temp_storage_t)
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int64_t start;
|
||||||
|
int64_t length;
|
||||||
|
} TIM_SORT_RUN_T;
|
||||||
|
|
||||||
|
void BINARY_INSERTION_SORT(SORT_TYPE *dst, const size_t size);
|
||||||
|
void TIM_SORT(SORT_TYPE *dst, const size_t size);
|
||||||
|
|
||||||
|
/* Function used to do a binary search for binary insertion sort */
|
||||||
|
static int64_t BINARY_INSERTION_FIND(SORT_TYPE *dst, const SORT_TYPE x, const size_t size)
|
||||||
|
{
|
||||||
|
int64_t l, c, r;
|
||||||
|
SORT_TYPE lx;
|
||||||
|
SORT_TYPE cx;
|
||||||
|
l = 0;
|
||||||
|
r = size - 1;
|
||||||
|
c = r >> 1;
|
||||||
|
lx = dst[l];
|
||||||
|
|
||||||
|
/* check for beginning conditions */
|
||||||
|
if (SORT_CMP(x, lx) < 0)
|
||||||
|
return 0;
|
||||||
|
else if (SORT_CMP(x, lx) == 0)
|
||||||
|
{
|
||||||
|
int64_t i = 1;
|
||||||
|
while (SORT_CMP(x, dst[i]) == 0) i++;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
cx = dst[c];
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
const int val = SORT_CMP(x, cx);
|
||||||
|
if (val < 0)
|
||||||
|
{
|
||||||
|
if (c - l <= 1) return c;
|
||||||
|
r = c;
|
||||||
|
}
|
||||||
|
else if (val > 0)
|
||||||
|
{
|
||||||
|
if (r - c <= 1) return c + 1;
|
||||||
|
l = c;
|
||||||
|
lx = cx;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
cx = dst[++c];
|
||||||
|
} while (SORT_CMP(x, cx) == 0);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
c = l + ((r - l) >> 1);
|
||||||
|
cx = dst[c];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Binary insertion sort, but knowing that the first "start" entries are sorted. Used in timsort. */
|
||||||
|
static void BINARY_INSERTION_SORT_START(SORT_TYPE *dst, const size_t start, const size_t size)
|
||||||
|
{
|
||||||
|
int64_t i;
|
||||||
|
for (i = start; i < (int64_t) size; i++)
|
||||||
|
{
|
||||||
|
int64_t j;
|
||||||
|
SORT_TYPE x;
|
||||||
|
int64_t location;
|
||||||
|
/* If this entry is already correct, just move along */
|
||||||
|
if (SORT_CMP(dst[i - 1], dst[i]) <= 0) continue;
|
||||||
|
|
||||||
|
/* Else we need to find the right place, shift everything over, and squeeze in */
|
||||||
|
x = dst[i];
|
||||||
|
location = BINARY_INSERTION_FIND(dst, x, i);
|
||||||
|
for (j = i - 1; j >= location; j--)
|
||||||
|
{
|
||||||
|
dst[j + 1] = dst[j];
|
||||||
|
}
|
||||||
|
dst[location] = x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Binary insertion sort */
|
||||||
|
void BINARY_INSERTION_SORT(SORT_TYPE *dst, const size_t size)
|
||||||
|
{
|
||||||
|
BINARY_INSERTION_SORT_START(dst, 1, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* timsort implementation, based on timsort.txt */
|
||||||
|
|
||||||
|
static void REVERSE_ELEMENTS(SORT_TYPE *dst, int64_t start, int64_t end)
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (start >= end) return;
|
||||||
|
SORT_SWAP(dst[start], dst[end]);
|
||||||
|
start++;
|
||||||
|
end--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64_t COUNT_RUN(SORT_TYPE *dst, const int64_t start, const size_t size)
|
||||||
|
{
|
||||||
|
int64_t curr;
|
||||||
|
if (size - start == 1) return 1;
|
||||||
|
if (start >= (int64_t) size - 2)
|
||||||
|
{
|
||||||
|
if (SORT_CMP(dst[size - 2], dst[size - 1]) > 0)
|
||||||
|
SORT_SWAP(dst[size - 2], dst[size - 1]);
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
curr = start + 2;
|
||||||
|
|
||||||
|
if (SORT_CMP(dst[start], dst[start + 1]) <= 0)
|
||||||
|
{
|
||||||
|
/* increasing run */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (curr == (int64_t) size - 1) break;
|
||||||
|
if (SORT_CMP(dst[curr - 1], dst[curr]) > 0) break;
|
||||||
|
curr++;
|
||||||
|
}
|
||||||
|
return curr - start;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* decreasing run */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (curr == (int64_t) size - 1) break;
|
||||||
|
if (SORT_CMP(dst[curr - 1], dst[curr]) <= 0) break;
|
||||||
|
curr++;
|
||||||
|
}
|
||||||
|
/* reverse in-place */
|
||||||
|
REVERSE_ELEMENTS(dst, start, curr - 1);
|
||||||
|
return curr - start;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define PUSH_NEXT() do {\
|
||||||
|
len = COUNT_RUN(dst, curr, size);\
|
||||||
|
run = minrun;\
|
||||||
|
if (run < minrun) run = minrun;\
|
||||||
|
if (run > (int64_t) size - curr) run = size - curr;\
|
||||||
|
if (run > len)\
|
||||||
|
{\
|
||||||
|
BINARY_INSERTION_SORT_START(&dst[curr], len, run);\
|
||||||
|
len = run;\
|
||||||
|
}\
|
||||||
|
{\
|
||||||
|
run_stack[stack_curr].start = curr;\
|
||||||
|
run_stack[stack_curr].length = len;\
|
||||||
|
stack_curr++;\
|
||||||
|
}\
|
||||||
|
curr += len;\
|
||||||
|
if (curr == (int64_t) size)\
|
||||||
|
{\
|
||||||
|
/* finish up */ \
|
||||||
|
while (stack_curr > 1) \
|
||||||
|
{ \
|
||||||
|
TIM_SORT_MERGE(dst, run_stack, stack_curr, store); \
|
||||||
|
run_stack[stack_curr - 2].length += run_stack[stack_curr - 1].length; \
|
||||||
|
stack_curr--; \
|
||||||
|
} \
|
||||||
|
if (store->storage != NULL)\
|
||||||
|
{\
|
||||||
|
free(store->storage);\
|
||||||
|
store->storage = NULL;\
|
||||||
|
}\
|
||||||
|
return;\
|
||||||
|
}\
|
||||||
|
}\
|
||||||
|
while (0)
|
||||||
|
|
||||||
|
static int CHECK_INVARIANT(TIM_SORT_RUN_T *stack, const int stack_curr)
|
||||||
|
{
|
||||||
|
int64_t A, B, C;
|
||||||
|
if (stack_curr < 2) return 1;
|
||||||
|
if (stack_curr == 2)
|
||||||
|
{
|
||||||
|
const int64_t A1 = stack[stack_curr - 2].length;
|
||||||
|
const int64_t B1 = stack[stack_curr - 1].length;
|
||||||
|
if (A1 <= B1) return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
A = stack[stack_curr - 3].length;
|
||||||
|
B = stack[stack_curr - 2].length;
|
||||||
|
C = stack[stack_curr - 1].length;
|
||||||
|
if ((A <= B + C) || (B <= C)) return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
size_t alloc;
|
||||||
|
SORT_TYPE *storage;
|
||||||
|
} TEMP_STORAGE_T;
|
||||||
|
|
||||||
|
|
||||||
|
static void TIM_SORT_RESIZE(TEMP_STORAGE_T *store, const size_t new_size)
|
||||||
|
{
|
||||||
|
if (store->alloc < new_size)
|
||||||
|
{
|
||||||
|
SORT_TYPE *tempstore = (SORT_TYPE *)realloc(store->storage, new_size * sizeof(SORT_TYPE));
|
||||||
|
if (tempstore == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error allocating temporary storage for tim sort: need %lu bytes", sizeof(SORT_TYPE) * new_size);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
store->storage = tempstore;
|
||||||
|
store->alloc = new_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TIM_SORT_MERGE(SORT_TYPE *dst, const TIM_SORT_RUN_T *stack, const int stack_curr, TEMP_STORAGE_T *store)
|
||||||
|
{
|
||||||
|
const int64_t A = stack[stack_curr - 2].length;
|
||||||
|
const int64_t B = stack[stack_curr - 1].length;
|
||||||
|
const int64_t curr = stack[stack_curr - 2].start;
|
||||||
|
SORT_TYPE *storage;
|
||||||
|
int64_t i, j, k;
|
||||||
|
|
||||||
|
TIM_SORT_RESIZE(store, MIN(A, B));
|
||||||
|
storage = store->storage;
|
||||||
|
|
||||||
|
/* left merge */
|
||||||
|
if (A < B)
|
||||||
|
{
|
||||||
|
memcpy(storage, &dst[curr], A * sizeof(SORT_TYPE));
|
||||||
|
i = 0;
|
||||||
|
j = curr + A;
|
||||||
|
|
||||||
|
for (k = curr; k < curr + A + B; k++)
|
||||||
|
{
|
||||||
|
if ((i < A) && (j < curr + A + B))
|
||||||
|
{
|
||||||
|
if (SORT_CMP(storage[i], dst[j]) <= 0)
|
||||||
|
dst[k] = storage[i++];
|
||||||
|
else
|
||||||
|
dst[k] = dst[j++];
|
||||||
|
}
|
||||||
|
else if (i < A)
|
||||||
|
{
|
||||||
|
dst[k] = storage[i++];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
dst[k] = dst[j++];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* right merge */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memcpy(storage, &dst[curr + A], B * sizeof(SORT_TYPE));
|
||||||
|
i = B - 1;
|
||||||
|
j = curr + A - 1;
|
||||||
|
|
||||||
|
for (k = curr + A + B - 1; k >= curr; k--)
|
||||||
|
{
|
||||||
|
if ((i >= 0) && (j >= curr))
|
||||||
|
{
|
||||||
|
if (SORT_CMP(dst[j], storage[i]) > 0)
|
||||||
|
dst[k] = dst[j--];
|
||||||
|
else
|
||||||
|
dst[k] = storage[i--];
|
||||||
|
}
|
||||||
|
else if (i >= 0)
|
||||||
|
dst[k] = storage[i--];
|
||||||
|
else
|
||||||
|
dst[k] = dst[j--];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int TIM_SORT_COLLAPSE(SORT_TYPE *dst, TIM_SORT_RUN_T *stack, int stack_curr, TEMP_STORAGE_T *store, const size_t size)
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
int64_t A, B, C;
|
||||||
|
/* if the stack only has one thing on it, we are done with the collapse */
|
||||||
|
if (stack_curr <= 1) break;
|
||||||
|
/* if this is the last merge, just do it */
|
||||||
|
if ((stack_curr == 2) &&
|
||||||
|
(stack[0].length + stack[1].length == (int64_t) size))
|
||||||
|
{
|
||||||
|
TIM_SORT_MERGE(dst, stack, stack_curr, store);
|
||||||
|
stack[0].length += stack[1].length;
|
||||||
|
stack_curr--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* check if the invariant is off for a stack of 2 elements */
|
||||||
|
else if ((stack_curr == 2) && (stack[0].length <= stack[1].length))
|
||||||
|
{
|
||||||
|
TIM_SORT_MERGE(dst, stack, stack_curr, store);
|
||||||
|
stack[0].length += stack[1].length;
|
||||||
|
stack_curr--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (stack_curr == 2)
|
||||||
|
break;
|
||||||
|
|
||||||
|
A = stack[stack_curr - 3].length;
|
||||||
|
B = stack[stack_curr - 2].length;
|
||||||
|
C = stack[stack_curr - 1].length;
|
||||||
|
|
||||||
|
/* check first invariant */
|
||||||
|
if (A <= B + C)
|
||||||
|
{
|
||||||
|
if (A < C)
|
||||||
|
{
|
||||||
|
TIM_SORT_MERGE(dst, stack, stack_curr - 1, store);
|
||||||
|
stack[stack_curr - 3].length += stack[stack_curr - 2].length;
|
||||||
|
stack[stack_curr - 2] = stack[stack_curr - 1];
|
||||||
|
stack_curr--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TIM_SORT_MERGE(dst, stack, stack_curr, store);
|
||||||
|
stack[stack_curr - 2].length += stack[stack_curr - 1].length;
|
||||||
|
stack_curr--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* check second invariant */
|
||||||
|
else if (B <= C)
|
||||||
|
{
|
||||||
|
TIM_SORT_MERGE(dst, stack, stack_curr, store);
|
||||||
|
stack[stack_curr - 2].length += stack[stack_curr - 1].length;
|
||||||
|
stack_curr--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return stack_curr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TIM_SORT(SORT_TYPE *dst, const size_t size)
|
||||||
|
{
|
||||||
|
int minrun;
|
||||||
|
TEMP_STORAGE_T _store, *store;
|
||||||
|
TIM_SORT_RUN_T run_stack[128];
|
||||||
|
int stack_curr = 0;
|
||||||
|
int64_t len, run;
|
||||||
|
int64_t curr = 0;
|
||||||
|
|
||||||
|
if (size < 64)
|
||||||
|
{
|
||||||
|
BINARY_INSERTION_SORT(dst, size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* compute the minimum run length */
|
||||||
|
minrun = compute_minrun(size);
|
||||||
|
|
||||||
|
/* temporary storage for merges */
|
||||||
|
store = &_store;
|
||||||
|
store->alloc = 0;
|
||||||
|
store->storage = NULL;
|
||||||
|
|
||||||
|
PUSH_NEXT();
|
||||||
|
PUSH_NEXT();
|
||||||
|
PUSH_NEXT();
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (!CHECK_INVARIANT(run_stack, stack_curr))
|
||||||
|
{
|
||||||
|
stack_curr = TIM_SORT_COLLAPSE(dst, run_stack, stack_curr, store, size);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
PUSH_NEXT();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef SORT_CONCAT
|
||||||
|
#undef SORT_MAKE_STR1
|
||||||
|
#undef SORT_MAKE_STR
|
||||||
|
#undef SORT_NAME
|
||||||
|
#undef SORT_TYPE
|
||||||
|
#undef SORT_CMP
|
||||||
|
#undef TEMP_STORAGE_T
|
||||||
|
#undef TIM_SORT_RUN_T
|
||||||
|
#undef PUSH_NEXT
|
||||||
|
#undef SORT_SWAP
|
||||||
|
#undef SORT_CONCAT
|
||||||
|
#undef SORT_MAKE_STR1
|
||||||
|
#undef SORT_MAKE_STR
|
||||||
|
#undef BINARY_INSERTION_FIND
|
||||||
|
#undef BINARY_INSERTION_SORT_START
|
||||||
|
#undef BINARY_INSERTION_SORT
|
||||||
|
#undef REVERSE_ELEMENTS
|
||||||
|
#undef COUNT_RUN
|
||||||
|
#undef TIM_SORT
|
||||||
|
#undef TIM_SORT_RESIZE
|
||||||
|
#undef TIM_SORT_COLLAPSE
|
||||||
|
#undef TIM_SORT_RUN_T
|
||||||
|
#undef TEMP_STORAGE_T
|
479
reactos/lib/3rdparty/libxml2/tree.c
vendored
479
reactos/lib/3rdparty/libxml2/tree.c
vendored
|
@ -41,6 +41,9 @@
|
||||||
#include <libxml/debugXML.h>
|
#include <libxml/debugXML.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "buf.h"
|
||||||
|
#include "save.h"
|
||||||
|
|
||||||
int __xmlRegisterCallbacks = 0;
|
int __xmlRegisterCallbacks = 0;
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
@ -682,7 +685,8 @@ try_complex:
|
||||||
void
|
void
|
||||||
xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme) {
|
xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme) {
|
||||||
if ((scheme == XML_BUFFER_ALLOC_EXACT) ||
|
if ((scheme == XML_BUFFER_ALLOC_EXACT) ||
|
||||||
(scheme == XML_BUFFER_ALLOC_DOUBLEIT))
|
(scheme == XML_BUFFER_ALLOC_DOUBLEIT) ||
|
||||||
|
(scheme == XML_BUFFER_ALLOC_HYBRID))
|
||||||
xmlBufferAllocScheme = scheme;
|
xmlBufferAllocScheme = scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,6 +697,9 @@ xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme) {
|
||||||
* XML_BUFFER_ALLOC_EXACT - use exact sizes, keeps memory usage down
|
* XML_BUFFER_ALLOC_EXACT - use exact sizes, keeps memory usage down
|
||||||
* XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed,
|
* XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed,
|
||||||
* improves performance
|
* improves performance
|
||||||
|
* XML_BUFFER_ALLOC_HYBRID - use exact sizes on small strings to keep memory usage tight
|
||||||
|
* in normal usage, and doubleit on large strings to avoid
|
||||||
|
* pathological performance.
|
||||||
*
|
*
|
||||||
* Returns the current allocation scheme
|
* Returns the current allocation scheme
|
||||||
*/
|
*/
|
||||||
|
@ -1261,9 +1268,14 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
|
||||||
const xmlChar *cur = value, *end = cur + len;
|
const xmlChar *cur = value, *end = cur + len;
|
||||||
const xmlChar *q;
|
const xmlChar *q;
|
||||||
xmlEntityPtr ent;
|
xmlEntityPtr ent;
|
||||||
|
xmlBufPtr buf;
|
||||||
|
|
||||||
if (value == NULL) return(NULL);
|
if (value == NULL) return(NULL);
|
||||||
|
|
||||||
|
buf = xmlBufCreateSize(0);
|
||||||
|
if (buf == NULL) return(NULL);
|
||||||
|
xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_HYBRID);
|
||||||
|
|
||||||
q = cur;
|
q = cur;
|
||||||
while ((cur < end) && (*cur != 0)) {
|
while ((cur < end) && (*cur != 0)) {
|
||||||
if (cur[0] == '&') {
|
if (cur[0] == '&') {
|
||||||
|
@ -1274,19 +1286,8 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
|
||||||
* Save the current text.
|
* Save the current text.
|
||||||
*/
|
*/
|
||||||
if (cur != q) {
|
if (cur != q) {
|
||||||
if ((last != NULL) && (last->type == XML_TEXT_NODE)) {
|
if (xmlBufAdd(buf, q, cur - q))
|
||||||
xmlNodeAddContentLen(last, q, cur - q);
|
goto out;
|
||||||
} else {
|
|
||||||
node = xmlNewDocTextLen(doc, q, cur - q);
|
|
||||||
if (node == NULL) return(ret);
|
|
||||||
if (last == NULL)
|
|
||||||
last = ret = node;
|
|
||||||
else {
|
|
||||||
last->next = node;
|
|
||||||
node->prev = last;
|
|
||||||
last = node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
q = cur;
|
q = cur;
|
||||||
if ((cur + 2 < end) && (cur[1] == '#') && (cur[2] == 'x')) {
|
if ((cur + 2 < end) && (cur[1] == '#') && (cur[2] == 'x')) {
|
||||||
|
@ -1351,7 +1352,7 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
|
||||||
if ((cur >= end) || (*cur == 0)) {
|
if ((cur >= end) || (*cur == 0)) {
|
||||||
xmlTreeErr(XML_TREE_UNTERMINATED_ENTITY, (xmlNodePtr) doc,
|
xmlTreeErr(XML_TREE_UNTERMINATED_ENTITY, (xmlNodePtr) doc,
|
||||||
(const char *) q);
|
(const char *) q);
|
||||||
return(ret);
|
goto out;
|
||||||
}
|
}
|
||||||
if (cur != q) {
|
if (cur != q) {
|
||||||
/*
|
/*
|
||||||
|
@ -1361,23 +1362,36 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
|
||||||
ent = xmlGetDocEntity(doc, val);
|
ent = xmlGetDocEntity(doc, val);
|
||||||
if ((ent != NULL) &&
|
if ((ent != NULL) &&
|
||||||
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
|
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
|
||||||
if (last == NULL) {
|
|
||||||
node = xmlNewDocText(doc, ent->content);
|
if (xmlBufCat(buf, ent->content))
|
||||||
last = ret = node;
|
goto out;
|
||||||
} else if (last->type != XML_TEXT_NODE) {
|
|
||||||
node = xmlNewDocText(doc, ent->content);
|
|
||||||
last = xmlAddNextSibling(last, node);
|
|
||||||
} else
|
|
||||||
xmlNodeAddContent(last, ent->content);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
/*
|
||||||
|
* Flush buffer so far
|
||||||
|
*/
|
||||||
|
if (!xmlBufIsEmpty(buf)) {
|
||||||
|
node = xmlNewDocText(doc, NULL);
|
||||||
|
if (node == NULL) {
|
||||||
|
if (val != NULL) xmlFree(val);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
node->content = xmlBufDetach(buf);
|
||||||
|
|
||||||
|
if (last == NULL) {
|
||||||
|
last = ret = node;
|
||||||
|
} else {
|
||||||
|
last = xmlAddNextSibling(last, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new REFERENCE_REF node
|
* Create a new REFERENCE_REF node
|
||||||
*/
|
*/
|
||||||
node = xmlNewReference(doc, val);
|
node = xmlNewReference(doc, val);
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
if (val != NULL) xmlFree(val);
|
if (val != NULL) xmlFree(val);
|
||||||
return(ret);
|
goto out;
|
||||||
}
|
}
|
||||||
else if ((ent != NULL) && (ent->children == NULL)) {
|
else if ((ent != NULL) && (ent->children == NULL)) {
|
||||||
xmlNodePtr temp;
|
xmlNodePtr temp;
|
||||||
|
@ -1404,40 +1418,44 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
|
||||||
q = cur;
|
q = cur;
|
||||||
}
|
}
|
||||||
if (charval != 0) {
|
if (charval != 0) {
|
||||||
xmlChar buf[10];
|
xmlChar buffer[10];
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
l = xmlCopyCharMultiByte(buf, charval);
|
l = xmlCopyCharMultiByte(buffer, charval);
|
||||||
buf[l] = 0;
|
buffer[l] = 0;
|
||||||
node = xmlNewDocText(doc, buf);
|
|
||||||
if (node != NULL) {
|
if (xmlBufCat(buf, buffer))
|
||||||
if (last == NULL) {
|
goto out;
|
||||||
last = ret = node;
|
|
||||||
} else {
|
|
||||||
last = xmlAddNextSibling(last, node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
charval = 0;
|
charval = 0;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
cur++;
|
cur++;
|
||||||
}
|
}
|
||||||
if ((cur != q) || (ret == NULL)) {
|
|
||||||
|
if (cur != q) {
|
||||||
/*
|
/*
|
||||||
* Handle the last piece of text.
|
* Handle the last piece of text.
|
||||||
*/
|
*/
|
||||||
if ((last != NULL) && (last->type == XML_TEXT_NODE)) {
|
if (xmlBufAdd(buf, q, cur - q))
|
||||||
xmlNodeAddContentLen(last, q, cur - q);
|
goto out;
|
||||||
} else {
|
|
||||||
node = xmlNewDocTextLen(doc, q, cur - q);
|
|
||||||
if (node == NULL) return(ret);
|
|
||||||
if (last == NULL) {
|
|
||||||
ret = node;
|
|
||||||
} else {
|
|
||||||
xmlAddNextSibling(last, node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!xmlBufIsEmpty(buf)) {
|
||||||
|
node = xmlNewDocText(doc, NULL);
|
||||||
|
if (node == NULL) goto out;
|
||||||
|
node->content = xmlBufDetach(buf);
|
||||||
|
|
||||||
|
if (last == NULL) {
|
||||||
|
last = ret = node;
|
||||||
|
} else {
|
||||||
|
last = xmlAddNextSibling(last, node);
|
||||||
|
}
|
||||||
|
} else if (ret == NULL) {
|
||||||
|
ret = xmlNewDocText(doc, BAD_CAST "");
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
xmlBufFree(buf);
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1458,9 +1476,14 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
|
||||||
const xmlChar *cur = value;
|
const xmlChar *cur = value;
|
||||||
const xmlChar *q;
|
const xmlChar *q;
|
||||||
xmlEntityPtr ent;
|
xmlEntityPtr ent;
|
||||||
|
xmlBufPtr buf;
|
||||||
|
|
||||||
if (value == NULL) return(NULL);
|
if (value == NULL) return(NULL);
|
||||||
|
|
||||||
|
buf = xmlBufCreateSize(0);
|
||||||
|
if (buf == NULL) return(NULL);
|
||||||
|
xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_HYBRID);
|
||||||
|
|
||||||
q = cur;
|
q = cur;
|
||||||
while (*cur != 0) {
|
while (*cur != 0) {
|
||||||
if (cur[0] == '&') {
|
if (cur[0] == '&') {
|
||||||
|
@ -1471,19 +1494,8 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
|
||||||
* Save the current text.
|
* Save the current text.
|
||||||
*/
|
*/
|
||||||
if (cur != q) {
|
if (cur != q) {
|
||||||
if ((last != NULL) && (last->type == XML_TEXT_NODE)) {
|
if (xmlBufAdd(buf, q, cur - q))
|
||||||
xmlNodeAddContentLen(last, q, cur - q);
|
goto out;
|
||||||
} else {
|
|
||||||
node = xmlNewDocTextLen(doc, q, cur - q);
|
|
||||||
if (node == NULL) return(ret);
|
|
||||||
if (last == NULL)
|
|
||||||
last = ret = node;
|
|
||||||
else {
|
|
||||||
last->next = node;
|
|
||||||
node->prev = last;
|
|
||||||
last = node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
q = cur;
|
q = cur;
|
||||||
if ((cur[1] == '#') && (cur[2] == 'x')) {
|
if ((cur[1] == '#') && (cur[2] == 'x')) {
|
||||||
|
@ -1536,7 +1548,7 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
|
||||||
if (*cur == 0) {
|
if (*cur == 0) {
|
||||||
xmlTreeErr(XML_TREE_UNTERMINATED_ENTITY,
|
xmlTreeErr(XML_TREE_UNTERMINATED_ENTITY,
|
||||||
(xmlNodePtr) doc, (const char *) q);
|
(xmlNodePtr) doc, (const char *) q);
|
||||||
return(ret);
|
goto out;
|
||||||
}
|
}
|
||||||
if (cur != q) {
|
if (cur != q) {
|
||||||
/*
|
/*
|
||||||
|
@ -1546,23 +1558,32 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
|
||||||
ent = xmlGetDocEntity(doc, val);
|
ent = xmlGetDocEntity(doc, val);
|
||||||
if ((ent != NULL) &&
|
if ((ent != NULL) &&
|
||||||
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
|
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
|
||||||
if (last == NULL) {
|
|
||||||
node = xmlNewDocText(doc, ent->content);
|
if (xmlBufCat(buf, ent->content))
|
||||||
last = ret = node;
|
goto out;
|
||||||
} else if (last->type != XML_TEXT_NODE) {
|
|
||||||
node = xmlNewDocText(doc, ent->content);
|
|
||||||
last = xmlAddNextSibling(last, node);
|
|
||||||
} else
|
|
||||||
xmlNodeAddContent(last, ent->content);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
/*
|
||||||
|
* Flush buffer so far
|
||||||
|
*/
|
||||||
|
if (!xmlBufIsEmpty(buf)) {
|
||||||
|
node = xmlNewDocText(doc, NULL);
|
||||||
|
node->content = xmlBufDetach(buf);
|
||||||
|
|
||||||
|
if (last == NULL) {
|
||||||
|
last = ret = node;
|
||||||
|
} else {
|
||||||
|
last = xmlAddNextSibling(last, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new REFERENCE_REF node
|
* Create a new REFERENCE_REF node
|
||||||
*/
|
*/
|
||||||
node = xmlNewReference(doc, val);
|
node = xmlNewReference(doc, val);
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
if (val != NULL) xmlFree(val);
|
if (val != NULL) xmlFree(val);
|
||||||
return(ret);
|
goto out;
|
||||||
}
|
}
|
||||||
else if ((ent != NULL) && (ent->children == NULL)) {
|
else if ((ent != NULL) && (ent->children == NULL)) {
|
||||||
xmlNodePtr temp;
|
xmlNodePtr temp;
|
||||||
|
@ -1588,19 +1609,15 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
|
||||||
q = cur;
|
q = cur;
|
||||||
}
|
}
|
||||||
if (charval != 0) {
|
if (charval != 0) {
|
||||||
xmlChar buf[10];
|
xmlChar buffer[10];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
len = xmlCopyCharMultiByte(buf, charval);
|
len = xmlCopyCharMultiByte(buffer, charval);
|
||||||
buf[len] = 0;
|
buffer[len] = 0;
|
||||||
node = xmlNewDocText(doc, buf);
|
|
||||||
if (node != NULL) {
|
if (xmlBufCat(buf, buffer))
|
||||||
if (last == NULL) {
|
goto out;
|
||||||
last = ret = node;
|
charval = 0;
|
||||||
} else {
|
|
||||||
last = xmlAddNextSibling(last, node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
cur++;
|
cur++;
|
||||||
|
@ -1609,18 +1626,22 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
|
||||||
/*
|
/*
|
||||||
* Handle the last piece of text.
|
* Handle the last piece of text.
|
||||||
*/
|
*/
|
||||||
if ((last != NULL) && (last->type == XML_TEXT_NODE)) {
|
xmlBufAdd(buf, q, cur - q);
|
||||||
xmlNodeAddContentLen(last, q, cur - q);
|
}
|
||||||
|
|
||||||
|
if (!xmlBufIsEmpty(buf)) {
|
||||||
|
node = xmlNewDocText(doc, NULL);
|
||||||
|
node->content = xmlBufDetach(buf);
|
||||||
|
|
||||||
|
if (last == NULL) {
|
||||||
|
last = ret = node;
|
||||||
} else {
|
} else {
|
||||||
node = xmlNewDocTextLen(doc, q, cur - q);
|
last = xmlAddNextSibling(last, node);
|
||||||
if (node == NULL) return(ret);
|
|
||||||
if (last == NULL) {
|
|
||||||
last = ret = node;
|
|
||||||
} else {
|
|
||||||
last = xmlAddNextSibling(last, node);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
xmlBufFree(buf);
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1641,9 +1662,14 @@ xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine)
|
||||||
xmlNodePtr node = list;
|
xmlNodePtr node = list;
|
||||||
xmlChar *ret = NULL;
|
xmlChar *ret = NULL;
|
||||||
xmlEntityPtr ent;
|
xmlEntityPtr ent;
|
||||||
|
int attr;
|
||||||
|
|
||||||
if (list == NULL)
|
if (list == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
if ((list->parent != NULL) && (list->parent->type == XML_ATTRIBUTE_NODE))
|
||||||
|
attr = 1;
|
||||||
|
else
|
||||||
|
attr = 0;
|
||||||
|
|
||||||
while (node != NULL) {
|
while (node != NULL) {
|
||||||
if ((node->type == XML_TEXT_NODE) ||
|
if ((node->type == XML_TEXT_NODE) ||
|
||||||
|
@ -1653,7 +1679,10 @@ xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine)
|
||||||
} else {
|
} else {
|
||||||
xmlChar *buffer;
|
xmlChar *buffer;
|
||||||
|
|
||||||
buffer = xmlEncodeEntitiesReentrant(doc, node->content);
|
if (attr)
|
||||||
|
buffer = xmlEncodeAttributeEntities(doc, node->content);
|
||||||
|
else
|
||||||
|
buffer = xmlEncodeEntitiesReentrant(doc, node->content);
|
||||||
if (buffer != NULL) {
|
if (buffer != NULL) {
|
||||||
ret = xmlStrcat(ret, buffer);
|
ret = xmlStrcat(ret, buffer);
|
||||||
xmlFree(buffer);
|
xmlFree(buffer);
|
||||||
|
@ -2759,7 +2788,7 @@ void
|
||||||
xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc) {
|
xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc) {
|
||||||
xmlAttrPtr prop;
|
xmlAttrPtr prop;
|
||||||
|
|
||||||
if (tree == NULL)
|
if ((tree == NULL) || (tree->type == XML_NAMESPACE_DECL))
|
||||||
return;
|
return;
|
||||||
if (tree->doc != doc) {
|
if (tree->doc != doc) {
|
||||||
if(tree->type == XML_ELEMENT_NODE) {
|
if(tree->type == XML_ELEMENT_NODE) {
|
||||||
|
@ -2787,7 +2816,7 @@ void
|
||||||
xmlSetListDoc(xmlNodePtr list, xmlDocPtr doc) {
|
xmlSetListDoc(xmlNodePtr list, xmlDocPtr doc) {
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
|
|
||||||
if (list == NULL)
|
if ((list == NULL) || (list->type == XML_NAMESPACE_DECL))
|
||||||
return;
|
return;
|
||||||
cur = list;
|
cur = list;
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
|
@ -2894,7 +2923,9 @@ static xmlNodePtr
|
||||||
xmlAddPropSibling(xmlNodePtr prev, xmlNodePtr cur, xmlNodePtr prop) {
|
xmlAddPropSibling(xmlNodePtr prev, xmlNodePtr cur, xmlNodePtr prop) {
|
||||||
xmlAttrPtr attr;
|
xmlAttrPtr attr;
|
||||||
|
|
||||||
if (cur->type != XML_ATTRIBUTE_NODE)
|
if ((cur == NULL) || (cur->type != XML_ATTRIBUTE_NODE) ||
|
||||||
|
(prop == NULL) || (prop->type != XML_ATTRIBUTE_NODE) ||
|
||||||
|
((prev != NULL) && (prev->type != XML_ATTRIBUTE_NODE)))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
/* check if an attribute with the same name exists */
|
/* check if an attribute with the same name exists */
|
||||||
|
@ -2942,14 +2973,14 @@ xmlAddPropSibling(xmlNodePtr prev, xmlNodePtr cur, xmlNodePtr prop) {
|
||||||
*/
|
*/
|
||||||
xmlNodePtr
|
xmlNodePtr
|
||||||
xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
||||||
if (cur == NULL) {
|
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddNextSibling : cur == NULL\n");
|
"xmlAddNextSibling : cur == NULL\n");
|
||||||
#endif
|
#endif
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (elem == NULL) {
|
if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddNextSibling : elem == NULL\n");
|
"xmlAddNextSibling : elem == NULL\n");
|
||||||
|
@ -3020,14 +3051,14 @@ xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
||||||
*/
|
*/
|
||||||
xmlNodePtr
|
xmlNodePtr
|
||||||
xmlAddPrevSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
xmlAddPrevSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
||||||
if (cur == NULL) {
|
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddPrevSibling : cur == NULL\n");
|
"xmlAddPrevSibling : cur == NULL\n");
|
||||||
#endif
|
#endif
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (elem == NULL) {
|
if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddPrevSibling : elem == NULL\n");
|
"xmlAddPrevSibling : elem == NULL\n");
|
||||||
|
@ -3098,7 +3129,7 @@ xmlNodePtr
|
||||||
xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
||||||
xmlNodePtr parent;
|
xmlNodePtr parent;
|
||||||
|
|
||||||
if (cur == NULL) {
|
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddSibling : cur == NULL\n");
|
"xmlAddSibling : cur == NULL\n");
|
||||||
|
@ -3106,7 +3137,7 @@ xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem == NULL) {
|
if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddSibling : elem == NULL\n");
|
"xmlAddSibling : elem == NULL\n");
|
||||||
|
@ -3174,7 +3205,7 @@ xmlNodePtr
|
||||||
xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
|
xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
|
||||||
xmlNodePtr prev;
|
xmlNodePtr prev;
|
||||||
|
|
||||||
if (parent == NULL) {
|
if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddChildList : parent == NULL\n");
|
"xmlAddChildList : parent == NULL\n");
|
||||||
|
@ -3182,7 +3213,7 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur == NULL) {
|
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddChildList : child == NULL\n");
|
"xmlAddChildList : child == NULL\n");
|
||||||
|
@ -3260,7 +3291,7 @@ xmlNodePtr
|
||||||
xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
||||||
xmlNodePtr prev;
|
xmlNodePtr prev;
|
||||||
|
|
||||||
if (parent == NULL) {
|
if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddChild : parent == NULL\n");
|
"xmlAddChild : parent == NULL\n");
|
||||||
|
@ -3268,7 +3299,7 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur == NULL) {
|
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlAddChild : child == NULL\n");
|
"xmlAddChild : child == NULL\n");
|
||||||
|
@ -3382,7 +3413,7 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
||||||
*/
|
*/
|
||||||
xmlNodePtr
|
xmlNodePtr
|
||||||
xmlGetLastChild(xmlNodePtr parent) {
|
xmlGetLastChild(xmlNodePtr parent) {
|
||||||
if (parent == NULL) {
|
if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlGetLastChild : parent == NULL\n");
|
"xmlGetLastChild : parent == NULL\n");
|
||||||
|
@ -3732,6 +3763,10 @@ xmlFreeNode(xmlNodePtr cur) {
|
||||||
* @cur: the node
|
* @cur: the node
|
||||||
*
|
*
|
||||||
* Unlink a node from it's current context, the node is not freed
|
* Unlink a node from it's current context, the node is not freed
|
||||||
|
* If one need to free the node, use xmlFreeNode() routine after the
|
||||||
|
* unlink to discard it.
|
||||||
|
* Note that namespace nodes can't be unlinked as they do not have
|
||||||
|
* pointer to their parent.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xmlUnlinkNode(xmlNodePtr cur) {
|
xmlUnlinkNode(xmlNodePtr cur) {
|
||||||
|
@ -3742,6 +3777,8 @@ xmlUnlinkNode(xmlNodePtr cur) {
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (cur->type == XML_NAMESPACE_DECL)
|
||||||
|
return;
|
||||||
if (cur->type == XML_DTD_NODE) {
|
if (cur->type == XML_DTD_NODE) {
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
doc = cur->doc;
|
doc = cur->doc;
|
||||||
|
@ -3810,14 +3847,15 @@ xmlUnlinkNode(xmlNodePtr cur) {
|
||||||
xmlNodePtr
|
xmlNodePtr
|
||||||
xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
|
xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
|
||||||
if (old == cur) return(NULL);
|
if (old == cur) return(NULL);
|
||||||
if ((old == NULL) || (old->parent == NULL)) {
|
if ((old == NULL) || (old->type == XML_NAMESPACE_DECL) ||
|
||||||
|
(old->parent == NULL)) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlReplaceNode : old == NULL or without parent\n");
|
"xmlReplaceNode : old == NULL or without parent\n");
|
||||||
#endif
|
#endif
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
if (cur == NULL) {
|
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
|
||||||
xmlUnlinkNode(old);
|
xmlUnlinkNode(old);
|
||||||
return(old);
|
return(old);
|
||||||
}
|
}
|
||||||
|
@ -3931,6 +3969,8 @@ xmlCopyPropInternal(xmlDocPtr doc, xmlNodePtr target, xmlAttrPtr cur) {
|
||||||
xmlAttrPtr ret;
|
xmlAttrPtr ret;
|
||||||
|
|
||||||
if (cur == NULL) return(NULL);
|
if (cur == NULL) return(NULL);
|
||||||
|
if ((target != NULL) && (target->type != XML_ELEMENT_NODE))
|
||||||
|
return(NULL);
|
||||||
if (target != NULL)
|
if (target != NULL)
|
||||||
ret = xmlNewDocProp(target->doc, cur->name, NULL);
|
ret = xmlNewDocProp(target->doc, cur->name, NULL);
|
||||||
else if (doc != NULL)
|
else if (doc != NULL)
|
||||||
|
@ -4050,6 +4090,8 @@ xmlCopyPropList(xmlNodePtr target, xmlAttrPtr cur) {
|
||||||
xmlAttrPtr ret = NULL;
|
xmlAttrPtr ret = NULL;
|
||||||
xmlAttrPtr p = NULL,q;
|
xmlAttrPtr p = NULL,q;
|
||||||
|
|
||||||
|
if ((target != NULL) && (target->type != XML_ELEMENT_NODE))
|
||||||
|
return(NULL);
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
q = xmlCopyProp(target, cur);
|
q = xmlCopyProp(target, cur);
|
||||||
if (q == NULL)
|
if (q == NULL)
|
||||||
|
@ -4495,39 +4537,71 @@ xmlCopyDoc(xmlDocPtr doc, int recursive) {
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlGetLineNo:
|
* xmlGetLineNoInternal:
|
||||||
* @node: valid node
|
* @node: valid node
|
||||||
|
* @depth: used to limit any risk of recursion
|
||||||
*
|
*
|
||||||
* Get line number of @node. This requires activation of this option
|
* Get line number of @node.
|
||||||
* before invoking the parser by calling xmlLineNumbersDefault(1)
|
* Try to override the limitation of lines being store in 16 bits ints
|
||||||
*
|
*
|
||||||
* Returns the line number if successful, -1 otherwise
|
* Returns the line number if successful, -1 otherwise
|
||||||
*/
|
*/
|
||||||
long
|
static long
|
||||||
xmlGetLineNo(xmlNodePtr node)
|
xmlGetLineNoInternal(xmlNodePtr node, int depth)
|
||||||
{
|
{
|
||||||
long result = -1;
|
long result = -1;
|
||||||
|
|
||||||
|
if (depth >= 5)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
if (!node)
|
if (!node)
|
||||||
return result;
|
return result;
|
||||||
if ((node->type == XML_ELEMENT_NODE) ||
|
if ((node->type == XML_ELEMENT_NODE) ||
|
||||||
(node->type == XML_TEXT_NODE) ||
|
(node->type == XML_TEXT_NODE) ||
|
||||||
(node->type == XML_COMMENT_NODE) ||
|
(node->type == XML_COMMENT_NODE) ||
|
||||||
(node->type == XML_PI_NODE))
|
(node->type == XML_PI_NODE)) {
|
||||||
result = (long) node->line;
|
if (node->line == 65535) {
|
||||||
else if ((node->prev != NULL) &&
|
if ((node->type == XML_TEXT_NODE) && (node->psvi != NULL))
|
||||||
|
result = (long) node->psvi;
|
||||||
|
else if ((node->type == XML_ELEMENT_NODE) &&
|
||||||
|
(node->children != NULL))
|
||||||
|
result = xmlGetLineNoInternal(node->children, depth + 1);
|
||||||
|
else if (node->next != NULL)
|
||||||
|
result = xmlGetLineNoInternal(node->next, depth + 1);
|
||||||
|
else if (node->prev != NULL)
|
||||||
|
result = xmlGetLineNoInternal(node->prev, depth + 1);
|
||||||
|
}
|
||||||
|
if ((result == -1) || (result == 65535))
|
||||||
|
result = (long) node->line;
|
||||||
|
} else if ((node->prev != NULL) &&
|
||||||
((node->prev->type == XML_ELEMENT_NODE) ||
|
((node->prev->type == XML_ELEMENT_NODE) ||
|
||||||
(node->prev->type == XML_TEXT_NODE) ||
|
(node->prev->type == XML_TEXT_NODE) ||
|
||||||
(node->prev->type == XML_COMMENT_NODE) ||
|
(node->prev->type == XML_COMMENT_NODE) ||
|
||||||
(node->prev->type == XML_PI_NODE)))
|
(node->prev->type == XML_PI_NODE)))
|
||||||
result = xmlGetLineNo(node->prev);
|
result = xmlGetLineNoInternal(node->prev, depth + 1);
|
||||||
else if ((node->parent != NULL) &&
|
else if ((node->parent != NULL) &&
|
||||||
(node->parent->type == XML_ELEMENT_NODE))
|
(node->parent->type == XML_ELEMENT_NODE))
|
||||||
result = xmlGetLineNo(node->parent);
|
result = xmlGetLineNoInternal(node->parent, depth + 1);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlGetLineNo:
|
||||||
|
* @node: valid node
|
||||||
|
*
|
||||||
|
* Get line number of @node.
|
||||||
|
* Try to override the limitation of lines being store in 16 bits ints
|
||||||
|
* if XML_PARSE_BIG_LINES parser option was used
|
||||||
|
*
|
||||||
|
* Returns the line number if successful, -1 otherwise
|
||||||
|
*/
|
||||||
|
long
|
||||||
|
xmlGetLineNo(xmlNodePtr node)
|
||||||
|
{
|
||||||
|
return(xmlGetLineNoInternal(node, 0));
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
|
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
|
||||||
/**
|
/**
|
||||||
* xmlGetNodePath:
|
* xmlGetNodePath:
|
||||||
|
@ -4550,7 +4624,7 @@ xmlGetNodePath(xmlNodePtr node)
|
||||||
char nametemp[100];
|
char nametemp[100];
|
||||||
int occur = 0, generic;
|
int occur = 0, generic;
|
||||||
|
|
||||||
if (node == NULL)
|
if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
buf_len = 500;
|
buf_len = 500;
|
||||||
|
@ -4815,7 +4889,7 @@ xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root) {
|
||||||
xmlNodePtr old = NULL;
|
xmlNodePtr old = NULL;
|
||||||
|
|
||||||
if (doc == NULL) return(NULL);
|
if (doc == NULL) return(NULL);
|
||||||
if (root == NULL)
|
if ((root == NULL) || (root->type == XML_NAMESPACE_DECL))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
xmlUnlinkNode(root);
|
xmlUnlinkNode(root);
|
||||||
xmlSetTreeDoc(root, doc);
|
xmlSetTreeDoc(root, doc);
|
||||||
|
@ -4902,6 +4976,8 @@ xmlChar *
|
||||||
xmlNodeGetLang(xmlNodePtr cur) {
|
xmlNodeGetLang(xmlNodePtr cur) {
|
||||||
xmlChar *lang;
|
xmlChar *lang;
|
||||||
|
|
||||||
|
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
|
||||||
|
return(NULL);
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
lang = xmlGetNsProp(cur, BAD_CAST "lang", XML_XML_NAMESPACE);
|
lang = xmlGetNsProp(cur, BAD_CAST "lang", XML_XML_NAMESPACE);
|
||||||
if (lang != NULL)
|
if (lang != NULL)
|
||||||
|
@ -4981,6 +5057,8 @@ int
|
||||||
xmlNodeGetSpacePreserve(xmlNodePtr cur) {
|
xmlNodeGetSpacePreserve(xmlNodePtr cur) {
|
||||||
xmlChar *space;
|
xmlChar *space;
|
||||||
|
|
||||||
|
if ((cur == NULL) || (cur->type != XML_ELEMENT_NODE))
|
||||||
|
return(-1);
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
space = xmlGetNsProp(cur, BAD_CAST "space", XML_XML_NAMESPACE);
|
space = xmlGetNsProp(cur, BAD_CAST "space", XML_XML_NAMESPACE);
|
||||||
if (space != NULL) {
|
if (space != NULL) {
|
||||||
|
@ -5147,6 +5225,8 @@ xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr cur) {
|
||||||
|
|
||||||
if ((cur == NULL) && (doc == NULL))
|
if ((cur == NULL) && (doc == NULL))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
if ((cur != NULL) && (cur->type == XML_NAMESPACE_DECL))
|
||||||
|
return(NULL);
|
||||||
if (doc == NULL) doc = cur->doc;
|
if (doc == NULL) doc = cur->doc;
|
||||||
if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) {
|
if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) {
|
||||||
cur = doc->children;
|
cur = doc->children;
|
||||||
|
@ -5226,11 +5306,39 @@ xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr cur) {
|
||||||
int
|
int
|
||||||
xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
|
xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
|
||||||
{
|
{
|
||||||
|
xmlBufPtr buf;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if ((cur == NULL) || (buffer == NULL)) return(-1);
|
if ((cur == NULL) || (buffer == NULL)) return(-1);
|
||||||
|
buf = xmlBufFromBuffer(buffer);
|
||||||
|
ret = xmlBufGetNodeContent(buf, cur);
|
||||||
|
buffer = xmlBufBackToBuffer(buf);
|
||||||
|
if ((ret < 0) || (buffer == NULL))
|
||||||
|
return(-1);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlBufGetNodeContent:
|
||||||
|
* @buf: a buffer xmlBufPtr
|
||||||
|
* @cur: the node being read
|
||||||
|
*
|
||||||
|
* Read the value of a node @cur, this can be either the text carried
|
||||||
|
* directly by this node if it's a TEXT node or the aggregate string
|
||||||
|
* of the values carried by this node child's (TEXT and ENTITY_REF).
|
||||||
|
* Entity references are substituted.
|
||||||
|
* Fills up the buffer @buffer with this value
|
||||||
|
*
|
||||||
|
* Returns 0 in case of success and -1 in case of error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xmlBufGetNodeContent(xmlBufPtr buf, xmlNodePtr cur)
|
||||||
|
{
|
||||||
|
if ((cur == NULL) || (buf == NULL)) return(-1);
|
||||||
switch (cur->type) {
|
switch (cur->type) {
|
||||||
case XML_CDATA_SECTION_NODE:
|
case XML_CDATA_SECTION_NODE:
|
||||||
case XML_TEXT_NODE:
|
case XML_TEXT_NODE:
|
||||||
xmlBufferCat(buffer, cur->content);
|
xmlBufCat(buf, cur->content);
|
||||||
break;
|
break;
|
||||||
case XML_DOCUMENT_FRAG_NODE:
|
case XML_DOCUMENT_FRAG_NODE:
|
||||||
case XML_ELEMENT_NODE:{
|
case XML_ELEMENT_NODE:{
|
||||||
|
@ -5241,10 +5349,10 @@ xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
|
||||||
case XML_CDATA_SECTION_NODE:
|
case XML_CDATA_SECTION_NODE:
|
||||||
case XML_TEXT_NODE:
|
case XML_TEXT_NODE:
|
||||||
if (tmp->content != NULL)
|
if (tmp->content != NULL)
|
||||||
xmlBufferCat(buffer, tmp->content);
|
xmlBufCat(buf, tmp->content);
|
||||||
break;
|
break;
|
||||||
case XML_ENTITY_REF_NODE:
|
case XML_ENTITY_REF_NODE:
|
||||||
xmlNodeBufGetContent(buffer, tmp);
|
xmlBufGetNodeContent(buf, tmp);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -5288,16 +5396,16 @@ xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
|
||||||
|
|
||||||
while (tmp != NULL) {
|
while (tmp != NULL) {
|
||||||
if (tmp->type == XML_TEXT_NODE)
|
if (tmp->type == XML_TEXT_NODE)
|
||||||
xmlBufferCat(buffer, tmp->content);
|
xmlBufCat(buf, tmp->content);
|
||||||
else
|
else
|
||||||
xmlNodeBufGetContent(buffer, tmp);
|
xmlBufGetNodeContent(buf, tmp);
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case XML_COMMENT_NODE:
|
case XML_COMMENT_NODE:
|
||||||
case XML_PI_NODE:
|
case XML_PI_NODE:
|
||||||
xmlBufferCat(buffer, cur->content);
|
xmlBufCat(buf, cur->content);
|
||||||
break;
|
break;
|
||||||
case XML_ENTITY_REF_NODE:{
|
case XML_ENTITY_REF_NODE:{
|
||||||
xmlEntityPtr ent;
|
xmlEntityPtr ent;
|
||||||
|
@ -5315,7 +5423,7 @@ xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
|
||||||
* xmlNodeGetContent() which handles all possible node types */
|
* xmlNodeGetContent() which handles all possible node types */
|
||||||
tmp = ent->children;
|
tmp = ent->children;
|
||||||
while (tmp) {
|
while (tmp) {
|
||||||
xmlNodeBufGetContent(buffer, tmp);
|
xmlBufGetNodeContent(buf, tmp);
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -5337,13 +5445,13 @@ xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
|
||||||
if ((cur->type == XML_ELEMENT_NODE) ||
|
if ((cur->type == XML_ELEMENT_NODE) ||
|
||||||
(cur->type == XML_TEXT_NODE) ||
|
(cur->type == XML_TEXT_NODE) ||
|
||||||
(cur->type == XML_CDATA_SECTION_NODE)) {
|
(cur->type == XML_CDATA_SECTION_NODE)) {
|
||||||
xmlNodeBufGetContent(buffer, cur);
|
xmlBufGetNodeContent(buf, cur);
|
||||||
}
|
}
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XML_NAMESPACE_DECL:
|
case XML_NAMESPACE_DECL:
|
||||||
xmlBufferCat(buffer, ((xmlNsPtr) cur)->href);
|
xmlBufCat(buf, ((xmlNsPtr) cur)->href);
|
||||||
break;
|
break;
|
||||||
case XML_ELEMENT_DECL:
|
case XML_ELEMENT_DECL:
|
||||||
case XML_ATTRIBUTE_DECL:
|
case XML_ATTRIBUTE_DECL:
|
||||||
|
@ -5352,6 +5460,7 @@ xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlNodeGetContent:
|
* xmlNodeGetContent:
|
||||||
* @cur: the node being read
|
* @cur: the node being read
|
||||||
|
@ -5371,16 +5480,15 @@ xmlNodeGetContent(xmlNodePtr cur)
|
||||||
switch (cur->type) {
|
switch (cur->type) {
|
||||||
case XML_DOCUMENT_FRAG_NODE:
|
case XML_DOCUMENT_FRAG_NODE:
|
||||||
case XML_ELEMENT_NODE:{
|
case XML_ELEMENT_NODE:{
|
||||||
xmlBufferPtr buffer;
|
xmlBufPtr buf;
|
||||||
xmlChar *ret;
|
xmlChar *ret;
|
||||||
|
|
||||||
buffer = xmlBufferCreateSize(64);
|
buf = xmlBufCreateSize(64);
|
||||||
if (buffer == NULL)
|
if (buf == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
xmlNodeBufGetContent(buffer, cur);
|
xmlBufGetNodeContent(buf, cur);
|
||||||
ret = buffer->content;
|
ret = xmlBufDetach(buf);
|
||||||
buffer->content = NULL;
|
xmlBufFree(buf);
|
||||||
xmlBufferFree(buffer);
|
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
case XML_ATTRIBUTE_NODE:
|
case XML_ATTRIBUTE_NODE:
|
||||||
|
@ -5392,7 +5500,7 @@ xmlNodeGetContent(xmlNodePtr cur)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
case XML_ENTITY_REF_NODE:{
|
case XML_ENTITY_REF_NODE:{
|
||||||
xmlEntityPtr ent;
|
xmlEntityPtr ent;
|
||||||
xmlBufferPtr buffer;
|
xmlBufPtr buf;
|
||||||
xmlChar *ret;
|
xmlChar *ret;
|
||||||
|
|
||||||
/* lookup entity declaration */
|
/* lookup entity declaration */
|
||||||
|
@ -5400,15 +5508,14 @@ xmlNodeGetContent(xmlNodePtr cur)
|
||||||
if (ent == NULL)
|
if (ent == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
buffer = xmlBufferCreate();
|
buf = xmlBufCreate();
|
||||||
if (buffer == NULL)
|
if (buf == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
xmlNodeBufGetContent(buffer, cur);
|
xmlBufGetNodeContent(buf, cur);
|
||||||
|
|
||||||
ret = buffer->content;
|
ret = xmlBufDetach(buf);
|
||||||
buffer->content = NULL;
|
xmlBufFree(buf);
|
||||||
xmlBufferFree(buffer);
|
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
case XML_ENTITY_NODE:
|
case XML_ENTITY_NODE:
|
||||||
|
@ -5423,18 +5530,17 @@ xmlNodeGetContent(xmlNodePtr cur)
|
||||||
case XML_DOCB_DOCUMENT_NODE:
|
case XML_DOCB_DOCUMENT_NODE:
|
||||||
#endif
|
#endif
|
||||||
case XML_HTML_DOCUMENT_NODE: {
|
case XML_HTML_DOCUMENT_NODE: {
|
||||||
xmlBufferPtr buffer;
|
xmlBufPtr buf;
|
||||||
xmlChar *ret;
|
xmlChar *ret;
|
||||||
|
|
||||||
buffer = xmlBufferCreate();
|
buf = xmlBufCreate();
|
||||||
if (buffer == NULL)
|
if (buf == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
xmlNodeBufGetContent(buffer, (xmlNodePtr) cur);
|
xmlBufGetNodeContent(buf, (xmlNodePtr) cur);
|
||||||
|
|
||||||
ret = buffer->content;
|
ret = xmlBufDetach(buf);
|
||||||
buffer->content = NULL;
|
xmlBufFree(buf);
|
||||||
xmlBufferFree(buffer);
|
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
case XML_NAMESPACE_DECL: {
|
case XML_NAMESPACE_DECL: {
|
||||||
|
@ -5755,6 +5861,9 @@ xmlGetNsList(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node)
|
||||||
int maxns = 10;
|
int maxns = 10;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
while (node != NULL) {
|
while (node != NULL) {
|
||||||
if (node->type == XML_ELEMENT_NODE) {
|
if (node->type == XML_ELEMENT_NODE) {
|
||||||
cur = node->nsDef;
|
cur = node->nsDef;
|
||||||
|
@ -5853,7 +5962,7 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
|
||||||
xmlNsPtr cur;
|
xmlNsPtr cur;
|
||||||
xmlNodePtr orig = node;
|
xmlNodePtr orig = node;
|
||||||
|
|
||||||
if (node == NULL) return(NULL);
|
if ((node == NULL) || (node->type == XML_NAMESPACE_DECL)) return(NULL);
|
||||||
if ((nameSpace != NULL) &&
|
if ((nameSpace != NULL) &&
|
||||||
(xmlStrEqual(nameSpace, (const xmlChar *)"xml"))) {
|
(xmlStrEqual(nameSpace, (const xmlChar *)"xml"))) {
|
||||||
if ((doc == NULL) && (node->type == XML_ELEMENT_NODE)) {
|
if ((doc == NULL) && (node->type == XML_ELEMENT_NODE)) {
|
||||||
|
@ -5983,7 +6092,7 @@ xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar * href)
|
||||||
xmlNodePtr orig = node;
|
xmlNodePtr orig = node;
|
||||||
int is_attr;
|
int is_attr;
|
||||||
|
|
||||||
if ((node == NULL) || (href == NULL))
|
if ((node == NULL) || (node->type == XML_NAMESPACE_DECL) || (href == NULL))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
if (xmlStrEqual(href, XML_XML_NAMESPACE)) {
|
if (xmlStrEqual(href, XML_XML_NAMESPACE)) {
|
||||||
/*
|
/*
|
||||||
|
@ -6074,7 +6183,7 @@ xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) {
|
||||||
xmlChar prefix[50];
|
xmlChar prefix[50];
|
||||||
int counter = 1;
|
int counter = 1;
|
||||||
|
|
||||||
if (tree == NULL) {
|
if ((tree == NULL) || (tree->type != XML_ELEMENT_NODE)) {
|
||||||
#ifdef DEBUG_TREE
|
#ifdef DEBUG_TREE
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlNewReconciliedNs : tree == NULL\n");
|
"xmlNewReconciliedNs : tree == NULL\n");
|
||||||
|
@ -6913,6 +7022,34 @@ xmlBufferCreateSize(size_t size) {
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlBufferDetach:
|
||||||
|
* @buf: the buffer
|
||||||
|
*
|
||||||
|
* Remove the string contained in a buffer and gie it back to the
|
||||||
|
* caller. The buffer is reset to an empty content.
|
||||||
|
* This doesn't work with immutable buffers as they can't be reset.
|
||||||
|
*
|
||||||
|
* Returns the previous string contained by the buffer.
|
||||||
|
*/
|
||||||
|
xmlChar *
|
||||||
|
xmlBufferDetach(xmlBufferPtr buf) {
|
||||||
|
xmlChar *ret;
|
||||||
|
|
||||||
|
if (buf == NULL)
|
||||||
|
return(NULL);
|
||||||
|
if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
|
ret = buf->content;
|
||||||
|
buf->content = NULL;
|
||||||
|
buf->size = 0;
|
||||||
|
buf->use = 0;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlBufferCreateStatic:
|
* xmlBufferCreateStatic:
|
||||||
* @mem: the memory area
|
* @mem: the memory area
|
||||||
|
@ -6964,6 +7101,7 @@ xmlBufferSetAllocationScheme(xmlBufferPtr buf,
|
||||||
(buf->alloc == XML_BUFFER_ALLOC_IO)) return;
|
(buf->alloc == XML_BUFFER_ALLOC_IO)) return;
|
||||||
if ((scheme == XML_BUFFER_ALLOC_DOUBLEIT) ||
|
if ((scheme == XML_BUFFER_ALLOC_DOUBLEIT) ||
|
||||||
(scheme == XML_BUFFER_ALLOC_EXACT) ||
|
(scheme == XML_BUFFER_ALLOC_EXACT) ||
|
||||||
|
(scheme == XML_BUFFER_ALLOC_HYBRID) ||
|
||||||
(scheme == XML_BUFFER_ALLOC_IMMUTABLE))
|
(scheme == XML_BUFFER_ALLOC_IMMUTABLE))
|
||||||
buf->alloc = scheme;
|
buf->alloc = scheme;
|
||||||
}
|
}
|
||||||
|
@ -7231,6 +7369,21 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
|
||||||
case XML_BUFFER_ALLOC_EXACT:
|
case XML_BUFFER_ALLOC_EXACT:
|
||||||
newSize = size+10;
|
newSize = size+10;
|
||||||
break;
|
break;
|
||||||
|
case XML_BUFFER_ALLOC_HYBRID:
|
||||||
|
if (buf->use < BASE_BUFFER_SIZE)
|
||||||
|
newSize = size;
|
||||||
|
else {
|
||||||
|
newSize = buf->size * 2;
|
||||||
|
while (size > newSize) {
|
||||||
|
if (newSize > UINT_MAX / 2) {
|
||||||
|
xmlTreeErrMemory("growing buffer");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
newSize *= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
newSize = size+10;
|
newSize = size+10;
|
||||||
break;
|
break;
|
||||||
|
@ -7887,6 +8040,8 @@ xmlDOMWrapNSNormGatherInScopeNs(xmlNsMapPtr *map,
|
||||||
|
|
||||||
if ((map == NULL) || (*map != NULL))
|
if ((map == NULL) || (*map != NULL))
|
||||||
return (-1);
|
return (-1);
|
||||||
|
if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
|
||||||
|
return (-1);
|
||||||
/*
|
/*
|
||||||
* Get in-scope ns-decls of @parent.
|
* Get in-scope ns-decls of @parent.
|
||||||
*/
|
*/
|
||||||
|
@ -8154,6 +8309,8 @@ xmlSearchNsByNamespaceStrict(xmlDocPtr doc, xmlNodePtr node,
|
||||||
|
|
||||||
if ((doc == NULL) || (nsName == NULL) || (retNs == NULL))
|
if ((doc == NULL) || (nsName == NULL) || (retNs == NULL))
|
||||||
return (-1);
|
return (-1);
|
||||||
|
if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
*retNs = NULL;
|
*retNs = NULL;
|
||||||
if (xmlStrEqual(nsName, XML_XML_NAMESPACE)) {
|
if (xmlStrEqual(nsName, XML_XML_NAMESPACE)) {
|
||||||
|
@ -8252,8 +8409,8 @@ xmlSearchNsByPrefixStrict(xmlDocPtr doc, xmlNodePtr node,
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
xmlNsPtr ns;
|
xmlNsPtr ns;
|
||||||
|
|
||||||
if ((doc == NULL) || (node == NULL))
|
if ((doc == NULL) || (node == NULL) || (node->type == XML_NAMESPACE_DECL))
|
||||||
return (-1);
|
return(-1);
|
||||||
|
|
||||||
if (retNs)
|
if (retNs)
|
||||||
*retNs = NULL;
|
*retNs = NULL;
|
||||||
|
@ -8321,6 +8478,9 @@ xmlDOMWrapNSNormDeclareNsForced(xmlDocPtr doc,
|
||||||
char buf[50];
|
char buf[50];
|
||||||
const xmlChar *pref;
|
const xmlChar *pref;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|
||||||
|
if ((doc == NULL) || (elem == NULL) || (elem->type != XML_ELEMENT_NODE))
|
||||||
|
return(NULL);
|
||||||
/*
|
/*
|
||||||
* Create a ns-decl on @anchor.
|
* Create a ns-decl on @anchor.
|
||||||
*/
|
*/
|
||||||
|
@ -8837,6 +8997,9 @@ xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt,
|
||||||
parnsdone = 0;
|
parnsdone = 0;
|
||||||
|
|
||||||
cur = node;
|
cur = node;
|
||||||
|
if ((cur != NULL) && (cur->type == XML_NAMESPACE_DECL))
|
||||||
|
goto internal_error;
|
||||||
|
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
/*
|
/*
|
||||||
* Paranoid source-doc sanity check.
|
* Paranoid source-doc sanity check.
|
||||||
|
@ -9216,6 +9379,9 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
|
||||||
*resNode = NULL;
|
*resNode = NULL;
|
||||||
|
|
||||||
cur = node;
|
cur = node;
|
||||||
|
if ((cur != NULL) && (cur->type == XML_NAMESPACE_DECL))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
if (cur->doc != sourceDoc) {
|
if (cur->doc != sourceDoc) {
|
||||||
/*
|
/*
|
||||||
|
@ -9733,6 +9899,8 @@ xmlDOMWrapAdoptAttr(xmlDOMWrapCtxtPtr ctxt,
|
||||||
if (attr->children == NULL)
|
if (attr->children == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
cur = attr->children;
|
cur = attr->children;
|
||||||
|
if ((cur != NULL) && (cur->type == XML_NAMESPACE_DECL))
|
||||||
|
goto internal_error;
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
cur->doc = destDoc;
|
cur->doc = destDoc;
|
||||||
switch (cur->type) {
|
switch (cur->type) {
|
||||||
|
@ -9817,7 +9985,8 @@ xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
|
||||||
xmlNodePtr destParent,
|
xmlNodePtr destParent,
|
||||||
int options)
|
int options)
|
||||||
{
|
{
|
||||||
if ((node == NULL) || (destDoc == NULL) ||
|
if ((node == NULL) || (node->type == XML_NAMESPACE_DECL) ||
|
||||||
|
(destDoc == NULL) ||
|
||||||
((destParent != NULL) && (destParent->doc != destDoc)))
|
((destParent != NULL) && (destParent->doc != destDoc)))
|
||||||
return(-1);
|
return(-1);
|
||||||
/*
|
/*
|
||||||
|
|
4
reactos/lib/3rdparty/libxml2/trio.c
vendored
4
reactos/lib/3rdparty/libxml2/trio.c
vendored
|
@ -307,6 +307,10 @@ typedef trio_longlong_t trio_int64_t;
|
||||||
#define NAN_LOWER "nan"
|
#define NAN_LOWER "nan"
|
||||||
#define NAN_UPPER "NAN"
|
#define NAN_UPPER "NAN"
|
||||||
|
|
||||||
|
#if !defined(HAVE_ISASCII) && !defined(isascii)
|
||||||
|
# define isascii(x) ((unsigned int)(x) < 128)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Various constants */
|
/* Various constants */
|
||||||
enum {
|
enum {
|
||||||
TYPE_PRINT = 1,
|
TYPE_PRINT = 1,
|
||||||
|
|
2
reactos/lib/3rdparty/libxml2/trio.h
vendored
2
reactos/lib/3rdparty/libxml2/trio.h
vendored
|
@ -28,7 +28,7 @@
|
||||||
* Use autoconf defines if present. Packages using trio must define
|
* Use autoconf defines if present. Packages using trio must define
|
||||||
* HAVE_CONFIG_H as a compiler option themselves.
|
* HAVE_CONFIG_H as a compiler option themselves.
|
||||||
*/
|
*/
|
||||||
#if defined(HAVE_CONFIG_H)
|
#if defined(TRIO_HAVE_CONFIG_H)
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
369
reactos/lib/3rdparty/libxml2/uri.c
vendored
369
reactos/lib/3rdparty/libxml2/uri.c
vendored
|
@ -18,6 +18,37 @@
|
||||||
#include <libxml/globals.h>
|
#include <libxml/globals.h>
|
||||||
#include <libxml/xmlerror.h>
|
#include <libxml/xmlerror.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MAX_URI_LENGTH:
|
||||||
|
*
|
||||||
|
* The definition of the URI regexp in the above RFC has no size limit
|
||||||
|
* In practice they are usually relativey short except for the
|
||||||
|
* data URI scheme as defined in RFC 2397. Even for data URI the usual
|
||||||
|
* maximum size before hitting random practical limits is around 64 KB
|
||||||
|
* and 4KB is usually a maximum admitted limit for proper operations.
|
||||||
|
* The value below is more a security limit than anything else and
|
||||||
|
* really should never be hit by 'normal' operations
|
||||||
|
* Set to 1 MByte in 2012, this is only enforced on output
|
||||||
|
*/
|
||||||
|
#define MAX_URI_LENGTH 1024 * 1024
|
||||||
|
|
||||||
|
static void
|
||||||
|
xmlURIErrMemory(const char *extra)
|
||||||
|
{
|
||||||
|
if (extra)
|
||||||
|
__xmlRaiseError(NULL, NULL, NULL,
|
||||||
|
NULL, NULL, XML_FROM_URI,
|
||||||
|
XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0,
|
||||||
|
extra, NULL, NULL, 0, 0,
|
||||||
|
"Memory allocation failed : %s\n", extra);
|
||||||
|
else
|
||||||
|
__xmlRaiseError(NULL, NULL, NULL,
|
||||||
|
NULL, NULL, XML_FROM_URI,
|
||||||
|
XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0,
|
||||||
|
NULL, NULL, NULL, 0, 0,
|
||||||
|
"Memory allocation failed\n");
|
||||||
|
}
|
||||||
|
|
||||||
static void xmlCleanURI(xmlURIPtr uri);
|
static void xmlCleanURI(xmlURIPtr uri);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -980,14 +1011,38 @@ xmlCreateURI(void) {
|
||||||
|
|
||||||
ret = (xmlURIPtr) xmlMalloc(sizeof(xmlURI));
|
ret = (xmlURIPtr) xmlMalloc(sizeof(xmlURI));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlURIErrMemory("creating URI structure\n");
|
||||||
"xmlCreateURI: out of memory\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, sizeof(xmlURI));
|
memset(ret, 0, sizeof(xmlURI));
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlSaveUriRealloc:
|
||||||
|
*
|
||||||
|
* Function to handle properly a reallocation when saving an URI
|
||||||
|
* Also imposes some limit on the length of an URI string output
|
||||||
|
*/
|
||||||
|
static xmlChar *
|
||||||
|
xmlSaveUriRealloc(xmlChar *ret, int *max) {
|
||||||
|
xmlChar *temp;
|
||||||
|
int tmp;
|
||||||
|
|
||||||
|
if (*max > MAX_URI_LENGTH) {
|
||||||
|
xmlURIErrMemory("reaching arbitrary MAX_URI_LENGTH limit\n");
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
tmp = *max * 2;
|
||||||
|
temp = (xmlChar *) xmlRealloc(ret, (tmp + 1));
|
||||||
|
if (temp == NULL) {
|
||||||
|
xmlURIErrMemory("saving URI\n");
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
*max = tmp;
|
||||||
|
return(temp);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlSaveUri:
|
* xmlSaveUri:
|
||||||
* @uri: pointer to an xmlURI
|
* @uri: pointer to an xmlURI
|
||||||
|
@ -1010,8 +1065,7 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||||
max = 80;
|
max = 80;
|
||||||
ret = (xmlChar *) xmlMallocAtomic((max + 1) * sizeof(xmlChar));
|
ret = (xmlChar *) xmlMallocAtomic((max + 1) * sizeof(xmlChar));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlURIErrMemory("saving URI\n");
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
len = 0;
|
len = 0;
|
||||||
|
@ -1020,28 +1074,16 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||||
p = uri->scheme;
|
p = uri->scheme;
|
||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len >= max) {
|
if (len >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
if (temp == NULL) goto mem_error;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
ret = temp;
|
||||||
}
|
}
|
||||||
ret[len++] = *p++;
|
ret[len++] = *p++;
|
||||||
}
|
}
|
||||||
if (len >= max) {
|
if (len >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
if (temp == NULL) goto mem_error;
|
||||||
if (temp == NULL) {
|
ret = temp;
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
ret[len++] = ':';
|
ret[len++] = ':';
|
||||||
}
|
}
|
||||||
|
@ -1049,15 +1091,9 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||||
p = uri->opaque;
|
p = uri->opaque;
|
||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
if (temp == NULL) goto mem_error;
|
||||||
if (temp == NULL) {
|
ret = temp;
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
if (IS_RESERVED(*(p)) || IS_UNRESERVED(*(p)))
|
if (IS_RESERVED(*(p)) || IS_UNRESERVED(*(p)))
|
||||||
ret[len++] = *p++;
|
ret[len++] = *p++;
|
||||||
|
@ -1072,15 +1108,9 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||||
} else {
|
} else {
|
||||||
if (uri->server != NULL) {
|
if (uri->server != NULL) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
if (temp == NULL) goto mem_error;
|
||||||
if (temp == NULL) {
|
ret = temp;
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
ret[len++] = '/';
|
ret[len++] = '/';
|
||||||
ret[len++] = '/';
|
ret[len++] = '/';
|
||||||
|
@ -1088,16 +1118,9 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||||
p = uri->user;
|
p = uri->user;
|
||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
if ((IS_UNRESERVED(*(p))) ||
|
if ((IS_UNRESERVED(*(p))) ||
|
||||||
((*(p) == ';')) || ((*(p) == ':')) ||
|
((*(p) == ';')) || ((*(p) == ':')) ||
|
||||||
|
@ -1114,78 +1137,43 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
ret[len++] = '@';
|
ret[len++] = '@';
|
||||||
}
|
}
|
||||||
p = uri->server;
|
p = uri->server;
|
||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len >= max) {
|
if (len >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
ret[len++] = *p++;
|
ret[len++] = *p++;
|
||||||
}
|
}
|
||||||
if (uri->port > 0) {
|
if (uri->port > 0) {
|
||||||
if (len + 10 >= max) {
|
if (len + 10 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
len += snprintf((char *) &ret[len], max - len, ":%d", uri->port);
|
len += snprintf((char *) &ret[len], max - len, ":%d", uri->port);
|
||||||
}
|
}
|
||||||
} else if (uri->authority != NULL) {
|
} else if (uri->authority != NULL) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
ret[len++] = '/';
|
ret[len++] = '/';
|
||||||
ret[len++] = '/';
|
ret[len++] = '/';
|
||||||
p = uri->authority;
|
p = uri->authority;
|
||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
if ((IS_UNRESERVED(*(p))) ||
|
if ((IS_UNRESERVED(*(p))) ||
|
||||||
((*(p) == '$')) || ((*(p) == ',')) || ((*(p) == ';')) ||
|
((*(p) == '$')) || ((*(p) == ',')) || ((*(p) == ';')) ||
|
||||||
|
@ -1202,16 +1190,9 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||||
}
|
}
|
||||||
} else if (uri->scheme != NULL) {
|
} else if (uri->scheme != NULL) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
ret[len++] = '/';
|
ret[len++] = '/';
|
||||||
ret[len++] = '/';
|
ret[len++] = '/';
|
||||||
|
@ -1229,14 +1210,9 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||||
(p[2] == ':') &&
|
(p[2] == ':') &&
|
||||||
(xmlStrEqual(BAD_CAST uri->scheme, BAD_CAST "file"))) {
|
(xmlStrEqual(BAD_CAST uri->scheme, BAD_CAST "file"))) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
ret = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (ret == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ret[len++] = *p++;
|
ret[len++] = *p++;
|
||||||
ret[len++] = *p++;
|
ret[len++] = *p++;
|
||||||
|
@ -1244,16 +1220,9 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||||
}
|
}
|
||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
if ((IS_UNRESERVED(*(p))) || ((*(p) == '/')) ||
|
if ((IS_UNRESERVED(*(p))) || ((*(p) == '/')) ||
|
||||||
((*(p) == ';')) || ((*(p) == '@')) || ((*(p) == '&')) ||
|
((*(p) == ';')) || ((*(p) == '@')) || ((*(p) == '&')) ||
|
||||||
|
@ -1271,61 +1240,33 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||||
}
|
}
|
||||||
if (uri->query_raw != NULL) {
|
if (uri->query_raw != NULL) {
|
||||||
if (len + 1 >= max) {
|
if (len + 1 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
ret[len++] = '?';
|
ret[len++] = '?';
|
||||||
p = uri->query_raw;
|
p = uri->query_raw;
|
||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len + 1 >= max) {
|
if (len + 1 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
ret[len++] = *p++;
|
ret[len++] = *p++;
|
||||||
}
|
}
|
||||||
} else if (uri->query != NULL) {
|
} else if (uri->query != NULL) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
ret[len++] = '?';
|
ret[len++] = '?';
|
||||||
p = uri->query;
|
p = uri->query;
|
||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p))))
|
if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p))))
|
||||||
ret[len++] = *p++;
|
ret[len++] = *p++;
|
||||||
|
@ -1341,31 +1282,17 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||||
}
|
}
|
||||||
if (uri->fragment != NULL) {
|
if (uri->fragment != NULL) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
ret[len++] = '#';
|
ret[len++] = '#';
|
||||||
p = uri->fragment;
|
p = uri->fragment;
|
||||||
while (*p != 0) {
|
while (*p != 0) {
|
||||||
if (len + 3 >= max) {
|
if (len + 3 >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret,
|
if (temp == NULL) goto mem_error;
|
||||||
(max + 1) * sizeof(xmlChar));
|
ret = temp;
|
||||||
if (temp == NULL) {
|
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p))))
|
if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p))))
|
||||||
ret[len++] = *p++;
|
ret[len++] = *p++;
|
||||||
|
@ -1379,18 +1306,16 @@ xmlSaveUri(xmlURIPtr uri) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (len >= max) {
|
if (len >= max) {
|
||||||
max *= 2;
|
temp = xmlSaveUriRealloc(ret, &max);
|
||||||
temp = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
|
if (temp == NULL) goto mem_error;
|
||||||
if (temp == NULL) {
|
ret = temp;
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlSaveUri: out of memory\n");
|
|
||||||
xmlFree(ret);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
ret = temp;
|
|
||||||
}
|
}
|
||||||
ret[len] = 0;
|
ret[len] = 0;
|
||||||
return(ret);
|
return(ret);
|
||||||
|
|
||||||
|
mem_error:
|
||||||
|
xmlFree(ret);
|
||||||
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1604,10 +1529,11 @@ xmlNormalizeURIPath(char *path) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Valgrind complained, strcpy(cur, segp + 3); */
|
/* Valgrind complained, strcpy(cur, segp + 3); */
|
||||||
/* string will overlap, do not use strcpy */
|
/* string will overlap, do not use strcpy */
|
||||||
tmp = cur;
|
tmp = cur;
|
||||||
segp += 3;
|
segp += 3;
|
||||||
while ((*tmp++ = *segp++) != 0);
|
while ((*tmp++ = *segp++) != 0)
|
||||||
|
;
|
||||||
|
|
||||||
/* If there are no previous segments, then keep going from here. */
|
/* If there are no previous segments, then keep going from here. */
|
||||||
segp = cur;
|
segp = cur;
|
||||||
|
@ -1692,8 +1618,7 @@ xmlURIUnescapeString(const char *str, int len, char *target) {
|
||||||
if (target == NULL) {
|
if (target == NULL) {
|
||||||
ret = (char *) xmlMallocAtomic(len + 1);
|
ret = (char *) xmlMallocAtomic(len + 1);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlURIErrMemory("unescaping URI value\n");
|
||||||
"xmlURIUnescapeString: out of memory\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -1743,8 +1668,7 @@ xmlURIEscapeStr(const xmlChar *str, const xmlChar *list) {
|
||||||
xmlChar *ret, ch;
|
xmlChar *ret, ch;
|
||||||
xmlChar *temp;
|
xmlChar *temp;
|
||||||
const xmlChar *in;
|
const xmlChar *in;
|
||||||
|
int len, out;
|
||||||
unsigned int len, out;
|
|
||||||
|
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
@ -1756,19 +1680,16 @@ xmlURIEscapeStr(const xmlChar *str, const xmlChar *list) {
|
||||||
len += 20;
|
len += 20;
|
||||||
ret = (xmlChar *) xmlMallocAtomic(len);
|
ret = (xmlChar *) xmlMallocAtomic(len);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlURIErrMemory("escaping URI value\n");
|
||||||
"xmlURIEscapeStr: out of memory\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
in = (const xmlChar *) str;
|
in = (const xmlChar *) str;
|
||||||
out = 0;
|
out = 0;
|
||||||
while(*in != 0) {
|
while(*in != 0) {
|
||||||
if (len - out <= 3) {
|
if (len - out <= 3) {
|
||||||
len += 20;
|
temp = xmlSaveUriRealloc(ret, &len);
|
||||||
temp = (xmlChar *) xmlRealloc(ret, len);
|
|
||||||
if (temp == NULL) {
|
if (temp == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlURIErrMemory("escaping URI value\n");
|
||||||
"xmlURIEscapeStr: out of memory\n");
|
|
||||||
xmlFree(ret);
|
xmlFree(ret);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
@ -1823,10 +1744,9 @@ xmlURIEscape(const xmlChar * str)
|
||||||
int ret2;
|
int ret2;
|
||||||
|
|
||||||
#define NULLCHK(p) if(!p) { \
|
#define NULLCHK(p) if(!p) { \
|
||||||
xmlGenericError(xmlGenericErrorContext, \
|
xmlURIErrMemory("escaping URI value\n"); \
|
||||||
"xmlURIEscape: out of memory\n"); \
|
xmlFreeURI(uri); \
|
||||||
xmlFreeURI(uri); \
|
return NULL; } \
|
||||||
return NULL; } \
|
|
||||||
|
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
@ -2133,8 +2053,7 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
|
||||||
len += strlen(bas->path);
|
len += strlen(bas->path);
|
||||||
res->path = (char *) xmlMallocAtomic(len);
|
res->path = (char *) xmlMallocAtomic(len);
|
||||||
if (res->path == NULL) {
|
if (res->path == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlURIErrMemory("resolving URI against base\n");
|
||||||
"xmlBuildURI: out of memory\n");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
res->path[0] = 0;
|
res->path[0] = 0;
|
||||||
|
@ -2395,8 +2314,7 @@ xmlBuildRelativeURI (const xmlChar * URI, const xmlChar * base)
|
||||||
*/
|
*/
|
||||||
val = (xmlChar *) xmlMalloc (len + 3 * nbslash);
|
val = (xmlChar *) xmlMalloc (len + 3 * nbslash);
|
||||||
if (val == NULL) {
|
if (val == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlURIErrMemory("building relative URI\n");
|
||||||
"xmlBuildRelativeURI: out of memory\n");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
vptr = val;
|
vptr = val;
|
||||||
|
@ -2479,7 +2397,20 @@ xmlCanonicPath(const xmlChar *path)
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
/* sanitize filename starting with // so it can be used as URI */
|
#if defined(_WIN32)
|
||||||
|
/*
|
||||||
|
* We must not change the backslashes to slashes if the the path
|
||||||
|
* starts with \\?\
|
||||||
|
* Those paths can be up to 32k characters long.
|
||||||
|
* Was added specifically for OpenOffice, those paths can't be converted
|
||||||
|
* to URIs anyway.
|
||||||
|
*/
|
||||||
|
if ((path[0] == '\\') && (path[1] == '\\') && (path[2] == '?') &&
|
||||||
|
(path[3] == '\\') )
|
||||||
|
return xmlStrdup((const xmlChar *) path);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* sanitize filename starting with // so it can be used as URI */
|
||||||
if ((path[0] == '/') && (path[1] == '/') && (path[2] != '/'))
|
if ((path[0] == '/') && (path[1] == '/') && (path[2] != '/'))
|
||||||
path++;
|
path++;
|
||||||
|
|
||||||
|
|
15
reactos/lib/3rdparty/libxml2/valid.c
vendored
15
reactos/lib/3rdparty/libxml2/valid.c
vendored
|
@ -5236,7 +5236,7 @@ xmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child,
|
||||||
xmlElementContentPtr cont;
|
xmlElementContentPtr cont;
|
||||||
const xmlChar *name;
|
const xmlChar *name;
|
||||||
|
|
||||||
if (elemDecl == NULL)
|
if ((elemDecl == NULL) || (parent == NULL))
|
||||||
return(-1);
|
return(-1);
|
||||||
cont = elemDecl->content;
|
cont = elemDecl->content;
|
||||||
name = elemDecl->name;
|
name = elemDecl->name;
|
||||||
|
@ -5517,7 +5517,8 @@ xmlValidateOneCdataElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
xmlNodePtr cur, child;
|
xmlNodePtr cur, child;
|
||||||
|
|
||||||
if ((ctxt == NULL) || (doc == NULL) || (elem == NULL))
|
if ((ctxt == NULL) || (doc == NULL) || (elem == NULL) ||
|
||||||
|
(elem->type != XML_ELEMENT_NODE))
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
child = elem->children;
|
child = elem->children;
|
||||||
|
@ -6379,7 +6380,8 @@ xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem) {
|
||||||
* they don't really mean anything validation wise.
|
* they don't really mean anything validation wise.
|
||||||
*/
|
*/
|
||||||
if ((elem->type == XML_XINCLUDE_START) ||
|
if ((elem->type == XML_XINCLUDE_START) ||
|
||||||
(elem->type == XML_XINCLUDE_END))
|
(elem->type == XML_XINCLUDE_END) ||
|
||||||
|
(elem->type == XML_NAMESPACE_DECL))
|
||||||
return(1);
|
return(1);
|
||||||
|
|
||||||
CHECK_DTD;
|
CHECK_DTD;
|
||||||
|
@ -6559,6 +6561,7 @@ xmlValidateCheckRefCallback(xmlListPtr ref_list, xmlValidCtxtPtr ctxt,
|
||||||
int
|
int
|
||||||
xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
|
xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
|
||||||
xmlRefTablePtr table;
|
xmlRefTablePtr table;
|
||||||
|
unsigned int save;
|
||||||
|
|
||||||
if (ctxt == NULL)
|
if (ctxt == NULL)
|
||||||
return(0);
|
return(0);
|
||||||
|
@ -6568,6 +6571,10 @@ xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* trick to get correct line id report */
|
||||||
|
save = ctxt->finishDtd;
|
||||||
|
ctxt->finishDtd = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check all the NOTATION/NOTATIONS attributes
|
* Check all the NOTATION/NOTATIONS attributes
|
||||||
*/
|
*/
|
||||||
|
@ -6581,6 +6588,8 @@ xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
|
||||||
ctxt->doc = doc;
|
ctxt->doc = doc;
|
||||||
ctxt->valid = 1;
|
ctxt->valid = 1;
|
||||||
xmlHashScan(table, (xmlHashScanner) xmlValidateCheckRefCallback, ctxt);
|
xmlHashScan(table, (xmlHashScanner) xmlValidateCheckRefCallback, ctxt);
|
||||||
|
|
||||||
|
ctxt->finishDtd = save;
|
||||||
return(ctxt->valid);
|
return(ctxt->valid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
74
reactos/lib/3rdparty/libxml2/xinclude.c
vendored
74
reactos/lib/3rdparty/libxml2/xinclude.c
vendored
|
@ -26,6 +26,7 @@
|
||||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||||
#include <libxml/xinclude.h>
|
#include <libxml/xinclude.h>
|
||||||
|
|
||||||
|
#include "buf.h"
|
||||||
|
|
||||||
#define XINCLUDE_MAX_DEPTH 40
|
#define XINCLUDE_MAX_DEPTH 40
|
||||||
|
|
||||||
|
@ -874,8 +875,8 @@ xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
||||||
static xmlNodePtr
|
static xmlNodePtr
|
||||||
xmlXIncludeGetNthChild(xmlNodePtr cur, int no) {
|
xmlXIncludeGetNthChild(xmlNodePtr cur, int no) {
|
||||||
int i;
|
int i;
|
||||||
if (cur == NULL)
|
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
|
||||||
return(cur);
|
return(NULL);
|
||||||
cur = cur->children;
|
cur = cur->children;
|
||||||
for (i = 0;i <= no;cur = cur->next) {
|
for (i = 0;i <= no;cur = cur->next) {
|
||||||
if (cur == NULL)
|
if (cur == NULL)
|
||||||
|
@ -922,11 +923,13 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
|
||||||
return(NULL);
|
return(NULL);
|
||||||
start = (xmlNodePtr) range->user;
|
start = (xmlNodePtr) range->user;
|
||||||
|
|
||||||
if (start == NULL)
|
if ((start == NULL) || (start->type == XML_NAMESPACE_DECL))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
end = range->user2;
|
end = range->user2;
|
||||||
if (end == NULL)
|
if (end == NULL)
|
||||||
return(xmlDocCopyNode(start, target, 1));
|
return(xmlDocCopyNode(start, target, 1));
|
||||||
|
if (end->type == XML_NAMESPACE_DECL)
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
cur = start;
|
cur = start;
|
||||||
index1 = range->index;
|
index1 = range->index;
|
||||||
|
@ -1796,6 +1799,9 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
|
||||||
int i;
|
int i;
|
||||||
xmlChar *encoding = NULL;
|
xmlChar *encoding = NULL;
|
||||||
xmlCharEncoding enc = (xmlCharEncoding) 0;
|
xmlCharEncoding enc = (xmlCharEncoding) 0;
|
||||||
|
xmlParserCtxtPtr pctxt;
|
||||||
|
xmlParserInputPtr inputStream;
|
||||||
|
int xinclude_multibyte_fallback_used = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check the URL and remove any fragment identifier
|
* Check the URL and remove any fragment identifier
|
||||||
|
@ -1870,43 +1876,65 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
|
||||||
/*
|
/*
|
||||||
* Load it.
|
* Load it.
|
||||||
*/
|
*/
|
||||||
buf = xmlParserInputBufferCreateFilename((const char *)URL, enc);
|
pctxt = xmlNewParserCtxt();
|
||||||
if (buf == NULL) {
|
inputStream = xmlLoadExternalEntity((const char*)URL, NULL, pctxt);
|
||||||
|
if(inputStream == NULL) {
|
||||||
|
xmlFreeParserCtxt(pctxt);
|
||||||
xmlFree(URL);
|
xmlFree(URL);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
buf = inputStream->buf;
|
||||||
|
if (buf == NULL) {
|
||||||
|
xmlFreeInputStream (inputStream);
|
||||||
|
xmlFreeParserCtxt(pctxt);
|
||||||
|
xmlFree(URL);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
if (buf->encoder)
|
||||||
|
xmlCharEncCloseFunc(buf->encoder);
|
||||||
|
buf->encoder = xmlGetCharEncodingHandler(enc);
|
||||||
node = xmlNewText(NULL);
|
node = xmlNewText(NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Scan all chars from the resource and add the to the node
|
* Scan all chars from the resource and add the to the node
|
||||||
*/
|
*/
|
||||||
|
xinclude_multibyte_fallback:
|
||||||
while (xmlParserInputBufferRead(buf, 128) > 0) {
|
while (xmlParserInputBufferRead(buf, 128) > 0) {
|
||||||
int len;
|
int len;
|
||||||
const xmlChar *content;
|
const xmlChar *content;
|
||||||
|
|
||||||
content = xmlBufferContent(buf->buffer);
|
content = xmlBufContent(buf->buffer);
|
||||||
len = xmlBufferLength(buf->buffer);
|
len = xmlBufLength(buf->buffer);
|
||||||
for (i = 0;i < len;) {
|
for (i = 0;i < len;) {
|
||||||
int cur;
|
int cur;
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
cur = xmlStringCurrentChar(NULL, &content[i], &l);
|
cur = xmlStringCurrentChar(NULL, &content[i], &l);
|
||||||
if (!IS_CHAR(cur)) {
|
if (!IS_CHAR(cur)) {
|
||||||
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
|
/* Handle splitted multibyte char at buffer boundary */
|
||||||
XML_XINCLUDE_INVALID_CHAR,
|
if (((len - i) < 4) && (!xinclude_multibyte_fallback_used)) {
|
||||||
"%s contains invalid char\n", URL);
|
xinclude_multibyte_fallback_used = 1;
|
||||||
xmlFreeParserInputBuffer(buf);
|
xmlBufShrink(buf->buffer, i);
|
||||||
xmlFree(URL);
|
goto xinclude_multibyte_fallback;
|
||||||
return(-1);
|
} else {
|
||||||
|
xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
|
||||||
|
XML_XINCLUDE_INVALID_CHAR,
|
||||||
|
"%s contains invalid char\n", URL);
|
||||||
|
xmlFreeParserInputBuffer(buf);
|
||||||
|
xmlFree(URL);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
xinclude_multibyte_fallback_used = 0;
|
||||||
xmlNodeAddContentLen(node, &content[i], l);
|
xmlNodeAddContentLen(node, &content[i], l);
|
||||||
}
|
}
|
||||||
i += l;
|
i += l;
|
||||||
}
|
}
|
||||||
xmlBufferShrink(buf->buffer, len);
|
xmlBufShrink(buf->buffer, len);
|
||||||
}
|
}
|
||||||
xmlFreeParserInputBuffer(buf);
|
xmlFreeParserCtxt(pctxt);
|
||||||
xmlXIncludeAddTxt(ctxt, node, URL);
|
xmlXIncludeAddTxt(ctxt, node, URL);
|
||||||
|
xmlFreeInputStream(inputStream);
|
||||||
|
|
||||||
loaded:
|
loaded:
|
||||||
/*
|
/*
|
||||||
|
@ -1933,7 +1961,8 @@ xmlXIncludeLoadFallback(xmlXIncludeCtxtPtr ctxt, xmlNodePtr fallback, int nr) {
|
||||||
xmlXIncludeCtxtPtr newctxt;
|
xmlXIncludeCtxtPtr newctxt;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if ((fallback == NULL) || (ctxt == NULL))
|
if ((fallback == NULL) || (fallback->type == XML_NAMESPACE_DECL) ||
|
||||||
|
(ctxt == NULL))
|
||||||
return(-1);
|
return(-1);
|
||||||
if (fallback->children != NULL) {
|
if (fallback->children != NULL) {
|
||||||
/*
|
/*
|
||||||
|
@ -2159,7 +2188,7 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
|
||||||
if ((nr < 0) || (nr >= ctxt->incNr))
|
if ((nr < 0) || (nr >= ctxt->incNr))
|
||||||
return(-1);
|
return(-1);
|
||||||
cur = ctxt->incTab[nr]->ref;
|
cur = ctxt->incTab[nr]->ref;
|
||||||
if (cur == NULL)
|
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2334,7 +2363,7 @@ xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int i, start;
|
int i, start;
|
||||||
|
|
||||||
if ((doc == NULL) || (tree == NULL))
|
if ((doc == NULL) || (tree == NULL) || (tree->type == XML_NAMESPACE_DECL))
|
||||||
return(-1);
|
return(-1);
|
||||||
if (ctxt == NULL)
|
if (ctxt == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
|
@ -2448,7 +2477,8 @@ xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree, int flags, void *data) {
|
||||||
xmlXIncludeCtxtPtr ctxt;
|
xmlXIncludeCtxtPtr ctxt;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if ((tree == NULL) || (tree->doc == NULL))
|
if ((tree == NULL) || (tree->type == XML_NAMESPACE_DECL) ||
|
||||||
|
(tree->doc == NULL))
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
ctxt = xmlXIncludeNewContext(tree->doc);
|
ctxt = xmlXIncludeNewContext(tree->doc);
|
||||||
|
@ -2533,7 +2563,8 @@ xmlXIncludeProcessTreeFlags(xmlNodePtr tree, int flags) {
|
||||||
xmlXIncludeCtxtPtr ctxt;
|
xmlXIncludeCtxtPtr ctxt;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if ((tree == NULL) || (tree->doc == NULL))
|
if ((tree == NULL) || (tree->type == XML_NAMESPACE_DECL) ||
|
||||||
|
(tree->doc == NULL))
|
||||||
return(-1);
|
return(-1);
|
||||||
ctxt = xmlXIncludeNewContext(tree->doc);
|
ctxt = xmlXIncludeNewContext(tree->doc);
|
||||||
if (ctxt == NULL)
|
if (ctxt == NULL)
|
||||||
|
@ -2577,7 +2608,8 @@ int
|
||||||
xmlXIncludeProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
|
xmlXIncludeProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if ((node == NULL) || (node->doc == NULL) || (ctxt == NULL))
|
if ((node == NULL) || (node->type == XML_NAMESPACE_DECL) ||
|
||||||
|
(node->doc == NULL) || (ctxt == NULL))
|
||||||
return(-1);
|
return(-1);
|
||||||
ret = xmlXIncludeDoProcess(ctxt, node->doc, node);
|
ret = xmlXIncludeDoProcess(ctxt, node->doc, node);
|
||||||
if ((ret >= 0) && (ctxt->nbErrors > 0))
|
if ((ret >= 0) && (ctxt->nbErrors > 0))
|
||||||
|
|
347
reactos/lib/3rdparty/libxml2/xmlIO.c
vendored
347
reactos/lib/3rdparty/libxml2/xmlIO.c
vendored
|
@ -35,6 +35,9 @@
|
||||||
#ifdef HAVE_ZLIB_H
|
#ifdef HAVE_ZLIB_H
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_LZMA_H
|
||||||
|
#include <lzma.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(WIN32) || defined(_WIN32)
|
#if defined(WIN32) || defined(_WIN32)
|
||||||
//#include <windows.h>
|
//#include <windows.h>
|
||||||
|
@ -94,6 +97,9 @@
|
||||||
#endif
|
#endif
|
||||||
#include <libxml/globals.h>
|
#include <libxml/globals.h>
|
||||||
|
|
||||||
|
#include "buf.h"
|
||||||
|
#include "enc.h"
|
||||||
|
|
||||||
/* #define VERBOSE_FAILURE */
|
/* #define VERBOSE_FAILURE */
|
||||||
/* #define DEBUG_EXTERNAL_ENTITIES */
|
/* #define DEBUG_EXTERNAL_ENTITIES */
|
||||||
/* #define DEBUG_INPUT */
|
/* #define DEBUG_INPUT */
|
||||||
|
@ -766,13 +772,21 @@ int
|
||||||
xmlCheckFilename (const char *path)
|
xmlCheckFilename (const char *path)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_STAT
|
#ifdef HAVE_STAT
|
||||||
struct stat stat_buffer;
|
struct stat stat_buffer;
|
||||||
#endif
|
#endif
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
#ifdef HAVE_STAT
|
#ifdef HAVE_STAT
|
||||||
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
|
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
|
||||||
|
/*
|
||||||
|
* On Windows stat and wstat do not work with long pathname,
|
||||||
|
* which start with '\\?\'
|
||||||
|
*/
|
||||||
|
if ((path[0] == '\\') && (path[1] == '\\') && (path[2] == '?') &&
|
||||||
|
(path[3] == '\\') )
|
||||||
|
return 1;
|
||||||
|
|
||||||
if (xmlWrapStat(path, &stat_buffer) == -1)
|
if (xmlWrapStat(path, &stat_buffer) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
|
@ -1307,6 +1321,125 @@ xmlGzfileClose (void * context) {
|
||||||
}
|
}
|
||||||
#endif /* HAVE_ZLIB_H */
|
#endif /* HAVE_ZLIB_H */
|
||||||
|
|
||||||
|
#ifdef HAVE_LZMA_H
|
||||||
|
/************************************************************************
|
||||||
|
* *
|
||||||
|
* I/O for compressed file accesses *
|
||||||
|
* *
|
||||||
|
************************************************************************/
|
||||||
|
#include "xzlib.h"
|
||||||
|
/**
|
||||||
|
* xmlXzfileMatch:
|
||||||
|
* @filename: the URI for matching
|
||||||
|
*
|
||||||
|
* input from compressed file test
|
||||||
|
*
|
||||||
|
* Returns 1 if matches, 0 otherwise
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
xmlXzfileMatch (const char *filename ATTRIBUTE_UNUSED) {
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlXzFileOpen_real:
|
||||||
|
* @filename: the URI for matching
|
||||||
|
*
|
||||||
|
* input from compressed file open
|
||||||
|
* if @filename is " " then the standard input is used
|
||||||
|
*
|
||||||
|
* Returns an I/O context or NULL in case of error
|
||||||
|
*/
|
||||||
|
static void *
|
||||||
|
xmlXzfileOpen_real (const char *filename) {
|
||||||
|
const char *path = NULL;
|
||||||
|
xzFile fd;
|
||||||
|
|
||||||
|
if (!strcmp(filename, "-")) {
|
||||||
|
fd = __libxml2_xzdopen(dup(0), "rb");
|
||||||
|
return((void *) fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost/", 17)) {
|
||||||
|
path = &filename[16];
|
||||||
|
} else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
|
||||||
|
path = &filename[7];
|
||||||
|
} else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:/", 6)) {
|
||||||
|
/* lots of generators seems to lazy to read RFC 1738 */
|
||||||
|
path = &filename[5];
|
||||||
|
} else
|
||||||
|
path = filename;
|
||||||
|
|
||||||
|
if (path == NULL)
|
||||||
|
return(NULL);
|
||||||
|
if (!xmlCheckFilename(path))
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
|
fd = __libxml2_xzopen(path, "rb");
|
||||||
|
return((void *) fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlXzfileOpen:
|
||||||
|
* @filename: the URI for matching
|
||||||
|
*
|
||||||
|
* Wrapper around xmlXzfileOpen_real that try it with an unescaped
|
||||||
|
* version of @filename, if this fails fallback to @filename
|
||||||
|
*
|
||||||
|
* Returns a handler or NULL in case or failure
|
||||||
|
*/
|
||||||
|
static void *
|
||||||
|
xmlXzfileOpen (const char *filename) {
|
||||||
|
char *unescaped;
|
||||||
|
void *retval;
|
||||||
|
|
||||||
|
retval = xmlXzfileOpen_real(filename);
|
||||||
|
if (retval == NULL) {
|
||||||
|
unescaped = xmlURIUnescapeString(filename, 0, NULL);
|
||||||
|
if (unescaped != NULL) {
|
||||||
|
retval = xmlXzfileOpen_real(unescaped);
|
||||||
|
}
|
||||||
|
xmlFree(unescaped);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlXzfileRead:
|
||||||
|
* @context: the I/O context
|
||||||
|
* @buffer: where to drop data
|
||||||
|
* @len: number of bytes to write
|
||||||
|
*
|
||||||
|
* Read @len bytes to @buffer from the compressed I/O channel.
|
||||||
|
*
|
||||||
|
* Returns the number of bytes written
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
xmlXzfileRead (void * context, char * buffer, int len) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = __libxml2_xzread((xzFile) context, &buffer[0], len);
|
||||||
|
if (ret < 0) xmlIOErr(0, "xzread()");
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlXzfileClose:
|
||||||
|
* @context: the I/O context
|
||||||
|
*
|
||||||
|
* Close a compressed I/O channel
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
xmlXzfileClose (void * context) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = (__libxml2_xzclose((xzFile) context) == LZMA_OK ) ? 0 : -1;
|
||||||
|
if (ret < 0) xmlIOErr(0, "xzclose()");
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
#endif /* HAVE_LZMA_H */
|
||||||
|
|
||||||
#ifdef LIBXML_HTTP_ENABLED
|
#ifdef LIBXML_HTTP_ENABLED
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
|
@ -1915,8 +2048,8 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) {
|
||||||
/* Pull the data out of the memory output buffer */
|
/* Pull the data out of the memory output buffer */
|
||||||
|
|
||||||
xmlOutputBufferPtr dctxt = ctxt->doc_buff;
|
xmlOutputBufferPtr dctxt = ctxt->doc_buff;
|
||||||
http_content = (char *)dctxt->buffer->content;
|
http_content = (char *) xmlBufContent(dctxt->buffer);
|
||||||
content_lgth = dctxt->buffer->use;
|
content_lgth = xmlBufUse(dctxt->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( http_content == NULL ) {
|
if ( http_content == NULL ) {
|
||||||
|
@ -2182,6 +2315,10 @@ xmlRegisterDefaultInputCallbacks(void) {
|
||||||
xmlRegisterInputCallbacks(xmlGzfileMatch, xmlGzfileOpen,
|
xmlRegisterInputCallbacks(xmlGzfileMatch, xmlGzfileOpen,
|
||||||
xmlGzfileRead, xmlGzfileClose);
|
xmlGzfileRead, xmlGzfileClose);
|
||||||
#endif /* HAVE_ZLIB_H */
|
#endif /* HAVE_ZLIB_H */
|
||||||
|
#ifdef HAVE_LZMA_H
|
||||||
|
xmlRegisterInputCallbacks(xmlXzfileMatch, xmlXzfileOpen,
|
||||||
|
xmlXzfileRead, xmlXzfileClose);
|
||||||
|
#endif /* HAVE_ZLIB_H */
|
||||||
|
|
||||||
#ifdef LIBXML_HTTP_ENABLED
|
#ifdef LIBXML_HTTP_ENABLED
|
||||||
xmlRegisterInputCallbacks(xmlIOHTTPMatch, xmlIOHTTPOpen,
|
xmlRegisterInputCallbacks(xmlIOHTTPMatch, xmlIOHTTPOpen,
|
||||||
|
@ -2279,15 +2416,15 @@ xmlAllocParserInputBuffer(xmlCharEncoding enc) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, (size_t) sizeof(xmlParserInputBuffer));
|
memset(ret, 0, (size_t) sizeof(xmlParserInputBuffer));
|
||||||
ret->buffer = xmlBufferCreateSize(2 * xmlDefaultBufferSize);
|
ret->buffer = xmlBufCreateSize(2 * xmlDefaultBufferSize);
|
||||||
if (ret->buffer == NULL) {
|
if (ret->buffer == NULL) {
|
||||||
xmlFree(ret);
|
xmlFree(ret);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
ret->buffer->alloc = XML_BUFFER_ALLOC_DOUBLEIT;
|
xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_DOUBLEIT);
|
||||||
ret->encoder = xmlGetCharEncodingHandler(enc);
|
ret->encoder = xmlGetCharEncodingHandler(enc);
|
||||||
if (ret->encoder != NULL)
|
if (ret->encoder != NULL)
|
||||||
ret->raw = xmlBufferCreateSize(2 * xmlDefaultBufferSize);
|
ret->raw = xmlBufCreateSize(2 * xmlDefaultBufferSize);
|
||||||
else
|
else
|
||||||
ret->raw = NULL;
|
ret->raw = NULL;
|
||||||
ret->readcallback = NULL;
|
ret->readcallback = NULL;
|
||||||
|
@ -2318,19 +2455,19 @@ xmlAllocOutputBuffer(xmlCharEncodingHandlerPtr encoder) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, (size_t) sizeof(xmlOutputBuffer));
|
memset(ret, 0, (size_t) sizeof(xmlOutputBuffer));
|
||||||
ret->buffer = xmlBufferCreate();
|
ret->buffer = xmlBufCreate();
|
||||||
if (ret->buffer == NULL) {
|
if (ret->buffer == NULL) {
|
||||||
xmlFree(ret);
|
xmlFree(ret);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* try to avoid a performance problem with Windows realloc() */
|
/* try to avoid a performance problem with Windows realloc() */
|
||||||
if (ret->buffer->alloc == XML_BUFFER_ALLOC_EXACT)
|
if (xmlBufGetAllocationScheme(ret->buffer) == XML_BUFFER_ALLOC_EXACT)
|
||||||
ret->buffer->alloc = XML_BUFFER_ALLOC_DOUBLEIT;
|
xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_DOUBLEIT);
|
||||||
|
|
||||||
ret->encoder = encoder;
|
ret->encoder = encoder;
|
||||||
if (encoder != NULL) {
|
if (encoder != NULL) {
|
||||||
ret->conv = xmlBufferCreateSize(4000);
|
ret->conv = xmlBufCreateSize(4000);
|
||||||
if (ret->conv == NULL) {
|
if (ret->conv == NULL) {
|
||||||
xmlFree(ret);
|
xmlFree(ret);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
@ -2339,7 +2476,7 @@ xmlAllocOutputBuffer(xmlCharEncodingHandlerPtr encoder) {
|
||||||
/*
|
/*
|
||||||
* This call is designed to initiate the encoder state
|
* This call is designed to initiate the encoder state
|
||||||
*/
|
*/
|
||||||
xmlCharEncOutFunc(encoder, ret->conv, NULL);
|
xmlCharEncOutput(ret, 1);
|
||||||
} else
|
} else
|
||||||
ret->conv = NULL;
|
ret->conv = NULL;
|
||||||
ret->writecallback = NULL;
|
ret->writecallback = NULL;
|
||||||
|
@ -2368,7 +2505,7 @@ xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, (size_t) sizeof(xmlOutputBuffer));
|
memset(ret, 0, (size_t) sizeof(xmlOutputBuffer));
|
||||||
ret->buffer = xmlBufferCreate();
|
ret->buffer = xmlBufCreate();
|
||||||
if (ret->buffer == NULL) {
|
if (ret->buffer == NULL) {
|
||||||
xmlFree(ret);
|
xmlFree(ret);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
@ -2377,15 +2514,12 @@ xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For conversion buffers we use the special IO handling
|
* For conversion buffers we use the special IO handling
|
||||||
* We don't do that from the exported API to avoid confusing
|
|
||||||
* user's code.
|
|
||||||
*/
|
*/
|
||||||
ret->buffer->alloc = XML_BUFFER_ALLOC_IO;
|
xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_IO);
|
||||||
ret->buffer->contentIO = ret->buffer->content;
|
|
||||||
|
|
||||||
ret->encoder = encoder;
|
ret->encoder = encoder;
|
||||||
if (encoder != NULL) {
|
if (encoder != NULL) {
|
||||||
ret->conv = xmlBufferCreateSize(4000);
|
ret->conv = xmlBufCreateSize(4000);
|
||||||
if (ret->conv == NULL) {
|
if (ret->conv == NULL) {
|
||||||
xmlFree(ret);
|
xmlFree(ret);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
@ -2394,7 +2528,7 @@ xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder) {
|
||||||
/*
|
/*
|
||||||
* This call is designed to initiate the encoder state
|
* This call is designed to initiate the encoder state
|
||||||
*/
|
*/
|
||||||
xmlCharEncOutFunc(encoder, ret->conv, NULL);
|
xmlCharEncOutput(ret, 1);
|
||||||
} else
|
} else
|
||||||
ret->conv = NULL;
|
ret->conv = NULL;
|
||||||
ret->writecallback = NULL;
|
ret->writecallback = NULL;
|
||||||
|
@ -2418,7 +2552,7 @@ xmlFreeParserInputBuffer(xmlParserInputBufferPtr in) {
|
||||||
if (in == NULL) return;
|
if (in == NULL) return;
|
||||||
|
|
||||||
if (in->raw) {
|
if (in->raw) {
|
||||||
xmlBufferFree(in->raw);
|
xmlBufFree(in->raw);
|
||||||
in->raw = NULL;
|
in->raw = NULL;
|
||||||
}
|
}
|
||||||
if (in->encoder != NULL) {
|
if (in->encoder != NULL) {
|
||||||
|
@ -2428,7 +2562,7 @@ xmlFreeParserInputBuffer(xmlParserInputBufferPtr in) {
|
||||||
in->closecallback(in->context);
|
in->closecallback(in->context);
|
||||||
}
|
}
|
||||||
if (in->buffer != NULL) {
|
if (in->buffer != NULL) {
|
||||||
xmlBufferFree(in->buffer);
|
xmlBufFree(in->buffer);
|
||||||
in->buffer = NULL;
|
in->buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2460,14 +2594,14 @@ xmlOutputBufferClose(xmlOutputBufferPtr out)
|
||||||
}
|
}
|
||||||
written = out->written;
|
written = out->written;
|
||||||
if (out->conv) {
|
if (out->conv) {
|
||||||
xmlBufferFree(out->conv);
|
xmlBufFree(out->conv);
|
||||||
out->conv = NULL;
|
out->conv = NULL;
|
||||||
}
|
}
|
||||||
if (out->encoder != NULL) {
|
if (out->encoder != NULL) {
|
||||||
xmlCharEncCloseFunc(out->encoder);
|
xmlCharEncCloseFunc(out->encoder);
|
||||||
}
|
}
|
||||||
if (out->buffer != NULL) {
|
if (out->buffer != NULL) {
|
||||||
xmlBufferFree(out->buffer);
|
xmlBufFree(out->buffer);
|
||||||
out->buffer = NULL;
|
out->buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2797,6 +2931,39 @@ xmlOutputBufferCreateBuffer(xmlBufferPtr buffer,
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlOutputBufferGetContent:
|
||||||
|
* @out: an xmlOutputBufferPtr
|
||||||
|
*
|
||||||
|
* Gives a pointer to the data currently held in the output buffer
|
||||||
|
*
|
||||||
|
* Returns a pointer to the data or NULL in case of error
|
||||||
|
*/
|
||||||
|
const xmlChar *
|
||||||
|
xmlOutputBufferGetContent(xmlOutputBufferPtr out) {
|
||||||
|
if ((out == NULL) || (out->buffer == NULL))
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
|
return(xmlBufContent(out->buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlOutputBufferGetSize:
|
||||||
|
* @out: an xmlOutputBufferPtr
|
||||||
|
*
|
||||||
|
* Gives the length of the data currently held in the output buffer
|
||||||
|
*
|
||||||
|
* Returns 0 in case or error or no data is held, the size otherwise
|
||||||
|
*/
|
||||||
|
size_t
|
||||||
|
xmlOutputBufferGetSize(xmlOutputBufferPtr out) {
|
||||||
|
if ((out == NULL) || (out->buffer == NULL))
|
||||||
|
return(0);
|
||||||
|
|
||||||
|
return(xmlBufUse(out->buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2849,7 +3016,7 @@ xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc) {
|
||||||
ret->context = (void *) mem;
|
ret->context = (void *) mem;
|
||||||
ret->readcallback = (xmlInputReadCallback) xmlNop;
|
ret->readcallback = (xmlInputReadCallback) xmlNop;
|
||||||
ret->closecallback = NULL;
|
ret->closecallback = NULL;
|
||||||
errcode = xmlBufferAdd(ret->buffer, (const xmlChar *) mem, size);
|
errcode = xmlBufAdd(ret->buffer, (const xmlChar *) mem, size);
|
||||||
if (errcode != 0) {
|
if (errcode != 0) {
|
||||||
xmlFree(ret);
|
xmlFree(ret);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
@ -2886,14 +3053,14 @@ xmlParserInputBufferCreateStatic(const char *mem, int size,
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, (size_t) sizeof(xmlParserInputBuffer));
|
memset(ret, 0, (size_t) sizeof(xmlParserInputBuffer));
|
||||||
ret->buffer = xmlBufferCreateStatic((void *)mem, (size_t) size);
|
ret->buffer = xmlBufCreateStatic((void *)mem, (size_t) size);
|
||||||
if (ret->buffer == NULL) {
|
if (ret->buffer == NULL) {
|
||||||
xmlFree(ret);
|
xmlFree(ret);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
ret->encoder = xmlGetCharEncodingHandler(enc);
|
ret->encoder = xmlGetCharEncodingHandler(enc);
|
||||||
if (ret->encoder != NULL)
|
if (ret->encoder != NULL)
|
||||||
ret->raw = xmlBufferCreateSize(2 * xmlDefaultBufferSize);
|
ret->raw = xmlBufCreateSize(2 * xmlDefaultBufferSize);
|
||||||
else
|
else
|
||||||
ret->raw = NULL;
|
ret->raw = NULL;
|
||||||
ret->compressed = -1;
|
ret->compressed = -1;
|
||||||
|
@ -3062,33 +3229,33 @@ xmlParserInputBufferPush(xmlParserInputBufferPtr in,
|
||||||
* Store the data in the incoming raw buffer
|
* Store the data in the incoming raw buffer
|
||||||
*/
|
*/
|
||||||
if (in->raw == NULL) {
|
if (in->raw == NULL) {
|
||||||
in->raw = xmlBufferCreate();
|
in->raw = xmlBufCreate();
|
||||||
}
|
}
|
||||||
ret = xmlBufferAdd(in->raw, (const xmlChar *) buf, len);
|
ret = xmlBufAdd(in->raw, (const xmlChar *) buf, len);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* convert as much as possible to the parser reading buffer.
|
* convert as much as possible to the parser reading buffer.
|
||||||
*/
|
*/
|
||||||
use = in->raw->use;
|
use = xmlBufUse(in->raw);
|
||||||
nbchars = xmlCharEncInFunc(in->encoder, in->buffer, in->raw);
|
nbchars = xmlCharEncInput(in);
|
||||||
if (nbchars < 0) {
|
if (nbchars < 0) {
|
||||||
xmlIOErr(XML_IO_ENCODER, NULL);
|
xmlIOErr(XML_IO_ENCODER, NULL);
|
||||||
in->error = XML_IO_ENCODER;
|
in->error = XML_IO_ENCODER;
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
in->rawconsumed += (use - in->raw->use);
|
in->rawconsumed += (use - xmlBufUse(in->raw));
|
||||||
} else {
|
} else {
|
||||||
nbchars = len;
|
nbchars = len;
|
||||||
ret = xmlBufferAdd(in->buffer, (xmlChar *) buf, nbchars);
|
ret = xmlBufAdd(in->buffer, (xmlChar *) buf, nbchars);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_INPUT
|
#ifdef DEBUG_INPUT
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"I/O: pushed %d chars, buffer %d/%d\n",
|
"I/O: pushed %d chars, buffer %d/%d\n",
|
||||||
nbchars, in->buffer->use, in->buffer->size);
|
nbchars, xmlBufUse(in->buffer), xmlBufLength(in->buffer));
|
||||||
#endif
|
#endif
|
||||||
return(nbchars);
|
return(nbchars);
|
||||||
}
|
}
|
||||||
|
@ -3126,29 +3293,23 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
||||||
char *buffer = NULL;
|
char *buffer = NULL;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
int nbchars = 0;
|
int nbchars = 0;
|
||||||
int buffree;
|
|
||||||
unsigned int needSize;
|
|
||||||
|
|
||||||
if ((in == NULL) || (in->error)) return(-1);
|
if ((in == NULL) || (in->error)) return(-1);
|
||||||
if ((len <= MINLEN) && (len != 4))
|
if ((len <= MINLEN) && (len != 4))
|
||||||
len = MINLEN;
|
len = MINLEN;
|
||||||
|
|
||||||
buffree = in->buffer->size - in->buffer->use;
|
if (xmlBufAvail(in->buffer) <= 0) {
|
||||||
if (buffree <= 0) {
|
|
||||||
xmlIOErr(XML_IO_BUFFER_FULL, NULL);
|
xmlIOErr(XML_IO_BUFFER_FULL, NULL);
|
||||||
in->error = XML_IO_BUFFER_FULL;
|
in->error = XML_IO_BUFFER_FULL;
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
needSize = in->buffer->use + len + 1;
|
if (xmlBufGrow(in->buffer, len + 1) < 0) {
|
||||||
if (needSize > in->buffer->size){
|
xmlIOErrMemory("growing input buffer");
|
||||||
if (!xmlBufferResize(in->buffer, needSize)){
|
in->error = XML_ERR_NO_MEMORY;
|
||||||
xmlIOErrMemory("growing input buffer");
|
return(-1);
|
||||||
in->error = XML_ERR_NO_MEMORY;
|
|
||||||
return(-1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
buffer = (char *)&in->buffer->content[in->buffer->use];
|
buffer = (char *)xmlBufEnd(in->buffer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call the read method for this I/O type.
|
* Call the read method for this I/O type.
|
||||||
|
@ -3173,32 +3334,31 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
||||||
* Store the data in the incoming raw buffer
|
* Store the data in the incoming raw buffer
|
||||||
*/
|
*/
|
||||||
if (in->raw == NULL) {
|
if (in->raw == NULL) {
|
||||||
in->raw = xmlBufferCreate();
|
in->raw = xmlBufCreate();
|
||||||
}
|
}
|
||||||
res = xmlBufferAdd(in->raw, (const xmlChar *) buffer, len);
|
res = xmlBufAdd(in->raw, (const xmlChar *) buffer, len);
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* convert as much as possible to the parser reading buffer.
|
* convert as much as possible to the parser reading buffer.
|
||||||
*/
|
*/
|
||||||
use = in->raw->use;
|
use = xmlBufUse(in->raw);
|
||||||
nbchars = xmlCharEncInFunc(in->encoder, in->buffer, in->raw);
|
nbchars = xmlCharEncInput(in);
|
||||||
if (nbchars < 0) {
|
if (nbchars < 0) {
|
||||||
xmlIOErr(XML_IO_ENCODER, NULL);
|
xmlIOErr(XML_IO_ENCODER, NULL);
|
||||||
in->error = XML_IO_ENCODER;
|
in->error = XML_IO_ENCODER;
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
in->rawconsumed += (use - in->raw->use);
|
in->rawconsumed += (use - xmlBufUse(in->raw));
|
||||||
} else {
|
} else {
|
||||||
nbchars = len;
|
nbchars = len;
|
||||||
in->buffer->use += nbchars;
|
xmlBufAddLen(in->buffer, nbchars);
|
||||||
buffer[nbchars] = 0;
|
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_INPUT
|
#ifdef DEBUG_INPUT
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"I/O: read %d chars, buffer %d/%d\n",
|
"I/O: read %d chars, buffer %d\n",
|
||||||
nbchars, in->buffer->use, in->buffer->size);
|
nbchars, xmlBufUse(in->buffer));
|
||||||
#endif
|
#endif
|
||||||
return(nbchars);
|
return(nbchars);
|
||||||
}
|
}
|
||||||
|
@ -3220,8 +3380,7 @@ xmlParserInputBufferRead(xmlParserInputBufferPtr in, int len) {
|
||||||
if ((in == NULL) || (in->error)) return(-1);
|
if ((in == NULL) || (in->error)) return(-1);
|
||||||
if (in->readcallback != NULL)
|
if (in->readcallback != NULL)
|
||||||
return(xmlParserInputBufferGrow(in, len));
|
return(xmlParserInputBufferGrow(in, len));
|
||||||
else if ((in->buffer != NULL) &&
|
else if (xmlBufGetAllocationScheme(in->buffer) == XML_BUFFER_ALLOC_IMMUTABLE)
|
||||||
(in->buffer->alloc == XML_BUFFER_ALLOC_IMMUTABLE))
|
|
||||||
return(0);
|
return(0);
|
||||||
else
|
else
|
||||||
return(-1);
|
return(-1);
|
||||||
|
@ -3266,30 +3425,30 @@ xmlOutputBufferWrite(xmlOutputBufferPtr out, int len, const char *buf) {
|
||||||
* Store the data in the incoming raw buffer
|
* Store the data in the incoming raw buffer
|
||||||
*/
|
*/
|
||||||
if (out->conv == NULL) {
|
if (out->conv == NULL) {
|
||||||
out->conv = xmlBufferCreate();
|
out->conv = xmlBufCreate();
|
||||||
}
|
}
|
||||||
ret = xmlBufferAdd(out->buffer, (const xmlChar *) buf, chunk);
|
ret = xmlBufAdd(out->buffer, (const xmlChar *) buf, chunk);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
if ((out->buffer->use < MINLEN) && (chunk == len))
|
if ((xmlBufUse(out->buffer) < MINLEN) && (chunk == len))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* convert as much as possible to the parser reading buffer.
|
* convert as much as possible to the parser reading buffer.
|
||||||
*/
|
*/
|
||||||
ret = xmlCharEncOutFunc(out->encoder, out->conv, out->buffer);
|
ret = xmlCharEncOutput(out, 0);
|
||||||
if ((ret < 0) && (ret != -3)) {
|
if ((ret < 0) && (ret != -3)) {
|
||||||
xmlIOErr(XML_IO_ENCODER, NULL);
|
xmlIOErr(XML_IO_ENCODER, NULL);
|
||||||
out->error = XML_IO_ENCODER;
|
out->error = XML_IO_ENCODER;
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
nbchars = out->conv->use;
|
nbchars = xmlBufUse(out->conv);
|
||||||
} else {
|
} else {
|
||||||
ret = xmlBufferAdd(out->buffer, (const xmlChar *) buf, chunk);
|
ret = xmlBufAdd(out->buffer, (const xmlChar *) buf, chunk);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return(-1);
|
return(-1);
|
||||||
nbchars = out->buffer->use;
|
nbchars = xmlBufUse(out->buffer);
|
||||||
}
|
}
|
||||||
buf += chunk;
|
buf += chunk;
|
||||||
len -= chunk;
|
len -= chunk;
|
||||||
|
@ -3303,14 +3462,14 @@ xmlOutputBufferWrite(xmlOutputBufferPtr out, int len, const char *buf) {
|
||||||
*/
|
*/
|
||||||
if (out->encoder != NULL) {
|
if (out->encoder != NULL) {
|
||||||
ret = out->writecallback(out->context,
|
ret = out->writecallback(out->context,
|
||||||
(const char *)out->conv->content, nbchars);
|
(const char *)xmlBufContent(out->conv), nbchars);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
xmlBufferShrink(out->conv, ret);
|
xmlBufShrink(out->conv, ret);
|
||||||
} else {
|
} else {
|
||||||
ret = out->writecallback(out->context,
|
ret = out->writecallback(out->context,
|
||||||
(const char *)out->buffer->content, nbchars);
|
(const char *)xmlBufContent(out->buffer), nbchars);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
xmlBufferShrink(out->buffer, ret);
|
xmlBufShrink(out->buffer, ret);
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
xmlIOErr(XML_IO_WRITE, NULL);
|
xmlIOErr(XML_IO_WRITE, NULL);
|
||||||
|
@ -3418,7 +3577,8 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
|
||||||
|
|
||||||
if ((out == NULL) || (out->error) || (str == NULL) ||
|
if ((out == NULL) || (out->error) || (str == NULL) ||
|
||||||
(out->buffer == NULL) ||
|
(out->buffer == NULL) ||
|
||||||
(out->buffer->alloc == XML_BUFFER_ALLOC_IMMUTABLE)) return(-1);
|
(xmlBufGetAllocationScheme(out->buffer) == XML_BUFFER_ALLOC_IMMUTABLE))
|
||||||
|
return(-1);
|
||||||
len = strlen((const char *)str);
|
len = strlen((const char *)str);
|
||||||
if (len < 0) return(0);
|
if (len < 0) return(0);
|
||||||
if (out->error) return(-1);
|
if (out->error) return(-1);
|
||||||
|
@ -3431,14 +3591,14 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
|
||||||
* how many bytes to consume and how many bytes to store.
|
* how many bytes to consume and how many bytes to store.
|
||||||
*/
|
*/
|
||||||
cons = len;
|
cons = len;
|
||||||
chunk = (out->buffer->size - out->buffer->use) - 1;
|
chunk = xmlBufAvail(out->buffer) - 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* make sure we have enough room to save first, if this is
|
* make sure we have enough room to save first, if this is
|
||||||
* not the case force a flush, but make sure we stay in the loop
|
* not the case force a flush, but make sure we stay in the loop
|
||||||
*/
|
*/
|
||||||
if (chunk < 40) {
|
if (chunk < 40) {
|
||||||
if (xmlBufferGrow(out->buffer, out->buffer->size + 100) < 0)
|
if (xmlBufGrow(out->buffer, 100) < 0)
|
||||||
return(-1);
|
return(-1);
|
||||||
oldwritten = -1;
|
oldwritten = -1;
|
||||||
continue;
|
continue;
|
||||||
|
@ -3452,36 +3612,33 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
|
||||||
* Store the data in the incoming raw buffer
|
* Store the data in the incoming raw buffer
|
||||||
*/
|
*/
|
||||||
if (out->conv == NULL) {
|
if (out->conv == NULL) {
|
||||||
out->conv = xmlBufferCreate();
|
out->conv = xmlBufCreate();
|
||||||
}
|
}
|
||||||
ret = escaping(out->buffer->content + out->buffer->use ,
|
ret = escaping(xmlBufEnd(out->buffer) ,
|
||||||
&chunk, str, &cons);
|
&chunk, str, &cons);
|
||||||
if ((ret < 0) || (chunk == 0)) /* chunk==0 => nothing done */
|
if ((ret < 0) || (chunk == 0)) /* chunk==0 => nothing done */
|
||||||
return(-1);
|
return(-1);
|
||||||
out->buffer->use += chunk;
|
xmlBufAddLen(out->buffer, chunk);
|
||||||
out->buffer->content[out->buffer->use] = 0;
|
|
||||||
|
|
||||||
if ((out->buffer->use < MINLEN) && (cons == len))
|
if ((xmlBufUse(out->buffer) < MINLEN) && (cons == len))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* convert as much as possible to the output buffer.
|
* convert as much as possible to the output buffer.
|
||||||
*/
|
*/
|
||||||
ret = xmlCharEncOutFunc(out->encoder, out->conv, out->buffer);
|
ret = xmlCharEncOutput(out, 0);
|
||||||
if ((ret < 0) && (ret != -3)) {
|
if ((ret < 0) && (ret != -3)) {
|
||||||
xmlIOErr(XML_IO_ENCODER, NULL);
|
xmlIOErr(XML_IO_ENCODER, NULL);
|
||||||
out->error = XML_IO_ENCODER;
|
out->error = XML_IO_ENCODER;
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
nbchars = out->conv->use;
|
nbchars = xmlBufUse(out->conv);
|
||||||
} else {
|
} else {
|
||||||
ret = escaping(out->buffer->content + out->buffer->use ,
|
ret = escaping(xmlBufEnd(out->buffer), &chunk, str, &cons);
|
||||||
&chunk, str, &cons);
|
|
||||||
if ((ret < 0) || (chunk == 0)) /* chunk==0 => nothing done */
|
if ((ret < 0) || (chunk == 0)) /* chunk==0 => nothing done */
|
||||||
return(-1);
|
return(-1);
|
||||||
out->buffer->use += chunk;
|
xmlBufAddLen(out->buffer, chunk);
|
||||||
out->buffer->content[out->buffer->use] = 0;
|
nbchars = xmlBufUse(out->buffer);
|
||||||
nbchars = out->buffer->use;
|
|
||||||
}
|
}
|
||||||
str += cons;
|
str += cons;
|
||||||
len -= cons;
|
len -= cons;
|
||||||
|
@ -3495,14 +3652,14 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
|
||||||
*/
|
*/
|
||||||
if (out->encoder != NULL) {
|
if (out->encoder != NULL) {
|
||||||
ret = out->writecallback(out->context,
|
ret = out->writecallback(out->context,
|
||||||
(const char *)out->conv->content, nbchars);
|
(const char *)xmlBufContent(out->conv), nbchars);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
xmlBufferShrink(out->conv, ret);
|
xmlBufShrink(out->conv, ret);
|
||||||
} else {
|
} else {
|
||||||
ret = out->writecallback(out->context,
|
ret = out->writecallback(out->context,
|
||||||
(const char *)out->buffer->content, nbchars);
|
(const char *)xmlBufContent(out->buffer), nbchars);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
xmlBufferShrink(out->buffer, ret);
|
xmlBufShrink(out->buffer, ret);
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
xmlIOErr(XML_IO_WRITE, NULL);
|
xmlIOErr(XML_IO_WRITE, NULL);
|
||||||
|
@ -3510,8 +3667,8 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
out->written += ret;
|
out->written += ret;
|
||||||
} else if (out->buffer->size - out->buffer->use < MINLEN) {
|
} else if (xmlBufAvail(out->buffer) < MINLEN) {
|
||||||
xmlBufferResize(out->buffer, out->buffer->size + MINLEN);
|
xmlBufGrow(out->buffer, MINLEN);
|
||||||
}
|
}
|
||||||
written += nbchars;
|
written += nbchars;
|
||||||
} while ((len > 0) && (oldwritten != written));
|
} while ((len > 0) && (oldwritten != written));
|
||||||
|
@ -3571,7 +3728,7 @@ xmlOutputBufferFlush(xmlOutputBufferPtr out) {
|
||||||
/*
|
/*
|
||||||
* convert as much as possible to the parser reading buffer.
|
* convert as much as possible to the parser reading buffer.
|
||||||
*/
|
*/
|
||||||
nbchars = xmlCharEncOutFunc(out->encoder, out->conv, out->buffer);
|
nbchars = xmlCharEncOutput(out, 0);
|
||||||
if (nbchars < 0) {
|
if (nbchars < 0) {
|
||||||
xmlIOErr(XML_IO_ENCODER, NULL);
|
xmlIOErr(XML_IO_ENCODER, NULL);
|
||||||
out->error = XML_IO_ENCODER;
|
out->error = XML_IO_ENCODER;
|
||||||
|
@ -3585,14 +3742,16 @@ xmlOutputBufferFlush(xmlOutputBufferPtr out) {
|
||||||
if ((out->conv != NULL) && (out->encoder != NULL) &&
|
if ((out->conv != NULL) && (out->encoder != NULL) &&
|
||||||
(out->writecallback != NULL)) {
|
(out->writecallback != NULL)) {
|
||||||
ret = out->writecallback(out->context,
|
ret = out->writecallback(out->context,
|
||||||
(const char *)out->conv->content, out->conv->use);
|
(const char *)xmlBufContent(out->conv),
|
||||||
|
xmlBufUse(out->conv));
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
xmlBufferShrink(out->conv, ret);
|
xmlBufShrink(out->conv, ret);
|
||||||
} else if (out->writecallback != NULL) {
|
} else if (out->writecallback != NULL) {
|
||||||
ret = out->writecallback(out->context,
|
ret = out->writecallback(out->context,
|
||||||
(const char *)out->buffer->content, out->buffer->use);
|
(const char *)xmlBufContent(out->buffer),
|
||||||
|
xmlBufUse(out->buffer));
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
xmlBufferShrink(out->buffer, ret);
|
xmlBufShrink(out->buffer, ret);
|
||||||
}
|
}
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
xmlIOErr(XML_IO_FLUSH, NULL);
|
xmlIOErr(XML_IO_FLUSH, NULL);
|
||||||
|
|
58
reactos/lib/3rdparty/libxml2/xmllint.c
vendored
58
reactos/lib/3rdparty/libxml2/xmllint.c
vendored
|
@ -130,6 +130,7 @@ static int copy = 0;
|
||||||
#endif /* LIBXML_TREE_ENABLED */
|
#endif /* LIBXML_TREE_ENABLED */
|
||||||
static int recovery = 0;
|
static int recovery = 0;
|
||||||
static int noent = 0;
|
static int noent = 0;
|
||||||
|
static int noenc = 0;
|
||||||
static int noblanks = 0;
|
static int noblanks = 0;
|
||||||
static int noout = 0;
|
static int noout = 0;
|
||||||
static int nowrap = 0;
|
static int nowrap = 0;
|
||||||
|
@ -168,7 +169,7 @@ static int nodefdtd = 0;
|
||||||
#ifdef LIBXML_PUSH_ENABLED
|
#ifdef LIBXML_PUSH_ENABLED
|
||||||
static int push = 0;
|
static int push = 0;
|
||||||
#endif /* LIBXML_PUSH_ENABLED */
|
#endif /* LIBXML_PUSH_ENABLED */
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
static int memory = 0;
|
static int memory = 0;
|
||||||
#endif
|
#endif
|
||||||
static int testIO = 0;
|
static int testIO = 0;
|
||||||
|
@ -208,7 +209,7 @@ static xmlStreamCtxtPtr patstream = NULL;
|
||||||
#ifdef LIBXML_XPATH_ENABLED
|
#ifdef LIBXML_XPATH_ENABLED
|
||||||
static const char *xpathquery = NULL;
|
static const char *xpathquery = NULL;
|
||||||
#endif
|
#endif
|
||||||
static int options = XML_PARSE_COMPACT;
|
static int options = XML_PARSE_COMPACT | XML_PARSE_BIG_LINES;
|
||||||
static int sax = 0;
|
static int sax = 0;
|
||||||
static int oldxml10 = 0;
|
static int oldxml10 = 0;
|
||||||
|
|
||||||
|
@ -519,10 +520,11 @@ endTimer(char *format, ...)
|
||||||
* We cannot do anything because we don't have a timing function
|
* We cannot do anything because we don't have a timing function
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_STDARG_H
|
#ifdef HAVE_STDARG_H
|
||||||
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
vfprintf(stderr, format, ap);
|
vfprintf(stderr, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
fprintf(stderr, " was not timed\n", msec);
|
fprintf(stderr, " was not timed\n");
|
||||||
#else
|
#else
|
||||||
/* We don't have gettimeofday, time or stdarg.h, what crazy world is
|
/* We don't have gettimeofday, time or stdarg.h, what crazy world is
|
||||||
* this ?!
|
* this ?!
|
||||||
|
@ -1667,6 +1669,7 @@ testSAX(const char *filename) {
|
||||||
(xmlSchemaValidityErrorFunc) fprintf,
|
(xmlSchemaValidityErrorFunc) fprintf,
|
||||||
(xmlSchemaValidityWarningFunc) fprintf,
|
(xmlSchemaValidityWarningFunc) fprintf,
|
||||||
stderr);
|
stderr);
|
||||||
|
xmlSchemaValidateSetFilename(vctxt, filename);
|
||||||
|
|
||||||
ret = xmlSchemaValidateStream(vctxt, buf, 0, handler,
|
ret = xmlSchemaValidateStream(vctxt, buf, 0, handler,
|
||||||
(void *)user_data);
|
(void *)user_data);
|
||||||
|
@ -1821,7 +1824,7 @@ static void processNode(xmlTextReaderPtr reader) {
|
||||||
static void streamFile(char *filename) {
|
static void streamFile(char *filename) {
|
||||||
xmlTextReaderPtr reader;
|
xmlTextReaderPtr reader;
|
||||||
int ret;
|
int ret;
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
struct stat info;
|
struct stat info;
|
||||||
const char *base = NULL;
|
const char *base = NULL;
|
||||||
|
@ -1972,7 +1975,7 @@ static void streamFile(char *filename) {
|
||||||
patstream = NULL;
|
patstream = NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
if (memory) {
|
if (memory) {
|
||||||
xmlFreeParserInputBuffer(input);
|
xmlFreeParserInputBuffer(input);
|
||||||
munmap((char *) base, info.st_size);
|
munmap((char *) base, info.st_size);
|
||||||
|
@ -2072,7 +2075,7 @@ static void doXPathDump(xmlXPathObjectPtr cur) {
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
#ifdef LIBXML_OUTPUT_ENABLED
|
||||||
xmlSaveCtxtPtr ctxt;
|
xmlSaveCtxtPtr ctxt;
|
||||||
|
|
||||||
if (cur->nodesetval->nodeNr <= 0) {
|
if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr <= 0)) {
|
||||||
fprintf(stderr, "XPath set is empty\n");
|
fprintf(stderr, "XPath set is empty\n");
|
||||||
progresult = XMLLINT_ERR_XPATH;
|
progresult = XMLLINT_ERR_XPATH;
|
||||||
break;
|
break;
|
||||||
|
@ -2137,7 +2140,7 @@ static void doXPathQuery(xmlDocPtr doc, const char *query) {
|
||||||
progresult = XMLLINT_ERR_MEM;
|
progresult = XMLLINT_ERR_MEM;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ctxt->node = xmlDocGetRootElement(doc);
|
ctxt->node = (xmlNodePtr) doc;
|
||||||
res = xmlXPathEval(BAD_CAST query, ctxt);
|
res = xmlXPathEval(BAD_CAST query, ctxt);
|
||||||
xmlXPathFreeContext(ctxt);
|
xmlXPathFreeContext(ctxt);
|
||||||
|
|
||||||
|
@ -2210,7 +2213,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* LIBXML_PUSH_ENABLED */
|
#endif /* LIBXML_PUSH_ENABLED */
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
else if ((html) && (memory)) {
|
else if ((html) && (memory)) {
|
||||||
int fd;
|
int fd;
|
||||||
struct stat info;
|
struct stat info;
|
||||||
|
@ -2325,7 +2328,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
||||||
if (rectxt == NULL)
|
if (rectxt == NULL)
|
||||||
xmlFreeParserCtxt(ctxt);
|
xmlFreeParserCtxt(ctxt);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
} else if (memory) {
|
} else if (memory) {
|
||||||
int fd;
|
int fd;
|
||||||
struct stat info;
|
struct stat info;
|
||||||
|
@ -2550,7 +2553,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
||||||
|
|
||||||
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_0, NULL, 1, &result);
|
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_0, NULL, 1, &result);
|
||||||
if (size >= 0) {
|
if (size >= 0) {
|
||||||
write(1, result, size);
|
if (write(1, result, size) == -1) {
|
||||||
|
fprintf(stderr, "Can't write data\n");
|
||||||
|
}
|
||||||
xmlFree(result);
|
xmlFree(result);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Failed to canonicalize\n");
|
fprintf(stderr, "Failed to canonicalize\n");
|
||||||
|
@ -2562,7 +2567,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
||||||
|
|
||||||
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_1, NULL, 1, &result);
|
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_1_1, NULL, 1, &result);
|
||||||
if (size >= 0) {
|
if (size >= 0) {
|
||||||
write(1, result, size);
|
if (write(1, result, size) == -1) {
|
||||||
|
fprintf(stderr, "Can't write data\n");
|
||||||
|
}
|
||||||
xmlFree(result);
|
xmlFree(result);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Failed to canonicalize\n");
|
fprintf(stderr, "Failed to canonicalize\n");
|
||||||
|
@ -2575,7 +2582,9 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
||||||
|
|
||||||
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_EXCLUSIVE_1_0, NULL, 1, &result);
|
size = xmlC14NDocDumpMemory(doc, NULL, XML_C14N_EXCLUSIVE_1_0, NULL, 1, &result);
|
||||||
if (size >= 0) {
|
if (size >= 0) {
|
||||||
write(1, result, size);
|
if (write(1, result, size) == -1) {
|
||||||
|
fprintf(stderr, "Can't write data\n");
|
||||||
|
}
|
||||||
xmlFree(result);
|
xmlFree(result);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Failed to canonicalize\n");
|
fprintf(stderr, "Failed to canonicalize\n");
|
||||||
|
@ -2583,7 +2592,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
if (memory) {
|
if (memory) {
|
||||||
xmlChar *result;
|
xmlChar *result;
|
||||||
int len;
|
int len;
|
||||||
|
@ -2604,12 +2613,14 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
|
||||||
fprintf(stderr, "Failed to save\n");
|
fprintf(stderr, "Failed to save\n");
|
||||||
progresult = XMLLINT_ERR_OUT;
|
progresult = XMLLINT_ERR_OUT;
|
||||||
} else {
|
} else {
|
||||||
write(1, result, len);
|
if (write(1, result, len) == -1) {
|
||||||
|
fprintf(stderr, "Can't write data\n");
|
||||||
|
}
|
||||||
xmlFree(result);
|
xmlFree(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else
|
} else
|
||||||
#endif /* HAVE_SYS_MMAN_H */
|
#endif /* HAVE_MMAP */
|
||||||
if (compress) {
|
if (compress) {
|
||||||
xmlSaveFile(output ? output : "-", doc);
|
xmlSaveFile(output ? output : "-", doc);
|
||||||
} else if (oldout) {
|
} else if (oldout) {
|
||||||
|
@ -2949,6 +2960,7 @@ static void showVersion(const char *name) {
|
||||||
if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug ");
|
if (xmlHasFeature(XML_WITH_DEBUG_MEM)) fprintf(stderr, "MemDebug ");
|
||||||
if (xmlHasFeature(XML_WITH_DEBUG_RUN)) fprintf(stderr, "RunDebug ");
|
if (xmlHasFeature(XML_WITH_DEBUG_RUN)) fprintf(stderr, "RunDebug ");
|
||||||
if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib ");
|
if (xmlHasFeature(XML_WITH_ZLIB)) fprintf(stderr, "Zlib ");
|
||||||
|
if (xmlHasFeature(XML_WITH_LZMA)) fprintf(stderr, "Lzma ");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2975,6 +2987,7 @@ static void usage(const char *name) {
|
||||||
printf("\t--recover : output what was parsable on broken XML documents\n");
|
printf("\t--recover : output what was parsable on broken XML documents\n");
|
||||||
printf("\t--huge : remove any internal arbitrary parser limits\n");
|
printf("\t--huge : remove any internal arbitrary parser limits\n");
|
||||||
printf("\t--noent : substitute entity references by their value\n");
|
printf("\t--noent : substitute entity references by their value\n");
|
||||||
|
printf("\t--noenc : ignore any encoding specified inside the document\n");
|
||||||
printf("\t--noout : don't output the result tree\n");
|
printf("\t--noout : don't output the result tree\n");
|
||||||
printf("\t--path 'paths': provide a set of paths for resources\n");
|
printf("\t--path 'paths': provide a set of paths for resources\n");
|
||||||
printf("\t--load-trace : print trace of all external entites loaded\n");
|
printf("\t--load-trace : print trace of all external entites loaded\n");
|
||||||
|
@ -3005,7 +3018,7 @@ static void usage(const char *name) {
|
||||||
#ifdef LIBXML_PUSH_ENABLED
|
#ifdef LIBXML_PUSH_ENABLED
|
||||||
printf("\t--push : use the push mode of the parser\n");
|
printf("\t--push : use the push mode of the parser\n");
|
||||||
#endif /* LIBXML_PUSH_ENABLED */
|
#endif /* LIBXML_PUSH_ENABLED */
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
printf("\t--memory : parse from memory\n");
|
printf("\t--memory : parse from memory\n");
|
||||||
#endif
|
#endif
|
||||||
printf("\t--maxmem nbbytes : limits memory allocation to nbbytes bytes\n");
|
printf("\t--maxmem nbbytes : limits memory allocation to nbbytes bytes\n");
|
||||||
|
@ -3129,6 +3142,10 @@ main(int argc, char **argv) {
|
||||||
(!strcmp(argv[i], "--noent"))) {
|
(!strcmp(argv[i], "--noent"))) {
|
||||||
noent++;
|
noent++;
|
||||||
options |= XML_PARSE_NOENT;
|
options |= XML_PARSE_NOENT;
|
||||||
|
} else if ((!strcmp(argv[i], "-noenc")) ||
|
||||||
|
(!strcmp(argv[i], "--noenc"))) {
|
||||||
|
noenc++;
|
||||||
|
options |= XML_PARSE_IGNORE_ENC;
|
||||||
} else if ((!strcmp(argv[i], "-nsclean")) ||
|
} else if ((!strcmp(argv[i], "-nsclean")) ||
|
||||||
(!strcmp(argv[i], "--nsclean"))) {
|
(!strcmp(argv[i], "--nsclean"))) {
|
||||||
options |= XML_PARSE_NSCLEAN;
|
options |= XML_PARSE_NSCLEAN;
|
||||||
|
@ -3231,7 +3248,7 @@ main(int argc, char **argv) {
|
||||||
(!strcmp(argv[i], "--push")))
|
(!strcmp(argv[i], "--push")))
|
||||||
push++;
|
push++;
|
||||||
#endif /* LIBXML_PUSH_ENABLED */
|
#endif /* LIBXML_PUSH_ENABLED */
|
||||||
#ifdef HAVE_SYS_MMAN_H
|
#ifdef HAVE_MMAP
|
||||||
else if ((!strcmp(argv[i], "-memory")) ||
|
else if ((!strcmp(argv[i], "-memory")) ||
|
||||||
(!strcmp(argv[i], "--memory")))
|
(!strcmp(argv[i], "--memory")))
|
||||||
memory++;
|
memory++;
|
||||||
|
@ -3323,8 +3340,9 @@ main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
else if ((!strcmp(argv[i], "-noblanks")) ||
|
else if ((!strcmp(argv[i], "-noblanks")) ||
|
||||||
(!strcmp(argv[i], "--noblanks"))) {
|
(!strcmp(argv[i], "--noblanks"))) {
|
||||||
noblanks++;
|
noblanks++;
|
||||||
xmlKeepBlanksDefault(0);
|
xmlKeepBlanksDefault(0);
|
||||||
|
options |= XML_PARSE_NOBLANKS;
|
||||||
}
|
}
|
||||||
else if ((!strcmp(argv[i], "-maxmem")) ||
|
else if ((!strcmp(argv[i], "-maxmem")) ||
|
||||||
(!strcmp(argv[i], "--maxmem"))) {
|
(!strcmp(argv[i], "--maxmem"))) {
|
||||||
|
@ -3349,11 +3367,11 @@ main(int argc, char **argv) {
|
||||||
i++;
|
i++;
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
#ifdef LIBXML_OUTPUT_ENABLED
|
||||||
format = atoi(argv[i]);
|
format = atoi(argv[i]);
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
|
||||||
if (format == 1) {
|
if (format == 1) {
|
||||||
noblanks++;
|
noblanks++;
|
||||||
xmlKeepBlanksDefault(0);
|
xmlKeepBlanksDefault(0);
|
||||||
}
|
}
|
||||||
|
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||||
}
|
}
|
||||||
#ifdef LIBXML_READER_ENABLED
|
#ifdef LIBXML_READER_ENABLED
|
||||||
else if ((!strcmp(argv[i], "-stream")) ||
|
else if ((!strcmp(argv[i], "-stream")) ||
|
||||||
|
|
11
reactos/lib/3rdparty/libxml2/xmlmemory.c
vendored
11
reactos/lib/3rdparty/libxml2/xmlmemory.c
vendored
|
@ -205,7 +205,8 @@ xmlMallocLoc(size_t size, const char * file, int line)
|
||||||
|
|
||||||
if (xmlMemTraceBlockAt == ret) {
|
if (xmlMemTraceBlockAt == ret) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"%p : Malloc(%ld) Ok\n", xmlMemTraceBlockAt, size);
|
"%p : Malloc(%lu) Ok\n", xmlMemTraceBlockAt,
|
||||||
|
(long unsigned)size);
|
||||||
xmlMallocBreakpoint();
|
xmlMallocBreakpoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +274,8 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
|
||||||
|
|
||||||
if (xmlMemTraceBlockAt == ret) {
|
if (xmlMemTraceBlockAt == ret) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"%p : Malloc(%ld) Ok\n", xmlMemTraceBlockAt, size);
|
"%p : Malloc(%lu) Ok\n", xmlMemTraceBlockAt,
|
||||||
|
(long unsigned)size);
|
||||||
xmlMallocBreakpoint();
|
xmlMallocBreakpoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,8 +350,9 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
|
||||||
}
|
}
|
||||||
if (xmlMemTraceBlockAt == ptr) {
|
if (xmlMemTraceBlockAt == ptr) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"%p : Realloced(%ld -> %ld) Ok\n",
|
"%p : Realloced(%lu -> %lu) Ok\n",
|
||||||
xmlMemTraceBlockAt, p->mh_size, size);
|
xmlMemTraceBlockAt, (long unsigned)p->mh_size,
|
||||||
|
(long unsigned)size);
|
||||||
xmlMallocBreakpoint();
|
xmlMallocBreakpoint();
|
||||||
}
|
}
|
||||||
p->mh_tag = MEMTAG;
|
p->mh_tag = MEMTAG;
|
||||||
|
|
17
reactos/lib/3rdparty/libxml2/xmlmodule.c
vendored
17
reactos/lib/3rdparty/libxml2/xmlmodule.c
vendored
|
@ -61,6 +61,10 @@ xmlModuleErrMemory(xmlModulePtr module, const char *extra)
|
||||||
* @options: a set of xmlModuleOption
|
* @options: a set of xmlModuleOption
|
||||||
*
|
*
|
||||||
* Opens a module/shared library given its name or path
|
* Opens a module/shared library given its name or path
|
||||||
|
* NOTE: that due to portability issues, behaviour can only be
|
||||||
|
* guaranteed with @name using ASCII. We canot guarantee that
|
||||||
|
* an UTF-8 string would work, which is why name is a const char *
|
||||||
|
* and not a const xmlChar * .
|
||||||
* TODO: options are not yet implemented.
|
* TODO: options are not yet implemented.
|
||||||
*
|
*
|
||||||
* Returns a handle for the module or NULL in case of error
|
* Returns a handle for the module or NULL in case of error
|
||||||
|
@ -99,6 +103,10 @@ xmlModuleOpen(const char *name, int options ATTRIBUTE_UNUSED)
|
||||||
* @symbol: the resulting symbol address
|
* @symbol: the resulting symbol address
|
||||||
*
|
*
|
||||||
* Lookup for a symbol address in the given module
|
* Lookup for a symbol address in the given module
|
||||||
|
* NOTE: that due to portability issues, behaviour can only be
|
||||||
|
* guaranteed with @name using ASCII. We canot guarantee that
|
||||||
|
* an UTF-8 string would work, which is why name is a const char *
|
||||||
|
* and not a const xmlChar * .
|
||||||
*
|
*
|
||||||
* Returns 0 if the symbol was found, or -1 in case of error
|
* Returns 0 if the symbol was found, or -1 in case of error
|
||||||
*/
|
*/
|
||||||
|
@ -300,7 +308,7 @@ xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
|
||||||
static void *
|
static void *
|
||||||
xmlModulePlatformOpen(const char *name)
|
xmlModulePlatformOpen(const char *name)
|
||||||
{
|
{
|
||||||
return LoadLibrary(name);
|
return LoadLibraryA(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -326,7 +334,14 @@ xmlModulePlatformClose(void *handle)
|
||||||
static int
|
static int
|
||||||
xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
|
xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32_WCE
|
||||||
|
/*
|
||||||
|
* GetProcAddressA seems only available on WinCE
|
||||||
|
*/
|
||||||
|
*symbol = GetProcAddressA(handle, name);
|
||||||
|
#else
|
||||||
*symbol = GetProcAddress(handle, name);
|
*symbol = GetProcAddress(handle, name);
|
||||||
|
#endif
|
||||||
return (NULL == *symbol) ? -1 : 0;
|
return (NULL == *symbol) ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
354
reactos/lib/3rdparty/libxml2/xmlreader.c
vendored
354
reactos/lib/3rdparty/libxml2/xmlreader.c
vendored
|
@ -44,6 +44,8 @@
|
||||||
#include <libxml/pattern.h>
|
#include <libxml/pattern.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "buf.h"
|
||||||
|
|
||||||
#define MAX_ERR_MSG_SIZE 64000
|
#define MAX_ERR_MSG_SIZE 64000
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -135,7 +137,7 @@ struct _xmlTextReader {
|
||||||
int depth; /* depth of the current node */
|
int depth; /* depth of the current node */
|
||||||
xmlNodePtr faketext;/* fake xmlNs chld */
|
xmlNodePtr faketext;/* fake xmlNs chld */
|
||||||
int preserve;/* preserve the resulting document */
|
int preserve;/* preserve the resulting document */
|
||||||
xmlBufferPtr buffer; /* used to return const xmlChar * */
|
xmlBufPtr buffer; /* used to return const xmlChar * */
|
||||||
xmlDictPtr dict; /* the context dictionnary */
|
xmlDictPtr dict; /* the context dictionnary */
|
||||||
|
|
||||||
/* entity stack when traversing entities content */
|
/* entity stack when traversing entities content */
|
||||||
|
@ -152,6 +154,7 @@ struct _xmlTextReader {
|
||||||
/* Handling of RelaxNG validation */
|
/* Handling of RelaxNG validation */
|
||||||
xmlRelaxNGPtr rngSchemas; /* The Relax NG schemas */
|
xmlRelaxNGPtr rngSchemas; /* The Relax NG schemas */
|
||||||
xmlRelaxNGValidCtxtPtr rngValidCtxt;/* The Relax NG validation context */
|
xmlRelaxNGValidCtxtPtr rngValidCtxt;/* The Relax NG validation context */
|
||||||
|
int rngPreserveCtxt; /* 1 if the context was provided by the user */
|
||||||
int rngValidErrors;/* The number of errors detected */
|
int rngValidErrors;/* The number of errors detected */
|
||||||
xmlNodePtr rngFullNode; /* the node if RNG not progressive */
|
xmlNodePtr rngFullNode; /* the node if RNG not progressive */
|
||||||
/* Handling of Schemas validation */
|
/* Handling of Schemas validation */
|
||||||
|
@ -806,9 +809,10 @@ xmlTextReaderCDataBlock(void *ctx, const xmlChar *ch, int len)
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xmlTextReaderPushData(xmlTextReaderPtr reader) {
|
xmlTextReaderPushData(xmlTextReaderPtr reader) {
|
||||||
xmlBufferPtr inbuf;
|
xmlBufPtr inbuf;
|
||||||
int val, s;
|
int val, s;
|
||||||
xmlTextReaderState oldstate;
|
xmlTextReaderState oldstate;
|
||||||
|
int alloc;
|
||||||
|
|
||||||
if ((reader->input == NULL) || (reader->input->buffer == NULL))
|
if ((reader->input == NULL) || (reader->input->buffer == NULL))
|
||||||
return(-1);
|
return(-1);
|
||||||
|
@ -816,17 +820,18 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
|
||||||
oldstate = reader->state;
|
oldstate = reader->state;
|
||||||
reader->state = XML_TEXTREADER_NONE;
|
reader->state = XML_TEXTREADER_NONE;
|
||||||
inbuf = reader->input->buffer;
|
inbuf = reader->input->buffer;
|
||||||
|
alloc = xmlBufGetAllocationScheme(inbuf);
|
||||||
|
|
||||||
while (reader->state == XML_TEXTREADER_NONE) {
|
while (reader->state == XML_TEXTREADER_NONE) {
|
||||||
if (inbuf->use < reader->cur + CHUNK_SIZE) {
|
if (xmlBufUse(inbuf) < reader->cur + CHUNK_SIZE) {
|
||||||
/*
|
/*
|
||||||
* Refill the buffer unless we are at the end of the stream
|
* Refill the buffer unless we are at the end of the stream
|
||||||
*/
|
*/
|
||||||
if (reader->mode != XML_TEXTREADER_MODE_EOF) {
|
if (reader->mode != XML_TEXTREADER_MODE_EOF) {
|
||||||
val = xmlParserInputBufferRead(reader->input, 4096);
|
val = xmlParserInputBufferRead(reader->input, 4096);
|
||||||
if ((val == 0) &&
|
if ((val == 0) &&
|
||||||
(inbuf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)) {
|
(alloc == XML_BUFFER_ALLOC_IMMUTABLE)) {
|
||||||
if (inbuf->use == reader->cur) {
|
if (xmlBufUse(inbuf) == reader->cur) {
|
||||||
reader->mode = XML_TEXTREADER_MODE_EOF;
|
reader->mode = XML_TEXTREADER_MODE_EOF;
|
||||||
reader->state = oldstate;
|
reader->state = oldstate;
|
||||||
}
|
}
|
||||||
|
@ -849,21 +854,23 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
|
||||||
* parse by block of CHUNK_SIZE bytes, various tests show that
|
* parse by block of CHUNK_SIZE bytes, various tests show that
|
||||||
* it's the best tradeoff at least on a 1.2GH Duron
|
* it's the best tradeoff at least on a 1.2GH Duron
|
||||||
*/
|
*/
|
||||||
if (inbuf->use >= reader->cur + CHUNK_SIZE) {
|
if (xmlBufUse(inbuf) >= reader->cur + CHUNK_SIZE) {
|
||||||
val = xmlParseChunk(reader->ctxt,
|
val = xmlParseChunk(reader->ctxt,
|
||||||
(const char *) &inbuf->content[reader->cur],
|
(const char *) xmlBufContent(inbuf) + reader->cur,
|
||||||
CHUNK_SIZE, 0);
|
CHUNK_SIZE, 0);
|
||||||
reader->cur += CHUNK_SIZE;
|
reader->cur += CHUNK_SIZE;
|
||||||
if ((val != 0) || (reader->ctxt->wellFormed == 0))
|
if (val != 0)
|
||||||
return(-1);
|
reader->ctxt->wellFormed = 0;
|
||||||
|
if (reader->ctxt->wellFormed == 0)
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
s = inbuf->use - reader->cur;
|
s = xmlBufUse(inbuf) - reader->cur;
|
||||||
val = xmlParseChunk(reader->ctxt,
|
val = xmlParseChunk(reader->ctxt,
|
||||||
(const char *) &inbuf->content[reader->cur],
|
(const char *) xmlBufContent(inbuf) + reader->cur,
|
||||||
s, 0);
|
s, 0);
|
||||||
reader->cur += s;
|
reader->cur += s;
|
||||||
if ((val != 0) || (reader->ctxt->wellFormed == 0))
|
if (val != 0)
|
||||||
return(-1);
|
reader->ctxt->wellFormed = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -872,10 +879,10 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
|
||||||
* Discard the consumed input when needed and possible
|
* Discard the consumed input when needed and possible
|
||||||
*/
|
*/
|
||||||
if (reader->mode == XML_TEXTREADER_MODE_INTERACTIVE) {
|
if (reader->mode == XML_TEXTREADER_MODE_INTERACTIVE) {
|
||||||
if (inbuf->alloc != XML_BUFFER_ALLOC_IMMUTABLE) {
|
if (alloc != XML_BUFFER_ALLOC_IMMUTABLE) {
|
||||||
if ((reader->cur >= 4096) &&
|
if ((reader->cur >= 4096) &&
|
||||||
(inbuf->use - reader->cur <= CHUNK_SIZE)) {
|
(xmlBufUse(inbuf) - reader->cur <= CHUNK_SIZE)) {
|
||||||
val = xmlBufferShrink(inbuf, reader->cur);
|
val = xmlBufShrink(inbuf, reader->cur);
|
||||||
if (val >= 0) {
|
if (val >= 0) {
|
||||||
reader->cur -= val;
|
reader->cur -= val;
|
||||||
}
|
}
|
||||||
|
@ -889,17 +896,26 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
|
||||||
*/
|
*/
|
||||||
else if (reader->mode == XML_TEXTREADER_MODE_EOF) {
|
else if (reader->mode == XML_TEXTREADER_MODE_EOF) {
|
||||||
if (reader->state != XML_TEXTREADER_DONE) {
|
if (reader->state != XML_TEXTREADER_DONE) {
|
||||||
s = inbuf->use - reader->cur;
|
s = xmlBufUse(inbuf) - reader->cur;
|
||||||
val = xmlParseChunk(reader->ctxt,
|
val = xmlParseChunk(reader->ctxt,
|
||||||
(const char *) &inbuf->content[reader->cur],
|
(const char *) xmlBufContent(inbuf) + reader->cur,
|
||||||
s, 1);
|
s, 1);
|
||||||
reader->cur = inbuf->use;
|
reader->cur = xmlBufUse(inbuf);
|
||||||
reader->state = XML_TEXTREADER_DONE;
|
reader->state = XML_TEXTREADER_DONE;
|
||||||
if ((val != 0) || (reader->ctxt->wellFormed == 0))
|
if (val != 0) {
|
||||||
return(-1);
|
if (reader->ctxt->wellFormed)
|
||||||
|
reader->ctxt->wellFormed = 0;
|
||||||
|
else
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reader->state = oldstate;
|
reader->state = oldstate;
|
||||||
|
if (reader->ctxt->wellFormed == 0) {
|
||||||
|
reader->mode = XML_TEXTREADER_MODE_EOF;
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1212,6 +1228,9 @@ xmlTextReaderCollectSiblings(xmlNodePtr node)
|
||||||
xmlBufferPtr buffer;
|
xmlBufferPtr buffer;
|
||||||
xmlChar *ret;
|
xmlChar *ret;
|
||||||
|
|
||||||
|
if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
buffer = xmlBufferCreate();
|
buffer = xmlBufferCreate();
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1264,8 +1283,6 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
|
||||||
return(xmlTextReaderReadTree(reader));
|
return(xmlTextReaderReadTree(reader));
|
||||||
if (reader->ctxt == NULL)
|
if (reader->ctxt == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
if (reader->ctxt->wellFormed != 1)
|
|
||||||
return(-1);
|
|
||||||
|
|
||||||
#ifdef DEBUG_READER
|
#ifdef DEBUG_READER
|
||||||
fprintf(stderr, "\nREAD ");
|
fprintf(stderr, "\nREAD ");
|
||||||
|
@ -2055,7 +2072,7 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
|
||||||
ret->entMax = 0;
|
ret->entMax = 0;
|
||||||
ret->entNr = 0;
|
ret->entNr = 0;
|
||||||
ret->input = input;
|
ret->input = input;
|
||||||
ret->buffer = xmlBufferCreateSize(100);
|
ret->buffer = xmlBufCreateSize(100);
|
||||||
if (ret->buffer == NULL) {
|
if (ret->buffer == NULL) {
|
||||||
xmlFree(ret);
|
xmlFree(ret);
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
@ -2064,7 +2081,7 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
|
||||||
}
|
}
|
||||||
ret->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
|
ret->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
|
||||||
if (ret->sax == NULL) {
|
if (ret->sax == NULL) {
|
||||||
xmlBufferFree(ret->buffer);
|
xmlBufFree(ret->buffer);
|
||||||
xmlFree(ret);
|
xmlFree(ret);
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlNewTextReader : malloc failed\n");
|
"xmlNewTextReader : malloc failed\n");
|
||||||
|
@ -2097,12 +2114,13 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
|
||||||
ret->mode = XML_TEXTREADER_MODE_INITIAL;
|
ret->mode = XML_TEXTREADER_MODE_INITIAL;
|
||||||
ret->node = NULL;
|
ret->node = NULL;
|
||||||
ret->curnode = NULL;
|
ret->curnode = NULL;
|
||||||
if (ret->input->buffer->use < 4) {
|
if (xmlBufUse(ret->input->buffer) < 4) {
|
||||||
xmlParserInputBufferRead(input, 4);
|
xmlParserInputBufferRead(input, 4);
|
||||||
}
|
}
|
||||||
if (ret->input->buffer->use >= 4) {
|
if (xmlBufUse(ret->input->buffer) >= 4) {
|
||||||
ret->ctxt = xmlCreatePushParserCtxt(ret->sax, NULL,
|
ret->ctxt = xmlCreatePushParserCtxt(ret->sax, NULL,
|
||||||
(const char *) ret->input->buffer->content, 4, URI);
|
(const char *) xmlBufContent(ret->input->buffer),
|
||||||
|
4, URI);
|
||||||
ret->base = 0;
|
ret->base = 0;
|
||||||
ret->cur = 4;
|
ret->cur = 4;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2114,7 +2132,7 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
|
||||||
if (ret->ctxt == NULL) {
|
if (ret->ctxt == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlNewTextReader : malloc failed\n");
|
"xmlNewTextReader : malloc failed\n");
|
||||||
xmlBufferFree(ret->buffer);
|
xmlBufFree(ret->buffer);
|
||||||
xmlFree(ret->sax);
|
xmlFree(ret->sax);
|
||||||
xmlFree(ret);
|
xmlFree(ret);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
@ -2187,7 +2205,8 @@ xmlFreeTextReader(xmlTextReaderPtr reader) {
|
||||||
reader->rngSchemas = NULL;
|
reader->rngSchemas = NULL;
|
||||||
}
|
}
|
||||||
if (reader->rngValidCtxt != NULL) {
|
if (reader->rngValidCtxt != NULL) {
|
||||||
xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
|
if (! reader->rngPreserveCtxt)
|
||||||
|
xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
|
||||||
reader->rngValidCtxt = NULL;
|
reader->rngValidCtxt = NULL;
|
||||||
}
|
}
|
||||||
if (reader->xsdPlug != NULL) {
|
if (reader->xsdPlug != NULL) {
|
||||||
|
@ -2243,7 +2262,7 @@ xmlFreeTextReader(xmlTextReaderPtr reader) {
|
||||||
if ((reader->input != NULL) && (reader->allocs & XML_TEXTREADER_INPUT))
|
if ((reader->input != NULL) && (reader->allocs & XML_TEXTREADER_INPUT))
|
||||||
xmlFreeParserInputBuffer(reader->input);
|
xmlFreeParserInputBuffer(reader->input);
|
||||||
if (reader->buffer != NULL)
|
if (reader->buffer != NULL)
|
||||||
xmlBufferFree(reader->buffer);
|
xmlBufFree(reader->buffer);
|
||||||
if (reader->entTab != NULL)
|
if (reader->entTab != NULL)
|
||||||
xmlFree(reader->entTab);
|
xmlFree(reader->entTab);
|
||||||
if (reader->dict != NULL)
|
if (reader->dict != NULL)
|
||||||
|
@ -3591,16 +3610,17 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) {
|
||||||
(attr->children->next == NULL))
|
(attr->children->next == NULL))
|
||||||
return(attr->children->content);
|
return(attr->children->content);
|
||||||
else {
|
else {
|
||||||
if (reader->buffer == NULL)
|
|
||||||
reader->buffer = xmlBufferCreateSize(100);
|
|
||||||
if (reader->buffer == NULL) {
|
if (reader->buffer == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
reader->buffer = xmlBufCreateSize(100);
|
||||||
"xmlTextReaderSetup : malloc failed\n");
|
if (reader->buffer == NULL) {
|
||||||
return (NULL);
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
}
|
"xmlTextReaderSetup : malloc failed\n");
|
||||||
reader->buffer->use = 0;
|
return (NULL);
|
||||||
xmlNodeBufGetContent(reader->buffer, node);
|
}
|
||||||
return(reader->buffer->content);
|
} else
|
||||||
|
xmlBufEmpty(reader->buffer);
|
||||||
|
xmlBufGetNodeContent(reader->buffer, node);
|
||||||
|
return(xmlBufContent(reader->buffer));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4095,9 +4115,11 @@ xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, xmlRelaxNGPtr schema) {
|
||||||
reader->rngSchemas = NULL;
|
reader->rngSchemas = NULL;
|
||||||
}
|
}
|
||||||
if (reader->rngValidCtxt != NULL) {
|
if (reader->rngValidCtxt != NULL) {
|
||||||
xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
|
if (! reader->rngPreserveCtxt)
|
||||||
|
xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
|
||||||
reader->rngValidCtxt = NULL;
|
reader->rngValidCtxt = NULL;
|
||||||
}
|
}
|
||||||
|
reader->rngPreserveCtxt = 0;
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
if (reader->mode != XML_TEXTREADER_MODE_INITIAL)
|
if (reader->mode != XML_TEXTREADER_MODE_INITIAL)
|
||||||
|
@ -4107,9 +4129,11 @@ xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, xmlRelaxNGPtr schema) {
|
||||||
reader->rngSchemas = NULL;
|
reader->rngSchemas = NULL;
|
||||||
}
|
}
|
||||||
if (reader->rngValidCtxt != NULL) {
|
if (reader->rngValidCtxt != NULL) {
|
||||||
xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
|
if (! reader->rngPreserveCtxt)
|
||||||
|
xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
|
||||||
reader->rngValidCtxt = NULL;
|
reader->rngValidCtxt = NULL;
|
||||||
}
|
}
|
||||||
|
reader->rngPreserveCtxt = 0;
|
||||||
reader->rngValidCtxt = xmlRelaxNGNewValidCtxt(schema);
|
reader->rngValidCtxt = xmlRelaxNGNewValidCtxt(schema);
|
||||||
if (reader->rngValidCtxt == NULL)
|
if (reader->rngValidCtxt == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
|
@ -4130,6 +4154,60 @@ xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, xmlRelaxNGPtr schema) {
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlTextReaderLocator:
|
||||||
|
* @ctx: the xmlTextReaderPtr used
|
||||||
|
* @file: returned file information
|
||||||
|
* @line: returned line information
|
||||||
|
*
|
||||||
|
* Internal locator function for the readers
|
||||||
|
*
|
||||||
|
* Returns 0 in case the Schema validation could be (des)activated and
|
||||||
|
* -1 in case of error.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
xmlTextReaderLocator(void *ctx, const char **file, unsigned long *line) {
|
||||||
|
xmlTextReaderPtr reader;
|
||||||
|
|
||||||
|
if ((ctx == NULL) || ((file == NULL) && (line == NULL)))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
if (file != NULL)
|
||||||
|
*file = NULL;
|
||||||
|
if (line != NULL)
|
||||||
|
*line = 0;
|
||||||
|
|
||||||
|
reader = (xmlTextReaderPtr) ctx;
|
||||||
|
if ((reader->ctxt != NULL) && (reader->ctxt->input != NULL)) {
|
||||||
|
if (file != NULL)
|
||||||
|
*file = reader->ctxt->input->filename;
|
||||||
|
if (line != NULL)
|
||||||
|
*line = reader->ctxt->input->line;
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
if (reader->node != NULL) {
|
||||||
|
long res;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
if (line != NULL) {
|
||||||
|
res = xmlGetLineNo(reader->node);
|
||||||
|
if (res > 0)
|
||||||
|
*line = (unsigned long) res;
|
||||||
|
else
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
if (file != NULL) {
|
||||||
|
xmlDocPtr doc = reader->node->doc;
|
||||||
|
if ((doc != NULL) && (doc->URL != NULL))
|
||||||
|
*file = (const char *) doc->URL;
|
||||||
|
else
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlTextReaderSetSchema:
|
* xmlTextReaderSetSchema:
|
||||||
* @reader: the xmlTextReaderPtr used
|
* @reader: the xmlTextReaderPtr used
|
||||||
|
@ -4197,6 +4275,10 @@ xmlTextReaderSetSchema(xmlTextReaderPtr reader, xmlSchemaPtr schema) {
|
||||||
reader->xsdValidCtxt = NULL;
|
reader->xsdValidCtxt = NULL;
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
xmlSchemaValidateSetLocator(reader->xsdValidCtxt,
|
||||||
|
xmlTextReaderLocator,
|
||||||
|
(void *) reader);
|
||||||
|
|
||||||
if (reader->errorFunc != NULL) {
|
if (reader->errorFunc != NULL) {
|
||||||
xmlSchemaSetValidErrors(reader->xsdValidCtxt,
|
xmlSchemaSetValidErrors(reader->xsdValidCtxt,
|
||||||
xmlTextReaderValidityErrorRelay,
|
xmlTextReaderValidityErrorRelay,
|
||||||
|
@ -4214,67 +4296,91 @@ xmlTextReaderSetSchema(xmlTextReaderPtr reader, xmlSchemaPtr schema) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlTextReaderRelaxNGValidate:
|
* xmlTextReaderRelaxNGValidateInternal:
|
||||||
* @reader: the xmlTextReaderPtr used
|
* @reader: the xmlTextReaderPtr used
|
||||||
* @rng: the path to a RelaxNG schema or NULL
|
* @rng: the path to a RelaxNG schema or NULL
|
||||||
|
* @ctxt: the RelaxNG schema validation context or NULL
|
||||||
|
* @options: options (not yet used)
|
||||||
*
|
*
|
||||||
* Use RelaxNG to validate the document as it is processed.
|
* Use RelaxNG to validate the document as it is processed.
|
||||||
* Activation is only possible before the first Read().
|
* Activation is only possible before the first Read().
|
||||||
* if @rng is NULL, then RelaxNG validation is deactivated.
|
* If both @rng and @ctxt are NULL, then RelaxNG validation is deactivated.
|
||||||
*
|
*
|
||||||
* Returns 0 in case the RelaxNG validation could be (de)activated and
|
* Returns 0 in case the RelaxNG validation could be (de)activated and
|
||||||
* -1 in case of error.
|
* -1 in case of error.
|
||||||
*/
|
*/
|
||||||
int
|
static int
|
||||||
xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng) {
|
xmlTextReaderRelaxNGValidateInternal(xmlTextReaderPtr reader,
|
||||||
xmlRelaxNGParserCtxtPtr ctxt;
|
const char *rng,
|
||||||
|
xmlRelaxNGValidCtxtPtr ctxt,
|
||||||
|
int options ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
if (reader == NULL)
|
if (reader == NULL)
|
||||||
return(-1);
|
|
||||||
|
|
||||||
if (rng == NULL) {
|
|
||||||
if (reader->rngValidCtxt != NULL) {
|
|
||||||
xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
|
|
||||||
reader->rngValidCtxt = NULL;
|
|
||||||
}
|
|
||||||
if (reader->rngSchemas != NULL) {
|
|
||||||
xmlRelaxNGFree(reader->rngSchemas);
|
|
||||||
reader->rngSchemas = NULL;
|
|
||||||
}
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
if (reader->mode != XML_TEXTREADER_MODE_INITIAL)
|
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
|
if ((rng != NULL) && (ctxt != NULL))
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
if (((rng != NULL) || (ctxt != NULL)) &&
|
||||||
|
((reader->mode != XML_TEXTREADER_MODE_INITIAL) ||
|
||||||
|
(reader->ctxt == NULL)))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
/* Cleanup previous validation stuff. */
|
||||||
|
if (reader->rngValidCtxt != NULL) {
|
||||||
|
if ( !reader->rngPreserveCtxt)
|
||||||
|
xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
|
||||||
|
reader->rngValidCtxt = NULL;
|
||||||
|
}
|
||||||
|
reader->rngPreserveCtxt = 0;
|
||||||
if (reader->rngSchemas != NULL) {
|
if (reader->rngSchemas != NULL) {
|
||||||
xmlRelaxNGFree(reader->rngSchemas);
|
xmlRelaxNGFree(reader->rngSchemas);
|
||||||
reader->rngSchemas = NULL;
|
reader->rngSchemas = NULL;
|
||||||
}
|
}
|
||||||
if (reader->rngValidCtxt != NULL) {
|
|
||||||
xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
|
if ((rng == NULL) && (ctxt == NULL)) {
|
||||||
reader->rngValidCtxt = NULL;
|
/* We just want to deactivate the validation, so get out. */
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
ctxt = xmlRelaxNGNewParserCtxt(rng);
|
|
||||||
if (reader->errorFunc != NULL) {
|
|
||||||
xmlRelaxNGSetParserErrors(ctxt,
|
if (rng != NULL) {
|
||||||
xmlTextReaderValidityErrorRelay,
|
xmlRelaxNGParserCtxtPtr pctxt;
|
||||||
xmlTextReaderValidityWarningRelay,
|
/* Parse the schema and create validation environment. */
|
||||||
reader);
|
|
||||||
}
|
pctxt = xmlRelaxNGNewParserCtxt(rng);
|
||||||
if (reader->sErrorFunc != NULL) {
|
if (reader->errorFunc != NULL) {
|
||||||
xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
|
xmlRelaxNGSetParserErrors(pctxt,
|
||||||
xmlTextReaderValidityStructuredRelay,
|
xmlTextReaderValidityErrorRelay,
|
||||||
reader);
|
xmlTextReaderValidityWarningRelay,
|
||||||
}
|
reader);
|
||||||
reader->rngSchemas = xmlRelaxNGParse(ctxt);
|
}
|
||||||
xmlRelaxNGFreeParserCtxt(ctxt);
|
if (reader->sErrorFunc != NULL) {
|
||||||
if (reader->rngSchemas == NULL)
|
xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
|
||||||
return(-1);
|
xmlTextReaderValidityStructuredRelay,
|
||||||
reader->rngValidCtxt = xmlRelaxNGNewValidCtxt(reader->rngSchemas);
|
reader);
|
||||||
if (reader->rngValidCtxt == NULL) {
|
}
|
||||||
xmlRelaxNGFree(reader->rngSchemas);
|
reader->rngSchemas = xmlRelaxNGParse(pctxt);
|
||||||
reader->rngSchemas = NULL;
|
xmlRelaxNGFreeParserCtxt(pctxt);
|
||||||
return(-1);
|
if (reader->rngSchemas == NULL)
|
||||||
|
return(-1);
|
||||||
|
reader->rngValidCtxt = xmlRelaxNGNewValidCtxt(reader->rngSchemas);
|
||||||
|
if (reader->rngValidCtxt == NULL) {
|
||||||
|
xmlRelaxNGFree(reader->rngSchemas);
|
||||||
|
reader->rngSchemas = NULL;
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Use the given validation context. */
|
||||||
|
reader->rngValidCtxt = ctxt;
|
||||||
|
reader->rngPreserveCtxt = 1;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Redirect the validation context's error channels to use
|
||||||
|
* the reader channels.
|
||||||
|
* TODO: In case the user provides the validation context we
|
||||||
|
* could make this redirection optional.
|
||||||
|
*/
|
||||||
if (reader->errorFunc != NULL) {
|
if (reader->errorFunc != NULL) {
|
||||||
xmlRelaxNGSetValidErrors(reader->rngValidCtxt,
|
xmlRelaxNGSetValidErrors(reader->rngValidCtxt,
|
||||||
xmlTextReaderValidityErrorRelay,
|
xmlTextReaderValidityErrorRelay,
|
||||||
|
@ -4387,6 +4493,9 @@ xmlTextReaderSchemaValidateInternal(xmlTextReaderPtr reader,
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
xmlSchemaValidateSetLocator(reader->xsdValidCtxt,
|
||||||
|
xmlTextReaderLocator,
|
||||||
|
(void *) reader);
|
||||||
/*
|
/*
|
||||||
* Redirect the validation context's error channels to use
|
* Redirect the validation context's error channels to use
|
||||||
* the reader channels.
|
* the reader channels.
|
||||||
|
@ -4447,6 +4556,46 @@ xmlTextReaderSchemaValidate(xmlTextReaderPtr reader, const char *xsd)
|
||||||
{
|
{
|
||||||
return(xmlTextReaderSchemaValidateInternal(reader, xsd, NULL, 0));
|
return(xmlTextReaderSchemaValidateInternal(reader, xsd, NULL, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlTextReaderRelaxNGValidateCtxt:
|
||||||
|
* @reader: the xmlTextReaderPtr used
|
||||||
|
* @ctxt: the RelaxNG schema validation context or NULL
|
||||||
|
* @options: options (not used yet)
|
||||||
|
*
|
||||||
|
* Use RelaxNG schema context to validate the document as it is processed.
|
||||||
|
* Activation is only possible before the first Read().
|
||||||
|
* If @ctxt is NULL, then RelaxNG schema validation is deactivated.
|
||||||
|
*
|
||||||
|
* Returns 0 in case the schemas validation could be (de)activated and
|
||||||
|
* -1 in case of error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader,
|
||||||
|
xmlRelaxNGValidCtxtPtr ctxt,
|
||||||
|
int options)
|
||||||
|
{
|
||||||
|
return(xmlTextReaderRelaxNGValidateInternal(reader, NULL, ctxt, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlTextReaderRelaxNGValidate:
|
||||||
|
* @reader: the xmlTextReaderPtr used
|
||||||
|
* @rng: the path to a RelaxNG schema or NULL
|
||||||
|
*
|
||||||
|
* Use RelaxNG schema to validate the document as it is processed.
|
||||||
|
* Activation is only possible before the first Read().
|
||||||
|
* If @rng is NULL, then RelaxNG schema validation is deactivated.
|
||||||
|
*
|
||||||
|
* Returns 0 in case the schemas validation could be (de)activated and
|
||||||
|
* -1 in case of error.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng)
|
||||||
|
{
|
||||||
|
return(xmlTextReaderRelaxNGValidateInternal(reader, rng, NULL, 0));
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4964,7 +5113,7 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
|
||||||
reader->allocs |= XML_TEXTREADER_INPUT;
|
reader->allocs |= XML_TEXTREADER_INPUT;
|
||||||
}
|
}
|
||||||
if (reader->buffer == NULL)
|
if (reader->buffer == NULL)
|
||||||
reader->buffer = xmlBufferCreateSize(100);
|
reader->buffer = xmlBufCreateSize(100);
|
||||||
if (reader->buffer == NULL) {
|
if (reader->buffer == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlTextReaderSetup : malloc failed\n");
|
"xmlTextReaderSetup : malloc failed\n");
|
||||||
|
@ -5005,13 +5154,14 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
|
||||||
reader->node = NULL;
|
reader->node = NULL;
|
||||||
reader->curnode = NULL;
|
reader->curnode = NULL;
|
||||||
if (input != NULL) {
|
if (input != NULL) {
|
||||||
if (reader->input->buffer->use < 4) {
|
if (xmlBufUse(reader->input->buffer) < 4) {
|
||||||
xmlParserInputBufferRead(input, 4);
|
xmlParserInputBufferRead(input, 4);
|
||||||
}
|
}
|
||||||
if (reader->ctxt == NULL) {
|
if (reader->ctxt == NULL) {
|
||||||
if (reader->input->buffer->use >= 4) {
|
if (xmlBufUse(reader->input->buffer) >= 4) {
|
||||||
reader->ctxt = xmlCreatePushParserCtxt(reader->sax, NULL,
|
reader->ctxt = xmlCreatePushParserCtxt(reader->sax, NULL,
|
||||||
(const char *) reader->input->buffer->content, 4, URL);
|
(const char *) xmlBufContent(reader->input->buffer),
|
||||||
|
4, URL);
|
||||||
reader->base = 0;
|
reader->base = 0;
|
||||||
reader->cur = 4;
|
reader->cur = 4;
|
||||||
} else {
|
} else {
|
||||||
|
@ -5040,10 +5190,7 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
|
||||||
inputStream->filename = (char *)
|
inputStream->filename = (char *)
|
||||||
xmlCanonicPath((const xmlChar *) URL);
|
xmlCanonicPath((const xmlChar *) URL);
|
||||||
inputStream->buf = buf;
|
inputStream->buf = buf;
|
||||||
inputStream->base = inputStream->buf->buffer->content;
|
xmlBufResetInput(buf->buffer, inputStream);
|
||||||
inputStream->cur = inputStream->buf->buffer->content;
|
|
||||||
inputStream->end =
|
|
||||||
&inputStream->buf->buffer->content[inputStream->buf->buffer->use];
|
|
||||||
|
|
||||||
inputPush(reader->ctxt, inputStream);
|
inputPush(reader->ctxt, inputStream);
|
||||||
reader->cur = 0;
|
reader->cur = 0;
|
||||||
|
@ -5331,8 +5478,11 @@ xmlReaderForIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
|
||||||
|
|
||||||
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
|
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
|
||||||
XML_CHAR_ENCODING_NONE);
|
XML_CHAR_ENCODING_NONE);
|
||||||
if (input == NULL)
|
if (input == NULL) {
|
||||||
|
if (ioclose != NULL)
|
||||||
|
ioclose(ioctx);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
}
|
||||||
reader = xmlNewTextReader(input, URL);
|
reader = xmlNewTextReader(input, URL);
|
||||||
if (reader == NULL) {
|
if (reader == NULL) {
|
||||||
xmlFreeParserInputBuffer(input);
|
xmlFreeParserInputBuffer(input);
|
||||||
|
@ -5549,10 +5699,14 @@ xmlReaderNewIO(xmlTextReaderPtr reader, xmlInputReadCallback ioread,
|
||||||
|
|
||||||
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
|
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
|
||||||
XML_CHAR_ENCODING_NONE);
|
XML_CHAR_ENCODING_NONE);
|
||||||
if (input == NULL)
|
if (input == NULL) {
|
||||||
|
if (ioclose != NULL)
|
||||||
|
ioclose(ioctx);
|
||||||
return (-1);
|
return (-1);
|
||||||
|
}
|
||||||
return (xmlTextReaderSetup(reader, input, URL, encoding, options));
|
return (xmlTextReaderSetup(reader, input, URL, encoding, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* Utilities *
|
* Utilities *
|
||||||
|
|
16
reactos/lib/3rdparty/libxml2/xmlregexp.c
vendored
16
reactos/lib/3rdparty/libxml2/xmlregexp.c
vendored
|
@ -44,6 +44,9 @@
|
||||||
|
|
||||||
#define MAX_PUSH 10000000
|
#define MAX_PUSH 10000000
|
||||||
|
|
||||||
|
#ifdef ERROR
|
||||||
|
#undef ERROR
|
||||||
|
#endif
|
||||||
#define ERROR(str) \
|
#define ERROR(str) \
|
||||||
ctxt->error = XML_REGEXP_COMPILE_ERROR; \
|
ctxt->error = XML_REGEXP_COMPILE_ERROR; \
|
||||||
xmlRegexpErrCompile(ctxt, str);
|
xmlRegexpErrCompile(ctxt, str);
|
||||||
|
@ -219,6 +222,7 @@ struct _xmlRegTrans {
|
||||||
struct _xmlAutomataState {
|
struct _xmlAutomataState {
|
||||||
xmlRegStateType type;
|
xmlRegStateType type;
|
||||||
xmlRegMarkedType mark;
|
xmlRegMarkedType mark;
|
||||||
|
xmlRegMarkedType markd;
|
||||||
xmlRegMarkedType reached;
|
xmlRegMarkedType reached;
|
||||||
int no;
|
int no;
|
||||||
int maxTrans;
|
int maxTrans;
|
||||||
|
@ -2586,6 +2590,8 @@ xmlFARecurseDeterminism(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
|
||||||
|
|
||||||
if (state == NULL)
|
if (state == NULL)
|
||||||
return(ret);
|
return(ret);
|
||||||
|
if (state->markd == XML_REGEXP_MARK_VISITED)
|
||||||
|
return(ret);
|
||||||
|
|
||||||
if (ctxt->flags & AM_AUTOMATA_RNG)
|
if (ctxt->flags & AM_AUTOMATA_RNG)
|
||||||
deep = 0;
|
deep = 0;
|
||||||
|
@ -2603,8 +2609,10 @@ xmlFARecurseDeterminism(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
|
||||||
if (t1->atom == NULL) {
|
if (t1->atom == NULL) {
|
||||||
if (t1->to < 0)
|
if (t1->to < 0)
|
||||||
continue;
|
continue;
|
||||||
|
state->markd = XML_REGEXP_MARK_VISITED;
|
||||||
res = xmlFARecurseDeterminism(ctxt, ctxt->states[t1->to],
|
res = xmlFARecurseDeterminism(ctxt, ctxt->states[t1->to],
|
||||||
to, atom);
|
to, atom);
|
||||||
|
state->markd = 0;
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
/* t1->nd = 1; */
|
/* t1->nd = 1; */
|
||||||
|
@ -3199,7 +3207,7 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
|
||||||
memset(exec->counts, 0, comp->nbCounters * sizeof(int));
|
memset(exec->counts, 0, comp->nbCounters * sizeof(int));
|
||||||
} else
|
} else
|
||||||
exec->counts = NULL;
|
exec->counts = NULL;
|
||||||
while ((exec->status == 0) &&
|
while ((exec->status == 0) && (exec->state != NULL) &&
|
||||||
((exec->inputString[exec->index] != 0) ||
|
((exec->inputString[exec->index] != 0) ||
|
||||||
((exec->state != NULL) &&
|
((exec->state != NULL) &&
|
||||||
(exec->state->type != XML_REGEXP_FINAL_STATE)))) {
|
(exec->state->type != XML_REGEXP_FINAL_STATE)))) {
|
||||||
|
@ -3453,6 +3461,8 @@ error:
|
||||||
}
|
}
|
||||||
xmlFree(exec->rollbacks);
|
xmlFree(exec->rollbacks);
|
||||||
}
|
}
|
||||||
|
if (exec->state == NULL)
|
||||||
|
return(-1);
|
||||||
if (exec->counts != NULL)
|
if (exec->counts != NULL)
|
||||||
xmlFree(exec->counts);
|
xmlFree(exec->counts);
|
||||||
if (exec->status == 0)
|
if (exec->status == 0)
|
||||||
|
@ -5370,6 +5380,10 @@ xmlFAParseRegExp(xmlRegParserCtxtPtr ctxt, int top) {
|
||||||
end = ctxt->state;
|
end = ctxt->state;
|
||||||
while ((CUR == '|') && (ctxt->error == 0)) {
|
while ((CUR == '|') && (ctxt->error == 0)) {
|
||||||
NEXT;
|
NEXT;
|
||||||
|
if (CUR == 0) {
|
||||||
|
ERROR("expecting a branch after |")
|
||||||
|
return;
|
||||||
|
}
|
||||||
ctxt->state = start;
|
ctxt->state = start;
|
||||||
ctxt->end = NULL;
|
ctxt->end = NULL;
|
||||||
xmlFAParseBranch(ctxt, end);
|
xmlFAParseBranch(ctxt, end);
|
||||||
|
|
269
reactos/lib/3rdparty/libxml2/xmlsave.c
vendored
269
reactos/lib/3rdparty/libxml2/xmlsave.c
vendored
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
#include <libxml/HTMLtree.h>
|
#include <libxml/HTMLtree.h>
|
||||||
|
|
||||||
|
#include "buf.h"
|
||||||
|
#include "enc.h"
|
||||||
|
#include "save.h"
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* XHTML detection *
|
* XHTML detection *
|
||||||
|
@ -248,7 +252,7 @@ xmlEscapeEntities(unsigned char* out, int *outlen,
|
||||||
/*
|
/*
|
||||||
* We assume we have UTF-8 input.
|
* We assume we have UTF-8 input.
|
||||||
*/
|
*/
|
||||||
if (outend - out < 10) break;
|
if (outend - out < 11) break;
|
||||||
|
|
||||||
if (*in < 0xC0) {
|
if (*in < 0xC0) {
|
||||||
xmlSaveErr(XML_SAVE_NOT_UTF8, NULL, NULL);
|
xmlSaveErr(XML_SAVE_NOT_UTF8, NULL, NULL);
|
||||||
|
@ -436,14 +440,14 @@ xmlAttrSerializeContent(xmlOutputBufferPtr buf, xmlAttrPtr attr)
|
||||||
while (children != NULL) {
|
while (children != NULL) {
|
||||||
switch (children->type) {
|
switch (children->type) {
|
||||||
case XML_TEXT_NODE:
|
case XML_TEXT_NODE:
|
||||||
xmlAttrSerializeTxtContent(buf->buffer, attr->doc,
|
xmlBufAttrSerializeTxtContent(buf->buffer, attr->doc,
|
||||||
attr, children->content);
|
attr, children->content);
|
||||||
break;
|
break;
|
||||||
case XML_ENTITY_REF_NODE:
|
case XML_ENTITY_REF_NODE:
|
||||||
xmlBufferAdd(buf->buffer, BAD_CAST "&", 1);
|
xmlBufAdd(buf->buffer, BAD_CAST "&", 1);
|
||||||
xmlBufferAdd(buf->buffer, children->name,
|
xmlBufAdd(buf->buffer, children->name,
|
||||||
xmlStrlen(children->name));
|
xmlStrlen(children->name));
|
||||||
xmlBufferAdd(buf->buffer, BAD_CAST ";", 1);
|
xmlBufAdd(buf->buffer, BAD_CAST ";", 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* should not happen unless we have a badly built tree */
|
/* should not happen unless we have a badly built tree */
|
||||||
|
@ -453,6 +457,96 @@ xmlAttrSerializeContent(xmlOutputBufferPtr buf, xmlAttrPtr attr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlBufDumpNotationTable:
|
||||||
|
* @buf: an xmlBufPtr output
|
||||||
|
* @table: A notation table
|
||||||
|
*
|
||||||
|
* This will dump the content of the notation table as an XML DTD definition
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xmlBufDumpNotationTable(xmlBufPtr buf, xmlNotationTablePtr table) {
|
||||||
|
xmlBufferPtr buffer;
|
||||||
|
|
||||||
|
buffer = xmlBufferCreate();
|
||||||
|
if (buffer == NULL) {
|
||||||
|
/*
|
||||||
|
* TODO set the error in buf
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
xmlDumpNotationTable(buffer, table);
|
||||||
|
xmlBufMergeBuffer(buf, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlBufDumpElementDecl:
|
||||||
|
* @buf: an xmlBufPtr output
|
||||||
|
* @elem: An element table
|
||||||
|
*
|
||||||
|
* This will dump the content of the element declaration as an XML
|
||||||
|
* DTD definition
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xmlBufDumpElementDecl(xmlBufPtr buf, xmlElementPtr elem) {
|
||||||
|
xmlBufferPtr buffer;
|
||||||
|
|
||||||
|
buffer = xmlBufferCreate();
|
||||||
|
if (buffer == NULL) {
|
||||||
|
/*
|
||||||
|
* TODO set the error in buf
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
xmlDumpElementDecl(buffer, elem);
|
||||||
|
xmlBufMergeBuffer(buf, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlBufDumpAttributeDecl:
|
||||||
|
* @buf: an xmlBufPtr output
|
||||||
|
* @attr: An attribute declaration
|
||||||
|
*
|
||||||
|
* This will dump the content of the attribute declaration as an XML
|
||||||
|
* DTD definition
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xmlBufDumpAttributeDecl(xmlBufPtr buf, xmlAttributePtr attr) {
|
||||||
|
xmlBufferPtr buffer;
|
||||||
|
|
||||||
|
buffer = xmlBufferCreate();
|
||||||
|
if (buffer == NULL) {
|
||||||
|
/*
|
||||||
|
* TODO set the error in buf
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
xmlDumpAttributeDecl(buffer, attr);
|
||||||
|
xmlBufMergeBuffer(buf, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlBufDumpEntityDecl:
|
||||||
|
* @buf: an xmlBufPtr output
|
||||||
|
* @ent: An entity table
|
||||||
|
*
|
||||||
|
* This will dump the content of the entity table as an XML DTD definition
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xmlBufDumpEntityDecl(xmlBufPtr buf, xmlEntityPtr ent) {
|
||||||
|
xmlBufferPtr buffer;
|
||||||
|
|
||||||
|
buffer = xmlBufferCreate();
|
||||||
|
if (buffer == NULL) {
|
||||||
|
/*
|
||||||
|
* TODO set the error in buf
|
||||||
|
*/
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
xmlDumpEntityDecl(buffer, ent);
|
||||||
|
xmlBufMergeBuffer(buf, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* Dumping XML tree content to an I/O output buffer *
|
* Dumping XML tree content to an I/O output buffer *
|
||||||
|
@ -469,7 +563,7 @@ static int xmlSaveSwitchEncoding(xmlSaveCtxtPtr ctxt, const char *encoding) {
|
||||||
(const char *)encoding);
|
(const char *)encoding);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
buf->conv = xmlBufferCreate();
|
buf->conv = xmlBufCreate();
|
||||||
if (buf->conv == NULL) {
|
if (buf->conv == NULL) {
|
||||||
xmlCharEncCloseFunc(buf->encoder);
|
xmlCharEncCloseFunc(buf->encoder);
|
||||||
xmlSaveErrMemory("creating encoding buffer");
|
xmlSaveErrMemory("creating encoding buffer");
|
||||||
|
@ -478,7 +572,7 @@ static int xmlSaveSwitchEncoding(xmlSaveCtxtPtr ctxt, const char *encoding) {
|
||||||
/*
|
/*
|
||||||
* initialize the state, e.g. if outputting a BOM
|
* initialize the state, e.g. if outputting a BOM
|
||||||
*/
|
*/
|
||||||
xmlCharEncOutFunc(buf->encoder, buf->conv, NULL);
|
xmlCharEncOutput(buf, 1);
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -487,7 +581,7 @@ static int xmlSaveClearEncoding(xmlSaveCtxtPtr ctxt) {
|
||||||
xmlOutputBufferPtr buf = ctxt->buf;
|
xmlOutputBufferPtr buf = ctxt->buf;
|
||||||
xmlOutputBufferFlush(buf);
|
xmlOutputBufferFlush(buf);
|
||||||
xmlCharEncCloseFunc(buf->encoder);
|
xmlCharEncCloseFunc(buf->encoder);
|
||||||
xmlBufferFree(buf->conv);
|
xmlBufFree(buf->conv);
|
||||||
buf->encoder = NULL;
|
buf->encoder = NULL;
|
||||||
buf->conv = NULL;
|
buf->conv = NULL;
|
||||||
return(0);
|
return(0);
|
||||||
|
@ -553,7 +647,7 @@ xmlNsDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur, xmlSaveCtxtPtr ctxt) {
|
||||||
} else
|
} else
|
||||||
xmlOutputBufferWrite(buf, 5, "xmlns");
|
xmlOutputBufferWrite(buf, 5, "xmlns");
|
||||||
xmlOutputBufferWrite(buf, 1, "=");
|
xmlOutputBufferWrite(buf, 1, "=");
|
||||||
xmlBufferWriteQuotedString(buf->buffer, cur->href);
|
xmlBufWriteQuotedString(buf->buffer, cur->href);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,12 +717,12 @@ xmlDtdDumpOutput(xmlSaveCtxtPtr ctxt, xmlDtdPtr dtd) {
|
||||||
xmlOutputBufferWriteString(buf, (const char *)dtd->name);
|
xmlOutputBufferWriteString(buf, (const char *)dtd->name);
|
||||||
if (dtd->ExternalID != NULL) {
|
if (dtd->ExternalID != NULL) {
|
||||||
xmlOutputBufferWrite(buf, 8, " PUBLIC ");
|
xmlOutputBufferWrite(buf, 8, " PUBLIC ");
|
||||||
xmlBufferWriteQuotedString(buf->buffer, dtd->ExternalID);
|
xmlBufWriteQuotedString(buf->buffer, dtd->ExternalID);
|
||||||
xmlOutputBufferWrite(buf, 1, " ");
|
xmlOutputBufferWrite(buf, 1, " ");
|
||||||
xmlBufferWriteQuotedString(buf->buffer, dtd->SystemID);
|
xmlBufWriteQuotedString(buf->buffer, dtd->SystemID);
|
||||||
} else if (dtd->SystemID != NULL) {
|
} else if (dtd->SystemID != NULL) {
|
||||||
xmlOutputBufferWrite(buf, 8, " SYSTEM ");
|
xmlOutputBufferWrite(buf, 8, " SYSTEM ");
|
||||||
xmlBufferWriteQuotedString(buf->buffer, dtd->SystemID);
|
xmlBufWriteQuotedString(buf->buffer, dtd->SystemID);
|
||||||
}
|
}
|
||||||
if ((dtd->entities == NULL) && (dtd->elements == NULL) &&
|
if ((dtd->entities == NULL) && (dtd->elements == NULL) &&
|
||||||
(dtd->attributes == NULL) && (dtd->notations == NULL) &&
|
(dtd->attributes == NULL) && (dtd->notations == NULL) &&
|
||||||
|
@ -643,7 +737,8 @@ xmlDtdDumpOutput(xmlSaveCtxtPtr ctxt, xmlDtdPtr dtd) {
|
||||||
*/
|
*/
|
||||||
if ((dtd->notations != NULL) && ((dtd->doc == NULL) ||
|
if ((dtd->notations != NULL) && ((dtd->doc == NULL) ||
|
||||||
(dtd->doc->intSubset == dtd))) {
|
(dtd->doc->intSubset == dtd))) {
|
||||||
xmlDumpNotationTable(buf->buffer, (xmlNotationTablePtr) dtd->notations);
|
xmlBufDumpNotationTable(buf->buffer,
|
||||||
|
(xmlNotationTablePtr) dtd->notations);
|
||||||
}
|
}
|
||||||
format = ctxt->format;
|
format = ctxt->format;
|
||||||
level = ctxt->level;
|
level = ctxt->level;
|
||||||
|
@ -841,15 +936,15 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cur->type == XML_ELEMENT_DECL) {
|
if (cur->type == XML_ELEMENT_DECL) {
|
||||||
xmlDumpElementDecl(buf->buffer, (xmlElementPtr) cur);
|
xmlBufDumpElementDecl(buf->buffer, (xmlElementPtr) cur);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cur->type == XML_ATTRIBUTE_DECL) {
|
if (cur->type == XML_ATTRIBUTE_DECL) {
|
||||||
xmlDumpAttributeDecl(buf->buffer, (xmlAttributePtr) cur);
|
xmlBufDumpAttributeDecl(buf->buffer, (xmlAttributePtr) cur);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cur->type == XML_ENTITY_DECL) {
|
if (cur->type == XML_ENTITY_DECL) {
|
||||||
xmlDumpEntityDecl(buf->buffer, (xmlEntityPtr) cur);
|
xmlBufDumpEntityDecl(buf->buffer, (xmlEntityPtr) cur);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cur->type == XML_TEXT_NODE) {
|
if (cur->type == XML_TEXT_NODE) {
|
||||||
|
@ -1097,12 +1192,12 @@ xmlDocContentDumpOutput(xmlSaveCtxtPtr ctxt, xmlDocPtr cur) {
|
||||||
if ((ctxt->options & XML_SAVE_NO_DECL) == 0) {
|
if ((ctxt->options & XML_SAVE_NO_DECL) == 0) {
|
||||||
xmlOutputBufferWrite(buf, 14, "<?xml version=");
|
xmlOutputBufferWrite(buf, 14, "<?xml version=");
|
||||||
if (cur->version != NULL)
|
if (cur->version != NULL)
|
||||||
xmlBufferWriteQuotedString(buf->buffer, cur->version);
|
xmlBufWriteQuotedString(buf->buffer, cur->version);
|
||||||
else
|
else
|
||||||
xmlOutputBufferWrite(buf, 5, "\"1.0\"");
|
xmlOutputBufferWrite(buf, 5, "\"1.0\"");
|
||||||
if (encoding != NULL) {
|
if (encoding != NULL) {
|
||||||
xmlOutputBufferWrite(buf, 10, " encoding=");
|
xmlOutputBufferWrite(buf, 10, " encoding=");
|
||||||
xmlBufferWriteQuotedString(buf->buffer, (xmlChar *) encoding);
|
xmlBufWriteQuotedString(buf->buffer, (xmlChar *) encoding);
|
||||||
}
|
}
|
||||||
switch (cur->standalone) {
|
switch (cur->standalone) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -1370,6 +1465,10 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
|
||||||
return;
|
return;
|
||||||
if (cur->type == XML_XINCLUDE_END)
|
if (cur->type == XML_XINCLUDE_END)
|
||||||
return;
|
return;
|
||||||
|
if (cur->type == XML_NAMESPACE_DECL) {
|
||||||
|
xmlNsDumpOutputCtxt(ctxt, (xmlNsPtr) cur);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (cur->type == XML_DTD_NODE) {
|
if (cur->type == XML_DTD_NODE) {
|
||||||
xmlDtdDumpOutput(ctxt, (xmlDtdPtr) cur);
|
xmlDtdDumpOutput(ctxt, (xmlDtdPtr) cur);
|
||||||
return;
|
return;
|
||||||
|
@ -1380,15 +1479,15 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
|
||||||
}
|
}
|
||||||
buf = ctxt->buf;
|
buf = ctxt->buf;
|
||||||
if (cur->type == XML_ELEMENT_DECL) {
|
if (cur->type == XML_ELEMENT_DECL) {
|
||||||
xmlDumpElementDecl(buf->buffer, (xmlElementPtr) cur);
|
xmlBufDumpElementDecl(buf->buffer, (xmlElementPtr) cur);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cur->type == XML_ATTRIBUTE_DECL) {
|
if (cur->type == XML_ATTRIBUTE_DECL) {
|
||||||
xmlDumpAttributeDecl(buf->buffer, (xmlAttributePtr) cur);
|
xmlBufDumpAttributeDecl(buf->buffer, (xmlAttributePtr) cur);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cur->type == XML_ENTITY_DECL) {
|
if (cur->type == XML_ENTITY_DECL) {
|
||||||
xmlDumpEntityDecl(buf->buffer, (xmlEntityPtr) cur);
|
xmlBufDumpEntityDecl(buf->buffer, (xmlEntityPtr) cur);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (cur->type == XML_TEXT_NODE) {
|
if (cur->type == XML_TEXT_NODE) {
|
||||||
|
@ -1936,18 +2035,19 @@ xmlSaveSetAttrEscape(xmlSaveCtxtPtr ctxt, xmlCharEncodingOutputFunc escape)
|
||||||
* Public entry points based on buffers *
|
* Public entry points based on buffers *
|
||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlAttrSerializeTxtContent:
|
* xmlBufAttrSerializeTxtContent:
|
||||||
* @buf: the XML buffer output
|
* @buf: and xmlBufPtr output
|
||||||
* @doc: the document
|
* @doc: the document
|
||||||
* @attr: the attribute node
|
* @attr: the attribute node
|
||||||
* @string: the text content
|
* @string: the text content
|
||||||
*
|
*
|
||||||
* Serialize text attribute values to an xml simple buffer
|
* Serialize text attribute values to an xmlBufPtr
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
|
xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc,
|
||||||
xmlAttrPtr attr, const xmlChar * string)
|
xmlAttrPtr attr, const xmlChar * string)
|
||||||
{
|
{
|
||||||
xmlChar *base, *cur;
|
xmlChar *base, *cur;
|
||||||
|
|
||||||
|
@ -1957,44 +2057,44 @@ xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
|
||||||
while (*cur != 0) {
|
while (*cur != 0) {
|
||||||
if (*cur == '\n') {
|
if (*cur == '\n') {
|
||||||
if (base != cur)
|
if (base != cur)
|
||||||
xmlBufferAdd(buf, base, cur - base);
|
xmlBufAdd(buf, base, cur - base);
|
||||||
xmlBufferAdd(buf, BAD_CAST " ", 5);
|
xmlBufAdd(buf, BAD_CAST " ", 5);
|
||||||
cur++;
|
cur++;
|
||||||
base = cur;
|
base = cur;
|
||||||
} else if (*cur == '\r') {
|
} else if (*cur == '\r') {
|
||||||
if (base != cur)
|
if (base != cur)
|
||||||
xmlBufferAdd(buf, base, cur - base);
|
xmlBufAdd(buf, base, cur - base);
|
||||||
xmlBufferAdd(buf, BAD_CAST " ", 5);
|
xmlBufAdd(buf, BAD_CAST " ", 5);
|
||||||
cur++;
|
cur++;
|
||||||
base = cur;
|
base = cur;
|
||||||
} else if (*cur == '\t') {
|
} else if (*cur == '\t') {
|
||||||
if (base != cur)
|
if (base != cur)
|
||||||
xmlBufferAdd(buf, base, cur - base);
|
xmlBufAdd(buf, base, cur - base);
|
||||||
xmlBufferAdd(buf, BAD_CAST "	", 4);
|
xmlBufAdd(buf, BAD_CAST "	", 4);
|
||||||
cur++;
|
cur++;
|
||||||
base = cur;
|
base = cur;
|
||||||
} else if (*cur == '"') {
|
} else if (*cur == '"') {
|
||||||
if (base != cur)
|
if (base != cur)
|
||||||
xmlBufferAdd(buf, base, cur - base);
|
xmlBufAdd(buf, base, cur - base);
|
||||||
xmlBufferAdd(buf, BAD_CAST """, 6);
|
xmlBufAdd(buf, BAD_CAST """, 6);
|
||||||
cur++;
|
cur++;
|
||||||
base = cur;
|
base = cur;
|
||||||
} else if (*cur == '<') {
|
} else if (*cur == '<') {
|
||||||
if (base != cur)
|
if (base != cur)
|
||||||
xmlBufferAdd(buf, base, cur - base);
|
xmlBufAdd(buf, base, cur - base);
|
||||||
xmlBufferAdd(buf, BAD_CAST "<", 4);
|
xmlBufAdd(buf, BAD_CAST "<", 4);
|
||||||
cur++;
|
cur++;
|
||||||
base = cur;
|
base = cur;
|
||||||
} else if (*cur == '>') {
|
} else if (*cur == '>') {
|
||||||
if (base != cur)
|
if (base != cur)
|
||||||
xmlBufferAdd(buf, base, cur - base);
|
xmlBufAdd(buf, base, cur - base);
|
||||||
xmlBufferAdd(buf, BAD_CAST ">", 4);
|
xmlBufAdd(buf, BAD_CAST ">", 4);
|
||||||
cur++;
|
cur++;
|
||||||
base = cur;
|
base = cur;
|
||||||
} else if (*cur == '&') {
|
} else if (*cur == '&') {
|
||||||
if (base != cur)
|
if (base != cur)
|
||||||
xmlBufferAdd(buf, base, cur - base);
|
xmlBufAdd(buf, base, cur - base);
|
||||||
xmlBufferAdd(buf, BAD_CAST "&", 5);
|
xmlBufAdd(buf, BAD_CAST "&", 5);
|
||||||
cur++;
|
cur++;
|
||||||
base = cur;
|
base = cur;
|
||||||
} else if ((*cur >= 0x80) && ((doc == NULL) ||
|
} else if ((*cur >= 0x80) && ((doc == NULL) ||
|
||||||
|
@ -2002,17 +2102,17 @@ xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
|
||||||
/*
|
/*
|
||||||
* We assume we have UTF-8 content.
|
* We assume we have UTF-8 content.
|
||||||
*/
|
*/
|
||||||
unsigned char tmp[10];
|
unsigned char tmp[12];
|
||||||
int val = 0, l = 1;
|
int val = 0, l = 1;
|
||||||
|
|
||||||
if (base != cur)
|
if (base != cur)
|
||||||
xmlBufferAdd(buf, base, cur - base);
|
xmlBufAdd(buf, base, cur - base);
|
||||||
if (*cur < 0xC0) {
|
if (*cur < 0xC0) {
|
||||||
xmlSaveErr(XML_SAVE_NOT_UTF8, (xmlNodePtr) attr, NULL);
|
xmlSaveErr(XML_SAVE_NOT_UTF8, (xmlNodePtr) attr, NULL);
|
||||||
if (doc != NULL)
|
if (doc != NULL)
|
||||||
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
||||||
xmlSerializeHexCharRef(tmp, *cur);
|
xmlSerializeHexCharRef(tmp, *cur);
|
||||||
xmlBufferAdd(buf, (xmlChar *) tmp, -1);
|
xmlBufAdd(buf, (xmlChar *) tmp, -1);
|
||||||
cur++;
|
cur++;
|
||||||
base = cur;
|
base = cur;
|
||||||
continue;
|
continue;
|
||||||
|
@ -2044,7 +2144,7 @@ xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
|
||||||
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
|
||||||
|
|
||||||
xmlSerializeHexCharRef(tmp, *cur);
|
xmlSerializeHexCharRef(tmp, *cur);
|
||||||
xmlBufferAdd(buf, (xmlChar *) tmp, -1);
|
xmlBufAdd(buf, (xmlChar *) tmp, -1);
|
||||||
cur++;
|
cur++;
|
||||||
base = cur;
|
base = cur;
|
||||||
continue;
|
continue;
|
||||||
|
@ -2054,7 +2154,7 @@ xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
|
||||||
* as a char ref
|
* as a char ref
|
||||||
*/
|
*/
|
||||||
xmlSerializeHexCharRef(tmp, val);
|
xmlSerializeHexCharRef(tmp, val);
|
||||||
xmlBufferAdd(buf, (xmlChar *) tmp, -1);
|
xmlBufAdd(buf, (xmlChar *) tmp, -1);
|
||||||
cur += l;
|
cur += l;
|
||||||
base = cur;
|
base = cur;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2062,7 +2162,31 @@ xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (base != cur)
|
if (base != cur)
|
||||||
xmlBufferAdd(buf, base, cur - base);
|
xmlBufAdd(buf, base, cur - base);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlAttrSerializeTxtContent:
|
||||||
|
* @buf: the XML buffer output
|
||||||
|
* @doc: the document
|
||||||
|
* @attr: the attribute node
|
||||||
|
* @string: the text content
|
||||||
|
*
|
||||||
|
* Serialize text attribute values to an xml simple buffer
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
|
||||||
|
xmlAttrPtr attr, const xmlChar * string)
|
||||||
|
{
|
||||||
|
xmlBufPtr buffer;
|
||||||
|
|
||||||
|
if ((buf == NULL) || (string == NULL))
|
||||||
|
return;
|
||||||
|
buffer = xmlBufFromBuffer(buf);
|
||||||
|
if (buffer == NULL)
|
||||||
|
return;
|
||||||
|
xmlBufAttrSerializeTxtContent(buffer, doc, attr, string);
|
||||||
|
xmlBufBackToBuffer(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2076,6 +2200,8 @@ xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
|
||||||
* Dump an XML node, recursive behaviour,children are printed too.
|
* Dump an XML node, recursive behaviour,children are printed too.
|
||||||
* Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1
|
* Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1
|
||||||
* or xmlKeepBlanksDefault(0) was called
|
* or xmlKeepBlanksDefault(0) was called
|
||||||
|
* Since this is using xmlBuffer structures it is limited to 2GB and somehow
|
||||||
|
* deprecated, use xmlBufNodeDump() instead.
|
||||||
*
|
*
|
||||||
* Returns the number of bytes written to the buffer or -1 in case of error
|
* Returns the number of bytes written to the buffer or -1 in case of error
|
||||||
*/
|
*/
|
||||||
|
@ -2083,7 +2209,42 @@ int
|
||||||
xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
|
xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
|
||||||
int format)
|
int format)
|
||||||
{
|
{
|
||||||
unsigned int use;
|
xmlBufPtr buffer;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if ((buf == NULL) || (cur == NULL))
|
||||||
|
return(-1);
|
||||||
|
buffer = xmlBufFromBuffer(buf);
|
||||||
|
if (buffer == NULL)
|
||||||
|
return(-1);
|
||||||
|
ret = xmlBufNodeDump(buffer, doc, cur, level, format);
|
||||||
|
xmlBufBackToBuffer(buffer);
|
||||||
|
if (ret > INT_MAX)
|
||||||
|
return(-1);
|
||||||
|
return((int) ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlBufNodeDump:
|
||||||
|
* @buf: the XML buffer output
|
||||||
|
* @doc: the document
|
||||||
|
* @cur: the current node
|
||||||
|
* @level: the imbrication level for indenting
|
||||||
|
* @format: is formatting allowed
|
||||||
|
*
|
||||||
|
* Dump an XML node, recursive behaviour,children are printed too.
|
||||||
|
* Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1
|
||||||
|
* or xmlKeepBlanksDefault(0) was called
|
||||||
|
*
|
||||||
|
* Returns the number of bytes written to the buffer, in case of error 0
|
||||||
|
* is returned or @buf stores the error
|
||||||
|
*/
|
||||||
|
|
||||||
|
size_t
|
||||||
|
xmlBufNodeDump(xmlBufPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
|
||||||
|
int format)
|
||||||
|
{
|
||||||
|
size_t use;
|
||||||
int ret;
|
int ret;
|
||||||
xmlOutputBufferPtr outbuf;
|
xmlOutputBufferPtr outbuf;
|
||||||
|
|
||||||
|
@ -2116,10 +2277,10 @@ xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
|
||||||
outbuf->context = NULL;
|
outbuf->context = NULL;
|
||||||
outbuf->written = 0;
|
outbuf->written = 0;
|
||||||
|
|
||||||
use = buf->use;
|
use = xmlBufUse(buf);
|
||||||
xmlNodeDumpOutput(outbuf, doc, cur, level, format, NULL);
|
xmlNodeDumpOutput(outbuf, doc, cur, level, format, NULL);
|
||||||
xmlFree(outbuf);
|
xmlFree(outbuf);
|
||||||
ret = buf->use - use;
|
ret = xmlBufUse(buf) - use;
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2299,11 +2460,11 @@ xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, xmlChar **doc_txt_ptr,
|
||||||
xmlDocContentDumpOutput(&ctxt, out_doc);
|
xmlDocContentDumpOutput(&ctxt, out_doc);
|
||||||
xmlOutputBufferFlush(out_buff);
|
xmlOutputBufferFlush(out_buff);
|
||||||
if (out_buff->conv != NULL) {
|
if (out_buff->conv != NULL) {
|
||||||
*doc_txt_len = out_buff->conv->use;
|
*doc_txt_len = xmlBufUse(out_buff->conv);
|
||||||
*doc_txt_ptr = xmlStrndup(out_buff->conv->content, *doc_txt_len);
|
*doc_txt_ptr = xmlStrndup(xmlBufContent(out_buff->conv), *doc_txt_len);
|
||||||
} else {
|
} else {
|
||||||
*doc_txt_len = out_buff->buffer->use;
|
*doc_txt_len = xmlBufUse(out_buff->buffer);
|
||||||
*doc_txt_ptr = xmlStrndup(out_buff->buffer->content, *doc_txt_len);
|
*doc_txt_ptr = xmlStrndup(xmlBufContent(out_buff->buffer),*doc_txt_len);
|
||||||
}
|
}
|
||||||
(void)xmlOutputBufferClose(out_buff);
|
(void)xmlOutputBufferClose(out_buff);
|
||||||
|
|
||||||
|
|
130
reactos/lib/3rdparty/libxml2/xmlschemas.c
vendored
130
reactos/lib/3rdparty/libxml2/xmlschemas.c
vendored
|
@ -975,6 +975,7 @@ struct _xmlSchemaValidCtxt {
|
||||||
xmlSAXHandlerPtr sax;
|
xmlSAXHandlerPtr sax;
|
||||||
xmlParserCtxtPtr parserCtxt;
|
xmlParserCtxtPtr parserCtxt;
|
||||||
void *user_data; /* TODO: What is this for? */
|
void *user_data; /* TODO: What is this for? */
|
||||||
|
char *filename;
|
||||||
|
|
||||||
int err;
|
int err;
|
||||||
int nberrors;
|
int nberrors;
|
||||||
|
@ -1028,6 +1029,10 @@ struct _xmlSchemaValidCtxt {
|
||||||
int hasKeyrefs;
|
int hasKeyrefs;
|
||||||
int createIDCNodeTables;
|
int createIDCNodeTables;
|
||||||
int psviExposeIDCNodeTables;
|
int psviExposeIDCNodeTables;
|
||||||
|
|
||||||
|
/* Locator for error reporting in streaming mode */
|
||||||
|
xmlSchemaValidityLocatorFunc locFunc;
|
||||||
|
void *locCtxt;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2078,6 +2083,20 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
|
||||||
(vctxt->parserCtxt->input != NULL))
|
(vctxt->parserCtxt->input != NULL))
|
||||||
file = vctxt->parserCtxt->input->filename;
|
file = vctxt->parserCtxt->input->filename;
|
||||||
}
|
}
|
||||||
|
if (vctxt->locFunc != NULL) {
|
||||||
|
if ((file == NULL) || (line == 0)) {
|
||||||
|
unsigned long l;
|
||||||
|
const char *f;
|
||||||
|
vctxt->locFunc(vctxt->locCtxt, &f, &l);
|
||||||
|
if (file == NULL)
|
||||||
|
file = f;
|
||||||
|
if (line == 0)
|
||||||
|
line = (int) l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((file == NULL) && (vctxt->filename != NULL))
|
||||||
|
file = vctxt->filename;
|
||||||
|
|
||||||
__xmlRaiseError(schannel, channel, data, ctxt,
|
__xmlRaiseError(schannel, channel, data, ctxt,
|
||||||
node, XML_FROM_SCHEMASV,
|
node, XML_FROM_SCHEMASV,
|
||||||
error, errorLevel, file, line,
|
error, errorLevel, file, line,
|
||||||
|
@ -12938,6 +12957,15 @@ xmlSchemaBuildAContentModel(xmlSchemaParserCtxtPtr pctxt,
|
||||||
if (tmp2 != 1) ret = 0;
|
if (tmp2 != 1) ret = 0;
|
||||||
sub = sub->next;
|
sub = sub->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* epsilon needed to block previous trans from
|
||||||
|
* being allowed to enter back from another
|
||||||
|
* construct
|
||||||
|
*/
|
||||||
|
pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
|
||||||
|
pctxt->state, NULL);
|
||||||
|
|
||||||
if (particle->minOccurs == 0) {
|
if (particle->minOccurs == 0) {
|
||||||
xmlAutomataNewEpsilon(pctxt->am, oldstate,
|
xmlAutomataNewEpsilon(pctxt->am, oldstate,
|
||||||
pctxt->state);
|
pctxt->state);
|
||||||
|
@ -13946,7 +13974,7 @@ xmlSchemaCheckCOSNSSubset(xmlSchemaWildcardPtr sub,
|
||||||
*/
|
*/
|
||||||
if ((sub->negNsSet != NULL) &&
|
if ((sub->negNsSet != NULL) &&
|
||||||
(super->negNsSet != NULL) &&
|
(super->negNsSet != NULL) &&
|
||||||
(sub->negNsSet->value == sub->negNsSet->value))
|
(sub->negNsSet->value == super->negNsSet->value))
|
||||||
return (0);
|
return (0);
|
||||||
/*
|
/*
|
||||||
* 3.1 sub must be a set whose members are either namespace names or <EFBFBD>absent<EFBFBD>.
|
* 3.1 sub must be a set whose members are either namespace names or <EFBFBD>absent<EFBFBD>.
|
||||||
|
@ -15156,9 +15184,10 @@ xmlSchemaCheckSTPropsCorrect(xmlSchemaParserCtxtPtr ctxt,
|
||||||
FREE_AND_NULL(str)
|
FREE_AND_NULL(str)
|
||||||
return (XML_SCHEMAP_ST_PROPS_CORRECT_1);
|
return (XML_SCHEMAP_ST_PROPS_CORRECT_1);
|
||||||
}
|
}
|
||||||
if ( (WXS_IS_LIST(type) || WXS_IS_UNION(type)) &&
|
if ((WXS_IS_LIST(type) || WXS_IS_UNION(type)) &&
|
||||||
(WXS_IS_RESTRICTION(type) == 0) &&
|
(WXS_IS_RESTRICTION(type) == 0) &&
|
||||||
(! WXS_IS_ANY_SIMPLE_TYPE(baseType))) {
|
((! WXS_IS_ANY_SIMPLE_TYPE(baseType)) &&
|
||||||
|
(baseType->type != XML_SCHEMA_TYPE_SIMPLE))) {
|
||||||
xmlSchemaPCustomErr(ctxt,
|
xmlSchemaPCustomErr(ctxt,
|
||||||
XML_SCHEMAP_ST_PROPS_CORRECT_1,
|
XML_SCHEMAP_ST_PROPS_CORRECT_1,
|
||||||
WXS_BASIC_CAST type, NULL,
|
WXS_BASIC_CAST type, NULL,
|
||||||
|
@ -18475,8 +18504,8 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
|
||||||
particle->children->children =
|
particle->children->children =
|
||||||
(xmlSchemaTreeItemPtr) xmlSchemaAddParticle(pctxt,
|
(xmlSchemaTreeItemPtr) xmlSchemaAddParticle(pctxt,
|
||||||
type->node,
|
type->node,
|
||||||
((xmlSchemaParticlePtr) type->subtypes)->minOccurs,
|
((xmlSchemaParticlePtr) baseType->subtypes)->minOccurs,
|
||||||
((xmlSchemaParticlePtr) type->subtypes)->maxOccurs);
|
((xmlSchemaParticlePtr) baseType->subtypes)->maxOccurs);
|
||||||
if (particle->children->children == NULL)
|
if (particle->children->children == NULL)
|
||||||
goto exit_failure;
|
goto exit_failure;
|
||||||
particle = (xmlSchemaParticlePtr)
|
particle = (xmlSchemaParticlePtr)
|
||||||
|
@ -21936,7 +21965,7 @@ xmlSchemaVAddNodeQName(xmlSchemaValidCtxtPtr vctxt,
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* Validation of identity-constraints (IDC) *
|
* Validation of identity-constraints (IDC) *
|
||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
|
@ -27448,9 +27477,29 @@ xmlSchemaNewValidCtxt(xmlSchemaPtr schema)
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlSchemaValidateSetFilename:
|
||||||
|
* @vctxt: the schema validation context
|
||||||
|
* @filename: the file name
|
||||||
|
*
|
||||||
|
* Workaround to provide file error reporting information when this is
|
||||||
|
* not provided by current APIs
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt, const char *filename) {
|
||||||
|
if (vctxt == NULL)
|
||||||
|
return;
|
||||||
|
if (vctxt->filename != NULL)
|
||||||
|
xmlFree(vctxt->filename);
|
||||||
|
if (filename != NULL)
|
||||||
|
vctxt->filename = (char *) xmlStrdup((const xmlChar *) filename);
|
||||||
|
else
|
||||||
|
vctxt->filename = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlSchemaClearValidCtxt:
|
* xmlSchemaClearValidCtxt:
|
||||||
* @ctxt: the schema validation context
|
* @vctxt: the schema validation context
|
||||||
*
|
*
|
||||||
* Free the resources associated to the schema validation context;
|
* Free the resources associated to the schema validation context;
|
||||||
* leaves some fields alive intended for reuse of the context.
|
* leaves some fields alive intended for reuse of the context.
|
||||||
|
@ -27551,6 +27600,11 @@ xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt)
|
||||||
* where the user provides the dict?
|
* where the user provides the dict?
|
||||||
*/
|
*/
|
||||||
vctxt->dict = xmlDictCreate();
|
vctxt->dict = xmlDictCreate();
|
||||||
|
|
||||||
|
if (vctxt->filename != NULL) {
|
||||||
|
xmlFree(vctxt->filename);
|
||||||
|
vctxt->filename = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27636,6 +27690,8 @@ xmlSchemaFreeValidCtxt(xmlSchemaValidCtxtPtr ctxt)
|
||||||
xmlSchemaItemListFree(ctxt->nodeQNames);
|
xmlSchemaItemListFree(ctxt->nodeQNames);
|
||||||
if (ctxt->dict != NULL)
|
if (ctxt->dict != NULL)
|
||||||
xmlDictFree(ctxt->dict);
|
xmlDictFree(ctxt->dict);
|
||||||
|
if (ctxt->filename != NULL)
|
||||||
|
xmlFree(ctxt->filename);
|
||||||
xmlFree(ctxt);
|
xmlFree(ctxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28629,6 +28685,63 @@ xmlSchemaSAXUnplug(xmlSchemaSAXPlugPtr plug)
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlSchemaValidateSetLocator:
|
||||||
|
* @vctxt: a schema validation context
|
||||||
|
* @f: the locator function pointer
|
||||||
|
* @ctxt: the locator context
|
||||||
|
*
|
||||||
|
* Allows to set a locator function to the validation context,
|
||||||
|
* which will be used to provide file and line information since
|
||||||
|
* those are not provided as part of the SAX validation flow
|
||||||
|
* Setting @f to NULL disable the locator.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
xmlSchemaValidateSetLocator(xmlSchemaValidCtxtPtr vctxt,
|
||||||
|
xmlSchemaValidityLocatorFunc f,
|
||||||
|
void *ctxt)
|
||||||
|
{
|
||||||
|
if (vctxt == NULL) return;
|
||||||
|
vctxt->locFunc = f;
|
||||||
|
vctxt->locCtxt = ctxt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlSchemaValidateStreamLocator:
|
||||||
|
* @ctx: the xmlTextReaderPtr used
|
||||||
|
* @file: returned file information
|
||||||
|
* @line: returned line information
|
||||||
|
*
|
||||||
|
* Internal locator function for the readers
|
||||||
|
*
|
||||||
|
* Returns 0 in case the Schema validation could be (des)activated and
|
||||||
|
* -1 in case of error.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
xmlSchemaValidateStreamLocator(void *ctx, const char **file,
|
||||||
|
unsigned long *line) {
|
||||||
|
xmlParserCtxtPtr ctxt;
|
||||||
|
|
||||||
|
if ((ctx == NULL) || ((file == NULL) && (line == NULL)))
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
if (file != NULL)
|
||||||
|
*file = NULL;
|
||||||
|
if (line != NULL)
|
||||||
|
*line = 0;
|
||||||
|
|
||||||
|
ctxt = (xmlParserCtxtPtr) ctx;
|
||||||
|
if (ctxt->input != NULL) {
|
||||||
|
if (file != NULL)
|
||||||
|
*file = ctxt->input->filename;
|
||||||
|
if (line != NULL)
|
||||||
|
*line = ctxt->input->line;
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlSchemaValidateStream:
|
* xmlSchemaValidateStream:
|
||||||
* @ctxt: a schema validation context
|
* @ctxt: a schema validation context
|
||||||
|
@ -28672,6 +28785,7 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt,
|
||||||
xmlCtxtUseOptions(pctxt, options);
|
xmlCtxtUseOptions(pctxt, options);
|
||||||
#endif
|
#endif
|
||||||
pctxt->linenumbers = 1;
|
pctxt->linenumbers = 1;
|
||||||
|
xmlSchemaValidateSetLocator(ctxt, xmlSchemaValidateStreamLocator, pctxt);
|
||||||
|
|
||||||
inputStream = xmlNewIOInputStream(pctxt, input, enc);;
|
inputStream = xmlNewIOInputStream(pctxt, input, enc);;
|
||||||
if (inputStream == NULL) {
|
if (inputStream == NULL) {
|
||||||
|
|
|
@ -3569,8 +3569,8 @@ xmlSchemaCompareDurations(xmlSchemaValPtr x, xmlSchemaValPtr y)
|
||||||
|
|
||||||
/* seconds */
|
/* seconds */
|
||||||
sec = x->value.dur.sec - y->value.dur.sec;
|
sec = x->value.dur.sec - y->value.dur.sec;
|
||||||
carry = (long)sec / SECS_PER_DAY;
|
carry = (long)(sec / SECS_PER_DAY);
|
||||||
sec -= (double)(carry * SECS_PER_DAY);
|
sec -= ((double)carry) * SECS_PER_DAY;
|
||||||
|
|
||||||
/* days */
|
/* days */
|
||||||
day = x->value.dur.day - y->value.dur.day + carry;
|
day = x->value.dur.day - y->value.dur.day + carry;
|
||||||
|
@ -5122,7 +5122,7 @@ xmlSchemaValidateListSimpleTypeFacet(xmlSchemaFacetPtr facet,
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet,
|
xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet,
|
||||||
xmlSchemaTypeType valType,
|
xmlSchemaValType valType,
|
||||||
const xmlChar *value,
|
const xmlChar *value,
|
||||||
xmlSchemaValPtr val,
|
xmlSchemaValPtr val,
|
||||||
unsigned long *length,
|
unsigned long *length,
|
||||||
|
|
32
reactos/lib/3rdparty/libxml2/xmlwriter.c
vendored
32
reactos/lib/3rdparty/libxml2/xmlwriter.c
vendored
|
@ -21,6 +21,10 @@
|
||||||
|
|
||||||
#include <libxml/xmlwriter.h>
|
#include <libxml/xmlwriter.h>
|
||||||
|
|
||||||
|
#include "buf.h"
|
||||||
|
#include "enc.h"
|
||||||
|
#include "save.h"
|
||||||
|
|
||||||
#define B64LINELEN 72
|
#define B64LINELEN 72
|
||||||
#define B64CRLF "\r\n"
|
#define B64CRLF "\r\n"
|
||||||
|
|
||||||
|
@ -548,9 +552,9 @@ xmlTextWriterStartDocument(xmlTextWriterPtr writer, const char *version,
|
||||||
writer->out->encoder = encoder;
|
writer->out->encoder = encoder;
|
||||||
if (encoder != NULL) {
|
if (encoder != NULL) {
|
||||||
if (writer->out->conv == NULL) {
|
if (writer->out->conv == NULL) {
|
||||||
writer->out->conv = xmlBufferCreateSize(4000);
|
writer->out->conv = xmlBufCreateSize(4000);
|
||||||
}
|
}
|
||||||
xmlCharEncOutFunc(encoder, writer->out->conv, NULL);
|
xmlCharEncOutput(writer->out, 1);
|
||||||
if ((writer->doc != NULL) && (writer->doc->encoding == NULL))
|
if ((writer->doc != NULL) && (writer->doc->encoding == NULL))
|
||||||
writer->doc->encoding = xmlStrdup((xmlChar *)writer->out->encoder->name);
|
writer->doc->encoding = xmlStrdup((xmlChar *)writer->out->encoder->name);
|
||||||
} else
|
} else
|
||||||
|
@ -1501,8 +1505,8 @@ xmlTextWriterWriteString(xmlTextWriterPtr writer, const xmlChar * content)
|
||||||
break;
|
break;
|
||||||
case XML_TEXTWRITER_ATTRIBUTE:
|
case XML_TEXTWRITER_ATTRIBUTE:
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
xmlAttrSerializeTxtContent(writer->out->buffer, writer->doc,
|
xmlBufAttrSerializeTxtContent(writer->out->buffer,
|
||||||
NULL, content);
|
writer->doc, NULL, content);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -4605,6 +4609,26 @@ xmlTextWriterSetIndentString(xmlTextWriterPtr writer, const xmlChar * str)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlTextWriterSetQuoteChar:
|
||||||
|
* @writer: the xmlTextWriterPtr
|
||||||
|
* @quotechar: the quote character
|
||||||
|
*
|
||||||
|
* Set the character used for quoting attributes.
|
||||||
|
*
|
||||||
|
* Returns -1 on error or 0 otherwise.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar)
|
||||||
|
{
|
||||||
|
if ((writer == NULL) || ((quotechar != '\'') && (quotechar != '"')))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
writer->qchar = quotechar;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlTextWriterWriteIndent:
|
* xmlTextWriterWriteIndent:
|
||||||
* @writer: the xmlTextWriterPtr
|
* @writer: the xmlTextWriterPtr
|
||||||
|
|
690
reactos/lib/3rdparty/libxml2/xpath.c
vendored
690
reactos/lib/3rdparty/libxml2/xpath.c
vendored
File diff suppressed because it is too large
Load diff
46
reactos/lib/3rdparty/libxml2/xpointer.c
vendored
46
reactos/lib/3rdparty/libxml2/xpointer.c
vendored
|
@ -134,7 +134,7 @@ xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur, int *level);
|
||||||
static int
|
static int
|
||||||
xmlXPtrGetArity(xmlNodePtr cur) {
|
xmlXPtrGetArity(xmlNodePtr cur) {
|
||||||
int i;
|
int i;
|
||||||
if (cur == NULL)
|
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
|
||||||
return(-1);
|
return(-1);
|
||||||
cur = cur->children;
|
cur = cur->children;
|
||||||
for (i = 0;cur != NULL;cur = cur->next) {
|
for (i = 0;cur != NULL;cur = cur->next) {
|
||||||
|
@ -157,7 +157,7 @@ xmlXPtrGetArity(xmlNodePtr cur) {
|
||||||
static int
|
static int
|
||||||
xmlXPtrGetIndex(xmlNodePtr cur) {
|
xmlXPtrGetIndex(xmlNodePtr cur) {
|
||||||
int i;
|
int i;
|
||||||
if (cur == NULL)
|
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
|
||||||
return(-1);
|
return(-1);
|
||||||
for (i = 1;cur != NULL;cur = cur->prev) {
|
for (i = 1;cur != NULL;cur = cur->prev) {
|
||||||
if ((cur->type == XML_ELEMENT_NODE) ||
|
if ((cur->type == XML_ELEMENT_NODE) ||
|
||||||
|
@ -179,7 +179,7 @@ xmlXPtrGetIndex(xmlNodePtr cur) {
|
||||||
static xmlNodePtr
|
static xmlNodePtr
|
||||||
xmlXPtrGetNthChild(xmlNodePtr cur, int no) {
|
xmlXPtrGetNthChild(xmlNodePtr cur, int no) {
|
||||||
int i;
|
int i;
|
||||||
if (cur == NULL)
|
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
|
||||||
return(cur);
|
return(cur);
|
||||||
cur = cur->children;
|
cur = cur->children;
|
||||||
for (i = 0;i <= no;cur = cur->next) {
|
for (i = 0;i <= no;cur = cur->next) {
|
||||||
|
@ -1007,21 +1007,14 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
|
||||||
NEXT;
|
NEXT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*cur++ = CUR;
|
|
||||||
} else if (CUR == '(') {
|
} else if (CUR == '(') {
|
||||||
level++;
|
level++;
|
||||||
*cur++ = CUR;
|
|
||||||
} else if (CUR == '^') {
|
} else if (CUR == '^') {
|
||||||
NEXT;
|
if ((NXT(1) == ')') || (NXT(1) == '(') || (NXT(1) == '^')) {
|
||||||
if ((CUR == ')') || (CUR == '(') || (CUR == '^')) {
|
NEXT;
|
||||||
*cur++ = CUR;
|
}
|
||||||
} else {
|
|
||||||
*cur++ = '^';
|
|
||||||
*cur++ = CUR;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
*cur++ = CUR;
|
|
||||||
}
|
}
|
||||||
|
*cur++ = CUR;
|
||||||
NEXT;
|
NEXT;
|
||||||
}
|
}
|
||||||
*cur = 0;
|
*cur = 0;
|
||||||
|
@ -1269,6 +1262,7 @@ xmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) {
|
||||||
ctxt->valueNr = 0;
|
ctxt->valueNr = 0;
|
||||||
ctxt->valueMax = 10;
|
ctxt->valueMax = 10;
|
||||||
ctxt->value = NULL;
|
ctxt->value = NULL;
|
||||||
|
ctxt->valueFrame = 0;
|
||||||
}
|
}
|
||||||
SKIP_BLANKS;
|
SKIP_BLANKS;
|
||||||
if (CUR == '/') {
|
if (CUR == '/') {
|
||||||
|
@ -1450,11 +1444,13 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
start = (xmlNodePtr) range->user;
|
start = (xmlNodePtr) range->user;
|
||||||
|
|
||||||
if (start == NULL)
|
if ((start == NULL) || (start->type == XML_NAMESPACE_DECL))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
end = range->user2;
|
end = range->user2;
|
||||||
if (end == NULL)
|
if (end == NULL)
|
||||||
return(xmlCopyNode(start, 1));
|
return(xmlCopyNode(start, 1));
|
||||||
|
if (end->type == XML_NAMESPACE_DECL)
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
cur = start;
|
cur = start;
|
||||||
index1 = range->index;
|
index1 = range->index;
|
||||||
|
@ -2310,7 +2306,7 @@ xmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt, int nargs) {
|
||||||
xmlNodePtr
|
xmlNodePtr
|
||||||
xmlXPtrAdvanceNode(xmlNodePtr cur, int *level) {
|
xmlXPtrAdvanceNode(xmlNodePtr cur, int *level) {
|
||||||
next:
|
next:
|
||||||
if (cur == NULL)
|
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
|
||||||
return(NULL);
|
return(NULL);
|
||||||
if (cur->children != NULL) {
|
if (cur->children != NULL) {
|
||||||
cur = cur->children ;
|
cur = cur->children ;
|
||||||
|
@ -2368,7 +2364,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *indx, int bytes) {
|
||||||
if ((node == NULL) || (indx == NULL))
|
if ((node == NULL) || (indx == NULL))
|
||||||
return(-1);
|
return(-1);
|
||||||
cur = *node;
|
cur = *node;
|
||||||
if (cur == NULL)
|
if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
|
||||||
return(-1);
|
return(-1);
|
||||||
pos = *indx;
|
pos = *indx;
|
||||||
|
|
||||||
|
@ -2459,9 +2455,10 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
|
||||||
|
|
||||||
if (string == NULL)
|
if (string == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
if (start == NULL)
|
if ((start == NULL) || (start->type == XML_NAMESPACE_DECL))
|
||||||
return(-1);
|
return(-1);
|
||||||
if ((end == NULL) || (endindex == NULL))
|
if ((end == NULL) || (*end == NULL) ||
|
||||||
|
((*end)->type == XML_NAMESPACE_DECL) || (endindex == NULL))
|
||||||
return(-1);
|
return(-1);
|
||||||
cur = start;
|
cur = start;
|
||||||
if (cur == NULL)
|
if (cur == NULL)
|
||||||
|
@ -2544,13 +2541,12 @@ xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
|
||||||
|
|
||||||
if (string == NULL)
|
if (string == NULL)
|
||||||
return(-1);
|
return(-1);
|
||||||
if ((start == NULL) || (startindex == NULL))
|
if ((start == NULL) || (*start == NULL) ||
|
||||||
|
((*start)->type == XML_NAMESPACE_DECL) || (startindex == NULL))
|
||||||
return(-1);
|
return(-1);
|
||||||
if ((end == NULL) || (endindex == NULL))
|
if ((end == NULL) || (endindex == NULL))
|
||||||
return(-1);
|
return(-1);
|
||||||
cur = *start;
|
cur = *start;
|
||||||
if (cur == NULL)
|
|
||||||
return(-1);
|
|
||||||
pos = *startindex - 1;
|
pos = *startindex - 1;
|
||||||
first = string[0];
|
first = string[0];
|
||||||
|
|
||||||
|
@ -2624,14 +2620,12 @@ xmlXPtrGetLastChar(xmlNodePtr *node, int *indx) {
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
int pos, len = 0;
|
int pos, len = 0;
|
||||||
|
|
||||||
if ((node == NULL) || (indx == NULL))
|
if ((node == NULL) || (*node == NULL) ||
|
||||||
|
((*node)->type == XML_NAMESPACE_DECL) || (indx == NULL))
|
||||||
return(-1);
|
return(-1);
|
||||||
cur = *node;
|
cur = *node;
|
||||||
pos = *indx;
|
pos = *indx;
|
||||||
|
|
||||||
if (cur == NULL)
|
|
||||||
return(-1);
|
|
||||||
|
|
||||||
if ((cur->type == XML_ELEMENT_NODE) ||
|
if ((cur->type == XML_ELEMENT_NODE) ||
|
||||||
(cur->type == XML_DOCUMENT_NODE) ||
|
(cur->type == XML_DOCUMENT_NODE) ||
|
||||||
(cur->type == XML_HTML_DOCUMENT_NODE)) {
|
(cur->type == XML_HTML_DOCUMENT_NODE)) {
|
||||||
|
|
755
reactos/lib/3rdparty/libxml2/xzlib.c
vendored
Normal file
755
reactos/lib/3rdparty/libxml2/xzlib.c
vendored
Normal file
|
@ -0,0 +1,755 @@
|
||||||
|
/**
|
||||||
|
* xzlib.c: front end for the transparent suport of lzma compression
|
||||||
|
* at the I/O layer, based on an example file from lzma project
|
||||||
|
*
|
||||||
|
* See Copyright for the status of this software.
|
||||||
|
*
|
||||||
|
* Anders F Bjorklund <afb@users.sourceforge.net>
|
||||||
|
*/
|
||||||
|
#define IN_LIBXML
|
||||||
|
#include "libxml.h"
|
||||||
|
#ifdef HAVE_LZMA_H
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#ifdef HAVE_ERRNO_H
|
||||||
|
#include <errno.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
|
#include <sys/types.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_SYS_STAT_H
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_FCNTL_H
|
||||||
|
#include <fcntl.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STDLIB_H
|
||||||
|
#include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_ZLIB_H
|
||||||
|
#include <zlib.h>
|
||||||
|
#endif
|
||||||
|
#include <lzma.h>
|
||||||
|
|
||||||
|
#include "xzlib.h"
|
||||||
|
#include <libxml/xmlmemory.h>
|
||||||
|
|
||||||
|
/* values for xz_state how */
|
||||||
|
#define LOOK 0 /* look for a gzip/lzma header */
|
||||||
|
#define COPY 1 /* copy input directly */
|
||||||
|
#define GZIP 2 /* decompress a gzip stream */
|
||||||
|
#define LZMA 3 /* decompress a lzma stream */
|
||||||
|
|
||||||
|
/* internal lzma file state data structure */
|
||||||
|
typedef struct {
|
||||||
|
int mode; /* see lzma modes above */
|
||||||
|
int fd; /* file descriptor */
|
||||||
|
char *path; /* path or fd for error messages */
|
||||||
|
uint64_t pos; /* current position in uncompressed data */
|
||||||
|
unsigned int size; /* buffer size, zero if not allocated yet */
|
||||||
|
unsigned int want; /* requested buffer size, default is BUFSIZ */
|
||||||
|
unsigned char *in; /* input buffer */
|
||||||
|
unsigned char *out; /* output buffer (double-sized when reading) */
|
||||||
|
unsigned char *next; /* next output data to deliver or write */
|
||||||
|
unsigned int have; /* amount of output data unused at next */
|
||||||
|
int eof; /* true if end of input file reached */
|
||||||
|
uint64_t start; /* where the lzma data started, for rewinding */
|
||||||
|
uint64_t raw; /* where the raw data started, for seeking */
|
||||||
|
int how; /* 0: get header, 1: copy, 2: decompress */
|
||||||
|
int direct; /* true if last read direct, false if lzma */
|
||||||
|
/* seek request */
|
||||||
|
uint64_t skip; /* amount to skip (already rewound if backwards) */
|
||||||
|
int seek; /* true if seek request pending */
|
||||||
|
/* error information */
|
||||||
|
int err; /* error code */
|
||||||
|
char *msg; /* error message */
|
||||||
|
/* lzma stream */
|
||||||
|
int init; /* is the iniflate stream initialized */
|
||||||
|
lzma_stream strm; /* stream structure in-place (not a pointer) */
|
||||||
|
char padding1[32]; /* padding allowing to cope with possible
|
||||||
|
extensions of above structure without
|
||||||
|
too much side effect */
|
||||||
|
#ifdef HAVE_ZLIB_H
|
||||||
|
/* zlib inflate or deflate stream */
|
||||||
|
z_stream zstrm; /* stream structure in-place (not a pointer) */
|
||||||
|
#endif
|
||||||
|
char padding2[32]; /* padding allowing to cope with possible
|
||||||
|
extensions of above structure without
|
||||||
|
too much side effect */
|
||||||
|
} xz_state, *xz_statep;
|
||||||
|
|
||||||
|
static void
|
||||||
|
xz_error(xz_statep state, int err, const char *msg)
|
||||||
|
{
|
||||||
|
/* free previously allocated message and clear */
|
||||||
|
if (state->msg != NULL) {
|
||||||
|
if (state->err != LZMA_MEM_ERROR)
|
||||||
|
xmlFree(state->msg);
|
||||||
|
state->msg = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set error code, and if no message, then done */
|
||||||
|
state->err = err;
|
||||||
|
if (msg == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* for an out of memory error, save as static string */
|
||||||
|
if (err == LZMA_MEM_ERROR) {
|
||||||
|
state->msg = (char *) msg;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* construct error message with path */
|
||||||
|
if ((state->msg =
|
||||||
|
xmlMalloc(strlen(state->path) + strlen(msg) + 3)) == NULL) {
|
||||||
|
state->err = LZMA_MEM_ERROR;
|
||||||
|
state->msg = (char *) "out of memory";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
strcpy(state->msg, state->path);
|
||||||
|
strcat(state->msg, ": ");
|
||||||
|
strcat(state->msg, msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xz_reset(xz_statep state)
|
||||||
|
{
|
||||||
|
state->have = 0; /* no output data available */
|
||||||
|
state->eof = 0; /* not at end of file */
|
||||||
|
state->how = LOOK; /* look for gzip header */
|
||||||
|
state->direct = 1; /* default for empty file */
|
||||||
|
state->seek = 0; /* no seek request pending */
|
||||||
|
xz_error(state, LZMA_OK, NULL); /* clear error */
|
||||||
|
state->pos = 0; /* no uncompressed data yet */
|
||||||
|
state->strm.avail_in = 0; /* no input data yet */
|
||||||
|
#ifdef HAVE_ZLIB_H
|
||||||
|
state->zstrm.avail_in = 0; /* no input data yet */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static xzFile
|
||||||
|
xz_open(const char *path, int fd, const char *mode ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
xz_statep state;
|
||||||
|
|
||||||
|
/* allocate xzFile structure to return */
|
||||||
|
state = xmlMalloc(sizeof(xz_state));
|
||||||
|
if (state == NULL)
|
||||||
|
return NULL;
|
||||||
|
state->size = 0; /* no buffers allocated yet */
|
||||||
|
state->want = BUFSIZ; /* requested buffer size */
|
||||||
|
state->msg = NULL; /* no error message yet */
|
||||||
|
state->init = 0; /* initialization of zlib data */
|
||||||
|
|
||||||
|
/* save the path name for error messages */
|
||||||
|
state->path = xmlMalloc(strlen(path) + 1);
|
||||||
|
if (state->path == NULL) {
|
||||||
|
xmlFree(state);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
strcpy(state->path, path);
|
||||||
|
|
||||||
|
/* open the file with the appropriate mode (or just use fd) */
|
||||||
|
state->fd = fd != -1 ? fd : open(path,
|
||||||
|
#ifdef O_LARGEFILE
|
||||||
|
O_LARGEFILE |
|
||||||
|
#endif
|
||||||
|
#ifdef O_BINARY
|
||||||
|
O_BINARY |
|
||||||
|
#endif
|
||||||
|
O_RDONLY, 0666);
|
||||||
|
if (state->fd == -1) {
|
||||||
|
xmlFree(state->path);
|
||||||
|
xmlFree(state);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* save the current position for rewinding (only if reading) */
|
||||||
|
state->start = lseek(state->fd, 0, SEEK_CUR);
|
||||||
|
if (state->start == (uint64_t) - 1)
|
||||||
|
state->start = 0;
|
||||||
|
|
||||||
|
/* initialize stream */
|
||||||
|
xz_reset(state);
|
||||||
|
|
||||||
|
/* return stream */
|
||||||
|
return (xzFile) state;
|
||||||
|
}
|
||||||
|
|
||||||
|
xzFile
|
||||||
|
__libxml2_xzopen(const char *path, const char *mode)
|
||||||
|
{
|
||||||
|
return xz_open(path, -1, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
xzFile
|
||||||
|
__libxml2_xzdopen(int fd, const char *mode)
|
||||||
|
{
|
||||||
|
char *path; /* identifier for error messages */
|
||||||
|
xzFile xz;
|
||||||
|
|
||||||
|
if (fd == -1 || (path = xmlMalloc(7 + 3 * sizeof(int))) == NULL)
|
||||||
|
return NULL;
|
||||||
|
sprintf(path, "<fd:%d>", fd); /* for debugging */
|
||||||
|
xz = xz_open(path, fd, mode);
|
||||||
|
xmlFree(path);
|
||||||
|
return xz;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
xz_load(xz_statep state, unsigned char *buf, unsigned int len,
|
||||||
|
unsigned int *have)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
*have = 0;
|
||||||
|
do {
|
||||||
|
ret = read(state->fd, buf + *have, len - *have);
|
||||||
|
if (ret <= 0)
|
||||||
|
break;
|
||||||
|
*have += ret;
|
||||||
|
} while (*have < len);
|
||||||
|
if (ret < 0) {
|
||||||
|
xz_error(state, -1, strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (ret == 0)
|
||||||
|
state->eof = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
xz_avail(xz_statep state)
|
||||||
|
{
|
||||||
|
lzma_stream *strm = &(state->strm);
|
||||||
|
|
||||||
|
if (state->err != LZMA_OK)
|
||||||
|
return -1;
|
||||||
|
if (state->eof == 0) {
|
||||||
|
/* avail_in is size_t, which is not necessary sizeof(unsigned) */
|
||||||
|
unsigned tmp = strm->avail_in;
|
||||||
|
|
||||||
|
if (xz_load(state, state->in, state->size, &tmp) == -1) {
|
||||||
|
strm->avail_in = tmp;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
strm->avail_in = tmp;
|
||||||
|
strm->next_in = state->in;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
is_format_xz(xz_statep state)
|
||||||
|
{
|
||||||
|
lzma_stream *strm = &(state->strm);
|
||||||
|
|
||||||
|
return strm->avail_in >= 6 && memcmp(state->in, "\3757zXZ", 6) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
is_format_lzma(xz_statep state)
|
||||||
|
{
|
||||||
|
lzma_stream *strm = &(state->strm);
|
||||||
|
|
||||||
|
lzma_filter filter;
|
||||||
|
lzma_options_lzma *opt;
|
||||||
|
uint32_t dict_size;
|
||||||
|
uint64_t uncompressed_size;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (strm->avail_in < 13)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
filter.id = LZMA_FILTER_LZMA1;
|
||||||
|
if (lzma_properties_decode(&filter, NULL, state->in, 5) != LZMA_OK)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
opt = filter.options;
|
||||||
|
dict_size = opt->dict_size;
|
||||||
|
free(opt); /* we can't use xmlFree on a string returned by zlib */
|
||||||
|
|
||||||
|
/* A hack to ditch tons of false positives: We allow only dictionary
|
||||||
|
* sizes that are 2^n or 2^n + 2^(n-1) or UINT32_MAX. LZMA_Alone
|
||||||
|
* created only files with 2^n, but accepts any dictionary size.
|
||||||
|
* If someone complains, this will be reconsidered.
|
||||||
|
*/
|
||||||
|
if (dict_size != UINT32_MAX) {
|
||||||
|
uint32_t d = dict_size - 1;
|
||||||
|
|
||||||
|
d |= d >> 2;
|
||||||
|
d |= d >> 3;
|
||||||
|
d |= d >> 4;
|
||||||
|
d |= d >> 8;
|
||||||
|
d |= d >> 16;
|
||||||
|
++d;
|
||||||
|
if (d != dict_size || dict_size == 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Another hack to ditch false positives: Assume that if the
|
||||||
|
* uncompressed size is known, it must be less than 256 GiB.
|
||||||
|
* Again, if someone complains, this will be reconsidered.
|
||||||
|
*/
|
||||||
|
uncompressed_size = 0;
|
||||||
|
for (i = 0; i < 8; ++i)
|
||||||
|
uncompressed_size |= (uint64_t) (state->in[5 + i]) << (i * 8);
|
||||||
|
|
||||||
|
if (uncompressed_size != UINT64_MAX
|
||||||
|
&& uncompressed_size > (UINT64_C(1) << 38))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_ZLIB_H
|
||||||
|
|
||||||
|
/* Get next byte from input, or -1 if end or error. */
|
||||||
|
#define NEXT() ((strm->avail_in == 0 && xz_avail(state) == -1) ? -1 : \
|
||||||
|
(strm->avail_in == 0 ? -1 : \
|
||||||
|
(strm->avail_in--, *(strm->next_in)++)))
|
||||||
|
|
||||||
|
/* Get a four-byte little-endian integer and return 0 on success and the value
|
||||||
|
in *ret. Otherwise -1 is returned and *ret is not modified. */
|
||||||
|
static int
|
||||||
|
gz_next4(xz_statep state, unsigned long *ret)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
unsigned long val;
|
||||||
|
z_streamp strm = &(state->zstrm);
|
||||||
|
|
||||||
|
val = NEXT();
|
||||||
|
val += (unsigned) NEXT() << 8;
|
||||||
|
val += (unsigned long) NEXT() << 16;
|
||||||
|
ch = NEXT();
|
||||||
|
if (ch == -1)
|
||||||
|
return -1;
|
||||||
|
val += (unsigned long) ch << 24;
|
||||||
|
*ret = val;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int
|
||||||
|
xz_head(xz_statep state)
|
||||||
|
{
|
||||||
|
lzma_stream *strm = &(state->strm);
|
||||||
|
lzma_stream init = LZMA_STREAM_INIT;
|
||||||
|
int flags;
|
||||||
|
unsigned len;
|
||||||
|
|
||||||
|
/* allocate read buffers and inflate memory */
|
||||||
|
if (state->size == 0) {
|
||||||
|
/* allocate buffers */
|
||||||
|
state->in = xmlMalloc(state->want);
|
||||||
|
state->out = xmlMalloc(state->want << 1);
|
||||||
|
if (state->in == NULL || state->out == NULL) {
|
||||||
|
if (state->out != NULL)
|
||||||
|
xmlFree(state->out);
|
||||||
|
if (state->in != NULL)
|
||||||
|
xmlFree(state->in);
|
||||||
|
xz_error(state, LZMA_MEM_ERROR, "out of memory");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
state->size = state->want;
|
||||||
|
|
||||||
|
/* allocate decoder memory */
|
||||||
|
state->strm = init;
|
||||||
|
state->strm.avail_in = 0;
|
||||||
|
state->strm.next_in = NULL;
|
||||||
|
if (lzma_auto_decoder(&state->strm, UINT64_MAX, 0) != LZMA_OK) {
|
||||||
|
xmlFree(state->out);
|
||||||
|
xmlFree(state->in);
|
||||||
|
state->size = 0;
|
||||||
|
xz_error(state, LZMA_MEM_ERROR, "out of memory");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#ifdef HAVE_ZLIB_H
|
||||||
|
/* allocate inflate memory */
|
||||||
|
state->zstrm.zalloc = Z_NULL;
|
||||||
|
state->zstrm.zfree = Z_NULL;
|
||||||
|
state->zstrm.opaque = Z_NULL;
|
||||||
|
state->zstrm.avail_in = 0;
|
||||||
|
state->zstrm.next_in = Z_NULL;
|
||||||
|
if (state->init == 0) {
|
||||||
|
if (inflateInit2(&(state->zstrm), -15) != Z_OK) {/* raw inflate */
|
||||||
|
xmlFree(state->out);
|
||||||
|
xmlFree(state->in);
|
||||||
|
state->size = 0;
|
||||||
|
xz_error(state, LZMA_MEM_ERROR, "out of memory");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
state->init = 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get some data in the input buffer */
|
||||||
|
if (strm->avail_in == 0) {
|
||||||
|
if (xz_avail(state) == -1)
|
||||||
|
return -1;
|
||||||
|
if (strm->avail_in == 0)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* look for the xz magic header bytes */
|
||||||
|
if (is_format_xz(state) || is_format_lzma(state)) {
|
||||||
|
state->how = LZMA;
|
||||||
|
state->direct = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#ifdef HAVE_ZLIB_H
|
||||||
|
/* look for the gzip magic header bytes 31 and 139 */
|
||||||
|
if (strm->next_in[0] == 31) {
|
||||||
|
strm->avail_in--;
|
||||||
|
strm->next_in++;
|
||||||
|
if (strm->avail_in == 0 && xz_avail(state) == -1)
|
||||||
|
return -1;
|
||||||
|
if (strm->avail_in && strm->next_in[0] == 139) {
|
||||||
|
/* we have a gzip header, woo hoo! */
|
||||||
|
strm->avail_in--;
|
||||||
|
strm->next_in++;
|
||||||
|
|
||||||
|
/* skip rest of header */
|
||||||
|
if (NEXT() != 8) { /* compression method */
|
||||||
|
xz_error(state, LZMA_DATA_ERROR,
|
||||||
|
"unknown compression method");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
flags = NEXT();
|
||||||
|
if (flags & 0xe0) { /* reserved flag bits */
|
||||||
|
xz_error(state, LZMA_DATA_ERROR,
|
||||||
|
"unknown header flags set");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
NEXT(); /* modification time */
|
||||||
|
NEXT();
|
||||||
|
NEXT();
|
||||||
|
NEXT();
|
||||||
|
NEXT(); /* extra flags */
|
||||||
|
NEXT(); /* operating system */
|
||||||
|
if (flags & 4) { /* extra field */
|
||||||
|
len = (unsigned) NEXT();
|
||||||
|
len += (unsigned) NEXT() << 8;
|
||||||
|
while (len--)
|
||||||
|
if (NEXT() < 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (flags & 8) /* file name */
|
||||||
|
while (NEXT() > 0) ;
|
||||||
|
if (flags & 16) /* comment */
|
||||||
|
while (NEXT() > 0) ;
|
||||||
|
if (flags & 2) { /* header crc */
|
||||||
|
NEXT();
|
||||||
|
NEXT();
|
||||||
|
}
|
||||||
|
/* an unexpected end of file is not checked for here -- it will be
|
||||||
|
* noticed on the first request for uncompressed data */
|
||||||
|
|
||||||
|
/* set up for decompression */
|
||||||
|
inflateReset(&state->zstrm);
|
||||||
|
state->zstrm.adler = crc32(0L, Z_NULL, 0);
|
||||||
|
state->how = GZIP;
|
||||||
|
state->direct = 0;
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
/* not a gzip file -- save first byte (31) and fall to raw i/o */
|
||||||
|
state->out[0] = 31;
|
||||||
|
state->have = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* doing raw i/o, save start of raw data for seeking, copy any leftover
|
||||||
|
* input to output -- this assumes that the output buffer is larger than
|
||||||
|
* the input buffer, which also assures space for gzungetc() */
|
||||||
|
state->raw = state->pos;
|
||||||
|
state->next = state->out;
|
||||||
|
if (strm->avail_in) {
|
||||||
|
memcpy(state->next + state->have, strm->next_in, strm->avail_in);
|
||||||
|
state->have += strm->avail_in;
|
||||||
|
strm->avail_in = 0;
|
||||||
|
}
|
||||||
|
state->how = COPY;
|
||||||
|
state->direct = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
xz_decomp(xz_statep state)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
unsigned had;
|
||||||
|
unsigned long crc, len;
|
||||||
|
lzma_stream *strm = &(state->strm);
|
||||||
|
|
||||||
|
lzma_action action = LZMA_RUN;
|
||||||
|
|
||||||
|
/* fill output buffer up to end of deflate stream */
|
||||||
|
had = strm->avail_out;
|
||||||
|
do {
|
||||||
|
/* get more input for inflate() */
|
||||||
|
if (strm->avail_in == 0 && xz_avail(state) == -1)
|
||||||
|
return -1;
|
||||||
|
if (strm->avail_in == 0) {
|
||||||
|
xz_error(state, LZMA_DATA_ERROR, "unexpected end of file");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (state->eof)
|
||||||
|
action = LZMA_FINISH;
|
||||||
|
|
||||||
|
/* decompress and handle errors */
|
||||||
|
#ifdef HAVE_ZLIB_H
|
||||||
|
if (state->how == GZIP) {
|
||||||
|
state->zstrm.avail_in = (uInt) state->strm.avail_in;
|
||||||
|
state->zstrm.next_in = (Bytef *) state->strm.next_in;
|
||||||
|
state->zstrm.avail_out = (uInt) state->strm.avail_out;
|
||||||
|
state->zstrm.next_out = (Bytef *) state->strm.next_out;
|
||||||
|
ret = inflate(&state->zstrm, Z_NO_FLUSH);
|
||||||
|
if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {
|
||||||
|
xz_error(state, Z_STREAM_ERROR,
|
||||||
|
"internal error: inflate stream corrupt");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (ret == Z_MEM_ERROR)
|
||||||
|
ret = LZMA_MEM_ERROR;
|
||||||
|
if (ret == Z_DATA_ERROR)
|
||||||
|
ret = LZMA_DATA_ERROR;
|
||||||
|
if (ret == Z_STREAM_END)
|
||||||
|
ret = LZMA_STREAM_END;
|
||||||
|
state->strm.avail_in = state->zstrm.avail_in;
|
||||||
|
state->strm.next_in = state->zstrm.next_in;
|
||||||
|
state->strm.avail_out = state->zstrm.avail_out;
|
||||||
|
state->strm.next_out = state->zstrm.next_out;
|
||||||
|
} else /* state->how == LZMA */
|
||||||
|
#endif
|
||||||
|
ret = lzma_code(strm, action);
|
||||||
|
if (ret == LZMA_MEM_ERROR) {
|
||||||
|
xz_error(state, LZMA_MEM_ERROR, "out of memory");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (ret == LZMA_DATA_ERROR) {
|
||||||
|
xz_error(state, LZMA_DATA_ERROR, "compressed data error");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} while (strm->avail_out && ret != LZMA_STREAM_END);
|
||||||
|
|
||||||
|
/* update available output and crc check value */
|
||||||
|
state->have = had - strm->avail_out;
|
||||||
|
state->next = strm->next_out - state->have;
|
||||||
|
#ifdef HAVE_ZLIB_H
|
||||||
|
state->zstrm.adler =
|
||||||
|
crc32(state->zstrm.adler, state->next, state->have);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (ret == LZMA_STREAM_END) {
|
||||||
|
#ifdef HAVE_ZLIB_H
|
||||||
|
if (state->how == GZIP) {
|
||||||
|
if (gz_next4(state, &crc) == -1 || gz_next4(state, &len) == -1) {
|
||||||
|
xz_error(state, LZMA_DATA_ERROR, "unexpected end of file");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (crc != state->zstrm.adler) {
|
||||||
|
xz_error(state, LZMA_DATA_ERROR, "incorrect data check");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (len != (state->zstrm.total_out & 0xffffffffL)) {
|
||||||
|
xz_error(state, LZMA_DATA_ERROR, "incorrect length check");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
state->strm.avail_in = 0;
|
||||||
|
state->strm.next_in = NULL;
|
||||||
|
state->strm.avail_out = 0;
|
||||||
|
state->strm.next_out = NULL;
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
if (strm->avail_in != 0 || !state->eof) {
|
||||||
|
xz_error(state, LZMA_DATA_ERROR, "trailing garbage");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
state->how = LOOK; /* ready for next stream, once have is 0 (leave
|
||||||
|
* state->direct unchanged to remember how) */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* good decompression */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
xz_make(xz_statep state)
|
||||||
|
{
|
||||||
|
lzma_stream *strm = &(state->strm);
|
||||||
|
|
||||||
|
if (state->how == LOOK) { /* look for lzma / gzip header */
|
||||||
|
if (xz_head(state) == -1)
|
||||||
|
return -1;
|
||||||
|
if (state->have) /* got some data from xz_head() */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (state->how == COPY) { /* straight copy */
|
||||||
|
if (xz_load(state, state->out, state->size << 1, &(state->have)) ==
|
||||||
|
-1)
|
||||||
|
return -1;
|
||||||
|
state->next = state->out;
|
||||||
|
} else if (state->how == LZMA || state->how == GZIP) { /* decompress */
|
||||||
|
strm->avail_out = state->size << 1;
|
||||||
|
strm->next_out = state->out;
|
||||||
|
if (xz_decomp(state) == -1)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
xz_skip(xz_statep state, uint64_t len)
|
||||||
|
{
|
||||||
|
unsigned n;
|
||||||
|
|
||||||
|
/* skip over len bytes or reach end-of-file, whichever comes first */
|
||||||
|
while (len)
|
||||||
|
/* skip over whatever is in output buffer */
|
||||||
|
if (state->have) {
|
||||||
|
n = (uint64_t) state->have > len ?
|
||||||
|
(unsigned) len : state->have;
|
||||||
|
state->have -= n;
|
||||||
|
state->next += n;
|
||||||
|
state->pos += n;
|
||||||
|
len -= n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* output buffer empty -- return if we're at the end of the input */
|
||||||
|
else if (state->eof && state->strm.avail_in == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* need more data to skip -- load up output buffer */
|
||||||
|
else {
|
||||||
|
/* get more output, looking for header if required */
|
||||||
|
if (xz_make(state) == -1)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
__libxml2_xzread(xzFile file, void *buf, unsigned len)
|
||||||
|
{
|
||||||
|
unsigned got, n;
|
||||||
|
xz_statep state;
|
||||||
|
lzma_stream *strm;
|
||||||
|
|
||||||
|
/* get internal structure */
|
||||||
|
if (file == NULL)
|
||||||
|
return -1;
|
||||||
|
state = (xz_statep) file;
|
||||||
|
strm = &(state->strm);
|
||||||
|
|
||||||
|
/* check that we're reading and that there's no error */
|
||||||
|
if (state->err != LZMA_OK)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* since an int is returned, make sure len fits in one, otherwise return
|
||||||
|
* with an error (this avoids the flaw in the interface) */
|
||||||
|
if ((int) len < 0) {
|
||||||
|
xz_error(state, LZMA_BUF_ERROR,
|
||||||
|
"requested length does not fit in int");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if len is zero, avoid unnecessary operations */
|
||||||
|
if (len == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* process a skip request */
|
||||||
|
if (state->seek) {
|
||||||
|
state->seek = 0;
|
||||||
|
if (xz_skip(state, state->skip) == -1)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get len bytes to buf, or less than len if at the end */
|
||||||
|
got = 0;
|
||||||
|
do {
|
||||||
|
/* first just try copying data from the output buffer */
|
||||||
|
if (state->have) {
|
||||||
|
n = state->have > len ? len : state->have;
|
||||||
|
memcpy(buf, state->next, n);
|
||||||
|
state->next += n;
|
||||||
|
state->have -= n;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* output buffer empty -- return if we're at the end of the input */
|
||||||
|
else if (state->eof && strm->avail_in == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* need output data -- for small len or new stream load up our output
|
||||||
|
* buffer */
|
||||||
|
else if (state->how == LOOK || len < (state->size << 1)) {
|
||||||
|
/* get more output, looking for header if required */
|
||||||
|
if (xz_make(state) == -1)
|
||||||
|
return -1;
|
||||||
|
continue; /* no progress yet -- go back to memcpy() above */
|
||||||
|
/* the copy above assures that we will leave with space in the
|
||||||
|
* output buffer, allowing at least one gzungetc() to succeed */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* large len -- read directly into user buffer */
|
||||||
|
else if (state->how == COPY) { /* read directly */
|
||||||
|
if (xz_load(state, buf, len, &n) == -1)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* large len -- decompress directly into user buffer */
|
||||||
|
else { /* state->how == LZMA */
|
||||||
|
strm->avail_out = len;
|
||||||
|
strm->next_out = buf;
|
||||||
|
if (xz_decomp(state) == -1)
|
||||||
|
return -1;
|
||||||
|
n = state->have;
|
||||||
|
state->have = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* update progress */
|
||||||
|
len -= n;
|
||||||
|
buf = (char *) buf + n;
|
||||||
|
got += n;
|
||||||
|
state->pos += n;
|
||||||
|
} while (len);
|
||||||
|
|
||||||
|
/* return number of bytes read into user buffer (will fit in int) */
|
||||||
|
return (int) got;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
__libxml2_xzclose(xzFile file)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
xz_statep state;
|
||||||
|
|
||||||
|
/* get internal structure */
|
||||||
|
if (file == NULL)
|
||||||
|
return LZMA_DATA_ERROR;
|
||||||
|
state = (xz_statep) file;
|
||||||
|
|
||||||
|
/* free memory and close file */
|
||||||
|
if (state->size) {
|
||||||
|
lzma_end(&(state->strm));
|
||||||
|
#ifdef HAVE_ZLIB_H
|
||||||
|
if (state->init == 1)
|
||||||
|
inflateEnd(&(state->zstrm));
|
||||||
|
state->init = 0;
|
||||||
|
#endif
|
||||||
|
xmlFree(state->out);
|
||||||
|
xmlFree(state->in);
|
||||||
|
}
|
||||||
|
xmlFree(state->path);
|
||||||
|
ret = close(state->fd);
|
||||||
|
xmlFree(state);
|
||||||
|
return ret ? ret : LZMA_OK;
|
||||||
|
}
|
||||||
|
#endif /* HAVE_LZMA_H */
|
18
reactos/lib/3rdparty/libxml2/xzlib.h
vendored
Normal file
18
reactos/lib/3rdparty/libxml2/xzlib.h
vendored
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
/**
|
||||||
|
* xzlib.h: header for the front end for the transparent suport of lzma
|
||||||
|
* compression at the I/O layer
|
||||||
|
*
|
||||||
|
* See Copyright for the status of this software.
|
||||||
|
*
|
||||||
|
* Anders F Bjorklund <afb@users.sourceforge.net>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LIBXML2_XZLIB_H
|
||||||
|
#define LIBXML2_XZLIB_H
|
||||||
|
typedef void *xzFile; /* opaque lzma file descriptor */
|
||||||
|
|
||||||
|
xzFile __libxml2_xzopen(const char *path, const char *mode);
|
||||||
|
xzFile __libxml2_xzdopen(int fd, const char *mode);
|
||||||
|
int __libxml2_xzread(xzFile file, void *buf, unsigned len);
|
||||||
|
int __libxml2_xzclose(xzFile file);
|
||||||
|
#endif /* LIBXML2_XZLIB_H */
|
Loading…
Add table
Add a link
Reference in a new issue