ReactOS  0.4.15-dev-341-g17c5fb8
parser.c File Reference
#include "libxml.h"
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <stdarg.h>
#include <stddef.h>
#include <libxml/xmlmemory.h>
#include <libxml/threads.h>
#include <libxml/globals.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/valid.h>
#include <libxml/entities.h>
#include <libxml/xmlerror.h>
#include <libxml/encoding.h>
#include <libxml/xmlIO.h>
#include <libxml/uri.h>
#include <ctype.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "buf.h"
#include "enc.h"
#include "elfgcchack.h"
Include dependency graph for parser.c:

Go to the source code of this file.

Classes

struct  _xmlDefAttrs
 

Macros

#define IN_LIBXML
 
#define XML_DIR_SEP   '/'
 
#define XML_PARSER_BIG_ENTITY   1000
 
#define XML_PARSER_LOT_ENTITY   5000
 
#define XML_PARSER_NON_LINEAR   10
 
#define SAX2   1
 
#define XML_PARSER_BIG_BUFFER_SIZE   300
 
#define XML_PARSER_BUFFER_SIZE   100
 
#define SAX_COMPAT_MODE   BAD_CAST "SAX compatibility mode document"
 
#define XML_PARSER_CHUNK_SIZE   100
 
#define RAW   (*ctxt->input->cur)
 
#define CUR   (*ctxt->input->cur)
 
#define NXT(val)   ctxt->input->cur[(val)]
 
#define CUR_PTR   ctxt->input->cur
 
#define BASE_PTR   ctxt->input->base
 
#define CMP4(s, c1, c2, c3, c4)
 
#define CMP5(s, c1, c2, c3, c4, c5)   ( CMP4( s, c1, c2, c3, c4 ) && ((unsigned char *) s)[ 4 ] == c5 )
 
#define CMP6(s, c1, c2, c3, c4, c5, c6)   ( CMP5( s, c1, c2, c3, c4, c5 ) && ((unsigned char *) s)[ 5 ] == c6 )
 
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)   ( CMP6( s, c1, c2, c3, c4, c5, c6 ) && ((unsigned char *) s)[ 6 ] == c7 )
 
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)   ( CMP7( s, c1, c2, c3, c4, c5, c6, c7 ) && ((unsigned char *) s)[ 7 ] == c8 )
 
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
 
#define CMP10(s, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10)
 
#define SKIP(val)
 
#define SKIPL(val)
 
#define SHRINK
 
#define GROW
 
#define SKIP_BLANKS   xmlSkipBlankChars(ctxt)
 
#define NEXT   xmlNextChar(ctxt)
 
#define NEXT1
 
#define NEXTL(l)
 
#define CUR_CHAR(l)   xmlCurrentChar(ctxt, &l)
 
#define CUR_SCHAR(s, l)   xmlStringCurrentChar(ctxt, s, &l)
 
#define COPY_BUF(l, b, i, v)
 
#define growBuffer(buffer, n)
 

Typedefs

typedef struct _xmlDefAttrs xmlDefAttrs
 
typedef xmlDefAttrsxmlDefAttrsPtr
 

Functions

static void xmlFatalErr (xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
 
static int xmlParserEntityCheck (xmlParserCtxtPtr ctxt, size_t size, xmlEntityPtr ent, size_t replacement)
 
static void xmlErrAttributeDup (xmlParserCtxtPtr ctxt, const xmlChar *prefix, const xmlChar *localname)
 
static void LIBXML_ATTR_FORMAT (3, 0)
 
int xmlHasFeature (xmlFeature feature)
 
static void xmlDetectSAX2 (xmlParserCtxtPtr ctxt)
 
static xmlCharxmlAttrNormalizeSpace (const xmlChar *src, xmlChar *dst)
 
static const xmlCharxmlAttrNormalizeSpace2 (xmlParserCtxtPtr ctxt, xmlChar *src, int *len)
 
static void xmlAddDefAttrs (xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, const xmlChar *value)
 
static void xmlAddSpecialAttr (xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, int type)
 
static void xmlCleanSpecialAttrCallback (void *payload, void *data, const xmlChar *fullname, const xmlChar *fullattr, const xmlChar *unused ATTRIBUTE_UNUSED)
 
static void xmlCleanSpecialAttr (xmlParserCtxtPtr ctxt)
 
int xmlCheckLanguageID (const xmlChar *lang)
 
static int nsPush (xmlParserCtxtPtr ctxt, const xmlChar *prefix, const xmlChar *URL)
 
static int nsPop (xmlParserCtxtPtr ctxt, int nr)
 
static int xmlCtxtGrowAttrs (xmlParserCtxtPtr ctxt, int nr)
 
int inputPush (xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
 
xmlParserInputPtr inputPop (xmlParserCtxtPtr ctxt)
 
int nodePush (xmlParserCtxtPtr ctxt, xmlNodePtr value)
 
xmlNodePtr nodePop (xmlParserCtxtPtr ctxt)
 
static int nameNsPush (xmlParserCtxtPtr ctxt, const xmlChar *value, const xmlChar *prefix, const xmlChar *URI, int nsNr)
 
int namePush (xmlParserCtxtPtr ctxt, const xmlChar *value)
 
const xmlCharnamePop (xmlParserCtxtPtr ctxt)
 
static int spacePush (xmlParserCtxtPtr ctxt, int val)
 
static int spacePop (xmlParserCtxtPtr ctxt)
 
static void xmlSHRINK (xmlParserCtxtPtr ctxt)
 
static void xmlGROW (xmlParserCtxtPtr ctxt)
 
int xmlSkipBlankChars (xmlParserCtxtPtr ctxt)
 
xmlChar xmlPopInput (xmlParserCtxtPtr ctxt)
 
int xmlPushInput (xmlParserCtxtPtr ctxt, xmlParserInputPtr input)
 
int xmlParseCharRef (xmlParserCtxtPtr ctxt)
 
static int xmlParseStringCharRef (xmlParserCtxtPtr ctxt, const xmlChar **str)
 
void xmlParserHandlePEReference (xmlParserCtxtPtr ctxt)
 
xmlCharxmlStringLenDecodeEntities (xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int what, xmlChar end, xmlChar end2, xmlChar end3)
 
xmlCharxmlStringDecodeEntities (xmlParserCtxtPtr ctxt, const xmlChar *str, int what, xmlChar end, xmlChar end2, xmlChar end3)
 
static int areBlanks (xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int blank_chars)
 
: the name of the element being defined.

xmlParseElementContentDecl: @ctxt: an XML parser context

Returns
: the Element Content pointer will be stored here if any

parse the declaration for an Element content either Mixed or Children, the cases EMPTY and ANY are handled directly in xmlParseElementDecl

[46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children

returns: the type of element content XML_ELEMENT_TYPE_xxx

static xmlEntityPtr xmlParseStringPEReference (xmlParserCtxtPtr ctxt, const xmlChar **str)
 
static int xmlLoadEntityContent (xmlParserCtxtPtr ctxt, xmlEntityPtr entity)
 
static xmlEntityPtr xmlParseStringEntityRef (xmlParserCtxtPtr ctxt, const xmlChar **str)
 
int xmlParseElementContentDecl (xmlParserCtxtPtr ctxt, const xmlChar *name, xmlElementContentPtr *result)
 
int xmlParseElementDecl (xmlParserCtxtPtr ctxt)
 
static void xmlParseConditionalSections (xmlParserCtxtPtr ctxt)
 
void xmlParseMarkupDecl (xmlParserCtxtPtr ctxt)
 
void xmlParseTextDecl (xmlParserCtxtPtr ctxt)
 
void xmlParseExternalSubset (xmlParserCtxtPtr ctxt, const xmlChar *ExternalID, const xmlChar *SystemID)
 
void xmlParseReference (xmlParserCtxtPtr ctxt)
 
xmlEntityPtr xmlParseEntityRef (xmlParserCtxtPtr ctxt)
 
void xmlParsePEReference (xmlParserCtxtPtr ctxt)
 
void xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt)
 
static void xmlParseInternalSubset (xmlParserCtxtPtr ctxt)
 
static const xmlCharxmlGetNamespace (xmlParserCtxtPtr ctxt, const xmlChar *prefix)
 
static const xmlCharxmlParseQName (xmlParserCtxtPtr ctxt, const xmlChar **prefix)
 

Variables

unsigned int xmlParserMaxDepth = 256
 
static const charxmlW3CPIs []
 

: an XML parser context

xmlSplitQName: @ctxt: an XML parser context

@prefix: a xmlChar **

parse an UTF8 encoded XML qualified name string

[NS 5] QName ::= (Prefix ':')? LocalPart

[NS 6] Prefix ::= NCName

[NS 7] LocalPart ::= NCName

Returns the local part, and prefix is updated to get the Prefix if any.

static const unsigned char test_char_data [256]
 
xmlCharxmlSplitQName (xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix)
 
static int xmlIsNameStartChar (xmlParserCtxtPtr ctxt, int c)
 
static int xmlIsNameChar (xmlParserCtxtPtr ctxt, int c)
 
static xmlCharxmlParseAttValueInternal (xmlParserCtxtPtr ctxt, int *len, int *alloc, int normalize)
 
static const xmlCharxmlParseNameComplex (xmlParserCtxtPtr ctxt)
 
const xmlCharxmlParseName (xmlParserCtxtPtr ctxt)
 
static const xmlCharxmlParseNCNameComplex (xmlParserCtxtPtr ctxt)
 
static const xmlCharxmlParseNCName (xmlParserCtxtPtr ctxt)
 
static const xmlCharxmlParseNameAndCompare (xmlParserCtxtPtr ctxt, xmlChar const *other)
 
static xmlCharxmlParseStringName (xmlParserCtxtPtr ctxt, const xmlChar **str)
 
xmlCharxmlParseNmtoken (xmlParserCtxtPtr ctxt)
 
xmlCharxmlParseEntityValue (xmlParserCtxtPtr ctxt, xmlChar **orig)
 
static xmlCharxmlParseAttValueComplex (xmlParserCtxtPtr ctxt, int *attlen, int normalize)
 
xmlCharxmlParseAttValue (xmlParserCtxtPtr ctxt)
 
xmlCharxmlParseSystemLiteral (xmlParserCtxtPtr ctxt)
 
xmlCharxmlParsePubidLiteral (xmlParserCtxtPtr ctxt)
 
static void xmlParseCharDataComplex (xmlParserCtxtPtr ctxt, int cdata)
 
void xmlParseCharData (xmlParserCtxtPtr ctxt, int cdata)
 
xmlCharxmlParseExternalID (xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict)
 
static void xmlParseCommentComplex (xmlParserCtxtPtr ctxt, xmlChar *buf, size_t len, size_t size)
 
void xmlParseComment (xmlParserCtxtPtr ctxt)
 
const xmlCharxmlParsePITarget (xmlParserCtxtPtr ctxt)
 
void xmlParsePI (xmlParserCtxtPtr ctxt)
 
void xmlParseNotationDecl (xmlParserCtxtPtr ctxt)
 
void xmlParseEntityDecl (xmlParserCtxtPtr ctxt)
 
int xmlParseDefaultDecl (xmlParserCtxtPtr ctxt, xmlChar **value)
 
xmlEnumerationPtr xmlParseNotationType (xmlParserCtxtPtr ctxt)
 
xmlEnumerationPtr xmlParseEnumerationType (xmlParserCtxtPtr ctxt)
 
int xmlParseEnumeratedType (xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
 
int xmlParseAttributeType (xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
 
void xmlParseAttributeListDecl (xmlParserCtxtPtr ctxt)
 
xmlElementContentPtr xmlParseElementMixedContentDecl (xmlParserCtxtPtr ctxt, int inputchk)
 
static xmlElementContentPtr xmlParseElementChildrenContentDeclPriv (xmlParserCtxtPtr ctxt, int inputchk, int depth)
 
xmlElementContentPtr xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk)
 

: the localname

xmlParseQNameAndCompare: @ctxt: an XML parser context

@prefix: the prefix, if any.

parse an XML name and compares for match (specialized for endtag parsing)

Returns NULL for an illegal name, (xmlChar*) 1 for success and the name for mismatch

#define GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end)
 
#define DICT_FREE(str)
 
#define bottom_parser
 
static int xmlParserInitialized = 0
 
static xmlParserCtxtPtr xmlCreateEntityParserCtxtInternal (const xmlChar *URL, const xmlChar *ID, const xmlChar *base, xmlParserCtxtPtr pctx)
 
static void xmlHaltParser (xmlParserCtxtPtr ctxt)
 
static int xmlParseElementStart (xmlParserCtxtPtr ctxt)
 
static void xmlParseElementEnd (xmlParserCtxtPtr ctxt)
 
static xmlParserErrors xmlParseExternalEntityPrivate (xmlDocPtr doc, xmlParserCtxtPtr oldctxt, xmlSAXHandlerPtr sax, void *user_data, int depth, const xmlChar *URL, const xmlChar *ID, xmlNodePtr *list)
 
static int xmlCtxtUseOptionsInternal (xmlParserCtxtPtr ctxt, int options, const char *encoding)
 
static xmlParserErrors xmlParseBalancedChunkMemoryInternal (xmlParserCtxtPtr oldctxt, const xmlChar *string, void *user_data, xmlNodePtr *lst)
 
static const xmlCharxmlParseQNameAndCompare (xmlParserCtxtPtr ctxt, xmlChar const *name, xmlChar const *prefix)
 
static const xmlCharxmlParseAttribute2 (xmlParserCtxtPtr ctxt, const xmlChar *pref, const xmlChar *elem, const xmlChar **prefix, xmlChar **value, int *len, int *alloc)
 
static const xmlCharxmlParseStartTag2 (xmlParserCtxtPtr ctxt, const xmlChar **pref, const xmlChar **URI, int *tlen)
 
static void xmlParseEndTag2 (xmlParserCtxtPtr ctxt, const xmlChar *prefix, const xmlChar *URI, int line, int nsNr, int tlen)
 
void xmlParseCDSect (xmlParserCtxtPtr ctxt)
 
void xmlParseContent (xmlParserCtxtPtr ctxt)
 
void xmlParseElement (xmlParserCtxtPtr ctxt)
 
xmlCharxmlParseVersionNum (xmlParserCtxtPtr ctxt)
 
xmlCharxmlParseVersionInfo (xmlParserCtxtPtr ctxt)
 
xmlCharxmlParseEncName (xmlParserCtxtPtr ctxt)
 
const xmlCharxmlParseEncodingDecl (xmlParserCtxtPtr ctxt)
 
int xmlParseSDDecl (xmlParserCtxtPtr ctxt)
 
void xmlParseXMLDecl (xmlParserCtxtPtr ctxt)
 
void xmlParseMisc (xmlParserCtxtPtr ctxt)
 
int xmlParseDocument (xmlParserCtxtPtr ctxt)
 
int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt)
 
void xmlStopParser (xmlParserCtxtPtr ctxt)
 
xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax, void *user_data, xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc)
 
int xmlParseCtxtExternalEntity (xmlParserCtxtPtr ctx, const xmlChar *URL, const xmlChar *ID, xmlNodePtr *lst)
 
xmlParserErrors xmlParseInNodeContext (xmlNodePtr node, const char *data, int datalen, int options, xmlNodePtr *lst)
 
xmlParserCtxtPtr xmlCreateEntityParserCtxt (const xmlChar *URL, const xmlChar *ID, const xmlChar *base)
 
xmlParserCtxtPtr xmlCreateURLParserCtxt (const char *filename, int options)
 
xmlParserCtxtPtr xmlCreateFileParserCtxt (const char *filename)
 
xmlParserCtxtPtr xmlCreateMemoryParserCtxt (const char *buffer, int size)
 
xmlParserCtxtPtr xmlCreateDocParserCtxt (const xmlChar *cur)
 
void XMLCDECL xmlGenericErrorDefaultFunc (void *ctx, const char *msg,...)
 
void xmlInitParser (void)
 
void xmlCleanupParser (void)
 
void xmlCtxtReset (xmlParserCtxtPtr ctxt)
 
int xmlCtxtResetPush (xmlParserCtxtPtr ctxt, const char *chunk, int size, const char *filename, const char *encoding)
 
int xmlCtxtUseOptions (xmlParserCtxtPtr ctxt, int options)
 
static xmlDocPtr xmlDoRead (xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
 
xmlDocPtr xmlReadDoc (const xmlChar *cur, const char *URL, const char *encoding, int options)
 
xmlDocPtr xmlReadFile (const char *filename, const char *encoding, int options)
 
xmlDocPtr xmlReadMemory (const char *buffer, int size, const char *URL, const char *encoding, int options)
 
xmlDocPtr xmlReadFd (int fd, const char *URL, const char *encoding, int options)
 
xmlDocPtr xmlReadIO (xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options)
 
xmlDocPtr xmlCtxtReadDoc (xmlParserCtxtPtr ctxt, const xmlChar *cur, const char *URL, const char *encoding, int options)
 
xmlDocPtr xmlCtxtReadFile (xmlParserCtxtPtr ctxt, const char *filename, const char *encoding, int options)
 
xmlDocPtr xmlCtxtReadMemory (xmlParserCtxtPtr ctxt, const char *buffer, int size, const char *URL, const char *encoding, int options)
 
xmlDocPtr xmlCtxtReadFd (xmlParserCtxtPtr ctxt, int fd, const char *URL, const char *encoding, int options)
 
xmlDocPtr xmlCtxtReadIO (xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, const char *URL, const char *encoding, int options)
 

Macro Definition Documentation

◆ BASE_PTR

#define BASE_PTR   ctxt->input->base

Definition at line 2037 of file parser.c.

◆ bottom_parser

#define bottom_parser

Definition at line 15604 of file parser.c.

◆ CMP10

#define CMP10 (   s,
  c1,
  c2,
  c3,
  c4,
  c5,
  c6,
  c7,
  c8,
  c9,
  c10 
)
Value:
( CMP9( s, c1, c2, c3, c4, c5, c6, c7, c8, c9 ) && \
((unsigned char *) s)[ 9 ] == c10 )
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2050
GLdouble s
Definition: gl.h:2039

Definition at line 2053 of file parser.c.

◆ CMP4

#define CMP4 (   s,
  c1,
  c2,
  c3,
  c4 
)
Value:
( ((unsigned char *) s)[ 0 ] == c1 && ((unsigned char *) s)[ 1 ] == c2 && \
((unsigned char *) s)[ 2 ] == c3 && ((unsigned char *) s)[ 3 ] == c4 )
GLdouble s
Definition: gl.h:2039

Definition at line 2039 of file parser.c.

◆ CMP5

#define CMP5 (   s,
  c1,
  c2,
  c3,
  c4,
  c5 
)    ( CMP4( s, c1, c2, c3, c4 ) && ((unsigned char *) s)[ 4 ] == c5 )

Definition at line 2042 of file parser.c.

◆ CMP6

#define CMP6 (   s,
  c1,
  c2,
  c3,
  c4,
  c5,
  c6 
)    ( CMP5( s, c1, c2, c3, c4, c5 ) && ((unsigned char *) s)[ 5 ] == c6 )

Definition at line 2044 of file parser.c.

◆ CMP7

#define CMP7 (   s,
  c1,
  c2,
  c3,
  c4,
  c5,
  c6,
  c7 
)    ( CMP6( s, c1, c2, c3, c4, c5, c6 ) && ((unsigned char *) s)[ 6 ] == c7 )

Definition at line 2046 of file parser.c.

◆ CMP8

#define CMP8 (   s,
  c1,
  c2,
  c3,
  c4,
  c5,
  c6,
  c7,
  c8 
)    ( CMP7( s, c1, c2, c3, c4, c5, c6, c7 ) && ((unsigned char *) s)[ 7 ] == c8 )

Definition at line 2048 of file parser.c.

◆ CMP9

#define CMP9 (   s,
  c1,
  c2,
  c3,
  c4,
  c5,
  c6,
  c7,
  c8,
  c9 
)
Value:
( CMP8( s, c1, c2, c3, c4, c5, c6, c7, c8 ) && \
((unsigned char *) s)[ 8 ] == c9 )
GLdouble s
Definition: gl.h:2039
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2048

Definition at line 2050 of file parser.c.

◆ COPY_BUF

#define COPY_BUF (   l,
  b,
  i,
  v 
)
Value:
if (l == 1) b[i++] = (xmlChar) v; \
else i += xmlCopyCharMultiByte(&b[i],v)
XMLPUBFUN int XMLCALL xmlCopyCharMultiByte(xmlChar *out, int val)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
r l[0]
Definition: byte_order.h:167
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
unsigned char xmlChar
Definition: xmlstring.h:28
const GLdouble * v
Definition: gl.h:2040

Definition at line 2137 of file parser.c.

◆ CUR

#define CUR   (*ctxt->input->cur)

Definition at line 2034 of file parser.c.

◆ CUR_CHAR

#define CUR_CHAR (   l)    xmlCurrentChar(ctxt, &l)

Definition at line 2134 of file parser.c.

◆ CUR_PTR

#define CUR_PTR   ctxt->input->cur

Definition at line 2036 of file parser.c.

◆ CUR_SCHAR

#define CUR_SCHAR (   s,
  l 
)    xmlStringCurrentChar(ctxt, s, &l)

Definition at line 2135 of file parser.c.

◆ DICT_FREE

#define DICT_FREE (   str)
Value:
if ((str) && ((!dict) || \
(xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
xmlFree((char *)(str));
const WCHAR * str
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN int XMLCALL xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1218

DICT_FREE: @str: a string

Free a string if it is not owned by the "dict" dictionary in the current scope

Definition at line 14835 of file parser.c.

◆ GROW

#define GROW
Value:
if ((ctxt->progressive == 0) && \
(ctxt->input->end - ctxt->input->cur < INPUT_CHUNK)) \
xmlGROW (ctxt);
#define INPUT_CHUNK

Definition at line 2087 of file parser.c.

◆ GROW_PARSE_ATT_VALUE_INTERNAL

#define GROW_PARSE_ATT_VALUE_INTERNAL (   ctxt,
  in,
  start,
  end 
)
Value:
const xmlChar *oldbase = ctxt->input->base;\
GROW;\
if (ctxt->instate == XML_PARSER_EOF)\
return(NULL);\
if (oldbase != ctxt->input->base) {\
ptrdiff_t delta = ctxt->input->base - oldbase;\
start = start + delta;\
in = in + delta;\
}\
end = ctxt->input->end;
smooth NULL
Definition: ftsmooth.c:416
unsigned char xmlChar
Definition: xmlstring.h:28
GLuint in
Definition: glext.h:9616
GLuint start
Definition: gl.h:1545

xmlParseAttValueInternal: @ctxt: an XML parser context @len: attribute len result @alloc: whether the attribute was reallocated as a new string @normalize: if 1 then further non-CDATA normalization must be done

parse a value for an attribute. NOTE: if no normalization is needed, the routine will return pointers directly from the data buffer.

3.3.3 Attribute-Value Normalization: Before the value of an attribute is passed to the application or checked for validity, the XML processor must normalize it as follows:

  • a character reference is processed by appending the referenced character to the attribute value
  • an entity reference is processed by recursively processing the replacement text of the entity
  • a whitespace character (#x20, #xD, #xA, #x9) is processed by appending #x20 to the normalized value, except that only a single #x20 is appended for a "#xD#xA" sequence that is part of an external parsed entity or the literal entity value of an internal parsed entity
  • other characters are processed by appending them to the normalized value If the declared value is not CDATA, then the XML processor must further process the normalized attribute value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) characters by a single space (#x20) character. All attributes for which no declaration has been read should be treated by a non-validating parser as if declared CDATA.

Returns the AttValue parsed or NULL. The value has to be freed by the caller if it was copied, this can be detected by val[*len] == 0.

Definition at line 8872 of file parser.c.

◆ growBuffer

#define growBuffer (   buffer,
  n 
)
Value:
{ \
xmlChar *tmp; \
size_t new_size = buffer##_size * 2 + n; \
if (new_size < buffer##_size) goto mem_error; \
tmp = (xmlChar *) xmlRealloc(buffer, new_size); \
if (tmp == NULL) goto mem_error; \
buffer = tmp; \
buffer##_size = new_size; \
}
GLdouble n
Definition: glext.h:7729
GLuint buffer
Definition: glext.h:5915
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
unsigned char xmlChar
Definition: xmlstring.h:28

Definition at line 2580 of file parser.c.

◆ IN_LIBXML

#define IN_LIBXML

Definition at line 38 of file parser.c.

◆ NEXT

#define NEXT   xmlNextChar(ctxt)

Definition at line 2117 of file parser.c.

◆ NEXT1

#define NEXT1
Value:
{ \
ctxt->input->col++; \
ctxt->input->cur++; \
ctxt->nbChars++; \
if (*ctxt->input->cur == 0) \
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); \
}
#define INPUT_CHUNK

Definition at line 2119 of file parser.c.

◆ NEXTL

#define NEXTL (   l)
Value:
do { \
if (*(ctxt->input->cur) == '\n') { \
ctxt->input->line++; ctxt->input->col = 1; \
} else ctxt->input->col++; \
ctxt->input->cur += l; \
} while (0)
r l[0]
Definition: byte_order.h:167

Definition at line 2127 of file parser.c.

◆ NXT

#define NXT (   val)    ctxt->input->cur[(val)]

Definition at line 2035 of file parser.c.

◆ RAW

#define RAW   (*ctxt->input->cur)

Definition at line 2033 of file parser.c.

◆ SAX2

#define SAX2   1

Definition at line 255 of file parser.c.

◆ SAX_COMPAT_MODE

#define SAX_COMPAT_MODE   BAD_CAST "SAX compatibility mode document"

Definition at line 258 of file parser.c.

◆ SHRINK

#define SHRINK
Value:
if ((ctxt->progressive == 0) && \
(ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \
(ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \
xmlSHRINK (ctxt);
#define INPUT_CHUNK

Definition at line 2076 of file parser.c.

◆ SKIP

#define SKIP (   val)
Value:
do { \
ctxt->nbChars += (val),ctxt->input->cur += (val),ctxt->input->col+=(val); \
if (*ctxt->input->cur == 0) \
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); \
} while (0)
GLuint GLfloat * val
Definition: glext.h:7180
#define INPUT_CHUNK

Definition at line 2057 of file parser.c.

◆ SKIP_BLANKS

#define SKIP_BLANKS   xmlSkipBlankChars(ctxt)

Definition at line 2115 of file parser.c.

◆ SKIPL

#define SKIPL (   val)
Value:
do { \
int skipl; \
for(skipl=0; skipl<val; skipl++) { \
if (*(ctxt->input->cur) == '\n') { \
ctxt->input->line++; ctxt->input->col = 1; \
} else ctxt->input->col++; \
ctxt->nbChars++; \
ctxt->input->cur++; \
} \
if (*ctxt->input->cur == 0) \
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); \
} while (0)
GLuint GLfloat * val
Definition: glext.h:7180
#define INPUT_CHUNK

Definition at line 2063 of file parser.c.

◆ XML_DIR_SEP

#define XML_DIR_SEP   '/'

Definition at line 44 of file parser.c.

◆ XML_PARSER_BIG_BUFFER_SIZE

#define XML_PARSER_BIG_BUFFER_SIZE   300

Definition at line 256 of file parser.c.

◆ XML_PARSER_BIG_ENTITY

#define XML_PARSER_BIG_ENTITY   1000

Definition at line 111 of file parser.c.

◆ XML_PARSER_BUFFER_SIZE

#define XML_PARSER_BUFFER_SIZE   100

Definition at line 257 of file parser.c.

◆ XML_PARSER_CHUNK_SIZE

#define XML_PARSER_CHUNK_SIZE   100

XML_PARSER_CHUNK_SIZE

When calling GROW that's the minimal amount of data the parser expected to have received. It is not a hard limit but an optimization when reading strings like Names It is not strictly needed as long as inputs available characters are followed by 0, which should be provided by the I/O level

Definition at line 269 of file parser.c.

◆ XML_PARSER_LOT_ENTITY

#define XML_PARSER_LOT_ENTITY   5000

Definition at line 112 of file parser.c.

◆ XML_PARSER_NON_LINEAR

#define XML_PARSER_NON_LINEAR   10

Definition at line 120 of file parser.c.

Typedef Documentation

◆ xmlDefAttrs

Definition at line 1094 of file parser.c.

◆ xmlDefAttrsPtr

Definition at line 1095 of file parser.c.

Function Documentation

◆ areBlanks()

static int areBlanks ( xmlParserCtxtPtr  ctxt,
const xmlChar str,
int  len,
int  blank_chars 
)
static

areBlanks: @ctxt: an XML parser context @str: a xmlChar * @len: the size of @str @blank_chars: we know the chars are blanks

Is this a sequence of blank chars that one can ignore ?

Returns 1 if ignorable 0 otherwise.

Definition at line 2825 of file parser.c.

2826  {
2827  int i, ret;
2828  xmlNodePtr lastChild;
2829 
2830  /*
2831  * Don't spend time trying to differentiate them, the same callback is
2832  * used !
2833  */
2834  if (ctxt->sax->ignorableWhitespace == ctxt->sax->characters)
2835  return(0);
2836 
2837  /*
2838  * Check for xml:space value.
2839  */
2840  if ((ctxt->space == NULL) || (*(ctxt->space) == 1) ||
2841  (*(ctxt->space) == -2))
2842  return(0);
2843 
2844  /*
2845  * Check that the string is made of blanks
2846  */
2847  if (blank_chars == 0) {
2848  for (i = 0;i < len;i++)
2849  if (!(IS_BLANK_CH(str[i]))) return(0);
2850  }
2851 
2852  /*
2853  * Look if the element is mixed content in the DTD if available
2854  */
2855  if (ctxt->node == NULL) return(0);
2856  if (ctxt->myDoc != NULL) {
2857  ret = xmlIsMixedElement(ctxt->myDoc, ctxt->node->name);
2858  if (ret == 0) return(1);
2859  if (ret == 1) return(0);
2860  }
2861 
2862  /*
2863  * Otherwise, heuristic :-\
2864  */
2865  if ((RAW != '<') && (RAW != 0xD)) return(0);
2866  if ((ctxt->node->children == NULL) &&
2867  (RAW == '<') && (NXT(1) == '/')) return(0);
2868 
2869  lastChild = xmlGetLastChild(ctxt->node);
2870  if (lastChild == NULL) {
2871  if ((ctxt->node->type != XML_ELEMENT_NODE) &&
2872  (ctxt->node->content != NULL)) return(0);
2873  } else if (xmlNodeIsText(lastChild))
2874  return(0);
2875  else if ((ctxt->node->children != NULL) &&
2876  (xmlNodeIsText(ctxt->node->children)))
2877  return(0);
2878  return(1);
2879 }
const xmlChar * name
Definition: tree.h:492
#define NXT(val)
Definition: parser.c:2035
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define IS_BLANK_CH(c)
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN xmlNodePtr XMLCALL xmlGetLastChild(const xmlNode *parent)
xmlNodePtr node
Definition: parser.h:205
XMLPUBFUN int XMLCALL xmlNodeIsText(const xmlNode *node)
xmlChar * content
Definition: tree.h:502
Definition: tree.h:489
int ret
xmlDocPtr myDoc
Definition: parser.h:187
GLenum GLsizei len
Definition: glext.h:6722
struct _xmlSAXHandler * sax
Definition: parser.h:185
xmlElementType type
Definition: tree.h:491
XMLPUBFUN int XMLCALL xmlIsMixedElement(xmlDocPtr doc, const xmlChar *name)
Definition: valid.c:3456
struct _xmlNode * children
Definition: tree.h:493
#define RAW
Definition: parser.c:2033
int * space
Definition: parser.h:244

Referenced by xmlParseCharData(), and xmlParseCharDataComplex().

◆ inputPop()

xmlParserInputPtr inputPop ( xmlParserCtxtPtr  ctxt)

inputPop: @ctxt: an XML parser context

Pops the top parser input from the input stack

Returns the input just removed

Definition at line 1749 of file parser.c.

1750 {
1752 
1753  if (ctxt == NULL)
1754  return(NULL);
1755  if (ctxt->inputNr <= 0)
1756  return (NULL);
1757  ctxt->inputNr--;
1758  if (ctxt->inputNr > 0)
1759  ctxt->input = ctxt->inputTab[ctxt->inputNr - 1];
1760  else
1761  ctxt->input = NULL;
1762  ret = ctxt->inputTab[ctxt->inputNr];
1763  ctxt->inputTab[ctxt->inputNr] = NULL;
1764  return (ret);
1765 }
xmlParserInputPtr * inputTab
Definition: parser.h:202
xmlParserInputPtr input
Definition: parser.h:199
smooth NULL
Definition: ftsmooth.c:416
int ret

Referenced by xmlCtxtReset(), xmlFreeParserCtxt(), xmlHaltParser(), xmlInitParserCtxt(), xmlPopInput(), and xmlPushInput().

◆ inputPush()

int inputPush ( xmlParserCtxtPtr  ctxt,
xmlParserInputPtr  value 
)

inputPush: @ctxt: an XML parser context @value: the parser input

Pushes a new parser input on top of the input stack

Returns -1 in case of error, the index in the stack otherwise

Definition at line 1718 of file parser.c.

1719 {
1720  if ((ctxt == NULL) || (value == NULL))
1721  return(-1);
1722  if (ctxt->inputNr >= ctxt->inputMax) {
1723  ctxt->inputMax *= 2;
1724  ctxt->inputTab =
1726  ctxt->inputMax *
1727  sizeof(ctxt->inputTab[0]));
1728  if (ctxt->inputTab == NULL) {
1729  xmlErrMemory(ctxt, NULL);
1731  ctxt->inputMax /= 2;
1732  value = NULL;
1733  return (-1);
1734  }
1735  }
1736  ctxt->inputTab[ctxt->inputNr] = value;
1737  ctxt->input = value;
1738  return (ctxt->inputNr++);
1739 }
xmlParserInputPtr * inputTab
Definition: parser.h:202
xmlParserInputPtr input
Definition: parser.h:199
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN void XMLCALL xmlFreeInputStream(xmlParserInputPtr input)
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
int inputMax
Definition: parser.h:201
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
GLsizei const GLfloat * value
Definition: glext.h:6069

Referenced by testSAX(), xmlCreateEntityParserCtxtInternal(), xmlCreateIOParserCtxt(), xmlCreateMemoryParserCtxt(), xmlCreateURLParserCtxt(), xmlCtxtReadDoc(), xmlCtxtReadFd(), xmlCtxtReadFile(), xmlCtxtReadIO(), xmlCtxtReadMemory(), xmlCtxtResetPush(), xmlPushInput(), xmlReadFd(), xmlReadIO(), and xsltDocDefaultLoaderFunc().

◆ LIBXML_ATTR_FORMAT()

static void LIBXML_ATTR_FORMAT ( ,
 
)
static

xmlFatalErrMsg: @ctxt: an XML parser context @error: the error number @msg: the error message

Handle a fatal parser error, i.e. violating Well-Formedness constraints

xmlWarningMsg: @ctxt: an XML parser context @error: the error number @msg: the error message @str1: extra data @str2: extra data

Handle a warning.

xmlValidityError: @ctxt: an XML parser context @error: the error number @msg: the error message @str1: extra data

Handle a validity error.

xmlFatalErrMsgInt: @ctxt: an XML parser context @error: the error number @msg: the error message @val: an integer value

Handle a fatal parser error, i.e. violating Well-Formedness constraints

xmlFatalErrMsgStrIntStr: @ctxt: an XML parser context @error: the error number @msg: the error message @str1: an string info @val: an integer value @str2: an string info

Handle a fatal parser error, i.e. violating Well-Formedness constraints

xmlFatalErrMsgStr: @ctxt: an XML parser context @error: the error number @msg: the error message @val: a string value

Handle a fatal parser error, i.e. violating Well-Formedness constraints

xmlErrMsgStr: @ctxt: an XML parser context @error: the error number @msg: the error message @val: a string value

Handle a non fatal parser error

xmlNsErr: @ctxt: an XML parser context @error: the error number @msg: the message @info1: extra information string @info2: extra information string

Handle a fatal parser error, i.e. violating Well-Formedness constraints

xmlNsWarn @ctxt: an XML parser context @error: the error number @msg: the message @info1: extra information string @info2: extra information string

Handle a namespace warning error

Definition at line 574 of file parser.c.

577 {
578  if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
579  (ctxt->instate == XML_PARSER_EOF))
580  return;
581  if (ctxt != NULL)
582  ctxt->errNo = error;
583  __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
584  XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "%s", msg);
585  if (ctxt != NULL) {
586  ctxt->wellFormed = 0;
587  if (ctxt->recovery == 0)
588  ctxt->disableSAX = 1;
589  }
590 }
smooth NULL
Definition: ftsmooth.c:416
DWORD error
Definition: parser.c:105
#define msg(x)
Definition: auth_time.c:54

◆ nameNsPush()

static int nameNsPush ( xmlParserCtxtPtr  ctxt,
const xmlChar value,
const xmlChar prefix,
const xmlChar URI,
int  nsNr 
)
static

nameNsPush: @ctxt: an XML parser context @value: the element name @prefix: the element prefix @URI: the element namespace name

Pushes a new element name/prefix/URL on top of the name stack

Returns -1 in case of error, the index in the stack otherwise

Definition at line 1843 of file parser.c.

1845 {
1846  if (ctxt->nameNr >= ctxt->nameMax) {
1847  const xmlChar * *tmp;
1848  void **tmp2;
1849  ctxt->nameMax *= 2;
1850  tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,
1851  ctxt->nameMax *
1852  sizeof(ctxt->nameTab[0]));
1853  if (tmp == NULL) {
1854  ctxt->nameMax /= 2;
1855  goto mem_error;
1856  }
1857  ctxt->nameTab = tmp;
1858  tmp2 = (void **) xmlRealloc((void * *)ctxt->pushTab,
1859  ctxt->nameMax * 3 *
1860  sizeof(ctxt->pushTab[0]));
1861  if (tmp2 == NULL) {
1862  ctxt->nameMax /= 2;
1863  goto mem_error;
1864  }
1865  ctxt->pushTab = tmp2;
1866  } else if (ctxt->pushTab == NULL) {
1867  ctxt->pushTab = (void **) xmlMalloc(ctxt->nameMax * 3 *
1868  sizeof(ctxt->pushTab[0]));
1869  if (ctxt->pushTab == NULL)
1870  goto mem_error;
1871  }
1872  ctxt->nameTab[ctxt->nameNr] = value;
1873  ctxt->name = value;
1874  ctxt->pushTab[ctxt->nameNr * 3] = (void *) prefix;
1875  ctxt->pushTab[ctxt->nameNr * 3 + 1] = (void *) URI;
1876  ctxt->pushTab[ctxt->nameNr * 3 + 2] = (void *) (ptrdiff_t) nsNr;
1877  return (ctxt->nameNr++);
1878 mem_error:
1879  xmlErrMemory(ctxt, NULL);
1880  return (-1);
1881 }
const xmlChar * name
Definition: parser.h:229
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
void ** pushTab
Definition: parser.h:283
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
unsigned char xmlChar
Definition: xmlstring.h:28
GLsizei const GLfloat * value
Definition: glext.h:6069
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
const xmlChar ** nameTab
Definition: parser.h:232

Referenced by xmlParseElementStart().

◆ namePop()

const xmlChar* namePop ( xmlParserCtxtPtr  ctxt)

namePop: @ctxt: an XML parser context

Pops the top element name from the name stack

Returns the name just removed

Definition at line 1950 of file parser.c.

1951 {
1952  const xmlChar *ret;
1953 
1954  if ((ctxt == NULL) || (ctxt->nameNr <= 0))
1955  return (NULL);
1956  ctxt->nameNr--;
1957  if (ctxt->nameNr > 0)
1958  ctxt->name = ctxt->nameTab[ctxt->nameNr - 1];
1959  else
1960  ctxt->name = NULL;
1961  ret = ctxt->nameTab[ctxt->nameNr];
1962  ctxt->nameTab[ctxt->nameNr] = NULL;
1963  return (ret);
1964 }
const xmlChar * name
Definition: parser.h:229
smooth NULL
Definition: ftsmooth.c:416
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
const xmlChar ** nameTab
Definition: parser.h:232

Referenced by xmlParseElementEnd(), and xmlParseElementStart().

◆ namePush()

int namePush ( xmlParserCtxtPtr  ctxt,
const xmlChar value 
)

namePush: @ctxt: an XML parser context @value: the element name

Pushes a new element name on top of the name stack

Returns -1 in case of error, the index in the stack otherwise

Definition at line 1919 of file parser.c.

1920 {
1921  if (ctxt == NULL) return (-1);
1922 
1923  if (ctxt->nameNr >= ctxt->nameMax) {
1924  const xmlChar * *tmp;
1925  tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,
1926  ctxt->nameMax * 2 *
1927  sizeof(ctxt->nameTab[0]));
1928  if (tmp == NULL) {
1929  goto mem_error;
1930  }
1931  ctxt->nameTab = tmp;
1932  ctxt->nameMax *= 2;
1933  }
1934  ctxt->nameTab[ctxt->nameNr] = value;
1935  ctxt->name = value;
1936  return (ctxt->nameNr++);
1937 mem_error:
1938  xmlErrMemory(ctxt, NULL);
1939  return (-1);
1940 }
const xmlChar * name
Definition: parser.h:229
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
unsigned char xmlChar
Definition: xmlstring.h:28
GLsizei const GLfloat * value
Definition: glext.h:6069
const xmlChar ** nameTab
Definition: parser.h:232

Referenced by xmlParseElementStart().

◆ nodePop()

xmlNodePtr nodePop ( xmlParserCtxtPtr  ctxt)

nodePop: @ctxt: an XML parser context

Pops the top element node from the node stack

Returns the node just removed

Definition at line 1814 of file parser.c.

1815 {
1816  xmlNodePtr ret;
1817 
1818  if (ctxt == NULL) return(NULL);
1819  if (ctxt->nodeNr <= 0)
1820  return (NULL);
1821  ctxt->nodeNr--;
1822  if (ctxt->nodeNr > 0)
1823  ctxt->node = ctxt->nodeTab[ctxt->nodeNr - 1];
1824  else
1825  ctxt->node = NULL;
1826  ret = ctxt->nodeTab[ctxt->nodeNr];
1827  ctxt->nodeTab[ctxt->nodeNr] = NULL;
1828  return (ret);
1829 }
xmlNodePtr * nodeTab
Definition: parser.h:208
smooth NULL
Definition: ftsmooth.c:416
xmlNodePtr node
Definition: parser.h:205
Definition: tree.h:489
int ret

Referenced by xmlParseElementStart(), and xmlSAX2EndElementNs().

◆ nodePush()

int nodePush ( xmlParserCtxtPtr  ctxt,
xmlNodePtr  value 
)

nodePush: @ctxt: an XML parser context @value: the element node

Pushes a new element node on top of the node stack

Returns -1 in case of error, the index in the stack otherwise

Definition at line 1776 of file parser.c.

1777 {
1778  if (ctxt == NULL) return(0);
1779  if (ctxt->nodeNr >= ctxt->nodeMax) {
1780  xmlNodePtr *tmp;
1781 
1782  tmp = (xmlNodePtr *) xmlRealloc(ctxt->nodeTab,
1783  ctxt->nodeMax * 2 *
1784  sizeof(ctxt->nodeTab[0]));
1785  if (tmp == NULL) {
1786  xmlErrMemory(ctxt, NULL);
1787  return (-1);
1788  }
1789  ctxt->nodeTab = tmp;
1790  ctxt->nodeMax *= 2;
1791  }
1792  if ((((unsigned int) ctxt->nodeNr) > xmlParserMaxDepth) &&
1793  ((ctxt->options & XML_PARSE_HUGE) == 0)) {
1794  xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
1795  "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
1797  xmlHaltParser(ctxt);
1798  return(-1);
1799  }
1800  ctxt->nodeTab[ctxt->nodeNr] = value;
1801  ctxt->node = value;
1802  return (ctxt->nodeNr++);
1803 }
xmlNodePtr * nodeTab
Definition: parser.h:208
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
xmlNodePtr node
Definition: parser.h:205
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
unsigned int xmlParserMaxDepth
Definition: parser.c:251
Definition: tree.h:489
GLsizei const GLfloat * value
Definition: glext.h:6069
static void xmlHaltParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12478

Referenced by xmlParseBalancedChunkMemoryInternal(), xmlParseCtxtExternalEntity(), xmlParseExternalEntityPrivate(), xmlParseInNodeContext(), and xmlSAX2StartElementNs().

◆ nsPop()

static int nsPop ( xmlParserCtxtPtr  ctxt,
int  nr 
)
static

nsPop: @ctxt: an XML parser context @nr: the number to pop

Pops the top @nr parser prefix/namespace from the ns stack

Returns the number of namespaces removed

Definition at line 1654 of file parser.c.

1655 {
1656  int i;
1657 
1658  if (ctxt->nsTab == NULL) return(0);
1659  if (ctxt->nsNr < nr) {
1660  xmlGenericError(xmlGenericErrorContext, "Pbm popping %d NS\n", nr);
1661  nr = ctxt->nsNr;
1662  }
1663  if (ctxt->nsNr <= 0)
1664  return (0);
1665 
1666  for (i = 0;i < nr;i++) {
1667  ctxt->nsNr--;
1668  ctxt->nsTab[ctxt->nsNr] = NULL;
1669  }
1670  return(nr);
1671 }
ULONG nr
Definition: thread.c:7
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
const xmlChar ** nsTab
Definition: parser.h:281
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlParseElementStart(), xmlParseEndTag2(), and xmlParseInNodeContext().

◆ nsPush()

static int nsPush ( xmlParserCtxtPtr  ctxt,
const xmlChar prefix,
const xmlChar URL 
)
static

nsPush: @ctxt: an XML parser context @prefix: the namespace prefix or NULL @URL: the namespace name

Pushes a new parser namespace on top of the ns stack

Returns -1 in case of error, -2 if the namespace should be discarded and the index in the stack otherwise.

Definition at line 1604 of file parser.c.

1605 {
1606  if (ctxt->options & XML_PARSE_NSCLEAN) {
1607  int i;
1608  for (i = ctxt->nsNr - 2;i >= 0;i -= 2) {
1609  if (ctxt->nsTab[i] == prefix) {
1610  /* in scope */
1611  if (ctxt->nsTab[i + 1] == URL)
1612  return(-2);
1613  /* out of scope keep it */
1614  break;
1615  }
1616  }
1617  }
1618  if ((ctxt->nsMax == 0) || (ctxt->nsTab == NULL)) {
1619  ctxt->nsMax = 10;
1620  ctxt->nsNr = 0;
1621  ctxt->nsTab = (const xmlChar **)
1622  xmlMalloc(ctxt->nsMax * sizeof(xmlChar *));
1623  if (ctxt->nsTab == NULL) {
1624  xmlErrMemory(ctxt, NULL);
1625  ctxt->nsMax = 0;
1626  return (-1);
1627  }
1628  } else if (ctxt->nsNr >= ctxt->nsMax) {
1629  const xmlChar ** tmp;
1630  ctxt->nsMax *= 2;
1631  tmp = (const xmlChar **) xmlRealloc((char *) ctxt->nsTab,
1632  ctxt->nsMax * sizeof(ctxt->nsTab[0]));
1633  if (tmp == NULL) {
1634  xmlErrMemory(ctxt, NULL);
1635  ctxt->nsMax /= 2;
1636  return (-1);
1637  }
1638  ctxt->nsTab = tmp;
1639  }
1640  ctxt->nsTab[ctxt->nsNr++] = prefix;
1641  ctxt->nsTab[ctxt->nsNr++] = URL;
1642  return (ctxt->nsNr);
1643 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
const xmlChar ** nsTab
Definition: parser.h:281

Referenced by xmlParseBalancedChunkMemoryInternal(), xmlParseInNodeContext(), and xmlParseStartTag2().

◆ spacePop()

static int spacePop ( xmlParserCtxtPtr  ctxt)
static

Definition at line 1985 of file parser.c.

1985  {
1986  int ret;
1987  if (ctxt->spaceNr <= 0) return(0);
1988  ctxt->spaceNr--;
1989  if (ctxt->spaceNr > 0)
1990  ctxt->space = &ctxt->spaceTab[ctxt->spaceNr - 1];
1991  else
1992  ctxt->space = &ctxt->spaceTab[0];
1993  ret = ctxt->spaceTab[ctxt->spaceNr];
1994  ctxt->spaceTab[ctxt->spaceNr] = -1;
1995  return(ret);
1996 }
int * spaceTab
Definition: parser.h:247
int ret
int * space
Definition: parser.h:244

Referenced by xmlParseElementStart(), and xmlParseEndTag2().

◆ spacePush()

static int spacePush ( xmlParserCtxtPtr  ctxt,
int  val 
)
static

Definition at line 1966 of file parser.c.

1966  {
1967  if (ctxt->spaceNr >= ctxt->spaceMax) {
1968  int *tmp;
1969 
1970  ctxt->spaceMax *= 2;
1971  tmp = (int *) xmlRealloc(ctxt->spaceTab,
1972  ctxt->spaceMax * sizeof(ctxt->spaceTab[0]));
1973  if (tmp == NULL) {
1974  xmlErrMemory(ctxt, NULL);
1975  ctxt->spaceMax /=2;
1976  return(-1);
1977  }
1978  ctxt->spaceTab = tmp;
1979  }
1980  ctxt->spaceTab[ctxt->spaceNr] = val;
1981  ctxt->space = &ctxt->spaceTab[ctxt->spaceNr];
1982  return(ctxt->spaceNr++);
1983 }
int * spaceTab
Definition: parser.h:247
int spaceMax
Definition: parser.h:246
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
GLuint GLfloat * val
Definition: glext.h:7180
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
int * space
Definition: parser.h:244

Referenced by xmlParseElementStart().

◆ xmlAddDefAttrs()

static void xmlAddDefAttrs ( xmlParserCtxtPtr  ctxt,
const xmlChar fullname,
const xmlChar fullattr,
const xmlChar value 
)
static

xmlAddDefAttrs: @ctxt: an XML parser context @fullname: the element fullname @fullattr: the attribute fullname @value: the attribute value

Add a defaulted attribute for an element

Definition at line 1215 of file parser.c.

1218  {
1220  int len;
1221  const xmlChar *name;
1222  const xmlChar *prefix;
1223 
1224  /*
1225  * Allows to detect attribute redefinitions
1226  */
1227  if (ctxt->attsSpecial != NULL) {
1228  if (xmlHashLookup2(ctxt->attsSpecial, fullname, fullattr) != NULL)
1229  return;
1230  }
1231 
1232  if (ctxt->attsDefault == NULL) {
1233  ctxt->attsDefault = xmlHashCreateDict(10, ctxt->dict);
1234  if (ctxt->attsDefault == NULL)
1235  goto mem_error;
1236  }
1237 
1238  /*
1239  * split the element name into prefix:localname , the string found
1240  * are within the DTD and then not associated to namespace names.
1241  */
1243  if (name == NULL) {
1244  name = xmlDictLookup(ctxt->dict, fullname, -1);
1245  prefix = NULL;
1246  } else {
1247  name = xmlDictLookup(ctxt->dict, name, -1);
1248  prefix = xmlDictLookup(ctxt->dict, fullname, len);
1249  }
1250 
1251  /*
1252  * make sure there is some storage
1253  */
1254  defaults = xmlHashLookup2(ctxt->attsDefault, name, prefix);
1255  if (defaults == NULL) {
1257  (4 * 5) * sizeof(const xmlChar *));
1258  if (defaults == NULL)
1259  goto mem_error;
1260  defaults->nbAttrs = 0;
1261  defaults->maxAttrs = 4;
1262  if (xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix,
1263  defaults, NULL) < 0) {
1264  xmlFree(defaults);
1265  goto mem_error;
1266  }
1267  } else if (defaults->nbAttrs >= defaults->maxAttrs) {
1269 
1271  (2 * defaults->maxAttrs * 5) * sizeof(const xmlChar *));
1272  if (temp == NULL)
1273  goto mem_error;
1274  defaults = temp;
1275  defaults->maxAttrs *= 2;
1276  if (xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix,
1277  defaults, NULL) < 0) {
1278  xmlFree(defaults);
1279  goto mem_error;
1280  }
1281  }
1282 
1283  /*
1284  * Split the element name into prefix:localname , the string found
1285  * are within the DTD and hen not associated to namespace names.
1286  */
1287  name = xmlSplitQName3(fullattr, &len);
1288  if (name == NULL) {
1289  name = xmlDictLookup(ctxt->dict, fullattr, -1);
1290  prefix = NULL;
1291  } else {
1292  name = xmlDictLookup(ctxt->dict, name, -1);
1293  prefix = xmlDictLookup(ctxt->dict, fullattr, len);
1294  }
1295 
1296  defaults->values[5 * defaults->nbAttrs] = name;
1297  defaults->values[5 * defaults->nbAttrs + 1] = prefix;
1298  /* intern the string and precompute the end */
1299  len = xmlStrlen(value);
1300  value = xmlDictLookup(ctxt->dict, value, len);
1301  defaults->values[5 * defaults->nbAttrs + 2] = value;
1302  defaults->values[5 * defaults->nbAttrs + 3] = value + len;
1303  if (ctxt->external)
1304  defaults->values[5 * defaults->nbAttrs + 4] = BAD_CAST "external";
1305  else
1306  defaults->values[5 * defaults->nbAttrs + 4] = NULL;
1307  defaults->nbAttrs++;
1308 
1309  return;
1310 
1311 mem_error:
1312  xmlErrMemory(ctxt, NULL);
1313  return;
1314 }
XMLPUBFUN const xmlChar *XMLCALL xmlSplitQName3(const xmlChar *name, int *len)
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:422
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:481
int external
Definition: parser.h:217
static const ASMPROP_RES defaults[ASM_NAME_MAX_PARAMS]
Definition: asmname.c:82
xmlHashTablePtr attsDefault
Definition: parser.h:284
smooth NULL
Definition: ftsmooth.c:416
#define BAD_CAST
Definition: xmlstring.h:35
xmlDictPtr dict
Definition: parser.h:263
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:865
const char * fullname
Definition: shader.c:1766
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
GLsizei const GLfloat * value
Definition: glext.h:6069
XMLPUBFUN int XMLCALL xmlHashUpdateEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata, xmlHashDeallocator f)
Definition: hash.c:450
static calc_node_t temp
Definition: rpn_ieee.c:38
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreateDict(int size, xmlDictPtr dict)
Definition: hash.c:215
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
xmlHashTablePtr attsSpecial
Definition: parser.h:285
Definition: name.c:38
xmlDefAttrs * xmlDefAttrsPtr
Definition: parser.c:1095
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by xmlParseAttributeListDecl().

◆ xmlAddSpecialAttr()

static void xmlAddSpecialAttr ( xmlParserCtxtPtr  ctxt,
const xmlChar fullname,
const xmlChar fullattr,
int  type 
)
static

xmlAddSpecialAttr: @ctxt: an XML parser context @fullname: the element fullname @fullattr: the attribute fullname @type: the attribute type

Register this attribute type

Definition at line 1326 of file parser.c.

1330 {
1331  if (ctxt->attsSpecial == NULL) {
1332  ctxt->attsSpecial = xmlHashCreateDict(10, ctxt->dict);
1333  if (ctxt->attsSpecial == NULL)
1334  goto mem_error;
1335  }
1336 
1337  if (xmlHashLookup2(ctxt->attsSpecial, fullname, fullattr) != NULL)
1338  return;
1339 
1340  xmlHashAddEntry2(ctxt->attsSpecial, fullname, fullattr,
1341  (void *) (ptrdiff_t) type);
1342  return;
1343 
1344 mem_error:
1345  xmlErrMemory(ctxt, NULL);
1346  return;
1347 }
XMLPUBFUN int XMLCALL xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata)
Definition: hash.c:411
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:481
smooth NULL
Definition: ftsmooth.c:416
xmlDictPtr dict
Definition: parser.h:263
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
const char * fullname
Definition: shader.c:1766
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreateDict(int size, xmlDictPtr dict)
Definition: hash.c:215
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
xmlHashTablePtr attsSpecial
Definition: parser.h:285

Referenced by xmlParseAttributeListDecl().

◆ xmlAttrNormalizeSpace()

static xmlChar* xmlAttrNormalizeSpace ( const xmlChar src,
xmlChar dst 
)
static

xmlAttrNormalizeSpace: @src: the source string @dst: the target string

Normalize the space in non CDATA attribute values: If the attribute type is not CDATA, then the XML processor MUST further process the normalized attribute value by discarding any leading and trailing space (#x20) characters, and by replacing sequences of space (#x20) characters by a single space (#x20) character. Note that the size of dst need to be at least src, and if one doesn't need to preserve dst (and it doesn't come from a dictionary or read-only) then passing src as dst is just fine.

Returns a pointer to the normalized value (dst) or NULL if no conversion is needed.

Definition at line 1125 of file parser.c.

1126 {
1127  if ((src == NULL) || (dst == NULL))
1128  return(NULL);
1129 
1130  while (*src == 0x20) src++;
1131  while (*src != 0) {
1132  if (*src == 0x20) {
1133  while (*src == 0x20) src++;
1134  if (*src != 0)
1135  *dst++ = 0x20;
1136  } else {
1137  *dst++ = *src++;
1138  }
1139  }
1140  *dst = 0;
1141  if (dst == src)
1142  return(NULL);
1143  return(dst);
1144 }
smooth NULL
Definition: ftsmooth.c:416
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by xmlAttrNormalizeSpace2(), and xmlParseAttributeListDecl().

◆ xmlAttrNormalizeSpace2()

static const xmlChar* xmlAttrNormalizeSpace2 ( xmlParserCtxtPtr  ctxt,
xmlChar src,
int len 
)
static

xmlAttrNormalizeSpace2: @src: the source string

Normalize the space in non CDATA attribute values, a slightly more complex front end to avoid allocation problems when running on attribute values coming from the input.

Returns a pointer to the normalized value (dst) or NULL if no conversion is needed.

Definition at line 1158 of file parser.c.

1159 {
1160  int i;
1161  int remove_head = 0;
1162  int need_realloc = 0;
1163  const xmlChar *cur;
1164 
1165  if ((ctxt == NULL) || (src == NULL) || (len == NULL))
1166  return(NULL);
1167  i = *len;
1168  if (i <= 0)
1169  return(NULL);
1170 
1171  cur = src;
1172  while (*cur == 0x20) {
1173  cur++;
1174  remove_head++;
1175  }
1176  while (*cur != 0) {
1177  if (*cur == 0x20) {
1178  cur++;
1179  if ((*cur == 0x20) || (*cur == 0)) {
1180  need_realloc = 1;
1181  break;
1182  }
1183  } else
1184  cur++;
1185  }
1186  if (need_realloc) {
1187  xmlChar *ret;
1188 
1189  ret = xmlStrndup(src + remove_head, i - remove_head + 1);
1190  if (ret == NULL) {
1191  xmlErrMemory(ctxt, NULL);
1192  return(NULL);
1193  }
1195  *len = (int) strlen((const char *)ret);
1196  return(ret);
1197  } else if (remove_head) {
1198  *len -= remove_head;
1199  memmove(src, src + remove_head, 1 + *len);
1200  return(src);
1201  }
1202  return(NULL);
1203 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
XMLPUBFUN xmlChar *XMLCALL xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:41
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
static xmlChar * xmlAttrNormalizeSpace(const xmlChar *src, xmlChar *dst)
Definition: parser.c:1125
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by xmlParseAttribute2().

◆ xmlCheckLanguageID()

int xmlCheckLanguageID ( const xmlChar lang)

xmlCheckLanguageID: @lang: pointer to the string value

Checks that the value conforms to the LanguageID production:

NOTE: this is somewhat deprecated, those productions were removed from the XML Second edition.

[33] LanguageID ::= Langcode ('-' Subcode)* [34] Langcode ::= ISO639Code | IanaCode | UserCode [35] ISO639Code ::= ([a-z] | [A-Z]) ([a-z] | [A-Z]) [36] IanaCode ::= ('i' | 'I') '-' ([a-z] | [A-Z])+ [37] UserCode ::= ('x' | 'X') '-' ([a-z] | [A-Z])+ [38] Subcode ::= ([a-z] | [A-Z])+

The current REC reference the successors of RFC 1766, currently 5646

http://www.rfc-editor.org/rfc/rfc5646.txt langtag = language ["-" script] ["-" region] *("-" variant) *("-" extension) ["-" privateuse] language = 2*3ALPHA ; shortest ISO 639 code ["-" extlang] ; sometimes followed by ; extended language subtags / 4ALPHA ; or reserved for future use / 5*8ALPHA ; or registered language subtag

extlang = 3ALPHA ; selected ISO 639 codes *2("-" 3ALPHA) ; permanently reserved

script = 4ALPHA ; ISO 15924 code

region = 2ALPHA ; ISO 3166-1 code / 3DIGIT ; UN M.49 code

variant = 5*8alphanum ; registered variants / (DIGIT 3alphanum)

extension = singleton 1*("-" (2*8alphanum))

                                ; Single alphanumerics
                                ; "x" reserved for private use

singleton = DIGIT ; 0 - 9 / x41-57 ; A - W / x59-5A ; Y - Z / x61-77 ; a - w / x79-7A ; y - z

it sounds right to still allow Irregular i-xxx IANA and user codes too The parser below doesn't try to cope with extension or privateuse that could be added but that's not interoperable anyway

Returns 1 if correct 0 otherwise

Definition at line 1447 of file parser.c.

1448 {
1449  const xmlChar *cur = lang, *nxt;
1450 
1451  if (cur == NULL)
1452  return (0);
1453  if (((cur[0] == 'i') && (cur[1] == '-')) ||
1454  ((cur[0] == 'I') && (cur[1] == '-')) ||
1455  ((cur[0] == 'x') && (cur[1] == '-')) ||
1456  ((cur[0] == 'X') && (cur[1] == '-'))) {
1457  /*
1458  * Still allow IANA code and user code which were coming
1459  * from the previous version of the XML-1.0 specification
1460  * it's deprecated but we should not fail
1461  */
1462  cur += 2;
1463  while (((cur[0] >= 'A') && (cur[0] <= 'Z')) ||
1464  ((cur[0] >= 'a') && (cur[0] <= 'z')))
1465  cur++;
1466  return(cur[0] == 0);
1467  }
1468  nxt = cur;
1469  while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1470  ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1471  nxt++;
1472  if (nxt - cur >= 4) {
1473  /*
1474  * Reserved
1475  */
1476  if ((nxt - cur > 8) || (nxt[0] != 0))
1477  return(0);
1478  return(1);
1479  }
1480  if (nxt - cur < 2)
1481  return(0);
1482  /* we got an ISO 639 code */
1483  if (nxt[0] == 0)
1484  return(1);
1485  if (nxt[0] != '-')
1486  return(0);
1487 
1488  nxt++;
1489  cur = nxt;
1490  /* now we can have extlang or script or region or variant */
1491  if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1492  goto region_m49;
1493 
1494  while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1495  ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1496  nxt++;
1497  if (nxt - cur == 4)
1498  goto script;
1499  if (nxt - cur == 2)
1500  goto region;
1501  if ((nxt - cur >= 5) && (nxt - cur <= 8))
1502  goto variant;
1503  if (nxt - cur != 3)
1504  return(0);
1505  /* we parsed an extlang */
1506  if (nxt[0] == 0)
1507  return(1);
1508  if (nxt[0] != '-')
1509  return(0);
1510 
1511  nxt++;
1512  cur = nxt;
1513  /* now we can have script or region or variant */
1514  if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1515  goto region_m49;
1516 
1517  while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1518  ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1519  nxt++;
1520  if (nxt - cur == 2)
1521  goto region;
1522  if ((nxt - cur >= 5) && (nxt - cur <= 8))
1523  goto variant;
1524  if (nxt - cur != 4)
1525  return(0);
1526  /* we parsed a script */
1527 script:
1528  if (nxt[0] == 0)
1529  return(1);
1530  if (nxt[0] != '-')
1531  return(0);
1532 
1533  nxt++;
1534  cur = nxt;
1535  /* now we can have region or variant */
1536  if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1537  goto region_m49;
1538 
1539  while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1540  ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1541  nxt++;
1542 
1543  if ((nxt - cur >= 5) && (nxt - cur <= 8))
1544  goto variant;
1545  if (nxt - cur != 2)
1546  return(0);
1547  /* we parsed a region */
1548 region:
1549  if (nxt[0] == 0)
1550  return(1);
1551  if (nxt[0] != '-')
1552  return(0);
1553 
1554  nxt++;
1555  cur = nxt;
1556  /* now we can just have a variant */
1557  while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1558  ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1559  nxt++;
1560 
1561  if ((nxt - cur < 5) || (nxt - cur > 8))
1562  return(0);
1563 
1564  /* we parsed a variant */
1565 variant:
1566  if (nxt[0] == 0)
1567  return(1);
1568  if (nxt[0] != '-')
1569  return(0);
1570  /* extensions and private use subtags not checked */
1571  return (1);
1572 
1573 region_m49:
1574  if (((nxt[1] >= '0') && (nxt[1] <= '9')) &&
1575  ((nxt[2] >= '0') && (nxt[2] <= '9'))) {
1576  nxt += 3;
1577  goto region;
1578  }
1579  return(0);
1580 }
smooth NULL
Definition: ftsmooth.c:416
script
Definition: msipriv.h:374
static const WCHAR lang[]
Definition: wbemdisp.c:287
unsigned char xmlChar
Definition: xmlstring.h:28

Referenced by xmlParseAttribute2().

◆ xmlCleanSpecialAttr()

static void xmlCleanSpecialAttr ( xmlParserCtxtPtr  ctxt)
static

xmlCleanSpecialAttr: @ctxt: an XML parser context

Trim the list of attributes defined to remove all those of type CDATA as they are not special. This call should be done when finishing to parse the DTD and before starting to parse the document root.

Definition at line 1374 of file parser.c.

1375 {
1376  if (ctxt->attsSpecial == NULL)
1377  return;
1378 
1380 
1381  if (xmlHashSize(ctxt->attsSpecial) == 0) {
1382  xmlHashFree(ctxt->attsSpecial, NULL);
1383  ctxt->attsSpecial = NULL;
1384  }
1385  return;
1386 }
XMLPUBFUN int XMLCALL xmlHashSize(xmlHashTablePtr table)
Definition: hash.c:1039
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:327
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN void XMLCALL xmlHashScanFull(xmlHashTablePtr table, xmlHashScannerFull f, void *data)
Definition: hash.c:880
xmlHashTablePtr attsSpecial
Definition: parser.h:285
static void xmlCleanSpecialAttrCallback(void *payload, void *data, const xmlChar *fullname, const xmlChar *fullattr, const xmlChar *unused ATTRIBUTE_UNUSED)
Definition: parser.c:1355

Referenced by xmlParseDocument().

◆ xmlCleanSpecialAttrCallback()

static void xmlCleanSpecialAttrCallback ( void payload,
void data,
const xmlChar fullname,
const xmlChar fullattr,
const xmlChar *unused  ATTRIBUTE_UNUSED 
)
static

xmlCleanSpecialAttrCallback:

Removes CDATA attributes from the special attribute table

Definition at line 1355 of file parser.c.

1357  {
1359 
1360  if (((ptrdiff_t) payload) == XML_ATTRIBUTE_CDATA) {
1361  xmlHashRemoveEntry2(ctxt->attsSpecial, fullname, fullattr, NULL);
1362  }
1363 }
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN int XMLCALL xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, xmlHashDeallocator f)
Definition: hash.c:1076
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
const char * fullname
Definition: shader.c:1766
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
xmlHashTablePtr attsSpecial
Definition: parser.h:285
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39

Referenced by xmlCleanSpecialAttr().

◆ xmlCleanupParser()

void xmlCleanupParser ( void  )

xmlCleanupParser:

This function name is somewhat misleading. It does not clean up parser state, it cleans up memory allocated by the library itself. It is a cleanup function for the XML library. It tries to reclaim all related global memory allocated for the library processing. It doesn't deallocate any document related memory. One should call xmlCleanupParser() only when the process has finished using the library and all XML/HTML documents built with it. See also xmlInitParser() which has the opposite function of preparing the library for operations.

WARNING: if your application is multithreaded or has plugin support calling this may crash the application if another thread or a plugin is still using libxml2. It's sometimes very hard to guess if libxml2 is in use in the application, some libraries or plugins may use it without notice. In case of doubt abstain from calling this function or do it just before calling exit() to avoid leak reports from valgrind !

Definition at line 14798 of file parser.c.

14798  {
14799  if (!xmlParserInitialized)
14800  return;
14801 
14803 #ifdef LIBXML_CATALOG_ENABLED
14804  xmlCatalogCleanup();
14805 #endif
14806  xmlDictCleanup();
14808 #ifdef LIBXML_OUTPUT_ENABLED
14809  xmlCleanupOutputCallbacks();
14810 #endif
14811 #ifdef LIBXML_SCHEMAS_ENABLED
14812  xmlSchemaCleanupTypes();
14813  xmlRelaxNGCleanupTypes();
14814 #endif
14817  xmlCleanupThreads(); /* must be last if called not from the main thread */
14818  xmlCleanupMemory();
14820 }
XMLPUBFUN void XMLCALL xmlCleanupGlobals(void)
Definition: globals.c:58
XMLPUBFUN void XMLCALL xmlCleanupInputCallbacks(void)
XMLPUBFUN void XMLCALL xmlCleanupThreads(void)
Definition: threads.c:908
XMLPUBFUN void XMLCALL xmlCleanupCharEncodingHandlers(void)
Definition: encoding.c:1455
XMLPUBFUN void XMLCALL xmlCleanupMemory(void)
Definition: xmlmemory.c:1008
XMLPUBFUN void XMLCALL xmlResetLastError(void)
XMLPUBFUN void XMLCALL xmlDictCleanup(void)
Definition: dict.c:222
static int xmlParserInitialized
Definition: parser.c:14729

Referenced by DllMain(), and main().

◆ xmlCreateDocParserCtxt()

xmlParserCtxtPtr xmlCreateDocParserCtxt ( const xmlChar cur)

xmlCreateDocParserCtxt: @cur: a pointer to an array of xmlChar

Creates a parser context for an XML in-memory document.

Returns the new parser context or NULL

Definition at line 14606 of file parser.c.

14606  {
14607  int len;
14608 
14609  if (cur == NULL)
14610  return(NULL);
14611  len = xmlStrlen(cur);
14612  return(xmlCreateMemoryParserCtxt((const char *)cur, len));
14613 }
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:422
smooth NULL
Definition: ftsmooth.c:416
GLenum GLsizei len
Definition: glext.h:6722
xmlParserCtxtPtr xmlCreateMemoryParserCtxt(const char *buffer, int size)
Definition: parser.c:14403

Referenced by xmlReadDoc().

◆ xmlCreateEntityParserCtxt()

xmlParserCtxtPtr xmlCreateEntityParserCtxt ( const xmlChar URL,
const xmlChar ID,
const xmlChar base 
)

xmlCreateEntityParserCtxt: @URL: the entity URL @ID: the entity PUBLIC ID @base: a possible base for the target URI

Create a parser context for an external entity Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

Returns the new parser context or NULL

Definition at line 14091 of file parser.c.

14092  {
14094 
14095 }
static xmlParserCtxtPtr xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID, const xmlChar *base, xmlParserCtxtPtr pctx)
Definition: parser.c:14018
smooth NULL
Definition: ftsmooth.c:416
#define ID
Definition: ruserpass.c:36

◆ xmlCreateEntityParserCtxtInternal()

static xmlParserCtxtPtr xmlCreateEntityParserCtxtInternal ( const xmlChar URL,
const xmlChar ID,
const xmlChar base,
xmlParserCtxtPtr  pctx 
)
static

xmlCreateEntityParserCtxtInternal: @URL: the entity URL @ID: the entity PUBLIC ID @base: a possible base for the target URI @pctx: parser context used to set options on new context

Create a parser context for an external entity Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

Returns the new parser context or NULL

Definition at line 14018 of file parser.c.

14019  {
14020  xmlParserCtxtPtr ctxt;
14021  xmlParserInputPtr inputStream;
14022  char *directory = NULL;
14023  xmlChar *uri;
14024 
14025  ctxt = xmlNewParserCtxt();
14026  if (ctxt == NULL) {
14027  return(NULL);
14028  }
14029 
14030  if (pctx != NULL) {
14031  ctxt->options = pctx->options;
14032  ctxt->_private = pctx->_private;
14033  /*
14034  * this is a subparser of pctx, so the input_id should be
14035  * incremented to distinguish from main entity
14036  */
14037  ctxt->input_id = pctx->input_id + 1;
14038  }
14039 
14040  /* Don't read from stdin. */
14041  if (xmlStrcmp(URL, BAD_CAST "-") == 0)
14042  URL = BAD_CAST "./-";
14043 
14044  uri = xmlBuildURI(URL, base);
14045 
14046  if (uri == NULL) {
14047  inputStream = xmlLoadExternalEntity((char *)URL, (char *)ID, ctxt);
14048  if (inputStream == NULL) {
14049  xmlFreeParserCtxt(ctxt);
14050  return(NULL);
14051  }
14052 
14053  inputPush(ctxt, inputStream);
14054 
14055  if ((ctxt->directory == NULL) && (directory == NULL))
14056  directory = xmlParserGetDirectory((char *)URL);
14057  if ((ctxt->directory == NULL) && (directory != NULL))
14058  ctxt->directory = directory;
14059  } else {
14060  inputStream = xmlLoadExternalEntity((char *)uri, (char *)ID, ctxt);
14061  if (inputStream == NULL) {
14062  xmlFree(uri);
14063  xmlFreeParserCtxt(ctxt);
14064  return(NULL);
14065  }
14066 
14067  inputPush(ctxt, inputStream);
14068 
14069  if ((ctxt->directory == NULL) && (directory == NULL))
14070  directory = xmlParserGetDirectory((char *)uri);
14071  if ((ctxt->directory == NULL) && (directory != NULL))
14072  ctxt->directory = directory;
14073  xmlFree(uri);
14074  }
14075  return(ctxt);
14076 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
const char * uri
Definition: sec_mgr.c:1588
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
int input_id
Definition: parser.h:312
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1884
smooth NULL
Definition: ftsmooth.c:416
void * _private
Definition: parser.h:256
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
unsigned char xmlChar
Definition: xmlstring.h:28
#define ID
Definition: ruserpass.c:36
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
char * directory
Definition: parser.h:226
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)
XMLPUBFUN int XMLCALL xmlStrcmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:132

Referenced by xmlCreateEntityParserCtxt(), xmlParseCtxtExternalEntity(), and xmlParseExternalEntityPrivate().

◆ xmlCreateFileParserCtxt()

xmlParserCtxtPtr xmlCreateFileParserCtxt ( const char filename)

xmlCreateFileParserCtxt: @filename: the filename

Create a parser context for a file content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time.

Returns the new parser context or NULL

Definition at line 14157 of file parser.c.

14158 {
14159  return(xmlCreateURLParserCtxt(filename, 0));
14160 }
const char * filename
Definition: ioapi.h:135
xmlParserCtxtPtr xmlCreateURLParserCtxt(const char *filename, int options)
Definition: parser.c:14115

◆ xmlCreateIOParserCtxt()

xmlParserCtxtPtr xmlCreateIOParserCtxt ( xmlSAXHandlerPtr  sax,
void user_data,
xmlInputReadCallback  ioread,
xmlInputCloseCallback  ioclose,
void ioctx,
xmlCharEncoding  enc 
)

xmlCreateIOParserCtxt: @sax: a SAX handler @user_data: The user data returned on SAX callbacks @ioread: an I/O read function @ioclose: an I/O close function @ioctx: an I/O handler @enc: the charset encoding if known

Create a parser context for using the XML parser with an existing I/O stream

Returns the new parser context or NULL

Definition at line 12534 of file parser.c.

12536  {
12537  xmlParserCtxtPtr ctxt;
12538  xmlParserInputPtr inputStream;
12540 
12541  if (ioread == NULL) return(NULL);
12542 
12543  buf = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx, enc);
12544  if (buf == NULL) {
12545  if (ioclose != NULL)
12546  ioclose(ioctx);
12547  return (NULL);
12548  }
12549 
12550  ctxt = xmlNewParserCtxt();
12551  if (ctxt == NULL) {
12553  return(NULL);
12554  }
12555  if (sax != NULL) {
12556 #ifdef LIBXML_SAX1_ENABLED
12557  if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
12558 #endif /* LIBXML_SAX1_ENABLED */
12559  xmlFree(ctxt->sax);
12560  ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(xmlSAXHandler));
12561  if (ctxt->sax == NULL) {
12562  xmlErrMemory(ctxt, NULL);
12563  xmlFreeParserCtxt(ctxt);
12564  return(NULL);
12565  }
12566  memset(ctxt->sax, 0, sizeof(xmlSAXHandler));
12567  if (sax->initialized == XML_SAX2_MAGIC)
12568  memcpy(ctxt->sax, sax, sizeof(xmlSAXHandler));
12569  else
12570  memcpy(ctxt->sax, sax, sizeof(xmlSAXHandlerV1));
12571  if (user_data != NULL)
12572  ctxt->userData = user_data;
12573  }
12574 
12575  inputStream = xmlNewIOInputStream(ctxt, buf, enc);
12576  if (inputStream == NULL) {
12577  xmlFreeParserCtxt(ctxt);
12578  return(NULL);
12579  }
12580  inputPush(ctxt, inputStream);
12581 
12582  return(ctxt);
12583 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define XML_SAX2_MAGIC
Definition: parser.h:671
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
static int sax
Definition: xmllint.c:198
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc)
smooth NULL
Definition: ftsmooth.c:416
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler
Definition: globals.h:321
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
xmlSAXHandler * xmlSAXHandlerPtr
Definition: tree.h:45
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct _xmlSAXHandler * sax
Definition: parser.h:185
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)
#define memset(x, y, z)
Definition: compat.h:39
void * userData
Definition: parser.h:186

◆ xmlCreateMemoryParserCtxt()

xmlParserCtxtPtr xmlCreateMemoryParserCtxt ( const char buffer,
int  size 
)

xmlCreateMemoryParserCtxt: @buffer: a pointer to a char array @size: the size of the array

Create a parser context for an XML in-memory document.

Returns the new parser context or NULL

Definition at line 14403 of file parser.c.

14403  {
14404  xmlParserCtxtPtr ctxt;
14407 
14408  if (buffer == NULL)
14409  return(NULL);
14410  if (size <= 0)
14411  return(NULL);
14412 
14413  ctxt = xmlNewParserCtxt();
14414  if (ctxt == NULL)
14415  return(NULL);
14416 
14417  /* TODO: xmlParserInputBufferCreateStatic, requires some serious changes */
14419  if (buf == NULL) {
14420  xmlFreeParserCtxt(ctxt);
14421  return(NULL);
14422  }
14423 
14424  input = xmlNewInputStream(ctxt);
14425  if (input == NULL) {
14427  xmlFreeParserCtxt(ctxt);
14428  return(NULL);
14429  }
14430 
14431  input->filename = NULL;
14432  input->buf = buf;
14433  xmlBufResetInput(input->buf->buffer, input);
14434 
14435  inputPush(ctxt, input);
14436  return(ctxt);
14437 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
GLuint buffer
Definition: glext.h:5915
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1283
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc)
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream(xmlParserCtxtPtr ctxt)

Referenced by xmlCreateDocParserCtxt(), xmlParseBalancedChunkMemoryInternal(), xmlParseInNodeContext(), and xmlReadMemory().

◆ xmlCreateURLParserCtxt()

xmlParserCtxtPtr xmlCreateURLParserCtxt ( const char filename,
int  options 
)

xmlCreateURLParserCtxt: @filename: the filename or URL @options: a combination of xmlParserOption

Create a parser context for a file or URL content. Automatic support for ZLIB/Compress compressed document is provided by default if found at compile-time and for file accesses

Returns the new parser context or NULL

Definition at line 14115 of file parser.c.

14116 {
14117  xmlParserCtxtPtr ctxt;
14118  xmlParserInputPtr inputStream;
14119  char *directory = NULL;
14120 
14121  ctxt = xmlNewParserCtxt();
14122  if (ctxt == NULL) {
14123  xmlErrMemory(NULL, "cannot allocate parser context");
14124  return(NULL);
14125  }
14126 
14127  if (options)
14129  ctxt->linenumbers = 1;
14130 
14131  inputStream = xmlLoadExternalEntity(filename, NULL, ctxt);
14132  if (inputStream == NULL) {
14133  xmlFreeParserCtxt(ctxt);
14134  return(NULL);
14135  }
14136 
14137  inputPush(ctxt, inputStream);
14138  if ((ctxt->directory == NULL) && (directory == NULL))
14140  if ((ctxt->directory == NULL) && (directory != NULL))
14141  ctxt->directory = directory;
14142 
14143  return(ctxt);
14144 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
const char * filename
Definition: ioapi.h:135
int linenumbers
Definition: parser.h:259
smooth NULL
Definition: ftsmooth.c:416
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:15045
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
char * directory
Definition: parser.h:226
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)

Referenced by xmlCreateFileParserCtxt(), and xmlReadFile().

◆ xmlCtxtGrowAttrs()

static int xmlCtxtGrowAttrs ( xmlParserCtxtPtr  ctxt,
int  nr 
)
static

Definition at line 1675 of file parser.c.

1675  {
1676  const xmlChar **atts;
1677  int *attallocs;
1678  int maxatts;
1679 
1680  if (ctxt->atts == NULL) {
1681  maxatts = 55; /* allow for 10 attrs by default */
1682  atts = (const xmlChar **)
1683  xmlMalloc(maxatts * sizeof(xmlChar *));
1684  if (atts == NULL) goto mem_error;
1685  ctxt->atts = atts;
1686  attallocs = (int *) xmlMalloc((maxatts / 5) * sizeof(int));
1687  if (attallocs == NULL) goto mem_error;
1688  ctxt->attallocs = attallocs;
1689  ctxt->maxatts = maxatts;
1690  } else if (nr + 5 > ctxt->maxatts) {
1691  maxatts = (nr + 5) * 2;
1692  atts = (const xmlChar **) xmlRealloc((void *) ctxt->atts,
1693  maxatts * sizeof(const xmlChar *));
1694  if (atts == NULL) goto mem_error;
1695  ctxt->atts = atts;
1696  attallocs = (int *) xmlRealloc((void *) ctxt->attallocs,
1697  (maxatts / 5) * sizeof(int));
1698  if (attallocs == NULL) goto mem_error;
1699  ctxt->attallocs = attallocs;
1700  ctxt->maxatts = maxatts;
1701  }
1702  return(ctxt->maxatts);
1703 mem_error:
1704  xmlErrMemory(ctxt, NULL);
1705  return(-1);
1706 }
int * attallocs
Definition: parser.h:282
ULONG nr
Definition: thread.c:7
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
unsigned char xmlChar
Definition: xmlstring.h:28
const xmlChar ** atts
Definition: parser.h:264
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
_In_ uint16_t _Out_ ULONG * atts
Definition: btrfs_drv.h:1109
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by xmlParseStartTag2().

◆ xmlCtxtReadDoc()

xmlDocPtr xmlCtxtReadDoc ( xmlParserCtxtPtr  ctxt,
const xmlChar cur,
const char URL,
const char encoding,
int  options 
)

xmlCtxtReadDoc: @ctxt: an XML parser context @cur: a pointer to a zero terminated string @URL: the base URL to use for the document @encoding: the document encoding, or NULL @options: a combination of xmlParserOption

parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context

Returns the resulting document tree

Definition at line 15413 of file parser.c.

15415 {
15417 
15418  if (cur == NULL)
15419  return (NULL);
15420  if (ctxt == NULL)
15421  return (NULL);
15422  xmlInitParser();
15423 
15424  xmlCtxtReset(ctxt);
15425 
15426  stream = xmlNewStringInputStream(ctxt, cur);
15427  if (stream == NULL) {
15428  return (NULL);
15429  }
15430  inputPush(ctxt, stream);
15431  return (xmlDoRead(ctxt, URL, encoding, options, 1));
15432 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewStringInputStream(xmlParserCtxtPtr ctxt, const xmlChar *buffer)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15204
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14847
void xmlInitParser(void)
Definition: parser.c:14740
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
ed encoding
Definition: write.c:2825

◆ xmlCtxtReadFd()

xmlDocPtr xmlCtxtReadFd ( xmlParserCtxtPtr  ctxt,
int  fd,
const char URL,
const char encoding,
int  options 
)

xmlCtxtReadFd: @ctxt: an XML parser context @fd: an open file descriptor @URL: the base URL to use for the document @encoding: the document encoding, or NULL @options: a combination of xmlParserOption

parse an XML from a file descriptor and build a tree. This reuses the existing @ctxt parser context NOTE that the file descriptor will not be closed when the reader is closed or reset.

Returns the resulting document tree

Definition at line 15528 of file parser.c.

15530 {
15533 
15534  if (fd < 0)
15535  return (NULL);
15536  if (ctxt == NULL)
15537  return (NULL);
15538  xmlInitParser();
15539 
15540  xmlCtxtReset(ctxt);
15541 
15542 
15544  if (input == NULL)
15545  return (NULL);
15546  input->closecallback = NULL;
15548  if (stream == NULL) {
15550  return (NULL);
15551  }
15552  inputPush(ctxt, stream);
15553  return (xmlDoRead(ctxt, URL, encoding, options, 1));
15554 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15204
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
static int fd
Definition: io.c:51
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14847
void xmlInitParser(void)
Definition: parser.c:14740
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
ed encoding
Definition: write.c:2825
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFd(int fd, xmlCharEncoding enc)
GLenum GLenum GLenum input
Definition: glext.h:9031

◆ xmlCtxtReadFile()

xmlDocPtr xmlCtxtReadFile ( xmlParserCtxtPtr  ctxt,
const char filename,
const char encoding,
int  options 
)

xmlCtxtReadFile: @ctxt: an XML parser context @filename: a file or URL @encoding: the document encoding, or NULL @options: a combination of xmlParserOption

parse an XML file from the filesystem or the network. This reuses the existing @ctxt parser context

Returns the resulting document tree

Definition at line 15447 of file parser.c.

15449 {
15451 
15452  if (filename == NULL)
15453  return (NULL);
15454  if (ctxt == NULL)
15455  return (NULL);
15456  xmlInitParser();
15457 
15458  xmlCtxtReset(ctxt);
15459 
15461  if (stream == NULL) {
15462  return (NULL);
15463  }
15464  inputPush(ctxt, stream);
15465  return (xmlDoRead(ctxt, NULL, encoding, options, 1));
15466 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15204
const char * filename
Definition: ioapi.h:135
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14847
void xmlInitParser(void)
Definition: parser.c:14740
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
ed encoding
Definition: write.c:2825

Referenced by parseAndPrintFile().

◆ xmlCtxtReadIO()

xmlDocPtr xmlCtxtReadIO ( xmlParserCtxtPtr  ctxt,
xmlInputReadCallback  ioread,
xmlInputCloseCallback  ioclose,
void ioctx,
const char URL,
const char encoding,
int  options 
)

xmlCtxtReadIO: @ctxt: an XML parser context @ioread: an I/O read function @ioclose: an I/O close function @ioctx: an I/O handler @URL: the base URL to use for the document @encoding: the document encoding, or NULL @options: a combination of xmlParserOption

parse an XML document from I/O functions and source and build a tree. This reuses the existing @ctxt parser context

Returns the resulting document tree

Definition at line 15572 of file parser.c.

15576 {
15579 
15580  if (ioread == NULL)
15581  return (NULL);
15582  if (ctxt == NULL)
15583  return (NULL);
15584  xmlInitParser();
15585 
15586  xmlCtxtReset(ctxt);
15587 
15588  input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
15590  if (input == NULL) {
15591  if (ioclose != NULL)
15592  ioclose(ioctx);
15593  return (NULL);
15594  }
15596  if (stream == NULL) {
15598  return (NULL);
15599  }
15600  inputPush(ctxt, stream);
15601  return (xmlDoRead(ctxt, URL, encoding, options, 1));
15602 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15204
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14847
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc)
void xmlInitParser(void)
Definition: parser.c:14740
smooth NULL
Definition: ftsmooth.c:416
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
ed encoding
Definition: write.c:2825
GLenum GLenum GLenum input
Definition: glext.h:9031

Referenced by parseAndPrintFile().

◆ xmlCtxtReadMemory()

xmlDocPtr xmlCtxtReadMemory ( xmlParserCtxtPtr  ctxt,
const char buffer,
int  size,
const char URL,
const char encoding,
int  options 
)

xmlCtxtReadMemory: @ctxt: an XML parser context @buffer: a pointer to a char array @size: the size of the array @URL: the base URL to use for the document @encoding: the document encoding, or NULL @options: a combination of xmlParserOption

parse an XML in-memory document and build a tree. This reuses the existing @ctxt parser context

Returns the resulting document tree

Definition at line 15483 of file parser.c.

15485 {
15488 
15489  if (ctxt == NULL)
15490  return (NULL);
15491  if (buffer == NULL)
15492  return (NULL);
15493  xmlInitParser();
15494 
15495  xmlCtxtReset(ctxt);
15496 
15498  if (input == NULL) {
15499  return(NULL);
15500  }
15501 
15503  if (stream == NULL) {
15505  return(NULL);
15506  }
15507 
15508  inputPush(ctxt, stream);
15509  return (xmlDoRead(ctxt, URL, encoding, options, 1));
15510 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15204
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
GLuint buffer
Definition: glext.h:5915
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14847
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc)
void xmlInitParser(void)
Definition: parser.c:14740
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
ed encoding
Definition: write.c:2825
GLenum GLenum GLenum input
Definition: glext.h:9031

Referenced by parseAndPrintFile().

◆ xmlCtxtReset()

void xmlCtxtReset ( xmlParserCtxtPtr  ctxt)

xmlCtxtReset: @ctxt: an XML parser context

Reset a parser context

Definition at line 14847 of file parser.c.

14848 {
14850  xmlDictPtr dict;
14851 
14852  if (ctxt == NULL)
14853  return;
14854 
14855  dict = ctxt->dict;
14856 
14857  while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
14859  }
14860  ctxt->inputNr = 0;
14861  ctxt->input = NULL;
14862 
14863  ctxt->spaceNr = 0;
14864  if (ctxt->spaceTab != NULL) {
14865  ctxt->spaceTab[0] = -1;
14866  ctxt->space = &ctxt->spaceTab[0];
14867  } else {
14868  ctxt->space = NULL;
14869  }
14870 
14871 
14872  ctxt->nodeNr = 0;
14873  ctxt->node = NULL;
14874 
14875  ctxt->nameNr = 0;
14876  ctxt->name = NULL;
14877 
14878  DICT_FREE(ctxt->version);
14879  ctxt->version = NULL;
14880  DICT_FREE(ctxt->encoding);
14881  ctxt->encoding = NULL;
14882  DICT_FREE(ctxt->directory);
14883  ctxt->directory = NULL;
14884  DICT_FREE(ctxt->extSubURI);
14885  ctxt->extSubURI = NULL;
14886  DICT_FREE(ctxt->extSubSystem);
14887  ctxt->extSubSystem = NULL;
14888  if (ctxt->myDoc != NULL)
14889  xmlFreeDoc(ctxt->myDoc);
14890  ctxt->myDoc = NULL;
14891 
14892  ctxt->standalone = -1;
14893  ctxt->hasExternalSubset = 0;
14894  ctxt->hasPErefs = 0;
14895  ctxt->html = 0;
14896  ctxt->external = 0;
14897  ctxt->instate = XML_PARSER_START;
14898  ctxt->token = 0;
14899 
14900  ctxt->wellFormed = 1;
14901  ctxt->nsWellFormed = 1;
14902  ctxt->disableSAX = 0;
14903  ctxt->valid = 1;
14904 #if 0
14905  ctxt->vctxt.userData = ctxt;
14908 #endif
14909  ctxt->record_info = 0;
14910  ctxt->nbChars = 0;
14911  ctxt->checkIndex = 0;
14912  ctxt->inSubset = 0;
14913  ctxt->errNo = XML_ERR_OK;
14914  ctxt->depth = 0;
14916  ctxt->catalogs = NULL;
14917  ctxt->nbentities = 0;
14918  ctxt->sizeentities = 0;
14919  ctxt->sizeentcopy = 0;
14920  xmlInitNodeInfoSeq(&ctxt->node_seq);
14921 
14922  if (ctxt->attsDefault != NULL) {
14924  ctxt->attsDefault = NULL;
14925  }
14926  if (ctxt->attsSpecial != NULL) {
14927  xmlHashFree(ctxt->attsSpecial, NULL);
14928  ctxt->attsSpecial = NULL;
14929  }
14930 
14931 #ifdef LIBXML_CATALOG_ENABLED
14932  if (ctxt->catalogs != NULL)
14933  xmlCatalogFreeLocal(ctxt->catalogs);
14934 #endif
14935  if (ctxt->lastError.code != XML_ERR_OK)
14936  xmlResetError(&ctxt->lastError);
14937 }
xmlParserInputState instate
Definition: parser.h:223
unsigned long sizeentities
Definition: parser.h:304
int * spaceTab
Definition: parser.h:247
xmlChar * extSubURI
Definition: parser.h:240
long checkIndex
Definition: parser.h:235
int nsWellFormed
Definition: parser.h:286
xmlValidityErrorFunc error
Definition: valid.h:84
int external
Definition: parser.h:217
long nbChars
Definition: parser.h:234
const xmlChar * name
Definition: parser.h:229
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
xmlError lastError
Definition: parser.h:301
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:327
int standalone
Definition: parser.h:192
xmlHashTablePtr attsDefault
Definition: parser.h:284
smooth NULL
Definition: ftsmooth.c:416
xmlChar * extSubSystem
Definition: parser.h:241
XMLPUBFUN void XMLCALL xmlFreeInputStream(xmlParserInputPtr input)
xmlDictPtr dict
Definition: parser.h:263
Definition: dict.c:116
#define DICT_FREE(str)
Definition: parser.c:14835
XMLPUBFUN void XMLCALL xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
int wellFormed
Definition: parser.h:188
xmlNodePtr node
Definition: parser.h:205
int record_info
Definition: parser.h:210
int hasPErefs
Definition: parser.h:216
xmlParserInputPtr inputPop(xmlParserCtxtPtr ctxt)
Definition: parser.c:1749
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
xmlDocPtr myDoc
Definition: parser.h:187
const xmlChar * encoding
Definition: parser.h:191
const xmlChar * version
Definition: parser.h:190
void * catalogs
Definition: parser.h:260
int hasExternalSubset
Definition: parser.h:215
XMLPUBFUN void XMLCALL xmlResetError(xmlErrorPtr err)
XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL xmlParserValidityWarning(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
unsigned long sizeentcopy
Definition: parser.h:313
GLenum GLenum GLenum input
Definition: glext.h:9031
int inSubset
Definition: parser.h:238
xmlHashTablePtr attsSpecial
Definition: parser.h:285
char * directory
Definition: parser.h:226
XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL xmlParserValidityError(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
int code
Definition: xmlerror.h:80
void * userData
Definition: valid.h:83
xmlValidCtxt vctxt
Definition: parser.h:221
int * space
Definition: parser.h:244
xmlValidityWarningFunc warning
Definition: valid.h:85
xmlParserNodeInfoSeq node_seq
Definition: parser.h:211
XMLPUBFUN void XMLCALL xmlHashDefaultDeallocator(void *entry, const xmlChar *name)
unsigned long nbentities
Definition: parser.h:303

Referenced by xmlClearParserCtxt(), xmlCtxtReadDoc(), xmlCtxtReadFd(), xmlCtxtReadFile(), xmlCtxtReadIO(), xmlCtxtReadMemory(), and xmlCtxtResetPush().

◆ xmlCtxtResetPush()

int xmlCtxtResetPush ( xmlParserCtxtPtr  ctxt,
const char chunk,
int  size,
const char filename,
const char encoding 
)

xmlCtxtResetPush: @ctxt: an XML parser context @chunk: a pointer to an array of chars @size: number of chars in the array @filename: an optional file name or URI @encoding: the document encoding, or NULL

Reset a push parser context

Returns 0 in case of success and 1 in case of error

Definition at line 14952 of file parser.c.

14954 {
14955  xmlParserInputPtr inputStream;
14958 
14959  if (ctxt == NULL)
14960  return(1);
14961 
14962  if ((encoding == NULL) && (chunk != NULL) && (size >= 4))
14963  enc = xmlDetectCharEncoding((const xmlChar *) chunk, size);
14964 
14966  if (buf == NULL)
14967  return(1);
14968 
14969  if (ctxt == NULL) {
14971  return(1);
14972  }
14973 
14974  xmlCtxtReset(ctxt);
14975 
14976  if (filename == NULL) {
14977  ctxt->directory = NULL;
14978  } else {
14980  }
14981 
14982  inputStream = xmlNewInputStream(ctxt);
14983  if (inputStream == NULL) {
14985  return(1);
14986  }
14987 
14988  if (filename == NULL)
14989  inputStream->filename = NULL;
14990  else
14991  inputStream->filename = (char *)
14992  xmlCanonicPath((const xmlChar *) filename);
14993  inputStream->buf = buf;
14994  xmlBufResetInput(buf->buffer, inputStream);
14995 
14996  inputPush(ctxt, inputStream);
14997 
14998  if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
14999  (ctxt->input->buf != NULL)) {
15000  size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
15001  size_t cur = ctxt->input->cur - ctxt->input->base;
15002 
15004 
15005  xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
15006 #ifdef DEBUG_PUSH
15007  xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size);
15008 #endif
15009  }
15010 
15011  if (encoding != NULL) {
15013 
15014  if (ctxt->encoding != NULL)
15015  xmlFree((xmlChar *) ctxt->encoding);
15016  ctxt->encoding = xmlStrdup((const xmlChar *) encoding);
15017 
15019  if (hdlr != NULL) {
15020  xmlSwitchToEncoding(ctxt, hdlr);
15021  } else {
15022  xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
15023  "Unsupported encoding %s\n", BAD_CAST encoding);
15024  }
15025  } else if (enc != XML_CHAR_ENCODING_NONE) {
15026  xmlSwitchEncoding(ctxt, enc);
15027  }
15028 
15029  return(0);
15030 }
XMLPUBFUN int XMLCALL xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
int xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input, size_t base, size_t cur)
Definition: buf.c:1333
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1718
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
XMLPUBFUN int XMLCALL xmlParserInputBufferPush(xmlParserInputBufferPtr in, int len, const char *buf)
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
const xmlChar * cur
Definition: parser.h:61
xmlCharEncoding
Definition: encoding.h:58
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1283
const char * filename
Definition: ioapi.h:135
const xmlChar * base
Definition: parser.h:60
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14847
xmlParserInputPtr input
Definition: parser.h:199
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
XMLPUBFUN xmlChar *XMLCALL xmlCanonicPath(const xmlChar *path)
Definition: uri.c:2372
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlAllocParserInputBuffer(xmlCharEncoding enc)
#define BAD_CAST
Definition: xmlstring.h:35
GLsizeiptr size
Definition: glext.h:5919
xmlBufPtr buffer
Definition: xmlIO.h:132
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
XMLPUBFUN xmlCharEncoding XMLCALL xmlDetectCharEncoding(const unsigned char *in, int len)
Definition: encoding.c:932
size_t xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1302
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1641
const xmlChar * encoding
Definition: parser.h:191
unsigned char xmlChar
Definition: xmlstring.h:28
ed encoding
Definition: write.c:2825
xmlParserInputBufferPtr buf
Definition: parser.h:56
const char * filename
Definition: parser.h:58
XMLPUBFUN int XMLCALL xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
char * directory
Definition: parser.h:226
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream(xmlParserCtxtPtr ctxt)
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

◆ xmlCtxtUseOptions()

int xmlCtxtUseOptions ( xmlParserCtxtPtr  ctxt,
int  options 
)

xmlCtxtUseOptions: @ctxt: an XML parser context @options: a combination of xmlParserOption

Applies the options to the parser context

Returns 0 in case of success, the set of unknown or unimplemented options in case of error.

Definition at line 15186 of file parser.c.

15187 {
15188  return(xmlCtxtUseOptionsInternal(ctxt, options, NULL));
15189 }
smooth NULL
Definition: ftsmooth.c:416
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:15045

Referenced by parseAndPrintFile(), and xsltDocDefaultLoaderFunc().

◆ xmlCtxtUseOptionsInternal()

static int xmlCtxtUseOptionsInternal ( xmlParserCtxtPtr  ctxt,
int  options,
const char encoding 
)
static

xmlCtxtUseOptionsInternal: @ctxt: an XML parser context @options: a combination of xmlParserOption @encoding: the user provided encoding to use

Applies the options to the parser context

Returns 0 in case of success, the set of unknown or unimplemented options in case of error.

Definition at line 15045 of file parser.c.

15046 {
15047  if (ctxt == NULL)
15048  return(-1);
15049  if (encoding != NULL) {
15050  if (ctxt->encoding != NULL)
15051  xmlFree((xmlChar *) ctxt->encoding);
15052  ctxt->encoding = xmlStrdup((const xmlChar *) encoding);
15053  }
15054  if (options & XML_PARSE_RECOVER) {
15055  ctxt->recovery = 1;
15057  ctxt->options |= XML_PARSE_RECOVER;
15058  } else
15059  ctxt->recovery = 0;
15060  if (options & XML_PARSE_DTDLOAD) {
15061  ctxt->loadsubset = XML_DETECT_IDS;
15063  ctxt->options |= XML_PARSE_DTDLOAD;
15064  } else
15065  ctxt->loadsubset = 0;
15066  if (options & XML_PARSE_DTDATTR) {
15067  ctxt->loadsubset |= XML_COMPLETE_ATTRS;
15069  ctxt->options |= XML_PARSE_DTDATTR;
15070  }
15071  if (options & XML_PARSE_NOENT) {
15072  ctxt->replaceEntities = 1;
15073  /* ctxt->loadsubset |= XML_DETECT_IDS; */
15075  ctxt->options |= XML_PARSE_NOENT;
15076  } else
15077  ctxt->replaceEntities = 0;
15078  if (options & XML_PARSE_PEDANTIC) {
15079  ctxt->pedantic = 1;
15081  ctxt->options |= XML_PARSE_PEDANTIC;
15082  } else
15083  ctxt->pedantic = 0;
15084  if (options & XML_PARSE_NOBLANKS) {
15085  ctxt->keepBlanks = 0;
15086  ctxt->sax->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
15088  ctxt->options |= XML_PARSE_NOBLANKS;
15089  } else
15090  ctxt->keepBlanks = 1;
15091  if (options & XML_PARSE_DTDVALID) {
15092  ctxt->validate = 1;
15094  ctxt->vctxt.warning = NULL;
15095  if (options & XML_PARSE_NOERROR)
15096  ctxt->vctxt.error = NULL;
15098  ctxt->options |= XML_PARSE_DTDVALID;
15099  } else
15100  ctxt->validate = 0;
15101  if (options & XML_PARSE_NOWARNING) {
15102  ctxt->sax->warning = NULL;
15104  }
15105  if (options & XML_PARSE_NOERROR) {
15106  ctxt->sax->error = NULL;
15107  ctxt->sax->fatalError = NULL;
15109  }
15110 #ifdef LIBXML_SAX1_ENABLED
15111  if (options & XML_PARSE_SAX1) {
15112  ctxt->sax->startElement = xmlSAX2StartElement;
15113  ctxt->sax->endElement = xmlSAX2EndElement;
15114  ctxt->sax->startElementNs = NULL;
15115  ctxt->sax->endElementNs = NULL;
15116  ctxt->sax->initialized = 1;
15118  ctxt->options |= XML_PARSE_SAX1;
15119  }
15120 #endif /* LIBXML_SAX1_ENABLED */
15121  if (options & XML_PARSE_NODICT) {
15122  ctxt->dictNames = 0;
15124  ctxt->options |= XML_PARSE_NODICT;
15125  } else {
15126  ctxt->dictNames = 1;
15127  }
15128  if (options & XML_PARSE_NOCDATA) {
15129  ctxt->sax->cdataBlock = NULL;
15131  ctxt->options |= XML_PARSE_NOCDATA;
15132  }
15133  if (options & XML_PARSE_NSCLEAN) {
15134  ctxt->options |= XML_PARSE_NSCLEAN;
15136  }
15137  if (options & XML_PARSE_NONET) {
15138  ctxt->options |= XML_PARSE_NONET;
15140  }
15141  if (options & XML_PARSE_COMPACT) {
15142  ctxt->options |= XML_PARSE_COMPACT;
15144  }
15145  if (options & XML_PARSE_OLD10) {
15146  ctxt->options |= XML_PARSE_OLD10;
15148  }
15149  if (options & XML_PARSE_NOBASEFIX) {
15150  ctxt->options |= XML_PARSE_NOBASEFIX;
15152  }
15153  if (options & XML_PARSE_HUGE) {
15154  ctxt->options |= XML_PARSE_HUGE;
15156  if (ctxt->dict != NULL)
15157  xmlDictSetLimit(ctxt->dict, 0);
15158  }
15159  if (options & XML_PARSE_OLDSAX) {
15160  ctxt->options |= XML_PARSE_OLDSAX;
15162  }
15163  if (options & XML_PARSE_IGNORE_ENC) {
15164  ctxt->options |= XML_PARSE_IGNORE_ENC;
15166  }
15167  if (options & XML_PARSE_BIG_LINES) {
15168  ctxt->options |= XML_PARSE_BIG_LINES;
15170  }
15171  ctxt->linenumbers = 1;
15172  return (options);
15173 }
#define XML_DETECT_IDS
Definition: parser.h:139
int pedantic
Definition: parser.h:255
XMLPUBFUN size_t XMLCALL xmlDictSetLimit(xmlDictPtr dict, size_t limit)
Definition: dict.c:1263
xmlValidityErrorFunc error
Definition: valid.h:84
int recovery
Definition: parser.h:261
int linenumbers
Definition: parser.h:259
int replaceEntities
Definition: parser.h:189
smooth NULL
Definition: ftsmooth.c:416
xmlDictPtr dict
Definition: parser.h:263
int validate
Definition: parser.h:220
XMLPUBFUN void XMLCALL xmlSAX2IgnorableWhitespace(void *ctx, const xmlChar *ch, int len)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
const xmlChar * encoding
Definition: parser.h:191
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
int loadsubset
Definition: parser.h:258
int dictNames
Definition: parser.h:292
ed encoding
Definition: write.c:2825
#define XML_COMPLETE_ATTRS
Definition: parser.h:148
int keepBlanks
Definition: parser.h:236
xmlValidCtxt vctxt
Definition: parser.h:221
xmlValidityWarningFunc warning
Definition: valid.h:85
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66

Referenced by xmlCreateURLParserCtxt(), xmlCtxtUseOptions(), xmlDoRead(), and xmlParseInNodeContext().

◆ xmlDetectSAX2()

static void xmlDetectSAX2 ( xmlParserCtxtPtr  ctxt)
static

xmlDetectSAX2: @ctxt: an XML parser context

Do the SAX2 detection and specific initialization

Definition at line 1075 of file parser.c.

1075  {
1076  if (ctxt == NULL) return;
1077 #ifdef LIBXML_SAX1_ENABLED
1078  if ((ctxt->sax) && (ctxt->sax->initialized == XML_SAX2_MAGIC) &&
1079  ((ctxt->sax->startElementNs != NULL) ||
1080  (ctxt->sax->endElementNs != NULL))) ctxt->sax2 = 1;
1081 #else
1082  ctxt->sax2 = 1;
1083 #endif /* LIBXML_SAX1_ENABLED */
1084 
1085  ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3);
1086  ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
1087  ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
1088  if ((ctxt->str_xml==NULL) || (ctxt->str_xmlns==NULL) ||
1089  (ctxt->str_xml_ns == NULL)) {
1090  xmlErrMemory(ctxt, NULL);
1091  }
1092 }
#define XML_SAX2_MAGIC
Definition: parser.h:671
const xmlChar * str_xmlns
Definition: parser.h:272
const xmlChar * str_xml
Definition: parser.h:271
smooth NULL
Definition: ftsmooth.c:416
#define XML_XML_NAMESPACE
Definition: tree.h:140
#define BAD_CAST
Definition: xmlstring.h:35
xmlDictPtr dict
Definition: parser.h:263
const xmlChar * str_xml_ns
Definition: parser.h:273
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:865
struct _xmlSAXHandler * sax
Definition: parser.h:185

Referenced by xmlParseBalancedChunkMemoryInternal(), xmlParseCtxtExternalEntity(), xmlParseDocument(), xmlParseExternalEntityPrivate(), xmlParseExternalSubset(), xmlParseExtParsedEnt(), and xmlParseInNodeContext().

◆ xmlDoRead()

static xmlDocPtr xmlDoRead ( xmlParserCtxtPtr  ctxt,
const char URL,
const char encoding,
int  options,
int  reuse 
)
static

xmlDoRead: @ctxt: an XML parser context @URL: the base URL to use for the document @encoding: the document encoding, or NULL @options: a combination of xmlParserOption @reuse: keep the context for reuse

Common front-end for the xmlRead functions

Returns the resulting document tree or NULL

Definition at line 15204 of file parser.c.

15206 {
15207  xmlDocPtr ret;
15208 
15210  if (encoding != NULL) {
15212 
15214  if (hdlr != NULL)
15215  xmlSwitchToEncoding(ctxt, hdlr);
15216  }
15217  if ((URL != NULL) && (ctxt->input != NULL) &&
15218  (ctxt->input->filename == NULL))
15219  ctxt->input->filename = (char *) xmlStrdup((const xmlChar *) URL);
15220  xmlParseDocument(ctxt);
15221  if ((ctxt->wellFormed) || ctxt->recovery)
15222  ret = ctxt->myDoc;
15223  else {
15224  ret = NULL;
15225  if (ctxt->myDoc != NULL) {
15226  xmlFreeDoc(ctxt->myDoc);
15227  }
15228  }
15229  ctxt->myDoc = NULL;
15230  if (!reuse) {
15231  xmlFreeParserCtxt(ctxt);
15232  }
15233 
15234  return (ret);
15235 }
XMLPUBFUN int XMLCALL xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
int xmlParseDocument(xmlParserCtxtPtr ctxt)
Definition: parser.c:10615
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
xmlParserInputPtr input
Definition: parser.h:199
int recovery
Definition: parser.h:261
smooth NULL
Definition: ftsmooth.c:416
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:15045
int wellFormed
Definition: parser.h:188
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
int ret
xmlDocPtr myDoc
Definition: parser.h:187
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1641
unsigned char xmlChar
Definition: xmlstring.h:28
ed encoding
Definition: write.c:2825
const char * filename
Definition: parser.h:58
Definition: tree.h:551
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66

Referenced by xmlCtxtReadDoc(), xmlCtxtReadFd(), xmlCtxtReadFile(), xmlCtxtReadIO(), xmlCtxtReadMemory(), xmlReadDoc(), xmlReadFd(), xmlReadFile(), xmlReadIO(), and xmlReadMemory().

◆ xmlErrAttributeDup()

static void xmlErrAttributeDup ( xmlParserCtxtPtr  ctxt,
const xmlChar prefix,
const xmlChar localname 
)
static

xmlErrAttributeDup: @ctxt: an XML parser context @prefix: the attribute prefix @localname: the attribute localname

Handle a redefinition of attribute error

Definition at line 323 of file parser.c.

325 {
326  if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
327  (ctxt->instate == XML_PARSER_EOF))
328  return;
329  if (ctxt != NULL)
331 
332  if (prefix == NULL)
333  __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER,
335  (const char *) localname, NULL, NULL, 0, 0,
336  "Attribute %s redefined\n", localname);
337  else
338  __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER,
340  (const char *) prefix, (const char *) localname,
341  NULL, 0, 0, "Attribute %s:%s redefined\n", prefix,
342  localname);
343  if (ctxt != NULL) {
344  ctxt->wellFormed = 0;
345  if (ctxt->recovery == 0)
346  ctxt->disableSAX = 1;
347  }
348 }
xmlParserInputState instate
Definition: parser.h:223
int disableSAX
Definition: parser.h:237
int recovery
Definition: parser.h:261
smooth NULL
Definition: ftsmooth.c:416
int wellFormed
Definition: parser.h:188

Referenced by xmlParseStartTag2().

◆ xmlFatalErr()

static void xmlFatalErr ( xmlParserCtxtPtr  ctxt,
xmlParserErrors  error,
const char info 
)
static

xmlFatalErr: @ctxt: an XML parser context @error: the error number @extra: extra information string

Handle a fatal parser error, i.e. violating Well-Formedness constraints

Definition at line 359 of file parser.c.

360 {
361  const char *errmsg;
362 
363  if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
364  (ctxt->instate == XML_PARSER_EOF))
365  return;
366  switch (error) {
368  errmsg = "CharRef: invalid hexadecimal value";
369  break;
371  errmsg = "CharRef: invalid decimal value";
372  break;
374  errmsg = "CharRef: invalid value";
375  break;
377  errmsg = "internal error";
378  break;
380  errmsg = "PEReference at end of document";
381  break;
383  errmsg = "PEReference in prolog";
384  break;
386  errmsg = "PEReference in epilog";
387  break;
389  errmsg = "PEReference: no name";
390  break;
392  errmsg = "PEReference: expecting ';'";
393  break;
394  case XML_ERR_ENTITY_LOOP:
395  errmsg = "Detected an entity reference loop";
396  break;
398  errmsg = "EntityValue: \" or ' expected";
399  break;
401  errmsg = "PEReferences forbidden in internal subset";
402  break;
404  errmsg = "EntityValue: \" or ' expected";
405  break;
407  errmsg = "AttValue: \" or ' expected";
408  break;
410  errmsg = "Unescaped '<' not allowed in attributes values";
411  break;
413  errmsg = "SystemLiteral \" or ' expected";
414  break;
416  errmsg = "Unfinished System or Public ID \" or ' expected";
417  break;
419  errmsg = "Sequence ']]>' not allowed in content";
420  break;
422  errmsg = "SYSTEM or PUBLIC, the URI is missing";
423  break;
425  errmsg = "PUBLIC, the Public Identifier is missing";
426  break;
428  errmsg = "Comment must not contain '--' (double-hyphen)";
429  break;
431  errmsg = "xmlParsePI : no target name";
432  break;
434  errmsg = "Invalid PI name";
435  break;
437  errmsg = "NOTATION: Name expected here";
438  break;
440  errmsg = "'>' required to close NOTATION declaration";
441  break;
443  errmsg = "Entity value required";
444  break;
446  errmsg = "Fragment not allowed";
447  break;
449  errmsg = "'(' required to start ATTLIST enumeration";
450  break;
452  errmsg = "NmToken expected in ATTLIST enumeration";
453  break;
455  errmsg = "')' required to finish ATTLIST enumeration";
456  break;
458  errmsg = "MixedContentDecl : '|' or ')*' expected";
459  break;
461  errmsg = "MixedContentDecl : '#PCDATA' expected";
462  break;
464  errmsg = "ContentDecl : Name or '(' expected";
465  break;
467  errmsg = "ContentDecl : ',' '|' or ')' expected";
468  break;
470  errmsg =
471  "PEReference: forbidden within markup decl in internal subset";
472  break;
473  case XML_ERR_GT_REQUIRED:
474  errmsg = "expected '>'";
475  break;
477  errmsg = "XML conditional section '[' expected";
478  break;
480  errmsg = "Content error in the external subset";
481  break;
483  errmsg =
484  "conditional section INCLUDE or IGNORE keyword expected";
485  break;
487  errmsg = "XML conditional section not closed";
488  break;
490  errmsg = "Text declaration '<?xml' required";
491  break;
493  errmsg = "parsing XML declaration: '?>' expected";
494  break;
496  errmsg = "external parsed entities cannot be standalone";
497  break;
499  errmsg = "EntityRef: expecting ';'";
500  break;
502  errmsg = "DOCTYPE improperly terminated";
503  break;
505  errmsg = "EndTag: '</' not found";
506  break;
508  errmsg = "expected '='";
509  break;
511  errmsg = "String not closed expecting \" or '";
512  break;
514  errmsg = "String not started expecting ' or \"";
515  break;
517  errmsg = "Invalid XML encoding name";
518  break;
520  errmsg = "standalone accepts only 'yes' or 'no'";
521  break;
523  errmsg = "Document is empty";
524  break;
526  errmsg = "Extra content at the end of the document";
527  break;
529  errmsg = "chunk is not well balanced";
530  break;
532  errmsg = "extra content at the end of well balanced chunk";
533  break;
535  errmsg = "Malformed declaration expecting version";
536  break;
538  errmsg = "Name too long use XML_PARSE_HUGE option";
539  break;
540 #if 0
541  case:
542  errmsg = "";
543  break;
544 #endif
545  default:
546  errmsg = "Unregistered error message";
547  }
548  if (ctxt != NULL)
549  ctxt->errNo = error;
550  if (info == NULL) {
551  __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
552  XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s\n",
553  errmsg);
554  } else {
555  __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
556  XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s: %s\n",
557  errmsg, info);
558  }
559  if (ctxt != NULL) {
560  ctxt->wellFormed = 0;
561  if (ctxt->recovery == 0)
562  ctxt->disableSAX = 1;
563  }
564 }
xmlParserInputState instate
Definition: parser.h:223
int disableSAX
Definition: parser.h:237
int recovery
Definition: parser.h:261
smooth NULL
Definition: ftsmooth.c:416
EXPORT int errmsg(char *msg, va_alist)
Definition: comerr.c:192
int wellFormed
Definition: parser.h:188
DWORD error
Definition: parser.c:105

Referenced by xmlGROW(), xmlLoadEntityContent(), xmlParseAttValueComplex(), xmlParseAttValueInternal(), xmlParseBalancedChunkMemoryInternal(), xmlParseCDSect(), xmlParseCharData(), xmlParseCharDataComplex(), xmlParseCharRef(), xmlParseCommentComplex(), xmlParseConditionalSections(), xmlParseContent(), xmlParseCtxtExternalEntity(), xmlParseDocTypeDecl(), xmlParseDocument(), xmlParseElementChildrenContentDeclPriv(), xmlParseElementDecl(), xmlParseElementMixedContentDecl(), xmlParseEncName(), xmlParseEncodingDecl(), xmlParseEndTag2(), xmlParseEntityDecl(), xmlParseEntityRef(), xmlParseEntityValue(), xmlParseEnumerationType(), xmlParseExternalEntityPrivate(), xmlParseExternalID(), xmlParseExternalSubset(), xmlParseExtParsedEnt(), xmlParseInNodeContext(), xmlParseInternalSubset(), xmlParseName(), xmlParseNameComplex(), xmlParseNCName(), xmlParseNCNameComplex(), xmlParseNmtoken(), xmlParseNotationDecl(), xmlParseNotationType(), xmlParsePEReference(), xmlParsePI(), xmlParsePITarget(), xmlParsePubidLiteral(), xmlParseReference(), xmlParserEntityCheck(), xmlParserHandlePEReference(), xmlParseSDDecl(), xmlParseStartTag2(), xmlParseStringCharRef(), xmlParseStringEntityRef(), xmlParseStringName(), xmlParseStringPEReference(), xmlParseSystemLiteral(), xmlParseTextDecl(), xmlParseVersionInfo(), xmlParseXMLDecl(), xmlPopInput(), xmlPushInput(), and xmlStringLenDecodeEntities().

◆ xmlGenericErrorDefaultFunc()

void XMLCDECL xmlGenericErrorDefaultFunc ( void ctx,
const char msg,
  ... 
)

Referenced by xmlInitParser().

◆ xmlGetNamespace()

static const xmlChar* xmlGetNamespace ( xmlParserCtxtPtr  ctxt,
const xmlChar prefix 
)
static

Definition at line 8686 of file parser.c.

8686  {
8687  int i;
8688 
8689  if (prefix == ctxt->str_xml) return(ctxt->str_xml_ns);
8690  for (i = ctxt->nsNr - 2;i >= 0;i-=2)
8691  if (ctxt->nsTab[i] == prefix) {
8692  if ((prefix == NULL) && (*ctxt->nsTab[i + 1] == 0))
8693  return(NULL);
8694  return(ctxt->nsTab[i + 1]);
8695  }
8696  return(NULL);
8697 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
const xmlChar * str_xml
Definition: parser.h:271
smooth NULL
Definition: ftsmooth.c:416
const xmlChar * str_xml_ns
Definition: parser.h:273
const xmlChar ** nsTab
Definition: parser.h:281

Referenced by xmlParseInNodeContext(), and xmlParseStartTag2().

◆ xmlGROW()

static void xmlGROW ( xmlParserCtxtPtr  ctxt)
static

Definition at line 2091 of file parser.c.

2091  {
2092  ptrdiff_t curEnd = ctxt->input->end - ctxt->input->cur;
2093  ptrdiff_t curBase = ctxt->input->cur - ctxt->input->base;
2094 
2095  if (((curEnd > XML_MAX_LOOKUP_LIMIT) ||
2096  (curBase > XML_MAX_LOOKUP_LIMIT)) &&
2097  ((ctxt->input->buf) &&
2099  ((ctxt->options & XML_PARSE_HUGE) == 0)) {
2100  xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup");
2101  xmlHaltParser(ctxt);
2102  return;
2103  }
2105  if ((ctxt->input->cur > ctxt->input->end) ||
2106  (ctxt->input->cur < ctxt->input->base)) {
2107  xmlHaltParser(ctxt);
2108  xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "cur index out of bound");
2109  return;
2110  }
2111  if ((ctxt->input->cur != NULL) && (*ctxt->input->cur == 0))
2113 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:359
#define XML_MAX_LOOKUP_LIMIT
const xmlChar * cur
Definition: parser.h:61
const xmlChar * base
Definition: parser.h:60
xmlInputReadCallback readcallback
Definition: xmlIO.h:127
xmlParserInputPtr input
Definition: parser.h:199
smooth NULL
Definition: ftsmooth.c:416
int xmlInputReadCallbackNop(void *context, char *buffer, int len)
XMLPUBFUN int XMLCALL xmlParserInputGrow(xmlParserInputPtr in, int len)
#define INPUT_CHUNK
xmlParserInputBufferPtr buf
Definition: parser.h:56
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
static void xmlHaltParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12478
const xmlChar * end
Definition: parser.h:62

◆ xmlHaltParser()

static void xmlHaltParser ( xmlParserCtxtPtr  ctxt)
static

xmlHaltParser: @ctxt: an XML parser context

Blocks further parser processing don't override error for internal use

Definition at line 12478 of file parser.c.

12478  {
12479  if (ctxt == NULL)
12480  return;
12481  ctxt->instate = XML_PARSER_EOF;
12482  ctxt->disableSAX = 1;
12483  while (ctxt->inputNr > 1)
12485  if (ctxt->input != NULL) {
12486  /*
12487  * in case there was a specific allocation deallocate before
12488  * overriding base
12489  */
12490  if (ctxt->input->free != NULL) {
12491  ctxt->input->free((xmlChar *) ctxt->input->base);
12492  ctxt->input->free = NULL;
12493  }
12494  if (ctxt->input->buf != NULL) {
12496  ctxt->input->buf = NULL;
12497  }
12498  ctxt->input->cur = BAD_CAST"";
12499  ctxt->input->length = 0;
12500  ctxt->input->base = ctxt->input->cur;
12501  ctxt->input->end = ctxt->input->cur;
12502  }
12503 }
xmlParserInputState instate
Definition: parser.h:223
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
const xmlChar * cur
Definition: parser.h:61
xmlParserInputDeallocate free
Definition: parser.h:72
const xmlChar * base
Definition: parser.h:60
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN void XMLCALL xmlFreeInputStream(xmlParserInputPtr input)
#define BAD_CAST
Definition: xmlstring.h:35
xmlParserInputPtr inputPop(xmlParserCtxtPtr ctxt)
Definition: parser.c:1749
unsigned char xmlChar
Definition: xmlstring.h:28
xmlParserInputBufferPtr buf
Definition: parser.h:56
const xmlChar * end
Definition: parser.h:62

Referenced by nodePush(), xmlGROW(), xmlParseConditionalSections(), xmlParseContent(), xmlParseElementStart(), xmlParseEntityDecl(), xmlParseExternalSubset(), and xmlStopParser().

◆ xmlHasFeature()

int xmlHasFeature ( xmlFeature  feature)

xmlHasFeature: @feature: the feature to be examined

Examines if the library has been compiled with a given feature.

Returns a non-zero value if the feature exist, otherwise zero. Returns zero (0) if the feature does not exist or an unknown unknown feature is requested, non-zero otherwise.

Definition at line 855 of file parser.c.

856 {
857  switch (feature) {
858  case XML_WITH_THREAD:
859 #ifdef LIBXML_THREAD_ENABLED
860  return(1);
861 #else
862  return(0);
863 #endif
864  case XML_WITH_TREE:
865 #ifdef LIBXML_TREE_ENABLED
866  return(1);
867 #else
868  return(0);
869 #endif
870  case XML_WITH_OUTPUT:
871 #ifdef LIBXML_OUTPUT_ENABLED
872  return(1);
873 #else
874  return(0);
875 #endif
876  case XML_WITH_PUSH:
877 #ifdef LIBXML_PUSH_ENABLED
878  return(1);
879 #else
880  return(0);
881 #endif
882  case XML_WITH_READER:
883 #ifdef LIBXML_READER_ENABLED
884  return(1);
885 #else
886  return(0);
887 #endif
888  case XML_WITH_PATTERN:
889 #ifdef LIBXML_PATTERN_ENABLED
890  return(1);
891 #else
892  return(0);
893 #endif
894  case XML_WITH_WRITER:
895 #ifdef LIBXML_WRITER_ENABLED
896  return(1);
897 #else
898  return(0);
899 #endif
900  case XML_WITH_SAX1:
901 #ifdef LIBXML_SAX1_ENABLED
902  return(1);
903 #else
904  return(0);
905 #endif
906  case XML_WITH_FTP:
907 #ifdef LIBXML_FTP_ENABLED
908  return(1);
909 #else
910  return(0);
911 #endif
912  case XML_WITH_HTTP:
913 #ifdef LIBXML_HTTP_ENABLED
914  return(1);
915 #else
916  return(0);
917 #endif
918  case XML_WITH_VALID:
919 #ifdef LIBXML_VALID_ENABLED
920  return(1);
921 #else
922  return(0);
923 #endif
924  case XML_WITH_HTML:
925 #ifdef LIBXML_HTML_ENABLED
926  return(1);
927 #else
928  return(0);
929 #endif
930  case XML_WITH_LEGACY:
931 #ifdef LIBXML_LEGACY_ENABLED
932  return(1);
933 #else
934  return(0);
935 #endif
936  case XML_WITH_C14N:
937 #ifdef LIBXML_C14N_ENABLED
938  return(1);
939 #else
940  return(0);
941 #endif
942  case XML_WITH_CATALOG:
943 #ifdef LIBXML_CATALOG_ENABLED
944  return(1);
945 #else
946  return(0);
947 #endif
948  case