ReactOS  0.4.15-dev-3217-gc6d1646
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)
 
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 519 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 501 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 513 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 507 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 1783 of file parser.c.

1784 {
1786 
1787  if (ctxt == NULL)
1788  return(NULL);
1789  if (ctxt->inputNr <= 0)
1790  return (NULL);
1791  ctxt->inputNr--;
1792  if (ctxt->inputNr > 0)
1793  ctxt->input = ctxt->inputTab[ctxt->inputNr - 1];
1794  else
1795  ctxt->input = NULL;
1796  ret = ctxt->inputTab[ctxt->inputNr];
1797  ctxt->inputTab[ctxt->inputNr] = NULL;
1798  return (ret);
1799 }
xmlParserInputPtr * inputTab
Definition: parser.h:204
xmlParserInputPtr input
Definition: parser.h:201
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 1752 of file parser.c.

1753 {
1754  if ((ctxt == NULL) || (value == NULL))
1755  return(-1);
1756  if (ctxt->inputNr >= ctxt->inputMax) {
1757  ctxt->inputMax *= 2;
1758  ctxt->inputTab =
1760  ctxt->inputMax *
1761  sizeof(ctxt->inputTab[0]));
1762  if (ctxt->inputTab == NULL) {
1763  xmlErrMemory(ctxt, NULL);
1765  ctxt->inputMax /= 2;
1766  value = NULL;
1767  return (-1);
1768  }
1769  }
1770  ctxt->inputTab[ctxt->inputNr] = value;
1771  ctxt->input = value;
1772  return (ctxt->inputNr++);
1773 }
Definition: pdh_main.c:93
xmlParserInputPtr * inputTab
Definition: parser.h:204
xmlParserInputPtr input
Definition: parser.h:201
XMLPUBFUN void XMLCALL xmlFreeInputStream(xmlParserInputPtr input)
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
int inputMax
Definition: parser.h:203
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(), xmlCtxtReadDoc(), 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 1990 of file parser.c.

1991 {
1992  const xmlChar *ret;
1993 
1994  if ((ctxt == NULL) || (ctxt->nameNr <= 0))
1995  return (NULL);
1996  ctxt->nameNr--;
1997  if (ctxt->nameNr > 0)
1998  ctxt->name = ctxt->nameTab[ctxt->nameNr - 1];
1999  else
2000  ctxt->name = NULL;
2001  ret = ctxt->nameTab[ctxt->nameNr];
2002  ctxt->nameTab[ctxt->nameNr] = NULL;
2003  return (ret);
2004 }
const xmlChar * name
Definition: parser.h:231
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
#define NULL
Definition: types.h:112
const xmlChar ** nameTab
Definition: parser.h:234

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

1960 {
1961  if (ctxt == NULL) return (-1);
1962 
1963  if (ctxt->nameNr >= ctxt->nameMax) {
1964  const xmlChar * *tmp;
1965  tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,
1966  ctxt->nameMax * 2 *
1967  sizeof(ctxt->nameTab[0]));
1968  if (tmp == NULL) {
1969  goto mem_error;
1970  }
1971  ctxt->nameTab = tmp;
1972  ctxt->nameMax *= 2;
1973  }
1974  ctxt->nameTab[ctxt->nameNr] = value;
1975  ctxt->name = value;
1976  return (ctxt->nameNr++);
1977 mem_error:
1978  xmlErrMemory(ctxt, NULL);
1979  return (-1);
1980 }
const xmlChar * name
Definition: parser.h:231
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
unsigned char xmlChar
Definition: xmlstring.h:28
GLsizei const GLfloat * value
Definition: glext.h:6069
#define NULL
Definition: types.h:112
const xmlChar ** nameTab
Definition: parser.h:234

◆ nodePop()

nodePop: @ctxt: an XML parser context

Pops the top element node from the node stack

Returns the node just removed

Definition at line 1848 of file parser.c.

1849 {
1850  xmlNodePtr ret;
1851 
1852  if (ctxt == NULL) return(NULL);
1853  if (ctxt->nodeNr <= 0)
1854  return (NULL);
1855  ctxt->nodeNr--;
1856  if (ctxt->nodeNr > 0)
1857  ctxt->node = ctxt->nodeTab[ctxt->nodeNr - 1];
1858  else
1859  ctxt->node = NULL;
1860  ret = ctxt->nodeTab[ctxt->nodeNr];
1861  ctxt->nodeTab[ctxt->nodeNr] = NULL;
1862  return (ret);
1863 }
xmlNodePtr * nodeTab
Definition: parser.h:210
xmlNodePtr node
Definition: parser.h:207
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 1810 of file parser.c.

1811 {
1812  if (ctxt == NULL) return(0);
1813  if (ctxt->nodeNr >= ctxt->nodeMax) {
1814  xmlNodePtr *tmp;
1815 
1816  tmp = (xmlNodePtr *) xmlRealloc(ctxt->nodeTab,
1817  ctxt->nodeMax * 2 *
1818  sizeof(ctxt->nodeTab[0]));
1819  if (tmp == NULL) {
1820  xmlErrMemory(ctxt, NULL);
1821  return (-1);
1822  }
1823  ctxt->nodeTab = tmp;
1824  ctxt->nodeMax *= 2;
1825  }
1826  if ((((unsigned int) ctxt->nodeNr) > xmlParserMaxDepth) &&
1827  ((ctxt->options & XML_PARSE_HUGE) == 0)) {
1828  xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
1829  "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
1831  xmlHaltParser(ctxt);
1832  return(-1);
1833  }
1834  ctxt->nodeTab[ctxt->nodeNr] = value;
1835  ctxt->node = value;
1836  return (ctxt->nodeNr++);
1837 }
xmlNodePtr * nodeTab
Definition: parser.h:210
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
xmlNodePtr node
Definition: parser.h:207
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
unsigned int xmlParserMaxDepth
Definition: parser.c:281
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:12544

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

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

895  {
896  if (out == NULL) return(0);
897  /* the len parameter is ignored */
898  if (val >= 0x80) {
899  return(xmlCopyCharMultiByte (out, val));
900  }
901  *out = (xmlChar) val;
902  return 1;
903 }
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 852 of file parserInternals.c.

852  {
853  if (out == NULL) return(0);
854  /*
855  * We are supposed to handle UTF8, check it's valid
856  * From rfc2044: encoding of the Unicode values on UTF-8:
857  *
858  * UCS-4 range (hex.) UTF-8 octet sequence (binary)
859  * 0000 0000-0000 007F 0xxxxxxx
860  * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
861  * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
862  */
863  if (val >= 0x80) {
864  xmlChar *savedout = out;
865  int bits;
866  if (val < 0x800) { *out++= (val >> 6) | 0xC0; bits= 0; }
867  else if (val < 0x10000) { *out++= (val >> 12) | 0xE0; bits= 6;}
868  else if (val < 0x110000) { *out++= (val >> 18) | 0xF0; bits= 12; }
869  else {
870  xmlErrEncodingInt(NULL, XML_ERR_INVALID_CHAR,
871  "Internal error, xmlCopyCharMultiByte 0x%X out of bound\n",
872  val);
873  return(0);
874  }
875  for ( ; bits >= 0; bits-= 6)
876  *out++= ((val >> bits) & 0x3F) | 0x80 ;
877  return (out - savedout);
878  }
879  *out = (xmlChar) val;
880  return 1;
881 }
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 14021 of file parser.c.

14022  {
14024 
14025 }
static xmlParserCtxtPtr xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID, const xmlChar *base, xmlParserCtxtPtr pctx)
Definition: parser.c:13948
#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 14087 of file parser.c.

14088 {
14089  return(xmlCreateURLParserCtxt(filename, 0));
14090 }
const char * filename
Definition: ioapi.h:135
xmlParserCtxtPtr xmlCreateURLParserCtxt(const char *filename, int options)
Definition: parser.c:14045

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

14333  {
14334  xmlParserCtxtPtr ctxt;
14337 
14338  if (buffer == NULL)
14339  return(NULL);
14340  if (size <= 0)
14341  return(NULL);
14342 
14343  ctxt = xmlNewParserCtxt();
14344  if (ctxt == NULL)
14345  return(NULL);
14346 
14347  /* TODO: xmlParserInputBufferCreateStatic, requires some serious changes */
14349  if (buf == NULL) {
14350  xmlFreeParserCtxt(ctxt);
14351  return(NULL);
14352  }
14353 
14354  input = xmlNewInputStream(ctxt);
14355  if (input == NULL) {
14357  xmlFreeParserCtxt(ctxt);
14358  return(NULL);
14359  }
14360 
14361  input->filename = NULL;
14362  input->buf = buf;
14363  xmlBufResetInput(input->buf->buffer, input);
14364 
14365  inputPush(ctxt, input);
14366  return(ctxt);
14367 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1752
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:1285
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 14045 of file parser.c.

14046 {
14047  xmlParserCtxtPtr ctxt;
14048  xmlParserInputPtr inputStream;
14049  char *directory = NULL;
14050 
14051  ctxt = xmlNewParserCtxt();
14052  if (ctxt == NULL) {
14053  xmlErrMemory(NULL, "cannot allocate parser context");
14054  return(NULL);
14055  }
14056 
14057  if (options)
14059  ctxt->linenumbers = 1;
14060 
14061  inputStream = xmlLoadExternalEntity(filename, NULL, ctxt);
14062  if (inputStream == NULL) {
14063  xmlFreeParserCtxt(ctxt);
14064  return(NULL);
14065  }
14066 
14067  inputPush(ctxt, inputStream);
14068  if ((ctxt->directory == NULL) && (directory == NULL))
14070  if ((ctxt->directory == NULL) && (directory != NULL))
14071  ctxt->directory = directory;
14072 
14073  return(ctxt);
14074 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1752
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
const char * filename
Definition: ioapi.h:135
int linenumbers
Definition: parser.h:261
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:14992
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:228
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 585 of file parserInternals.c.

585  {
586  if ((ctxt == NULL) || (len == NULL) || (ctxt->input == NULL)) return(0);
587  if (ctxt->instate == XML_PARSER_EOF)
588  return(0);
589 
590  if ((*ctxt->input->cur >= 0x20) && (*ctxt->input->cur <= 0x7F)) {
591  *len = 1;
592  return((int) *ctxt->input->cur);
593  }
594  if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
595  /*
596  * We are supposed to handle UTF8, check it's valid
597  * From rfc2044: encoding of the Unicode values on UTF-8:
598  *
599  * UCS-4 range (hex.) UTF-8 octet sequence (binary)
600  * 0000 0000-0000 007F 0xxxxxxx
601  * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
602  * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
603  *
604  * Check for the 0x110000 limit too
605  */
606  const unsigned char *cur = ctxt->input->cur;
607  unsigned char c;
608  unsigned int val;
609 
610  c = *cur;
611  if (c & 0x80) {
612  if (((c & 0x40) == 0) || (c == 0xC0))
613  goto encoding_error;
614  if (cur[1] == 0) {
616  cur = ctxt->input->cur;
617  }
618  if ((cur[1] & 0xc0) != 0x80)
619  goto encoding_error;
620  if ((c & 0xe0) == 0xe0) {
621  if (cur[2] == 0) {
623  cur = ctxt->input->cur;
624  }
625  if ((cur[2] & 0xc0) != 0x80)
626  goto encoding_error;
627  if ((c & 0xf0) == 0xf0) {
628  if (cur[3] == 0) {
630  cur = ctxt->input->cur;
631  }
632  if (((c & 0xf8) != 0xf0) ||
633  ((cur[3] & 0xc0) != 0x80))
634  goto encoding_error;
635  /* 4-byte code */
636  *len = 4;
637  val = (cur[0] & 0x7) << 18;
638  val |= (cur[1] & 0x3f) << 12;
639  val |= (cur[2] & 0x3f) << 6;
640  val |= cur[3] & 0x3f;
641  if (val < 0x10000)
642  goto encoding_error;
643  } else {
644  /* 3-byte code */
645  *len = 3;
646  val = (cur[0] & 0xf) << 12;
647  val |= (cur[1] & 0x3f) << 6;
648  val |= cur[2] & 0x3f;
649  if (val < 0x800)
650  goto encoding_error;
651  }
652  } else {
653  /* 2-byte code */
654  *len = 2;
655  val = (cur[0] & 0x1f) << 6;
656  val |= cur[1] & 0x3f;
657  if (val < 0x80)
658  goto encoding_error;
659  }
660  if (!IS_CHAR(val)) {
661  xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
662  "Char 0x%X out of allowed range\n", val);
663  }
664  return(val);
665  } else {
666  /* 1-byte code */
667  *len = 1;
668  if (*ctxt->input->cur == 0)
670  if ((*ctxt->input->cur == 0) &&
671  (ctxt->input->end > ctxt->input->cur)) {
672  xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
673  "Char 0x0 out of allowed range\n", 0);
674  }
675  if (*ctxt->input->cur == 0xD) {
676  if (ctxt->input->cur[1] == 0xA) {
677  ctxt->input->cur++;
678  }
679  return(0xA);
680  }
681  return((int) *ctxt->input->cur);
682  }
683  }
684  /*
685  * Assume it's a fixed length encoding (1) with
686  * a compatible encoding for the ASCII set, since
687  * XML constructs only use < 128 chars
688  */
689  *len = 1;
690  if (*ctxt->input->cur == 0xD) {
691  if (ctxt->input->cur[1] == 0xA) {
692  ctxt->input->cur++;
693  }
694  return(0xA);
695  }
696  return((int) *ctxt->input->cur);
697 encoding_error:
698  /*
699  * An encoding problem may arise from a truncated input buffer
700  * splitting a character in the middle. In that case do not raise
701  * an error but return 0 to indicate an end of stream problem
702  */
703  if (ctxt->input->end - ctxt->input->cur < 4) {
704  *len = 0;
705  return(0);
706  }
707 
708  /*
709  * If we detect an UTF8 error that probably mean that the
710  * input encoding didn't get properly advertised in the
711  * declaration header. Report the error and switch the encoding
712  * to ISO-Latin-1 (if you don't like this policy, just declare the
713  * encoding !)
714  */
715  {
716  char buffer[150];
717 
718  snprintf(&buffer[0], 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
719  ctxt->input->cur[0], ctxt->input->cur[1],
720  ctxt->input->cur[2], ctxt->input->cur[3]);
722  "Input is not proper UTF-8, indicate encoding !\n%s",
723  BAD_CAST buffer, NULL);
724  }
726  *len = 1;
727  return((int) *ctxt->input->cur);
728 }
xmlParserInputState instate
Definition: parser.h:225
const xmlChar * cur
Definition: parser.h:61
#define snprintf
Definition: wintirpc.h:48
GLuint buffer
Definition: glext.h:5915
xmlParserInputPtr input
Definition: parser.h:201
#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:62

◆ xmlFreeInputStream()

XMLPUBFUN void XMLCALL xmlFreeInputStream ( xmlParserInputPtr  input)

xmlFreeInputStream: @input: an xmlParserInputPtr

Free up an input stream.

Definition at line 1339 of file parserInternals.c.

1339  {
1340  if (input == NULL) return;
1341 
1342  if (input->filename != NULL) xmlFree((char *) input->filename);
1343  if (input->directory != NULL) xmlFree((char *) input->directory);
1344  if (input->encoding != NULL) xmlFree((char *) input->encoding);
1345  if (input->version != NULL) xmlFree((char *) input->version);
1346  if ((input->free != NULL) && (input->base != NULL))
1347  input->free((xmlChar *) input->base);
1348  if (input->buf != NULL)
1350  xmlFree(input);
1351 }
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLenum GLenum input
Definition: glext.h:9031
#define NULL
Definition: types.h:112

Referenced by inputPush(), xmlCtxtReset(), xmlFreeParserCtxt(), xmlHaltParser(), xmlInitParserCtxt(), 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 229 of file parserInternals.c.

229  {
230  return(IS_BASECHAR(c) || IS_IDEOGRAPHIC(c));
231 }
#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 1430 of file parserInternals.c.

1430  {
1432 
1433  if (entity == NULL) {
1434  xmlErrInternal(ctxt, "xmlNewEntityInputStream entity = NULL\n",
1435  NULL);
1436  return(NULL);
1437  }
1440  "new input from entity: %s\n", entity->name);
1441  if (entity->content == NULL) {
1442  switch (entity->etype) {
1444  xmlErrInternal(ctxt, "Cannot parse entity %s\n",
1445  entity->name);
1446  break;
1449  return(xmlLoadExternalEntity((char *) entity->URI,
1450  (char *) entity->ExternalID, ctxt));
1452  xmlErrInternal(ctxt,
1453  "Internal entity %s without content !\n",
1454  entity->name);
1455  break;
1457  xmlErrInternal(ctxt,
1458  "Internal parameter entity %s without content !\n",
1459  entity->name);
1460  break;
1462  xmlErrInternal(ctxt,
1463  "Predefined entity %s without content !\n",
1464  entity->name);
1465  break;
1466  }
1467  return(NULL);
1468  }
1469  input = xmlNewInputStream(ctxt);
1470  if (input == NULL) {
1471  return(NULL);
1472  }
1473  if (entity->URI != NULL)
1474  input->filename = (char *) xmlStrdup((xmlChar *) entity->URI);
1475  input->base = entity->content;
1476  if (entity->length == 0)
1477  entity->length = xmlStrlen(entity->content);
1478  input->cur = entity->content;
1479  input->length = entity->length;
1480  input->end = &entity->content[input->length];
1481  return(input);
1482 }
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:425
Definition: actctx.c:387
WCHAR * name
Definition: actctx.c:405
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
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:432
#define NULL
Definition: types.h:112
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

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 1526 of file parserInternals.c.

1526  {
1528  xmlParserInputPtr inputStream;
1529  char *directory = NULL;
1530  xmlChar *URI = NULL;
1531 
1534  "new input from file: %s\n", filename);
1535  if (ctxt == NULL) return(NULL);
1537  if (buf == NULL) {
1538  if (filename == NULL)
1539  __xmlLoaderErr(ctxt,
1540  "failed to load external entity: NULL filename \n",
1541  NULL);
1542  else
1543  __xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n",
1544  (const char *) filename);
1545  return(NULL);
1546  }
1547 
1548  inputStream = xmlNewInputStream(ctxt);
1549  if (inputStream == NULL)
1550  return(NULL);
1551 
1552  inputStream->buf = buf;
1553  inputStream = xmlCheckHTTPInput(ctxt, inputStream);
1554  if (inputStream == NULL)
1555  return(NULL);
1556 
1557  if (inputStream->filename == NULL)
1558  URI = xmlStrdup((xmlChar *) filename);
1559  else
1560  URI = xmlStrdup((xmlChar *) inputStream->filename);
1561  directory = xmlParserGetDirectory((const char *) URI);
1562  if (inputStream->filename != NULL) xmlFree((char *)inputStream->filename);
1563  inputStream->filename = (char *) xmlCanonicPath((const xmlChar *) URI);
1564  if (URI != NULL) xmlFree((char *) URI);
1565  inputStream->directory = directory;
1566 
1567  xmlBufResetInput(inputStream->buf->buffer, inputStream);
1568  if ((ctxt->directory == NULL) && (directory != NULL))
1569  ctxt->directory = (char *) xmlStrdup((const xmlChar *) directory);
1570  return(inputStream);
1571 }
void __xmlLoaderErr(void *ctx, const char *msg, const char *filename) LIBXML_ATTR_FORMAT(2
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1285
const char * filename
Definition: ioapi.h:135
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
XMLPUBFUN xmlChar *XMLCALL xmlCanonicPath(const xmlChar *path)
Definition: uri.c:2379
xmlBufPtr buffer
Definition: xmlIO.h:132
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
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:56
const char * filename
Definition: parser.h:58
XMLPUBVAR int xmlParserDebugEntities
Definition: globals.h:432
#define NULL
Definition: types.h:112
char * directory
Definition: parser.h:228
const char * directory
Definition: parser.h:59
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

◆ 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 1362 of file parserInternals.c.

1362  {
1364 
1366  if (input == NULL) {
1367  xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
1368  return(NULL);
1369  }
1370  memset(input, 0, sizeof(xmlParserInput));
1371  input->line = 1;
1372  input->col = 1;
1373  input->standalone = -1;
1374 
1375  /*
1376  * If the context is NULL the id cannot be initialized, but that
1377  * should not happen while parsing which is the situation where
1378  * the id is actually needed.
1379  */
1380  if (ctxt != NULL)
1381  input->id = ctxt->input_id++;
1382 
1383  return(input);
1384 }
xmlParserInput * xmlParserInputPtr
Definition: tree.h:36
int input_id
Definition: parser.h:314
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:247
#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 1493 of file parserInternals.c.

1493  {
1495 
1496  if (buffer == NULL) {
1497  xmlErrInternal(ctxt, "xmlNewStringInputStream string = NULL\n",
1498  NULL);
1499  return(NULL);
1500  }
1503  "new fixed input: %.30s\n", buffer);
1504  input = xmlNewInputStream(ctxt);
1505  if (input == NULL) {
1506  xmlErrMemory(ctxt, "couldn't allocate a new input stream\n");
1507  return(NULL);
1508  }
1509  input->base = buffer;
1510  input->cur = buffer;
1511  input->length = xmlStrlen(buffer);
1512  input->end = &buffer[input->length];
1513  return(input);
1514 }
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:425
GLuint buffer
Definition: glext.h:5915
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
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:432
#define NULL
Definition: types.h:112
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Referenced by xmlCtxtReadDoc().

◆ xmlNextChar()

XMLPUBFUN void XMLCALL xmlNextChar ( xmlParserCtxtPtr  ctxt)

xmlNextChar: @ctxt: the XML parser context

Skip to the next char input char.

Definition at line 423 of file parserInternals.c.

424 {
425  if ((ctxt == NULL) || (ctxt->instate == XML_PARSER_EOF) ||
426  (ctxt->input == NULL))
427  return;
428 
429  if (!(VALID_CTXT(ctxt))) {
430  xmlErrInternal(ctxt, "Parser input data memory error\n", NULL);
432  xmlStopParser(ctxt);
433  return;
434  }
435 
436  if ((*ctxt->input->cur == 0) &&
437  (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) {
438  return;
439  }
440 
441  if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
442  const unsigned char *cur;
443  unsigned char c;
444 
445  /*
446  * 2.11 End-of-Line Handling
447  * the literal two-character sequence "#xD#xA" or a standalone
448  * literal #xD, an XML processor must pass to the application
449  * the single character #xA.
450  */
451  if (*(ctxt->input->cur) == '\n') {
452  ctxt->input->line++; ctxt->input->col = 1;
453  } else
454  ctxt->input->col++;
455 
456  /*
457  * We are supposed to handle UTF8, check it's valid
458  * From rfc2044: encoding of the Unicode values on UTF-8:
459  *
460  * UCS-4 range (hex.) UTF-8 octet sequence (binary)
461  * 0000 0000-0000 007F 0xxxxxxx
462  * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
463  * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
464  *
465  * Check for the 0x110000 limit too
466  */
467  cur = ctxt->input->cur;
468 
469  c = *cur;
470  if (c & 0x80) {
471  if (c == 0xC0)
472  goto encoding_error;
473  if (cur[1] == 0) {
475  cur = ctxt->input->cur;
476  }
477  if ((cur[1] & 0xc0) != 0x80)
478  goto encoding_error;
479  if ((c & 0xe0) == 0xe0) {
480  unsigned int val;
481 
482  if (cur[2] == 0) {
484  cur = ctxt->input->cur;
485  }
486  if ((cur[2] & 0xc0) != 0x80)
487  goto encoding_error;
488  if ((c & 0xf0) == 0xf0) {
489  if (cur[3] == 0) {
491  cur = ctxt->input->cur;
492  }
493  if (((c & 0xf8) != 0xf0) ||
494  ((cur[3] & 0xc0) != 0x80))
495  goto encoding_error;
496  /* 4-byte code */
497  ctxt->input->cur += 4;
498  val = (cur[0] & 0x7) << 18;
499  val |= (cur[1] & 0x3f) << 12;
500  val |= (cur[2] & 0x3f) << 6;
501  val |= cur[3] & 0x3f;
502  } else {
503  /* 3-byte code */
504  ctxt->input->cur += 3;
505  val = (cur[0] & 0xf) << 12;
506  val |= (cur[1] & 0x3f) << 6;
507  val |= cur[2] & 0x3f;
508  }
509  if (((val > 0xd7ff) && (val < 0xe000)) ||
510  ((val > 0xfffd) && (val < 0x10000)) ||
511  (val >= 0x110000)) {
512  xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
513  "Char 0x%X out of allowed range\n",
514  val);
515  }
516  } else
517  /* 2-byte code */
518  ctxt->input->cur += 2;
519  } else
520  /* 1-byte code */
521  ctxt->input->cur++;
522  } else {
523  /*
524  * Assume it's a fixed length encoding (1) with
525  * a compatible encoding for the ASCII set, since
526  * XML constructs only use < 128 chars
527  */
528 
529  if (*(ctxt->input->cur) == '\n') {
530  ctxt->input->line++; ctxt->input->col = 1;
531  } else
532  ctxt->input->col++;
533  ctxt->input->cur++;
534  }
535  if (*ctxt->input->cur == 0)
537  return;
538 encoding_error:
539  /*
540  * If we detect an UTF8 error that probably mean that the
541  * input encoding didn't get properly advertised in the
542  * declaration header. Report the error and switch the encoding
543  * to ISO-Latin-1 (if you don't like this policy, just declare the
544  * encoding !)
545  */
546  if ((ctxt == NULL) || (ctxt->input == NULL) ||
547  (ctxt->input->end - ctxt->input->cur < 4)) {
549  "Input is not proper UTF-8, indicate encoding !\n",
550  NULL, NULL);
551  } else {
552  char buffer[150];
553 
554  snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
555  ctxt->input->cur[0], ctxt->input->cur[1],
556  ctxt->input->cur[2], ctxt->input->cur[3]);
558  "Input is not proper UTF-8, indicate encoding !\n%s",
559  BAD_CAST buffer, NULL);
560  }
562  ctxt->input->cur++;
563  return;
564 }
xmlParserInputState instate
Definition: parser.h:225
#define VALID_CTXT(ctxt)
const xmlChar * cur
Definition: parser.h:61
#define snprintf
Definition: wintirpc.h:48
GLuint buffer
Definition: glext.h:5915
XMLPUBFUN void XMLCALL xmlStopParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12578
xmlParserInputPtr input
Definition: parser.h:201
#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:62

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

5970  {
5971  const xmlChar *elemName;
5972  const xmlChar *attrName;
5974 
5975  if (CMP9(CUR_PTR, '<', '!', 'A', 'T', 'T', 'L', 'I', 'S', 'T')) {
5976  int inputid = ctxt->input->id;
5977 
5978  SKIP(9);
5979  if (SKIP_BLANKS == 0) {
5980  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5981  "Space required after '<!ATTLIST'\n");
5982  }
5983  elemName = xmlParseName(ctxt);
5984  if (elemName == NULL) {
5985  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5986  "ATTLIST: no name for Element\n");
5987  return;
5988  }
5989  SKIP_BLANKS;
5990  GROW;
5991  while ((RAW != '>') && (ctxt->instate != XML_PARSER_EOF)) {
5992  int type;
5993  int def;
5994  xmlChar *defaultValue = NULL;
5995 
5996  GROW;
5997  tree = NULL;
5998  attrName = xmlParseName(ctxt);
5999  if (attrName == NULL) {
6000  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6001  "ATTLIST: no name for Attribute\n");
6002  break;
6003  }
6004  GROW;
6005  if (SKIP_BLANKS == 0) {
6006  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6007  "Space required after the attribute name\n");
6008  break;
6009  }
6010 
6011  type = xmlParseAttributeType(ctxt, &tree);
6012  if (type <= 0) {
6013  break;
6014  }
6015 
6016  GROW;
6017  if (SKIP_BLANKS == 0) {
6018  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6019  "Space required after the attribute type\n");
6020  if (tree != NULL)
6022  break;
6023  }
6024 
6025  def = xmlParseDefaultDecl(ctxt, &defaultValue);
6026  if (def <= 0) {
6027  if (defaultValue != NULL)
6028  xmlFree(defaultValue);
6029  if (tree != NULL)
6031  break;
6032  }
6033  if ((type != XML_ATTRIBUTE_CDATA) && (defaultValue != NULL))
6034  xmlAttrNormalizeSpace(defaultValue, defaultValue);
6035 
6036  GROW;
6037  if (RAW != '>') {
6038  if (SKIP_BLANKS == 0) {
6039  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6040  "Space required after the attribute default value\n");
6041  if (defaultValue != NULL)
6042  xmlFree(defaultValue);
6043  if (tree != NULL)
6045  break;
6046  }
6047  }
6048  if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
6049  (ctxt->sax->attributeDecl != NULL))
6050  ctxt->sax->attributeDecl(ctxt->userData, elemName, attrName,
6051  type, def, defaultValue, tree);
6052  else if (tree != NULL)
6054 
6055  if ((ctxt->sax2) && (defaultValue != NULL) &&
6056  (def != XML_ATTRIBUTE_IMPLIED) &&
6057  (def != XML_ATTRIBUTE_REQUIRED)) {
6058  xmlAddDefAttrs(ctxt, elemName, attrName, defaultValue);
6059  }
6060  if (ctxt->sax2) {
6061  xmlAddSpecialAttr(ctxt, elemName, attrName, type);
6062  }
6063  if (defaultValue != NULL)
6064  xmlFree(defaultValue);
6065  GROW;
6066  }
6067  if (RAW == '>') {
6068  if (inputid != ctxt->input->id) {
6069  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6070  "Attribute list declaration doesn't start and"
6071  " stop in the same entity\n");
6072  }
6073  NEXT;
6074  }
6075  }
6076 }
static void xmlAddDefAttrs(xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, const xmlChar *value)
Definition: parser.c:1249
int xmlParseDefaultDecl(xmlParserCtxtPtr ctxt, xmlChar **value)
Definition: parser.c:5676
xmlParserInputState instate
Definition: parser.h:225
#define GROW
Definition: parser.c:2126
struct _tree tree
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2090
#define SKIP_BLANKS
Definition: parser.c:2154
int xmlParseAttributeType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
Definition: parser.c:5928
xmlParserInputPtr input
Definition: parser.h:201
int disableSAX
Definition: parser.h:239
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3343
static xmlChar * xmlAttrNormalizeSpace(const xmlChar *src, xmlChar *dst)
Definition: parser.c:1159
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
#define NEXT
Definition: parser.c:2156
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:187
#define SKIP(val)
Definition: parser.c:2097
static void xmlAddSpecialAttr(xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, int type)
Definition: parser.c:1360
#define NULL
Definition: types.h:112
#define CUR_PTR
Definition: parser.c:2076
#define RAW
Definition: parser.c:2073
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
void * userData
Definition: parser.h:188
XMLPUBFUN void XMLCALL xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1831

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

5928  {
5929  SHRINK;
5930  if (CMP5(CUR_PTR, 'C', 'D', 'A', 'T', 'A')) {
5931  SKIP(5);
5932  return(XML_ATTRIBUTE_CDATA);
5933  } else if (CMP6(CUR_PTR, 'I', 'D', 'R', 'E', 'F', 'S')) {
5934  SKIP(6);
5935  return(XML_ATTRIBUTE_IDREFS);
5936  } else if (CMP5(CUR_PTR, 'I', 'D', 'R', 'E', 'F')) {
5937  SKIP(5);
5938  return(XML_ATTRIBUTE_IDREF);
5939  } else if ((RAW == 'I') && (NXT(1) == 'D')) {
5940  SKIP(2);
5941  return(XML_ATTRIBUTE_ID);
5942  } else if (CMP6(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'Y')) {
5943  SKIP(6);
5944  return(XML_ATTRIBUTE_ENTITY);
5945  } else if (CMP8(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S')) {
5946  SKIP(8);
5947  return(XML_ATTRIBUTE_ENTITIES);
5948  } else if (CMP8(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S')) {
5949  SKIP(8);
5950  return(XML_ATTRIBUTE_NMTOKENS);
5951  } else if (CMP7(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N')) {
5952  SKIP(7);
5953  return(XML_ATTRIBUTE_NMTOKEN);
5954  }
5955  return(xmlParseEnumeratedType(ctxt, tree));
5956 }
#define NXT(val)
Definition: parser.c:2075
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2082
#define CMP6(s, c1, c2, c3, c4, c5, c6)
Definition: parser.c:2084
int xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
Definition: parser.c:5865
#define SKIP(val)
Definition: parser.c:2097
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)
Definition: parser.c:2086
#define CUR_PTR
Definition: parser.c:2076
#define RAW
Definition: parser.c:2073
#define SHRINK
Definition: parser.c:2115
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2088

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

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

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

9759  {
9760  xmlChar *buf = NULL;
9761  int len = 0;
9763  int r, rl;
9764  int s, sl;
9765  int cur, l;
9766  int count = 0;
9767 
9768  /* Check 2.6.0 was NXT(0) not RAW */
9769  if (CMP9(CUR_PTR, '<', '!', '[', 'C', 'D', 'A', 'T', 'A', '[')) {
9770  SKIP(9);
9771  } else
9772  return;
9773 
9775  r = CUR_CHAR(rl);
9776  if (!IS_CHAR(r)) {
9778  ctxt->instate = XML_PARSER_CONTENT;
9779  return;
9780  }
9781  NEXTL(rl);
9782  s = CUR_CHAR(sl);
9783  if (!IS_CHAR(s)) {
9785  ctxt->instate = XML_PARSER_CONTENT;
9786  return;
9787  }
9788  NEXTL(sl);
9789  cur = CUR_CHAR(l);
9790  buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
9791  if (buf == NULL) {
9792  xmlErrMemory(ctxt, NULL);
9793  return;
9794  }
9795  while (IS_CHAR(cur) &&
9796  ((r != ']') || (s != ']') || (cur != '>'))) {
9797  if (len + 5 >= size) {
9798  xmlChar *tmp;
9799 
9800  if ((size > XML_MAX_TEXT_LENGTH) &&
9801  ((ctxt->options & XML_PARSE_HUGE) == 0)) {
9802  xmlFatalErrMsgStr(ctxt, XML_ERR_CDATA_NOT_FINISHED,
9803  "CData section too big found", NULL);
9804  xmlFree (buf);
9805  return;
9806  }
9807  tmp = (xmlChar *) xmlRealloc(buf, size * 2 * sizeof(xmlChar));
9808  if (tmp == NULL) {
9809  xmlFree(buf);
9810  xmlErrMemory(ctxt, NULL);
9811  return;
9812  }
9813  buf = tmp;
9814  size *= 2;
9815  }
9816  COPY_BUF(rl,buf,len,r);
9817  r = s;
9818  rl = sl;
9819  s = cur;
9820  sl = l;
9821  count++;
9822  if (count > 50) {
9823  SHRINK;
9824  GROW;
9825  if (ctxt->instate == XML_PARSER_EOF) {
9826  xmlFree(buf);
9827  return;
9828  }
9829  count = 0;
9830  }
9831  NEXTL(l);
9832  cur = CUR_CHAR(l);
9833  }
9834  buf[len] = 0;
9835  ctxt->instate = XML_PARSER_CONTENT;
9836  if (cur != '>') {
9837  xmlFatalErrMsgStr(ctxt, XML_ERR_CDATA_NOT_FINISHED,
9838  "CData section not finished\n%.50s\n", buf);
9839  xmlFree(buf);
9840  return;
9841  }
9842  NEXTL(l);
9843 
9844  /*
9845  * OK the buffer is to be consumed as cdata.
9846  */
9847  if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
9848  if (ctxt->sax->cdataBlock != NULL)
9849  ctxt->sax->cdataBlock(ctxt->userData, buf, len);
9850  else if (ctxt->sax->characters != NULL)
9851  ctxt->sax->characters(ctxt->userData, buf, len);
9852  }
9853  xmlFree(buf);
9854 }
#define COPY_BUF(l, b, i, v)
Definition: parser.c:2175
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:389
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
Definition: globals.h:248
xmlParserInputState instate
Definition: parser.h:225
#define GROW
Definition: parser.c:2126
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:2090
int disableSAX
Definition: parser.h:239
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define XML_PARSER_BUFFER_SIZE
Definition: parser.c:287
#define IS_CHAR(c)
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
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:250
#define CUR_CHAR(l)
Definition: parser.c:2172
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:187
#define NEXTL(l)
Definition: parser.c:2165
FxCollectionEntry * cur
#define SKIP(val)
Definition: parser.c:2097
#define NULL
Definition: types.h:112
#define CUR_PTR
Definition: parser.c:2076
#define SHRINK
Definition: parser.c:2115
void * userData
Definition: parser.h:188

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

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

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

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

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

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

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

9950  {
9951  int nameNr = ctxt->nameNr;
9952 
9954 
9955  if ((ctxt->instate != XML_PARSER_EOF) && (ctxt->nameNr > nameNr)) {
9956  const xmlChar *name = ctxt->nameTab[ctxt->nameNr - 1];
9957  int line = ctxt->pushTab[ctxt->nameNr - 1].line;
9958  xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
9959  "Premature end of data in tag %s line %d\n",
9960  name, line, NULL);
9961  }
9962 }
xmlParserInputState instate
Definition: parser.h:225
Definition: parser.c:48
int line
Definition: parser.c:93
xmlStartTag * pushTab
Definition: parser.h:285
unsigned char xmlChar
Definition: xmlstring.h:28
#define NULL
Definition: types.h:112
Definition: name.c:38
const xmlChar ** nameTab
Definition: parser.h:234
static void xmlParseContentInternal(xmlParserCtxtPtr ctxt)
Definition: parser.c:9865

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

5676  {
5677  int val;
5678  xmlChar *ret;
5679 
5680  *value = NULL;
5681  if (CMP9(CUR_PTR, '#', 'R', 'E', 'Q', 'U', 'I', 'R', 'E', 'D')) {
5682  SKIP(9);
5683  return(XML_ATTRIBUTE_REQUIRED);
5684  }
5685  if (CMP8(CUR_PTR, '#', 'I', 'M', 'P', 'L', 'I', 'E', 'D')) {
5686  SKIP(8);
5687  return(XML_ATTRIBUTE_IMPLIED);
5688  }
5690  if (CMP6(CUR_PTR, '#', 'F', 'I', 'X', 'E', 'D')) {
5691  SKIP(6);
5693  if (SKIP_BLANKS == 0) {
5694  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5695  "Space required after '#FIXED'\n");
5696  }
5697  }
5698  ret = xmlParseAttValue(ctxt);
5699  ctxt->instate = XML_PARSER_DTD;
5700  if (ret == NULL) {
5701  xmlFatalErrMsg(ctxt, (xmlParserErrors)ctxt->errNo,
5702  "Attribute default value declaration error\n");
5703  } else
5704  *value = ret;
5705  return(val);
5706 }
Definition: pdh_main.c:93
xmlParserInputState instate
Definition: parser.h:225
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2090
#define SKIP_BLANKS
Definition: parser.c:2154
#define CMP6(s, c1, c2, c3, c4, c5, c6)
Definition: parser.c:2084
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:2097
#define NULL
Definition: types.h:112
#define CUR_PTR
Definition: parser.c:2076
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2088
xmlChar * xmlParseAttValue(xmlParserCtxtPtr ctxt)
Definition: parser.c:4180

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

8273  {
8274  const xmlChar *name = NULL;
8275  xmlChar *ExternalID = NULL;
8276  xmlChar *URI = NULL;
8277 
8278  /*
8279  * We know that '<!DOCTYPE' has been detected.
8280  */
8281  SKIP(9);
8282 
8283  SKIP_BLANKS;
8284 
8285  /*
8286  * Parse the DOCTYPE name.
8287  */
8288  name = xmlParseName(ctxt);
8289  if (name == NULL) {
8290  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
8291  "xmlParseDocTypeDecl : no DOCTYPE name !\n");
8292  }
8293  ctxt->intSubName = name;
8294 
8295  SKIP_BLANKS;
8296 
8297  /*
8298  * Check for SystemID and ExternalID
8299  */
8300  URI = xmlParseExternalID(ctxt, &ExternalID, 1);
8301 
8302  if ((URI != NULL) || (ExternalID != NULL)) {
8303  ctxt->hasExternalSubset = 1;
8304  }
8305  ctxt->extSubURI = URI;
8306  ctxt->extSubSystem = ExternalID;
8307 
8308  SKIP_BLANKS;
8309 
8310  /*
8311  * Create and update the internal subset.
8312  */
8313  if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) &&
8314  (!ctxt->disableSAX))
8315  ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI);
8316  if (ctxt->instate == XML_PARSER_EOF)
8317  return;
8318 
8319  /*
8320  * Is there any internal subset declarations ?
8321  * they are handled separately in xmlParseInternalSubset()
8322  */
8323  if (RAW == '[')
8324  return;
8325 
8326  /*
8327  * We should be at the end of the DOCTYPE declaration.
8328  */
8329  if (RAW != '>') {
8331  }
8332  NEXT;
8333 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:389
xmlParserInputState instate
Definition: parser.h:225
xmlChar * extSubURI
Definition: parser.h:242
xmlChar * xmlParseExternalID(xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict)
Definition: parser.c:4676
#define SKIP_BLANKS
Definition: parser.c:2154
int disableSAX
Definition: parser.h:239
xmlChar * extSubSystem
Definition: parser.h:243
const xmlChar * intSubName
Definition: parser.h:241
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3343
#define NEXT
Definition: parser.c:2156
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:187
int hasExternalSubset
Definition: parser.h:217
#define SKIP(val)
Definition: parser.c:2097
#define NULL
Definition: types.h:112
Definition: name.c:38
#define RAW
Definition: parser.c:2073
void * userData
Definition: parser.h:188
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 9979 of file parser.c.

9979  {
9980  if (xmlParseElementStart(ctxt) != 0)
9981  return;
9982 
9984  if (ctxt->instate == XML_PARSER_EOF)
9985  return;
9986 
9987  if (CUR == 0) {
9988  const xmlChar *name = ctxt->nameTab[ctxt->nameNr - 1];
9989  int line = ctxt->pushTab[ctxt->nameNr - 1].line;
9990  xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
9991  "Premature end of data in tag %s line %d\n",
9992  name, line, NULL);
9993  return;
9994  }
9995 
9996  xmlParseElementEnd(ctxt);
9997 }
xmlParserInputState instate
Definition: parser.h:225
Definition: parser.c:48
int line
Definition: parser.c:93
xmlStartTag * pushTab
Definition: parser.h:285
unsigned char xmlChar
Definition: xmlstring.h:28
#define CUR
Definition: parser.c:2074
#define NULL
Definition: types.h:112
Definition: name.c:38
const xmlChar ** nameTab
Definition: parser.h:234
static void xmlParseElementEnd(xmlParserCtxtPtr ctxt)
Definition: parser.c:10136
static int xmlParseElementStart(xmlParserCtxtPtr ctxt)
Definition: parser.c:10007
static void xmlParseContentInternal(xmlParserCtxtPtr ctxt)
Definition: parser.c:9865

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

6527  {
6528  /* stub left for API/ABI compat */
6529  return(xmlParseElementChildrenContentDeclPriv(ctxt, inputchk, 1));
6530 }
static xmlElementContentPtr xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk, int depth)
Definition: parser.c:6224

◆ xmlParseElementContentDecl()

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

Definition at line 6547 of file parser.c.

6548  {
6549 
6551  int inputid = ctxt->input->id;
6552  int res;
6553 
6554  *result = NULL;
6555 
6556  if (RAW != '(') {
6557  xmlFatalErrMsgStr(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED,
6558  "xmlParseElementContentDecl : %s '(' expected\n", name);
6559  return(-1);
6560  }
6561  NEXT;
6562  GROW;
6563  if (ctxt->instate == XML_PARSER_EOF)
6564  return(-1);
6565  SKIP_BLANKS;
6566  if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
6567  tree = xmlParseElementMixedContentDecl(ctxt, inputid);
6569  } else {
6570  tree = xmlParseElementChildrenContentDeclPriv(ctxt, inputid, 1);
6572  }
6573  SKIP_BLANKS;
6574  *result = tree;
6575  return(res);
6576 }
xmlParserInputState instate
Definition: parser.h:225
#define GROW
Definition: parser.c:2126
GLuint64EXT * result
Definition: glext.h:11304
struct _tree tree
#define SKIP_BLANKS
Definition: parser.c:2154
xmlParserInputPtr input
Definition: parser.h:201
xmlElementContentPtr xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk)
Definition: parser.c:6098
static xmlElementContentPtr xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk, int depth)
Definition: parser.c:6224
#define NEXT
Definition: parser.c:2156
#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:2086
#define CUR_PTR
Definition: parser.c:2076
#define RAW
Definition: parser.c:2073

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

6592  {
6593  const xmlChar *name;
6594  int ret = -1;
6596 
6597  /* GROW; done in the caller */
6598  if (CMP9(CUR_PTR, '<', '!', 'E', 'L', 'E', 'M', 'E', 'N', 'T')) {
6599  int inputid = ctxt->input->id;
6600 
6601  SKIP(9);
6602  if (SKIP_BLANKS == 0) {
6603  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6604  "Space required after 'ELEMENT'\n");
6605  return(-1);
6606  }
6607  name = xmlParseName(ctxt);
6608  if (name == NULL) {
6609  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6610  "xmlParseElementDecl: no name for Element\n");
6611  return(-1);
6612  }
6613  if (SKIP_BLANKS == 0) {
6614  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6615  "Space required after the element name\n");
6616  }
6617  if (CMP5(CUR_PTR, 'E', 'M', 'P', 'T', 'Y')) {
6618  SKIP(5);
6619  /*
6620  * Element must always be empty.
6621  */
6623  } else if ((RAW == 'A') && (NXT(1) == 'N') &&
6624  (NXT(2) == 'Y')) {
6625  SKIP(3);
6626  /*
6627  * Element is a generic container.
6628  */
6630  } else if (RAW == '(') {
6632  } else {
6633  /*
6634  * [ WFC: PEs in Internal Subset ] error handling.
6635  */
6636  if ((RAW == '%') && (ctxt->external == 0) &&
6637  (ctxt->inputNr == 1)) {
6638  xmlFatalErrMsg(ctxt, XML_ERR_PEREF_IN_INT_SUBSET,
6639  "PEReference: forbidden within markup decl in internal subset\n");
6640  } else {
6641  xmlFatalErrMsg(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED,
6642  "xmlParseElementDecl: 'EMPTY', 'ANY' or '(' expected\n");
6643  }
6644  return(-1);
6645  }
6646 
6647  SKIP_BLANKS;
6648 
6649  if (RAW != '>') {
6651  if (content != NULL) {
6653  }
6654  } else {
6655  if (inputid != ctxt->input->id) {
6656  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6657  "Element declaration doesn't start and stop in"
6658  " the same entity\n");
6659  }
6660 
6661  NEXT;
6662  if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
6663  (ctxt->sax->elementDecl != NULL)) {
6664  if (content != NULL)
6665  content->parent = NULL;
6666  ctxt->sax->elementDecl(ctxt->userData, name, ret,
6667  content);
6668  if ((content != NULL) && (content->parent == NULL)) {
6669  /*
6670  * this is a trick: if xmlAddElementDecl is called,
6671  * instead of copying the full tree it is plugged directly
6672  * if called from the parser. Avoid duplicating the
6673  * interfaces or change the API/ABI
6674  */
6676  }
6677  } else if (content != NULL) {
6679  }
6680  }
6681  }
6682  return(ret);
6683 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:389
#define NXT(val)
Definition: parser.c:2075
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2082
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2090
int external
Definition: parser.h:219
#define SKIP_BLANKS
Definition: parser.c:2154
int xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlElementContentPtr *result)
Definition: parser.c:6547
xmlParserInputPtr input
Definition: parser.h:201
int disableSAX
Definition: parser.h:239
content
Definition: atl_ax.c:993
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3343
XMLPUBFUN void XMLCALL xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1101
#define NEXT
Definition: parser.c:2156
int ret
xmlDocPtr myDoc
Definition: parser.h:189
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:187
#define SKIP(val)
Definition: parser.c:2097
#define NULL
Definition: types.h:112
Definition: name.c:38
#define CUR_PTR
Definition: parser.c:2076
#define RAW
Definition: parser.c:2073
void * userData
Definition: parser.h:188
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 6098 of file parser.c.

6098  {
6100  const xmlChar *elem = NULL;
6101 
6102  GROW;
6103  if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
6104  SKIP(7);
6105  SKIP_BLANKS;
6106  SHRINK;
6107  if (RAW == ')') {
6108  if (ctxt->input->id != inputchk) {
6109  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6110  "Element content declaration doesn't start and"
6111  " stop in the same entity\n");
6112  }
6113  NEXT;
6115  if (ret == NULL)
6116  return(NULL);
6117  if (RAW == '*') {
6118  ret->ocur = XML_ELEMENT_CONTENT_MULT;
6119  NEXT;
6120  }
6121  return(ret);
6122  }
6123  if ((RAW == '(') || (RAW == '|')) {
6125  if (ret == NULL) return(NULL);
6126  }
6127  while ((RAW == '|') && (ctxt->instate != XML_PARSER_EOF)) {
6128  NEXT;
6129  if (elem == NULL) {
6131  if (ret == NULL) {
6133  return(NULL);
6134  }
6135  ret->c1 = cur;
6136  if (cur != NULL)
6137  cur->parent = ret;
6138  cur = ret;
6139  } else {
6141  if (n == NULL) {
6143  return(NULL);
6144  }
6146  if (n->c1 != NULL)
6147  n->c1->parent = n;
6148  cur->c2 = n;
6149  if (n != NULL)
6150  n->parent = cur;
6151  cur = n;
6152  }
6153  SKIP_BLANKS;
6154  elem = xmlParseName(ctxt);
6155  if (elem == NULL) {
6156  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6157  "xmlParseElementMixedContentDecl : Name expected\n");
6159  return(NULL);
6160  }
6161  SKIP_BLANKS;
6162  GROW;
6163  }
6164  if ((RAW == ')') && (NXT(1) == '*')) {
6165  if (elem != NULL) {
6166  cur->c2 = xmlNewDocElementContent(ctxt->myDoc, elem,
6168  if (cur->c2 != NULL)
6169  cur->c2->parent = cur;
6170  }
6171  if (ret != NULL)
6172  ret->ocur = XML_ELEMENT_CONTENT_MULT;
6173  if (ctxt->input->id != inputchk) {
6174  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6175  "Element content declaration doesn't start and"
6176  " stop in the same entity\n");
6177  }
6178  SKIP(2);
6179  } else {
6182  return(NULL);
6183  }
6184 
6185  } else {
6187  }
6188  return(ret);
6189 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:389
xmlParserInputState instate
Definition: parser.h:225
#define GROW
Definition: parser.c:2126
#define NXT(val)
Definition: parser.c:2075
GLdouble n
Definition: glext.h:7729
XMLPUBFUN xmlElementContentPtr XMLCALL xmlNewDocElementContent(xmlDocPtr doc, const xmlChar *name, xmlElementContentType type)
Definition: valid.c:921
#define SKIP_BLANKS
Definition: parser.c:2154
xmlParserInputPtr input
Definition: parser.h:201
static size_t elem
Definition: string.c:68
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3343
XMLPUBFUN void XMLCALL xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1101
#define NEXT
Definition: parser.c:2156
int ret
xmlDocPtr myDoc
Definition: parser.h:189
unsigned char xmlChar
Definition: xmlstring.h:28
FxCollectionEntry * cur
#define SKIP(val)
Definition: parser.c:2097
#define NULL
Definition: types.h:112
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)
Definition: parser.c:2086
#define CUR_PTR
Definition: parser.c:2076
#define RAW
Definition: parser.c:2073
#define SHRINK
Definition: parser.c:2115

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

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

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

10350  {
10351  xmlChar *encoding = NULL;
10352 
10353  SKIP_BLANKS;
10354  if (CMP8(CUR_PTR, 'e', 'n', 'c', 'o', 'd', 'i', 'n', 'g')) {
10355  SKIP(8);
10356  SKIP_BLANKS;
10357  if (RAW != '=') {
10359  return(NULL);
10360  }
10361  NEXT;
10362  SKIP_BLANKS;
10363  if (RAW == '"') {
10364  NEXT;
10365  encoding = xmlParseEncName(ctxt);
10366  if (RAW != '"') {
10368  xmlFree((xmlChar *) encoding);
10369  return(NULL);
10370  } else
10371  NEXT;
10372  } else if (RAW == '\''){
10373  NEXT;
10374  encoding = xmlParseEncName(ctxt);
10375  if (RAW != '\'') {
10377  xmlFree((xmlChar *) encoding);
10378  return(NULL);
10379  } else
10380  NEXT;
10381  } else {
10383  }
10384 
10385  /*
10386  * Non standard parsing, allowing the user to ignore encoding
10387  */
10388  if (ctxt->options & XML_PARSE_IGNORE_ENC) {
10389  xmlFree((xmlChar *) encoding);
10390  return(NULL);
10391  }
10392 
10393  /*
10394  * UTF-16 encoding switch has already taken place at this stage,
10395  * more over the little-endian/big-endian selection is already done
10396  */
10397  if ((encoding != NULL) &&
10398  ((!xmlStrcasecmp(encoding, BAD_CAST "UTF-16")) ||
10399  (!xmlStrcasecmp(encoding, BAD_CAST "UTF16")))) {
10400  /*
10401  * If no encoding was passed to the parser, that we are
10402  * using UTF-16 and no decoder is present i.e. the
10403  * document is apparently UTF-8 compatible, then raise an
10404  * encoding mismatch fatal error
10405  */
10406  if ((ctxt->encoding == NULL) &&
10407  (ctxt->input->buf != NULL) &&
10408  (ctxt->input->buf->encoder == NULL)) {
10409  xmlFatalErrMsg(ctxt, XML_ERR_INVALID_ENCODING,
10410  "Document labelled UTF-16 but has UTF-8 content\n");
10411  }
10412  if (ctxt->encoding != NULL)
10413  xmlFree((xmlChar *) ctxt->encoding);
10414  ctxt->encoding = encoding;
10415  }
10416  /*
10417  * UTF-8 encoding is handled natively
10418  */
10419  else if ((encoding != NULL) &&
10420  ((!xmlStrcasecmp(encoding, BAD_CAST "UTF-8")) ||
10421  (!xmlStrcasecmp(encoding, BAD_CAST "UTF8")))) {
10422  if (ctxt->encoding != NULL)
10423  xmlFree((xmlChar *) ctxt->encoding);
10424  ctxt->encoding = encoding;
10425  }
10426  else if (encoding != NULL) {
10428 
10429  if (ctxt->input->encoding != NULL)
10430  xmlFree((xmlChar *) ctxt->input->encoding);
10431  ctxt->input->encoding = encoding;
10432 
10433  handler = xmlFindCharEncodingHandler((const char *) encoding);
10434  if (handler != NULL) {
10435  if (xmlSwitchToEncoding(ctxt, handler) < 0) {
10436  /* failed to convert */
10438  return(NULL);
10439  }
10440  } else {
10441  xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
10442  "Unsupported encoding %s\n", encoding);
10443  return(NULL);
10444  }
10445  }
10446  }
10447  return(encoding);
10448 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:389
XMLPUBFUN int XMLCALL xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
xmlChar * xmlParseEncName(xmlParserCtxtPtr ctxt)
Definition: parser.c:10285
#define SKIP_BLANKS
Definition: parser.c:2154
xmlParserInputPtr input
Definition: parser.h:201
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
#define NEXT
Definition: parser.c:2156
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1660
const xmlChar * encoding
Definition: parser.h:193
unsigned char xmlChar
Definition: xmlstring.h:28
ed encoding
Definition: write.c:2825
xmlCharEncodingHandlerPtr encoder
Definition: xmlIO.h:130
#define SKIP(val)
Definition: parser.c:2097
xmlParserInputBufferPtr buf
Definition: parser.h:56
#define NULL
Definition: types.h:112
const xmlChar * encoding
Definition: parser.h:73
#define CUR_PTR
Definition: parser.c:2076
#define RAW
Definition: parser.c:2073
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
XMLPUBFUN int XMLCALL xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:274
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2088

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

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

Referenced by xmlParseMarkupDecl().

◆ xmlParseEntityRef()

XMLPUBFUN xmlEntityPtr XMLCALL xmlParseEntityRef ( xmlParserCtxtPtr  ctxt)

xmlParseEntityRef: @ctxt: an XML parser context

parse ENTITY references declarations

[68] EntityRef ::= '&' Name ';'

[ WFC: Entity Declared ] In a document without any DTD, a document with only an internal DTD subset which contains no parameter entity references, or a document with "standalone='yes'", the Name given in the entity reference must match that in an entity declaration, except that well-formed documents need not declare any of the following entities: amp, lt, gt, apos, quot. The declaration of a parameter entity must precede any reference to it. Similarly, the declaration of a general entity must precede any reference to it which appears in a default value in an attribute-list declaration. Note that if entities are declared in the external subset or in external parameter entities, a non-validating processor is not obligated to read and process their declarations; for such documents, the rule that an entity must be declared is a well-formedness constraint only if standalone='yes'.

[ WFC: Parsed Entity ] An entity reference must not contain the name of an unparsed entity