ReactOS  0.4.15-dev-5615-gc3644fd
parserInternals.h File Reference
#include <libxml/xmlversion.h>
#include <libxml/parser.h>
#include <libxml/HTMLparser.h>
#include <libxml/chvalid.h>
Include dependency graph for parserInternals.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define XML_MAX_TEXT_LENGTH   10000000
 
#define XML_MAX_NAME_LENGTH   50000
 
#define XML_MAX_DICTIONARY_LIMIT   10000000
 
#define XML_MAX_LOOKUP_LIMIT   10000000
 
#define XML_MAX_NAMELEN   100
 
#define INPUT_CHUNK   250
 
#define IS_BYTE_CHAR(c)   xmlIsChar_ch(c)
 
#define IS_CHAR(c)   xmlIsCharQ(c)
 
#define IS_CHAR_CH(c)   xmlIsChar_ch(c)
 
#define IS_BLANK(c)   xmlIsBlankQ(c)
 
#define IS_BLANK_CH(c)   xmlIsBlank_ch(c)
 
#define IS_BASECHAR(c)   xmlIsBaseCharQ(c)
 
#define IS_DIGIT(c)   xmlIsDigitQ(c)
 
#define IS_DIGIT_CH(c)   xmlIsDigit_ch(c)
 
#define IS_COMBINING(c)   xmlIsCombiningQ(c)
 
#define IS_COMBINING_CH(c)   0
 
#define IS_EXTENDER(c)   xmlIsExtenderQ(c)
 
#define IS_EXTENDER_CH(c)   xmlIsExtender_ch(c)
 
#define IS_IDEOGRAPHIC(c)   xmlIsIdeographicQ(c)
 
#define IS_LETTER(c)   (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))
 
#define IS_LETTER_CH(c)   xmlIsBaseChar_ch(c)
 
#define IS_ASCII_LETTER(c)
 
#define IS_ASCII_DIGIT(c)   ((0x30 <= (c)) && ((c) <= 0x39))
 
#define IS_PUBIDCHAR(c)   xmlIsPubidCharQ(c)
 
#define IS_PUBIDCHAR_CH(c)   xmlIsPubidChar_ch(c)
 
#define SKIP_EOL(p)
 
#define MOVETO_ENDTAG(p)   while ((*p) && (*(p) != '>')) (p)++
 
#define MOVETO_STARTTAG(p)   while ((*p) && (*(p) != '<')) (p)++
 
#define XML_SUBSTITUTE_NONE   0
 
#define XML_SUBSTITUTE_REF   1
 
#define XML_SUBSTITUTE_PEREF   2
 
#define XML_SUBSTITUTE_BOTH   3
 

Functions

XMLPUBFUN int XMLCALL xmlIsLetter (int c)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateFileParserCtxt (const char *filename)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateURLParserCtxt (const char *filename, int options)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateMemoryParserCtxt (const char *buffer, int size)
 
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateEntityParserCtxt (const xmlChar *URL, const xmlChar *ID, const xmlChar *base)
 
XMLPUBFUN int XMLCALL xmlSwitchEncoding (xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
 
XMLPUBFUN int XMLCALL xmlSwitchToEncoding (xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
 
XML_DEPRECATED XMLPUBFUN int XMLCALL xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt, xmlParserInputPtr input, xmlCharEncodingHandlerPtr handler)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewStringInputStream (xmlParserCtxtPtr ctxt, const xmlChar *buffer)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewEntityInputStream (xmlParserCtxtPtr ctxt, xmlEntityPtr entity)
 
XMLPUBFUN int XMLCALL xmlPushInput (xmlParserCtxtPtr ctxt, xmlParserInputPtr input)
 
XMLPUBFUN xmlChar XMLCALL xmlPopInput (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlFreeInputStream (xmlParserInputPtr input)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputFromFile (xmlParserCtxtPtr ctxt, const char *filename)
 
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlSplitQName (xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix)
 
XMLPUBFUN const xmlChar *XMLCALL xmlParseName (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseNmtoken (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseEntityValue (xmlParserCtxtPtr ctxt, xmlChar **orig)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseAttValue (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseSystemLiteral (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParsePubidLiteral (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseCharData (xmlParserCtxtPtr ctxt, int cdata)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseExternalID (xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict)
 
XMLPUBFUN void XMLCALL xmlParseComment (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN const xmlChar *XMLCALL xmlParsePITarget (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParsePI (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseNotationDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseEntityDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlParseDefaultDecl (xmlParserCtxtPtr ctxt, xmlChar **value)
 
XMLPUBFUN xmlEnumerationPtr XMLCALL xmlParseNotationType (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlEnumerationPtr XMLCALL xmlParseEnumerationType (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlParseEnumeratedType (xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
 
XMLPUBFUN int XMLCALL xmlParseAttributeType (xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
 
XMLPUBFUN void XMLCALL xmlParseAttributeListDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementMixedContentDecl (xmlParserCtxtPtr ctxt, int inputchk)
 
XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk)
 
XMLPUBFUN int XMLCALL xmlParseElementContentDecl (xmlParserCtxtPtr ctxt, const xmlChar *name, xmlElementContentPtr *result)
 
XMLPUBFUN int XMLCALL xmlParseElementDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseMarkupDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlParseCharRef (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlEntityPtr XMLCALL xmlParseEntityRef (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseReference (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParsePEReference (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseCDSect (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseContent (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseElement (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseVersionNum (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseVersionInfo (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN xmlChar *XMLCALL xmlParseEncName (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN const xmlChar *XMLCALL xmlParseEncodingDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlParseSDDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseXMLDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseTextDecl (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseMisc (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParseExternalSubset (xmlParserCtxtPtr ctxt, const xmlChar *ExternalID, const xmlChar *SystemID)
 
XMLPUBFUN xmlChar *XMLCALL xmlStringDecodeEntities (xmlParserCtxtPtr ctxt, const xmlChar *str, int what, xmlChar end, xmlChar end2, xmlChar end3)
 
XMLPUBFUN xmlChar *XMLCALL xmlStringLenDecodeEntities (xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int what, xmlChar end, xmlChar end2, xmlChar end3)
 
XMLPUBFUN int XMLCALL nodePush (xmlParserCtxtPtr ctxt, xmlNodePtr value)
 
XMLPUBFUN xmlNodePtr XMLCALL nodePop (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL inputPush (xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
 
XMLPUBFUN xmlParserInputPtr XMLCALL inputPop (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN const xmlChar *XMLCALL namePop (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL namePush (xmlParserCtxtPtr ctxt, const xmlChar *value)
 
XMLPUBFUN int XMLCALL xmlSkipBlankChars (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlStringCurrentChar (xmlParserCtxtPtr ctxt, const xmlChar *cur, int *len)
 
XMLPUBFUN void XMLCALL xmlParserHandlePEReference (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN int XMLCALL xmlCheckLanguageID (const xmlChar *lang)
 
XMLPUBFUN int XMLCALL xmlCurrentChar (xmlParserCtxtPtr ctxt, int *len)
 
XMLPUBFUN int XMLCALL xmlCopyCharMultiByte (xmlChar *out, int val)
 
XMLPUBFUN int XMLCALL xmlCopyChar (int len, xmlChar *out, int val)
 
XMLPUBFUN void XMLCALL xmlNextChar (xmlParserCtxtPtr ctxt)
 
XMLPUBFUN void XMLCALL xmlParserInputShrink (xmlParserInputPtr in)
 

Variables

XMLPUBVAR unsigned int xmlParserMaxDepth
 
XMLPUBVAR const xmlChar xmlStringText []
 
XMLPUBVAR const xmlChar xmlStringTextNoenc []
 
XMLPUBVAR const xmlChar xmlStringComment []
 

Macro Definition Documentation

◆ INPUT_CHUNK

#define INPUT_CHUNK   250

INPUT_CHUNK:

The parser tries to always have that amount of input ready. One of the point is providing context when reporting errors.

Definition at line 89 of file parserInternals.h.

◆ IS_ASCII_DIGIT

#define IS_ASCII_DIGIT (   c)    ((0x30 <= (c)) && ((c) <= 0x39))

IS_ASCII_DIGIT: : an xmlChar value

Macro to check [0-9]

Definition at line 260 of file parserInternals.h.

◆ IS_ASCII_LETTER

#define IS_ASCII_LETTER (   c)
Value:
(((0x41 <= (c)) && ((c) <= 0x5a)) || \
((0x61 <= (c)) && ((c) <= 0x7a)))
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80

IS_ASCII_LETTER: : an xmlChar value

Macro to check [a-zA-Z]

Definition at line 250 of file parserInternals.h.

◆ IS_BASECHAR

#define IS_BASECHAR (   c)    xmlIsBaseCharQ(c)

IS_BASECHAR: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[85] BaseChar ::= ... long list see REC ...

Definition at line 153 of file parserInternals.h.

◆ IS_BLANK

#define IS_BLANK (   c)    xmlIsBlankQ(c)

IS_BLANK: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[3] S ::= (#x20 | #x9 | #xD | #xA)+

Definition at line 135 of file parserInternals.h.

◆ IS_BLANK_CH

#define IS_BLANK_CH (   c)    xmlIsBlank_ch(c)

IS_BLANK_CH: : an xmlChar value (normally unsigned char)

Behaviour same as IS_BLANK

Definition at line 143 of file parserInternals.h.

◆ IS_BYTE_CHAR

#define IS_BYTE_CHAR (   c)    xmlIsChar_ch(c)

IS_BYTE_CHAR: : an byte value (int)

Macro to check the following production in the XML spec:

[2] Char ::= #x9 | #xA | #xD | [#x20...] any byte character in the accepted range

Definition at line 105 of file parserInternals.h.

◆ IS_CHAR

#define IS_CHAR (   c)    xmlIsCharQ(c)

IS_CHAR: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.

Definition at line 117 of file parserInternals.h.

◆ IS_CHAR_CH

#define IS_CHAR_CH (   c)    xmlIsChar_ch(c)

IS_CHAR_CH: : an xmlChar (usually an unsigned char)

Behaves like IS_CHAR on single-byte value

Definition at line 125 of file parserInternals.h.

◆ IS_COMBINING

#define IS_COMBINING (   c)    xmlIsCombiningQ(c)

IS_COMBINING: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[87] CombiningChar ::= ... long list see REC ...

Definition at line 181 of file parserInternals.h.

◆ IS_COMBINING_CH

#define IS_COMBINING_CH (   c)    0

IS_COMBINING_CH: : an xmlChar (usually an unsigned char)

Always false (all combining chars > 0xff)

Definition at line 189 of file parserInternals.h.

◆ IS_DIGIT

#define IS_DIGIT (   c)    xmlIsDigitQ(c)

IS_DIGIT: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[88] Digit ::= ... long list see REC ...

Definition at line 163 of file parserInternals.h.

◆ IS_DIGIT_CH

#define IS_DIGIT_CH (   c)    xmlIsDigit_ch(c)

IS_DIGIT_CH: : an xmlChar value (usually an unsigned char)

Behaves like IS_DIGIT but with a single byte argument

Definition at line 171 of file parserInternals.h.

◆ IS_EXTENDER

#define IS_EXTENDER (   c)    xmlIsExtenderQ(c)

IS_EXTENDER: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 | #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] | [#x309D-#x309E] | [#x30FC-#x30FE]

Definition at line 202 of file parserInternals.h.

◆ IS_EXTENDER_CH

#define IS_EXTENDER_CH (   c)    xmlIsExtender_ch(c)

IS_EXTENDER_CH: : an xmlChar value (usually an unsigned char)

Behaves like IS_EXTENDER but with a single-byte argument

Definition at line 210 of file parserInternals.h.

◆ IS_IDEOGRAPHIC

#define IS_IDEOGRAPHIC (   c)    xmlIsIdeographicQ(c)

IS_IDEOGRAPHIC: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029]

Definition at line 221 of file parserInternals.h.

◆ IS_LETTER

#define IS_LETTER (   c)    (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))

IS_LETTER: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[84] Letter ::= BaseChar | Ideographic

Definition at line 232 of file parserInternals.h.

◆ IS_LETTER_CH

#define IS_LETTER_CH (   c)    xmlIsBaseChar_ch(c)

IS_LETTER_CH: : an xmlChar value (normally unsigned char)

Macro behaves like IS_LETTER, but only check base chars

Definition at line 241 of file parserInternals.h.

◆ IS_PUBIDCHAR

#define IS_PUBIDCHAR (   c)    xmlIsPubidCharQ(c)

IS_PUBIDCHAR: : an UNICODE value (int)

Macro to check the following production in the XML spec:

[13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#$_%]

Definition at line 271 of file parserInternals.h.

◆ IS_PUBIDCHAR_CH

#define IS_PUBIDCHAR_CH (   c)    xmlIsPubidChar_ch(c)

IS_PUBIDCHAR_CH: : an xmlChar value (normally unsigned char)

Same as IS_PUBIDCHAR but for single-byte value

Definition at line 279 of file parserInternals.h.

◆ MOVETO_ENDTAG

#define MOVETO_ENDTAG (   p)    while ((*p) && (*(p) != '>')) (p)++

MOVETO_ENDTAG: : and UTF8 string pointer

Skips to the next '>' char.

Definition at line 297 of file parserInternals.h.

◆ MOVETO_STARTTAG

#define MOVETO_STARTTAG (   p)    while ((*p) && (*(p) != '<')) (p)++

MOVETO_STARTTAG: : and UTF8 string pointer

Skips to the next '<' char.

Definition at line 306 of file parserInternals.h.

◆ SKIP_EOL

#define SKIP_EOL (   p)
Value:
if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; } \
if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; }
GLfloat GLfloat p
Definition: glext.h:8902

SKIP_EOL: : and UTF8 string pointer

Skips the end of line chars.

Definition at line 287 of file parserInternals.h.

◆ XML_MAX_DICTIONARY_LIMIT

#define XML_MAX_DICTIONARY_LIMIT   10000000

XML_MAX_DICTIONARY_LIMIT:

Maximum size allowed by the parser for a dictionary by default This is not a limitation of the parser but a safety boundary feature, use XML_PARSE_HUGE option to override it. Introduced in 2.9.0

Definition at line 63 of file parserInternals.h.

◆ XML_MAX_LOOKUP_LIMIT

#define XML_MAX_LOOKUP_LIMIT   10000000

XML_MAX_LOOKUP_LIMIT:

Maximum size allowed by the parser for ahead lookup This is an upper boundary enforced by the parser to avoid bad behaviour on "unfriendly' content Introduced in 2.9.0

Definition at line 73 of file parserInternals.h.

◆ XML_MAX_NAME_LENGTH

#define XML_MAX_NAME_LENGTH   50000

XML_MAX_NAME_LENGTH:

Maximum size allowed for a markup identifier. This is not a limitation of the parser but a safety boundary feature, use XML_PARSE_HUGE option to override it. Note that with the use of parsing dictionaries overriding the limit may result in more runtime memory usage in face of "unfriendly' content Introduced in 2.9.0

Definition at line 53 of file parserInternals.h.

◆ XML_MAX_NAMELEN

#define XML_MAX_NAMELEN   100

XML_MAX_NAMELEN:

Identifiers can be longer, but this will be more costly at runtime.

Definition at line 81 of file parserInternals.h.

◆ XML_MAX_TEXT_LENGTH

#define XML_MAX_TEXT_LENGTH   10000000

XML_MAX_TEXT_LENGTH:

Maximum size allowed for a single text node when building a tree. This is not a limitation of the parser but a safety boundary feature, use XML_PARSE_HUGE option to override it. Introduced in 2.9.0

Definition at line 41 of file parserInternals.h.

◆ XML_SUBSTITUTE_BOTH

#define XML_SUBSTITUTE_BOTH   3

XML_SUBSTITUTE_BOTH:

Both general and parameter entities need to be substituted.

Definition at line 520 of file parserInternals.h.

◆ XML_SUBSTITUTE_NONE

#define XML_SUBSTITUTE_NONE   0

XML_SUBSTITUTE_NONE:

If no entities need to be substituted.

Definition at line 502 of file parserInternals.h.

◆ XML_SUBSTITUTE_PEREF

#define XML_SUBSTITUTE_PEREF   2

XML_SUBSTITUTE_PEREF:

Whether parameter entities need to be substituted.

Definition at line 514 of file parserInternals.h.

◆ XML_SUBSTITUTE_REF

#define XML_SUBSTITUTE_REF   1

XML_SUBSTITUTE_REF:

Whether general entities need to be substituted.

Definition at line 508 of file parserInternals.h.

Function Documentation

◆ inputPop()

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

XMLPUBFUN int XMLCALL 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().

◆ namePop()

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

XMLPUBFUN int XMLCALL 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()

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

XMLPUBFUN int XMLCALL 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().

◆ xmlCheckLanguageID()

XMLPUBFUN int XMLCALL 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().

◆ xmlCopyChar()

XMLPUBFUN int XMLCALL xmlCopyChar ( int len  ATTRIBUTE_UNUSED,
xmlChar out,
int  val 
)

xmlCopyChar: @len: Ignored, compatibility @out: pointer to an array of xmlChar @val: the char value

append the char value in the array

Returns the number of xmlChar written

Definition at line 852 of file parserInternals.c.

852  {
853  if (out == NULL) return(0);
854  /* the len parameter is ignored */
855  if (val >= 0x80) {
856  return(xmlCopyCharMultiByte (out, val));
857  }
858  *out = (xmlChar) val;
859  return 1;
860 }
int xmlCopyCharMultiByte(xmlChar *out, int val)
GLuint GLfloat * val
Definition: glext.h:7180
static FILE * out
Definition: regtests2xml.c:44
unsigned char xmlChar
Definition: xmlstring.h:28
#define NULL
Definition: types.h:112

Referenced by xmlParseAttValueComplex().

◆ xmlCopyCharMultiByte()

XMLPUBFUN int XMLCALL xmlCopyCharMultiByte ( xmlChar out,
int  val 
)

xmlCopyCharMultiByte: @out: pointer to an array of xmlChar @val: the char value

append the char value in the array

Returns the number of xmlChar written

Definition at line 809 of file parserInternals.c.

809  {
810  if (out == NULL) return(0);
811  /*
812  * We are supposed to handle UTF8, check it's valid
813  * From rfc2044: encoding of the Unicode values on UTF-8:
814  *
815  * UCS-4 range (hex.) UTF-8 octet sequence (binary)
816  * 0000 0000-0000 007F 0xxxxxxx
817  * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
818  * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
819  */
820  if (val >= 0x80) {
821  xmlChar *savedout = out;
822  int bits;
823  if (val < 0x800) { *out++= (val >> 6) | 0xC0; bits= 0; }
824  else if (val < 0x10000) { *out++= (val >> 12) | 0xE0; bits= 6;}
825  else if (val < 0x110000) { *out++= (val >> 18) | 0xF0; bits= 12; }
826  else {
827  xmlErrEncodingInt(NULL, XML_ERR_INVALID_CHAR,
828  "Internal error, xmlCopyCharMultiByte 0x%X out of bound\n",
829  val);
830  return(0);
831  }
832  for ( ; bits >= 0; bits-= 6)
833  *out++= ((val >> bits) & 0x3F) | 0x80 ;
834  return (out - savedout);
835  }
836  *out = (xmlChar) val;
837  return 1;
838 }
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
GLuint GLfloat * val
Definition: glext.h:7180
static FILE * out
Definition: regtests2xml.c:44
unsigned char xmlChar
Definition: xmlstring.h:28
#define NULL
Definition: types.h:112

Referenced by xmlCopyChar(), and xsltNumberFormatDecimal().

◆ xmlCreateEntityParserCtxt()

XMLPUBFUN xmlParserCtxtPtr XMLCALL 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

◆ xmlCreateFileParserCtxt()

XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlCreateFileParserCtxt ( const char filename)

Parser context.

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

◆ xmlCreateMemoryParserCtxt()

XMLPUBFUN xmlParserCtxtPtr XMLCALL 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()

XMLPUBFUN xmlParserCtxtPtr XMLCALL 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().

◆ xmlCurrentChar()

XMLPUBFUN int XMLCALL xmlCurrentChar ( xmlParserCtxtPtr  ctxt,
int len 
)

xmlCurrentChar: @ctxt: the XML parser context @len: pointer to the length of the char read

The current char value, if using UTF-8 this may actually span multiple bytes in the input buffer. Implement the end of line normalization: 2.11 End-of-Line Handling Wherever an external parsed entity or the literal entity value of an internal parsed entity contains either the literal two-character sequence "#xD#xA" or a standalone literal #xD, an XML processor must pass to the application the single character #xA. This behavior can conveniently be produced by normalizing all line breaks to #xA on input, before parsing.)

Returns the current char value and its length

Definition at line 542 of file parserInternals.c.

542  {
543  if ((ctxt == NULL) || (len == NULL) || (ctxt->input == NULL)) return(0);
544  if (ctxt->instate == XML_PARSER_EOF)
545  return(0);
546 
547  if ((*ctxt->input->cur >= 0x20) && (*ctxt->input->cur <= 0x7F)) {
548  *len = 1;
549  return((int) *ctxt->input->cur);
550  }
551  if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
552  /*
553  * We are supposed to handle UTF8, check it's valid
554  * From rfc2044: encoding of the Unicode values on UTF-8:
555  *
556  * UCS-4 range (hex.) UTF-8 octet sequence (binary)
557  * 0000 0000-0000 007F 0xxxxxxx
558  * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
559  * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
560  *
561  * Check for the 0x110000 limit too
562  */
563  const unsigned char *cur = ctxt->input->cur;
564  unsigned char c;
565  unsigned int val;
566 
567  c = *cur;
568  if (c & 0x80) {
569  if (((c & 0x40) == 0) || (c == 0xC0))
570  goto encoding_error;
571  if (cur[1] == 0) {
573  cur = ctxt->input->cur;
574  }
575  if ((cur[1] & 0xc0) != 0x80)
576  goto encoding_error;
577  if ((c & 0xe0) == 0xe0) {
578  if (cur[2] == 0) {
580  cur = ctxt->input->cur;
581  }
582  if ((cur[2] & 0xc0) != 0x80)
583  goto encoding_error;
584  if ((c & 0xf0) == 0xf0) {
585  if (cur[3] == 0) {
587  cur = ctxt->input->cur;
588  }
589  if (((c & 0xf8) != 0xf0) ||
590  ((cur[3] & 0xc0) != 0x80))
591  goto encoding_error;
592  /* 4-byte code */
593  *len = 4;
594  val = (cur[0] & 0x7) << 18;
595  val |= (cur[1] & 0x3f) << 12;
596  val |= (cur[2] & 0x3f) << 6;
597  val |= cur[3] & 0x3f;
598  if (val < 0x10000)
599  goto encoding_error;
600  } else {
601  /* 3-byte code */
602  *len = 3;
603  val = (cur[0] & 0xf) << 12;
604  val |= (cur[1] & 0x3f) << 6;
605  val |= cur[2] & 0x3f;
606  if (val < 0x800)
607  goto encoding_error;
608  }
609  } else {
610  /* 2-byte code */
611  *len = 2;
612  val = (cur[0] & 0x1f) << 6;
613  val |= cur[1] & 0x3f;
614  if (val < 0x80)
615  goto encoding_error;
616  }
617  if (!IS_CHAR(val)) {
618  xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
619  "Char 0x%X out of allowed range\n", val);
620  }
621  return(val);
622  } else {
623  /* 1-byte code */
624  *len = 1;
625  if (*ctxt->input->cur == 0)
627  if ((*ctxt->input->cur == 0) &&
628  (ctxt->input->end > ctxt->input->cur)) {
629  xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
630  "Char 0x0 out of allowed range\n", 0);
631  }
632  if (*ctxt->input->cur == 0xD) {
633  if (ctxt->input->cur[1] == 0xA) {
634  ctxt->input->cur++;
635  }
636  return(0xA);
637  }
638  return((int) *ctxt->input->cur);
639  }
640  }
641  /*
642  * Assume it's a fixed length encoding (1) with
643  * a compatible encoding for the ASCII set, since
644  * XML constructs only use < 128 chars
645  */
646  *len = 1;
647  if (*ctxt->input->cur == 0xD) {
648  if (ctxt->input->cur[1] == 0xA) {
649  ctxt->input->cur++;
650  }
651  return(0xA);
652  }
653  return((int) *ctxt->input->cur);
654 encoding_error:
655  /*
656  * An encoding problem may arise from a truncated input buffer
657  * splitting a character in the middle. In that case do not raise
658  * an error but return 0 to indicate an end of stream problem
659  */
660  if (ctxt->input->end - ctxt->input->cur < 4) {
661  *len = 0;
662  return(0);
663  }
664 
665  /*
666  * If we detect an UTF8 error that probably mean that the
667  * input encoding didn't get properly advertised in the
668  * declaration header. Report the error and switch the encoding
669  * to ISO-Latin-1 (if you don't like this policy, just declare the
670  * encoding !)
671  */
672  {
673  char buffer[150];
674 
675  snprintf(&buffer[0], 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
676  ctxt->input->cur[0], ctxt->input->cur[1],
677  ctxt->input->cur[2], ctxt->input->cur[3]);
679  "Input is not proper UTF-8, indicate encoding !\n%s",
680  BAD_CAST buffer, NULL);
681  }
683  *len = 1;
684  return((int) *ctxt->input->cur);
685 }
xmlParserInputState instate
Definition: parser.h:223
const xmlChar * cur
Definition: parser.h:59
#define snprintf
Definition: wintirpc.h:48
GLuint buffer
Definition: glext.h:5915
xmlParserInputPtr input
Definition: parser.h:199
#define IS_CHAR(c)
#define BAD_CAST
Definition: xmlstring.h:35
GLuint GLfloat * val
Definition: glext.h:7180
const GLubyte * c
Definition: glext.h:8905
void __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr, const char *msg, const xmlChar *str1, const xmlChar *str2)
GLenum GLsizei len
Definition: glext.h:6722
#define INPUT_CHUNK
FxCollectionEntry * cur
#define NULL
Definition: types.h:112
int xmlParserInputGrow(xmlParserInputPtr in, int len)
#define c
Definition: ke_i.h:80
const xmlChar * end
Definition: parser.h:60

◆ xmlFreeInputStream()

XMLPUBFUN void XMLCALL xmlFreeInputStream ( xmlParserInputPtr  input)

xmlFreeInputStream: @input: an xmlParserInputPtr

Free up an input stream.

Definition at line 1192 of file parserInternals.c.

1192  {
1193  if (input == NULL) return;
1194 
1195  if (input->filename != NULL) xmlFree((char *) input->filename);
1196  if (input->directory != NULL) xmlFree((char *) input->directory);
1197  if (input->encoding != NULL) xmlFree((char *) input->encoding);
1198  if (input->version != NULL) xmlFree((char *) input->version);
1199  if ((input->free != NULL) && (input->base != NULL))
1200  input->free((xmlChar *) input->base);
1201  if (input->buf != NULL)
1203  xmlFree(input);
1204 }
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLenum GLenum input
Definition: glext.h:9031
#define NULL
Definition: types.h:112

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

◆ xmlIsLetter()

XMLPUBFUN int XMLCALL xmlIsLetter ( int  c)

xmlIsLetter: : an unicode character (int)

Check whether the character is allowed by the production [84] Letter ::= BaseChar | Ideographic

Returns 0 if not, non-zero otherwise

Definition at line 213 of file parserInternals.c.

213  {
214  return(IS_BASECHAR(c) || IS_IDEOGRAPHIC(c));
215 }
#define IS_IDEOGRAPHIC(c)
#define IS_BASECHAR(c)
const GLubyte * c
Definition: glext.h:8905

◆ xmlNewEntityInputStream()

XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewEntityInputStream ( xmlParserCtxtPtr  ctxt,
xmlEntityPtr  entity 
)

xmlNewEntityInputStream: @ctxt: an XML parser context @entity: an Entity pointer

Create a new input stream based on an xmlEntityPtr

Returns the new input stream or NULL

Definition at line 1283 of file parserInternals.c.

1283  {
1285 
1286  if (entity == NULL) {
1287  xmlErrInternal(ctxt, "xmlNewEntityInputStream entity = NULL\n",
1288  NULL);
1289  return(NULL);
1290  }
1293  "new input from entity: %s\n", entity->name);
1294  if (entity->content == NULL) {
1295  switch (entity->etype) {
1297  xmlErrInternal(ctxt, "Cannot parse entity %s\n",
1298  entity->name);
1299  break;
1302  return(xmlLoadExternalEntity((char *) entity->URI,
1303  (char *) entity->ExternalID, ctxt));
1305  xmlErrInternal(ctxt,
1306  "Internal entity %s without content !\n",
1307  entity->name);
1308  break;
1310  xmlErrInternal(ctxt,
1311  "Internal parameter entity %s without content !\n",
1312  entity->name);
1313  break;
1315  xmlErrInternal(ctxt,
1316  "Predefined entity %s without content !\n",
1317  entity->name);
1318  break;
1319  }
1320  return(NULL);
1321  }
1322  input = xmlNewInputStream(ctxt);
1323  if (input == NULL) {
1324  return(NULL);
1325  }
1326  if (entity->URI != NULL)
1327  input->filename = (char *) xmlStrdup((xmlChar *) entity->URI);
1328  input->base = entity->content;
1329  if (entity->length == 0)
1330  entity->length = xmlStrlen(entity->content);
1331  input->cur = entity->content;
1332  input->length = entity->length;
1333  input->end = &entity->content[input->length];
1334  return(input);
1335 }
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:426
Definition: actctx.c:387
WCHAR * name
Definition: actctx.c:405
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:337
xmlParserInputPtr xmlNewInputStream(xmlParserCtxtPtr ctxt)
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBVAR int xmlParserDebugEntities
Definition: globals.h:423
#define NULL
Definition: types.h:112
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:67
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:353

Referenced by xmlLoadEntityContent(), and xmlParsePEReference().

◆ xmlNewInputFromFile()

XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputFromFile ( xmlParserCtxtPtr  ctxt,
const char filename 
)

xmlNewInputFromFile: @ctxt: an XML parser context @filename: the filename to use as entity

Create a new input stream based on a file or an URL.

Returns the new input stream or NULL in case of error

Definition at line 1379 of file parserInternals.c.

1379  {
1381  xmlParserInputPtr inputStream;
1382  char *directory = NULL;
1383  xmlChar *URI = NULL;
1384 
1387  "new input from file: %s\n", filename);
1388  if (ctxt == NULL) return(NULL);
1390  if (buf == NULL) {
1391  if (filename == NULL)
1392  __xmlLoaderErr(ctxt,
1393  "failed to load external entity: NULL filename \n",
1394  NULL);
1395  else
1396  __xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n",
1397  (const char *) filename);
1398  return(NULL);
1399  }
1400 
1401  inputStream = xmlNewInputStream(ctxt);
1402  if (inputStream == NULL) {
1404  return(NULL);
1405  }
1406 
1407  inputStream->buf = buf;
1408  inputStream = xmlCheckHTTPInput(ctxt, inputStream);
1409  if (inputStream == NULL)
1410  return(NULL);
1411 
1412  if (inputStream->filename == NULL)
1413  URI = xmlStrdup((xmlChar *) filename);
1414  else
1415  URI = xmlStrdup((xmlChar *) inputStream->filename);
1416  directory = xmlParserGetDirectory((const char *) URI);
1417  if (inputStream->filename != NULL) xmlFree((char *)inputStream->filename);
1418  inputStream->filename = (char *) xmlCanonicPath((const xmlChar *) URI);
1419  if (URI != NULL) xmlFree((char *) URI);
1420  inputStream->directory = directory;
1421 
1422  xmlBufResetInput(inputStream->buf->buffer, inputStream);
1423  if ((ctxt->directory == NULL) && (directory != NULL))
1424  ctxt->directory = (char *) xmlStrdup((const xmlChar *) directory);
1425  return(inputStream);
1426 }
void __xmlLoaderErr(void *ctx, const char *msg, const char *filename) LIBXML_ATTR_FORMAT(2
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1094
const char * filename
Definition: ioapi.h:137
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
xmlBufPtr buffer
Definition: xmlIO.h:132
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc)
xmlParserInputPtr xmlNewInputStream(xmlParserCtxtPtr ctxt)
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN xmlParserInputPtr XMLCALL xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret)
xmlParserInputBufferPtr buf
Definition: parser.h:54
const char * filename
Definition: parser.h:56
XMLPUBVAR int xmlParserDebugEntities
Definition: globals.h:423
#define NULL
Definition: types.h:112
char * directory
Definition: parser.h:226
const char * directory
Definition: parser.h:57
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:67
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:353

◆ xmlNewInputStream()

XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream ( xmlParserCtxtPtr  ctxt)

xmlNewInputStream: @ctxt: an XML parser context

Create a new input stream structure.

Returns the new input stream or NULL

Definition at line 1215 of file parserInternals.c.

1215  {
1217 
1219  if (input == NULL) {
1220  xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
1221  return(NULL);
1222  }
1223  memset(input, 0, sizeof(xmlParserInput));
1224  input->line = 1;
1225  input->col = 1;
1226  input->standalone = -1;
1227 
1228  /*
1229  * If the context is NULL the id cannot be initialized, but that
1230  * should not happen while parsing which is the situation where
1231  * the id is actually needed.
1232  */
1233  if (ctxt != NULL)
1234  input->id = ctxt->input_id++;
1235 
1236  return(input);
1237 }
xmlParserInput * xmlParserInputPtr
Definition: tree.h:36
int input_id
Definition: parser.h:312
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
GLenum GLenum GLenum input
Definition: glext.h:9031
#define NULL
Definition: types.h:112
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
#define memset(x, y, z)
Definition: compat.h:39

Referenced by xmlCreateMemoryParserCtxt(), xmlCtxtResetPush(), xmlNewEntityInputStream(), xmlNewInputFromFile(), xmlNewIOInputStream(), and xmlNewStringInputStream().

◆ xmlNewStringInputStream()

XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewStringInputStream ( xmlParserCtxtPtr  ctxt,
const xmlChar buffer 
)

Input Streams.

xmlNewStringInputStream: @ctxt: an XML parser context @buffer: an memory buffer

Create a new input stream based on a memory buffer. Returns the new input stream

Definition at line 1346 of file parserInternals.c.

1346  {
1348 
1349  if (buffer == NULL) {
1350  xmlErrInternal(ctxt, "xmlNewStringInputStream string = NULL\n",
1351  NULL);
1352  return(NULL);
1353  }
1356  "new fixed input: %.30s\n", buffer);
1357  input = xmlNewInputStream(ctxt);
1358  if (input == NULL) {
1359  xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
1360  return(NULL);
1361  }
1362  input->base = buffer;
1363  input->cur = buffer;
1364  input->length = xmlStrlen(buffer);
1365  input->end = &buffer[input->length];
1366  return(input);
1367 }
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:426
GLuint buffer
Definition: glext.h:5915
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:337
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
xmlParserInputPtr xmlNewInputStream(xmlParserCtxtPtr ctxt)
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBVAR int xmlParserDebugEntities
Definition: globals.h:423
#define NULL
Definition: types.h:112
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:353

◆ xmlNextChar()

XMLPUBFUN void XMLCALL xmlNextChar ( xmlParserCtxtPtr  ctxt)

xmlNextChar: @ctxt: the XML parser context

Skip to the next char input char.

Definition at line 380 of file parserInternals.c.

381 {
382  if ((ctxt == NULL) || (ctxt->instate == XML_PARSER_EOF) ||
383  (ctxt->input == NULL))
384  return;
385 
386  if (!(VALID_CTXT(ctxt))) {
387  xmlErrInternal(ctxt, "Parser input data memory error\n", NULL);
389  xmlStopParser(ctxt);
390  return;
391  }
392 
393  if ((*ctxt->input->cur == 0) &&
394  (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) {
395  return;
396  }
397 
398  if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
399  const unsigned char *cur;
400  unsigned char c;
401 
402  /*
403  * 2.11 End-of-Line Handling
404  * the literal two-character sequence "#xD#xA" or a standalone
405  * literal #xD, an XML processor must pass to the application
406  * the single character #xA.
407  */
408  if (*(ctxt->input->cur) == '\n') {
409  ctxt->input->line++; ctxt->input->col = 1;
410  } else
411  ctxt->input->col++;
412 
413  /*
414  * We are supposed to handle UTF8, check it's valid
415  * From rfc2044: encoding of the Unicode values on UTF-8:
416  *
417  * UCS-4 range (hex.) UTF-8 octet sequence (binary)
418  * 0000 0000-0000 007F 0xxxxxxx
419  * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
420  * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
421  *
422  * Check for the 0x110000 limit too
423  */
424  cur = ctxt->input->cur;
425 
426  c = *cur;
427  if (c & 0x80) {
428  if (c == 0xC0)
429  goto encoding_error;
430  if (cur[1] == 0) {
432  cur = ctxt->input->cur;
433  }
434  if ((cur[1] & 0xc0) != 0x80)
435  goto encoding_error;
436  if ((c & 0xe0) == 0xe0) {
437  unsigned int val;
438 
439  if (cur[2] == 0) {
441  cur = ctxt->input->cur;
442  }
443  if ((cur[2] & 0xc0) != 0x80)
444  goto encoding_error;
445  if ((c & 0xf0) == 0xf0) {
446  if (cur[3] == 0) {
448  cur = ctxt->input->cur;
449  }
450  if (((c & 0xf8) != 0xf0) ||
451  ((cur[3] & 0xc0) != 0x80))
452  goto encoding_error;
453  /* 4-byte code */
454  ctxt->input->cur += 4;
455  val = (cur[0] & 0x7) << 18;
456  val |= (cur[1] & 0x3f) << 12;
457  val |= (cur[2] & 0x3f) << 6;
458  val |= cur[3] & 0x3f;
459  } else {
460  /* 3-byte code */
461  ctxt->input->cur += 3;
462  val = (cur[0] & 0xf) << 12;
463  val |= (cur[1] & 0x3f) << 6;
464  val |= cur[2] & 0x3f;
465  }
466  if (((val > 0xd7ff) && (val < 0xe000)) ||
467  ((val > 0xfffd) && (val < 0x10000)) ||
468  (val >= 0x110000)) {
469  xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
470  "Char 0x%X out of allowed range\n",
471  val);
472  }
473  } else
474  /* 2-byte code */
475  ctxt->input->cur += 2;
476  } else
477  /* 1-byte code */
478  ctxt->input->cur++;
479  } else {
480  /*
481  * Assume it's a fixed length encoding (1) with
482  * a compatible encoding for the ASCII set, since
483  * XML constructs only use < 128 chars
484  */
485 
486  if (*(ctxt->input->cur) == '\n') {
487  ctxt->input->line++; ctxt->input->col = 1;
488  } else
489  ctxt->input->col++;
490  ctxt->input->cur++;
491  }
492  if (*ctxt->input->cur == 0)
494  return;
495 encoding_error:
496  /*
497  * If we detect an UTF8 error that probably mean that the
498  * input encoding didn't get properly advertised in the
499  * declaration header. Report the error and switch the encoding
500  * to ISO-Latin-1 (if you don't like this policy, just declare the
501  * encoding !)
502  */
503  if ((ctxt == NULL) || (ctxt->input == NULL) ||
504  (ctxt->input->end - ctxt->input->cur < 4)) {
506  "Input is not proper UTF-8, indicate encoding !\n",
507  NULL, NULL);
508  } else {
509  char buffer[150];
510 
511  snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
512  ctxt->input->cur[0], ctxt->input->cur[1],
513  ctxt->input->cur[2], ctxt->input->cur[3]);
515  "Input is not proper UTF-8, indicate encoding !\n%s",
516  BAD_CAST buffer, NULL);
517  }
519  ctxt->input->cur++;
520  return;
521 }
xmlParserInputState instate
Definition: parser.h:223
#define VALID_CTXT(ctxt)
const xmlChar * cur
Definition: parser.h:59
#define snprintf
Definition: wintirpc.h:48
GLuint buffer
Definition: glext.h:5915
XMLPUBFUN void XMLCALL xmlStopParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12583
xmlParserInputPtr input
Definition: parser.h:199
#define BAD_CAST
Definition: xmlstring.h:35
GLuint GLfloat * val
Definition: glext.h:7180
const GLubyte * c
Definition: glext.h:8905
void __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr, const char *msg, const xmlChar *str1, const xmlChar *str2)
#define INPUT_CHUNK
FxCollectionEntry * cur
#define NULL
Definition: types.h:112
int xmlParserInputGrow(xmlParserInputPtr in, int len)
#define c
Definition: ke_i.h:80
const xmlChar * end
Definition: parser.h:60

◆ xmlParseAttributeListDecl()

XMLPUBFUN void XMLCALL xmlParseAttributeListDecl ( xmlParserCtxtPtr  ctxt)

xmlParseAttributeListDecl: @ctxt: an XML parser context

: parse the Attribute list def for an element

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

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

Definition at line 5976 of file parser.c.

5976  {
5977  const xmlChar *elemName;
5978  const xmlChar *attrName;
5980 
5981  if (CMP9(CUR_PTR, '<', '!', 'A', 'T', 'T', 'L', 'I', 'S', 'T')) {
5982  int inputid = ctxt->input->id;
5983 
5984  SKIP(9);
5985  if (SKIP_BLANKS == 0) {
5986  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5987  "Space required after '<!ATTLIST'\n");
5988  }
5989  elemName = xmlParseName(ctxt);
5990  if (elemName == NULL) {
5991  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5992  "ATTLIST: no name for Element\n");
5993  return;
5994  }
5995  SKIP_BLANKS;
5996  GROW;
5997  while ((RAW != '>') && (ctxt->instate != XML_PARSER_EOF)) {
5998  int type;
5999  int def;
6000  xmlChar *defaultValue = NULL;
6001 
6002  GROW;
6003  tree = NULL;
6004  attrName = xmlParseName(ctxt);
6005  if (attrName == NULL) {
6006  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6007  "ATTLIST: no name for Attribute\n");
6008  break;
6009  }
6010  GROW;
6011  if (SKIP_BLANKS == 0) {
6012  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6013  "Space required after the attribute name\n");
6014  break;
6015  }
6016 
6017  type = xmlParseAttributeType(ctxt, &tree);
6018  if (type <= 0) {
6019  break;
6020  }
6021 
6022  GROW;
6023  if (SKIP_BLANKS == 0) {
6024  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6025  "Space required after the attribute type\n");
6026  if (tree != NULL)
6028  break;
6029  }
6030 
6031  def = xmlParseDefaultDecl(ctxt, &defaultValue);
6032  if (def <= 0) {
6033  if (defaultValue != NULL)
6034  xmlFree(defaultValue);
6035  if (tree != NULL)
6037  break;
6038  }
6039  if ((type != XML_ATTRIBUTE_CDATA) && (defaultValue != NULL))
6040  xmlAttrNormalizeSpace(defaultValue, defaultValue);
6041 
6042  GROW;
6043  if (RAW != '>') {
6044  if (SKIP_BLANKS == 0) {
6045  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6046  "Space required after the attribute default value\n");
6047  if (defaultValue != NULL)
6048  xmlFree(defaultValue);
6049  if (tree != NULL)
6051  break;
6052  }
6053  }
6054  if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
6055  (ctxt->sax->attributeDecl != NULL))
6056  ctxt->sax->attributeDecl(ctxt->userData, elemName, attrName,
6057  type, def, defaultValue, tree);
6058  else if (tree != NULL)
6060 
6061  if ((ctxt->sax2) && (defaultValue != NULL) &&
6062  (def != XML_ATTRIBUTE_IMPLIED) &&
6063  (def != XML_ATTRIBUTE_REQUIRED)) {
6064  xmlAddDefAttrs(ctxt, elemName, attrName, defaultValue);
6065  }
6066  if (ctxt->sax2) {
6067  xmlAddSpecialAttr(ctxt, elemName, attrName, type);
6068  }
6069  if (defaultValue != NULL)
6070  xmlFree(defaultValue);
6071  GROW;
6072  }
6073  if (RAW == '>') {
6074  if (inputid != ctxt->input->id) {
6075  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6076  "Attribute list declaration doesn't start and"
6077  " stop in the same entity\n");
6078  }
6079  NEXT;
6080  }
6081  }
6082 }
static void xmlAddDefAttrs(xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, const xmlChar *value)
Definition: parser.c:1242
int xmlParseDefaultDecl(xmlParserCtxtPtr ctxt, xmlChar **value)
Definition: parser.c:5682
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2117
struct _tree tree
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2081
#define SKIP_BLANKS
Definition: parser.c:2145
int xmlParseAttributeType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
Definition: parser.c:5934
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3344
static xmlChar * xmlAttrNormalizeSpace(const xmlChar *src, xmlChar *dst)
Definition: parser.c:1152
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
#define NEXT
Definition: parser.c:2147
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
#define SKIP(val)
Definition: parser.c:2088
static void xmlAddSpecialAttr(xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, int type)
Definition: parser.c:1353
#define NULL
Definition: types.h:112
#define CUR_PTR
Definition: parser.c:2067
#define RAW
Definition: parser.c:2064
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
void * userData
Definition: parser.h:186
XMLPUBFUN void XMLCALL xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1817

Referenced by xmlParseMarkupDecl().

◆ xmlParseAttributeType()

XMLPUBFUN int XMLCALL xmlParseAttributeType ( xmlParserCtxtPtr  ctxt,
xmlEnumerationPtr tree 
)

xmlParseAttributeType: @ctxt: an XML parser context @tree: the enumeration tree built while parsing

parse the Attribute list def for an element

[54] AttType ::= StringType | TokenizedType | EnumeratedType

[55] StringType ::= 'CDATA'

[56] TokenizedType ::= 'ID' | 'IDREF' | 'IDREFS' | 'ENTITY' | 'ENTITIES' | 'NMTOKEN' | 'NMTOKENS'

Validity constraints for attribute values syntax are checked in xmlValidateAttributeValue()

[ VC: ID ] Values of type ID must match the Name production. A name must not appear more than once in an XML document as a value of this type; i.e., ID values must uniquely identify the elements which bear them.

[ VC: One ID per Element Type ] No element type may have more than one ID attribute specified.

[ VC: ID Attribute Default ] An ID attribute must have a declared default of #IMPLIED or #REQUIRED.

[ VC: IDREF ] Values of type IDREF must match the Name production, and values of type IDREFS must match Names; each IDREF Name must match the value of an ID attribute on some element in the XML document; i.e. IDREF values must match the value of some ID attribute.

[ VC: Entity Name ] Values of type ENTITY must match the Name production, values of type ENTITIES must match Names; each Entity Name must match the name of an unparsed entity declared in the DTD.

[ VC: Name Token ] Values of type NMTOKEN must match the Nmtoken production; values of type NMTOKENS must match Nmtokens.

Returns the attribute type

Definition at line 5934 of file parser.c.

5934  {
5935  SHRINK;
5936  if (CMP5(CUR_PTR, 'C', 'D', 'A', 'T', 'A')) {
5937  SKIP(5);
5938  return(XML_ATTRIBUTE_CDATA);
5939  } else if (CMP6(CUR_PTR, 'I', 'D', 'R', 'E', 'F', 'S')) {
5940  SKIP(6);
5941  return(XML_ATTRIBUTE_IDREFS);
5942  } else if (CMP5(CUR_PTR, 'I', 'D', 'R', 'E', 'F')) {
5943  SKIP(5);
5944  return(XML_ATTRIBUTE_IDREF);
5945  } else if ((RAW == 'I') && (NXT(1) == 'D')) {
5946  SKIP(2);
5947  return(XML_ATTRIBUTE_ID);
5948  } else if (CMP6(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'Y')) {
5949  SKIP(6);
5950  return(XML_ATTRIBUTE_ENTITY);
5951  } else if (CMP8(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S')) {
5952  SKIP(8);
5953  return(XML_ATTRIBUTE_ENTITIES);
5954  } else if (CMP8(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S')) {
5955  SKIP(8);
5956  return(XML_ATTRIBUTE_NMTOKENS);
5957  } else if (CMP7(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N')) {
5958  SKIP(7);
5959  return(XML_ATTRIBUTE_NMTOKEN);
5960  }
5961  return(xmlParseEnumeratedType(ctxt, tree));
5962 }
#define NXT(val)
Definition: parser.c:2066
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2073
#define CMP6(s, c1, c2, c3, c4, c5, c6)
Definition: parser.c:2075
int xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
Definition: parser.c:5871
#define SKIP(val)
Definition: parser.c:2088
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)
Definition: parser.c:2077
#define CUR_PTR
Definition: parser.c:2067
#define RAW
Definition: parser.c:2064
#define SHRINK
Definition: parser.c:2106
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2079

Referenced by xmlParseAttributeListDecl().

◆ xmlParseAttValue()

XMLPUBFUN xmlChar* XMLCALL xmlParseAttValue ( xmlParserCtxtPtr  ctxt)

xmlParseAttValue: @ctxt: an XML parser context

parse a value for an attribute Note: the parser won't do substitution of entities here, this will be handled later in xmlStringGetNodeList

[10] AttValue ::= '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'"

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.

Definition at line 4182 of file parser.c.

4182  {
4183  if ((ctxt == NULL) || (ctxt->input == NULL)) return(NULL);
4184  return(xmlParseAttValueInternal(ctxt, NULL, NULL, 0));
4185 }
xmlParserInputPtr input
Definition: parser.h:199
#define NULL
Definition: types.h:112
static xmlChar * xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, int normalize)
Definition: parser.c:8960

Referenced by xmlParseDefaultDecl().

◆ xmlParseCDSect()

XMLPUBFUN void XMLCALL xmlParseCDSect ( xmlParserCtxtPtr  ctxt)

xmlParseCDSect: @ctxt: an XML parser context

Parse escaped pure raw content.

[18] CDSect ::= CDStart CData CDEnd

[19] CDStart ::= ''

[20] Data ::= (Char* - (Char* '' Char*))

[21] CDEnd ::= ']]>'

Definition at line 9765 of file parser.c.

9765  {
9766  xmlChar *buf = NULL;
9767  int len = 0;
9769  int r, rl;
9770  int s, sl;
9771  int cur, l;
9772  int count = 0;
9773  int maxLength = (ctxt->options & XML_PARSE_HUGE) ?
9776 
9777  /* Check 2.6.0 was NXT(0) not RAW */
9778  if (CMP9(CUR_PTR, '<', '!', '[', 'C', 'D', 'A', 'T', 'A', '[')) {
9779  SKIP(9);
9780  } else
9781  return;
9782 
9784  r = CUR_CHAR(rl);
9785  if (!IS_CHAR(r)) {
9787  ctxt->instate = XML_PARSER_CONTENT;
9788  return;
9789  }
9790  NEXTL(rl);
9791  s = CUR_CHAR(sl);
9792  if (!IS_CHAR(s)) {
9794  ctxt->instate = XML_PARSER_CONTENT;
9795  return;
9796  }
9797  NEXTL(sl);
9798  cur = CUR_CHAR(l);
9799  buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
9800  if (buf == NULL) {
9801  xmlErrMemory(ctxt, NULL);
9802  return;
9803  }
9804  while (IS_CHAR(cur) &&
9805  ((r != ']') || (s != ']') || (cur != '>'))) {
9806  if (len + 5 >= size) {
9807  xmlChar *tmp;
9808 
9809  tmp = (xmlChar *) xmlRealloc(buf, size * 2 * sizeof(xmlChar));
9810  if (tmp == NULL) {
9811  xmlFree(buf);
9812  xmlErrMemory(ctxt, NULL);
9813  return;
9814  }
9815  buf = tmp;
9816  size *= 2;
9817  }
9818  COPY_BUF(rl,buf,len,r);
9819  r = s;
9820  rl = sl;
9821  s = cur;
9822  sl = l;
9823  count++;
9824  if (count > 50) {
9825  SHRINK;
9826  GROW;
9827  if (ctxt->instate == XML_PARSER_EOF) {
9828  xmlFree(buf);
9829  return;
9830  }
9831  count = 0;
9832  }
9833  NEXTL(l);
9834  cur = CUR_CHAR(l);
9835  if (len > maxLength) {
9836  xmlFatalErrMsg(ctxt, XML_ERR_CDATA_NOT_FINISHED,
9837  "CData section too big found\n");
9838  xmlFree(buf);
9839  return;
9840  }
9841  }
9842  buf[len] = 0;
9843  ctxt->instate = XML_PARSER_CONTENT;
9844  if (cur != '>') {
9845  xmlFatalErrMsgStr(ctxt, XML_ERR_CDATA_NOT_FINISHED,
9846  "CData section not finished\n%.50s\n", buf);
9847  xmlFree(buf);
9848  return;
9849  }
9850  NEXTL(l);
9851 
9852  /*
9853  * OK the buffer is to be consumed as cdata.
9854  */
9855  if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
9856  if (ctxt->sax->cdataBlock != NULL)
9857  ctxt->sax->cdataBlock(ctxt->userData, buf, len);
9858  else if (ctxt->sax->characters != NULL)
9859  ctxt->sax->characters(ctxt->userData, buf, len);
9860  }
9861  xmlFree(buf);
9862 }
#define COPY_BUF(l, b, i, v)
Definition: parser.c:2166
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:378
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
Definition: globals.h:249
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2117
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define XML_MAX_TEXT_LENGTH
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2081
int disableSAX
Definition: parser.h:237
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define XML_MAX_HUGE_LENGTH
Definition: parser.c:105
#define XML_PARSER_BUFFER_SIZE
Definition: parser.c:276
#define IS_CHAR(c)
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
r l[0]
Definition: byte_order.h:167
GLsizeiptr size
Definition: glext.h:5919
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
#define CUR_CHAR(l)
Definition: parser.c:2163
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
struct _xmlSAXHandler * sax
Definition: parser.h:185
#define NEXTL(l)
Definition: parser.c:2156
FxCollectionEntry * cur
#define SKIP(val)
Definition: parser.c:2088
#define NULL
Definition: types.h:112
GLsizei maxLength
Definition: glext.h:6877
#define CUR_PTR
Definition: parser.c:2067
#define SHRINK
Definition: parser.c:2106
void * userData
Definition: parser.h:186

Referenced by xmlParseContentInternal().

◆ xmlParseCharData()

XMLPUBFUN void XMLCALL xmlParseCharData ( xmlParserCtxtPtr  ctxt,
int  cdata 
)

xmlParseCharData: @ctxt: an XML parser context @cdata: int indicating whether we are within a CDATA section

parse a CharData section. if we are within a CDATA section ']]>' marks an end of section.

The right angle bracket (>) may be represented using the string "&gt;", and must, for compatibility, be escaped using "&gt;" or a character reference when it appears in the string "]]>" in content, when that string is not marking the end of a CDATA section.

[14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)

Definition at line 4425 of file parser.c.

4425  {
4426  const xmlChar *in;
4427  int nbchar = 0;
4428  int line = ctxt->input->line;
4429  int col = ctxt->input->col;
4430  int ccol;
4431 
4432  SHRINK;
4433  GROW;
4434  /*
4435  * Accelerated common case where input don't need to be
4436  * modified before passing it to the handler.
4437  */
4438  if (!cdata) {
4439  in = ctxt->input->cur;
4440  do {
4441 get_more_space:
4442  while (*in == 0x20) { in++; ctxt->input->col++; }
4443  if (*in == 0xA) {
4444  do {
4445  ctxt->input->line++; ctxt->input->col = 1;
4446  in++;
4447  } while (*in == 0xA);
4448  goto get_more_space;
4449  }
4450  if (*in == '<') {
4451  nbchar = in - ctxt->input->cur;
4452  if (nbchar > 0) {
4453  const xmlChar *tmp = ctxt->input->cur;
4454  ctxt->input->cur = in;
4455 
4456  if ((ctxt->sax != NULL) &&
4457  (ctxt->sax->ignorableWhitespace !=
4458  ctxt->sax->characters)) {
4459  if (areBlanks(ctxt, tmp, nbchar, 1)) {
4460  if (ctxt->sax->ignorableWhitespace != NULL)
4461  ctxt->sax->ignorableWhitespace(ctxt->userData,
4462  tmp, nbchar);
4463  } else {
4464  if (ctxt->sax->characters != NULL)
4465  ctxt->sax->characters(ctxt->userData,
4466  tmp, nbchar);
4467  if (*ctxt->space == -1)
4468  *ctxt->space = -2;
4469  }
4470  } else if ((ctxt->sax != NULL) &&
4471  (ctxt->sax->characters != NULL)) {
4472  ctxt->sax->characters(ctxt->userData,
4473  tmp, nbchar);
4474  }
4475  }
4476  return;
4477  }
4478 
4479 get_more:
4480  ccol = ctxt->input->col;
4481  while (test_char_data[*in]) {
4482  in++;
4483  ccol++;
4484  }
4485  ctxt->input->col = ccol;
4486  if (*in == 0xA) {
4487  do {
4488  ctxt->input->line++; ctxt->input->col = 1;
4489  in++;
4490  } while (*in == 0xA);
4491  goto get_more;
4492  }
4493  if (*in == ']') {
4494  if ((in[1] == ']') && (in[2] == '>')) {
4496  ctxt->input->cur = in + 1;
4497  return;
4498  }
4499  in++;
4500  ctxt->input->col++;
4501  goto get_more;
4502  }
4503  nbchar = in - ctxt->input->cur;
4504  if (nbchar > 0) {
4505  if ((ctxt->sax != NULL) &&
4506  (ctxt->sax->ignorableWhitespace !=
4507  ctxt->sax->characters) &&
4508  (IS_BLANK_CH(*ctxt->input->cur))) {
4509  const xmlChar *tmp = ctxt->input->cur;
4510  ctxt->input->cur = in;
4511 
4512  if (areBlanks(ctxt, tmp, nbchar, 0)) {
4513  if (ctxt->sax->ignorableWhitespace != NULL)
4514  ctxt->sax->ignorableWhitespace(ctxt->userData,
4515  tmp, nbchar);
4516  } else {
4517  if (ctxt->sax->characters != NULL)
4518  ctxt->sax->characters(ctxt->userData,
4519  tmp, nbchar);
4520  if (*ctxt->space == -1)
4521  *ctxt->space = -2;
4522  }
4523  line = ctxt->input->line;
4524  col = ctxt->input->col;
4525  } else if (ctxt->sax != NULL) {
4526  if (ctxt->sax->characters != NULL)
4527  ctxt->sax->characters(ctxt->userData,
4528  ctxt->input->cur, nbchar);
4529  line = ctxt->input->line;
4530  col = ctxt->input->col;
4531  }
4532  /* something really bad happened in the SAX callback */
4533  if (ctxt->instate != XML_PARSER_CONTENT)
4534  return;
4535  }
4536  ctxt->input->cur = in;
4537  if (*in == 0xD) {
4538  in++;
4539  if (*in == 0xA) {
4540  ctxt->input->cur = in;
4541  in++;
4542  ctxt->input->line++; ctxt->input->col = 1;
4543  continue; /* while */
4544  }
4545  in--;
4546  }
4547  if (*in == '<') {
4548  return;
4549  }
4550  if (*in == '&') {
4551  return;
4552  }
4553  SHRINK;
4554  GROW;
4555  if (ctxt->instate == XML_PARSER_EOF)
4556  return;
4557  in = ctxt->input->cur;
4558  } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09) || (*in == 0x0a));
4559  nbchar = 0;
4560  }
4561  ctxt->input->line = line;
4562  ctxt->input->col = col;
4563  xmlParseCharDataComplex(ctxt, cdata);
4564 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:378
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2117
const xmlChar * cur
Definition: parser.h:59
static void xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata)
Definition: parser.c:4576
xmlParserInputPtr input
Definition: parser.h:199
#define IS_BLANK_CH(c)
Definition: parser.c:48
static const unsigned char test_char_data[256]
Definition: parser.c:4373
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
IN PCTCH line
Definition: pager.h:36
GLuint in
Definition: glext.h:9616
#define NULL
Definition: types.h:112
static int areBlanks(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int blank_chars)
Definition: parser.c:2864
#define SHRINK
Definition: parser.c:2106
int * space
Definition: parser.h:244
void * userData
Definition: parser.h:186

Referenced by xmlParseContentInternal().

◆ xmlParseCharRef()

XMLPUBFUN int XMLCALL xmlParseCharRef ( xmlParserCtxtPtr  ctxt)

xmlParseCharRef: @ctxt: an XML parser context

parse Reference declarations

[66] CharRef ::= '&#' [0-9]+ ';' | '&x' [0-9a-fA-F]+ ';'

[ WFC: Legal Character ] Characters referred to using character references must match the production for Char.

Returns the value parsed (as an int), 0 in case of error

Definition at line 2332 of file parser.c.

2332  {
2333  int val = 0;
2334  int count = 0;
2335 
2336  /*
2337  * Using RAW/CUR/NEXT is okay since we are working on ASCII range here
2338  */
2339  if ((RAW == '&') && (NXT(1) == '#') &&
2340  (NXT(2) == 'x')) {
2341  SKIP(3);
2342  GROW;
2343  while (RAW != ';') { /* loop blocked by count */
2344  if (count++ > 20) {
2345  count = 0;
2346  GROW;
2347  if (ctxt->instate == XML_PARSER_EOF)
2348  return(0);
2349  }
2350  if ((RAW >= '0') && (RAW <= '9'))
2351  val = val * 16 + (CUR - '0');
2352  else if ((RAW >= 'a') && (RAW <= 'f') && (count < 20))
2353  val = val * 16 + (CUR - 'a') + 10;
2354  else if ((RAW >= 'A') && (RAW <= 'F') && (count < 20))
2355  val = val * 16 + (CUR - 'A') + 10;
2356  else {
2358  val = 0;
2359  break;
2360  }
2361  if (val > 0x110000)
2362  val = 0x110000;
2363 
2364  NEXT;
2365  count++;
2366  }
2367  if (RAW == ';') {
2368  /* on purpose to avoid reentrancy problems with NEXT and SKIP */
2369  ctxt->input->col++;
2370  ctxt->input->cur++;
2371  }
2372  } else if ((RAW == '&') && (NXT(1) == '#')) {
2373  SKIP(2);
2374  GROW;
2375  while (RAW != ';') { /* loop blocked by count */
2376  if (count++ > 20) {
2377  count = 0;
2378  GROW;
2379  if (ctxt->instate == XML_PARSER_EOF)
2380  return(0);
2381  }
2382  if ((RAW >= '0') && (RAW <= '9'))
2383  val = val * 10 + (CUR - '0');
2384  else {
2386  val = 0;
2387  break;
2388  }
2389  if (val > 0x110000)
2390  val = 0x110000;
2391 
2392  NEXT;
2393  count++;
2394  }
2395  if (RAW == ';') {
2396  /* on purpose to avoid reentrancy problems with NEXT and SKIP */
2397  ctxt->input->col++;
2398  ctxt->input->cur++;
2399  }
2400  } else {
2402  }
2403 
2404  /*
2405  * [ WFC: Legal Character ]
2406  * Characters referred to using character references must match the
2407  * production for Char.
2408  */
2409  if (val >= 0x110000) {
2410  xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
2411  "xmlParseCharRef: character reference out of bounds\n",
2412  val);
2413  } else if (IS_CHAR(val)) {
2414  return(val);
2415  } else {
2416  xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
2417  "xmlParseCharRef: invalid xmlChar value %d\n",
2418  val);
2419  }
2420  return(0);
2421 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:378
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2117
#define NXT(val)
Definition: parser.c:2066
GLuint GLuint GLsizei count
Definition: gl.h:1545
const xmlChar * cur
Definition: parser.h:59
xmlParserInputPtr input
Definition: parser.h:199
#define IS_CHAR(c)
GLuint GLfloat * val
Definition: glext.h:7180
#define NEXT
Definition: parser.c:2147
#define SKIP(val)
Definition: parser.c:2088
#define CUR
Definition: parser.c:2065
#define NULL
Definition: types.h:112
#define RAW
Definition: parser.c:2064

Referenced by xmlParseAttValueComplex(), and xmlParseReference().

◆ xmlParseComment()

XMLPUBFUN void XMLCALL xmlParseComment ( xmlParserCtxtPtr  ctxt)

xmlParseComment: @ctxt: an XML parser context

Skip an XML (SGML) comment The spec says that "For compatibility, the string "–" (double-hyphen) must not occur within comments. "

[15] Comment ::= ''

Definition at line 4888 of file parser.c.

4888  {
4889  xmlChar *buf = NULL;
4890  size_t size = XML_PARSER_BUFFER_SIZE;
4891  size_t len = 0;
4892  size_t maxLength = (ctxt->options & XML_PARSE_HUGE) ?
4896  const xmlChar *in;
4897  size_t nbchar = 0;
4898  int ccol;
4899  int inputid;
4900 
4901  /*
4902  * Check that there is a comment right here.
4903  */
4904  if ((RAW != '<') || (NXT(1) != '!') ||
4905  (NXT(2) != '-') || (NXT(3) != '-')) return;
4906  state = ctxt->instate;
4907  ctxt->instate = XML_PARSER_COMMENT;
4908  inputid = ctxt->input->id;
4909  SKIP(4);
4910  SHRINK;
4911  GROW;
4912 
4913  /*
4914  * Accelerated common case where input don't need to be
4915  * modified before passing it to the handler.
4916  */
4917  in = ctxt->input->cur;
4918  do {
4919  if (*in == 0xA) {
4920  do {
4921  ctxt->input->line++; ctxt->input->col = 1;
4922  in++;
4923  } while (*in == 0xA);
4924  }
4925 get_more:
4926  ccol = ctxt->input->col;
4927  while (((*in > '-') && (*in <= 0x7F)) ||
4928  ((*in >= 0x20) && (*in < '-')) ||
4929  (*in == 0x09)) {
4930  in++;
4931  ccol++;
4932  }
4933  ctxt->input->col = ccol;
4934  if (*in == 0xA) {
4935  do {
4936  ctxt->input->line++; ctxt->input->col = 1;
4937  in++;
4938  } while (*in == 0xA);
4939  goto get_more;
4940  }
4941  nbchar = in - ctxt->input->cur;
4942  /*
4943  * save current set of data
4944  */
4945  if (nbchar > 0) {
4946  if ((ctxt->sax != NULL) &&
4947  (ctxt->sax->comment != NULL)) {
4948  if (buf == NULL) {
4949  if ((*in == '-') && (in[1] == '-'))
4950  size = nbchar + 1;
4951  else
4952  size = XML_PARSER_BUFFER_SIZE + nbchar;
4953  buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
4954  if (buf == NULL) {
4955  xmlErrMemory(ctxt, NULL);
4956  ctxt->instate = state;
4957  return;
4958  }
4959  len = 0;
4960  } else if (len + nbchar + 1 >= size) {
4961  xmlChar *new_buf;
4962  size += len + nbchar + XML_PARSER_BUFFER_SIZE;
4963  new_buf = (xmlChar *) xmlRealloc(buf,
4964  size * sizeof(xmlChar));
4965  if (new_buf == NULL) {
4966  xmlFree (buf);
4967  xmlErrMemory(ctxt, NULL);
4968  ctxt->instate = state;
4969  return;
4970  }
4971  buf = new_buf;
4972  }
4973  memcpy(&buf[len], ctxt->input->cur, nbchar);
4974  len += nbchar;
4975  buf[len] = 0;
4976  }
4977  }
4978  if (len > maxLength) {
4979  xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
4980  "Comment too big found", NULL);
4981  xmlFree (buf);
4982  return;
4983  }
4984  ctxt->input->cur = in;
4985  if (*in == 0xA) {
4986  in++;
4987  ctxt->input->line++; ctxt->input->col = 1;
4988  }
4989  if (*in == 0xD) {
4990  in++;
4991  if (*in == 0xA) {
4992  ctxt->input->cur = in;
4993  in++;
4994  ctxt->input->line++; ctxt->input->col = 1;
4995  goto get_more;
4996  }
4997  in--;
4998  }
4999  SHRINK;
5000  GROW;
5001  if (ctxt->instate == XML_PARSER_EOF) {
5002  xmlFree(buf);
5003  return;
5004  }
5005  in = ctxt->input->cur;
5006  if (*in == '-') {
5007  if (in[1] == '-') {
5008  if (in[2] == '>') {
5009  if (ctxt->input->id != inputid) {
5010  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5011  "comment doesn't start and stop in the"
5012  " same entity\n");
5013  }
5014  SKIP(3);
5015  if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
5016  (!ctxt->disableSAX)) {
5017  if (buf != NULL)
5018  ctxt->sax->comment(ctxt->userData, buf);
5019  else
5020  ctxt->sax->comment(ctxt->userData, BAD_CAST "");
5021  }
5022  if (buf != NULL)
5023  xmlFree(buf);
5024  if (ctxt->instate != XML_PARSER_EOF)
5025  ctxt->instate = state;
5026  return;
5027  }
5028  if (buf != NULL) {
5029  xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
5030  "Double hyphen within comment: "
5031  "<!--%.50s\n",
5032  buf);
5033  } else
5034  xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
5035  "Double hyphen within comment\n", NULL);
5036  if (ctxt->instate == XML_PARSER_EOF) {
5037  xmlFree(buf);
5038  return;
5039  }
5040  in++;
5041  ctxt->input->col++;
5042  }
5043  in++;
5044  ctxt->input->col++;
5045  goto get_more;
5046  }
5047  } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09) || (*in == 0x0a));
5049  ctxt->instate = state;
5050  return;
5051 }
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
Definition: globals.h:249
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2117
#define NXT(val)
Definition: parser.c:2066
const xmlChar * cur
Definition: parser.h:59
#define XML_MAX_TEXT_LENGTH
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define XML_MAX_HUGE_LENGTH
Definition: parser.c:105
#define XML_PARSER_BUFFER_SIZE
Definition: parser.c:276
xmlParserInputState
Definition: parser.h:110
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
GLsizeiptr size
Definition: glext.h:5919
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
static int state
Definition: maze.c:121
unsigned char xmlChar
Definition: xmlstring.h:28
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
struct _xmlSAXHandler * sax
Definition: parser.h:185
#define SKIP(val)
Definition: parser.c:2088
GLuint in
Definition: glext.h:9616
static void xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, size_t len, size_t size)
Definition: parser.c:4750
#define NULL
Definition: types.h:112
GLsizei maxLength
Definition: glext.h:6877
#define RAW
Definition: parser.c:2064
#define SHRINK
Definition: parser.c:2106
void * userData
Definition: parser.h:186

Referenced by xmlParseContentInternal(), xmlParseMarkupDecl(), and xmlParseMisc().

◆ xmlParseContent()

XMLPUBFUN void XMLCALL xmlParseContent ( xmlParserCtxtPtr  ctxt)

xmlParseContent: @ctxt: an XML parser context

Parse a content sequence. Stops at EOF or '</'.

[43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*

Definition at line 9958 of file parser.c.

9958  {
9959  int nameNr = ctxt->nameNr;
9960 
9962 
9963  if ((ctxt->instate != XML_PARSER_EOF) && (ctxt->nameNr > nameNr)) {
9964  const xmlChar *name = ctxt->nameTab[ctxt->nameNr - 1];
9965  int line = ctxt->pushTab[ctxt->nameNr - 1].line;
9966  xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
9967  "Premature end of data in tag %s line %d\n",
9968  name, line, NULL);
9969  }
9970 }
xmlParserInputState instate
Definition: parser.h:223
Definition: parser.c:48
int line
Definition: parser.c:80
xmlStartTag * pushTab
Definition: parser.h:283
unsigned char xmlChar
Definition: xmlstring.h:28
#define NULL
Definition: types.h:112
Definition: name.c:38
const xmlChar ** nameTab
Definition: parser.h:232
static void xmlParseContentInternal(xmlParserCtxtPtr ctxt)
Definition: parser.c:9873

Referenced by xmlParseBalancedChunkMemoryInternal(), xmlParseExternalEntityPrivate(), xmlParseExtParsedEnt(), and xmlParseInNodeContext().

◆ xmlParseDefaultDecl()

XMLPUBFUN int XMLCALL xmlParseDefaultDecl ( xmlParserCtxtPtr  ctxt,
xmlChar **  value 
)

xmlParseDefaultDecl: @ctxt: an XML parser context @value: Receive a possible fixed default value for the attribute

Parse an attribute default declaration

[60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('FIXED' S)? AttValue)

[ VC: Required Attribute ] if the default declaration is the keyword #REQUIRED, then the attribute must be specified for all elements of the type in the attribute-list declaration.

[ VC: Attribute Default Legal ] The declared default value must meet the lexical constraints of the declared attribute type c.f. xmlValidateAttributeDecl()

[ VC: Fixed Attribute Default ] if an attribute has a default value declared with the FIXED keyword, instances of that attribute must match the default value.

[ WFC: No < in Attribute Values ] handled in xmlParseAttValue()

returns: XML_ATTRIBUTE_NONE, XML_ATTRIBUTE_REQUIRED, XML_ATTRIBUTE_IMPLIED or XML_ATTRIBUTE_FIXED.

Definition at line 5682 of file parser.c.

5682  {
5683  int val;
5684  xmlChar *ret;
5685 
5686  *value = NULL;
5687  if (CMP9(CUR_PTR, '#', 'R', 'E', 'Q', 'U', 'I', 'R', 'E', 'D')) {
5688  SKIP(9);
5689  return(XML_ATTRIBUTE_REQUIRED);
5690  }
5691  if (CMP8(CUR_PTR, '#', 'I', 'M', 'P', 'L', 'I', 'E', 'D')) {
5692  SKIP(8);
5693  return(XML_ATTRIBUTE_IMPLIED);
5694  }
5696  if (CMP6(CUR_PTR, '#', 'F', 'I', 'X', 'E', 'D')) {
5697  SKIP(6);
5699  if (SKIP_BLANKS == 0) {
5700  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5701  "Space required after '#FIXED'\n");
5702  }
5703  }
5704  ret = xmlParseAttValue(ctxt);
5705  ctxt->instate = XML_PARSER_DTD;
5706  if (ret == NULL) {
5707  xmlFatalErrMsg(ctxt, (xmlParserErrors)ctxt->errNo,
5708  "Attribute default value declaration error\n");
5709  } else
5710  *value = ret;
5711  return(val);
5712 }
Definition: pdh_main.c:93
xmlParserInputState instate
Definition: parser.h:223
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2081
#define SKIP_BLANKS
Definition: parser.c:2145
#define CMP6(s, c1, c2, c3, c4, c5, c6)
Definition: parser.c:2075
GLuint GLfloat * val
Definition: glext.h:7180
xmlParserErrors
Definition: xmlerror.h:99
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
#define SKIP(val)
Definition: parser.c:2088
#define NULL
Definition: types.h:112
#define CUR_PTR
Definition: parser.c:2067
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2079
xmlChar * xmlParseAttValue(xmlParserCtxtPtr ctxt)
Definition: parser.c:4182

Referenced by xmlParseAttributeListDecl().

◆ xmlParseDocTypeDecl()

XMLPUBFUN void XMLCALL xmlParseDocTypeDecl ( xmlParserCtxtPtr  ctxt)

xmlParseDocTypeDecl: @ctxt: an XML parser context

parse a DOCTYPE declaration

[28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S? ('[' (markupdecl | PEReference | S)* ']' S?)? '>'

[ VC: Root Element Type ] The Name in the document type declaration must match the element type of the root element.

Definition at line 8282 of file parser.c.

8282  {
8283  const xmlChar *name = NULL;
8284  xmlChar *ExternalID = NULL;
8285  xmlChar *URI = NULL;
8286 
8287  /*
8288  * We know that '<!DOCTYPE' has been detected.
8289  */
8290  SKIP(9);
8291 
8292  SKIP_BLANKS;
8293 
8294  /*
8295  * Parse the DOCTYPE name.
8296  */
8297  name = xmlParseName(ctxt);
8298  if (name == NULL) {
8299  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
8300  "xmlParseDocTypeDecl : no DOCTYPE name !\n");
8301  }
8302  ctxt->intSubName = name;
8303 
8304  SKIP_BLANKS;
8305 
8306  /*
8307  * Check for SystemID and ExternalID
8308  */
8309  URI = xmlParseExternalID(ctxt, &ExternalID, 1);
8310 
8311  if ((URI != NULL) || (ExternalID != NULL)) {
8312  ctxt->hasExternalSubset = 1;
8313  }
8314  ctxt->extSubURI = URI;
8315  ctxt->extSubSystem = ExternalID;
8316 
8317  SKIP_BLANKS;
8318 
8319  /*
8320  * Create and update the internal subset.
8321  */
8322  if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) &&
8323  (!ctxt->disableSAX))
8324  ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI);
8325  if (ctxt->instate == XML_PARSER_EOF)
8326  return;
8327 
8328  /*
8329  * Is there any internal subset declarations ?
8330  * they are handled separately in xmlParseInternalSubset()
8331  */
8332  if (RAW == '[')
8333  return;
8334 
8335  /*
8336  * We should be at the end of the DOCTYPE declaration.
8337  */
8338  if (RAW != '>') {
8340  }
8341  NEXT;
8342 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:378
xmlParserInputState instate
Definition: parser.h:223
xmlChar * extSubURI
Definition: parser.h:240
xmlChar * xmlParseExternalID(xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict)
Definition: parser.c:4683
#define SKIP_BLANKS
Definition: parser.c:2145
int disableSAX
Definition: parser.h:237
xmlChar * extSubSystem
Definition: parser.h:241
const xmlChar * intSubName
Definition: parser.h:239
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3344
#define NEXT
Definition: parser.c:2147
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
int hasExternalSubset
Definition: parser.h:215
#define SKIP(val)
Definition: parser.c:2088
#define NULL
Definition: types.h:112
Definition: name.c:38
#define RAW
Definition: parser.c:2064
void * userData
Definition: parser.h:186
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by xmlParseDocument().

◆ xmlParseElement()

XMLPUBFUN void XMLCALL xmlParseElement ( xmlParserCtxtPtr  ctxt)

xmlParseElement: @ctxt: an XML parser context

parse an XML element

[39] element ::= EmptyElemTag | STag content ETag

[ WFC: Element Type Match ] The Name in an element's end-tag must match the element type in the start-tag.

Definition at line 9987 of file parser.c.

9987  {
9988  if (xmlParseElementStart(ctxt) != 0)
9989  return;
9990 
9992  if (ctxt->instate == XML_PARSER_EOF)
9993  return;
9994 
9995  if (CUR == 0) {
9996  const xmlChar *name = ctxt->nameTab[ctxt->nameNr - 1];
9997  int line = ctxt->pushTab[ctxt->nameNr - 1].line;
9998  xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
9999  "Premature end of data in tag %s line %d\n",
10000  name, line, NULL);
10001  return;
10002  }
10003 
10004  xmlParseElementEnd(ctxt);
10005 }
xmlParserInputState instate
Definition: parser.h:223
Definition: parser.c:48
int line
Definition: parser.c:80
xmlStartTag * pushTab
Definition: parser.h:283
unsigned char xmlChar
Definition: xmlstring.h:28
#define CUR
Definition: parser.c:2065
#define NULL
Definition: types.h:112
Definition: name.c:38
const xmlChar ** nameTab
Definition: parser.h:232
static void xmlParseElementEnd(xmlParserCtxtPtr ctxt)
Definition: parser.c:10144
static int xmlParseElementStart(xmlParserCtxtPtr ctxt)
Definition: parser.c:10015
static void xmlParseContentInternal(xmlParserCtxtPtr ctxt)
Definition: parser.c:9873

Referenced by xmlParseDocument().

◆ xmlParseElementChildrenContentDecl()

XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementChildrenContentDecl ( xmlParserCtxtPtr  ctxt,
int  inputchk 
)

xmlParseElementChildrenContentDecl: @ctxt: an XML parser context @inputchk: the input used for the current entity, needed for boundary checks

parse the declaration for a Mixed Element content The leading '(' and spaces have been skipped in xmlParseElementContentDecl

[47] children ::= (choice | seq) ('?' | '*' | '+')?

[48] cp ::= (Name | choice | seq) ('?' | '*' | '+')?

[49] choice ::= '(' S? cp ( S? '|' S? cp )* S? ')'

[50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'

[ VC: Proper Group/PE Nesting ] applies to [49] and [50] TODO Parameter-entity replacement text must be properly nested with parenthesized groups. That is to say, if either of the opening or closing parentheses in a choice, seq, or Mixed construct is contained in the replacement text for a parameter entity, both must be contained in the same replacement text. For interoperability, if a parameter-entity reference appears in a choice, seq, or Mixed construct, its replacement text should not be empty, and neither the first nor last non-blank character of the replacement text should be a connector (| or ,).

Returns the tree of xmlElementContentPtr describing the element hierarchy.

Definition at line 6533 of file parser.c.

6533  {
6534  /* stub left for API/ABI compat */
6535  return(xmlParseElementChildrenContentDeclPriv(ctxt, inputchk, 1));
6536 }
static xmlElementContentPtr xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk, int depth)
Definition: parser.c:6230

◆ xmlParseElementContentDecl()

XMLPUBFUN int XMLCALL xmlParseElementContentDecl ( xmlParserCtxtPtr  ctxt,
const xmlChar name,
xmlElementContentPtr result 
)

Definition at line 6553 of file parser.c.

6554  {
6555 
6557  int inputid = ctxt->input->id;
6558  int res;
6559 
6560  *result = NULL;
6561 
6562  if (RAW != '(') {
6563  xmlFatalErrMsgStr(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED,
6564  "xmlParseElementContentDecl : %s '(' expected\n", name);
6565  return(-1);
6566  }
6567  NEXT;
6568  GROW;
6569  if (ctxt->instate == XML_PARSER_EOF)
6570  return(-1);
6571  SKIP_BLANKS;
6572  if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
6573  tree = xmlParseElementMixedContentDecl(ctxt, inputid);
6575  } else {
6576  tree = xmlParseElementChildrenContentDeclPriv(ctxt, inputid, 1);
6578  }
6579  SKIP_BLANKS;
6580  *result = tree;
6581  return(res);
6582 }
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2117
GLuint64EXT * result
Definition: glext.h:11304
struct _tree tree
#define SKIP_BLANKS
Definition: parser.c:2145
xmlParserInputPtr input
Definition: parser.h:199
xmlElementContentPtr xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk)
Definition: parser.c:6104
static xmlElementContentPtr xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk, int depth)
Definition: parser.c:6230
#define NEXT
Definition: parser.c:2147
#define NULL
Definition: types.h:112
Definition: name.c:38
GLuint res
Definition: glext.h:9613
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)
Definition: parser.c:2077
#define CUR_PTR
Definition: parser.c:2067
#define RAW
Definition: parser.c:2064

Referenced by xmlParseElementDecl().

◆ xmlParseElementDecl()

XMLPUBFUN int XMLCALL xmlParseElementDecl ( xmlParserCtxtPtr  ctxt)

xmlParseElementDecl: @ctxt: an XML parser context

parse an Element declaration.

[45] elementdecl ::= '<!ELEMENT' S Name S contentspec S? '>'

[ VC: Unique Element Type Declaration ] No element type may be declared more than once

Returns the type of the element, or -1 in case of error

Definition at line 6598 of file parser.c.

6598  {
6599  const xmlChar *name;
6600  int ret = -1;
6602 
6603  /* GROW; done in the caller */
6604  if (CMP9(CUR_PTR, '<', '!', 'E', 'L', 'E', 'M', 'E', 'N', 'T')) {
6605  int inputid = ctxt->input->id;
6606 
6607  SKIP(9);
6608  if (SKIP_BLANKS == 0) {
6609  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6610  "Space required after 'ELEMENT'\n");
6611  return(-1);
6612  }
6613  name = xmlParseName(ctxt);
6614  if (name == NULL) {
6615  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6616  "xmlParseElementDecl: no name for Element\n");
6617  return(-1);
6618  }
6619  if (SKIP_BLANKS == 0) {
6620  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6621  "Space required after the element name\n");
6622  }
6623  if (CMP5(CUR_PTR, 'E', 'M', 'P', 'T', 'Y')) {
6624  SKIP(5);
6625  /*
6626  * Element must always be empty.
6627  */
6629  } else if ((RAW == 'A') && (NXT(1) == 'N') &&
6630  (NXT(2) == 'Y')) {
6631  SKIP(3);
6632  /*
6633  * Element is a generic container.
6634  */
6636  } else if (RAW == '(') {
6638  } else {
6639  /*
6640  * [ WFC: PEs in Internal Subset ] error handling.
6641  */
6642  if ((RAW == '%') && (ctxt->external == 0) &&
6643  (ctxt->inputNr == 1)) {
6644  xmlFatalErrMsg(ctxt, XML_ERR_PEREF_IN_INT_SUBSET,
6645  "PEReference: forbidden within markup decl in internal subset\n");
6646  } else {
6647  xmlFatalErrMsg(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED,
6648  "xmlParseElementDecl: 'EMPTY', 'ANY' or '(' expected\n");
6649  }
6650  return(-1);
6651  }
6652 
6653  SKIP_BLANKS;
6654 
6655  if (RAW != '>') {
6657  if (content != NULL) {
6659  }
6660  } else {
6661  if (inputid != ctxt->input->id) {
6662  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6663  "Element declaration doesn't start and stop in"
6664  " the same entity\n");
6665  }
6666 
6667  NEXT;
6668  if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
6669  (ctxt->sax->elementDecl != NULL)) {
6670  if (content != NULL)
6671  content->parent = NULL;
6672  ctxt->sax->elementDecl(ctxt->userData, name, ret,
6673  content);
6674  if ((content != NULL) && (content->parent == NULL)) {
6675  /*
6676  * this is a trick: if xmlAddElementDecl is called,
6677  * instead of copying the full tree it is plugged directly
6678  * if called from the parser. Avoid duplicating the
6679  * interfaces or change the API/ABI
6680  */
6682  }
6683  } else if (content != NULL) {
6685  }
6686  }
6687  }
6688  return(ret);
6689 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:378
#define NXT(val)
Definition: parser.c:2066
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2073
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2081
int external
Definition: parser.h:217
#define SKIP_BLANKS
Definition: parser.c:2145
int xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlElementContentPtr *result)
Definition: parser.c:6553
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
content
Definition: atl_ax.c:993
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3344
XMLPUBFUN void XMLCALL xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1089
#define NEXT
Definition: parser.c:2147
int ret
xmlDocPtr myDoc
Definition: parser.h:187
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
#define SKIP(val)
Definition: parser.c:2088
#define NULL
Definition: types.h:112
Definition: name.c:38
#define CUR_PTR
Definition: parser.c:2067
#define RAW
Definition: parser.c:2064
void * userData
Definition: parser.h:186
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by xmlParseMarkupDecl().

◆ xmlParseElementMixedContentDecl()

XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementMixedContentDecl ( xmlParserCtxtPtr  ctxt,
int  inputchk 
)

xmlParseElementMixedContentDecl: @ctxt: an XML parser context @inputchk: the input used for the current entity, needed for boundary checks

parse the declaration for a Mixed Element content The leading '(' and spaces have been skipped in xmlParseElementContentDecl

[51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? '#PCDATA' S? ')'

[ VC: Proper Group/PE Nesting ] applies to [51] too (see [49])

[ VC: No Duplicate Types ] The same name must not appear more than once in a single mixed-content declaration.

returns: the list of the xmlElementContentPtr describing the element choices

Definition at line 6104 of file parser.c.

6104  {
6106  const xmlChar *elem = NULL;
6107 
6108  GROW;
6109  if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
6110  SKIP(7);
6111  SKIP_BLANKS;
6112  SHRINK;
6113  if (RAW == ')') {
6114  if (ctxt->input->id != inputchk) {
6115  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6116  "Element content declaration doesn't start and"
6117  " stop in the same entity\n");
6118  }
6119  NEXT;
6121  if (ret == NULL)
6122  return(NULL);
6123  if (RAW == '*') {
6124  ret->ocur = XML_ELEMENT_CONTENT_MULT;
6125  NEXT;
6126  }
6127  return(ret);
6128  }
6129  if ((RAW == '(') || (RAW == '|')) {
6131  if (ret == NULL) return(NULL);
6132  }
6133  while ((RAW == '|') && (ctxt->instate != XML_PARSER_EOF)) {
6134  NEXT;
6135  if (elem == NULL) {
6137  if (ret == NULL) {
6139  return(NULL);
6140  }
6141  ret->c1 = cur;
6142  if (cur != NULL)
6143  cur->parent = ret;
6144  cur = ret;
6145  } else {
6147  if (n == NULL) {
6149  return(NULL);
6150  }
6152  if (n->c1 != NULL)
6153  n->c1->parent = n;
6154  cur->c2 = n;
6155  if (n != NULL)
6156  n->parent = cur;
6157  cur = n;
6158  }
6159  SKIP_BLANKS;
6160  elem = xmlParseName(ctxt);
6161  if (elem == NULL) {
6162  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6163  "xmlParseElementMixedContentDecl : Name expected\n");
6165  return(NULL);
6166  }
6167  SKIP_BLANKS;
6168  GROW;
6169  }
6170  if ((RAW == ')') && (NXT(1) == '*')) {
6171  if (elem != NULL) {
6172  cur->c2 = xmlNewDocElementContent(ctxt->myDoc, elem,
6174  if (cur->c2 != NULL)
6175  cur->c2->parent = cur;
6176  }
6177  if (ret != NULL)
6178  ret->ocur = XML_ELEMENT_CONTENT_MULT;
6179  if (ctxt->input->id != inputchk) {
6180  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6181  "Element content declaration doesn't start and"
6182  " stop in the same entity\n");
6183  }
6184  SKIP(2);
6185  } else {
6188  return(NULL);
6189  }
6190 
6191  } else {
6193  }
6194  return(ret);
6195 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:378
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2117
#define NXT(val)
Definition: parser.c:2066
GLdouble n
Definition: glext.h:7729
XMLPUBFUN xmlElementContentPtr XMLCALL xmlNewDocElementContent(xmlDocPtr doc, const xmlChar *name, xmlElementContentType type)
Definition: valid.c:908
#define SKIP_BLANKS
Definition: parser.c:2145
xmlParserInputPtr input
Definition: parser.h:199
static size_t elem
Definition: string.c:68
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3344
XMLPUBFUN void XMLCALL xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1089
#define NEXT
Definition: parser.c:2147
int ret
xmlDocPtr myDoc
Definition: parser.h:187
unsigned char xmlChar
Definition: xmlstring.h:28
FxCollectionEntry * cur
#define SKIP(val)
Definition: parser.c:2088
#define NULL
Definition: types.h:112
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)
Definition: parser.c:2077
#define CUR_PTR
Definition: parser.c:2067
#define RAW
Definition: parser.c:2064
#define SHRINK
Definition: parser.c:2106

Referenced by xmlParseElementContentDecl().

◆ xmlParseEncName()

XMLPUBFUN xmlChar* XMLCALL xmlParseEncName ( xmlParserCtxtPtr  ctxt)

xmlParseEncName: @ctxt: an XML parser context

parse the XML encoding name

[81] EncName ::= A-Za-z*

Returns the encoding name value or NULL

Definition at line 10293 of file parser.c.

10293  {
10294  xmlChar *buf = NULL;
10295  int len = 0;
10296  int size = 10;
10297  xmlChar cur;
10298 
10299  cur = CUR;
10300  if (((cur >= 'a') && (cur <= 'z')) ||
10301  ((cur >= 'A') && (cur <= 'Z'))) {
10302  buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
10303  if (buf == NULL) {
10304  xmlErrMemory(ctxt, NULL);
10305  return(NULL);
10306  }
10307 
10308  buf[len++] = cur;
10309  NEXT;
10310  cur = CUR;
10311  while (((cur >= 'a') && (cur <= 'z')) ||
10312  ((cur >= 'A') && (cur <= 'Z')) ||
10313  ((cur >= '0') && (cur <= '9')) ||
10314  (cur == '.') || (cur == '_') ||
10315  (cur == '-')) {
10316  if (len + 1 >= size) {
10317  xmlChar *tmp;
10318 
10319  size *= 2;
10320  tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
10321  if (tmp == NULL) {
10322  xmlErrMemory(ctxt, NULL);
10323  xmlFree(buf);
10324  return(NULL);
10325  }
10326  buf = tmp;
10327  }
10328  buf[len++] = cur;
10329  NEXT;
10330  cur = CUR;
10331  if (cur == 0) {
10332  SHRINK;
10333  GROW;
10334  cur = CUR;
10335  }
10336  }
10337  buf[len] = 0;
10338  } else {
10340  }
10341  return(buf);
10342 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:378
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
Definition: globals.h:249
#define GROW
Definition: parser.c:2117
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:250
GLsizeiptr size
Definition: glext.h:5919
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
#define NEXT
Definition: parser.c:2147
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
FxCollectionEntry * cur
#define CUR
Definition: parser.c:2065
#define NULL
Definition: types.h:112
#define SHRINK
Definition: parser.c:2106

Referenced by xmlParseEncodingDecl().

◆ xmlParseEncodingDecl()

XMLPUBFUN const xmlChar* XMLCALL xmlParseEncodingDecl ( xmlParserCtxtPtr  ctxt)

xmlParseEncodingDecl: @ctxt: an XML parser context

parse the XML encoding declaration

[80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'")

this setups the conversion filters.

Returns the encoding value or NULL

Definition at line 10358 of file parser.c.

10358  {
10359  xmlChar *encoding = NULL;
10360 
10361  SKIP_BLANKS;
10362  if (CMP8(CUR_PTR, 'e', 'n', 'c', 'o', 'd', 'i', 'n', 'g')) {
10363  SKIP(8);
10364  SKIP_BLANKS;
10365  if (RAW != '=') {
10367  return(NULL);
10368  }
10369  NEXT;
10370  SKIP_BLANKS;
10371  if (RAW == '"') {
10372  NEXT;
10373  encoding = xmlParseEncName(ctxt);
10374  if (RAW != '"') {
10376  xmlFree((xmlChar *) encoding);
10377  return(NULL);
10378  } else
10379  NEXT;
10380  } else if (RAW == '\''){
10381  NEXT;
10382  encoding = xmlParseEncName(ctxt);
10383  if (RAW != '\'') {
10385  xmlFree((xmlChar *) encoding);
10386  return(NULL);
10387  } else
10388  NEXT;
10389  } else {
10391  }
10392 
10393  /*
10394  * Non standard parsing, allowing the user to ignore encoding
10395  */
10396  if (ctxt->options & XML_PARSE_IGNORE_ENC) {
10397  xmlFree((xmlChar *) encoding);
10398  return(NULL);
10399  }
10400 
10401  /*
10402  * UTF-16 encoding switch has already taken place at this stage,
10403  * more over the little-endian/big-endian selection is already done
10404  */
10405  if ((encoding != NULL) &&
10406  ((!xmlStrcasecmp(encoding, BAD_CAST "UTF-16")) ||
10407  (!xmlStrcasecmp(encoding, BAD_CAST "UTF16")))) {
10408  /*
10409  * If no encoding was passed to the parser, that we are
10410  * using UTF-16 and no decoder is present i.e. the
10411  * document is apparently UTF-8 compatible, then raise an
10412  * encoding mismatch fatal error
10413  */
10414  if ((ctxt->encoding == NULL) &&
10415  (ctxt->input->buf != NULL) &&
10416  (ctxt->input->buf->encoder == NULL)) {
10417  xmlFatalErrMsg(ctxt, XML_ERR_INVALID_ENCODING,
10418  "Document labelled UTF-16 but has UTF-8 content\n");
10419  }
10420  if (ctxt->encoding != NULL)
10421  xmlFree((xmlChar *) ctxt->encoding);
10422  ctxt->encoding = encoding;
10423  }
10424  /*
10425  * UTF-8 encoding is handled natively
10426  */
10427  else if ((encoding != NULL) &&
10428  ((!xmlStrcasecmp(encoding, BAD_CAST "UTF-8")) ||
10429  (!xmlStrcasecmp(encoding, BAD_CAST "UTF8")))) {
10430  if (ctxt->encoding != NULL)
10431  xmlFree((xmlChar *) ctxt->encoding);
10432  ctxt->encoding = encoding;
10433  }
10434  else if (encoding != NULL) {
10436 
10437  if (ctxt->input->encoding != NULL)
10438  xmlFree((xmlChar *) ctxt->input->encoding);
10439  ctxt->input->encoding = encoding;
10440 
10441  handler = xmlFindCharEncodingHandler((const char *) encoding);
10442  if (handler != NULL) {
10443  if (xmlSwitchToEncoding(ctxt, handler) < 0) {
10444  /* failed to convert */
10446  return(NULL);
10447  }
10448  } else {
10449  xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
10450  "Unsupported encoding %s\n", encoding);
10451  return(NULL);
10452  }
10453  }
10454  }
10455  return(encoding);
10456 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:378
XMLPUBFUN int XMLCALL xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
xmlChar * xmlParseEncName(xmlParserCtxtPtr ctxt)
Definition: parser.c:10293
static char * encoding
Definition: xmllint.c:155
#define SKIP_BLANKS
Definition: parser.c:2145
xmlParserInputPtr input
Definition: parser.h:199
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
#define NEXT
Definition: parser.c:2147
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
xmlCharEncodingHandlerPtr encoder
Definition: xmlIO.h:130
#define SKIP(val)
Definition: parser.c:2088
xmlParserInputBufferPtr buf
Definition: parser.h:54
#define NULL
Definition: types.h:112
const xmlChar * encoding
Definition: parser.h:71
#define CUR_PTR
Definition: parser.c:2067
#define RAW
Definition: parser.c:2064
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7482
XMLPUBFUN int XMLCALL xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:275
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2079

Referenced by xmlParseTextDecl(), and xmlParseXMLDecl().

◆ xmlParseEntityDecl()

XMLPUBFUN void XMLCALL xmlParseEntityDecl ( xmlParserCtxtPtr  ctxt)

xmlParseEntityDecl: @ctxt: an XML parser context

parse <!ENTITY declarations

[70] EntityDecl ::= GEDecl | PEDecl

[71] GEDecl ::= '<!ENTITY' S Name S EntityDef S? '>'

[72] PEDecl ::= '<!ENTITY' S '' S Name S PEDef S? '>'

[73] EntityDef ::= EntityValue | (ExternalID NDataDecl?)

[74] PEDef ::= EntityValue | ExternalID

[76] NDataDecl ::= S 'NDATA' S Name

[ VC: Notation Declared ] The Name must match the declared name of a notation.

Definition at line 5409 of file parser.c.

5409  {
5410  const xmlChar *name = NULL;
5411  xmlChar *value = NULL;
5412  xmlChar *URI = NULL, *literal = NULL;
5413  const xmlChar *ndata = NULL;
5414  int isParameter = 0;
5415  xmlChar *orig = NULL;
5416 
5417  /* GROW; done in the caller */
5418  if (CMP8(CUR_PTR, '<', '!', 'E', 'N', 'T', 'I', 'T', 'Y')) {
5419  int inputid = ctxt->input->id;
5420  SHRINK;
5421  SKIP(8);
5422  if (SKIP_BLANKS == 0) {
5423  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5424  "Space required after '<!ENTITY'\n");
5425  }
5426 
5427  if (RAW == '%') {
5428  NEXT;
5429  if (SKIP_BLANKS == 0) {
5430  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5431  "Space required after '%%'\n");
5432  }
5433  isParameter = 1;
5434  }
5435 
5436  name = xmlParseName(ctxt);
5437  if (name == NULL) {
5438  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5439  "xmlParseEntityDecl: no name\n");
5440  return;
5441  }
5442  if (xmlStrchr(name, ':') != NULL) {
5443  xmlNsErr(ctxt, XML_NS_ERR_COLON,
5444  "colons are forbidden from entities names '%s'\n",
5445  name, NULL, NULL);
5446  }
5447  if (SKIP_BLANKS == 0) {
5448  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5449  "Space required after the entity name\n");
5450  }
5451 
5453  /*
5454  * handle the various case of definitions...
5455  */
5456  if (isParameter) {
5457  if ((RAW == '"') || (RAW == '\'')) {
5458  value = xmlParseEntityValue(ctxt, &orig);
5459  if (value) {
5460  if ((ctxt->sax != NULL) &&
5461  (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5462  ctxt->sax->entityDecl(ctxt->userData, name,
5464  NULL, NULL, value);
5465  }
5466  } else {
5467  URI = xmlParseExternalID(ctxt, &literal, 1);
5468  if ((URI == NULL) && (literal == NULL)) {
5470  }
5471  if (URI) {
5472  xmlURIPtr uri;
5473 
5474  uri = xmlParseURI((const char *) URI);
5475  if (uri == NULL) {
5476  xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
5477  "Invalid URI: %s\n", URI);
5478  /*
5479  * This really ought to be a well formedness error
5480  * but the XML Core WG decided otherwise c.f. issue
5481  * E26 of the XML erratas.
5482  */
5483  } else {
5484  if (uri->fragment != NULL) {
5485  /*
5486  * Okay this is foolish to block those but not
5487  * invalid URIs.
5488  */
5490  } else {
5491  if ((ctxt->sax != NULL) &&
5492  (!ctxt->disableSAX) &&
5493  (ctxt->sax->entityDecl != NULL))
5494  ctxt->sax->entityDecl(ctxt->userData, name,
5496  literal, URI, NULL);
5497  }
5498  xmlFreeURI(uri);
5499  }
5500  }
5501  }
5502  } else {
5503  if ((RAW == '"') || (RAW == '\'')) {
5504  value = xmlParseEntityValue(ctxt, &orig);
5505  if ((ctxt->sax != NULL) &&
5506  (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5507  ctxt->sax->entityDecl(ctxt->userData, name,
5509  NULL, NULL, value);
5510  /*
5511  * For expat compatibility in SAX mode.
5512  */
5513  if ((ctxt->myDoc == NULL) ||
5515  if (ctxt->myDoc == NULL) {
5516  ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
5517  if (ctxt->myDoc == NULL) {
5518  xmlErrMemory(ctxt, "New Doc failed");
5519  return;
5520  }
5522  }
5523  if (ctxt->myDoc->intSubset == NULL)
5524  ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
5525  BAD_CAST "fake", NULL, NULL);
5526 
5528  NULL, NULL, value);
5529  }
5530  } else {
5531  URI = xmlParseExternalID(ctxt, &literal, 1);
5532  if ((URI == NULL) && (literal == NULL)) {
5534  }
5535  if (URI) {
5536  xmlURIPtr uri;
5537 
5538  uri = xmlParseURI((const char *)URI);
5539  if (uri == NULL) {
5540  xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
5541  "Invalid URI: %s\n", URI);
5542  /*
5543  * This really ought to be a well formedness error
5544  * but the XML Core WG decided otherwise c.f. issue
5545  * E26 of the XML erratas.
5546  */
5547  } else {
5548  if (uri->fragment != NULL) {
5549  /*
5550  * Okay this is foolish to block those but not
5551  * invalid URIs.
5552  */
5554  }
5555  xmlFreeURI(uri);
5556  }
5557  }
5558  if ((RAW != '>') && (SKIP_BLANKS == 0)) {
5559  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5560  "Space required before 'NDATA'\n");
5561  }
5562  if (CMP5(CUR_PTR, 'N', 'D', 'A', 'T', 'A')) {
5563  SKIP(5);
5564  if (SKIP_BLANKS == 0) {
5565  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5566  "Space required after 'NDATA'\n");
5567  }
5568  ndata = xmlParseName(ctxt);
5569  if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
5570  (ctxt->sax->unparsedEntityDecl != NULL))
5571  ctxt->sax->unparsedEntityDecl(ctxt->userData, name,
5572  literal, URI, ndata);
5573  } else {
5574  if ((ctxt->sax != NULL) &&
5575  (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5576  ctxt->sax->entityDecl(ctxt->userData, name,
5578  literal, URI, NULL);
5579  /*
5580  * For expat compatibility in SAX mode.
5581  * assuming the entity replacement was asked for
5582  */
5583  if ((ctxt->replaceEntities != 0) &&
5584  ((ctxt->myDoc == NULL) ||
5585  (xmlStrEqual(ctxt->myDoc->version, SAX_COMPAT_MODE)))) {
5586  if (ctxt->myDoc == NULL) {
5587  ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
5588  if (ctxt->myDoc == NULL) {
5589  xmlErrMemory(ctxt, "New Doc failed");
5590  return;
5591  }
5593  }
5594 
5595  if (ctxt->myDoc->intSubset == NULL)
5596  ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
5597  BAD_CAST "fake", NULL, NULL);
5598  xmlSAX2EntityDecl(ctxt, name,
5600  literal, URI, NULL);
5601  }
5602  }
5603  }
5604  }
5605  if (ctxt->instate == XML_PARSER_EOF)
5606  goto done;
5607  SKIP_BLANKS;
5608  if (RAW != '>') {
5609  xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
5610  "xmlParseEntityDecl: entity %s not terminated\n", name);
5611  xmlHaltParser(ctxt);
5612  } else {
5613  if (inputid != ctxt->input->id) {
5614  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5615  "Entity declaration doesn't start and stop in"
5616  " the same entity\n");
5617  }
5618  NEXT;
5619  }
5620  if (orig != NULL) {
5621  /*
5622  * Ugly mechanism to save the raw entity value.
5623  */
5624  xmlEntityPtr cur = NULL;
5625 
5626  if (isParameter) {
5627  if ((ctxt->sax != NULL) &&
5628  (ctxt->sax->getParameterEntity != NULL))
5629  cur = ctxt->sax->getParameterEntity(ctxt->userData, name);
5630  } else {
5631  if ((ctxt->sax != NULL) &&
5632  (ctxt->sax->getEntity != NULL))
5633  cur = ctxt->sax->getEntity(ctxt->userData, name);
5634  if ((cur == NULL) && (ctxt->userData==ctxt)) {
5635  cur = xmlSAX2GetEntity(ctxt, name);
5636  }
5637  }
5638  if ((cur != NULL) && (cur->orig == NULL)) {
5639  cur->orig = orig;
5640  orig = NULL;
5641  }
5642  }
5643 
5644 done:
5645  if (value != NULL) xmlFree(value);
5646  if (URI != NULL) xmlFree(URI);
5647  if (literal != NULL) xmlFree(literal);
5648  if (orig != NULL) xmlFree(orig);
5649  }
5650 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:378
Definition: pdh_main.c:93
xmlParserInputState instate
Definition: parser.h:223
XMLPUBFUN xmlDtdPtr XMLCALL xmlNewDtd(xmlDocPtr doc, const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID)
int properties
Definition: tree.h:584
const xmlChar * version
Definition: tree.h:573
struct _xmlDtd * intSubset
Definition: tree.h:570
const char * uri
Definition: sec_mgr.c:1588
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2073
xmlChar * xmlParseExternalID(xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict)
Definition: parser.c:4683
XMLPUBFUN xmlURIPtr XMLCALL xmlParseURI(const char *str)
Definition: uri.c:940
XMLPUBFUN void XMLCALL xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type, const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
Definition: SAX2.c:604
XMLPUBFUN const xmlChar *XMLCALL xmlStrchr(const xmlChar *str, xmlChar val)
Definition: xmlstring.c:325
#define SKIP_BLANKS
Definition: parser.c:2145
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
int replaceEntities
Definition: parser.h:189
xmlChar * xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig)
Definition: parser.c:3767
#define BAD_CAST
Definition: xmlstring.h:35
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3344
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
#define NEXT
Definition: parser.c:2147
xmlDocPtr myDoc
Definition: parser.h:187
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
FxCollectionEntry * cur
#define SKIP(val)
Definition: parser.c:2088
Definition: uri.h:33
#define NULL
Definition: types.h:112
XMLPUBFUN void XMLCALL xmlFreeURI(xmlURIPtr uri)
Definition: uri.c:1387
Definition: name.c:38
#define CUR_PTR
Definition: parser.c:2067
#define RAW
Definition: parser.c:2064
XMLPUBFUN xmlEntityPtr XMLCALL xmlSAX2GetEntity(void *ctx, const xmlChar *name)
Definition: SAX2.c:526
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:160
static void xmlHaltParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12549
#define SHRINK
Definition: parser.c:2106
#define SAX_COMPAT_MODE
Definition: parser.c:277
XMLPUBFUN xmlDocPtr XMLCALL xmlNewDoc(const xmlChar *version)
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2079
void * userData
Definition: parser.h:186

Referenced by xmlParseMarkupDecl().

◆ xmlParseEntityRef()

XMLPUBFUN xmlEntityPtr XMLCALL xmlParseEntityRef (