ReactOS 0.4.15-dev-8135-g1bc6c90
parser.c File Reference
#include "libxml.h"
#include <stdlib.h>
#include <limits.h>
#include <string.h>
#include <stdarg.h>
#include <stddef.h>
#include <ctype.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 "buf.h"
#include "enc.h"
Include dependency graph for parser.c:

Go to the source code of this file.

Classes

struct  _xmlStartTag
 
struct  _xmlDefAttrs
 

Macros

#define IN_LIBXML
 
#define XML_DIR_SEP   '/'
 
#define XML_MAX_HUGE_LENGTH   1000000000
 
#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 CUR_CONSUMED    (ctxt->input->consumed + (ctxt->input->cur - ctxt->input->base))
 
#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 line, 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 char *const xmlW3CPIs []
 

: 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)
 
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 xmlStartTag *tag)
 
void xmlParseCDSect (xmlParserCtxtPtr ctxt)
 
static void xmlParseContentInternal (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)
 

: 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)
 

Macro Definition Documentation

◆ BASE_PTR

#define BASE_PTR   ctxt->input->base

Definition at line 2068 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 )
GLdouble s
Definition: gl.h:2039
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2081

Definition at line 2084 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 )

Definition at line 2070 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 2073 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 2075 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 2077 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 2079 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 )
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2079

Definition at line 2081 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)
r l[0]
Definition: byte_order.h:168
const GLdouble * v
Definition: gl.h:2040
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
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
XMLPUBFUN int XMLCALL xmlCopyCharMultiByte(xmlChar *out, int val)
unsigned char xmlChar
Definition: xmlstring.h:28

Definition at line 2166 of file parser.c.

◆ CUR

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

Definition at line 2065 of file parser.c.

◆ CUR_CHAR

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

Definition at line 2163 of file parser.c.

◆ CUR_CONSUMED

#define CUR_CONSUMED    (ctxt->input->consumed + (ctxt->input->cur - ctxt->input->base))

Definition at line 2170 of file parser.c.

◆ CUR_PTR

#define CUR_PTR   ctxt->input->cur

Definition at line 2067 of file parser.c.

◆ CUR_SCHAR

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

Definition at line 2164 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
XMLPUBFUN int XMLCALL xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1220

DICT_FREE: @str: a string

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

Definition at line 14789 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 2117 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;
#define NULL
Definition: types.h:112
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLuint in
Definition: glext.h:9616
@ XML_PARSER_EOF
Definition: parser.h:111
#define GROW
Definition: parser.c:2117

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 8947 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
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250

Definition at line 2613 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 2147 of file parser.c.

◆ NEXT1

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

Definition at line 2149 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)

Definition at line 2156 of file parser.c.

◆ NXT

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

Definition at line 2066 of file parser.c.

◆ RAW

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

Definition at line 2064 of file parser.c.

◆ SAX2

#define SAX2   1

Definition at line 274 of file parser.c.

◆ SAX_COMPAT_MODE

#define SAX_COMPAT_MODE   BAD_CAST "SAX compatibility mode document"

Definition at line 277 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);

Definition at line 2106 of file parser.c.

◆ SKIP

#define SKIP (   val)
Value:
do { \
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

Definition at line 2088 of file parser.c.

◆ SKIP_BLANKS

#define SKIP_BLANKS   xmlSkipBlankChars(ctxt)

Definition at line 2145 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->input->cur++; \
} \
if (*ctxt->input->cur == 0) \
xmlParserInputGrow(ctxt->input, INPUT_CHUNK); \
} while (0)

Definition at line 2094 of file parser.c.

◆ XML_DIR_SEP

#define XML_DIR_SEP   '/'

Definition at line 44 of file parser.c.

◆ XML_MAX_HUGE_LENGTH

#define XML_MAX_HUGE_LENGTH   1000000000

Definition at line 105 of file parser.c.

◆ XML_PARSER_BIG_BUFFER_SIZE

#define XML_PARSER_BIG_BUFFER_SIZE   300

Definition at line 275 of file parser.c.

◆ XML_PARSER_BIG_ENTITY

#define XML_PARSER_BIG_ENTITY   1000

Definition at line 107 of file parser.c.

◆ XML_PARSER_BUFFER_SIZE

#define XML_PARSER_BUFFER_SIZE   100

Definition at line 276 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 288 of file parser.c.

◆ XML_PARSER_LOT_ENTITY

#define XML_PARSER_LOT_ENTITY   5000

Definition at line 108 of file parser.c.

◆ XML_PARSER_NON_LINEAR

#define XML_PARSER_NON_LINEAR   10

Definition at line 116 of file parser.c.

Typedef Documentation

◆ xmlDefAttrs

Definition at line 1121 of file parser.c.

◆ xmlDefAttrsPtr

Definition at line 1122 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 2864 of file parser.c.

2865 {
2866 int i, ret;
2867 xmlNodePtr lastChild;
2868
2869 /*
2870 * Don't spend time trying to differentiate them, the same callback is
2871 * used !
2872 */
2873 if (ctxt->sax->ignorableWhitespace == ctxt->sax->characters)
2874 return(0);
2875
2876 /*
2877 * Check for xml:space value.
2878 */
2879 if ((ctxt->space == NULL) || (*(ctxt->space) == 1) ||
2880 (*(ctxt->space) == -2))
2881 return(0);
2882
2883 /*
2884 * Check that the string is made of blanks
2885 */
2886 if (blank_chars == 0) {
2887 for (i = 0;i < len;i++)
2888 if (!(IS_BLANK_CH(str[i]))) return(0);
2889 }
2890
2891 /*
2892 * Look if the element is mixed content in the DTD if available
2893 */
2894 if (ctxt->node == NULL) return(0);
2895 if (ctxt->myDoc != NULL) {
2896 ret = xmlIsMixedElement(ctxt->myDoc, ctxt->node->name);
2897 if (ret == 0) return(1);
2898 if (ret == 1) return(0);
2899 }
2900
2901 /*
2902 * Otherwise, heuristic :-\
2903 */
2904 if ((RAW != '<') && (RAW != 0xD)) return(0);
2905 if ((ctxt->node->children == NULL) &&
2906 (RAW == '<') && (NXT(1) == '/')) return(0);
2907
2908 lastChild = xmlGetLastChild(ctxt->node);
2909 if (lastChild == NULL) {
2910 if ((ctxt->node->type != XML_ELEMENT_NODE) &&
2911 (ctxt->node->content != NULL)) return(0);
2912 } else if (xmlNodeIsText(lastChild))
2913 return(0);
2914 else if ((ctxt->node->children != NULL) &&
2915 (xmlNodeIsText(ctxt->node->children)))
2916 return(0);
2917 return(1);
2918}
GLenum GLsizei len
Definition: glext.h:6722
#define IS_BLANK_CH(c)
XMLPUBFUN xmlNodePtr XMLCALL xmlGetLastChild(const xmlNode *parent)
XMLPUBFUN int XMLCALL xmlNodeIsText(const xmlNode *node)
@ XML_ELEMENT_NODE
Definition: tree.h:160
#define RAW
Definition: parser.c:2064
#define NXT(val)
Definition: parser.c:2066
Definition: tree.h:489
xmlChar * content
Definition: tree.h:502
struct _xmlNode * children
Definition: tree.h:493
const xmlChar * name
Definition: tree.h:492
xmlElementType type
Definition: tree.h:491
int * space
Definition: parser.h:244
struct _xmlSAXHandler * sax
Definition: parser.h:185
xmlDocPtr myDoc
Definition: parser.h:187
xmlNodePtr node
Definition: parser.h:205
XMLPUBFUN int XMLCALL xmlIsMixedElement(xmlDocPtr doc, const xmlChar *name)
Definition: valid.c:3494
int ret

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 1774 of file parser.c.

1775{
1777
1778 if (ctxt == NULL)
1779 return(NULL);
1780 if (ctxt->inputNr <= 0)
1781 return (NULL);
1782 ctxt->inputNr--;
1783 if (ctxt->inputNr > 0)
1784 ctxt->input = ctxt->inputTab[ctxt->inputNr - 1];
1785 else
1786 ctxt->input = NULL;
1787 ret = ctxt->inputTab[ctxt->inputNr];
1788 ctxt->inputTab[ctxt->inputNr] = NULL;
1789 return (ret);
1790}
xmlParserInputPtr * inputTab
Definition: parser.h:202
xmlParserInputPtr input
Definition: parser.h:199

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 1745 of file parser.c.

1746{
1747 if ((ctxt == NULL) || (value == NULL))
1748 return(-1);
1749 if (ctxt->inputNr >= ctxt->inputMax) {
1750 ctxt->inputMax *= 2;
1751 ctxt->inputTab =
1753 ctxt->inputMax *
1754 sizeof(ctxt->inputTab[0]));
1755 if (ctxt->inputTab == NULL) {
1756 xmlErrMemory(ctxt, NULL);
1757 ctxt->inputMax /= 2;
1758 return (-1);
1759 }
1760 }
1761 ctxt->inputTab[ctxt->inputNr] = value;
1762 ctxt->input = value;
1763 return (ctxt->inputNr++);
1764}
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
int inputMax
Definition: parser.h:201
Definition: pdh_main.c:94

Referenced by testSAX(), xmlCreateEntityParserCtxtInternal(), xmlCreateIOParserCtxt(), xmlCreateMemoryParserCtxt(), xmlCreateURLParserCtxt(), 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 593 of file parser.c.

596{
597 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
598 (ctxt->instate == XML_PARSER_EOF))
599 return;
600 if (ctxt != NULL)
601 ctxt->errNo = error;
602 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
603 XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "%s", msg);
604 if (ctxt != NULL) {
605 ctxt->wellFormed = 0;
606 if (ctxt->recovery == 0)
607 ctxt->disableSAX = 1;
608 }
609}
#define msg(x)
Definition: auth_time.c:54
#define error(str)
Definition: mkdosfs.c:1605
@ XML_ERR_FATAL
Definition: xmlerror.h:28
@ XML_FROM_PARSER
Definition: xmlerror.h:38

◆ nameNsPush()

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

nameNsPush: @ctxt: an XML parser context @value: the element name @prefix: the element prefix @URI: the element namespace name the current line number for error messages @nsNr: the number of namespaces pushed on the namespace table

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 1870 of file parser.c.

1872{
1874
1875 if (ctxt->nameNr >= ctxt->nameMax) {
1876 const xmlChar * *tmp;
1877 xmlStartTag *tmp2;
1878 ctxt->nameMax *= 2;
1879 tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,
1880 ctxt->nameMax *
1881 sizeof(ctxt->nameTab[0]));
1882 if (tmp == NULL) {
1883 ctxt->nameMax /= 2;
1884 goto mem_error;
1885 }
1886 ctxt->nameTab = tmp;
1887 tmp2 = (xmlStartTag *) xmlRealloc((void * *)ctxt->pushTab,
1888 ctxt->nameMax *
1889 sizeof(ctxt->pushTab[0]));
1890 if (tmp2 == NULL) {
1891 ctxt->nameMax /= 2;
1892 goto mem_error;
1893 }
1894 ctxt->pushTab = tmp2;
1895 } else if (ctxt->pushTab == NULL) {
1896 ctxt->pushTab = (xmlStartTag *) xmlMalloc(ctxt->nameMax *
1897 sizeof(ctxt->pushTab[0]));
1898 if (ctxt->pushTab == NULL)
1899 goto mem_error;
1900 }
1901 ctxt->nameTab[ctxt->nameNr] = value;
1902 ctxt->name = value;
1903 tag = &ctxt->pushTab[ctxt->nameNr];
1904 tag->prefix = prefix;
1905 tag->URI = URI;
1906 tag->line = line;
1907 tag->nsNr = nsNr;
1908 return (ctxt->nameNr++);
1909mem_error:
1910 xmlErrMemory(ctxt, NULL);
1911 return (-1);
1912}
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
xmlStartTag * pushTab
Definition: parser.h:283
const xmlChar * name
Definition: parser.h:229
const xmlChar ** nameTab
Definition: parser.h:232
Definition: parser.c:49
Definition: ecma_167.h:138

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 1981 of file parser.c.

1982{
1983 const xmlChar *ret;
1984
1985 if ((ctxt == NULL) || (ctxt->nameNr <= 0))
1986 return (NULL);
1987 ctxt->nameNr--;
1988 if (ctxt->nameNr > 0)
1989 ctxt->name = ctxt->nameTab[ctxt->nameNr - 1];
1990 else
1991 ctxt->name = NULL;
1992 ret = ctxt->nameTab[ctxt->nameNr];
1993 ctxt->nameTab[ctxt->nameNr] = NULL;
1994 return (ret);
1995}

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 1950 of file parser.c.

1951{
1952 if (ctxt == NULL) return (-1);
1953
1954 if (ctxt->nameNr >= ctxt->nameMax) {
1955 const xmlChar * *tmp;
1956 tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,
1957 ctxt->nameMax * 2 *
1958 sizeof(ctxt->nameTab[0]));
1959 if (tmp == NULL) {
1960 goto mem_error;
1961 }
1962 ctxt->nameTab = tmp;
1963 ctxt->nameMax *= 2;
1964 }
1965 ctxt->nameTab[ctxt->nameNr] = value;
1966 ctxt->name = value;
1967 return (ctxt->nameNr++);
1968mem_error:
1969 xmlErrMemory(ctxt, NULL);
1970 return (-1);
1971}

◆ 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 1839 of file parser.c.

1840{
1842
1843 if (ctxt == NULL) return(NULL);
1844 if (ctxt->nodeNr <= 0)
1845 return (NULL);
1846 ctxt->nodeNr--;
1847 if (ctxt->nodeNr > 0)
1848 ctxt->node = ctxt->nodeTab[ctxt->nodeNr - 1];
1849 else
1850 ctxt->node = NULL;
1851 ret = ctxt->nodeTab[ctxt->nodeNr];
1852 ctxt->nodeTab[ctxt->nodeNr] = NULL;
1853 return (ret);
1854}
xmlNodePtr * nodeTab
Definition: parser.h:208

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 1801 of file parser.c.

1802{
1803 if (ctxt == NULL) return(0);
1804 if (ctxt->nodeNr >= ctxt->nodeMax) {
1805 xmlNodePtr *tmp;
1806
1807 tmp = (xmlNodePtr *) xmlRealloc(ctxt->nodeTab,
1808 ctxt->nodeMax * 2 *
1809 sizeof(ctxt->nodeTab[0]));
1810 if (tmp == NULL) {
1811 xmlErrMemory(ctxt, NULL);
1812 return (-1);
1813 }
1814 ctxt->nodeTab = tmp;
1815 ctxt->nodeMax *= 2;
1816 }
1817 if ((((unsigned int) ctxt->nodeNr) > xmlParserMaxDepth) &&
1818 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
1819 xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
1820 "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
1822 xmlHaltParser(ctxt);
1823 return(-1);
1824 }
1825 ctxt->nodeTab[ctxt->nodeNr] = value;
1826 ctxt->node = value;
1827 return (ctxt->nodeNr++);
1828}
@ XML_PARSE_HUGE
Definition: parser.h:1114
unsigned int xmlParserMaxDepth
Definition: parser.c:270
static void xmlHaltParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12549
@ XML_ERR_INTERNAL_ERROR
Definition: xmlerror.h:101

Referenced by xmlParseBalancedChunkMemoryInternal(), 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 1681 of file parser.c.

1682{
1683 int i;
1684
1685 if (ctxt->nsTab == NULL) return(0);
1686 if (ctxt->nsNr < nr) {
1687 xmlGenericError(xmlGenericErrorContext, "Pbm popping %d NS\n", nr);
1688 nr = ctxt->nsNr;
1689 }
1690 if (ctxt->nsNr <= 0)
1691 return (0);
1692
1693 for (i = 0;i < nr;i++) {
1694 ctxt->nsNr--;
1695 ctxt->nsTab[ctxt->nsNr] = NULL;
1696 }
1697 return(nr);
1698}
ULONG nr
Definition: thread.c:7
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:353
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:337
const xmlChar ** nsTab
Definition: parser.h:281

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 1631 of file parser.c.

1632{
1633 if (ctxt->options & XML_PARSE_NSCLEAN) {
1634 int i;
1635 for (i = ctxt->nsNr - 2;i >= 0;i -= 2) {
1636 if (ctxt->nsTab[i] == prefix) {
1637 /* in scope */
1638 if (ctxt->nsTab[i + 1] == URL)
1639 return(-2);
1640 /* out of scope keep it */
1641 break;
1642 }
1643 }
1644 }
1645 if ((ctxt->nsMax == 0) || (ctxt->nsTab == NULL)) {
1646 ctxt->nsMax = 10;
1647 ctxt->nsNr = 0;
1648 ctxt->nsTab = (const xmlChar **)
1649 xmlMalloc(ctxt->nsMax * sizeof(xmlChar *));
1650 if (ctxt->nsTab == NULL) {
1651 xmlErrMemory(ctxt, NULL);
1652 ctxt->nsMax = 0;
1653 return (-1);
1654 }
1655 } else if (ctxt->nsNr >= ctxt->nsMax) {
1656 const xmlChar ** tmp;
1657 ctxt->nsMax *= 2;
1658 tmp = (const xmlChar **) xmlRealloc((char *) ctxt->nsTab,
1659 ctxt->nsMax * sizeof(ctxt->nsTab[0]));
1660 if (tmp == NULL) {
1661 xmlErrMemory(ctxt, NULL);
1662 ctxt->nsMax /= 2;
1663 return (-1);
1664 }
1665 ctxt->nsTab = tmp;
1666 }
1667 ctxt->nsTab[ctxt->nsNr++] = prefix;
1668 ctxt->nsTab[ctxt->nsNr++] = URL;
1669 return (ctxt->nsNr);
1670}
@ XML_PARSE_NSCLEAN
Definition: parser.h:1106

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

◆ spacePop()

static int spacePop ( xmlParserCtxtPtr  ctxt)
static

Definition at line 2016 of file parser.c.

2016 {
2017 int ret;
2018 if (ctxt->spaceNr <= 0) return(0);
2019 ctxt->spaceNr--;
2020 if (ctxt->spaceNr > 0)
2021 ctxt->space = &ctxt->spaceTab[ctxt->spaceNr - 1];
2022 else
2023 ctxt->space = &ctxt->spaceTab[0];
2024 ret = ctxt->spaceTab[ctxt->spaceNr];
2025 ctxt->spaceTab[ctxt->spaceNr] = -1;
2026 return(ret);
2027}
int * spaceTab
Definition: parser.h:247

Referenced by xmlParseElementStart(), and xmlParseEndTag2().

◆ spacePush()

static int spacePush ( xmlParserCtxtPtr  ctxt,
int  val 
)
static

Definition at line 1997 of file parser.c.

1997 {
1998 if (ctxt->spaceNr >= ctxt->spaceMax) {
1999 int *tmp;
2000
2001 ctxt->spaceMax *= 2;
2002 tmp = (int *) xmlRealloc(ctxt->spaceTab,
2003 ctxt->spaceMax * sizeof(ctxt->spaceTab[0]));
2004 if (tmp == NULL) {
2005 xmlErrMemory(ctxt, NULL);
2006 ctxt->spaceMax /=2;
2007 return(-1);
2008 }
2009 ctxt->spaceTab = tmp;
2010 }
2011 ctxt->spaceTab[ctxt->spaceNr] = val;
2012 ctxt->space = &ctxt->spaceTab[ctxt->spaceNr];
2013 return(ctxt->spaceNr++);
2014}
int spaceMax
Definition: parser.h:246

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 1242 of file parser.c.

1245 {
1247 int len;
1248 const xmlChar *name;
1249 const xmlChar *prefix;
1250
1251 /*
1252 * Allows to detect attribute redefinitions
1253 */
1254 if (ctxt->attsSpecial != NULL) {
1255 if (xmlHashLookup2(ctxt->attsSpecial, fullname, fullattr) != NULL)
1256 return;
1257 }
1258
1259 if (ctxt->attsDefault == NULL) {
1260 ctxt->attsDefault = xmlHashCreateDict(10, ctxt->dict);
1261 if (ctxt->attsDefault == NULL)
1262 goto mem_error;
1263 }
1264
1265 /*
1266 * split the element name into prefix:localname , the string found
1267 * are within the DTD and then not associated to namespace names.
1268 */
1270 if (name == NULL) {
1271 name = xmlDictLookup(ctxt->dict, fullname, -1);
1272 prefix = NULL;
1273 } else {
1274 name = xmlDictLookup(ctxt->dict, name, -1);
1275 prefix = xmlDictLookup(ctxt->dict, fullname, len);
1276 }
1277
1278 /*
1279 * make sure there is some storage
1280 */
1281 defaults = xmlHashLookup2(ctxt->attsDefault, name, prefix);
1282 if (defaults == NULL) {
1284 (4 * 5) * sizeof(const xmlChar *));
1285 if (defaults == NULL)
1286 goto mem_error;
1287 defaults->nbAttrs = 0;
1288 defaults->maxAttrs = 4;
1289 if (xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix,
1290 defaults, NULL) < 0) {
1292 goto mem_error;
1293 }
1294 } else if (defaults->nbAttrs >= defaults->maxAttrs) {
1296
1298 (2 * defaults->maxAttrs * 5) * sizeof(const xmlChar *));
1299 if (temp == NULL)
1300 goto mem_error;
1301 defaults = temp;
1302 defaults->maxAttrs *= 2;
1303 if (xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix,
1304 defaults, NULL) < 0) {
1306 goto mem_error;
1307 }
1308 }
1309
1310 /*
1311 * Split the element name into prefix:localname , the string found
1312 * are within the DTD and hen not associated to namespace names.
1313 */
1314 name = xmlSplitQName3(fullattr, &len);
1315 if (name == NULL) {
1316 name = xmlDictLookup(ctxt->dict, fullattr, -1);
1317 prefix = NULL;
1318 } else {
1319 name = xmlDictLookup(ctxt->dict, name, -1);
1320 prefix = xmlDictLookup(ctxt->dict, fullattr, len);
1321 }
1322
1323 defaults->values[5 * defaults->nbAttrs] = name;
1324 defaults->values[5 * defaults->nbAttrs + 1] = prefix;
1325 /* intern the string and precompute the end */
1326 len = xmlStrlen(value);
1327 value = xmlDictLookup(ctxt->dict, value, len);
1328 defaults->values[5 * defaults->nbAttrs + 2] = value;
1329 defaults->values[5 * defaults->nbAttrs + 3] = value + len;
1330 if (ctxt->external)
1331 defaults->values[5 * defaults->nbAttrs + 4] = BAD_CAST "external";
1332 else
1333 defaults->values[5 * defaults->nbAttrs + 4] = NULL;
1334 defaults->nbAttrs++;
1335
1336 return;
1337
1338mem_error:
1339 xmlErrMemory(ctxt, NULL);
1340 return;
1341}
const char * fullname
Definition: shader.c:1766
static const ASMPROP_RES defaults[ASM_NAME_MAX_PARAMS]
Definition: asmname.c:82
static calc_node_t temp
Definition: rpn_ieee.c:38
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:867
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
XMLPUBFUN int XMLCALL xmlHashUpdateEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata, xmlHashDeallocator f)
Definition: hash.c:445
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreateDict(int size, xmlDictPtr dict)
Definition: hash.c:210
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:476
XMLPUBFUN const xmlChar *XMLCALL xmlSplitQName3(const xmlChar *name, int *len)
xmlDefAttrs * xmlDefAttrsPtr
Definition: parser.c:1122
int external
Definition: parser.h:217
xmlDictPtr dict
Definition: parser.h:263
xmlHashTablePtr attsSpecial
Definition: parser.h:285
xmlHashTablePtr attsDefault
Definition: parser.h:284
Definition: name.c:39
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:426

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 1353 of file parser.c.

1357{
1358 if (ctxt->attsSpecial == NULL) {
1359 ctxt->attsSpecial = xmlHashCreateDict(10, ctxt->dict);
1360 if (ctxt->attsSpecial == NULL)
1361 goto mem_error;
1362 }
1363
1364 if (xmlHashLookup2(ctxt->attsSpecial, fullname, fullattr) != NULL)
1365 return;
1366
1367 xmlHashAddEntry2(ctxt->attsSpecial, fullname, fullattr,
1368 (void *) (ptrdiff_t) type);
1369 return;
1370
1371mem_error:
1372 xmlErrMemory(ctxt, NULL);
1373 return;
1374}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
XMLPUBFUN int XMLCALL xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata)
Definition: hash.c:406

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 1152 of file parser.c.

1153{
1154 if ((src == NULL) || (dst == NULL))
1155 return(NULL);
1156
1157 while (*src == 0x20) src++;
1158 while (*src != 0) {
1159 if (*src == 0x20) {
1160 while (*src == 0x20) src++;
1161 if (*src != 0)
1162 *dst++ = 0x20;
1163 } else {
1164 *dst++ = *src++;
1165 }
1166 }
1167 *dst = 0;
1168 if (dst == src)
1169 return(NULL);
1170 return(dst);
1171}
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 1185 of file parser.c.

1186{
1187 int i;
1188 int remove_head = 0;
1189 int need_realloc = 0;
1190 const xmlChar *cur;
1191
1192 if ((ctxt == NULL) || (src == NULL) || (len == NULL))
1193 return(NULL);
1194 i = *len;
1195 if (i <= 0)
1196 return(NULL);
1197
1198 cur = src;
1199 while (*cur == 0x20) {
1200 cur++;
1201 remove_head++;
1202 }
1203 while (*cur != 0) {
1204 if (*cur == 0x20) {
1205 cur++;
1206 if ((*cur == 0x20) || (*cur == 0)) {
1207 need_realloc = 1;
1208 break;
1209 }
1210 } else
1211 cur++;
1212 }
1213 if (need_realloc) {
1214 xmlChar *ret;
1215
1216 ret = xmlStrndup(src + remove_head, i - remove_head + 1);
1217 if (ret == NULL) {
1218 xmlErrMemory(ctxt, NULL);
1219 return(NULL);
1220 }
1222 *len = (int) strlen((const char *)ret);
1223 return(ret);
1224 } else if (remove_head) {
1225 *len -= remove_head;
1226 memmove(src, src + remove_head, 1 + *len);
1227 return(src);
1228 }
1229 return(NULL);
1230}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
FxCollectionEntry * cur
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static xmlChar * xmlAttrNormalizeSpace(const xmlChar *src, xmlChar *dst)
Definition: parser.c:1152
XMLPUBFUN xmlChar *XMLCALL xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:42

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 1474 of file parser.c.

1475{
1476 const xmlChar *cur = lang, *nxt;
1477
1478 if (cur == NULL)
1479 return (0);
1480 if (((cur[0] == 'i') && (cur[1] == '-')) ||
1481 ((cur[0] == 'I') && (cur[1] == '-')) ||
1482 ((cur[0] == 'x') && (cur[1] == '-')) ||
1483 ((cur[0] == 'X') && (cur[1] == '-'))) {
1484 /*
1485 * Still allow IANA code and user code which were coming
1486 * from the previous version of the XML-1.0 specification
1487 * it's deprecated but we should not fail
1488 */
1489 cur += 2;
1490 while (((cur[0] >= 'A') && (cur[0] <= 'Z')) ||
1491 ((cur[0] >= 'a') && (cur[0] <= 'z')))
1492 cur++;
1493 return(cur[0] == 0);
1494 }
1495 nxt = cur;
1496 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1497 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1498 nxt++;
1499 if (nxt - cur >= 4) {
1500 /*
1501 * Reserved
1502 */
1503 if ((nxt - cur > 8) || (nxt[0] != 0))
1504 return(0);
1505 return(1);
1506 }
1507 if (nxt - cur < 2)
1508 return(0);
1509 /* we got an ISO 639 code */
1510 if (nxt[0] == 0)
1511 return(1);
1512 if (nxt[0] != '-')
1513 return(0);
1514
1515 nxt++;
1516 cur = nxt;
1517 /* now we can have extlang or script or region or variant */
1518 if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1519 goto region_m49;
1520
1521 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1522 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1523 nxt++;
1524 if (nxt - cur == 4)
1525 goto script;
1526 if (nxt - cur == 2)
1527 goto region;
1528 if ((nxt - cur >= 5) && (nxt - cur <= 8))
1529 goto variant;
1530 if (nxt - cur != 3)
1531 return(0);
1532 /* we parsed an extlang */
1533 if (nxt[0] == 0)
1534 return(1);
1535 if (nxt[0] != '-')
1536 return(0);
1537
1538 nxt++;
1539 cur = nxt;
1540 /* now we can have script or region or variant */
1541 if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1542 goto region_m49;
1543
1544 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1545 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1546 nxt++;
1547 if (nxt - cur == 2)
1548 goto region;
1549 if ((nxt - cur >= 5) && (nxt - cur <= 8))
1550 goto variant;
1551 if (nxt - cur != 4)
1552 return(0);
1553 /* we parsed a script */
1554script:
1555 if (nxt[0] == 0)
1556 return(1);
1557 if (nxt[0] != '-')
1558 return(0);
1559
1560 nxt++;
1561 cur = nxt;
1562 /* now we can have region or variant */
1563 if ((nxt[0] >= '0') && (nxt[0] <= '9'))
1564 goto region_m49;
1565
1566 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1567 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1568 nxt++;
1569
1570 if ((nxt - cur >= 5) && (nxt - cur <= 8))
1571 goto variant;
1572 if (nxt - cur != 2)
1573 return(0);
1574 /* we parsed a region */
1575region:
1576 if (nxt[0] == 0)
1577 return(1);
1578 if (nxt[0] != '-')
1579 return(0);
1580
1581 nxt++;
1582 cur = nxt;
1583 /* now we can just have a variant */
1584 while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
1585 ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
1586 nxt++;
1587
1588 if ((nxt - cur < 5) || (nxt - cur > 8))
1589 return(0);
1590
1591 /* we parsed a variant */
1592variant:
1593 if (nxt[0] == 0)
1594 return(1);
1595 if (nxt[0] != '-')
1596 return(0);
1597 /* extensions and private use subtags not checked */
1598 return (1);
1599
1600region_m49:
1601 if (((nxt[1] >= '0') && (nxt[1] <= '9')) &&
1602 ((nxt[2] >= '0') && (nxt[2] <= '9'))) {
1603 nxt += 3;
1604 goto region;
1605 }
1606 return(0);
1607}
script
Definition: msipriv.h:383
static const WCHAR lang[]
Definition: wbemdisp.c:287

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 1401 of file parser.c.

1402{
1403 if (ctxt->attsSpecial == NULL)
1404 return;
1405
1407
1408 if (xmlHashSize(ctxt->attsSpecial) == 0) {
1410 ctxt->attsSpecial = NULL;
1411 }
1412 return;
1413}
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:322
XMLPUBFUN void XMLCALL xmlHashScanFull(xmlHashTablePtr table, xmlHashScannerFull f, void *data)
Definition: hash.c:875
XMLPUBFUN int XMLCALL xmlHashSize(xmlHashTablePtr table)
Definition: hash.c:1034
static void xmlCleanSpecialAttrCallback(void *payload, void *data, const xmlChar *fullname, const xmlChar *fullattr, const xmlChar *unused ATTRIBUTE_UNUSED)
Definition: parser.c:1382

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 1382 of file parser.c.

1384 {
1386
1387 if (((ptrdiff_t) payload) == XML_ATTRIBUTE_CDATA) {
1388 xmlHashRemoveEntry2(ctxt->attsSpecial, fullname, fullattr, NULL);
1389 }
1390}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
XMLPUBFUN int XMLCALL xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, xmlHashDeallocator f)
Definition: hash.c:1071
@ XML_ATTRIBUTE_CDATA
Definition: tree.h:207
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 14739 of file parser.c.

14739 {
14741 return;
14742
14744#ifdef LIBXML_CATALOG_ENABLED
14745 xmlCatalogCleanup();
14746#endif
14749#ifdef LIBXML_OUTPUT_ENABLED
14750 xmlCleanupOutputCallbacks();
14751#endif
14752#ifdef LIBXML_SCHEMAS_ENABLED
14753 xmlSchemaCleanupTypes();
14754 xmlRelaxNGCleanupTypes();
14755#endif
14757 xmlCleanupThreads(); /* must be last if called not from the main thread */
14760}
XML_DEPRECATED XMLPUBFUN void XMLCALL xmlCleanupCharEncodingHandlers(void)
Definition: encoding.c:1483
XML_DEPRECATED XMLPUBFUN void XMLCALL xmlDictCleanup(void)
Definition: dict.c:224
XML_DEPRECATED XMLPUBFUN void XMLCALL xmlCleanupGlobals(void)
Definition: globals.c:535
static int xmlParserInitialized
Definition: parser.c:14665
XML_DEPRECATED XMLPUBFUN void XMLCALL xmlCleanupThreads(void)
Definition: threads.c:900
XMLPUBFUN void XMLCALL xmlCleanupInputCallbacks(void)
XML_DEPRECATED XMLPUBFUN void XMLCALL xmlCleanupMemory(void)
Definition: xmlmemory.c:989

Referenced by DllMain(), main(), and xmlInitParser().

◆ 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 14542 of file parser.c.

14542 {
14543 int len;
14544
14545 if (cur == NULL)
14546 return(NULL);
14547 len = xmlStrlen(cur);
14548 return(xmlCreateMemoryParserCtxt((const char *)cur, len));
14549}
xmlParserCtxtPtr xmlCreateMemoryParserCtxt(const char *buffer, int size)
Definition: parser.c:14339

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 14027 of file parser.c.

14028 {
14030
14031}
#define ID
Definition: ruserpass.c:36
static xmlParserCtxtPtr xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID, const xmlChar *base, xmlParserCtxtPtr pctx)
Definition: parser.c:13954

◆ 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 13954 of file parser.c.

13955 {
13956 xmlParserCtxtPtr ctxt;
13957 xmlParserInputPtr inputStream;
13958 char *directory = NULL;
13959 xmlChar *uri;
13960
13961 ctxt = xmlNewParserCtxt();
13962 if (ctxt == NULL) {
13963 return(NULL);
13964 }
13965
13966 if (pctx != NULL) {
13967 ctxt->options = pctx->options;
13968 ctxt->_private = pctx->_private;
13969 /*
13970 * this is a subparser of pctx, so the input_id should be
13971 * incremented to distinguish from main entity
13972 */
13973 ctxt->input_id = pctx->input_id + 1;
13974 }
13975
13976 /* Don't read from stdin. */
13977 if (xmlStrcmp(URL, BAD_CAST "-") == 0)
13978 URL = BAD_CAST "./-";
13979
13980 uri = xmlBuildURI(URL, base);
13981
13982 if (uri == NULL) {
13983 inputStream = xmlLoadExternalEntity((char *)URL, (char *)ID, ctxt);
13984 if (inputStream == NULL) {
13985 xmlFreeParserCtxt(ctxt);
13986 return(NULL);
13987 }
13988
13989 inputPush(ctxt, inputStream);
13990
13991 if ((ctxt->directory == NULL) && (directory == NULL))
13992 directory = xmlParserGetDirectory((char *)URL);
13993 if ((ctxt->directory == NULL) && (directory != NULL))
13994 ctxt->directory = directory;
13995 } else {
13996 inputStream = xmlLoadExternalEntity((char *)uri, (char *)ID, ctxt);
13997 if (inputStream == NULL) {
13998 xmlFree(uri);
13999 xmlFreeParserCtxt(ctxt);
14000 return(NULL);
14001 }
14002
14003 inputPush(ctxt, inputStream);
14004
14005 if ((ctxt->directory == NULL) && (directory == NULL))
14007 if ((ctxt->directory == NULL) && (directory != NULL))
14008 ctxt->directory = directory;
14009 xmlFree(uri);
14010 }
14011 return(ctxt);
14012}
const char * uri
Definition: sec_mgr.c:1588
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1745
char * directory
Definition: parser.h:226
void * _private
Definition: parser.h:256
int input_id
Definition: parser.h:312
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1892
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
XMLPUBFUN int XMLCALL xmlStrcmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:133

Referenced by xmlCreateEntityParserCtxt(), 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 14093 of file parser.c.

14094{
14095 return(xmlCreateURLParserCtxt(filename, 0));
14096}
const char * filename
Definition: ioapi.h:137
xmlParserCtxtPtr xmlCreateURLParserCtxt(const char *filename, int options)
Definition: parser.c:14051

◆ 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 12605 of file parser.c.

12607 {
12608 xmlParserCtxtPtr ctxt;
12609 xmlParserInputPtr inputStream;
12611
12612 if (ioread == NULL) return(NULL);
12613
12614 buf = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx, enc);
12615 if (buf == NULL) {
12616 if (ioclose != NULL)
12617 ioclose(ioctx);
12618 return (NULL);
12619 }
12620
12621 ctxt = xmlNewParserCtxt();
12622 if (ctxt == NULL) {
12624 return(NULL);
12625 }
12626 if (sax != NULL) {
12627#ifdef LIBXML_SAX1_ENABLED
12629#endif /* LIBXML_SAX1_ENABLED */
12630 xmlFree(ctxt->sax);
12631 ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(xmlSAXHandler));
12632 if (ctxt->sax == NULL) {
12634 xmlErrMemory(ctxt, NULL);
12635 xmlFreeParserCtxt(ctxt);
12636 return(NULL);
12637 }
12638 memset(ctxt->sax, 0, sizeof(xmlSAXHandler));
12639 if (sax->initialized == XML_SAX2_MAGIC)
12640 memcpy(ctxt->sax, sax, sizeof(xmlSAXHandler));
12641 else
12642 memcpy(ctxt->sax, sax, sizeof(xmlSAXHandlerV1));
12643 if (user_data != NULL)
12644 ctxt->userData = user_data;
12645 }
12646
12647 inputStream = xmlNewIOInputStream(ctxt, buf, enc);
12648 if (inputStream == NULL) {
12649 xmlFreeParserCtxt(ctxt);
12650 return(NULL);
12651 }
12652 inputPush(ctxt, inputStream);
12653
12654 return(ctxt);
12655}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler
Definition: globals.h:312
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
#define XML_SAX2_MAGIC
Definition: parser.h:671
xmlSAXHandler * xmlSAXHandlerPtr
Definition: tree.h:45
#define memset(x, y, z)
Definition: compat.h:39
void * userData
Definition: parser.h:186
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc)
static int sax
Definition: xmllint.c:193

◆ 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 14339 of file parser.c.

14339 {
14340 xmlParserCtxtPtr ctxt;
14343
14344 if (buffer == NULL)
14345 return(NULL);
14346 if (size <= 0)
14347 return(NULL);
14348
14349 ctxt = xmlNewParserCtxt();
14350 if (ctxt == NULL)
14351 return(NULL);
14352
14353 /* TODO: xmlParserInputBufferCreateStatic, requires some serious changes */
14355 if (buf == NULL) {
14356 xmlFreeParserCtxt(ctxt);
14357 return(NULL);
14358 }
14359
14360 input = xmlNewInputStream(ctxt);
14361 if (input == NULL) {
14363 xmlFreeParserCtxt(ctxt);
14364 return(NULL);
14365 }
14366
14367 input->filename = NULL;
14368 input->buf = buf;
14369 xmlBufResetInput(input->buf->buffer, input);
14370
14371 inputPush(ctxt, input);
14372 return(ctxt);
14373}
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1094
@ XML_CHAR_ENCODING_NONE
Definition: encoding.h:58
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream(xmlParserCtxtPtr ctxt)
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc)

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 14051 of file parser.c.

14052{
14053 xmlParserCtxtPtr ctxt;
14054 xmlParserInputPtr inputStream;
14055 char *directory = NULL;
14056
14057 ctxt = xmlNewParserCtxt();
14058 if (ctxt == NULL) {
14059 xmlErrMemory(NULL, "cannot allocate parser context");
14060 return(NULL);
14061 }
14062
14063 if (options)
14065 ctxt->linenumbers = 1;
14066
14067 inputStream = xmlLoadExternalEntity(filename, NULL, ctxt);
14068 if (inputStream == NULL) {
14069 xmlFreeParserCtxt(ctxt);
14070 return(NULL);
14071 }
14072
14073 inputPush(ctxt, inputStream);
14074 if ((ctxt->directory == NULL) && (directory == NULL))
14076 if ((ctxt->directory == NULL) && (directory != NULL))
14077 ctxt->directory = directory;
14078
14079 return(ctxt);
14080}
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:15000
int linenumbers
Definition: parser.h:259

Referenced by xmlCreateFileParserCtxt(), and xmlReadFile().

◆ xmlCtxtGrowAttrs()

static int xmlCtxtGrowAttrs ( xmlParserCtxtPtr  ctxt,
int  nr 
)
static

Definition at line 1702 of file parser.c.

1702 {
1703 const xmlChar **atts;
1704 int *attallocs;
1705 int maxatts;
1706
1707 if (ctxt->atts == NULL) {
1708 maxatts = 55; /* allow for 10 attrs by default */
1709 atts = (const xmlChar **)
1710 xmlMalloc(maxatts * sizeof(xmlChar *));
1711 if (atts == NULL) goto mem_error;
1712 ctxt->atts = atts;
1713 attallocs = (int *) xmlMalloc((maxatts / 5) * sizeof(int));
1714 if (attallocs == NULL) goto mem_error;
1715 ctxt->attallocs = attallocs;
1716 ctxt->maxatts = maxatts;
1717 } else if (nr + 5 > ctxt->maxatts) {
1718 maxatts = (nr + 5) * 2;
1719 atts = (const xmlChar **) xmlRealloc((void *) ctxt->atts,
1720 maxatts * sizeof(const xmlChar *));
1721 if (atts == NULL) goto mem_error;
1722 ctxt->atts = atts;
1723 attallocs = (int *) xmlRealloc((void *) ctxt->attallocs,
1724 (maxatts / 5) * sizeof(int));
1725 if (attallocs == NULL) goto mem_error;
1726 ctxt->attallocs = attallocs;
1727 ctxt->maxatts = maxatts;
1728 }
1729 return(ctxt->maxatts);
1730mem_error:
1731 xmlErrMemory(ctxt, NULL);
1732 return(-1);
1733}
_In_ uint16_t _Out_ ULONG * atts
Definition: btrfs_drv.h:1107
const xmlChar ** atts
Definition: parser.h:264
int * attallocs
Definition: parser.h:282

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 15368 of file parser.c.

15370{
15371 if (cur == NULL)
15372 return (NULL);
15373 return (xmlCtxtReadMemory(ctxt, (const char *) cur, xmlStrlen(cur), URL,
15374 encoding, options));
15375}
xmlDocPtr xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size, const char *URL, const char *encoding, int options)
Definition: parser.c:15426
static char * encoding
Definition: xmllint.c:155

◆ 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 15471 of file parser.c.

15473{
15476
15477 if (fd < 0)
15478 return (NULL);
15479 if (ctxt == NULL)
15480 return (NULL);
15481 xmlInitParser();
15482
15483 xmlCtxtReset(ctxt);
15484
15485
15487 if (input == NULL)
15488 return (NULL);
15489 input->closecallback = NULL;
15491 if (stream == NULL) {
15493 return (NULL);
15494 }
15495 inputPush(ctxt, stream);
15496 return (xmlDoRead(ctxt, URL, encoding, options, 1));
15497}
void xmlInitParser(void)
Definition: parser.c:14676
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15159
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14801
static int fd
Definition: io.c:51
Definition: parse.h:23
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFd(int fd, xmlCharEncoding enc)

◆ 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 15390 of file parser.c.

15392{
15394
15395 if (filename == NULL)
15396 return (NULL);
15397 if (ctxt == NULL)
15398 return (NULL);
15399 xmlInitParser();
15400
15401 xmlCtxtReset(ctxt);
15402
15404 if (stream == NULL) {
15405 return (NULL);
15406 }
15407 inputPush(ctxt, stream);
15408 return (xmlDoRead(ctxt, NULL, encoding, options, 1));
15409}

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 15515 of file parser.c.

15519{
15522
15523 if (ioread == NULL)
15524 return (NULL);
15525 if (ctxt == NULL)
15526 return (NULL);
15527 xmlInitParser();
15528
15529 xmlCtxtReset(ctxt);
15530
15531 input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
15533 if (input == NULL) {
15534 if (ioclose != NULL)
15535 ioclose(ioctx);
15536 return (NULL);
15537 }
15539 if (stream == NULL) {
15541 return (NULL);
15542 }
15543 inputPush(ctxt, stream);
15544 return (xmlDoRead(ctxt, URL, encoding, options, 1));
15545}

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 15426 of file parser.c.

15428{
15431
15432 if (ctxt == NULL)
15433 return (NULL);
15434 if (buffer == NULL)
15435 return (NULL);
15436 xmlInitParser();
15437
15438 xmlCtxtReset(ctxt);
15439
15441 if (input == NULL) {
15442 return(NULL);
15443 }
15444
15446 if (stream == NULL) {
15448 return(NULL);
15449 }
15450
15451 inputPush(ctxt, stream);
15452 return (xmlDoRead(ctxt, URL, encoding, options, 1));
15453}

Referenced by parseAndPrintFile(), and xmlCtxtReadDoc().

◆ xmlCtxtReset()

void xmlCtxtReset ( xmlParserCtxtPtr  ctxt)

xmlCtxtReset: @ctxt: an XML parser context

Reset a parser context

Definition at line 14801 of file parser.c.

14802{
14804 xmlDictPtr dict;
14805
14806 if (ctxt == NULL)
14807 return;
14808
14809 dict = ctxt->dict;
14810
14811 while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
14813 }
14814 ctxt->inputNr = 0;
14815 ctxt->input = NULL;
14816
14817 ctxt->spaceNr = 0;
14818 if (ctxt->spaceTab != NULL) {
14819 ctxt->spaceTab[0] = -1;
14820 ctxt->space = &ctxt->spaceTab[0];
14821 } else {
14822 ctxt->space = NULL;
14823 }
14824
14825
14826 ctxt->nodeNr = 0;
14827 ctxt->node = NULL;
14828
14829 ctxt->nameNr = 0;
14830 ctxt->name = NULL;
14831
14832 ctxt->nsNr = 0;
14833
14834 DICT_FREE(ctxt->version);
14835 ctxt->version = NULL;
14836 DICT_FREE(ctxt->encoding);
14837 ctxt->encoding = NULL;
14838 DICT_FREE(ctxt->directory);
14839 ctxt->directory = NULL;
14840 DICT_FREE(ctxt->extSubURI);
14841 ctxt->extSubURI = NULL;
14842 DICT_FREE(ctxt->extSubSystem);
14843 ctxt->extSubSystem = NULL;
14844 if (ctxt->myDoc != NULL)
14845 xmlFreeDoc(ctxt->myDoc);
14846 ctxt->myDoc = NULL;
14847
14848 ctxt->standalone = -1;
14849 ctxt->hasExternalSubset = 0;
14850 ctxt->hasPErefs = 0;
14851 ctxt->html = 0;
14852 ctxt->external = 0;
14853 ctxt->instate = XML_PARSER_START;
14854 ctxt->token = 0;
14855
14856 ctxt->wellFormed = 1;
14857 ctxt->nsWellFormed = 1;
14858 ctxt->disableSAX = 0;
14859 ctxt->valid = 1;
14860#if 0
14861 ctxt->vctxt.userData = ctxt;
14862 ctxt->vctxt.error = xmlParserValidityError;
14863 ctxt->vctxt.warning = xmlParserValidityWarning;
14864#endif
14865 ctxt->record_info = 0;
14866 ctxt->checkIndex = 0;
14867 ctxt->inSubset = 0;
14868 ctxt->errNo = XML_ERR_OK;
14869 ctxt->depth = 0;
14871 ctxt->catalogs = NULL;
14872 ctxt->nbentities = 0;
14873 ctxt->sizeentities = 0;
14874 ctxt->sizeentcopy = 0;
14876
14877 if (ctxt->attsDefault != NULL) {
14879 ctxt->attsDefault = NULL;
14880 }
14881 if (ctxt->attsSpecial != NULL) {
14883 ctxt->attsSpecial = NULL;
14884 }
14885
14886#ifdef LIBXML_CATALOG_ENABLED
14887 if (ctxt->catalogs != NULL)
14888 xmlCatalogFreeLocal(ctxt->catalogs);
14889#endif
14890 if (ctxt->lastError.code != XML_ERR_OK)
14891 xmlResetError(&ctxt->lastError);
14892}
@ XML_CHAR_ENCODING_UTF8
Definition: encoding.h:59
XMLPUBFUN void XMLCALL xmlFreeInputStream(xmlParserInputPtr input)
XMLPUBFUN void XMLCALL xmlHashDefaultDeallocator(void *entry, const xmlChar *name)
@ XML_PARSER_START
Definition: parser.h:112
XMLPUBFUN void XMLCALL xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
#define DICT_FREE(str)
Definition: parser.c:14789
xmlParserInputPtr inputPop(xmlParserCtxtPtr ctxt)
Definition: parser.c:1774
Definition: dict.c:111
int code
Definition: xmlerror.h:80
xmlError lastError
Definition: parser.h:301
int nsWellFormed
Definition: parser.h:286
int hasPErefs
Definition: parser.h:216
xmlValidCtxt vctxt
Definition: parser.h:221
int wellFormed
Definition: parser.h:188
int disableSAX
Definition: parser.h:237
xmlChar * extSubSystem
Definition: parser.h:241
xmlParserNodeInfoSeq node_seq
Definition: parser.h:211
int hasExternalSubset
Definition: parser.h:215
long checkIndex
Definition: parser.h:235
xmlParserInputState instate
Definition: parser.h:223
const xmlChar * encoding
Definition: parser.h:191
void * catalogs
Definition: parser.h:260
xmlChar * extSubURI
Definition: parser.h:240
unsigned long sizeentities
Definition: parser.h:304
const xmlChar * version
Definition: parser.h:190
int record_info
Definition: parser.h:210
int inSubset
Definition: parser.h:238
int standalone
Definition: parser.h:192
unsigned long sizeentcopy
Definition: parser.h:313
unsigned long nbentities
Definition: parser.h:303
XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL xmlParserValidityWarning(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL xmlParserValidityError(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
XMLPUBFUN void XMLCALL xmlResetError(xmlErrorPtr err)
@ XML_ERR_OK
Definition: xmlerror.h:100

Referenced by xmlClearParserCtxt(), 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 14907 of file parser.c.

14909{
14910 xmlParserInputPtr inputStream;
14913
14914 if (ctxt == NULL)
14915 return(1);
14916
14917 if ((encoding == NULL) && (chunk != NULL) && (size >= 4))
14918 enc = xmlDetectCharEncoding((const xmlChar *) chunk, size);
14919
14921 if (buf == NULL)
14922 return(1);
14923
14924 if (ctxt == NULL) {
14926 return(1);
14927 }
14928
14929 xmlCtxtReset(ctxt);
14930
14931 if (filename == NULL) {
14932 ctxt->directory = NULL;
14933 } else {
14935 }
14936
14937 inputStream = xmlNewInputStream(ctxt);
14938 if (inputStream == NULL) {
14940 return(1);
14941 }
14942
14943 if (filename == NULL)
14944 inputStream->filename = NULL;
14945 else
14946 inputStream->filename = (char *)
14947 xmlCanonicPath((const xmlChar *) filename);
14948 inputStream->buf = buf;
14949 xmlBufResetInput(buf->buffer, inputStream);
14950
14951 inputPush(ctxt, inputStream);
14952
14953 if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
14954 (ctxt->input->buf != NULL)) {
14955 size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
14956 size_t cur = ctxt->input->cur - ctxt->input->base;
14957
14959
14961#ifdef DEBUG_PUSH
14962 xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size);
14963#endif
14964 }
14965
14966 if (encoding != NULL) {
14968
14969 if (ctxt->encoding != NULL)
14970 xmlFree((xmlChar *) ctxt->encoding);
14971 ctxt->encoding = xmlStrdup((const xmlChar *) encoding);
14972
14974 if (hdlr != NULL) {
14975 xmlSwitchToEncoding(ctxt, hdlr);
14976 } else {
14977 xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
14978 "Unsupported encoding %s\n", BAD_CAST encoding);
14979 }
14980 } else if (enc != XML_CHAR_ENCODING_NONE) {
14981 xmlSwitchEncoding(ctxt, enc);
14982 }
14983
14984 return(0);
14985}
size_t xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1113
int xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input, size_t base, size_t cur)
Definition: buf.c:1144
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1678
xmlCharEncoding
Definition: encoding.h:56
XMLPUBFUN xmlCharEncoding XMLCALL xmlDetectCharEncoding(const unsigned char *in, int len)
Definition: encoding.c:952
XMLPUBFUN int XMLCALL xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
XMLPUBFUN int XMLCALL xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
xmlBufPtr buffer
Definition: xmlIO.h:132
const char * filename
Definition: parser.h:56
const xmlChar * base
Definition: parser.h:58
xmlParserInputBufferPtr buf
Definition: parser.h:54
const xmlChar * cur
Definition: parser.h:59
XMLPUBFUN xmlChar *XMLCALL xmlCanonicPath(const xmlChar *path)
Definition: uri.c:2380
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlAllocParserInputBuffer(xmlCharEncoding enc)
XMLPUBFUN int XMLCALL xmlParserInputBufferPush(xmlParserInputBufferPtr in, int len, const char *buf)
@ XML_ERR_UNSUPPORTED_ENCODING
Definition: xmlerror.h:132
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:67

◆ 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 15141 of file parser.c.

15142{
15143 return(xmlCtxtUseOptionsInternal(ctxt, options, NULL));
15144}

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 15000 of file parser.c.

15001{
15002 if (ctxt == NULL)
15003 return(-1);
15004 if (encoding != NULL) {
15005 if (ctxt->encoding != NULL)
15006 xmlFree((xmlChar *) ctxt->encoding);
15007 ctxt->encoding = xmlStrdup((const xmlChar *) encoding);
15008 }
15009 if (options & XML_PARSE_RECOVER) {
15010 ctxt->recovery = 1;
15012 ctxt->options |= XML_PARSE_RECOVER;
15013 } else
15014 ctxt->recovery = 0;
15015 if (options & XML_PARSE_DTDLOAD) {
15016 ctxt->loadsubset = XML_DETECT_IDS;
15018 ctxt->options |= XML_PARSE_DTDLOAD;
15019 } else
15020 ctxt->loadsubset = 0;
15021 if (options & XML_PARSE_DTDATTR) {
15024 ctxt->options |= XML_PARSE_DTDATTR;
15025 }
15026 if (options & XML_PARSE_NOENT) {
15027 ctxt->replaceEntities = 1;
15028 /* ctxt->loadsubset |= XML_DETECT_IDS; */
15030 ctxt->options |= XML_PARSE_NOENT;
15031 } else
15032 ctxt->replaceEntities = 0;
15034 ctxt->pedantic = 1;
15036 ctxt->options |= XML_PARSE_PEDANTIC;
15037 } else
15038 ctxt->pedantic = 0;
15040 ctxt->keepBlanks = 0;
15041 ctxt->sax->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
15043 ctxt->options |= XML_PARSE_NOBLANKS;
15044 } else
15045 ctxt->keepBlanks = 1;
15047 ctxt->validate = 1;
15049 ctxt->vctxt.warning = NULL;
15051 ctxt->vctxt.error = NULL;
15053 ctxt->options |= XML_PARSE_DTDVALID;
15054 } else
15055 ctxt->validate = 0;
15057 ctxt->sax->warning = NULL;
15059 }
15060 if (options & XML_PARSE_NOERROR) {
15061 ctxt->sax->error = NULL;
15062 ctxt->sax->fatalError = NULL;
15064 }
15065#ifdef LIBXML_SAX1_ENABLED
15066 if (options & XML_PARSE_SAX1) {
15067 ctxt->sax->startElement = xmlSAX2StartElement;
15068 ctxt->sax->endElement = xmlSAX2EndElement;
15069 ctxt->sax->startElementNs = NULL;
15070 ctxt->sax->endElementNs = NULL;
15071 ctxt->sax->initialized = 1;
15073 ctxt->options |= XML_PARSE_SAX1;
15074 }
15075#endif /* LIBXML_SAX1_ENABLED */
15076 if (options & XML_PARSE_NODICT) {
15077 ctxt->dictNames = 0;
15079 ctxt->options |= XML_PARSE_NODICT;
15080 } else {
15081 ctxt->dictNames = 1;
15082 }
15083 if (options & XML_PARSE_NOCDATA) {
15084 ctxt->sax->cdataBlock = NULL;
15086 ctxt->options |= XML_PARSE_NOCDATA;
15087 }
15088 if (options & XML_PARSE_NSCLEAN) {
15089 ctxt->options |= XML_PARSE_NSCLEAN;
15091 }
15092 if (options & XML_PARSE_NONET) {
15093 ctxt->options |= XML_PARSE_NONET;
15095 }
15096 if (options & XML_PARSE_COMPACT) {
15097 ctxt->options |= XML_PARSE_COMPACT;
15099 }
15100 if (options & XML_PARSE_OLD10) {
15101 ctxt->options |= XML_PARSE_OLD10;
15103 }
15107 }
15108 if (options & XML_PARSE_HUGE) {
15109 ctxt->options |= XML_PARSE_HUGE;
15111 if (ctxt->dict != NULL)
15112 xmlDictSetLimit(ctxt->dict, 0);
15113 }
15114 if (options & XML_PARSE_OLDSAX) {
15115 ctxt->options |= XML_PARSE_OLDSAX;
15117 }
15121 }
15125 }
15126 ctxt->linenumbers = 1;
15127 return (options);
15128}
XMLPUBFUN void XMLCALL xmlSAX2IgnorableWhitespace(void *ctx, const xmlChar *ch, int len)
XMLPUBFUN size_t XMLCALL xmlDictSetLimit(xmlDictPtr dict, size_t limit)
Definition: dict.c:1265
#define XML_DETECT_IDS
Definition: parser.h:137
#define XML_COMPLETE_ATTRS
Definition: parser.h:146
@ XML_PARSE_SAX1
Definition: parser.h:1102
@ XML_PARSE_DTDVALID
Definition: parser.h:1097
@ XML_PARSE_NOWARNING
Definition: parser.h:1099
@ XML_PARSE_NOCDATA
Definition: parser.h:1107
@ XML_PARSE_COMPACT
Definition: parser.h:1109
@ XML_PARSE_NONET
Definition: parser.h:1104
@ XML_PARSE_NOBLANKS
Definition: parser.h:1101
@ XML_PARSE_IGNORE_ENC
Definition: parser.h:1116
@ XML_PARSE_NOBASEFIX
Definition: parser.h:1113
@ XML_PARSE_DTDLOAD
Definition: parser.h:1095
@ XML_PARSE_RECOVER
Definition: parser.h:1093
@ XML_PARSE_NODICT
Definition: parser.h:1105
@ XML_PARSE_BIG_LINES
Definition: parser.h:1117
@ XML_PARSE_DTDATTR
Definition: parser.h:1096
@ XML_PARSE_OLD10
Definition: parser.h:1112
@ XML_PARSE_OLDSAX
Definition: parser.h:1115
@ XML_PARSE_NOERROR
Definition: parser.h:1098
@ XML_PARSE_NOENT
Definition: parser.h:1094
@ XML_PARSE_PEDANTIC
Definition: parser.h:1100
int replaceEntities
Definition: parser.h:189
int keepBlanks
Definition: parser.h:236
int loadsubset
Definition: parser.h:258
int dictNames
Definition: parser.h:292
int pedantic
Definition: parser.h:255
int recovery
Definition: parser.h:261
int validate
Definition: parser.h:220

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 1094 of file parser.c.

1094 {
1096
1097 /* Avoid unused variable warning if features are disabled. */
1098 (void) sax;
1099
1100 if (ctxt == NULL) return;
1101 sax = ctxt->sax;
1102#ifdef LIBXML_SAX1_ENABLED
1103 if ((sax) && (sax->initialized == XML_SAX2_MAGIC) &&
1104 ((sax->startElementNs != NULL) ||
1105 (sax->endElementNs != NULL) ||
1106 ((sax->startElement == NULL) && (sax->endElement == NULL))))
1107 ctxt->sax2 = 1;
1108#else
1109 ctxt->sax2 = 1;
1110#endif /* LIBXML_SAX1_ENABLED */
1111
1112 ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3);
1113 ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
1114 ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
1115 if ((ctxt->str_xml==NULL) || (ctxt->str_xmlns==NULL) ||
1116 (ctxt->str_xml_ns == NULL)) {
1117 xmlErrMemory(ctxt, NULL);
1118 }
1119}
#define XML_XML_NAMESPACE
Definition: tree.h:140
const xmlChar * str_xml
Definition: parser.h:271
const xmlChar * str_xml_ns
Definition: parser.h:273
const xmlChar * str_xmlns
Definition: parser.h:272

Referenced by xmlParseBalancedChunkMemoryInternal(), 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 15159 of file parser.c.

15161{
15162 xmlDocPtr ret;
15163
15165 if (encoding != NULL) {
15167
15169 if (hdlr != NULL)
15170 xmlSwitchToEncoding(ctxt, hdlr);
15171 }
15172 if ((URL != NULL) && (ctxt->input != NULL) &&
15173 (ctxt->input->filename == NULL))
15174 ctxt->input->filename = (char *) xmlStrdup((const xmlChar *) URL);
15175 xmlParseDocument(ctxt);
15176 if ((ctxt->wellFormed) || ctxt->recovery)
15177 ret = ctxt->myDoc;
15178 else {
15179 ret = NULL;
15180 if (ctxt->myDoc != NULL) {
15181 xmlFreeDoc(ctxt->myDoc);
15182 }
15183 }
15184 ctxt->myDoc = NULL;
15185 if (!reuse) {
15186 xmlFreeParserCtxt(ctxt);
15187 }
15188
15189 return (ret);
15190}
int xmlParseDocument(xmlParserCtxtPtr ctxt)
Definition: parser.c:10697
Definition: tree.h:551

Referenced by 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 342 of file parser.c.

344{
345 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
346 (ctxt->instate == XML_PARSER_EOF))
347 return;
348 if (ctxt != NULL)
350
351 if (prefix == NULL)
352 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER,
354 (const char *) localname, NULL, NULL, 0, 0,
355 "Attribute %s redefined\n", localname);
356 else
357 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER,
359 (const char *) prefix, (const char *) localname,
360 NULL, 0, 0, "Attribute %s:%s redefined\n", prefix,
361 localname);
362 if (ctxt != NULL) {
363 ctxt->wellFormed = 0;
364 if (ctxt->recovery == 0)
365 ctxt->disableSAX = 1;
366 }
367}
@ XML_ERR_ATTRIBUTE_REDEFINED
Definition: xmlerror.h:142

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 378 of file parser.c.

379{
380 const char *errmsg;
381
382 if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
383 (ctxt->instate == XML_PARSER_EOF))
384 return;
385 switch (error) {
387 errmsg = "CharRef: invalid hexadecimal value";
388 break;
390 errmsg = "CharRef: invalid decimal value";
391 break;
393 errmsg = "CharRef: invalid value";
394 break;
396 errmsg = "internal error";
397 break;
399 errmsg = "PEReference at end of document";
400 break;
402 errmsg = "PEReference in prolog";
403 break;
405 errmsg = "PEReference in epilog";
406 break;
408 errmsg = "PEReference: no name";
409 break;
411 errmsg = "PEReference: expecting ';'";
412 break;
414 errmsg = "Detected an entity reference loop";
415 break;
417 errmsg = "EntityValue: \" or ' expected";
418 break;
420 errmsg = "PEReferences forbidden in internal subset";
421 break;
423 errmsg = "EntityValue: \" or ' expected";
424 break;
426 errmsg = "AttValue: \" or ' expected";
427 break;
429 errmsg = "Unescaped '<' not allowed in attributes values";
430 break;
432 errmsg = "SystemLiteral \" or ' expected";
433 break;
435 errmsg = "Unfinished System or Public ID \" or ' expected";
436 break;
438 errmsg = "Sequence ']]>' not allowed in content";
439 break;
441 errmsg = "SYSTEM or PUBLIC, the URI is missing";
442 break;
444 errmsg = "PUBLIC, the Public Identifier is missing";
445 break;
447 errmsg = "Comment must not contain '--' (double-hyphen)";
448 break;
450 errmsg = "xmlParsePI : no target name";
451 break;
453 errmsg = "Invalid PI name";
454 break;
456 errmsg = "NOTATION: Name expected here";
457 break;
459 errmsg = "'>' required to close NOTATION declaration";
460 break;
462 errmsg = "Entity value required";
463 break;
465 errmsg = "Fragment not allowed";
466 break;
468 errmsg = "'(' required to start ATTLIST enumeration";
469 break;
471 errmsg = "NmToken expected in ATTLIST enumeration";
472 break;
474 errmsg = "')' required to finish ATTLIST enumeration";
475 break;
477 errmsg = "MixedContentDecl : '|' or ')*' expected";
478 break;
480 errmsg = "MixedContentDecl : '#PCDATA' expected";
481 break;
483 errmsg = "ContentDecl : Name or '(' expected";
484 break;
486 errmsg = "ContentDecl : ',' '|' or ')' expected";
487 break;
489 errmsg =
490 "PEReference: forbidden within markup decl in internal subset";
491 break;
493 errmsg = "expected '>'";
494 break;
496 errmsg = "XML conditional section '[' expected";
497 break;
499 errmsg = "Content error in the external subset";
500 break;
502 errmsg =
503 "conditional section INCLUDE or IGNORE keyword expected";
504 break;
506 errmsg = "XML conditional section not closed";
507 break;
509 errmsg = "Text declaration '<?xml' required";
510 break;
512 errmsg = "parsing XML declaration: '?>' expected";
513 break;
515 errmsg = "external parsed entities cannot be standalone";
516 break;
518 errmsg = "EntityRef: expecting ';'";
519 break;
521 errmsg = "DOCTYPE improperly terminated";
522 break;
524 errmsg = "EndTag: '</' not found";
525 break;
527 errmsg = "expected '='";
528 break;
530 errmsg = "String not closed expecting \" or '";
531 break;
533 errmsg = "String not started expecting ' or \"";
534 break;
536 errmsg = "Invalid XML encoding name";
537 break;
539 errmsg = "standalone accepts only 'yes' or 'no'";
540 break;
542 errmsg = "Document is empty";
543 break;
545 errmsg = "Extra content at the end of the document";
546 break;
548 errmsg = "chunk is not well balanced";
549 break;
551 errmsg = "extra content at the end of well balanced chunk";
552 break;
554 errmsg = "Malformed declaration expecting version";
555 break;
557 errmsg = "Name too long";
558 break;
559#if 0
560 case:
561 errmsg = "";
562 break;
563#endif
564 default:
565 errmsg = "Unregistered error message";
566 }
567 if (ctxt != NULL)
568 ctxt->errNo = error;
569 if (info == NULL) {
570 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
571 XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s\n",
572 errmsg);
573 } else {
574 __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
575 XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, "%s: %s\n",
576 errmsg, info);
577 }
578 if (ctxt != NULL) {
579 ctxt->wellFormed = 0;
580 if (ctxt->recovery == 0)
581 ctxt->disableSAX = 1;
582 }
583}
EXPORT int errmsg(char *msg, va_alist)
Definition: comerr.c:192
@ XML_ERR_PEREF_NO_NAME
Definition: xmlerror.h:124
@ XML_ERR_NOT_WELL_BALANCED
Definition: xmlerror.h:185
@ XML_ERR_ENCODING_NAME
Definition: xmlerror.h:179
@ XML_ERR_ENTITY_NOT_FINISHED
Definition: xmlerror.h:137
@ XML_ERR_ENTITYREF_SEMICOL_MISSING
Definition: xmlerror.h:123
@ XML_ERR_PEREF_IN_PROLOG
Definition: xmlerror.h:119
@ XML_ERR_LT_IN_ATTRIBUTE
Definition: xmlerror.h:138
@ XML_ERR_ENTITY_PE_INTERNAL
Definition: xmlerror.h:188
@ XML_ERR_ATTLIST_NOT_STARTED
Definition: xmlerror.h:150
@ XML_ERR_LITERAL_NOT_FINISHED
Definition: xmlerror.h:144
@ XML_ERR_XMLDECL_NOT_FINISHED
Definition: xmlerror.h:157
@ XML_ERR_DOCUMENT_END
Definition: xmlerror.h:105
@ XML_ERR_ELEMCONTENT_NOT_STARTED
Definition: xmlerror.h:154
@ XML_ERR_LTSLASH_REQUIRED
Definition: xmlerror.h:174
@ XML_ERR_PI_NOT_STARTED
Definition: xmlerror.h:146
@ XML_ERR_MIXED_NOT_STARTED
Definition: xmlerror.h:152
@ XML_ERR_PEREF_IN_EPILOG
Definition: xmlerror.h:120
@ XML_ERR_DOCTYPE_NOT_FINISHED
Definition: xmlerror.h:161
@ XML_ERR_CONDSEC_INVALID
Definition: xmlerror.h:183
@ XML_ERR_ENTITY_LOOP
Definition: xmlerror.h:189
@ XML_ERR_EXT_ENTITY_STANDALONE
Definition: xmlerror.h:182
@ XML_ERR_RESERVED_XML_NAME
Definition: xmlerror.h:164
@ XML_ERR_HYPHEN_IN_COMMENT
Definition: xmlerror.h:180
@ XML_ERR_MISPLACED_CDATA_END
Definition: xmlerror.h:162
@ XML_ERR_CONDSEC_INVALID_KEYWORD
Definition: xmlerror.h:195
@ XML_ERR_URI_FRAGMENT
Definition: xmlerror.h:192
@ XML_ERR_VALUE_REQUIRED
Definition: xmlerror.h:184
@ XML_ERR_PEREF_AT_EOF
Definition: xmlerror.h:118
@ XML_ERR_INVALID_CHARREF
Definition: xmlerror.h:108
@ XML_ERR_NMTOKEN_REQUIRED
Definition: xmlerror.h:167
@ XML_ERR_PEREF_IN_INT_SUBSET
Definition: xmlerror.h:121
@ XML_ERR_GT_REQUIRED
Definition: xmlerror.h:173
@ XML_ERR_ELEMCONTENT_NOT_FINISHED
Definition: xmlerror.h:155
@ XML_ERR_PCDATA_REQUIRED
Definition: xmlerror.h:169
@ XML_ERR_NOTATION_NOT_STARTED
Definition: xmlerror.h:148
@ XML_ERR_STRING_NOT_CLOSED
Definition: xmlerror.h:134
@ XML_ERR_ATTRIBUTE_NOT_STARTED
Definition: xmlerror.h:139
@ XML_ERR_CONDSEC_NOT_FINISHED
Definition: xmlerror.h:159
@ XML_ERR_DOCUMENT_EMPTY
Definition: xmlerror.h:104
@ XML_ERR_INVALID_DEC_CHARREF
Definition: xmlerror.h:107
@ XML_ERR_LITERAL_NOT_STARTED
Definition: xmlerror.h:143
@ XML_ERR_PUBID_REQUIRED
Definition: xmlerror.h:171
@ XML_ERR_URI_REQUIRED
Definition: xmlerror.h:170
@ XML_ERR_STRING_NOT_STARTED
Definition: xmlerror.h:133
@ XML_ERR_INVALID_HEX_CHARREF
Definition: xmlerror.h:106
@ XML_ERR_VERSION_MISSING
Definition: xmlerror.h:196
@ XML_ERR_EXT_SUBSET_NOT_FINISHED
Definition: xmlerror.h:160
@ XML_ERR_STANDALONE_VALUE
Definition: xmlerror.h:178
@ XML_ERR_EQUAL_REQUIRED
Definition: xmlerror.h:175
@ XML_ERR_ATTLIST_NOT_FINISHED
Definition: xmlerror.h:151
@ XML_ERR_XMLDECL_NOT_STARTED
Definition: xmlerror.h:156
@ XML_ERR_PEREF_SEMICOL_MISSING
Definition: xmlerror.h:125
@ XML_ERR_EXTRA_CONTENT
Definition: xmlerror.h:186
@ XML_ERR_NOTATION_NOT_FINISHED
Definition: xmlerror.h:149
@ XML_ERR_NAME_TOO_LONG
Definition: xmlerror.h:210
@ XML_ERR_ENTITY_NOT_STARTED
Definition: xmlerror.h:136

Referenced by xmlGROW(), xmlLoadEntityContent(), xmlParseAttValueComplex(), xmlParseAttValueInternal(), xmlParseBalancedChunkMemoryInternal(), xmlParseCDSect(), xmlParseCharData(), xmlParseCharDataComplex(), xmlParseCharRef(), xmlParseCommentComplex(), xmlParseConditionalSections(), xmlParseContentInternal(), 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 8760 of file parser.c.

8760 {
8761 int i;
8762
8763 if (prefix == ctxt->str_xml) return(ctxt->str_xml_ns);
8764 for (i = ctxt->nsNr - 2;i >= 0;i-=2)
8765 if (ctxt->nsTab[i] == prefix) {
8766 if ((prefix == NULL) && (*ctxt->nsTab[i + 1] == 0))
8767 return(NULL);
8768 return(ctxt->nsTab[i + 1]);
8769 }
8770 return(NULL);
8771}

Referenced by xmlParseInNodeContext(), and xmlParseStartTag2().

◆ xmlGROW()

static void xmlGROW ( xmlParserCtxtPtr  ctxt)
static

Definition at line 2121 of file parser.c.

2121 {
2122 ptrdiff_t curEnd = ctxt->input->end - ctxt->input->cur;
2123 ptrdiff_t curBase = ctxt->input->cur - ctxt->input->base;
2124
2125 if (((curEnd > XML_MAX_LOOKUP_LIMIT) ||
2126 (curBase > XML_MAX_LOOKUP_LIMIT)) &&
2127 ((ctxt->input->buf) &&
2129 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
2130 xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup");
2131 xmlHaltParser(ctxt);
2132 return;
2133 }
2135 if ((ctxt->input->cur > ctxt->input->end) ||
2136 (ctxt->input->cur < ctxt->input->base)) {
2137 xmlHaltParser(ctxt);
2138 xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "cur index out of bound");
2139 return;
2140 }
2141 if ((ctxt->input->cur != NULL) && (*ctxt->input->cur == 0))
2143}
int xmlInputReadCallbackNop(void *context, char *buffer, int len)
#define XML_MAX_LOOKUP_LIMIT
XMLPUBFUN int XMLCALL xmlParserInputGrow(xmlParserInputPtr in, int len)
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:378
xmlInputReadCallback readcallback
Definition: xmlIO.h:127
const xmlChar * end
Definition: parser.h:60

◆ 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 12549 of file parser.c.

12549 {
12550 if (ctxt == NULL)
12551 return;
12552 ctxt->instate = XML_PARSER_EOF;
12553 ctxt->disableSAX = 1;
12554 while (ctxt->inputNr > 1)
12556 if (ctxt->input != NULL) {
12557 /*
12558 * in case there was a specific allocation deallocate before
12559 * overriding base
12560 */
12561 if (ctxt->input->free != NULL) {
12562 ctxt->input->free((xmlChar *) ctxt->input->base);
12563 ctxt->input->free = NULL;
12564 }
12565 if (ctxt->input->buf != NULL) {
12567 ctxt->input->buf = NULL;
12568 }
12569 ctxt->input->cur = BAD_CAST"";
12570 ctxt->input->length = 0;
12571 ctxt->input->base = ctxt->input->cur;
12572 ctxt->input->end = ctxt->input->cur;
12573 }
12574}
xmlParserInputDeallocate free
Definition: parser.h:70

Referenced by nodePush(), xmlGROW(), xmlParseConditionalSections(), xmlParseContentInternal(), xmlParseElementStart(), xmlParseEntityDecl(), xmlParseExternalSubset(), xmlParseReference(), 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 874 of file parser.c.

875{
876 switch (feature) {
877 case XML_WITH_THREAD:
878#ifdef LIBXML_THREAD_ENABLED
879 return(1);
880#else
881 return(0);
882#endif
883 case XML_WITH_TREE:
884#ifdef LIBXML_TREE_ENABLED
885 return(1);
886#else
887 return(0);
888#endif
889 case XML_WITH_OUTPUT:
890#ifdef LIBXML_OUTPUT_ENABLED
891 return(1);
892#else
893 return(0);
894#endif
895 case XML_WITH_PUSH:
896#ifdef LIBXML_PUSH_ENABLED
897 return(1);
898#else
899 return(0);
900#endif
901 case XML_WITH_READER:
902#ifdef LIBXML_READER_ENABLED
903 return(1);
904#else
905 return(0);
906#endif
907 case XML_WITH_PATTERN:
908#ifdef LIBXML_PATTERN_ENABLED
909 return(1);
910#else
911 return(0);
912#endif
913 case XML_WITH_WRITER:
914#ifdef LIBXML_WRITER_ENABLED
915 return(1);
916#else
917 return(0);
918#endif
919 case XML_WITH_SAX1:
920#ifdef LIBXML_SAX1_ENABLED
921 return(1);
922#else
923 return(0);
924#endif
925 case XML_WITH_FTP:
926#ifdef LIBXML_FTP_ENABLED
927 return(1);
928#else
929 return(0);
930#endif
931 case XML_WITH_HTTP:
932#ifdef LIBXML_HTTP_ENABLED
933 return(1);
934#else
935 return(0);
936#endif
937 case XML_WITH_VALID:
938#ifdef LIBXML_VALID_ENABLED
939 return(1);
940#else
941 return(0);
942#endif
943 case XML_WITH_HTML:
944#ifdef LIBXML_HTML_ENABLED
945 return(1);
946#else
947 return(0);
948#endif
949 case XML_WITH_LEGACY:
950#ifdef LIBXML_LEGACY_ENABLED
951 return(1);
952#else
953 return(0);
954#endif
955 case XML_WITH_C14N:
956#ifdef LIBXML_C14N_ENABLED
957 return(1);
958#else
959 return(0);
960#endif
961 case XML_WITH_CATALOG:
962#ifdef LIBXML_CATALOG_ENABLED
963 return(1);
964#else
965 return(0);
966#endif
967 case XML_WITH_XPATH:
968#ifdef LIBXML_XPATH_ENABLED
969 return(1);
970#else
971 return(0);
972#endif
973 case XML_WITH_XPTR:
974#ifdef LIBXML_XPTR_ENABLED
975 return(1);
976#else
977 return(0);
978#endif
980#ifdef LIBXML_XINCLUDE_ENABLED
981 return(1);
982#else
983 return(0);
984#endif
985 case XML_WITH_ICONV:
986#ifdef LIBXML_ICONV_ENABLED
987 return(1);
988#else
989 return(0);
990#endif
992#ifdef LIBXML_ISO8859X_ENABLED
993 return(1);
994#else
995 return(0);
996#endif
997 case XML_WITH_UNICODE:
998#ifdef LIBXML_UNICODE_ENABLED
999 return(1);
1000#else
1001 return(0);
1002#endif
1003 case XML_WITH_REGEXP:
1004#ifdef LIBXML_REGEXP_ENABLED
1005 return(1);
1006#else
1007 return(0);
1008#endif
1009 case XML_WITH_AUTOMATA:
1010#ifdef LIBXML_AUTOMATA_ENABLED
1011 return(1);
1012#else
1013 return(0);
1014#endif
1015 case XML_WITH_EXPR:
1016#ifdef LIBXML_EXPR_ENABLED
1017 return(1);
1018#else
1019 return(0);
1020#endif
1021 case XML_WITH_SCHEMAS:
1022#ifdef LIBXML_SCHEMAS_ENABLED
1023 return(1);
1024#else
1025 return(0);
1026#endif
1028#ifdef LIBXML_SCHEMATRON_ENABLED
1029 return(1);
1030#else
1031 return(0);
1032#endif
1033 case XML_WITH_MODULES:
1034#ifdef LIBXML_MODULES_ENABLED
1035 return(1);
1036#else
1037 return(0);
1038#endif
1039 case XML_WITH_DEBUG:
1040#ifdef LIBXML_DEBUG_ENABLED
1041 return(1);
1042#else
1043 return(0);
1044#endif
1045 case XML_WITH_DEBUG_MEM:
1046#ifdef DEBUG_MEMORY_LOCATION
1047 return(1);
1048#else
1049 return(0);
1050#endif
1051 case XML_WITH_DEBUG_RUN:
1052#ifdef LIBXML_DEBUG_RUNTIME
1053 return(1);
1054#else
1055 return(0);
1056#endif
1057 case XML_WITH_ZLIB:
1058#ifdef LIBXML_ZLIB_ENABLED
1059 return(1);
1060#else
1061 return(0);
1062#endif
1063 case XML_WITH_LZMA:
1064#ifdef LIBXML_LZMA_ENABLED
1065 return(1);
1066#else
1067 return(0);
1068#endif
1069 case XML_WITH_ICU:
1070#ifdef LIBXML_ICU_ENABLED
1071 return(1);
1072#else
1073 return(0);
1074#endif
1075 default:
1076 break;
1077 }
1078 return(0);
1079}
INTERNETFEATURELIST feature
Definition: misc.c:1719
@ XML_WITH_DEBUG
Definition: parser.h:1229
@ XML_WITH_LEGACY
Definition: parser.h:1214
@ XML_WITH_CATALOG
Definition: parser.h:1216
@ XML_WITH_XPATH
Definition: parser.h:1217
@ XML_WITH_TREE
Definition: parser.h:1203
@ XML_WITH_DEBUG_MEM
Definition: parser.h:1230
@ XML_WITH_DEBUG_RUN
Definition: parser.h:1231
@ XML_WITH_XPTR
Definition: parser.h:1218
@ XML_WITH_OUTPUT
Definition: parser.h:1204
@ XML_WITH_EXPR
Definition: parser.h:1225
@ XML_WITH_VALID
Definition: parser.h:1212
@ XML_WITH_THREAD
Definition: parser.h:1202
@ XML_WITH_SCHEMAS
Definition: parser.h:1226
@ XML_WITH_C14N
Definition: parser.h:1215
@ XML_WITH_MODULES
Definition: parser.h:1228
@ XML_WITH_UNICODE
Definition: parser.h:1222
@ XML_WITH_REGEXP
Definition: parser.h:1223
@ XML_WITH_HTML
Definition: parser.h:1213
@ XML_WITH_LZMA
Definition: parser.h:1234
@ XML_WITH_AUTOMATA
Definition: parser.h:1224
@ XML_WITH_ISO8859X
Definition: parser.h:1221
@ XML_WITH_PUSH
Definition: parser.h:1205
@ XML_WITH_ICONV
Definition: parser.h:1220
@ XML_WITH_ZLIB
Definition: parser.h:1232
@ XML_WITH_SAX1
Definition: parser.h:1209
@ XML_WITH_PATTERN
Definition: parser.h:1207
@ XML_WITH_WRITER
Definition: parser.h:1208
@ XML_WITH_FTP
Definition: parser.h:1210
@ XML_WITH_HTTP
Definition: parser.h:1211
@ XML_WITH_READER
Definition: parser.h:1206
@ XML_WITH_XINCLUDE
Definition: parser.h:1219
@ XML_WITH_SCHEMATRON
Definition: parser.h:1227
@ XML_WITH_ICU
Definition: parser.h:1233

Referenced by showVersion().

◆ xmlInitParser()

void xmlInitParser ( void  )

xmlInitParser:

Initialization function for the XML parser. This is not reentrant. Call once before processing in case of use in multithreaded programs.

Definition at line 14676 of file parser.c.

14676 {
14677 if (xmlParserInitialized != 0)
14678 return;
14679
14680#if defined(_WIN32) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
14681 if (xmlFree == free)
14683#endif
14684
14685#ifdef LIBXML_THREAD_ENABLED
14687 if (xmlParserInitialized == 0) {
14688#endif
14692 (xmlGenericError == NULL))
14694 xmlInitMemory();
14699#ifdef LIBXML_OUTPUT_ENABLED
14700 xmlRegisterDefaultOutputCallbacks();
14701#endif /* LIBXML_OUTPUT_ENABLED */
14702#ifdef LIBXML_HTML_ENABLED
14703 htmlInitAutoClose();
14704 htmlDefaultSAXHandlerInit();
14705#endif
14706#ifdef LIBXML_XPATH_ENABLED
14707 xmlXPathInit();
14708#endif
14710#ifdef LIBXML_THREAD_ENABLED
14711 }
14713#endif
14714}
XML_DEPRECATED XMLPUBFUN void XMLCALL xmlDefaultSAXHandlerInit(void)
Definition: SAX2.c:2934
#define free
Definition: debug_ros.c:5
XML_DEPRECATED XMLPUBFUN void XMLCALL xmlInitCharEncodingHandlers(void)
Definition: encoding.c:1420
int __cdecl atexit(void(__cdecl *)(void))
Definition: atonexit.c:97
void void __xmlGlobalInitMutexLock(void)
Definition: threads.c:413
void __xmlGlobalInitMutexUnlock(void)
Definition: threads.c:488
XML_DEPRECATED XMLPUBFUN int XMLCALL xmlInitializeDict(void)
Definition: dict.c:157
XML_DEPRECATED XMLPUBFUN void XMLCALL xmlInitGlobals(void)
Definition: globals.c:48
void xmlCleanupParser(void)
Definition: parser.c:14739
void XMLCDECL xmlGenericErrorDefaultFunc(void *ctx, const char *msg,...)
XML_DEPRECATED XMLPUBFUN void XMLCALL xmlInitThreads(void)
Definition: threads.c:847
XMLPUBFUN void XMLCALL xmlRegisterDefaultInputCallbacks(void)
XMLPUBFUN void XMLCALL initGenericErrorDefaultFunc(xmlGenericErrorFunc *handler)
Definition: error.c:90
XML_DEPRECATED XMLPUBFUN int XMLCALL xmlInitMemory(void)
Definition: xmlmemory.c:946

Referenced by DllMain(), xmlCheckVersion(), xmlCtxtReadFd(), xmlCtxtReadFile(), xmlCtxtReadIO(), xmlCtxtReadMemory(), xmlInitParserCtxt(), xmlParseDocument(), xmlReadDoc(), xmlReadFd(), xmlReadFile(), xmlReadIO(), and xmlReadMemory().

◆ xmlIsNameChar()

static int xmlIsNameChar ( xmlParserCtxtPtr  ctxt,
int  c 
)
static

Definition at line 3161 of file parser.c.

3161 {
3162 if ((ctxt->options & XML_PARSE_OLD10) == 0) {
3163 /*
3164 * Use the new checks of production [4] [4a] amd [5] of the
3165 * Update 5 of XML-1.0
3166 */
3167 if ((c != ' ') && (c != '>') && (c != '/') && /* accelerators */
3168 (((c >= 'a') && (c <= 'z')) ||
3169 ((c >= 'A') && (c <= 'Z')) ||
3170 ((c >= '0') && (c <= '9')) || /* !start */
3171 (c == '_') || (c == ':') ||
3172 (c == '-') || (c == '.') || (c == 0xB7) || /* !start */
3173 ((c >= 0xC0) && (c <= 0xD6)) ||
3174 ((c >= 0xD8) && (c <= 0xF6)) ||
3175 ((c >= 0xF8) && (c <= 0x2FF)) ||
3176 ((c >= 0x300) && (c <= 0x36F)) || /* !start */
3177 ((c >= 0x370) && (c <= 0x37D)) ||
3178 ((c >= 0x37F) && (c <= 0x1FFF)) ||
3179 ((c >= 0x200C) && (c <= 0x200D)) ||
3180 ((c >= 0x203F) && (c <= 0x2040)) || /* !start */
3181 ((c >= 0x2070) && (c <= 0x218F)) ||
3182 ((c >= 0x2C00) && (c <= 0x2FEF)) ||
3183 ((c >= 0x3001) && (c <= 0xD7FF)) ||
3184 ((c >= 0xF900) && (c <= 0xFDCF)) ||
3185 ((c >= 0xFDF0) && (c <= 0xFFFD)) ||
3186 ((c >= 0x10000) && (c <= 0xEFFFF))))
3187 return(1);
3188 } else {
3189 if ((IS_LETTER(c)) || (IS_DIGIT(c)) ||
3190 (c == '.') || (c == '-') ||
3191 (c == '_') || (c == ':') ||
3192 (IS_COMBINING(c)) ||
3193 (IS_EXTENDER(c)))
3194 return(1);
3195 }
3196 return(0);
3197}
const GLubyte * c
Definition: glext.h:8905
#define IS_COMBINING(c)
#define IS_DIGIT(c)
#define IS_EXTENDER(c)
#define IS_LETTER(c)

Referenced by xmlParseNCNameComplex(), xmlParseNmtoken(), and xmlParseStringName().

◆ xmlIsNameStartChar()

static int xmlIsNameStartChar ( xmlParserCtxtPtr  ctxt,
int  c 
)
static

Definition at line 3130 of file parser.c.

3130 {
3131 if ((ctxt->options & XML_PARSE_OLD10) == 0) {
3132 /*
3133 * Use the new checks of production [4] [4a] amd [5] of the
3134 * Update 5 of XML-1.0
3135 */
3136 if ((c != ' ') && (c != '>') && (c != '/') && /* accelerators */
3137 (((c >= 'a') && (c <= 'z')) ||
3138 ((c >= 'A') && (c <= 'Z')) ||
3139 (c == '_') || (c == ':') ||
3140 ((c >= 0xC0) && (c <= 0xD6)) ||
3141 ((c >= 0xD8) && (c <= 0xF6)) ||
3142 ((c >= 0xF8) && (c <= 0x2FF)) ||
3143 ((c >= 0x370) && (c <= 0x37D)) ||
3144 ((c >= 0x37F) && (c <= 0x1FFF)) ||
3145 ((c >= 0x200C) && (c <= 0x200D)) ||
3146 ((c >= 0x2070) && (c <= 0x218F)) ||
3147 ((c >= 0x2C00) && (c <= 0x2FEF)) ||
3148 ((c >= 0x3001) && (c <= 0xD7FF)) ||
3149 ((c >= 0xF900) && (c <= 0xFDCF)) ||
3150 ((c >= 0xFDF0) && (c <= 0xFFFD)) ||
3151 ((c >= 0x10000) && (c <= 0xEFFFF))))
3152 return(1);
3153 } else {
3154 if (IS_LETTER(c) || (c == '_') || (c == ':'))
3155 return(1);
3156 }
3157 return(0);
3158}

Referenced by xmlParseNCNameComplex(), and xmlParseStringName().

◆ xmlLoadEntityContent()

static int xmlLoadEntityContent ( xmlParserCtxtPtr  ctxt,
xmlEntityPtr  entity 
)
static

xmlLoadEntityContent: @ctxt: an XML parser context @entity: an unloaded system entity

Load the original content of the given system entity from the ExternalID/SystemID given. This is to be used for Included in Literal http://www.w3.org/TR/REC-xml/#inliteral processing of entities references

Returns 0 in case of success and -1 in case of failure

Definition at line 8060 of file parser.c.

8060 {
8063 int l, c;
8064 int count = 0;
8065
8066 if ((ctxt == NULL) || (entity == NULL) ||
8069 (entity->content != NULL)) {
8071 "xmlLoadEntityContent parameter error");
8072 return(-1);
8073 }
8074
8077 "Reading %s entity content input\n", entity->name);
8078
8079 buf = xmlBufferCreate();
8080 if (buf == NULL) {
8082 "xmlLoadEntityContent parameter error");
8083 return(-1);
8084 }
8086
8088 if (input == NULL) {
8090 "xmlLoadEntityContent input error");
8092 return(-1);
8093 }
8094
8095 /*
8096 * Push the entity as the current input, read char by char
8097 * saving to the buffer until the end of the entity or an error
8098 */
8099 if (xmlPushInput(ctxt, input) < 0) {
8102 return(-1);
8103 }
8104
8105 GROW;
8106 c = CUR_CHAR(l);
8107 while ((ctxt->input == input) && (ctxt->input->cur < ctxt->input->end) &&
8108 (IS_CHAR(c))) {
8109 xmlBufferAdd(buf, ctxt->input->cur, l);
8110 if (count++ > XML_PARSER_CHUNK_SIZE) {
8111 count = 0;
8112 GROW;
8113 if (ctxt->instate == XML_PARSER_EOF) {
8115 return(-1);
8116 }
8117 }
8118 NEXTL(l);
8119 c = CUR_CHAR(l);
8120 if (c == 0) {
8121 count = 0;
8122 GROW;
8123 if (ctxt->instate == XML_PARSER_EOF) {
8125 return(-1);
8126 }
8127 c = CUR_CHAR(l);
8128 }
8129 }
8130
8131 if ((ctxt->input == input) && (ctxt->input->cur >= ctxt->input->end)) {
8132 xmlPopInput(ctxt);
8133 } else if (!IS_CHAR(c)) {
8134 xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
8135 "xmlLoadEntityContent: invalid char value %d\n",
8136 c);
8138 return(-1);
8139 }
8140 entity->content = buf->content;
8141 buf->content = NULL;
8143
8144 return(0);
8145}
@ XML_EXTERNAL_GENERAL_PARSED_ENTITY
Definition: entities.h:26
@ XML_EXTERNAL_PARAMETER_ENTITY
Definition: entities.h:29
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define c
Definition: ke_i.h:80
#define IS_CHAR(c)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity)
XMLPUBVAR int xmlParserDebugEntities
Definition: globals.h:423
XMLPUBFUN void XMLCALL xmlBufferFree(xmlBufferPtr buf)
XMLPUBFUN int XMLCALL xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len)
XMLPUBFUN xmlBufferPtr XMLCALL xmlBufferCreate(void)
@ XML_BUFFER_ALLOC_DOUBLEIT
Definition: tree.h:75
XMLPUBFUN void XMLCALL xmlBufferSetAllocationScheme(xmlBufferPtr buf, xmlBufferAllocationScheme scheme)
#define NEXTL(l)
Definition: parser.c:2156
xmlChar xmlPopInput(xmlParserCtxtPtr ctxt)
Definition: parser.c:2265
#define XML_PARSER_CHUNK_SIZE
Definition: parser.c:288
int xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input)
Definition: parser.c:2290
#define CUR_CHAR(l)
Definition: parser.c:2163
Definition: actctx.c:447
WCHAR * name
Definition: actctx.c:464
@ XML_ERR_INVALID_CHAR
Definition: xmlerror.h:109

Referenced by xmlStringLenDecodeEntities().

◆ xmlParseAttribute2()

static const xmlChar * xmlParseAttribute2 ( xmlParserCtxtPtr  ctxt,
const xmlChar pref,
const xmlChar elem,
const xmlChar **  prefix,
xmlChar **  value,
int len,
int alloc 
)
static

xmlParseAttribute2: @ctxt: an XML parser context @pref: the element prefix @elem: the element name @prefix: a xmlChar ** used to store the value of the attribute prefix @value: a xmlChar ** used to store the value of the attribute @len: an int * to save the length of the attribute @alloc: an int * to indicate if the attribute was allocated

parse an attribute in the new SAX2 framework.

Returns the attribute name, and the value in *value, .

Definition at line 9125 of file parser.c.

9129{
9130 const xmlChar *name;
9131 xmlChar *val, *internal_val = NULL;
9132 int normalize = 0;
9133
9134 *value = NULL;
9135 GROW;
9136 name = xmlParseQName(ctxt, prefix);
9137 if (name == NULL) {
9138 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
9139 "error parsing attribute name\n");
9140 return (NULL);
9141 }
9142
9143 /*
9144 * get the type if needed
9145 */
9146 if (ctxt->attsSpecial != NULL) {
9147 int type;
9148
9150 pref, elem, *prefix, name);
9151 if (type != 0)
9152 normalize = 1;
9153 }
9154
9155 /*
9156 * read the value
9157 */
9159 if (RAW == '=') {
9160 NEXT;
9163 if (normalize) {
9164 /*
9165 * Sometimes a second normalisation pass for spaces is needed
9166 * but that only happens if charrefs or entities references
9167 * have been used in the attribute value, i.e. the attribute
9168 * value have been extracted in an allocated string already.
9169 */
9170 if (*alloc) {
9171 const xmlChar *val2;
9172
9173 val2 = xmlAttrNormalizeSpace2(ctxt, val, len);
9174 if ((val2 != NULL) && (val2 != val)) {
9175 xmlFree(val);
9176 val = (xmlChar *) val2;
9177 }
9178 }
9179 }
9181 } else {
9182 xmlFatalErrMsgStr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
9183 "Specification mandates value for attribute %s\n",
9184 name);
9185 return (NULL);
9186 }
9187
9188 if (*prefix == ctxt->str_xml) {
9189 /*
9190 * Check that xml:lang conforms to the specification
9191 * No more registered as an error, just generate a warning now
9192 * since this was deprecated in XML second edition
9193 */
9194 if ((ctxt->pedantic) && (xmlStrEqual(name, BAD_CAST "lang"))) {
9195 internal_val = xmlStrndup(val, *len);
9196 if (!xmlCheckLanguageID(internal_val)) {
9197 xmlWarningMsg(ctxt, XML_WAR_LANG_VALUE,
9198 "Malformed value for xml:lang : %s\n",
9199 internal_val, NULL);
9200 }
9201 }
9202
9203 /*
9204 * Check that xml:space conforms to the specification
9205 */
9206 if (xmlStrEqual(name, BAD_CAST "space")) {
9207 internal_val = xmlStrndup(val, *len);
9208 if (xmlStrEqual(internal_val, BAD_CAST "default"))
9209 *(ctxt->space) = 0;
9210 else if (xmlStrEqual(internal_val, BAD_CAST "preserve"))
9211 *(ctxt->space) = 1;
9212 else {
9213 xmlWarningMsg(ctxt, XML_WAR_SPACE_VALUE,
9214 "Invalid value \"%s\" for xml:space : \"default\" or \"preserve\" expected\n",
9215 internal_val, NULL);
9216 }
9217 }
9218 if (internal_val) {
9219 xmlFree(internal_val);
9220 }
9221 }
9222
9223 *value = val;
9224 return (name);
9225}
static void normalize(float vec[3])
Definition: bezierEval.cc:234
static size_t elem
Definition: string.c:68
#define alloc
Definition: rosglue.h:13
XMLPUBFUN void *XMLCALL xmlHashQLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *prefix, const xmlChar *name2, const xmlChar *prefix2)
Definition: hash.c:510
@ XML_PARSER_CONTENT
Definition: parser.h:119
static xmlChar * xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, int normalize)
Definition: parser.c:8960
#define NEXT
Definition: parser.c:2147
#define SKIP_BLANKS
Definition: parser.c:2145
static const xmlChar * xmlParseQName(xmlParserCtxtPtr ctxt, const xmlChar **prefix)
Definition: parser.c:8788
int xmlCheckLanguageID(const xmlChar *lang)
Definition: parser.c:1474
static const xmlChar * xmlAttrNormalizeSpace2(xmlParserCtxtPtr ctxt, xmlChar *src, int *len)
Definition: parser.c:1185
@ XML_WAR_LANG_VALUE
Definition: xmlerror.h:198
@ XML_ERR_ATTRIBUTE_WITHOUT_VALUE
Definition: xmlerror.h:141
@ XML_ERR_NAME_REQUIRED
Definition: xmlerror.h:168
@ XML_WAR_SPACE_VALUE
Definition: xmlerror.h:202
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:160

Referenced by xmlParseStartTag2().

◆ xmlParseAttributeListDecl()

void xmlParseAttributeListDecl ( xmlParserCtxtPtr  ctxt)

xmlParseAttributeListDecl: @ctxt: an XML parser context

: parse the Attribute list def for an element

[52] AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>'

[53] AttDef ::= S Name S AttType S DefaultDecl

Definition at line 5976 of file parser.c.

5976 {
5977 const xmlChar *elemName;
5978 const xmlChar *attrName;
5980
5981 if (CMP9(CUR_PTR, '<', '!', 'A', 'T', 'T', 'L', 'I', 'S', 'T')) {
5982 int inputid = ctxt->input->id;
5983
5984 SKIP(9);
5985 if (SKIP_BLANKS == 0) {
5986 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5987 "Space required after '<!ATTLIST'\n");
5988 }
5989 elemName = xmlParseName(ctxt);
5990 if (elemName == NULL) {
5991 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5992 "ATTLIST: no name for Element\n");
5993 return;
5994 }
5996 GROW;
5997 while ((RAW != '>') && (ctxt->instate != XML_PARSER_EOF)) {
5998 int type;
5999 int def;
6000 xmlChar *defaultValue = NULL;
6001
6002 GROW;
6003 tree = NULL;
6004 attrName = xmlParseName(ctxt);
6005 if (attrName == NULL) {
6006 xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6007 "ATTLIST: no name for Attribute\n");
6008 break;
6009 }
6010 GROW;
6011 if (SKIP_BLANKS == 0) {
6012 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6013 "Space required after the attribute name\n");
6014 break;
6015 }
6016
6018 if (type <= 0) {
6019 break;
6020 }
6021
6022 GROW;
6023 if (SKIP_BLANKS == 0) {
6024 xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6025 "Space required after the attribute type\n");
6026 if (tree != NULL)
6028 break;
6029 }
6030
6031 def = xmlParseDefaultDecl(ctxt, &defaultValue);
6032 if (def <= 0) {
6033 if (defaultValue != NULL)
6034 xmlFree(defaultValue);
6035 if (tree != NULL)
6037 break;
6038 }
6039 if ((type !=