ReactOS  0.4.15-dev-5499-g1341c38
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 []
 

: an XML parser context

xmlSplitQName: @ctxt: an XML parser context

@prefix: a xmlChar **

parse an UTF8 encoded XML qualified name string

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

[NS 6] Prefix ::= NCName

[NS 7] LocalPart ::= NCName

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

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

: the localname

xmlParseQNameAndCompare: @ctxt: an XML parser context

@prefix: the prefix, if any.

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

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

#define GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end)
 
#define DICT_FREE(str)
 
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)
 

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

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 )
GLdouble s
Definition: gl.h:2039

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

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
unsigned char xmlChar
Definition: xmlstring.h:28
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;
unsigned char xmlChar
Definition: xmlstring.h:28
GLuint in
Definition: glext.h:9616
GLuint start
Definition: gl.h:1545
#define NULL
Definition: types.h:112

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
unsigned char xmlChar
Definition: xmlstring.h:28
#define NULL
Definition: types.h:112

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); \
}
#define 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)
r l[0]
Definition: byte_order.h:167

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);
#define INPUT_CHUNK

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
#define INPUT_CHUNK

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)
GLuint GLfloat * val
Definition: glext.h:7180
#define INPUT_CHUNK

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 }
const xmlChar * name
Definition: tree.h:492
#define NXT(val)
Definition: parser.c:2066
#define IS_BLANK_CH(c)
const WCHAR * str
XMLPUBFUN xmlNodePtr XMLCALL xmlGetLastChild(const xmlNode *parent)
xmlNodePtr node
Definition: parser.h:205
XMLPUBFUN int XMLCALL xmlNodeIsText(const xmlNode *node)
xmlChar * content
Definition: tree.h:502
Definition: tree.h:489
int ret
xmlDocPtr myDoc
Definition: parser.h:187
GLenum GLsizei len
Definition: glext.h:6722
struct _xmlSAXHandler * sax
Definition: parser.h:185
xmlElementType type
Definition: tree.h:491
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 xmlIsMixedElement(xmlDocPtr doc, const xmlChar *name)
Definition: valid.c:3494
#define NULL
Definition: types.h:112
struct _xmlNode * children
Definition: tree.h:493
#define RAW
Definition: parser.c:2064
int * space
Definition: parser.h:244

Referenced by xmlParseCharData(), and xmlParseCharDataComplex().

◆ inputPop()

xmlParserInputPtr inputPop ( xmlParserCtxtPtr  ctxt)

inputPop: @ctxt: an XML parser context

Pops the top parser input from the input stack

Returns the input just removed

Definition at line 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
int ret
#define NULL
Definition: types.h:112

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 }
Definition: pdh_main.c:93
xmlParserInputPtr * inputTab
Definition: parser.h:202
xmlParserInputPtr input
Definition: parser.h:199
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
int inputMax
Definition: parser.h:201
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
GLsizei const GLfloat * value
Definition: glext.h:6069
#define NULL
Definition: types.h:112

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 }
DWORD error
Definition: parser.c:105
#define NULL
Definition: types.h:112
#define msg(x)
Definition: auth_time.c:54

◆ 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 {
1873  xmlStartTag *tag;
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++);
1909 mem_error:
1910  xmlErrMemory(ctxt, NULL);
1911  return (-1);
1912 }
Definition: ecma_167.h:138
const xmlChar * name
Definition: parser.h:229
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
xmlStartTag * pushTab
Definition: parser.h:283
unsigned char xmlChar
Definition: xmlstring.h:28
GLsizei const GLfloat * value
Definition: glext.h:6069
IN PCTCH line
Definition: pager.h:36
#define NULL
Definition: types.h:112
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
const xmlChar ** nameTab
Definition: parser.h:232
char * tag
Definition: main.c:59

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 }
const xmlChar * name
Definition: parser.h:229
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
#define NULL
Definition: types.h:112
const xmlChar ** nameTab
Definition: parser.h:232

Referenced by xmlParseElementEnd(), and xmlParseElementStart().

◆ namePush()

int namePush ( xmlParserCtxtPtr  ctxt,
const xmlChar value 
)

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

Pushes a new element name on top of the name stack

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

Definition at line 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++);
1968 mem_error:
1969  xmlErrMemory(ctxt, NULL);
1970  return (-1);
1971 }
const xmlChar * name
Definition: parser.h:229
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
unsigned char xmlChar
Definition: xmlstring.h:28
GLsizei const GLfloat * value
Definition: glext.h:6069
#define NULL
Definition: types.h:112
const xmlChar ** nameTab
Definition: parser.h:232

◆ 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 {
1841  xmlNodePtr ret;
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
xmlNodePtr node
Definition: parser.h:205
Definition: tree.h:489
int ret
#define NULL
Definition: types.h:112

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 }
xmlNodePtr * nodeTab
Definition: parser.h:208
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
xmlNodePtr node
Definition: parser.h:205
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
unsigned int xmlParserMaxDepth
Definition: parser.c:270
Definition: tree.h:489
GLsizei const GLfloat * value
Definition: glext.h:6069
#define NULL
Definition: types.h:112
static void xmlHaltParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12549

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 xmlGenericErrorFunc xmlGenericError
Definition: globals.h:337
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
const xmlChar ** nsTab
Definition: parser.h:281
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:353

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 }
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
unsigned char xmlChar
Definition: xmlstring.h:28
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
const xmlChar ** nsTab
Definition: parser.h:281

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
int ret
int * space
Definition: parser.h:244

Referenced by xmlParseElementStart(), and xmlParseEndTag2().

◆ spacePush()

static int spacePush ( xmlParserCtxtPtr  ctxt,
int  val 
)
static

Definition at line 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 * spaceTab
Definition: parser.h:247
int spaceMax
Definition: parser.h:246
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
GLuint GLfloat * val
Definition: glext.h:7180
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
#define NULL
Definition: types.h:112
int * space
Definition: parser.h:244

Referenced by xmlParseElementStart().

◆ xmlAddDefAttrs()

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

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

Add a defaulted attribute for an element

Definition at line 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) {
1291  xmlFree(defaults);
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) {
1305  xmlFree(defaults);
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 
1338 mem_error:
1339  xmlErrMemory(ctxt, NULL);
1340  return;
1341 }
Definition: pdh_main.c:93
XMLPUBFUN const xmlChar *XMLCALL xmlSplitQName3(const xmlChar *name, int *len)
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:426
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:476
int external
Definition: parser.h:217
static const ASMPROP_RES defaults[ASM_NAME_MAX_PARAMS]
Definition: asmname.c:82
xmlHashTablePtr attsDefault
Definition: parser.h:284
#define BAD_CAST
Definition: xmlstring.h:35
xmlDictPtr dict
Definition: parser.h:263
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:867
const char * fullname
Definition: shader.c:1766
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
GLsizei const GLfloat * value
Definition: glext.h:6069
XMLPUBFUN int XMLCALL xmlHashUpdateEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata, xmlHashDeallocator f)
Definition: hash.c:445
static calc_node_t temp
Definition: rpn_ieee.c:38
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreateDict(int size, xmlDictPtr dict)
Definition: hash.c:210
#define NULL
Definition: types.h:112
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
xmlHashTablePtr attsSpecial
Definition: parser.h:285
Definition: name.c:38
xmlDefAttrs * xmlDefAttrsPtr
Definition: parser.c:1122
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by xmlParseAttributeListDecl().

◆ xmlAddSpecialAttr()

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

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

Register this attribute type

Definition at line 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 
1371 mem_error:
1372  xmlErrMemory(ctxt, NULL);
1373  return;
1374 }
XMLPUBFUN int XMLCALL xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata)
Definition: hash.c:406
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:476
xmlDictPtr dict
Definition: parser.h:263
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
const char * fullname
Definition: shader.c:1766
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreateDict(int size, xmlDictPtr dict)
Definition: hash.c:210
#define NULL
Definition: types.h:112
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
xmlHashTablePtr attsSpecial
Definition: parser.h:285
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

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
#define NULL
Definition: types.h:112

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 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
XMLPUBFUN xmlChar *XMLCALL xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:42
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
static xmlChar * xmlAttrNormalizeSpace(const xmlChar *src, xmlChar *dst)
Definition: parser.c:1152
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
FxCollectionEntry * cur
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by xmlParseAttribute2().

◆ xmlCheckLanguageID()

int xmlCheckLanguageID ( const xmlChar lang)

xmlCheckLanguageID: @lang: pointer to the string value

Checks that the value conforms to the LanguageID production:

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

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

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

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

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

script = 4ALPHA ; ISO 15924 code

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

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

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

                                ; Single alphanumerics
                                ; "x" reserved for private use

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

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

Returns 1 if correct 0 otherwise

Definition at line 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 */
1554 script:
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 */
1575 region:
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 */
1592 variant:
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 
1600 region_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:382
static const WCHAR lang[]
Definition: wbemdisp.c:287
unsigned char xmlChar
Definition: xmlstring.h:28
FxCollectionEntry * cur
#define NULL
Definition: types.h:112

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) {
1409  xmlHashFree(ctxt->attsSpecial, NULL);
1410  ctxt->attsSpecial = NULL;
1411  }
1412  return;
1413 }
XMLPUBFUN int XMLCALL xmlHashSize(xmlHashTablePtr table)
Definition: hash.c:1034
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
#define NULL
Definition: types.h:112
xmlHashTablePtr attsSpecial
Definition: parser.h:285
static void xmlCleanSpecialAttrCallback(void *payload, void *data, const xmlChar *fullname, const xmlChar *fullattr, const xmlChar *unused ATTRIBUTE_UNUSED)
Definition: parser.c: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 }
XMLPUBFUN int XMLCALL xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, xmlHashDeallocator f)
Definition: hash.c:1071
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
const char * fullname
Definition: shader.c:1766
#define NULL
Definition: types.h:112
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
xmlHashTablePtr attsSpecial
Definition: parser.h:285
xmlParserCtxt * xmlParserCtxtPtr
Definition: tree.h:39

Referenced by xmlCleanSpecialAttr().

◆ xmlCleanupParser()

void xmlCleanupParser ( void  )

xmlCleanupParser:

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

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

Definition at line 14739 of file parser.c.

14739  {
14740  if (!xmlParserInitialized)
14741  return;
14742 
14744 #ifdef LIBXML_CATALOG_ENABLED
14745  xmlCatalogCleanup();
14746 #endif
14747  xmlDictCleanup();
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 */
14758  xmlCleanupMemory();
14760 }
XMLPUBFUN void XMLCALL xmlCleanupInputCallbacks(void)
XML_DEPRECATED XMLPUBFUN void XMLCALL xmlCleanupGlobals(void)
Definition: globals.c:535
XML_DEPRECATED XMLPUBFUN void XMLCALL xmlCleanupMemory(void)
Definition: xmlmemory.c:989
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 xmlCleanupThreads(void)
Definition: threads.c:900
static int xmlParserInitialized
Definition: parser.c:14665

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 }
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:426
GLenum GLsizei len
Definition: glext.h:6722
FxCollectionEntry * cur
xmlParserCtxtPtr xmlCreateMemoryParserCtxt(const char *buffer, int size)
Definition: parser.c:14339
#define NULL
Definition: types.h:112

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 }
static xmlParserCtxtPtr xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID, const xmlChar *base, xmlParserCtxtPtr pctx)
Definition: parser.c:13954
#define ID
Definition: ruserpass.c:36
#define NULL
Definition: types.h:112

◆ 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))
14006  directory = xmlParserGetDirectory((char *)uri);
14007  if ((ctxt->directory == NULL) && (directory != NULL))
14008  ctxt->directory = directory;
14009  xmlFree(uri);
14010  }
14011  return(ctxt);
14012 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1745
const char * uri
Definition: sec_mgr.c:1588
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
int input_id
Definition: parser.h:312
XMLPUBFUN xmlChar *XMLCALL xmlBuildURI(const xmlChar *URI, const xmlChar *base)
Definition: uri.c:1892
void * _private
Definition: parser.h:256
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
unsigned char xmlChar
Definition: xmlstring.h:28
#define ID
Definition: ruserpass.c:36
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
#define NULL
Definition: types.h:112
char * directory
Definition: parser.h:226
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)
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
12628  if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
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 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1745
#define XML_SAX2_MAGIC
Definition: parser.h:671
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
static int sax
Definition: xmllint.c:193
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc)
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler
Definition: globals.h:312
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
xmlSAXHandler * xmlSAXHandlerPtr
Definition: tree.h:45
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct _xmlSAXHandler * sax
Definition: parser.h:185
#define NULL
Definition: types.h:112
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)
#define memset(x, y, z)
Definition: compat.h:39
void * userData
Definition: parser.h:186

◆ xmlCreateMemoryParserCtxt()

xmlParserCtxtPtr xmlCreateMemoryParserCtxt ( const char buffer,
int  size 
)

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

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

Returns the new parser context or NULL

Definition at line 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 inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1745
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
GLuint buffer
Definition: glext.h:5915
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1094
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum GLenum input
Definition: glext.h:9031
#define NULL
Definition: types.h:112
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream(xmlParserCtxtPtr ctxt)

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

◆ xmlCreateURLParserCtxt()

xmlParserCtxtPtr xmlCreateURLParserCtxt ( const char filename,
int  options 
)

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

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

Returns the new parser context or NULL

Definition at line 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 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1745
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
const char * filename
Definition: ioapi.h:137
int linenumbers
Definition: parser.h:259
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:15000
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
#define NULL
Definition: types.h:112
char * directory
Definition: parser.h:226
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)

Referenced by xmlCreateFileParserCtxt(), and xmlReadFile().

◆ xmlCtxtGrowAttrs()

static int xmlCtxtGrowAttrs ( xmlParserCtxtPtr  ctxt,
int  nr 
)
static

Definition at line 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);
1730 mem_error:
1731  xmlErrMemory(ctxt, NULL);
1732  return(-1);
1733 }
int * attallocs
Definition: parser.h:282
ULONG nr
Definition: thread.c:7
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
unsigned char xmlChar
Definition: xmlstring.h:28
const xmlChar ** atts
Definition: parser.h:264
#define NULL
Definition: types.h:112
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
_In_ uint16_t _Out_ ULONG * atts
Definition: btrfs_drv.h:1107
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by xmlParseStartTag2().

◆ xmlCtxtReadDoc()

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

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

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

Returns the resulting document tree

Definition at line 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 }
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:426
static char * encoding
Definition: xmllint.c:155
xmlDocPtr xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size, const char *URL, const char *encoding, int options)
Definition: parser.c:15426
FxCollectionEntry * cur
#define NULL
Definition: types.h:112

◆ 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 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1745
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15159
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
static char * encoding
Definition: xmllint.c:155
static int fd
Definition: io.c:51
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14801
void xmlInitParser(void)
Definition: parser.c:14676
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFd(int fd, xmlCharEncoding enc)
GLenum GLenum GLenum input
Definition: glext.h:9031
#define NULL
Definition: types.h:112

◆ 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 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1745
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15159
static char * encoding
Definition: xmllint.c:155
const char * filename
Definition: ioapi.h:137
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14801
void xmlInitParser(void)
Definition: parser.c:14676
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
#define NULL
Definition: types.h:112

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 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1745
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15159
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
static char * encoding
Definition: xmllint.c:155
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14801
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc)
void xmlInitParser(void)
Definition: parser.c:14676
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
GLenum GLenum GLenum input
Definition: glext.h:9031
#define NULL
Definition: types.h:112

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 }
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input, xmlCharEncoding enc)
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1745
static xmlDocPtr xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding, int options, int reuse)
Definition: parser.c:15159
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
static char * encoding
Definition: xmllint.c:155
GLuint buffer
Definition: glext.h:5915
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14801
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc)
void xmlInitParser(void)
Definition: parser.c:14676
GLsizeiptr size
Definition: glext.h:5919
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
GLenum GLenum GLenum input
Definition: glext.h:9031
#define NULL
Definition: types.h:112

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;
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;
14875  xmlInitNodeInfoSeq(&ctxt->node_seq);
14876 
14877  if (ctxt->attsDefault != NULL) {
14879  ctxt->attsDefault = NULL;
14880  }
14881  if (ctxt->attsSpecial != NULL) {
14882  xmlHashFree(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 }
xmlParserInputState instate
Definition: parser.h:223
unsigned long sizeentities
Definition: parser.h:304
int * spaceTab
Definition: parser.h:247
xmlChar * extSubURI
Definition: parser.h:240
long checkIndex
Definition: parser.h:235
int nsWellFormed
Definition: parser.h:286
xmlValidityErrorFunc error
Definition: valid.h:84
int external
Definition: parser.h:217
const xmlChar * name
Definition: parser.h:229
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
xmlError lastError
Definition: parser.h:301
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:322
int standalone
Definition: parser.h:192
xmlHashTablePtr attsDefault
Definition: parser.h:284
xmlChar * extSubSystem
Definition: parser.h:241
XMLPUBFUN void XMLCALL xmlFreeInputStream(xmlParserInputPtr input)
xmlDictPtr dict
Definition: parser.h:263
Definition: dict.c:111
#define DICT_FREE(str)
Definition: parser.c:14789
XMLPUBFUN void XMLCALL xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
int wellFormed
Definition: parser.h:188
xmlNodePtr node
Definition: parser.h:205
int record_info
Definition: parser.h:210
int hasPErefs
Definition: parser.h:216
xmlParserInputPtr inputPop(xmlParserCtxtPtr ctxt)
Definition: parser.c:1774
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
xmlDocPtr myDoc
Definition: parser.h:187
const xmlChar * encoding
Definition: parser.h:191
const xmlChar * version
Definition: parser.h:190
void * catalogs
Definition: parser.h:260
int hasExternalSubset
Definition: parser.h:215
XMLPUBFUN void XMLCALL xmlResetError(xmlErrorPtr err)
XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL xmlParserValidityWarning(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
unsigned long sizeentcopy
Definition: parser.h:313
GLenum GLenum GLenum input
Definition: glext.h:9031
int inSubset
Definition: parser.h:238
#define NULL
Definition: types.h:112
xmlHashTablePtr attsSpecial
Definition: parser.h:285
char * directory
Definition: parser.h:226
XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL XMLPUBFUN void XMLCDECL xmlParserValidityError(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
int code
Definition: xmlerror.h:80
void * userData
Definition: valid.h:83
xmlValidCtxt vctxt
Definition: parser.h:221
int * space
Definition: parser.h:244
xmlValidityWarningFunc warning
Definition: valid.h:85
xmlParserNodeInfoSeq node_seq
Definition: parser.h:211
XMLPUBFUN void XMLCALL xmlHashDefaultDeallocator(void *entry, const xmlChar *name)
unsigned long nbentities
Definition: parser.h:303

Referenced by xmlClearParserCtxt(), 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 
14960  xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
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 }
XMLPUBFUN int XMLCALL xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
int xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input, size_t base, size_t cur)
Definition: buf.c:1144
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1745
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
XMLPUBFUN int XMLCALL xmlParserInputBufferPush(xmlParserInputBufferPtr in, int len, const char *buf)
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
const xmlChar * cur
Definition: parser.h:59
static char * encoding
Definition: xmllint.c:155
xmlCharEncoding
Definition: encoding.h:56
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1094
const char * filename
Definition: ioapi.h:137
const xmlChar * base
Definition: parser.h:58
void xmlCtxtReset(xmlParserCtxtPtr ctxt)
Definition: parser.c:14801
xmlParserInputPtr input
Definition: parser.h:199
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:337
XMLPUBFUN xmlChar *XMLCALL xmlCanonicPath(const xmlChar *path)
Definition: uri.c:2380
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlAllocParserInputBuffer(xmlCharEncoding enc)
#define BAD_CAST
Definition: xmlstring.h:35
GLsizeiptr size
Definition: glext.h:5919
xmlBufPtr buffer
Definition: xmlIO.h:132
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
XMLPUBFUN xmlCharEncoding XMLCALL xmlDetectCharEncoding(const unsigned char *in, int len)
Definition: encoding.c:952
size_t xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1113
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1678
const xmlChar * encoding
Definition: parser.h:191
unsigned char xmlChar
Definition: xmlstring.h:28
FxCollectionEntry * cur
xmlParserInputBufferPtr buf
Definition: parser.h:54
const char * filename
Definition: parser.h:56
XMLPUBFUN int XMLCALL xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
#define NULL
Definition: types.h:112
char * directory
Definition: parser.h:226
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:67
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream(xmlParserCtxtPtr ctxt)
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:353

◆ 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 }
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:15000
#define NULL
Definition: types.h:112

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) {
15022  ctxt->loadsubset |= XML_COMPLETE_ATTRS;
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;
15033  if (options & XML_PARSE_PEDANTIC) {
15034  ctxt->pedantic = 1;
15036  ctxt->options |= XML_PARSE_PEDANTIC;
15037  } else
15038  ctxt->pedantic = 0;
15039  if (options & XML_PARSE_NOBLANKS) {
15040  ctxt->keepBlanks = 0;
15041  ctxt->sax->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
15043  ctxt->options |= XML_PARSE_NOBLANKS;
15044  } else
15045  ctxt->keepBlanks = 1;
15046  if (options & XML_PARSE_DTDVALID) {
15047  ctxt->validate = 1;
15049  ctxt->vctxt.warning = NULL;
15050  if (options & XML_PARSE_NOERROR)
15051  ctxt->vctxt.error = NULL;
15053  ctxt->options |= XML_PARSE_DTDVALID;
15054  } else
15055  ctxt->validate = 0;
15056  if (options & XML_PARSE_NOWARNING) {
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  }
15104  if (options & XML_PARSE_NOBASEFIX) {
15105  ctxt->options |= XML_PARSE_NOBASEFIX;
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  }
15118  if (options & XML_PARSE_IGNORE_ENC) {
15119  ctxt->options |= XML_PARSE_IGNORE_ENC;
15121  }
15122  if (options & XML_PARSE_BIG_LINES) {
15123  ctxt->options |= XML_PARSE_BIG_LINES;
15125  }
15126  ctxt->linenumbers = 1;
15127  return (options);
15128 }
#define XML_DETECT_IDS
Definition: parser.h:137
int pedantic
Definition: parser.h:255
XMLPUBFUN size_t XMLCALL xmlDictSetLimit(xmlDictPtr dict, size_t limit)
Definition: dict.c:1265
static char * encoding
Definition: xmllint.c:155
xmlValidityErrorFunc error
Definition: valid.h:84
int recovery
Definition: parser.h:261
int linenumbers
Definition: parser.h:259
int replaceEntities
Definition: parser.h:189
xmlDictPtr dict
Definition: parser.h:263
int validate
Definition: parser.h:220
XMLPUBFUN void XMLCALL xmlSAX2IgnorableWhitespace(void *ctx, const xmlChar *ch, int len)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
const xmlChar * encoding
Definition: parser.h:191
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
int loadsubset
Definition: parser.h:258
int dictNames
Definition: parser.h:292
#define XML_COMPLETE_ATTRS
Definition: parser.h:146
#define NULL
Definition: types.h:112
int keepBlanks
Definition: parser.h:236
xmlValidCtxt vctxt
Definition: parser.h:221
xmlValidityWarningFunc warning
Definition: valid.h:85
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:67

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 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define XML_SAX2_MAGIC
Definition: parser.h:671
static int sax
Definition: xmllint.c:193
const xmlChar * str_xmlns
Definition: parser.h:272
const xmlChar * str_xml
Definition: parser.h:271
#define XML_XML_NAMESPACE
Definition: tree.h:140
#define BAD_CAST
Definition: xmlstring.h:35
xmlDictPtr dict
Definition: parser.h:263
const xmlChar * str_xml_ns
Definition: parser.h:273
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:867
struct _xmlSAXHandler * sax
Definition: parser.h:185
#define NULL
Definition: types.h:112

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 }
XMLPUBFUN int XMLCALL xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
int xmlParseDocument(xmlParserCtxtPtr ctxt)
Definition: parser.c:10697
static char * encoding
Definition: xmllint.c:155
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
xmlParserInputPtr input
Definition: parser.h:199
int recovery
Definition: parser.h:261
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:15000
int wellFormed
Definition: parser.h:188
XMLPUBFUN void XMLCALL xmlFreeDoc(xmlDocPtr cur)
int ret
xmlDocPtr myDoc
Definition: parser.h:187
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1678
unsigned char xmlChar
Definition: xmlstring.h:28
const char * filename
Definition: parser.h:56
#define NULL
Definition: types.h:112
Definition: tree.h:551
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:67

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 }
xmlParserInputState instate
Definition: parser.h:223
int disableSAX
Definition: parser.h:237
int recovery
Definition: parser.h:261
int wellFormed
Definition: parser.h:188
#define NULL
Definition: types.h:112

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;
413  case XML_ERR_ENTITY_LOOP:
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;
492  case XML_ERR_GT_REQUIRED:
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 }
xmlParserInputState instate
Definition: parser.h:223
int disableSAX
Definition: parser.h:237
int recovery
Definition: parser.h:261
EXPORT int errmsg(char *msg, va_alist)
Definition: comerr.c:192
int wellFormed
Definition: parser.h:188
DWORD error
Definition: parser.c:105
#define NULL
Definition: types.h:112

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 }
const xmlChar * str_xml
Definition: parser.h:271
const xmlChar * str_xml_ns
Definition: parser.h:273
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112
const xmlChar ** nsTab
Definition: parser.h:281

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 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:378
#define XML_MAX_LOOKUP_LIMIT
const xmlChar * cur
Definition: parser.h:59
const xmlChar * base
Definition: parser.h:58
xmlInputReadCallback readcallback
Definition: xmlIO.h:127
xmlParserInputPtr input
Definition: parser.h:199
int xmlInputReadCallbackNop(void *context, char *buffer, int len)
XMLPUBFUN int XMLCALL xmlParserInputGrow(xmlParserInputPtr in, int len)
#define INPUT_CHUNK
xmlParserInputBufferPtr buf
Definition: parser.h:54
#define NULL
Definition: types.h:112
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
static void xmlHaltParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12549
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) {
12566