ReactOS  0.4.13-dev-563-g0561610
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 identitier 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 1740 of file parser.c.

1741 {
1743 
1744  if (ctxt == NULL)
1745  return(NULL);
1746  if (ctxt->inputNr <= 0)
1747  return (NULL);
1748  ctxt->inputNr--;
1749  if (ctxt->inputNr > 0)
1750  ctxt->input = ctxt->inputTab[ctxt->inputNr - 1];
1751  else
1752  ctxt->input = NULL;
1753  ret = ctxt->inputTab[ctxt->inputNr];
1754  ctxt->inputTab[ctxt->inputNr] = NULL;
1755  return (ret);
1756 }
xmlParserInputPtr * inputTab
Definition: parser.h:202
xmlParserInputPtr input
Definition: parser.h:199
smooth NULL
Definition: ftsmooth.c:416
int ret

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

◆ inputPush()

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

1710 {
1711  if ((ctxt == NULL) || (value == NULL))
1712  return(-1);
1713  if (ctxt->inputNr >= ctxt->inputMax) {
1714  ctxt->inputMax *= 2;
1715  ctxt->inputTab =
1717  ctxt->inputMax *
1718  sizeof(ctxt->inputTab[0]));
1719  if (ctxt->inputTab == NULL) {
1720  xmlErrMemory(ctxt, NULL);
1722  ctxt->inputMax /= 2;
1723  value = NULL;
1724  return (-1);
1725  }
1726  }
1727  ctxt->inputTab[ctxt->inputNr] = value;
1728  ctxt->input = value;
1729  return (ctxt->inputNr++);
1730 }
xmlParserInputPtr * inputTab
Definition: parser.h:202
xmlParserInputPtr input
Definition: parser.h:199
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN void XMLCALL xmlFreeInputStream(xmlParserInputPtr input)
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
int inputMax
Definition: parser.h:201
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
GLsizei const GLfloat * value
Definition: glext.h:6069

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

◆ namePop()

namePop: @ctxt: an XML parser context

Pops the top element name from the name stack

Returns the name just removed

Definition at line 1936 of file parser.c.

1937 {
1938  const xmlChar *ret;
1939 
1940  if ((ctxt == NULL) || (ctxt->nameNr <= 0))
1941  return (NULL);
1942  ctxt->nameNr--;
1943  if (ctxt->nameNr > 0)
1944  ctxt->name = ctxt->nameTab[ctxt->nameNr - 1];
1945  else
1946  ctxt->name = NULL;
1947  ret = ctxt->nameTab[ctxt->nameNr];
1948  ctxt->nameTab[ctxt->nameNr] = NULL;
1949  return (ret);
1950 }
const xmlChar * name
Definition: parser.h:229
smooth NULL
Definition: ftsmooth.c:416
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
const xmlChar ** nameTab
Definition: parser.h:232

Referenced by xmlParseElement().

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

1906 {
1907  if (ctxt == NULL) return (-1);
1908 
1909  if (ctxt->nameNr >= ctxt->nameMax) {
1910  const xmlChar * *tmp;
1911  tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,
1912  ctxt->nameMax * 2 *
1913  sizeof(ctxt->nameTab[0]));
1914  if (tmp == NULL) {
1915  goto mem_error;
1916  }
1917  ctxt->nameTab = tmp;
1918  ctxt->nameMax *= 2;
1919  }
1920  ctxt->nameTab[ctxt->nameNr] = value;
1921  ctxt->name = value;
1922  return (ctxt->nameNr++);
1923 mem_error:
1924  xmlErrMemory(ctxt, NULL);
1925  return (-1);
1926 }
const xmlChar * name
Definition: parser.h:229
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlReallocFunc xmlRealloc
Definition: globals.h:249
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
unsigned char xmlChar
Definition: xmlstring.h:28
GLsizei const GLfloat * value
Definition: glext.h:6069
const xmlChar ** nameTab
Definition: parser.h:232

Referenced by xmlParseElement().

◆ nodePop()

nodePop: @ctxt: an XML parser context

Pops the top element node from the node stack

Returns the node just removed

Definition at line 1805 of file parser.c.

1806 {
1807  xmlNodePtr ret;
1808 
1809  if (ctxt == NULL) return(NULL);
1810  if (ctxt->nodeNr <= 0)
1811  return (NULL);
1812  ctxt->nodeNr--;
1813  if (ctxt->nodeNr > 0)
1814  ctxt->node = ctxt->nodeTab[ctxt->nodeNr - 1];
1815  else
1816  ctxt->node = NULL;
1817  ret = ctxt->nodeTab[ctxt->nodeNr];
1818  ctxt->nodeTab[ctxt->nodeNr] = NULL;
1819  return (ret);
1820 }
xmlNodePtr * nodeTab
Definition: parser.h:208
smooth NULL
Definition: ftsmooth.c:416
xmlNodePtr node
Definition: parser.h:205
Definition: tree.h:489
int ret

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

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

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

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

Referenced by xmlParseAttribute2().

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

900  {
901  if (out == NULL) return(0);
902  /* the len parameter is ignored */
903  if (val >= 0x80) {
904  return(xmlCopyCharMultiByte (out, val));
905  }
906  *out = (xmlChar) val;
907  return 1;
908 }
int xmlCopyCharMultiByte(xmlChar *out, int val)
smooth NULL
Definition: ftsmooth.c:416
GLuint GLfloat * val
Definition: glext.h:7180
static FILE * out
Definition: regtests2xml.c:44
unsigned char xmlChar
Definition: xmlstring.h:28

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

857  {
858  if (out == NULL) return(0);
859  /*
860  * We are supposed to handle UTF8, check it's valid
861  * From rfc2044: encoding of the Unicode values on UTF-8:
862  *
863  * UCS-4 range (hex.) UTF-8 octet sequence (binary)
864  * 0000 0000-0000 007F 0xxxxxxx
865  * 0000 0080-0000 07FF 110xxxxx 10xxxxxx
866  * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
867  */
868  if (val >= 0x80) {
869  xmlChar *savedout = out;
870  int bits;
871  if (val < 0x800) { *out++= (val >> 6) | 0xC0; bits= 0; }
872  else if (val < 0x10000) { *out++= (val >> 12) | 0xE0; bits= 6;}
873  else if (val < 0x110000) { *out++= (val >> 18) | 0xF0; bits= 12; }
874  else {
875  xmlErrEncodingInt(NULL, XML_ERR_INVALID_CHAR,
876  "Internal error, xmlCopyCharMultiByte 0x%X out of bound\n",
877  val);
878  return(0);
879  }
880  for ( ; bits >= 0; bits-= 6)
881  *out++= ((val >> bits) & 0x3F) | 0x80 ;
882  return (out - savedout);
883  }
884  *out = (xmlChar) val;
885  return 1;
886 }
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
smooth NULL
Definition: ftsmooth.c:416
GLuint GLfloat * val
Definition: glext.h:7180
static FILE * out
Definition: regtests2xml.c:44
unsigned char xmlChar
Definition: xmlstring.h:28

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

14058  {
14060 
14061 }
static xmlParserCtxtPtr xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID, const xmlChar *base, xmlParserCtxtPtr pctx)
Definition: parser.c:13988
smooth NULL
Definition: ftsmooth.c:416
#define ID
Definition: ruserpass.c:36

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

14124 {
14125  return(xmlCreateURLParserCtxt(filename, 0));
14126 }
const char * filename
Definition: ioapi.h:135
xmlParserCtxtPtr xmlCreateURLParserCtxt(const char *filename, int options)
Definition: parser.c:14081

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

14369  {
14370  xmlParserCtxtPtr ctxt;
14373 
14374  if (buffer == NULL)
14375  return(NULL);
14376  if (size <= 0)
14377  return(NULL);
14378 
14379  ctxt = xmlNewParserCtxt();
14380  if (ctxt == NULL)
14381  return(NULL);
14382 
14383  /* TODO: xmlParserInputBufferCreateStatic, requires some serious changes */
14385  if (buf == NULL) {
14386  xmlFreeParserCtxt(ctxt);
14387  return(NULL);
14388  }
14389 
14390  input = xmlNewInputStream(ctxt);
14391  if (input == NULL) {
14393  xmlFreeParserCtxt(ctxt);
14394  return(NULL);
14395  }
14396 
14397  input->filename = NULL;
14398  input->buf = buf;
14399  xmlBufResetInput(input->buf->buffer, input);
14400 
14401  inputPush(ctxt, input);
14402  return(ctxt);
14403 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1709
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBFUN void XMLCALL xmlFreeParserInputBuffer(xmlParserInputBufferPtr in)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
GLuint buffer
Definition: glext.h:5915
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1283
XMLPUBFUN xmlParserInputBufferPtr XMLCALL xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc)
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
GLenum GLenum GLenum input
Definition: glext.h:9031
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlNewInputStream(xmlParserCtxtPtr ctxt)

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

◆ xmlCreateURLParserCtxt()

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

14082 {
14083  xmlParserCtxtPtr ctxt;
14084  xmlParserInputPtr inputStream;
14085  char *directory = NULL;
14086 
14087  ctxt = xmlNewParserCtxt();
14088  if (ctxt == NULL) {
14089  xmlErrMemory(NULL, "cannot allocate parser context");
14090  return(NULL);
14091  }
14092 
14093  if (options)
14095  ctxt->linenumbers = 1;
14096 
14097  inputStream = xmlLoadExternalEntity(filename, NULL, ctxt);
14098  if (inputStream == NULL) {
14099  xmlFreeParserCtxt(ctxt);
14100  return(NULL);
14101  }
14102 
14103  inputPush(ctxt, inputStream);
14104  if ((ctxt->directory == NULL) && (directory == NULL))
14106  if ((ctxt->directory == NULL) && (directory != NULL))
14107  ctxt->directory = directory;
14108 
14109  return(ctxt);
14110 }
int inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
Definition: parser.c:1709
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
XMLPUBFUN void XMLCALL xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
const char * filename
Definition: ioapi.h:135
int linenumbers
Definition: parser.h:259
smooth NULL
Definition: ftsmooth.c:416
static int xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
Definition: parser.c:15021
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
XMLPUBFUN xmlParserInputPtr XMLCALL xmlLoadExternalEntity(const char *URL, const char *ID, xmlParserCtxtPtr ctxt)
char * directory
Definition: parser.h:226
XMLPUBFUN xmlParserCtxtPtr XMLCALL xmlNewParserCtxt(void)

Referenced by xmlCreateFileParserCtxt(), and xmlReadFile().

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

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

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:422
Definition: actctx.c:371
WCHAR * name
Definition: actctx.c:389
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
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
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
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBFUN char *XMLCALL xmlParserGetDirectory(const char *filename)
int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input)
Definition: buf.c:1283
const char * filename
Definition: ioapi.h:135
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
XMLPUBFUN xmlChar *XMLCALL xmlCanonicPath(const xmlChar *path)
Definition: uri.c:2370
smooth NULL
Definition: ftsmooth.c:416
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
char * directory
Definition: parser.h:226
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:312
smooth NULL
Definition: ftsmooth.c:416
void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
GLenum GLenum GLenum input
Definition: glext.h:9031
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:422
GLuint buffer
Definition: glext.h:5915
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
smooth NULL
Definition: ftsmooth.c:416
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
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 
523  ctxt->nbChars++;
524  } else {
525  /*
526  * Assume it's a fixed length encoding (1) with
527  * a compatible encoding for the ASCII set, since
528  * XML constructs only use < 128 chars
529  */
530 
531  if (*(ctxt->input->cur) == '\n') {
532  ctxt->input->line++; ctxt->input->col = 1;
533  } else
534  ctxt->input->col++;
535  ctxt->input->cur++;
536  ctxt->nbChars++;
537  }
538  if (*ctxt->input->cur == 0)
540  return;
541 encoding_error:
542  /*
543  * If we detect an UTF8 error that probably mean that the
544  * input encoding didn't get properly advertised in the
545  * declaration header. Report the error and switch the encoding
546  * to ISO-Latin-1 (if you don't like this policy, just declare the
547  * encoding !)
548  */
549  if ((ctxt == NULL) || (ctxt->input == NULL) ||
550  (ctxt->input->end - ctxt->input->cur < 4)) {
552  "Input is not proper UTF-8, indicate encoding !\n",
553  NULL, NULL);
554  } else {
555  char buffer[150];
556 
557  snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
558  ctxt->input->cur[0], ctxt->input->cur[1],
559  ctxt->input->cur[2], ctxt->input->cur[3]);
561  "Input is not proper UTF-8, indicate encoding !\n%s",
562  BAD_CAST buffer, NULL);
563  }
565  ctxt->input->cur++;
566  return;
567 }
xmlParserInputState instate
Definition: parser.h:223
#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:12483
long nbChars
Definition: parser.h:234
xmlParserInputPtr input
Definition: parser.h:199
smooth NULL
Definition: ftsmooth.c:416
#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
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 5899 of file parser.c.

5899  {
5900  const xmlChar *elemName;
5901  const xmlChar *attrName;
5903 
5904  if (CMP9(CUR_PTR, '<', '!', 'A', 'T', 'T', 'L', 'I', 'S', 'T')) {
5905  int inputid = ctxt->input->id;
5906 
5907  SKIP(9);
5908  if (SKIP_BLANKS == 0) {
5909  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5910  "Space required after '<!ATTLIST'\n");
5911  }
5912  elemName = xmlParseName(ctxt);
5913  if (elemName == NULL) {
5914  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5915  "ATTLIST: no name for Element\n");
5916  return;
5917  }
5918  SKIP_BLANKS;
5919  GROW;
5920  while ((RAW != '>') && (ctxt->instate != XML_PARSER_EOF)) {
5921  int type;
5922  int def;
5923  xmlChar *defaultValue = NULL;
5924 
5925  GROW;
5926  tree = NULL;
5927  attrName = xmlParseName(ctxt);
5928  if (attrName == NULL) {
5929  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5930  "ATTLIST: no name for Attribute\n");
5931  break;
5932  }
5933  GROW;
5934  if (SKIP_BLANKS == 0) {
5935  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5936  "Space required after the attribute name\n");
5937  break;
5938  }
5939 
5940  type = xmlParseAttributeType(ctxt, &tree);
5941  if (type <= 0) {
5942  break;
5943  }
5944 
5945  GROW;
5946  if (SKIP_BLANKS == 0) {
5947  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5948  "Space required after the attribute type\n");
5949  if (tree != NULL)
5951  break;
5952  }
5953 
5954  def = xmlParseDefaultDecl(ctxt, &defaultValue);
5955  if (def <= 0) {
5956  if (defaultValue != NULL)
5957  xmlFree(defaultValue);
5958  if (tree != NULL)
5960  break;
5961  }
5962  if ((type != XML_ATTRIBUTE_CDATA) && (defaultValue != NULL))
5963  xmlAttrNormalizeSpace(defaultValue, defaultValue);
5964 
5965  GROW;
5966  if (RAW != '>') {
5967  if (SKIP_BLANKS == 0) {
5968  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5969  "Space required after the attribute default value\n");
5970  if (defaultValue != NULL)
5971  xmlFree(defaultValue);
5972  if (tree != NULL)
5974  break;
5975  }
5976  }
5977  if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
5978  (ctxt->sax->attributeDecl != NULL))
5979  ctxt->sax->attributeDecl(ctxt->userData, elemName, attrName,
5980  type, def, defaultValue, tree);
5981  else if (tree != NULL)
5983 
5984  if ((ctxt->sax2) && (defaultValue != NULL) &&
5985  (def != XML_ATTRIBUTE_IMPLIED) &&
5986  (def != XML_ATTRIBUTE_REQUIRED)) {
5987  xmlAddDefAttrs(ctxt, elemName, attrName, defaultValue);
5988  }
5989  if (ctxt->sax2) {
5990  xmlAddSpecialAttr(ctxt, elemName, attrName, type);
5991  }
5992  if (defaultValue != NULL)
5993  xmlFree(defaultValue);
5994  GROW;
5995  }
5996  if (RAW == '>') {
5997  if (inputid != ctxt->input->id) {
5998  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
5999  "Attribute list declaration doesn't start and"
6000  " stop in the same entity\n");
6001  }
6002  NEXT;
6003  }
6004  }
6005 }
static void xmlAddDefAttrs(xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, const xmlChar *value)
Definition: parser.c:1206
int xmlParseDefaultDecl(xmlParserCtxtPtr ctxt, xmlChar **value)
Definition: parser.c:5605
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2073
struct _tree tree
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2036
#define SKIP_BLANKS
Definition: parser.c:2101
int xmlParseAttributeType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
Definition: parser.c:5857
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
smooth NULL
Definition: ftsmooth.c:416
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3281
static xmlChar * xmlAttrNormalizeSpace(const xmlChar *src, xmlChar *dst)
Definition: parser.c:1116
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
#define NEXT
Definition: parser.c:2103
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
#define SKIP(val)
Definition: parser.c:2043
static void xmlAddSpecialAttr(xmlParserCtxtPtr ctxt, const xmlChar *fullname, const xmlChar *fullattr, int type)
Definition: parser.c:1317
#define CUR_PTR
Definition: parser.c:2022
#define RAW
Definition: parser.c:2019
void * userData
Definition: parser.h:186
XMLPUBFUN void XMLCALL xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1788

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

5857  {
5858  SHRINK;
5859  if (CMP5(CUR_PTR, 'C', 'D', 'A', 'T', 'A')) {
5860  SKIP(5);
5861  return(XML_ATTRIBUTE_CDATA);
5862  } else if (CMP6(CUR_PTR, 'I', 'D', 'R', 'E', 'F', 'S')) {
5863  SKIP(6);
5864  return(XML_ATTRIBUTE_IDREFS);
5865  } else if (CMP5(CUR_PTR, 'I', 'D', 'R', 'E', 'F')) {
5866  SKIP(5);
5867  return(XML_ATTRIBUTE_IDREF);
5868  } else if ((RAW == 'I') && (NXT(1) == 'D')) {
5869  SKIP(2);
5870  return(XML_ATTRIBUTE_ID);
5871  } else if (CMP6(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'Y')) {
5872  SKIP(6);
5873  return(XML_ATTRIBUTE_ENTITY);
5874  } else if (CMP8(CUR_PTR, 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S')) {
5875  SKIP(8);
5876  return(XML_ATTRIBUTE_ENTITIES);
5877  } else if (CMP8(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S')) {
5878  SKIP(8);
5879  return(XML_ATTRIBUTE_NMTOKENS);
5880  } else if (CMP7(CUR_PTR, 'N', 'M', 'T', 'O', 'K', 'E', 'N')) {
5881  SKIP(7);
5882  return(XML_ATTRIBUTE_NMTOKEN);
5883  }
5884  return(xmlParseEnumeratedType(ctxt, tree));
5885 }
#define NXT(val)
Definition: parser.c:2021
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2028
#define CMP6(s, c1, c2, c3, c4, c5, c6)
Definition: parser.c:2030
int xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree)
Definition: parser.c:5794
#define SKIP(val)
Definition: parser.c:2043
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)
Definition: parser.c:2032
#define CUR_PTR
Definition: parser.c:2022
#define RAW
Definition: parser.c:2019
#define SHRINK
Definition: parser.c:2062
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2034

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

4118  {
4119  if ((ctxt == NULL) || (ctxt->input == NULL)) return(NULL);
4120  return(xmlParseAttValueInternal(ctxt, NULL, NULL, 0));
4121 }
xmlParserInputPtr input
Definition: parser.h:199
smooth NULL
Definition: ftsmooth.c:416
static xmlChar * xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc, int normalize)
Definition: parser.c:8844

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

9703  {
9704  xmlChar *buf = NULL;
9705  int len = 0;
9707  int r, rl;
9708  int s, sl;
9709  int cur, l;
9710  int count = 0;
9711 
9712  /* Check 2.6.0 was NXT(0) not RAW */
9713  if (CMP9(CUR_PTR, '<', '!', '[', 'C', 'D', 'A', 'T', 'A', '[')) {
9714  SKIP(9);
9715  } else
9716  return;
9717 
9719  r = CUR_CHAR(rl);
9720  if (!IS_CHAR(r)) {
9722  ctxt->instate = XML_PARSER_CONTENT;
9723  return;
9724  }
9725  NEXTL(rl);
9726  s = CUR_CHAR(sl);
9727  if (!IS_CHAR(s)) {
9729  ctxt->instate = XML_PARSER_CONTENT;
9730  return;
9731  }
9732  NEXTL(sl);
9733  cur = CUR_CHAR(l);
9734  buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
9735  if (buf == NULL) {
9736  xmlErrMemory(ctxt, NULL);
9737  return;
9738  }
9739  while (IS_CHAR(cur) &&
9740  ((r != ']') || (s != ']') || (cur != '>'))) {
9741  if (len + 5 >= size) {
9742  xmlChar *tmp;
9743 
9744  if ((size > XML_MAX_TEXT_LENGTH) &&
9745  ((ctxt->options & XML_PARSE_HUGE) == 0)) {
9746  xmlFatalErrMsgStr(ctxt, XML_ERR_CDATA_NOT_FINISHED,
9747  "CData section too big found", NULL);
9748  xmlFree (buf);
9749  return;
9750  }
9751  tmp = (xmlChar *) xmlRealloc(buf, size * 2 * sizeof(xmlChar));
9752  if (tmp == NULL) {
9753  xmlFree(buf);
9754  xmlErrMemory(ctxt, NULL);
9755  return;
9756  }
9757  buf = tmp;
9758  size *= 2;
9759  }
9760  COPY_BUF(rl,buf,len,r);
9761  r = s;
9762  rl = sl;
9763  s = cur;
9764  sl = l;
9765  count++;
9766  if (count > 50) {
9767  GROW;
9768  if (ctxt->instate == XML_PARSER_EOF) {
9769  xmlFree(buf);
9770  return;
9771  }
9772  count = 0;
9773  }
9774  NEXTL(l);
9775  cur = CUR_CHAR(l);
9776  }
9777  buf[len] = 0;
9778  ctxt->instate = XML_PARSER_CONTENT;
9779  if (cur != '>') {
9780  xmlFatalErrMsgStr(ctxt, XML_ERR_CDATA_NOT_FINISHED,
9781  "CData section not finished\n%.50s\n", buf);
9782  xmlFree(buf);
9783  return;
9784  }
9785  NEXTL(l);
9786 
9787  /*
9788  * OK the buffer is to be consumed as cdata.
9789  */
9790  if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
9791  if (ctxt->sax->cdataBlock != NULL)
9792  ctxt->sax->cdataBlock(ctxt->userData, buf, len);
9793  else if (ctxt->sax->characters != NULL)
9794  ctxt->sax->characters(ctxt->userData, buf, len);
9795  }
9796  xmlFree(buf);
9797 }
#define COPY_BUF(l, b, i, v)
Definition: parser.c:2123
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:350
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
Definition: globals.h:248
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2073
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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:2036
int disableSAX
Definition: parser.h:237
#define XML_PARSER_BUFFER_SIZE
Definition: parser.c:248
#define IS_CHAR(c)
smooth NULL
Definition: ftsmooth.c:416
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:2120
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
struct _xmlSAXHandler * sax
Definition: parser.h:185
#define NEXTL(l)
Definition: parser.c:2113
#define SKIP(val)
Definition: parser.c:2043
#define CUR_PTR
Definition: parser.c:2022
void * userData
Definition: parser.h:186

Referenced by xmlParseContent().

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

4355  {
4356  const xmlChar *in;
4357  int nbchar = 0;
4358  int line = ctxt->input->line;
4359  int col = ctxt->input->col;
4360  int ccol;
4361 
4362  SHRINK;
4363  GROW;
4364  /*
4365  * Accelerated common case where input don't need to be
4366  * modified before passing it to the handler.
4367  */
4368  if (!cdata) {
4369  in = ctxt->input->cur;
4370  do {
4371 get_more_space:
4372  while (*in == 0x20) { in++; ctxt->input->col++; }
4373  if (*in == 0xA) {
4374  do {
4375  ctxt->input->line++; ctxt->input->col = 1;
4376  in++;
4377  } while (*in == 0xA);
4378  goto get_more_space;
4379  }
4380  if (*in == '<') {
4381  nbchar = in - ctxt->input->cur;
4382  if (nbchar > 0) {
4383  const xmlChar *tmp = ctxt->input->cur;
4384  ctxt->input->cur = in;
4385 
4386  if ((ctxt->sax != NULL) &&
4387  (ctxt->sax->ignorableWhitespace !=
4388  ctxt->sax->characters)) {
4389  if (areBlanks(ctxt, tmp, nbchar, 1)) {
4390  if (ctxt->sax->ignorableWhitespace != NULL)
4391  ctxt->sax->ignorableWhitespace(ctxt->userData,
4392  tmp, nbchar);
4393  } else {
4394  if (ctxt->sax->characters != NULL)
4395  ctxt->sax->characters(ctxt->userData,
4396  tmp, nbchar);
4397  if (*ctxt->space == -1)
4398  *ctxt->space = -2;
4399  }
4400  } else if ((ctxt->sax != NULL) &&
4401  (ctxt->sax->characters != NULL)) {
4402  ctxt->sax->characters(ctxt->userData,
4403  tmp, nbchar);
4404  }
4405  }
4406  return;
4407  }
4408 
4409 get_more:
4410  ccol = ctxt->input->col;
4411  while (test_char_data[*in]) {
4412  in++;
4413  ccol++;
4414  }
4415  ctxt->input->col = ccol;
4416  if (*in == 0xA) {
4417  do {
4418  ctxt->input->line++; ctxt->input->col = 1;
4419  in++;
4420  } while (*in == 0xA);
4421  goto get_more;
4422  }
4423  if (*in == ']') {
4424  if ((in[1] == ']') && (in[2] == '>')) {
4426  ctxt->input->cur = in + 1;
4427  return;
4428  }
4429  in++;
4430  ctxt->input->col++;
4431  goto get_more;
4432  }
4433  nbchar = in - ctxt->input->cur;
4434  if (nbchar > 0) {
4435  if ((ctxt->sax != NULL) &&
4436  (ctxt->sax->ignorableWhitespace !=
4437  ctxt->sax->characters) &&
4438  (IS_BLANK_CH(*ctxt->input->cur))) {
4439  const xmlChar *tmp = ctxt->input->cur;
4440  ctxt->input->cur = in;
4441 
4442  if (areBlanks(ctxt, tmp, nbchar, 0)) {
4443  if (ctxt->sax->ignorableWhitespace != NULL)
4444  ctxt->sax->ignorableWhitespace(ctxt->userData,
4445  tmp, nbchar);
4446  } else {
4447  if (ctxt->sax->characters != NULL)
4448  ctxt->sax->characters(ctxt->userData,
4449  tmp, nbchar);
4450  if (*ctxt->space == -1)
4451  *ctxt->space = -2;
4452  }
4453  line = ctxt->input->line;
4454  col = ctxt->input->col;
4455  } else if (ctxt->sax != NULL) {
4456  if (ctxt->sax->characters != NULL)
4457  ctxt->sax->characters(ctxt->userData,
4458  ctxt->input->cur, nbchar);
4459  line = ctxt->input->line;
4460  col = ctxt->input->col;
4461  }
4462  /* something really bad happened in the SAX callback */
4463  if (ctxt->instate != XML_PARSER_CONTENT)
4464  return;
4465  }
4466  ctxt->input->cur = in;
4467  if (*in == 0xD) {
4468  in++;
4469  if (*in == 0xA) {
4470  ctxt->input->cur = in;
4471  in++;
4472  ctxt->input->line++; ctxt->input->col = 1;
4473  continue; /* while */
4474  }
4475  in--;
4476  }
4477  if (*in == '<') {
4478  return;
4479  }
4480  if (*in == '&') {
4481  return;
4482  }
4483  SHRINK;
4484  GROW;
4485  if (ctxt->instate == XML_PARSER_EOF)
4486  return;
4487  in = ctxt->input->cur;
4488  } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09));
4489  nbchar = 0;
4490  }
4491  ctxt->input->line = line;
4492  ctxt->input->col = col;
4493  xmlParseCharDataComplex(ctxt, cdata);
4494 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:350
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2073
const xmlChar * cur
Definition: parser.h:61
static void xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata)
Definition: parser.c:4506
xmlParserInputPtr input
Definition: parser.h:199
#define IS_BLANK_CH(c)
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
static const unsigned char test_char_data[256]
Definition: parser.c:4303
char line[200]
Definition: main.c:97
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
GLuint in
Definition: glext.h:9616
static int areBlanks(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, int blank_chars)
Definition: parser.c:2805
#define SHRINK
Definition: parser.c:2062
int * space
Definition: parser.h:244
void * userData
Definition: parser.h:186

Referenced by xmlParseContent().

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

2283  {
2284  unsigned int val = 0;
2285  int count = 0;
2286  unsigned int outofrange = 0;
2287 
2288  /*
2289  * Using RAW/CUR/NEXT is okay since we are working on ASCII range here
2290  */
2291  if ((RAW == '&') && (NXT(1) == '#') &&
2292  (NXT(2) == 'x')) {
2293  SKIP(3);
2294  GROW;
2295  while (RAW != ';') { /* loop blocked by count */
2296  if (count++ > 20) {
2297  count = 0;
2298  GROW;
2299  if (ctxt->instate == XML_PARSER_EOF)
2300  return(0);
2301  }
2302  if ((RAW >= '0') && (RAW <= '9'))
2303  val = val * 16 + (CUR - '0');
2304  else if ((RAW >= 'a') && (RAW <= 'f') && (count < 20))
2305  val = val * 16 + (CUR - 'a') + 10;
2306  else if ((RAW >= 'A') && (RAW <= 'F') && (count < 20))
2307  val = val * 16 + (CUR - 'A') + 10;
2308  else {
2310  val = 0;
2311  break;
2312  }
2313  if (val > 0x10FFFF)
2314  outofrange = val;
2315 
2316  NEXT;
2317  count++;
2318  }
2319  if (RAW == ';') {
2320  /* on purpose to avoid reentrancy problems with NEXT and SKIP */
2321  ctxt->input->col++;
2322  ctxt->nbChars ++;
2323  ctxt->input->cur++;
2324  }
2325  } else if ((RAW == '&') && (NXT(1) == '#')) {
2326  SKIP(2);
2327  GROW;
2328  while (RAW != ';') { /* loop blocked by count */
2329  if (count++ > 20) {
2330  count = 0;
2331  GROW;
2332  if (ctxt->instate == XML_PARSER_EOF)
2333  return(0);
2334  }
2335  if ((RAW >= '0') && (RAW <= '9'))
2336  val = val * 10 + (CUR - '0');
2337  else {
2339  val = 0;
2340  break;
2341  }
2342  if (val > 0x10FFFF)
2343  outofrange = val;
2344 
2345  NEXT;
2346  count++;
2347  }
2348  if (RAW == ';') {
2349  /* on purpose to avoid reentrancy problems with NEXT and SKIP */
2350  ctxt->input->col++;
2351  ctxt->nbChars ++;
2352  ctxt->input->cur++;
2353  }
2354  } else {
2356  }
2357 
2358  /*
2359  * [ WFC: Legal Character ]
2360  * Characters referred to using character references must match the
2361  * production for Char.
2362  */
2363  if ((IS_CHAR(val) && (outofrange == 0))) {
2364  return(val);
2365  } else {
2366  xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
2367  "xmlParseCharRef: invalid xmlChar value %d\n",
2368  val);
2369  }
2370  return(0);
2371 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:350
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2073
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define NXT(val)
Definition: parser.c:2021
const xmlChar * cur
Definition: parser.h:61
long nbChars
Definition: parser.h:234
xmlParserInputPtr input
Definition: parser.h:199
#define IS_CHAR(c)
smooth NULL
Definition: ftsmooth.c:416
GLuint GLfloat * val
Definition: glext.h:7180
#define NEXT
Definition: parser.c:2103
#define SKIP(val)
Definition: parser.c:2043
#define CUR
Definition: parser.c:2020
#define RAW
Definition: parser.c:2019

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

4812  {
4813  xmlChar *buf = NULL;
4814  size_t size = XML_PARSER_BUFFER_SIZE;
4815  size_t len = 0;
4817  const xmlChar *in;
4818  size_t nbchar = 0;
4819  int ccol;
4820  int inputid;
4821 
4822  /*
4823  * Check that there is a comment right here.
4824  */
4825  if ((RAW != '<') || (NXT(1) != '!') ||
4826  (NXT(2) != '-') || (NXT(3) != '-')) return;
4827  state = ctxt->instate;
4828  ctxt->instate = XML_PARSER_COMMENT;
4829  inputid = ctxt->input->id;
4830  SKIP(4);
4831  SHRINK;
4832  GROW;
4833 
4834  /*
4835  * Accelerated common case where input don't need to be
4836  * modified before passing it to the handler.
4837  */
4838  in = ctxt->input->cur;
4839  do {
4840  if (*in == 0xA) {
4841  do {
4842  ctxt->input->line++; ctxt->input->col = 1;
4843  in++;
4844  } while (*in == 0xA);
4845  }
4846 get_more:
4847  ccol = ctxt->input->col;
4848  while (((*in > '-') && (*in <= 0x7F)) ||
4849  ((*in >= 0x20) && (*in < '-')) ||
4850  (*in == 0x09)) {
4851  in++;
4852  ccol++;
4853  }
4854  ctxt->input->col = ccol;
4855  if (*in == 0xA) {
4856  do {
4857  ctxt->input->line++; ctxt->input->col = 1;
4858  in++;
4859  } while (*in == 0xA);
4860  goto get_more;
4861  }
4862  nbchar = in - ctxt->input->cur;
4863  /*
4864  * save current set of data
4865  */
4866  if (nbchar > 0) {
4867  if ((ctxt->sax != NULL) &&
4868  (ctxt->sax->comment != NULL)) {
4869  if (buf == NULL) {
4870  if ((*in == '-') && (in[1] == '-'))
4871  size = nbchar + 1;
4872  else
4873  size = XML_PARSER_BUFFER_SIZE + nbchar;
4874  buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
4875  if (buf == NULL) {
4876  xmlErrMemory(ctxt, NULL);
4877  ctxt->instate = state;
4878  return;
4879  }
4880  len = 0;
4881  } else if (len + nbchar + 1 >= size) {
4882  xmlChar *new_buf;
4883  size += len + nbchar + XML_PARSER_BUFFER_SIZE;
4884  new_buf = (xmlChar *) xmlRealloc(buf,
4885  size * sizeof(xmlChar));
4886  if (new_buf == NULL) {
4887  xmlFree (buf);
4888  xmlErrMemory(ctxt, NULL);
4889  ctxt->instate = state;
4890  return;
4891  }
4892  buf = new_buf;
4893  }
4894  memcpy(&buf[len], ctxt->input->cur, nbchar);
4895  len += nbchar;
4896  buf[len] = 0;
4897  }
4898  }
4899  if ((len > XML_MAX_TEXT_LENGTH) &&
4900  ((ctxt->options & XML_PARSE_HUGE) == 0)) {
4901  xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
4902  "Comment too big found", NULL);
4903  xmlFree (buf);
4904  return;
4905  }
4906  ctxt->input->cur = in;
4907  if (*in == 0xA) {
4908  in++;
4909  ctxt->input->line++; ctxt->input->col = 1;
4910  }
4911  if (*in == 0xD) {
4912  in++;
4913  if (*in == 0xA) {
4914  ctxt->input->cur = in;
4915  in++;
4916  ctxt->input->line++; ctxt->input->col = 1;
4917  continue; /* while */
4918  }
4919  in--;
4920  }
4921  SHRINK;
4922  GROW;
4923  if (ctxt->instate == XML_PARSER_EOF) {
4924  xmlFree(buf);
4925  return;
4926  }
4927  in = ctxt->input->cur;
4928  if (*in == '-') {
4929  if (in[1] == '-') {
4930  if (in[2] == '>') {
4931  if (ctxt->input->id != inputid) {
4932  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
4933  "comment doesn't start and stop in the"
4934  " same entity\n");
4935  }
4936  SKIP(3);
4937  if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
4938  (!ctxt->disableSAX)) {
4939  if (buf != NULL)
4940  ctxt->sax->comment(ctxt->userData, buf);
4941  else
4942  ctxt->sax->comment(ctxt->userData, BAD_CAST "");
4943  }
4944  if (buf != NULL)
4945  xmlFree(buf);
4946  if (ctxt->instate != XML_PARSER_EOF)
4947  ctxt->instate = state;
4948  return;
4949  }
4950  if (buf != NULL) {
4951  xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
4952  "Double hyphen within comment: "
4953  "<!--%.50s\n",
4954  buf);
4955  } else
4956  xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
4957  "Double hyphen within comment\n", NULL);
4958  in++;
4959  ctxt->input->col++;
4960  }
4961  in++;
4962  ctxt->input->col++;
4963  goto get_more;
4964  }
4965  } while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09));
4967  ctxt->instate = state;
4968  return;
4969 }
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
Definition: globals.h:248
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2073
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define NXT(val)
Definition: parser.c:2021
const xmlChar * cur
Definition: parser.h:61
#define XML_MAX_TEXT_LENGTH
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
#define XML_PARSER_BUFFER_SIZE
Definition: parser.c:248
xmlParserInputState
Definition: parser.h:112
smooth NULL
Definition: ftsmooth.c:416
#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:185
#define SKIP(val)
Definition: parser.c:2043
GLuint in
Definition: glext.h:9616
static void xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, size_t len, size_t size)
Definition: parser.c:4678
#define RAW
Definition: parser.c:2019
#define SHRINK
Definition: parser.c:2062
void * userData
Definition: parser.h:186

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

◆ xmlParseContent()

XMLPUBFUN void XMLCALL xmlParseContent ( xmlParserCtxtPtr  ctxt)

xmlParseContent: @ctxt: an XML parser context

Parse a content:

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

Definition at line 9809 of file parser.c.

9809  {
9810  GROW;
9811  while ((RAW != 0) &&
9812  ((RAW != '<') || (NXT(1) != '/')) &&
9813  (ctxt->instate != XML_PARSER_EOF)) {
9814  const xmlChar *test = CUR_PTR;
9815  unsigned int cons = ctxt->input->consumed;
9816  const xmlChar *cur = ctxt->input->cur;
9817 
9818  /*
9819  * First case : a Processing Instruction.
9820  */
9821  if ((*cur == '<') && (cur[1] == '?')) {
9822  xmlParsePI(ctxt);
9823  }
9824 
9825  /*
9826  * Second case : a CDSection
9827  */
9828  /* 2.6.0 test was *cur not RAW */
9829  else if (CMP9(CUR_PTR, '<', '!', '[', 'C', 'D', 'A', 'T', 'A', '[')) {
9830  xmlParseCDSect(ctxt);
9831  }
9832 
9833  /*
9834  * Third case : a comment
9835  */
9836  else if ((*cur == '<') && (NXT(1) == '!') &&
9837  (NXT(2) == '-') && (NXT(3) == '-')) {
9838  xmlParseComment(ctxt);
9839  ctxt->instate = XML_PARSER_CONTENT;
9840  }
9841 
9842  /*
9843  * Fourth case : a sub-element.
9844  */
9845  else if (*cur == '<') {
9846  xmlParseElement(ctxt);
9847  }
9848 
9849  /*
9850  * Fifth case : a reference. If if has not been resolved,
9851  * parsing returns it's Name, create the node
9852  */
9853 
9854  else if (*cur == '&') {
9855  xmlParseReference(ctxt);
9856  }
9857 
9858  /*
9859  * Last case, text. Note that References are handled directly.
9860  */
9861  else {
9862  xmlParseCharData(ctxt, 0);
9863  }
9864 
9865  GROW;
9866  SHRINK;
9867 
9868  if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
9870  "detected an error in element content\n");
9871  xmlHaltParser(ctxt);
9872  break;
9873  }
9874  }
9875 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:350
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2073
#define NXT(val)
Definition: parser.c:2021
const xmlChar * cur
Definition: parser.h:61
#define test
Definition: rosglue.h:37
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2036
void xmlParseCDSect(xmlParserCtxtPtr ctxt)
Definition: parser.c:9703
xmlParserInputPtr input
Definition: parser.h:199
void xmlParseReference(xmlParserCtxtPtr ctxt)
Definition: parser.c:6996
unsigned long consumed
Definition: parser.h:71
void xmlParsePI(xmlParserCtxtPtr ctxt)
Definition: parser.c:5092
void xmlParseElement(xmlParserCtxtPtr ctxt)
Definition: parser.c:9892
pair cons(caddr_t car, pair cdr)
Definition: tree.c:57
unsigned char xmlChar
Definition: xmlstring.h:28
#define CUR_PTR
Definition: parser.c:2022
#define RAW
Definition: parser.c:2019
void xmlParseCharData(xmlParserCtxtPtr ctxt, int cdata)
Definition: parser.c:4355
static void xmlHaltParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12449
#define SHRINK
Definition: parser.c:2062
void xmlParseComment(xmlParserCtxtPtr ctxt)
Definition: parser.c:4812

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

5605  {
5606  int val;
5607  xmlChar *ret;
5608 
5609  *value = NULL;
5610  if (CMP9(CUR_PTR, '#', 'R', 'E', 'Q', 'U', 'I', 'R', 'E', 'D')) {
5611  SKIP(9);
5612  return(XML_ATTRIBUTE_REQUIRED);
5613  }
5614  if (CMP8(CUR_PTR, '#', 'I', 'M', 'P', 'L', 'I', 'E', 'D')) {
5615  SKIP(8);
5616  return(XML_ATTRIBUTE_IMPLIED);
5617  }
5619  if (CMP6(CUR_PTR, '#', 'F', 'I', 'X', 'E', 'D')) {
5620  SKIP(6);
5622  if (SKIP_BLANKS == 0) {
5623  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5624  "Space required after '#FIXED'\n");
5625  }
5626  }
5627  ret = xmlParseAttValue(ctxt);
5628  ctxt->instate = XML_PARSER_DTD;
5629  if (ret == NULL) {
5630  xmlFatalErrMsg(ctxt, (xmlParserErrors)ctxt->errNo,
5631  "Attribute default value declaration error\n");
5632  } else
5633  *value = ret;
5634  return(val);
5635 }
xmlParserInputState instate
Definition: parser.h:223
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2036
#define SKIP_BLANKS
Definition: parser.c:2101
#define CMP6(s, c1, c2, c3, c4, c5, c6)
Definition: parser.c:2030
smooth NULL
Definition: ftsmooth.c:416
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:2043
#define CUR_PTR
Definition: parser.c:2022
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2034
xmlChar * xmlParseAttValue(xmlParserCtxtPtr ctxt)
Definition: parser.c:4118

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

8194  {
8195  const xmlChar *name = NULL;
8196  xmlChar *ExternalID = NULL;
8197  xmlChar *URI = NULL;
8198 
8199  /*
8200  * We know that '<!DOCTYPE' has been detected.
8201  */
8202  SKIP(9);
8203 
8204  SKIP_BLANKS;
8205 
8206  /*
8207  * Parse the DOCTYPE name.
8208  */
8209  name = xmlParseName(ctxt);
8210  if (name == NULL) {
8211  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
8212  "xmlParseDocTypeDecl : no DOCTYPE name !\n");
8213  }
8214  ctxt->intSubName = name;
8215 
8216  SKIP_BLANKS;
8217 
8218  /*
8219  * Check for SystemID and ExternalID
8220  */
8221  URI = xmlParseExternalID(ctxt, &ExternalID, 1);
8222 
8223  if ((URI != NULL) || (ExternalID != NULL)) {
8224  ctxt->hasExternalSubset = 1;
8225  }
8226  ctxt->extSubURI = URI;
8227  ctxt->extSubSystem = ExternalID;
8228 
8229  SKIP_BLANKS;
8230 
8231  /*
8232  * Create and update the internal subset.
8233  */
8234  if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) &&
8235  (!ctxt->disableSAX))
8236  ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI);
8237  if (ctxt->instate == XML_PARSER_EOF)
8238  return;
8239 
8240  /*
8241  * Is there any internal subset declarations ?
8242  * they are handled separately in xmlParseInternalSubset()
8243  */
8244  if (RAW == '[')
8245  return;
8246 
8247  /*
8248  * We should be at the end of the DOCTYPE declaration.
8249  */
8250  if (RAW != '>') {
8252  }
8253  NEXT;
8254 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:350
xmlParserInputState instate
Definition: parser.h:223
xmlChar * extSubURI
Definition: parser.h:240
xmlChar * xmlParseExternalID(xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict)
Definition: parser.c:4611
#define SKIP_BLANKS
Definition: parser.c:2101
int disableSAX
Definition: parser.h:237
smooth NULL
Definition: ftsmooth.c:416
xmlChar * extSubSystem
Definition: parser.h:241
const xmlChar * intSubName
Definition: parser.h:239
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3281
#define NEXT
Definition: parser.c:2103
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
int hasExternalSubset
Definition: parser.h:215
#define SKIP(val)
Definition: parser.c:2043
Definition: name.c:36
#define RAW
Definition: parser.c:2019
void * userData
Definition: parser.h:186
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by xmlParseDocument().

◆ xmlParseElement()

XMLPUBFUN void XMLCALL xmlParseElement ( xmlParserCtxtPtr  ctxt)

xmlParseElement: @ctxt: an XML parser context

parse an XML element, this is highly recursive

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

9892  {
9893  const xmlChar *name;
9894  const xmlChar *prefix = NULL;
9895  const xmlChar *URI = NULL;
9896  xmlParserNodeInfo node_info;
9897  int line, tlen = 0;
9898  xmlNodePtr ret;
9899  int nsNr = ctxt->nsNr;
9900 
9901  if (((unsigned int) ctxt->nameNr > xmlParserMaxDepth) &&
9902  ((ctxt->options & XML_PARSE_HUGE) == 0)) {
9903  xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
9904  "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
9906  xmlHaltParser(ctxt);
9907  return;
9908  }
9909 
9910  /* Capture start position */
9911  if (ctxt->record_info) {
9912  node_info.begin_pos = ctxt->input->consumed +
9913  (CUR_PTR - ctxt->input->base);
9914  node_info.begin_line = ctxt->input->line;
9915  }
9916 
9917  if (ctxt->spaceNr == 0)
9918  spacePush(ctxt, -1);
9919  else if (*ctxt->space == -2)
9920  spacePush(ctxt, -1);
9921  else
9922  spacePush(ctxt, *ctxt->space);
9923 
9924  line = ctxt->input->line;
9925 #ifdef LIBXML_SAX1_ENABLED
9926  if (ctxt->sax2)
9927 #endif /* LIBXML_SAX1_ENABLED */
9928  name = xmlParseStartTag2(ctxt, &prefix, &URI, &tlen);
9929 #ifdef LIBXML_SAX1_ENABLED
9930  else
9931  name = xmlParseStartTag(ctxt);
9932 #endif /* LIBXML_SAX1_ENABLED */
9933  if (ctxt->instate == XML_PARSER_EOF)
9934  return;
9935  if (name == NULL) {
9936  spacePop(ctxt);
9937  return;
9938  }
9939  namePush(ctxt, name);
9940  ret = ctxt->node;
9941 
9942 #ifdef LIBXML_VALID_ENABLED
9943  /*
9944  * [ VC: Root Element Type ]
9945  * The Name in the document type declaration must match the element
9946  * type of the root element.
9947  */
9948  if (ctxt->validate && ctxt->wellFormed && ctxt->myDoc &&
9949  ctxt->node && (ctxt->node == ctxt->myDoc->children))
9950  ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
9951 #endif /* LIBXML_VALID_ENABLED */
9952 
9953  /*
9954  * Check for an Empty Element.
9955  */
9956  if ((RAW == '/') && (NXT(1) == '>')) {
9957  SKIP(2);
9958  if (ctxt->sax2) {
9959  if ((ctxt->sax != NULL) && (ctxt->sax->endElementNs != NULL) &&
9960  (!ctxt->disableSAX))
9961  ctxt->sax->endElementNs(ctxt->userData, name, prefix, URI);
9962 #ifdef LIBXML_SAX1_ENABLED
9963  } else {
9964  if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL) &&
9965  (!ctxt->disableSAX))
9966  ctxt->sax->endElement(ctxt->userData, name);
9967 #endif /* LIBXML_SAX1_ENABLED */
9968  }
9969  namePop(ctxt);
9970  spacePop(ctxt);
9971  if (nsNr != ctxt->nsNr)
9972  nsPop(ctxt, ctxt->nsNr - nsNr);
9973  if ( ret != NULL && ctxt->record_info ) {
9974  node_info.end_pos = ctxt->input->consumed +
9975  (CUR_PTR - ctxt->input->base);
9976  node_info.end_line = ctxt->input->line;
9977  node_info.node = ret;
9978  xmlParserAddNodeInfo(ctxt, &node_info);
9979  }
9980  return;
9981  }
9982  if (RAW == '>') {
9983  NEXT1;
9984  } else {
9985  xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_GT_REQUIRED,
9986  "Couldn't find end of Start Tag %s line %d\n",
9987  name, line, NULL);
9988 
9989  /*
9990  * end of parsing of this node.
9991  */
9992  nodePop(ctxt);
9993  namePop(ctxt);
9994  spacePop(ctxt);
9995  if (nsNr != ctxt->nsNr)
9996  nsPop(ctxt, ctxt->nsNr - nsNr);
9997 
9998  /*
9999  * Capture end position and add node
10000  */
10001  if ( ret != NULL && ctxt->record_info ) {
10002  node_info.end_pos = ctxt->input->consumed +
10003  (CUR_PTR - ctxt->input->base);
10004  node_info.end_line = ctxt->input->line;
10005  node_info.node = ret;
10006  xmlParserAddNodeInfo(ctxt, &node_info);
10007  }
10008  return;
10009  }
10010 
10011  /*
10012  * Parse the content of the element:
10013  */
10014  xmlParseContent(ctxt);
10015  if (ctxt->instate == XML_PARSER_EOF)
10016  return;
10017  if (!IS_BYTE_CHAR(RAW)) {
10018  xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
10019  "Premature end of data in tag %s line %d\n",
10020  name, line, NULL);
10021 
10022  /*
10023  * end of parsing of this node.
10024  */
10025  nodePop(ctxt);
10026  namePop(ctxt);
10027  spacePop(ctxt);
10028  if (nsNr != ctxt->nsNr)
10029  nsPop(ctxt, ctxt->nsNr - nsNr);
10030  return;
10031  }
10032 
10033  /*
10034  * parse the end of tag: '</' should be here.
10035  */
10036  if (ctxt->sax2) {
10037  xmlParseEndTag2(ctxt, prefix, URI, line, ctxt->nsNr - nsNr, tlen);
10038  namePop(ctxt);
10039  }
10040 #ifdef LIBXML_SAX1_ENABLED
10041  else
10042  xmlParseEndTag1(ctxt, line);
10043 #endif /* LIBXML_SAX1_ENABLED */
10044 
10045  /*
10046  * Capture end position and add node
10047  */
10048  if ( ret != NULL && ctxt->record_info ) {
10049  node_info.end_pos = ctxt->input->consumed +
10050  (CUR_PTR - ctxt->input->base);
10051  node_info.end_line = ctxt->input->line;
10052  node_info.node = ret;
10053  xmlParserAddNodeInfo(ctxt, &node_info);
10054  }
10055 }
xmlParserInputState instate
Definition: parser.h:223
xmlNodePtr nodePop(xmlParserCtxtPtr ctxt)
Definition: parser.c:1805
#define NXT(val)
Definition: parser.c:2021
const xmlChar * namePop(xmlParserCtxtPtr ctxt)
Definition: parser.c:1936
unsigned long begin_line
Definition: parser.h:93
const xmlChar * base
Definition: parser.h:60
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
unsigned long begin_pos
Definition: parser.h:92
int namePush(xmlParserCtxtPtr ctxt, const xmlChar *value)
Definition: parser.c:1905
unsigned long consumed
Definition: parser.h:71
static const xmlChar * xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref, const xmlChar **URI, int *tlen)
Definition: parser.c:9177
static void xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix, const xmlChar *URI, int line, int nsNr, int tlen)
Definition: parser.c:9616
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
int validate
Definition: parser.h:220
static int spacePop(xmlParserCtxtPtr ctxt)
Definition: parser.c:1971
int wellFormed
Definition: parser.h:188
xmlNodePtr node
Definition: parser.h:205
int record_info
Definition: parser.h:210
static int spacePush(xmlParserCtxtPtr ctxt, int val)
Definition: parser.c:1952
unsigned int xmlParserMaxDepth
Definition: parser.c:242
unsigned long end_pos
Definition: parser.h:94
#define IS_BYTE_CHAR(c)
static int nsPop(xmlParserCtxtPtr ctxt, int nr)
Definition: parser.c:1645
Definition: tree.h:489
const struct _xmlNode * node
Definition: parser.h:90
int ret
xmlDocPtr myDoc
Definition: parser.h:187
char line[200]
Definition: main.c:97
XMLPUBFUN void XMLCALL xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt, const xmlParserNodeInfoPtr info)
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
#define SKIP(val)
Definition: parser.c:2043
unsigned long end_line
Definition: parser.h:95
void xmlParseContent(xmlParserCtxtPtr ctxt)
Definition: parser.c:9809
Definition: name.c:36
#define CUR_PTR
Definition: parser.c:2022
#define RAW
Definition: parser.c:2019
struct _xmlNode * children
Definition: tree.h:555
static void xmlHaltParser(xmlParserCtxtPtr ctxt)
Definition: parser.c:12449
xmlValidCtxt vctxt
Definition: parser.h:221
int * space
Definition: parser.h:244
void * userData
Definition: parser.h:186
#define NEXT1
Definition: parser.c:2105
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by xmlParseContent(), and 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 6443 of file parser.c.

6443  {
6444  /* stub left for API/ABI compat */
6445  return(xmlParseElementChildrenContentDeclPriv(ctxt, inputchk, 1));
6446 }
static xmlElementContentPtr xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk, int depth)
Definition: parser.c:6147

◆ xmlParseElementContentDecl()

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

Definition at line 6463 of file parser.c.

6464  {
6465 
6467  int inputid = ctxt->input->id;
6468  int res;
6469 
6470  *result = NULL;
6471 
6472  if (RAW != '(') {
6473  xmlFatalErrMsgStr(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED,
6474  "xmlParseElementContentDecl : %s '(' expected\n", name);
6475  return(-1);
6476  }
6477  NEXT;
6478  GROW;
6479  if (ctxt->instate == XML_PARSER_EOF)
6480  return(-1);
6481  SKIP_BLANKS;
6482  if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
6483  tree = xmlParseElementMixedContentDecl(ctxt, inputid);
6485  } else {
6486  tree = xmlParseElementChildrenContentDeclPriv(ctxt, inputid, 1);
6488  }
6489  SKIP_BLANKS;
6490  *result = tree;
6491  return(res);
6492 }
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2073
struct _tree tree
#define SKIP_BLANKS
Definition: parser.c:2101
xmlParserInputPtr input
Definition: parser.h:199
smooth NULL
Definition: ftsmooth.c:416
xmlElementContentPtr xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk)
Definition: parser.c:6027
static xmlElementContentPtr xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk, int depth)
Definition: parser.c:6147
#define NEXT
Definition: parser.c:2103
Definition: name.c:36
GLuint res
Definition: glext.h:9613
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)
Definition: parser.c:2032
#define CUR_PTR
Definition: parser.c:2022
#define RAW
Definition: parser.c:2019
GLuint64EXT * result
Definition: glext.h:11304

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

6508  {
6509  const xmlChar *name;
6510  int ret = -1;
6512 
6513  /* GROW; done in the caller */
6514  if (CMP9(CUR_PTR, '<', '!', 'E', 'L', 'E', 'M', 'E', 'N', 'T')) {
6515  int inputid = ctxt->input->id;
6516 
6517  SKIP(9);
6518  if (SKIP_BLANKS == 0) {
6519  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6520  "Space required after 'ELEMENT'\n");
6521  return(-1);
6522  }
6523  name = xmlParseName(ctxt);
6524  if (name == NULL) {
6525  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6526  "xmlParseElementDecl: no name for Element\n");
6527  return(-1);
6528  }
6529  if (SKIP_BLANKS == 0) {
6530  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
6531  "Space required after the element name\n");
6532  }
6533  if (CMP5(CUR_PTR, 'E', 'M', 'P', 'T', 'Y')) {
6534  SKIP(5);
6535  /*
6536  * Element must always be empty.
6537  */
6539  } else if ((RAW == 'A') && (NXT(1) == 'N') &&
6540  (NXT(2) == 'Y')) {
6541  SKIP(3);
6542  /*
6543  * Element is a generic container.
6544  */
6546  } else if (RAW == '(') {
6548  } else {
6549  /*
6550  * [ WFC: PEs in Internal Subset ] error handling.
6551  */
6552  if ((RAW == '%') && (ctxt->external == 0) &&
6553  (ctxt->inputNr == 1)) {
6554  xmlFatalErrMsg(ctxt, XML_ERR_PEREF_IN_INT_SUBSET,
6555  "PEReference: forbidden within markup decl in internal subset\n");
6556  } else {
6557  xmlFatalErrMsg(ctxt, XML_ERR_ELEMCONTENT_NOT_STARTED,
6558  "xmlParseElementDecl: 'EMPTY', 'ANY' or '(' expected\n");
6559  }
6560  return(-1);
6561  }
6562 
6563  SKIP_BLANKS;
6564 
6565  if (RAW != '>') {
6567  if (content != NULL) {
6569  }
6570  } else {
6571  if (inputid != ctxt->input->id) {
6572  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6573  "Element declaration doesn't start and stop in"
6574  " the same entity\n");
6575  }
6576 
6577  NEXT;
6578  if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
6579  (ctxt->sax->elementDecl != NULL)) {
6580  if (content != NULL)
6581  content->parent = NULL;
6582  ctxt->sax->elementDecl(ctxt->userData, name, ret,
6583  content);
6584  if ((content != NULL) && (content->parent == NULL)) {
6585  /*
6586  * this is a trick: if xmlAddElementDecl is called,
6587  * instead of copying the full tree it is plugged directly
6588  * if called from the parser. Avoid duplicating the
6589  * interfaces or change the API/ABI
6590  */
6592  }
6593  } else if (content != NULL) {
6595  }
6596  }
6597  }
6598  return(ret);
6599 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:350
#define NXT(val)
Definition: parser.c:2021
#define CMP5(s, c1, c2, c3, c4, c5)
Definition: parser.c:2028
#define CMP9(s, c1, c2, c3, c4, c5, c6, c7, c8, c9)
Definition: parser.c:2036
int external
Definition: parser.h:217
#define SKIP_BLANKS
Definition: parser.c:2101
int xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlElementContentPtr *result)
Definition: parser.c:6463
xmlParserInputPtr input
Definition: parser.h:199
int disableSAX
Definition: parser.h:237
content
Definition: atl_ax.c:994
smooth NULL
Definition: ftsmooth.c:416
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3281
XMLPUBFUN void XMLCALL xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1101
#define NEXT
Definition: parser.c:2103
int ret
xmlDocPtr myDoc
Definition: parser.h:187
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlSAXHandler * sax
Definition: parser.h:185
#define SKIP(val)
Definition: parser.c:2043
Definition: name.c:36
#define CUR_PTR
Definition: parser.c:2022
#define RAW
Definition: parser.c:2019
void * userData
Definition: parser.h:186
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by xmlParseMarkupDecl().

◆ xmlParseElementMixedContentDecl()

XMLPUBFUN xmlElementContentPtr XMLCALL xmlParseElementMixedContentDecl ( xmlParserCtxtPtr  ctxt,
int  inputchk 
)

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

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

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

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

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

returns: the list of the xmlElementContentPtr describing the element choices

Definition at line 6027 of file parser.c.

6027  {
6028  xmlElementContentPtr ret = NULL, cur = NULL, n;
6029  const xmlChar *elem = NULL;
6030 
6031  GROW;
6032  if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
6033  SKIP(7);
6034  SKIP_BLANKS;
6035  SHRINK;
6036  if (RAW == ')') {
6037  if (ctxt->input->id != inputchk) {
6038  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6039  "Element content declaration doesn't start and"
6040  " stop in the same entity\n");
6041  }
6042  NEXT;
6044  if (ret == NULL)
6045  return(NULL);
6046  if (RAW == '*') {
6047  ret->ocur = XML_ELEMENT_CONTENT_MULT;
6048  NEXT;
6049  }
6050  return(ret);
6051  }
6052  if ((RAW == '(') || (RAW == '|')) {
6054  if (ret == NULL) return(NULL);
6055  }
6056  while ((RAW == '|') && (ctxt->instate != XML_PARSER_EOF)) {
6057  NEXT;
6058  if (elem == NULL) {
6060  if (ret == NULL) return(NULL);
6061  ret->c1 = cur;
6062  if (cur != NULL)
6063  cur->parent = ret;
6064  cur = ret;
6065  } else {
6067  if (n == NULL) return(NULL);
6069  if (n->c1 != NULL)
6070  n->c1->parent = n;
6071  cur->c2 = n;
6072  if (n != NULL)
6073  n->parent = cur;
6074  cur = n;
6075  }
6076  SKIP_BLANKS;
6077  elem = xmlParseName(ctxt);
6078  if (elem == NULL) {
6079  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
6080  "xmlParseElementMixedContentDecl : Name expected\n");
6082  return(NULL);
6083  }
6084  SKIP_BLANKS;
6085  GROW;
6086  }
6087  if ((RAW == ')') && (NXT(1) == '*')) {
6088  if (elem != NULL) {
6089  cur->c2 = xmlNewDocElementContent(ctxt->myDoc, elem,
6091  if (cur->c2 != NULL)
6092  cur->c2->parent = cur;
6093  }
6094  if (ret != NULL)
6095  ret->ocur = XML_ELEMENT_CONTENT_MULT;
6096  if (ctxt->input->id != inputchk) {
6097  xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
6098  "Element content declaration doesn't start and"
6099  " stop in the same entity\n");
6100  }
6101  SKIP(2);
6102  } else {
6105  return(NULL);
6106  }
6107 
6108  } else {
6110  }
6111  return(ret);
6112 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:350
xmlParserInputState instate
Definition: parser.h:223
#define GROW
Definition: parser.c:2073
#define NXT(val)
Definition: parser.c:2021
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:2101
xmlParserInputPtr input
Definition: parser.h:199
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
const xmlChar * xmlParseName(xmlParserCtxtPtr ctxt)
Definition: parser.c:3281
XMLPUBFUN void XMLCALL xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1101
#define NEXT
Definition: parser.c:2103
int ret
xmlDocPtr myDoc
Definition: parser.h:187
unsigned char xmlChar
Definition: xmlstring.h:28
#define SKIP(val)
Definition: parser.c:2043
#define CMP7(s, c1, c2, c3, c4, c5, c6, c7)
Definition: parser.c:2032
#define CUR_PTR
Definition: parser.c:2022
#define RAW
Definition: parser.c:2019
#define SHRINK
Definition: parser.c:2062

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

10175  {
10176  xmlChar *buf = NULL;
10177  int len = 0;
10178  int size = 10;
10179  xmlChar cur;
10180 
10181  cur = CUR;
10182  if (((cur >= 'a') && (cur <= 'z')) ||
10183  ((cur >= 'A') && (cur <= 'Z'))) {
10184  buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
10185  if (buf == NULL) {
10186  xmlErrMemory(ctxt, NULL);
10187  return(NULL);
10188  }
10189 
10190  buf[len++] = cur;
10191  NEXT;
10192  cur = CUR;
10193  while (((cur >= 'a') && (cur <= 'z')) ||
10194  ((cur >= 'A') && (cur <= 'Z')) ||
10195  ((cur >= '0') && (cur <= '9')) ||
10196  (cur == '.') || (cur == '_') ||
10197  (cur == '-')) {
10198  if (len + 1 >= size) {
10199  xmlChar *tmp;
10200 
10201  size *= 2;
10202  tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
10203  if (tmp == NULL) {
10204  xmlErrMemory(ctxt, NULL);
10205  xmlFree(buf);
10206  return(NULL);
10207  }
10208  buf = tmp;
10209  }
10210  buf[len++] = cur;
10211  NEXT;
10212  cur = CUR;
10213  if (cur == 0) {
10214  SHRINK;
10215  GROW;
10216  cur = CUR;
10217  }
10218  }
10219  buf[len] = 0;
10220  } else {
10222  }
10223  return(buf);
10224 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:350
XMLPUBVAR xmlMallocFunc xmlMallocAtomic
Definition: globals.h:248
#define GROW
Definition: parser.c:2073
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
smooth NULL
Definition: ftsmooth.c:416
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:2103
unsigned char xmlChar
Definition: xmlstring.h:28
GLenum GLsizei len
Definition: glext.h:6722
#define CUR
Definition: parser.c:2020
#define SHRINK
Definition: parser.c:2062

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

10240  {
10241  xmlChar *encoding = NULL;
10242 
10243  SKIP_BLANKS;
10244  if (CMP8(CUR_PTR, 'e', 'n', 'c', 'o', 'd', 'i', 'n', 'g')) {
10245  SKIP(8);
10246  SKIP_BLANKS;
10247  if (RAW != '=') {
10249  return(NULL);
10250  }
10251  NEXT;
10252  SKIP_BLANKS;
10253  if (RAW == '"') {
10254  NEXT;
10255  encoding = xmlParseEncName(ctxt);
10256  if (RAW != '"') {
10258  xmlFree((xmlChar *) encoding);
10259  return(NULL);
10260  } else
10261  NEXT;
10262  } else if (RAW == '\''){
10263  NEXT;
10264  encoding = xmlParseEncName(ctxt);
10265  if (RAW != '\'') {
10267  xmlFree((xmlChar *) encoding);
10268  return(NULL);
10269  } else
10270  NEXT;
10271  } else {
10273  }
10274 
10275  /*
10276  * Non standard parsing, allowing the user to ignore encoding
10277  */
10278  if (ctxt->options & XML_PARSE_IGNORE_ENC) {
10279  xmlFree((xmlChar *) encoding);
10280  return(NULL);
10281  }
10282 
10283  /*
10284  * UTF-16 encoding stwich has already taken place at this stage,
10285  * more over the little-endian/big-endian selection is already done
10286  */
10287  if ((encoding != NULL) &&
10288  ((!xmlStrcasecmp(encoding, BAD_CAST "UTF-16")) ||
10289  (!xmlStrcasecmp(encoding, BAD_CAST "UTF16")))) {
10290  /*
10291  * If no encoding was passed to the parser, that we are
10292  * using UTF-16 and no decoder is present i.e. the
10293  * document is apparently UTF-8 compatible, then raise an
10294  * encoding mismatch fatal error
10295  */
10296  if ((ctxt->encoding == NULL) &&
10297  (ctxt->input->buf != NULL) &&
10298  (ctxt->input->buf->encoder == NULL)) {
10299  xmlFatalErrMsg(ctxt, XML_ERR_INVALID_ENCODING,
10300  "Document labelled UTF-16 but has UTF-8 content\n");
10301  }
10302  if (ctxt->encoding != NULL)
10303  xmlFree((xmlChar *) ctxt->encoding);
10304  ctxt->encoding = encoding;
10305  }
10306  /*
10307  * UTF-8 encoding is handled natively
10308  */
10309  else if ((encoding != NULL) &&
10310  ((!xmlStrcasecmp(encoding, BAD_CAST "UTF-8")) ||
10311  (!xmlStrcasecmp(encoding, BAD_CAST "UTF8")))) {
10312  if (ctxt->encoding != NULL)
10313  xmlFree((xmlChar *) ctxt->encoding);
10314  ctxt->encoding = encoding;
10315  }
10316  else if (encoding != NULL) {
10318 
10319  if (ctxt->input->encoding != NULL)
10320  xmlFree((xmlChar *) ctxt->input->encoding);
10321  ctxt->input->encoding = encoding;
10322 
10323  handler = xmlFindCharEncodingHandler((const char *) encoding);
10324  if (handler != NULL) {
10325  if (xmlSwitchToEncoding(ctxt, handler) < 0) {
10326  /* failed to convert */
10328  return(NULL);
10329  }
10330  } else {
10331  xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
10332  "Unsupported encoding %s\n", encoding);
10333  return(NULL);
10334  }
10335  }
10336  }
10337  return(encoding);
10338 }
static void xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
Definition: parser.c:350
XMLPUBFUN int XMLCALL xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
xmlChar * xmlParseEncName(xmlParserCtxtPtr ctxt)
Definition: parser.c:10175
#define SKIP_BLANKS
Definition: parser.c:2101
xmlParserInputPtr input
Definition: parser.h:199
smooth NULL
Definition: ftsmooth.c:416
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
#define NEXT
Definition: parser.c:2103
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL xmlFindCharEncodingHandler(const char *name)
Definition: encoding.c:1641
const xmlChar * encoding
Definition: parser.h:191
unsigned char xmlChar
Definition: xmlstring.h:28
ed encoding
Definition: write.c:2847
xmlCharEncodingHandlerPtr encoder
Definition: xmlIO.h:130
#define SKIP(val)
Definition: parser.c:2043
xmlParserInputBufferPtr buf
Definition: parser.h:56
const xmlChar * encoding
Definition: parser.h:73
#define CUR_PTR
Definition: parser.c:2022
#define RAW
Definition: parser.c:2019
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7786
XMLPUBFUN int XMLCALL xmlStrcasecmp(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:271
#define CMP8(s, c1, c2, c3, c4, c5, c6, c7, c8)
Definition: parser.c:2034

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

5332  {
5333  const xmlChar *name = NULL;
5334  xmlChar *value = NULL;
5335  xmlChar *URI = NULL, *literal = NULL;
5336  const xmlChar *ndata = NULL;
5337  int isParameter = 0;
5338  xmlChar *orig = NULL;
5339 
5340  /* GROW; done in the caller */
5341  if (CMP8(CUR_PTR, '<', '!', 'E', 'N', 'T', 'I', 'T', 'Y')) {
5342  int inputid = ctxt->input->id;
5343  SHRINK;
5344  SKIP(8);
5345  if (SKIP_BLANKS == 0) {
5346  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5347  "Space required after '<!ENTITY'\n");
5348  }
5349 
5350  if (RAW == '%') {
5351  NEXT;
5352  if (SKIP_BLANKS == 0) {
5353  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5354  "Space required after '%%'\n");
5355  }
5356  isParameter = 1;
5357  }
5358 
5359  name = xmlParseName(ctxt);
5360  if (name == NULL) {
5361  xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
5362  "xmlParseEntityDecl: no name\n");
5363  return;
5364  }
5365  if (xmlStrchr(name, ':') != NULL) {
5366  xmlNsErr(ctxt, XML_NS_ERR_COLON,
5367  "colons are forbidden from entities names '%s'\n",
5368  name, NULL, NULL);
5369  }
5370  if (SKIP_BLANKS == 0) {
5371  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5372  "Space required after the entity name\n");
5373  }
5374 
5376  /*
5377  * handle the various case of definitions...
5378  */
5379  if (isParameter) {
5380  if ((RAW == '"') || (RAW == '\'')) {
5381  value = xmlParseEntityValue(ctxt, &orig);
5382  if (value) {
5383  if ((ctxt->sax != NULL) &&
5384  (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5385  ctxt->sax->entityDecl(ctxt->userData, name,
5387  NULL, NULL, value);
5388  }
5389  } else {
5390  URI = xmlParseExternalID(ctxt, &literal, 1);
5391  if ((URI == NULL) && (literal == NULL)) {
5393  }
5394  if (URI) {
5395  xmlURIPtr uri;
5396 
5397  uri = xmlParseURI((const char *) URI);
5398  if (uri == NULL) {
5399  xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
5400  "Invalid URI: %s\n", URI);
5401  /*
5402  * This really ought to be a well formedness error
5403  * but the XML Core WG decided otherwise c.f. issue
5404  * E26 of the XML erratas.
5405  */
5406  } else {
5407  if (uri->fragment != NULL) {
5408  /*
5409  * Okay this is foolish to block those but not
5410  * invalid URIs.
5411  */
5413  } else {
5414  if ((ctxt->sax != NULL) &&
5415  (!ctxt->disableSAX) &&
5416  (ctxt->sax->entityDecl != NULL))
5417  ctxt->sax->entityDecl(ctxt->userData, name,
5419  literal, URI, NULL);
5420  }
5421  xmlFreeURI(uri);
5422  }
5423  }
5424  }
5425  } else {
5426  if ((RAW == '"') || (RAW == '\'')) {
5427  value = xmlParseEntityValue(ctxt, &orig);
5428  if ((ctxt->sax != NULL) &&
5429  (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5430  ctxt->sax->entityDecl(ctxt->userData, name,
5432  NULL, NULL, value);
5433  /*
5434  * For expat compatibility in SAX mode.
5435  */
5436  if ((ctxt->myDoc == NULL) ||
5438  if (ctxt->myDoc == NULL) {
5439  ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
5440  if (ctxt->myDoc == NULL) {
5441  xmlErrMemory(ctxt, "New Doc failed");
5442  return;
5443  }
5445  }
5446  if (ctxt->myDoc->intSubset == NULL)
5447  ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
5448  BAD_CAST "fake", NULL, NULL);
5449 
5451  NULL, NULL, value);
5452  }
5453  } else {
5454  URI = xmlParseExternalID(ctxt, &literal, 1);
5455  if ((URI == NULL) && (literal == NULL)) {
5457  }
5458  if (URI) {
5459  xmlURIPtr uri;
5460 
5461  uri = xmlParseURI((const char *)URI);
5462  if (uri == NULL) {
5463  xmlErrMsgStr(ctxt, XML_ERR_INVALID_URI,
5464  "Invalid URI: %s\n", URI);
5465  /*
5466  * This really ought to be a well formedness error
5467  * but the XML Core WG decided otherwise c.f. issue
5468  * E26 of the XML erratas.
5469  */
5470  } else {
5471  if (uri->fragment != NULL) {
5472  /*
5473  * Okay this is foolish to block those but not
5474  * invalid URIs.
5475  */
5477  }
5478  xmlFreeURI(uri);
5479  }
5480  }
5481  if ((RAW != '>') && (SKIP_BLANKS == 0)) {
5482  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5483  "Space required before 'NDATA'\n");
5484  }
5485  if (CMP5(CUR_PTR, 'N', 'D', 'A', 'T', 'A')) {
5486  SKIP(5);
5487  if (SKIP_BLANKS == 0) {
5488  xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
5489  "Space required after 'NDATA'\n");
5490  }
5491  ndata = xmlParseName(ctxt);
5492  if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
5493  (ctxt->sax->unparsedEntityDecl != NULL))
5494  ctxt->sax->unparsedEntityDecl(ctxt->userData, name,
5495  literal, URI, ndata);
5496  } else {
5497  if ((ctxt->sax != NULL) &&
5498  (!ctxt->disableSAX) && (ctxt->sax->entityDecl != NULL))
5499  ctxt->sax->entityDecl(ctxt->userData, name,
5501  literal, URI, NULL);
5502  /*
5503  * For expat compatibility in SAX mode.
5504  * assuming the entity repalcement was asked for
5505  */
5506  if ((ctxt->replaceEntities != 0) &&
5507  ((ctxt->myDoc == NULL) ||
5508  (xmlStrEqual(ctxt->myDoc->version, SAX_COMPAT_MODE)))) {
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 
5518  if (ctxt->myDoc->intSubset == NULL)
5519  ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
5520  BAD_CAST "fake", NULL, NULL);
5521  xmlSAX2EntityDecl(ctxt, name,
5523  literal, URI, NULL);
5524  }
5525  }
5526  }
5527  }
5528  if (ctxt->instate == XML_PARSER_EOF)
5529  goto done;
5530  SKIP_BLANKS;
5531