Ignore:
Timestamp:
Feb 17, 2001, 3:03:14 PM (25 years ago)
Author:
umoeller
Message:

Updates to XML.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/xmlparse.c

    r36 r38  
    55 *      SourceForge Oct 22, 2000.
    66 *
    7  *      Expat is a library, written in C, for parsing XML documents. It's
     7 *      This was ported to and integrated with the xwphelpers
     8 *      for V0.9.9 (2001-02-10) [umoeller]. See xml.c for a general
     9 *      introduction to @XML support in the xwphelpers.
     10 *
     11 *      Expat is a library, written in C, for parsing XML @documents. It's
    812 *      the underlying XML parser for the open source Mozilla project,
    913 *      perl's XML::Parser, and other open-source XML parsers.
     
    1822 *      that comes with expat as an HTML file. I (umoeller)
    1923 *      have integrated the docs into the sources and added a
    20  *      couple of remarks on the way.
    21  *
    22  *      See XML_ParserCreate for an introduction to expat.
     24 *      couple of remarks while trying to implement parsers.
     25 *
     26 *      See XML_ParserCreate for instructions how to parse XML.
     27 *
     28 *      Note that expat is a non-validating XML processor. Validation
     29 *      is supported by the top layer of xwphelpers XML support. See
     30 *      xml.c.
    2331 *
    2432 *@@added V0.9.9 (2001-02-10) [umoeller]
     33 *@@header "expat\expat.h"
    2534 */
    2635
     
    4857 *      TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    4958 *      SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     59 */
     60
     61/*
     62 *@@category: Helpers\C helpers\XML\expat
     63 *      expat XML parser. See xmlparse.c.
    5064 */
    5165
     
    95109    typedef char ICHAR;
    96110#endif
    97 
    98111
    99112#ifndef XML_NS
     
    281294} OPEN_INTERNAL_ENTITY, *POPEN_INTERNAL_ENTITY;
    282295
    283 typedef enum XML_Error Processor(XML_Parser parser,
     296typedef XMLERROR Processor(XML_Parser parser,
    284297                                 const char *start,
    285298                                 const char *end,
     
    302315static Processor externalEntityContentProcessor;
    303316
    304 static enum XML_Error handleUnknownEncoding(XML_Parser parser,
     317static XMLERROR handleUnknownEncoding(XML_Parser parser,
    305318                                            const XML_Char * encodingName);
    306 static enum XML_Error processXmlDecl(XML_Parser parser,
     319static XMLERROR processXmlDecl(XML_Parser parser,
    307320                                     int isGeneralTextEntity,
    308321                                     const char *,
    309322                                     const char *);
    310 static enum XML_Error initializeEncoding(XML_Parser parser);
    311 static enum XML_Error doProlog(XML_Parser parser,
     323static XMLERROR initializeEncoding(XML_Parser parser);
     324static XMLERROR doProlog(XML_Parser parser,
    312325                               const ENCODING * enc,
    313326                               const char *s,
     
    316329                               const char *next,
    317330                               const char **nextPtr);
    318 static enum XML_Error processInternalParamEntity(XML_Parser parser,
     331static XMLERROR processInternalParamEntity(XML_Parser parser,
    319332                                                 ENTITY * entity);
    320 static enum XML_Error doContent(XML_Parser parser,
     333static XMLERROR doContent(XML_Parser parser,
    321334                                int startTagLevel,
    322335                                const ENCODING * enc,
     
    324337                                const char *end,
    325338                                const char **endPtr);
    326 static enum XML_Error doCdataSection(XML_Parser parser,
     339static XMLERROR doCdataSection(XML_Parser parser,
    327340                                     const ENCODING *,
    328341                                     const char **startPtr,
     
    331344
    332345#ifdef XML_DTD
    333 static enum XML_Error doIgnoreSection(XML_Parser parser,
     346static XMLERROR doIgnoreSection(XML_Parser parser,
    334347                                      const ENCODING *,
    335348                                      const char **startPtr,
     
    338351#endif /* XML_DTD */
    339352
    340 static enum XML_Error storeAtts(XML_Parser parser,
     353static XMLERROR storeAtts(XML_Parser parser,
    341354                                const ENCODING *,
    342355                                const char *s,
     
    356369                           XML_Parser parser);
    357370
    358 static enum XML_Error storeAttributeValue(XML_Parser parser,
     371static XMLERROR storeAttributeValue(XML_Parser parser,
    359372                                          const ENCODING *,
    360373                                          int isCdata,
     
    362375                                          const char *,
    363376                                          STRING_POOL *);
    364 static enum XML_Error appendAttributeValue(XML_Parser parser,
     377static XMLERROR appendAttributeValue(XML_Parser parser,
    365378                                           const ENCODING *,
    366379                                           int isCdata,
     
    373386                                     const char *end);
    374387static int setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *);
    375 static enum XML_Error storeEntityValue(XML_Parser parser,
     388static XMLERROR storeEntityValue(XML_Parser parser,
    376389                                       const ENCODING * enc,
    377390                                       const char *start,
     
    426439
    427440static int nextScaffoldPart(XML_Parser parser);
    428 static XML_Content *build_model(XML_Parser parser);
     441static XMLCONTENT *build_model(XML_Parser parser);
    429442
    430443static const XML_Char *poolCopyString(STRING_POOL * pool, const XML_Char * s);
     
    499512    PROLOG_STATE m_prologState;
    500513    Processor *m_processor;
    501     enum XML_Error m_errorCode;
     514    XMLERROR m_errorCode;
    502515    const char *m_eventPtr;
    503516    const char *m_eventEndPtr;
     
    631644 *@@ XML_ParserCreate:
    632645 *      constructs a new parser. If encoding is non-null, it specifies
    633  *      a character encoding to use for the document. This overrides
    634  *      the document encoding declaration.
     646 *      a character encoding to use for the document (see below).
     647 *      This overrides the document encoding declaration.
    635648 *
    636649 *      Expat is a stream-oriented parser. You register callback (or
     
    638651 *      the document. As the parser recognizes parts of the document,
    639652 *      it will call the appropriate handler for that part (if you've
    640  *      registered one.) The document is fed to the parser in pieces,
     653 *      registered one). The document is fed to the parser in pieces,
    641654 *      so you can start parsing before you have all the document.
    642655 *      This also allows you to parse really huge documents that won't
     
    685698 *
    686699 *      The things you're likely to want to keep on a stack are the
    687  *      currently opened element and it's attributes. You push this
     700 *      currently opened element and its attributes. You push this
    688701 *      information onto the stack in the start handler and you pop
    689702 *      it off in the end handler.
    690703 *
    691704 *      For some tasks, it is sufficient to just keep information on
    692  *      what the depth of the stack is (or would be if you had one.)
     705 *      what the depth of the stack is (or would be if you had one).
    693706 *      The outline program shown above presents one example. Another
    694707 *      such task would be skipping over a complete element. When you
     
    710723 *      While XML is based on Unicode, and every XML processor is
    711724 *      required to recognized UTF-8 and UTF-16 (1 and 2 byte
    712  *      encodings of Unicode), other encodings may be declared in
     725 *      encodings of Unicode), other @encodings may be declared in
    713726 *      XML documents or entities. For the main document, an XML
    714727 *      declaration may contain an encoding declaration in its
    715  *      @text_declaration:
    716  *
    717  +          <?xml version="1.0" encoding="ISO-8859-2"?>
     728 *      @text_declaration. See @encodings for additional
     729 *      information.
    718730 *
    719731 *      With expat, you may also specify an encoding at the time
    720732 *      of creating a parser. This is useful when the encoding
    721733 *      information may come from a source outside the document
    722  *      itself (like a higher level protocol.)
    723  *
    724  *      There are four built-in encodings in expat:
    725  *
    726  *      --   UTF-8: 8-bit encoding of Unicode.
    727  *
    728  *      --   UTF-16: 16-bit encoding of Unicode.
    729  *
    730  *      --   ISO-8859-1: that's "latin 1".
    731  *
    732  *      --   US-ASCII
    733  *
    734  *      Anything else discovered in an encoding declaration or in
    735  *      the protocol encoding specified in the parser constructor,
    736  *      triggers a call to the UnknownEncodingHandler (see
    737  *      XML_SetUnknownEncodingHandler). This handler gets passed
    738  *      the encoding name and a pointer to an XML_Encoding data
    739  *      structure. Your handler must fill in this structure and
    740  *      return 1 if it knows how to deal with the encoding. Otherwise
    741  *      the handler should return 0. The handler also gets passed a
    742  *      pointer to an optional application data structure that you may
    743  *      indicate when you set the handler.
     734 *      itself (like a higher level protocol).
     735 *
     736 *      See XML_SetUnknownEncodingHandler for encodings directly
     737 *      supported by expat and for how to handle other encodings.
    744738 *
    745739 *      One pitfall that novice expat users are likely to fall into is
     
    751745 *      <B>Handling External Entity References</B>
    752746 *
    753  *      Expat does not read or parse external entities directly. Note that
    754  *      any external @DTD is a special case of an external entity. If you've
    755  *      set no ExternalEntityRefHandler (see XML_SetExternalEntityRefHandler),
    756  *      then external entity references are silently ignored. Otherwise, it
    757  *      calls your handler with the information needed to read and parse the
    758  *      external entity.
    759  *
    760  *      <B>Parsing DTDs</B>
     747 *      Expat does not read or parse @external_entities directly. Note that
     748 *      any external @DTD is a special case of an external entity. For how to
     749 *      handle external entities, see XML_SetExternalEntityRefHandler.
     750 *
     751 *      <B>Parsing Parameter Entities</B>
    761752 *
    762753 *      In order to parse @parameter_entities, before starting the parse,
     
    933924    declNotationPublicId = 0;
    934925    memset(&position, 0, sizeof(POSITION));
    935     errorCode = XML_ERROR_NONE;
     926    errorCode = ERROR_EXPAT_NONE;
    936927    eventPtr = 0;
    937928    eventEndPtr = 0;
     
    13491340 *      This handler must have the following prototype:
    13501341 *
    1351  +          void EXPATENTRY StartElementHandler(void *userData,
    1352  +                                            const XML_Char *name,
    1353  +                                            const XML_Char **atts);
     1342 +          void EXPATENTRY StartElementHandler(void *pUserData,
     1343 +                                              const XML_Char *name,
     1344 +                                              const XML_Char **atts);
    13541345 +
    13551346 *      "data" is the user data pointer set with XML_SetUserData.
     
    13981389 *      Handler prototype:
    13991390 +
    1400  +          void EXPATENTRY (void *userData,
    1401  +                         const XML_Char *name);
     1391 +          void EXPATENTRY EndElementHandler(void *pUserData,
     1392 +                                            const XML_Char *name);
    14021393 */
    14031394
     
    14101401/*
    14111402 *@@ XML_SetCharacterDataHandler:
    1412  *      sets a character data (text) handler.
     1403 *      sets a character data (text, @content) handler.
    14131404 *
    14141405 *      Handler prototype:
    14151406 *
    1416  +          void EXPATENTRY CharacterDataHandler(void *userData,
    1417  +                                             const XML_Char *s,
    1418  +                                             int len);
     1407 +          void EXPATENTRY CharacterDataHandler(void *pUserData,
     1408 +                                               const XML_Char *s,
     1409 +                                               int len);
    14191410 +
    14201411 *      The string your handler receives is NOT zero terminated.
     
    14381429 *      Handler prototype:
    14391430 *
    1440  +          void EXPATENTRY ProcessingInstructionHandler(void *userData,
    1441  +                                                     const XML_Char *target,
    1442  +                                                     const XML_Char *data);
     1431 +          void EXPATENTRY ProcessingInstructionHandler(void *pUserData,
     1432 +                                                       const XML_Char *target,
     1433 +                                                       const XML_Char *data);
    14431434 +
    14441435 *      The target is the first word in the processing instruction. The data
     
    14601451 *      Handler prototype:
    14611452 *
    1462  +          void EXPATENTRY CommentHandler(void *userData,
    1463  +                                       const XML_Char *data);
     1453 +          void EXPATENTRY CommentHandler(void *pUserData,
     1454 +                                         const XML_Char *data);
    14641455 *
    14651456 */
     
    14921483 *      Handler prototype:
    14931484 *
    1494  +          void EXPATENTRY StartCdataSectionHandler(void *userData);
     1485 +          void EXPATENTRY StartCdataSectionHandler(void *pUserData);
    14951486 *
    14961487 */
     
    15091500 *      Handler prototype:
    15101501 *
    1511  *          void EXPATENTRY EndCdataSectionHandler(void *userData);
     1502 *          void EXPATENTRY EndCdataSectionHandler(void *pUserData);
    15121503 */
    15131504
     
    15291520 *      Handler prototype:
    15301521 +
    1531  +          void EXPATENTRY DefaultHandler(void *userData,
    1532  +                                       const XML_Char *s,
    1533  +                                       int len);
     1522 +          void EXPATENTRY DefaultHandler(void *pUserData,
     1523 +                                         const XML_Char *s,
     1524 +                                         int len);
    15341525 *
    15351526 *      The characters are passed exactly as they were in the XML
     
    15471538 *      turning off expansion of references to internally defined
    15481539 *      general entities. Instead these references are passed to
    1549  *      the default handler.
     1540 *      the default handler. To avoid that, use XML_SetDefaultHandlerExpand.
    15501541 */
    15511542
     
    15941585 *      Handler prototype:
    15951586 *
    1596  +          void EXPATENTRY StartDoctypeDeclHandler(void *userData,
    1597  +                                                const XML_Char *doctypeName,
    1598  +                                                const XML_Char *sysid,
    1599  +                                                const XML_Char *pubid,
    1600  +                                                int has_internal_subset);
    1601  *
    1602  *      Both sysid and pubid may be NULL. The has_internal_subset
     1587 +          void EXPATENTRY StartDoctypeDeclHandler(void *pUserData,
     1588 +                                                  const XML_Char *pcszDoctypeName,
     1589 +                                                  const XML_Char *pcszSysid,
     1590 +                                                  const XML_Char *pcszPubid,
     1591 +                                                  int fHasInternalSubset);
     1592 *
     1593 *      Both pcszSysid and pcszPubid may be NULL. "fHasInternalSubset"
    16031594 *      will be non-zero if the DOCTYPE declaration has an internal subset.
    16041595 */
     
    16171608 *      Handler prototype:
    16181609 *
    1619  +          void EXPATENTRY EndDoctypeDeclHandler(void *userData);
     1610 +          void EXPATENTRY EndDoctypeDeclHandler(void *pUserData);
    16201611 *
    16211612 */
     
    16511642 *      Handler prototype:
    16521643 +
    1653  +      void EXPATENTRY NotationDeclHandler(void *userData,
    1654  +                                        const XML_Char *notationName,
    1655  +                                        const XML_Char *base,
    1656  +                                        const XML_Char *systemId,
    1657  +                                        const XML_Char *publicId);
     1644 +      void EXPATENTRY NotationDeclHandler(void *pUserData,
     1645 +                                          const XML_Char *pcszNotationName,
     1646 +                                          const XML_Char *pcszBase,
     1647 +                                          const XML_Char *pcszSystemId,
     1648 +                                          const XML_Char *pcszPublicId);
    16581649 +
    16591650 */
     
    16891680 *      Handler prototype:
    16901681 *
    1691  +      void EXPATENTRY StartNamespaceDeclHandler(void *userData,
    1692  +                                              const XML_Char *prefix,
    1693  +                                              const XML_Char *uri);
     1682 +      void EXPATENTRY StartNamespaceDeclHandler(void *pUserData,
     1683 +                                                const XML_Char *prefix,
     1684 +                                                const XML_Char *uri);
    16941685 +
    16951686 */
     
    17101701 *      Handler prototype:
    17111702 +
    1712  +      void EXPATENTRY EndNamespaceDeclHandler)(void *userData,
    1713  +                                             const XML_Char *prefix);
     1703 +      void EXPATENTRY EndNamespaceDeclHandler(void *pUserData,
     1704 +                                              const XML_Char *prefix);
    17141705 */
    17151706
     
    17281719 *      not have standalone set to "yes" in an XML declaration.
    17291720 *      If this handler returns 0, then the parser will throw an
    1730  *      XML_ERROR_NOT_STANDALONE error.
     1721 *      ERROR_EXPAT_NOT_STANDALONE error.
    17311722 *
    17321723 *      Handler prototype:
    17331724 *
    1734  +          int EXPATENTRY NotStandaloneHandler(void *userData);
     1725 +          int EXPATENTRY NotStandaloneHandler(void *pUserData);
    17351726 */
    17361727
     
    17431734/*
    17441735 *@@ XML_SetExternalEntityRefHandler:
    1745  *      sets an external entity reference handler. This handler is
    1746  *      also called for processing an external DTD subset if
    1747  *      parameter entity parsing is in effect.
     1736 *      sets a handler for references to @external_entities.
     1737 *
     1738 *      This handler is also called for processing an external DTD
     1739 *      subset if parameter entity parsing is in effect.
    17481740 *      (See XML_SetParamEntityParsing.)
     1741 *
     1742 *      Warning: If you have set no ExternalEntityRefHandler, then
     1743 *      external entity references are silently ignored. Otherwise,
     1744 *      they trigger a call to your handler with the information
     1745 *      needed to read and parse the external entity.
    17491746 *
    17501747 *      Handler prototype:
    17511748 +
    17521749 +      int EXPATENTRY ExternalEntityRefHandler(XML_Parser parser,
    1753  +                                            const XML_Char *context,
    1754  +                                            const XML_Char *base,
    1755  +                                            const XML_Char *systemId,
    1756  +                                            const XML_Char *publicId);
     1750 +                                              const XML_Char *pcszContext,
     1751 +                                              const XML_Char *pcszBase,
     1752 +                                              const XML_Char *pcszSystemId,
     1753 +                                              const XML_Char *pcszPublicId);
    17571754 +
    1758  *      The context argument specifies the parsing context in the
     1755 *      The pcszContext argument specifies the parsing context in the
    17591756 *      format expected by the context argument to
    1760  *      XML_ExternalEntityParserCreate; context is valid only until
     1757 *      XML_ExternalEntityParserCreate; pcszContext is valid only until
    17611758 *      the handler returns, so if the referenced entity is to be
    17621759 *      parsed later, it must be copied.
    17631760 *
    1764  *      The base parameter is the base to use for relative system
     1761 *      The pcszBase parameter is the base to use for relative system
    17651762 *      identifiers. It is set by XML_SetBase and may be null.
    17661763 *
    1767  *      The publicId parameter is the public id given in the entity
     1764 *      The pcszPublicId parameter is the public id given in the entity
    17681765 *      declaration and may be null.
    17691766 *
    1770  *      The systemId is the system identifier specified in the
     1767 *      The pcszSystemId is the system identifier specified in the
    17711768 *      entity declaration and is never null.
    17721769 *
     
    17761773 *      of the external entity reference. Returning a zero indicates
    17771774 *      failure, and causes the calling parser to return an
    1778  *      XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
    1779  *
    1780  *      Second, instead of having userData as its first argument,
     1775 *      ERROR_EXPAT_EXTERNAL_ENTITY_HANDLING error.
     1776 *
     1777 *      Second, instead of having pUserData as its first argument,
    17811778 *      it receives the parser that encountered the entity reference.
    17821779 *      This, along with the context parameter, may be used as
     
    17901787 *      Your handler isn't actually responsible for parsing the entity,
    17911788 *      but it is responsible for creating a subsidiary parser with
    1792  *      XML_ExternalEntityParserCreate that will do the job. This returns
     1789 *      XML_ExternalEntityParserCreate that will do the job. That returns
    17931790 *      an instance of XML_Parser that has handlers and other data
    17941791 *      structures initialized from the parent parser. You may then use
    1795  *      XML_Parse or XML_ParseBuffer calls against this parser. Since
     1792 *      XML_Parse or XML_ParseBuffer calls against that parser. Since
    17961793 *      external entities may refer to other external entities, your
    17971794 *      handler should be prepared to be called recursively.
     
    18141811/*
    18151812 *@@ XML_SetUnknownEncodingHandler:
    1816  *      sets a handler to deal with encodings other than the
    1817  *      built in set (see XML_ParserCreate).
     1813 *      sets a handler to deal with @encodings other than the
     1814 *      built-in set.
     1815 *
     1816 *      There are four built-in encodings in expat:
     1817 *
     1818 *      --   UTF-8: 8-bit encoding of Unicode.
     1819 *
     1820 *      --   UTF-16: 16-bit encoding of Unicode.
     1821 *
     1822 *      --   ISO-8859-1: that's "latin 1".
     1823 *
     1824 *      --   US-ASCII
     1825 *
     1826 *      Anything else discovered in an encoding declaration or in
     1827 *      the protocol encoding specified in the parser constructor
     1828 *      triggers a call to the UnknownEncodingHandler.
    18181829 *
    18191830 *      Handler prototype:
    18201831 *
    18211832 +          int EXPATENTRY UnknownEncodingHandler(void *encodingHandlerData,
    1822  +                                              const XML_Char *name,
    1823  +                                              XML_Encoding *info);
     1833 +                                                const XML_Char *name,
     1834 +                                                XML_Encoding *info);
    18241835 +
    18251836 *      The encodingHandlerData argument is that which was passed as the
     
    18431854 *      1.  Every ASCII character that can appear in a well-formed XML
    18441855 *          document must be represented by a single byte, and that byte
    1845  *          must correspond to it's ASCII encoding (except for the
     1856 *          must correspond to its ASCII encoding (except for the
    18461857 *          characters $@\^'{}~).
    18471858 *
     
    18521863 *          the built-in support for UTF-16 and UTF-8.)
    18531864 *
    1854  *      4.  No character may be encoded by more that one distinct
     1865 *      4.  No character may be encoded by more than one distinct
    18551866 *          sequence of bytes.
    18561867 */
     
    18661877/*
    18671878 *@@ XML_SetElementDeclHandler:
    1868  *      sets a handler for element declarations in a DTD. The
     1879 *      sets a handler for an @element_declaration in a @DTD. The
    18691880 *      handler gets called with the name of the element in
    18701881 *      the declaration and a pointer to a structure that contains
     
    18741885 *      This handler must have the following prototype:
    18751886 *
    1876  +          void EXPATENTRY ElementDeclHandler(void *userData,
    1877  +                                           const XML_Char *name,
    1878  +                                           XML_Content *model);
    1879  *
    1880  *      The model argument is the root of a tree of XML_Content
    1881  *      nodes. If type equals XML_CTYPE_EMPTY or XML_CTYPE_ANY,
    1882  *      then quant will be XML_CQUANT_NONE, and the other fields
    1883  *      will be zero or NULL.
    1884  *
    1885  *      If type is XML_CTYPE_MIXED, then quant will be
    1886  *      XML_CQUANT_NONE or XML_CQUANT_REP and numchildren will
    1887  *      contain the number of elements that are allowed to be
    1888  *      mixed in and children points to an array of XML_Content
    1889  *      structures that will all have type XML_CTYPE_NAME with no
    1890  *      quantification. Only the root node can be type
    1891  *      XML_CTYPE_EMPTY, XML_CTYPE_ANY, or XML_CTYPE_MIXED.
    1892  *
    1893  *      For type XML_CTYPE_NAME, the name field points to the
    1894  *      name and the numchildren and children fields will be
    1895  *      zero and NULL. The quant field will indicate any
    1896  *      quantifiers placed on the name.
    1897  *
    1898  *      Types XML_CTYPE_CHOICE and XML_CTYPE_SEQ indicate a
    1899  *      choice or sequence respectively. The numchildren field
    1900  *      indicates how many nodes in the choice or sequence and
    1901  *      children points to the nodes.
     1887 +          void EXPATENTRY ElementDeclHandler(void *pUserData,
     1888 +                                             const XML_Char *name,
     1889 +                                             XMLCONTENT *model);
     1890 *
     1891 *      See _XMLCONTENT for details.
    19021892 */
    19031893
     
    19101900/*
    19111901 *@@ XML_SetAttlistDeclHandler:
    1912  *      sets a handler for attlist declarations in the DTD.
     1902 *      sets a handler for an @attribute_declaration in the @DTD.
    19131903 *
    19141904 *      This handler must have the following prototype:
    19151905 *
    1916  +          void EXPATENTRY AttlistDeclHandler(void *userData,
    1917  +                                           const XML_Char  *elname,
    1918  +                                           const XML_Char  *attname,
    1919  +                                           const XML_Char  *att_type,
    1920  +                                           const XML_Char  *dflt,
    1921  +                                           int     isrequired);
     1906 +          void EXPATENTRY AttlistDeclHandler(void *pUserData,
     1907 +                                             const XML_Char *pcszElementName,
     1908 +                                             const XML_Char *pcszAttribName,
     1909 +                                             const XML_Char *pcszAttribType,
     1910 +                                             const XML_Char *pcszDefault,
     1911 +                                             int fIsRequired);
    19221912 *
    19231913 *      This handler is called for each attribute. So a single attlist
    19241914 *      declaration with multiple attributes declared will generate
    1925  *      multiple calls to this handler. The elname parameter
    1926  *      returns the name of the element for which the attribute
    1927  *      is being declared. The attribute name is in the attname
    1928  *      parameter. The attribute type is in the att_type parameter.
    1929  *      It is the string representing the type in the declaration
    1930  *      with whitespace removed.
    1931  *
    1932  *      The dflt parameter holds the default value. It will be
    1933  *      NULL in the case of "#IMPLIED" or "#REQUIRED" attributes.
    1934  *      You can distinguish these two cases by checking the
    1935  *      isrequired parameter, which will be true in the case of
    1936  *      "#REQUIRED" attributes. Attributes which are "#FIXED"
    1937  *      will have also have a true isrequired, but they will have
    1938  *      the non-NULL fixed value in the dflt parameter.
     1915 *      multiple calls to this handler.
     1916 *
     1917 *      --  pcszElementName is the name of the  element for which the
     1918 *          attribute is being declared.
     1919 *
     1920 *      --  pcszAttribName has the attribute name being declared.
     1921 *
     1922 *      --  pcszAttribType is the attribute type.
     1923 *          It is the string representing the type in the declaration
     1924 *          with whitespace removed.
     1925 *
     1926 *      --  pcszDefault holds the default value. It will be
     1927 *          NULL in the case of "#IMPLIED" or "#REQUIRED" attributes.
     1928 *          You can distinguish these two cases by checking the
     1929 *          fIsRequired parameter, which will be true in the case of
     1930 *          "#REQUIRED" attributes. Attributes which are "#FIXED"
     1931 *          will have also have a TRUE fIsRequired, but they will have
     1932 *          the non-NULL fixed value in the pcszDefault parameter.
    19391933 */
    19401934
     
    19511945 *      Handler prototype:
    19521946 *
    1953  +          void EXPATENTRY EntityDeclHandler(void *userData,
    1954  +                                          const XML_Char *entityName,
    1955  +                                          int is_parameter_entity,
    1956  +                                          const XML_Char *value,
    1957  +                                          int value_length,
    1958  +                                          const XML_Char *base,
    1959  +                                          const XML_Char *systemId,
    1960  +                                          const XML_Char *publicId,
    1961  +                                          const XML_Char *notationName);
     1947 +          void EXPATENTRY EntityDeclHandler(void *pUserData,
     1948 +                                            const XML_Char *pcszEntityName,
     1949 +                                            int fIsParameterEntity,
     1950 +                                            const XML_Char *pcszValue,
     1951 +                                            int iValueLength,
     1952 +                                            const XML_Char *pcszBase,
     1953 +                                            const XML_Char *pcszSystemId,
     1954 +                                            const XML_Char *pcszPublicId,
     1955 +                                            const XML_Char *pcszNotationName);
    19621956 +
    1963  *      The is_parameter_entity argument will be non-zero in the case
     1957 *      The fIsParameterEntity argument will be non-zero in the case
    19641958 *      of parameter entities and zero otherwise.
    19651959 *
    1966  *      For internal entities (<!ENTITY foo "bar">), value will be
    1967  *      non-NULL and systemId, publicId, and notationName will all
    1968  *      be NULL. The value string is not NULL terminated; the length
    1969  *      is provided in the value_length parameter. Do not use
    1970  *      value_length to test for internal entities, since it is legal
     1960 *      For internal entities (<!ENTITY foo "bar">), pcszValue will be
     1961 *      non-NULL and pcszSystemId, pcszPublicId, and pcszNotationName
     1962 *      will all be NULL. The value string is not NULL terminated; the
     1963 *      lengthis provided in the iValueLength parameter. Do not use
     1964 *      iValueLength to test for internal entities, since it is legal
    19711965 *      to have zero-length values. Instead check for whether or not
    1972  *      value is NULL.
    1973  *
    1974  *      The notationName argument will have a non-NULL value only for
    1975  *      unparsed entity declarations.
     1966 *      pcszValue is NULL.
     1967 *
     1968 *      The pcszNotationName argument will have a non-NULL value only
     1969 *      for unparsed entity declarations.
    19761970 */
    19771971
     
    19891983 *      Handler prototype:
    19901984 *
    1991  +          void EXPATENTRY XmlDeclHandler(void           *userData,
    1992  +                                       const XML_Char *version,
    1993  +                                       const XML_Char *encoding,
    1994  +                                       int            standalone);
     1985 +          void EXPATENTRY XmlDeclHandler(void *pUserData,
     1986 +                                         const XML_Char *pcszVersion,
     1987 +                                         const XML_Char *pcszEncoding,
     1988 +                                         int standalone);
    19951989 *
    19961990 *      The way to distinguish is that the version parameter will
     
    20102004/*
    20112005 *@@ XML_SetParamEntityParsing:
    2012  *      this enables parsing of parameter entities, including the
    2013  *      external parameter entity that is the external DTD subset,
    2014  *      according to code. The choices for code are:
     2006 *      this enables parsing of @parameter_entities, including the
     2007 *      external parameter entity that is the external @DTD subset,
     2008 *      according to code.
     2009 *
     2010 *      If parsing of parameter entities is enabled, then references
     2011 *      to external parameter entities (including the external DTD
     2012 *      subset) will be passed to the handler set with
     2013 *      XML_SetExternalEntityRefHandler. The context passed will be 0.
     2014 *
     2015 *      Unlike external general entities, external parameter entities
     2016 *      can only be parsed synchronously. If the external parameter
     2017 *      entity is to be parsed, it must be parsed during the call to
     2018 *      the external entity ref handler: the complete sequence of
     2019 *      XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
     2020 *      XML_ParserFree calls must be made during this call.
     2021 *
     2022 *      After XML_ExternalEntityParserCreate has been called to create
     2023 *      the parser for the external parameter entity (context must be 0
     2024 *      for this call), it is illegal to make any calls on the old parser
     2025 *      until XML_ParserFree has been called on the newly created parser.
     2026 *      If the library has been compiled without support for parameter
     2027 *      entity parsing (ie without XML_DTD being defined), then
     2028 *      XML_SetParamEntityParsing will return 0 if parsing of parameter
     2029 *      entities is requested; otherwise it will return non-zero.
     2030 *
     2031 *      NOTE: The xwphelpers implementation #defines XML_DTD in
     2032 *      include\expat\expat_setup.h, which is included in all expat
     2033 *      files.
     2034 *
     2035 *      The choices for code are:
    20152036 *
    20162037 *      --  XML_PARAM_ENTITY_PARSING_NEVER:
    2017  *          Don't parse parameter entities or the external subset
     2038 *          Don't parse parameter entities or the external subset.
     2039 *          This is the only choice if XML_DTD is not defined.
    20182040 *
    20192041 *      --  XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE:
    2020  *          Parse parameter entites and the external subset unless
     2042 *          Parse parameter entities and the external subset unless
    20212043 *          standalone was set to "yes" in the XML declaration.
    20222044 *
     
    20672089            return 1;
    20682090        positionPtr = bufferPtr;
    2069         errorCode = processor(parser, bufferPtr, parseEndPtr = bufferEnd, 0);
    2070         if (errorCode == XML_ERROR_NONE)
     2091        errorCode = processor(parser,
     2092                              bufferPtr,
     2093                              parseEndPtr = bufferEnd,
     2094                              0);
     2095        if (errorCode == ERROR_EXPAT_NONE)
    20712096            return 1;
    20722097        eventEndPtr = eventPtr;
     
    20842109        if (isFinal)
    20852110        {
    2086             errorCode = processor(parser, s, parseEndPtr = s + len, 0);
    2087             if (errorCode == XML_ERROR_NONE)
     2111            errorCode = processor(parser,
     2112                                  s,
     2113                                  parseEndPtr = s + len,
     2114                                  0);
     2115            if (errorCode == ERROR_EXPAT_NONE)
    20882116                return 1;
    20892117            eventEndPtr = eventPtr;
     
    20922120        }
    20932121        errorCode = processor(parser, s, parseEndPtr = s + len, &end);
    2094         if (errorCode != XML_ERROR_NONE)
     2122        if (errorCode != ERROR_EXPAT_NONE)
    20952123        {
    20962124            eventEndPtr = eventPtr;
     
    21092137                if (!buffer)
    21102138                {
    2111                     errorCode = XML_ERROR_NO_MEMORY;
     2139                    errorCode = ERROR_EXPAT_NO_MEMORY;
    21122140                    eventPtr = eventEndPtr = 0;
    21132141                    processor = errorProcessor;
     
    21472175    errorCode = processor(parser, start, parseEndPtr = bufferEnd,
    21482176                          isFinal ? (const char **)0 : &bufferPtr);
    2149     if (errorCode == XML_ERROR_NONE)
     2177    if (errorCode == ERROR_EXPAT_NONE)
    21502178    {
    21512179        if (!isFinal)
     
    22362264            if (newBuf == 0)
    22372265            {
    2238                 errorCode = XML_ERROR_NO_MEMORY;
     2266                errorCode = ERROR_EXPAT_NO_MEMORY;
    22392267                return 0;
    22402268            }
     
    22892317 */
    22902318
    2291 enum XML_Error XML_GetErrorCode(XML_Parser parser)
     2319XMLERROR XML_GetErrorCode(XML_Parser parser)
    22922320{
    22932321    return errorCode;
     
    23572385 *      returns the line number of the position.
    23582386 *
    2359  *      To be called on parser errors. See XML_GetErrorCode.
     2387 *      Can be called on parser errors. See XML_GetErrorCode.
    23602388 */
    23612389
     
    23752403 *      line, of the position.
    23762404 *
    2377  *      To be called on parser errors. See XML_GetErrorCode.
     2405 *      Can be called on parser errors. See XML_GetErrorCode.
    23782406 */
    23792407
     
    24082436
    24092437/*
    2410  *@@ XML_ErrorString:
    2411  *      returns a string describing the error corresponding to code.
    2412  *      The code should be one of the enums that can be returned from
    2413  *      XML_GetErrorCode.
    2414  */
    2415 
    2416 const XML_LChar* XML_ErrorString(int code)
    2417 {
    2418     static const XML_LChar *message[] =
    2419     {
    2420         0,
    2421         XML_T("out of memory"),
    2422         XML_T("syntax error"),
    2423         XML_T("no element found"),
    2424         XML_T("not well-formed (invalid token)"),
    2425         XML_T("unclosed token"),
    2426         XML_T("unclosed token"),
    2427         XML_T("mismatched tag"),
    2428         XML_T("duplicate attribute"),
    2429         XML_T("junk after document element"),
    2430         XML_T("illegal parameter entity reference"),
    2431         XML_T("undefined entity"),
    2432         XML_T("recursive entity reference"),
    2433         XML_T("asynchronous entity"),
    2434         XML_T("reference to invalid character number"),
    2435         XML_T("reference to binary entity"),
    2436         XML_T("reference to external entity in attribute"),
    2437         XML_T("xml processing instruction not at start of external entity"),
    2438         XML_T("unknown encoding"),
    2439         XML_T("encoding specified in XML declaration is incorrect"),
    2440         XML_T("unclosed CDATA section"),
    2441         XML_T("error in processing external entity reference"),
    2442         XML_T("document is not standalone"),
    2443         XML_T("unexpected parser state - please send a bug report")
    2444     };
    2445 
    2446     if (code > 0 && code < sizeof(message) / sizeof(message[0]))
    2447         return message[code];
    2448     return 0;
    2449 }
    2450 
    2451 /*
    24522438 *@@ XML_ExpatVersion:
    24532439 *      returns the library version string (e.g. "expat_1.95.1").
     
    24592445}
    24602446
    2461 static enum XML_Error contentProcessor(XML_Parser parser,
     2447static XMLERROR contentProcessor(XML_Parser parser,
    24622448                                       const char *start,
    24632449                                       const char *end,
     
    24672453}
    24682454
    2469 static enum XML_Error externalEntityInitProcessor(XML_Parser parser,
     2455static XMLERROR externalEntityInitProcessor(XML_Parser parser,
    24702456                                                  const char *start,
    24712457                                                  const char *end,
    24722458                                                  const char **endPtr)
    24732459{
    2474     enum XML_Error result = initializeEncoding(parser);
    2475 
    2476     if (result != XML_ERROR_NONE)
     2460    XMLERROR result = initializeEncoding(parser);
     2461
     2462    if (result != ERROR_EXPAT_NONE)
    24772463        return result;
    24782464    processor = externalEntityInitProcessor2;
     
    24802466}
    24812467
    2482 static enum XML_Error externalEntityInitProcessor2(XML_Parser parser,
     2468static XMLERROR externalEntityInitProcessor2(XML_Parser parser,
    24832469                                                   const char *start,
    24842470                                                   const char *end,
     
    24972483            {
    24982484                *endPtr = start;
    2499                 return XML_ERROR_NONE;
     2485                return ERROR_EXPAT_NONE;
    25002486            }
    25012487            eventPtr = start;
    2502             return XML_ERROR_UNCLOSED_TOKEN;
     2488            return ERROR_EXPAT_UNCLOSED_TOKEN;
    25032489        case XML_TOK_PARTIAL_CHAR:
    25042490            if (endPtr)
    25052491            {
    25062492                *endPtr = start;
    2507                 return XML_ERROR_NONE;
     2493                return ERROR_EXPAT_NONE;
    25082494            }
    25092495            eventPtr = start;
    2510             return XML_ERROR_PARTIAL_CHAR;
     2496            return ERROR_EXPAT_PARTIAL_CHAR;
    25112497    }
    25122498    processor = externalEntityInitProcessor3;
     
    25142500}
    25152501
    2516 static enum XML_Error externalEntityInitProcessor3(XML_Parser parser,
     2502static XMLERROR externalEntityInitProcessor3(XML_Parser parser,
    25172503                                                   const char *start,
    25182504                                                   const char *end,
     
    25262512        case XML_TOK_XML_DECL:
    25272513            {
    2528                 enum XML_Error result = processXmlDecl(parser, 1, start, next);
    2529 
    2530                 if (result != XML_ERROR_NONE)
     2514                XMLERROR result = processXmlDecl(parser, 1, start, next);
     2515
     2516                if (result != ERROR_EXPAT_NONE)
    25312517                    return result;
    25322518                start = next;
     
    25372523            {
    25382524                *endPtr = start;
    2539                 return XML_ERROR_NONE;
     2525                return ERROR_EXPAT_NONE;
    25402526            }
    25412527            eventPtr = start;
    2542             return XML_ERROR_UNCLOSED_TOKEN;
     2528            return ERROR_EXPAT_UNCLOSED_TOKEN;
    25432529        case XML_TOK_PARTIAL_CHAR:
    25442530            if (endPtr)
    25452531            {
    25462532                *endPtr = start;
    2547                 return XML_ERROR_NONE;
     2533                return ERROR_EXPAT_NONE;
    25482534            }
    25492535            eventPtr = start;
    2550             return XML_ERROR_PARTIAL_CHAR;
     2536            return ERROR_EXPAT_PARTIAL_CHAR;
    25512537    }
    25522538    processor = externalEntityContentProcessor;
     
    25552541}
    25562542
    2557 static enum XML_Error externalEntityContentProcessor(XML_Parser parser,
     2543static XMLERROR externalEntityContentProcessor(XML_Parser parser,
    25582544                                                     const char *start,
    25592545                                                     const char *end,
     
    25632549}
    25642550
    2565 static enum XML_Error
     2551static XMLERROR
    25662552 doContent(XML_Parser parser,
    25672553           int startTagLevel,
     
    25972583                {
    25982584                    *nextPtr = s;
    2599                     return XML_ERROR_NONE;
     2585                    return ERROR_EXPAT_NONE;
    26002586                }
    26012587                *eventEndPP = end;
     
    26092595                    reportDefault(parser, enc, s, end);
    26102596                if (startTagLevel == 0)
    2611                     return XML_ERROR_NO_ELEMENTS;
     2597                    return ERROR_EXPAT_NO_ELEMENTS;
    26122598                if (tagLevel != startTagLevel)
    2613                     return XML_ERROR_ASYNC_ENTITY;
    2614                 return XML_ERROR_NONE;
     2599                    return ERROR_EXPAT_ASYNC_ENTITY;
     2600                return ERROR_EXPAT_NONE;
    26152601            case XML_TOK_NONE:
    26162602                if (nextPtr)
    26172603                {
    26182604                    *nextPtr = s;
    2619                     return XML_ERROR_NONE;
     2605                    return ERROR_EXPAT_NONE;
    26202606                }
    26212607                if (startTagLevel > 0)
    26222608                {
    26232609                    if (tagLevel != startTagLevel)
    2624                         return XML_ERROR_ASYNC_ENTITY;
    2625                     return XML_ERROR_NONE;
    2626                 }
    2627                 return XML_ERROR_NO_ELEMENTS;
     2610                        return ERROR_EXPAT_ASYNC_ENTITY;
     2611                    return ERROR_EXPAT_NONE;
     2612                }
     2613                return ERROR_EXPAT_NO_ELEMENTS;
    26282614            case XML_TOK_INVALID:
    26292615                *eventPP = next;
    2630                 return XML_ERROR_INVALID_TOKEN;
     2616                return ERROR_EXPAT_INVALID_TOKEN;
    26312617            case XML_TOK_PARTIAL:
    26322618                if (nextPtr)
    26332619                {
    26342620                    *nextPtr = s;
    2635                     return XML_ERROR_NONE;
    2636                 }
    2637                 return XML_ERROR_UNCLOSED_TOKEN;
     2621                    return ERROR_EXPAT_NONE;
     2622                }
     2623                return ERROR_EXPAT_UNCLOSED_TOKEN;
    26382624            case XML_TOK_PARTIAL_CHAR:
    26392625                if (nextPtr)
    26402626                {
    26412627                    *nextPtr = s;
    2642                     return XML_ERROR_NONE;
    2643                 }
    2644                 return XML_ERROR_PARTIAL_CHAR;
     2628                    return ERROR_EXPAT_NONE;
     2629                }
     2630                return ERROR_EXPAT_PARTIAL_CHAR;
    26452631            case XML_TOK_ENTITY_REF:
    26462632                {
     
    26632649                                           next - enc->minBytesPerChar);
    26642650                    if (!name)
    2665                         return XML_ERROR_NO_MEMORY;
     2651                        return ERROR_EXPAT_NO_MEMORY;
    26662652                    entity = (ENTITY*)lookup(&dtd.generalEntities, name, 0);
    26672653                    poolDiscard(&dtd.pool);
     
    26692655                    {
    26702656                        if (dtd.complete || dtd.standalone)
    2671                             return XML_ERROR_UNDEFINED_ENTITY;
     2657                            return ERROR_EXPAT_UNDEFINED_ENTITY;
    26722658                        if (defaultHandler)
    26732659                            reportDefault(parser, enc, s, next);
     
    26752661                    }
    26762662                    if (entity->open)
    2677                         return XML_ERROR_RECURSIVE_ENTITY_REF;
     2663                        return ERROR_EXPAT_RECURSIVE_ENTITY_REF;
    26782664                    if (entity->notation)
    2679                         return XML_ERROR_BINARY_ENTITY_REF;
     2665                        return ERROR_EXPAT_BINARY_ENTITY_REF;
    26802666                    if (entity)
    26812667                    {
    26822668                        if (entity->textPtr)
    26832669                        {
    2684                             enum XML_Error result;
     2670                            XMLERROR result;
    26852671                            OPEN_INTERNAL_ENTITY openEntity;
    26862672
     
    27152701                            entity->open = 0;
    27162702                            if (!context)
    2717                                 return XML_ERROR_NO_MEMORY;
     2703                                return ERROR_EXPAT_NO_MEMORY;
    27182704                            if (!externalEntityRefHandler(externalEntityRefHandlerArg,
    27192705                                                          context,
     
    27212707                                                          entity->systemId,
    27222708                                                          entity->publicId))
    2723                                 return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
     2709                                return ERROR_EXPAT_EXTERNAL_ENTITY_HANDLING;
    27242710                            poolDiscard(&tempPool);
    27252711                        }
     
    27322718                if (!startElementHandler)
    27332719                {
    2734                     enum XML_Error result = storeAtts(parser, enc, s, 0, 0);
     2720                    XMLERROR result = storeAtts(parser, enc, s, 0, 0);
    27352721
    27362722                    if (result)
     
    27512737                        tag = (TAG*)MALLOC(sizeof(TAG));
    27522738                        if (!tag)
    2753                             return XML_ERROR_NO_MEMORY;
     2739                            return ERROR_EXPAT_NO_MEMORY;
    27542740                        tag->buf = (char*)MALLOC(INIT_TAG_BUF_SIZE);
    27552741                        if (!tag->buf)
    2756                             return XML_ERROR_NO_MEMORY;
     2742                            return ERROR_EXPAT_NO_MEMORY;
    27572743                        tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE;
    27582744                    }
     
    27742760                            tag->buf = (char*)REALLOC(tag->buf, bufSize);
    27752761                            if (!tag->buf)
    2776                                 return XML_ERROR_NO_MEMORY;
     2762                                return ERROR_EXPAT_NO_MEMORY;
    27772763                            tag->bufEnd = tag->buf + bufSize;
    27782764                        }
     
    27832769                    if (startElementHandler)
    27842770                    {
    2785                         enum XML_Error result;
     2771                        XMLERROR result;
    27862772                        XML_Char *toPtr;
    27872773
     
    28052791                            tag->buf = (char*)REALLOC(tag->buf, bufSize);
    28062792                            if (!tag->buf)
    2807                                 return XML_ERROR_NO_MEMORY;
     2793                                return ERROR_EXPAT_NO_MEMORY;
    28082794                            tag->bufEnd = tag->buf + bufSize;
    28092795                            if (nextPtr)
     
    28282814                if (!startElementHandler)
    28292815                {
    2830                     enum XML_Error result = storeAtts(parser, enc, s, 0, 0);
     2816                    XMLERROR result = storeAtts(parser, enc, s, 0, 0);
    28312817
    28322818                    if (result)
     
    28382824                {
    28392825                    const char *rawName = s + enc->minBytesPerChar;
    2840                     enum XML_Error result;
     2826                    XMLERROR result;
    28412827                    BINDING *bindings = 0;
    28422828                    TAG_NAME name;
     
    28452831                                       rawName + XmlNameLength(enc, rawName));
    28462832                    if (!name.str)
    2847                         return XML_ERROR_NO_MEMORY;
     2833                        return ERROR_EXPAT_NO_MEMORY;
    28482834                    poolFinish(&tempPool);
    28492835                    result = storeAtts(parser, enc, s, &name, &bindings);
     
    28792865            case XML_TOK_END_TAG:
    28802866                if (tagLevel == startTagLevel)
    2881                     return XML_ERROR_ASYNC_ENTITY;
     2867                    return ERROR_EXPAT_ASYNC_ENTITY;
    28822868                else
    28832869                {
     
    28952881                    {
    28962882                        *eventPP = rawName;
    2897                         return XML_ERROR_TAG_MISMATCH;
     2883                        return ERROR_EXPAT_TAG_MISMATCH;
    28982884                    }
    28992885                    --tagLevel;
     
    29322918
    29332919                    if (n < 0)
    2934                         return XML_ERROR_BAD_CHAR_REF;
     2920                        return ERROR_EXPAT_BAD_CHAR_REF;
    29352921                    if (characterDataHandler)
    29362922                    {
     
    29442930                break;
    29452931            case XML_TOK_XML_DECL:
    2946                 return XML_ERROR_MISPLACED_XML_PI;
     2932                return ERROR_EXPAT_MISPLACED_XML_PI;
    29472933            case XML_TOK_DATA_NEWLINE:
    29482934                if (characterDataHandler)
     
    29572943            case XML_TOK_CDATA_SECT_OPEN:
    29582944                {
    2959                     enum XML_Error result;
     2945                    XMLERROR result;
    29602946
    29612947                    if (startCdataSectionHandler)
     
    29902976                {
    29912977                    *nextPtr = s;
    2992                     return XML_ERROR_NONE;
     2978                    return ERROR_EXPAT_NONE;
    29932979                }
    29942980                if (characterDataHandler)
     
    30112997                {
    30122998                    *eventPP = end;
    3013                     return XML_ERROR_NO_ELEMENTS;
     2999                    return ERROR_EXPAT_NO_ELEMENTS;
    30143000                }
    30153001                if (tagLevel != startTagLevel)
    30163002                {
    30173003                    *eventPP = end;
    3018                     return XML_ERROR_ASYNC_ENTITY;
    3019                 }
    3020                 return XML_ERROR_NONE;
     3004                    return ERROR_EXPAT_ASYNC_ENTITY;
     3005                }
     3006                return ERROR_EXPAT_NONE;
    30213007            case XML_TOK_DATA_CHARS:
    30223008                if (characterDataHandler)
     
    30463032            case XML_TOK_PI:
    30473033                if (!reportProcessingInstruction(parser, enc, s, next))
    3048                     return XML_ERROR_NO_MEMORY;
     3034                    return ERROR_EXPAT_NO_MEMORY;
    30493035                break;
    30503036            case XML_TOK_COMMENT:
    30513037                if (!reportComment(parser, enc, s, next))
    3052                     return XML_ERROR_NO_MEMORY;
     3038                    return ERROR_EXPAT_NO_MEMORY;
    30533039                break;
    30543040            default:
     
    30653051 * otherwise just check the attributes for well-formedness. */
    30663052
    3067 static enum XML_Error storeAtts(XML_Parser parser,
     3053static XMLERROR storeAtts(XML_Parser parser,
    30683054                                const ENCODING * enc,
    30693055                                const char *attStr,
     
    30893075            tagNamePtr->str = poolCopyString(&dtd.pool, tagNamePtr->str);
    30903076            if (!tagNamePtr->str)
    3091                 return XML_ERROR_NO_MEMORY;
     3077                return ERROR_EXPAT_NO_MEMORY;
    30923078            elementType = (ELEMENT_TYPE*)lookup(&dtd.elementTypes, tagNamePtr->str, sizeof(ELEMENT_TYPE));
    30933079            if (!elementType)
    3094                 return XML_ERROR_NO_MEMORY;
     3080                return ERROR_EXPAT_NO_MEMORY;
    30953081            if (ns && !setElementTypePrefix(parser, elementType))
    3096                 return XML_ERROR_NO_MEMORY;
     3082                return ERROR_EXPAT_NO_MEMORY;
    30973083        }
    30983084        nDefaultAtts = elementType->nDefaultAtts;
     
    31073093        atts = (PATTRIBUTE)REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE));
    31083094        if (!atts)
    3109             return XML_ERROR_NO_MEMORY;
     3095            return ERROR_EXPAT_NO_MEMORY;
    31103096        if (n > oldAttsSize)
    31113097            XmlGetAttributes(enc, attStr, n, atts);
     
    31203106
    31213107        if (!attId)
    3122             return XML_ERROR_NO_MEMORY;
     3108            return ERROR_EXPAT_NO_MEMORY;
    31233109        /* detect duplicate attributes */
    31243110        if ((attId->name)[-1])
     
    31263112            if (enc == encoding)
    31273113                eventPtr = atts[i].name;
    3128             return XML_ERROR_DUPLICATE_ATTRIBUTE;
     3114            return ERROR_EXPAT_DUPLICATE_ATTRIBUTE;
    31293115        }
    31303116        (attId->name)[-1] = 1;
     
    31323118        if (!atts[i].normalized)
    31333119        {
    3134             enum XML_Error result;
     3120            XMLERROR result;
    31353121            int isCdata = 1;
    31363122
     
    31693155            appAtts[attIndex] = poolStoreString(&tempPool, enc, atts[i].valuePtr, atts[i].valueEnd);
    31703156            if (appAtts[attIndex] == 0)
    3171                 return XML_ERROR_NO_MEMORY;
     3157                return ERROR_EXPAT_NO_MEMORY;
    31723158            poolFinish(&tempPool);
    31733159        }
     
    31793165                /* deal with namespace declarations here */
    31803166                if (!addBinding(parser, attId->prefix, attId, appAtts[attIndex], bindingsPtr))
    3181                     return XML_ERROR_NO_MEMORY;
     3167                    return ERROR_EXPAT_NO_MEMORY;
    31823168                --attIndex;
    31833169            }
     
    32213207                    {
    32223208                        if (!addBinding(parser, da->id->prefix, da->id, da->value, bindingsPtr))
    3223                             return XML_ERROR_NO_MEMORY;
     3209                            return ERROR_EXPAT_NO_MEMORY;
    32243210                    }
    32253211                    else
     
    32623248                    {
    32633249                        if (!poolAppendChar(&tempPool, b->uri[j]))
    3264                             return XML_ERROR_NO_MEMORY;
     3250                            return ERROR_EXPAT_NO_MEMORY;
    32653251                    }
    32663252                    while (*s++ != ':')
     
    32693255                    {
    32703256                        if (!poolAppendChar(&tempPool, *s))
    3271                             return XML_ERROR_NO_MEMORY;
     3257                            return ERROR_EXPAT_NO_MEMORY;
    32723258                    }
    32733259                    while (*s++);
     
    32793265                        {
    32803266                            if (!poolAppendChar(&tempPool, *s))
    3281                                 return XML_ERROR_NO_MEMORY;
     3267                                return ERROR_EXPAT_NO_MEMORY;
    32823268                        }
    32833269                        while (*s++);
     
    32983284        ((XML_Char*)(appAtts[i]))[-1] = 0;
    32993285    if (!tagNamePtr)
    3300         return XML_ERROR_NONE;
     3286        return ERROR_EXPAT_NONE;
    33013287    for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding)
    33023288        binding->attId->name[-1] = 0;
     
    33063292        binding = elementType->prefix->binding;
    33073293        if (!binding)
    3308             return XML_ERROR_NONE;
     3294            return ERROR_EXPAT_NONE;
    33093295        localPart = tagNamePtr->str;
    33103296        while (*localPart++ != XML_T(':'))
     
    33173303    }
    33183304    else
    3319         return XML_ERROR_NONE;
     3305        return ERROR_EXPAT_NONE;
    33203306    tagNamePtr->localPart = localPart;
    33213307    tagNamePtr->uriLen = binding->uriLen;
     
    33293315
    33303316        if (!uri)
    3331             return XML_ERROR_NO_MEMORY;
     3317            return ERROR_EXPAT_NO_MEMORY;
    33323318        binding->uriAlloc = n + EXPAND_SPARE;
    33333319        memcpy(uri, binding->uri, binding->uriLen * sizeof(XML_Char));
     
    33403326    memcpy(binding->uri + binding->uriLen, localPart, i * sizeof(XML_Char));
    33413327    tagNamePtr->str = binding->uri;
    3342     return XML_ERROR_NONE;
     3328    return ERROR_EXPAT_NONE;
    33433329}
    33443330
     
    33993385 * the whole file is parsed with one call. */
    34003386
    3401 static enum XML_Error cdataSectionProcessor(XML_Parser parser,
     3387static XMLERROR cdataSectionProcessor(XML_Parser parser,
    34023388                                     const char *start,
    34033389                                     const char *end,
    34043390                                     const char **endPtr)
    34053391{
    3406     enum XML_Error result = doCdataSection(parser, encoding, &start, end, endPtr);
     3392    XMLERROR result = doCdataSection(parser, encoding, &start, end, endPtr);
    34073393
    34083394    if (start)
     
    34173403 * the section is not yet closed. */
    34183404
    3419 static enum XML_Error doCdataSection(XML_Parser parser,
     3405static XMLERROR doCdataSection(XML_Parser parser,
    34203406                              const ENCODING * enc,
    34213407                              const char **startPtr,
     
    34593445                    reportDefault(parser, enc, s, next);
    34603446                *startPtr = next;
    3461                 return XML_ERROR_NONE;
     3447                return ERROR_EXPAT_NONE;
    34623448            case XML_TOK_DATA_NEWLINE:
    34633449                if (characterDataHandler)
     
    34973483            case XML_TOK_INVALID:
    34983484                *eventPP = next;
    3499                 return XML_ERROR_INVALID_TOKEN;
     3485                return ERROR_EXPAT_INVALID_TOKEN;
    35003486            case XML_TOK_PARTIAL_CHAR:
    35013487                if (nextPtr)
    35023488                {
    35033489                    *nextPtr = s;
    3504                     return XML_ERROR_NONE;
    3505                 }
    3506                 return XML_ERROR_PARTIAL_CHAR;
     3490                    return ERROR_EXPAT_NONE;
     3491                }
     3492                return ERROR_EXPAT_PARTIAL_CHAR;
    35073493            case XML_TOK_PARTIAL:
    35083494            case XML_TOK_NONE:
     
    35103496                {
    35113497                    *nextPtr = s;
    3512                     return XML_ERROR_NONE;
    3513                 }
    3514                 return XML_ERROR_UNCLOSED_CDATA_SECTION;
     3498                    return ERROR_EXPAT_NONE;
     3499                }
     3500                return ERROR_EXPAT_UNCLOSED_CDATA_SECTION;
    35153501            default:
    35163502                *eventPP = next;
    3517                 return XML_ERROR_UNEXPECTED_STATE;
     3503                return ERROR_EXPAT_UNEXPECTED_STATE;
    35183504        }
    35193505        *eventPP = s = next;
     
    35273513 * the whole file is parsed with one call. */
    35283514
    3529 static enum XML_Error ignoreSectionProcessor(XML_Parser parser,
     3515static XMLERROR ignoreSectionProcessor(XML_Parser parser,
    35303516                                      const char *start,
    35313517                                      const char *end,
    35323518                                      const char **endPtr)
    35333519{
    3534     enum XML_Error result = doIgnoreSection(parser, encoding, &start, end, endPtr);
     3520    XMLERROR result = doIgnoreSection(parser, encoding, &start, end, endPtr);
    35353521
    35363522    if (start)
     
    35453531 * the section is not yet closed. */
    35463532
    3547 static enum XML_Error doIgnoreSection(XML_Parser parser,
     3533static XMLERROR doIgnoreSection(XML_Parser parser,
    35483534                               const ENCODING * enc,
    35493535                               const char **startPtr,
     
    35783564                reportDefault(parser, enc, s, next);
    35793565            *startPtr = next;
    3580             return XML_ERROR_NONE;
     3566            return ERROR_EXPAT_NONE;
    35813567        case XML_TOK_INVALID:
    35823568            *eventPP = next;
    3583             return XML_ERROR_INVALID_TOKEN;
     3569            return ERROR_EXPAT_INVALID_TOKEN;
    35843570        case XML_TOK_PARTIAL_CHAR:
    35853571            if (nextPtr)
    35863572            {
    35873573                *nextPtr = s;
    3588                 return XML_ERROR_NONE;
     3574                return ERROR_EXPAT_NONE;
    35893575            }
    3590             return XML_ERROR_PARTIAL_CHAR;
     3576            return ERROR_EXPAT_PARTIAL_CHAR;
    35913577        case XML_TOK_PARTIAL:
    35923578        case XML_TOK_NONE:
     
    35943580            {
    35953581                *nextPtr = s;
    3596                 return XML_ERROR_NONE;
     3582                return ERROR_EXPAT_NONE;
    35973583            }
    3598             return XML_ERROR_SYNTAX;    /* XML_ERROR_UNCLOSED_IGNORE_SECTION */
     3584            return ERROR_EXPAT_SYNTAX;    /* ERROR_EXPAT_UNCLOSED_IGNORE_SECTION */
    35993585        default:
    36003586            *eventPP = next;
    3601             return XML_ERROR_UNEXPECTED_STATE;
     3587            return ERROR_EXPAT_UNEXPECTED_STATE;
    36023588    }
    36033589    /* not reached */
     
    36063592#endif /* XML_DTD */
    36073593
    3608 static enum XML_Error  initializeEncoding(XML_Parser parser)
     3594static XMLERROR  initializeEncoding(XML_Parser parser)
    36093595{
    36103596    const char *s;
     
    36363622#endif
    36373623    if ((ns ? XmlInitEncodingNS : XmlInitEncoding) (&initEncoding, &encoding, s))
    3638         return XML_ERROR_NONE;
     3624        return ERROR_EXPAT_NONE;
    36393625    return handleUnknownEncoding(parser, protocolEncodingName);
    36403626}
    36413627
    3642 static enum XML_Error  processXmlDecl(XML_Parser parser, int isGeneralTextEntity,
     3628static XMLERROR  processXmlDecl(XML_Parser parser, int isGeneralTextEntity,
    36433629                const char *s, const char *next)
    36443630{
     
    36633649                              &newEncoding,
    36643650                              &standalone))
    3665         return XML_ERROR_SYNTAX;
     3651        return ERROR_EXPAT_SYNTAX;
    36663652    if (!isGeneralTextEntity && standalone == 1)
    36673653    {
     
    36823668                                     + XmlNameLength(encoding, encodingName));
    36833669            if (!storedEncName)
    3684                 return XML_ERROR_NO_MEMORY;
     3670                return ERROR_EXPAT_NO_MEMORY;
    36853671            poolFinish(&temp2Pool);
    36863672        }
     
    36923678                                      versionend - encoding->minBytesPerChar);
    36933679            if (!storedversion)
    3694                 return XML_ERROR_NO_MEMORY;
     3680                return ERROR_EXPAT_NO_MEMORY;
    36953681        }
    36963682        xmlDeclHandler(handlerArg, storedversion, storedEncName, standalone);
     
    37053691            {
    37063692                eventPtr = encodingName;
    3707                 return XML_ERROR_INCORRECT_ENCODING;
     3693                return ERROR_EXPAT_INCORRECT_ENCODING;
    37083694            }
    37093695            encoding = newEncoding;
     
    37113697        else if (encodingName)
    37123698        {
    3713             enum XML_Error result;
     3699            XMLERROR result;
    37143700
    37153701            if (!storedEncName)
     
    37213707                                     + XmlNameLength(encoding, encodingName));
    37223708                if (!storedEncName)
    3723                     return XML_ERROR_NO_MEMORY;
     3709                    return ERROR_EXPAT_NO_MEMORY;
    37243710            }
    37253711            result = handleUnknownEncoding(parser, storedEncName);
    37263712            poolClear(&tempPool);
    3727             if (result == XML_ERROR_UNKNOWN_ENCODING)
     3713            if (result == ERROR_EXPAT_UNKNOWN_ENCODING)
    37283714                eventPtr = encodingName;
    37293715            return result;
     
    37343720        poolClear(&temp2Pool);
    37353721
    3736     return XML_ERROR_NONE;
    3737 }
    3738 
    3739 static enum XML_Error handleUnknownEncoding(XML_Parser parser,
     3722    return ERROR_EXPAT_NONE;
     3723}
     3724
     3725static XMLERROR handleUnknownEncoding(XML_Parser parser,
    37403726                                            const XML_Char* encodingName)
    37413727{
     
    37613747                if (info.release)
    37623748                    info.release(info.data);
    3763                 return XML_ERROR_NO_MEMORY;
     3749                return ERROR_EXPAT_NO_MEMORY;
    37643750            }
    37653751            enc = (ns
     
    37743760                unknownEncodingRelease = info.release;
    37753761                encoding = enc;
    3776                 return XML_ERROR_NONE;
     3762                return ERROR_EXPAT_NONE;
    37773763            }
    37783764        }
     
    37803766            info.release(info.data);
    37813767    }
    3782     return XML_ERROR_UNKNOWN_ENCODING;
    3783 }
    3784 
    3785 static enum XML_Error prologInitProcessor(XML_Parser parser,
     3768    return ERROR_EXPAT_UNKNOWN_ENCODING;
     3769}
     3770
     3771static XMLERROR prologInitProcessor(XML_Parser parser,
    37863772                     const char *s,
    37873773                     const char *end,
    37883774                     const char **nextPtr)
    37893775{
    3790     enum XML_Error result = initializeEncoding(parser);
    3791 
    3792     if (result != XML_ERROR_NONE)
     3776    XMLERROR result = initializeEncoding(parser);
     3777
     3778    if (result != ERROR_EXPAT_NONE)
    37933779        return result;
    37943780    processor = prologProcessor;
     
    37963782}
    37973783
    3798 static enum XML_Error prologProcessor(XML_Parser parser,
     3784static XMLERROR prologProcessor(XML_Parser parser,
    37993785                 const char *s,
    38003786                 const char *end,
     
    38073793}
    38083794
    3809 static enum XML_Error doProlog(XML_Parser parser,
     3795static XMLERROR doProlog(XML_Parser parser,
    38103796          const ENCODING * enc,
    38113797          const char *s,
     
    38463832            {
    38473833                *nextPtr = s;
    3848                 return XML_ERROR_NONE;
     3834                return ERROR_EXPAT_NONE;
    38493835            }
    38503836            switch (tok)
     
    38523838                case XML_TOK_INVALID:
    38533839                    *eventPP = next;
    3854                     return XML_ERROR_INVALID_TOKEN;
     3840                    return ERROR_EXPAT_INVALID_TOKEN;
    38553841                case XML_TOK_PARTIAL:
    3856                     return XML_ERROR_UNCLOSED_TOKEN;
     3842                    return ERROR_EXPAT_UNCLOSED_TOKEN;
    38573843                case XML_TOK_PARTIAL_CHAR:
    3858                     return XML_ERROR_PARTIAL_CHAR;
     3844                    return ERROR_EXPAT_PARTIAL_CHAR;
    38593845                case XML_TOK_NONE:
    38603846#ifdef XML_DTD
    38613847                    if (enc != encoding)
    3862                         return XML_ERROR_NONE;
     3848                        return ERROR_EXPAT_NONE;
    38633849                    if (parentParser)
    38643850                    {
    38653851                        if (XmlTokenRole(&prologState, XML_TOK_NONE, end, end, enc)
    38663852                            == XML_ROLE_ERROR)
    3867                             return XML_ERROR_SYNTAX;
     3853                            return ERROR_EXPAT_SYNTAX;
    38683854                        hadExternalDoctype = 0;
    3869                         return XML_ERROR_NONE;
     3855                        return ERROR_EXPAT_NONE;
    38703856                    }
    38713857#endif /* XML_DTD */
    3872                     return XML_ERROR_NO_ELEMENTS;
     3858                    return ERROR_EXPAT_NO_ELEMENTS;
    38733859                default:
    38743860                    tok = -tok;
     
    38823868            case XML_ROLE_XML_DECL:
    38833869                {
    3884                     enum XML_Error result = processXmlDecl(parser, 0, s, next);
    3885 
    3886                     if (result != XML_ERROR_NONE)
     3870                    XMLERROR result = processXmlDecl(parser, 0, s, next);
     3871
     3872                    if (result != ERROR_EXPAT_NONE)
    38873873                        return result;
    38883874                    enc = encoding;
     
    38943880                    doctypeName = poolStoreString(&tempPool, enc, s, next);
    38953881                    if (!doctypeName)
    3896                         return XML_ERROR_NO_MEMORY;
     3882                        return ERROR_EXPAT_NO_MEMORY;
    38973883                    poolFinish(&tempPool);
    38983884                    doctypeSysid = 0;
     
    39123898            case XML_ROLE_TEXT_DECL:
    39133899                {
    3914                     enum XML_Error result = processXmlDecl(parser, 1, s, next);
    3915 
    3916                     if (result != XML_ERROR_NONE)
     3900                    XMLERROR result = processXmlDecl(parser, 1, s, next);
     3901
     3902                    if (result != ERROR_EXPAT_NONE)
    39173903                        return result;
    39183904                    enc = encoding;
     
    39253911                    doctypePubid = poolStoreString(&tempPool, enc, s + 1, next - 1);
    39263912                    if (!doctypePubid)
    3927                         return XML_ERROR_NO_MEMORY;
     3913                        return ERROR_EXPAT_NO_MEMORY;
    39283914                    poolFinish(&tempPool);
    39293915                }
     
    39333919                                               sizeof(ENTITY));
    39343920                if (!declEntity)
    3935                     return XML_ERROR_NO_MEMORY;
     3921                    return ERROR_EXPAT_NO_MEMORY;
    39363922#endif /* XML_DTD */
    39373923                /* fall through */
    39383924            case XML_ROLE_ENTITY_PUBLIC_ID:
    39393925                if (!XmlIsPublicId(enc, s, next, eventPP))
    3940                     return XML_ERROR_SYNTAX;
     3926                    return ERROR_EXPAT_SYNTAX;
    39413927                if (declEntity)
    39423928                {
     
    39473933
    39483934                    if (!tem)
    3949                         return XML_ERROR_NO_MEMORY;
     3935                        return ERROR_EXPAT_NO_MEMORY;
    39503936                    normalizePublicId(tem);
    39513937                    declEntity->publicId = tem;
     
    39753961                                                      entity->systemId,
    39763962                                                      entity->publicId))
    3977                             return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
     3963                            return ERROR_EXPAT_EXTERNAL_ENTITY_HANDLING;
    39783964                    }
    39793965#endif /* XML_DTD */
     
    39823968                        && notStandaloneHandler
    39833969                        && !notStandaloneHandler(handlerArg))
    3984                         return XML_ERROR_NOT_STANDALONE;
     3970                        return ERROR_EXPAT_NOT_STANDALONE;
    39853971                }
    39863972                if (endDoctypeDeclHandler)
     
    39933979                declElementType = getElementType(parser, enc, s, next);
    39943980                if (!declElementType)
    3995                     return XML_ERROR_NO_MEMORY;
     3981                    return ERROR_EXPAT_NO_MEMORY;
    39963982                break;
    39973983            case XML_ROLE_ATTRIBUTE_NAME:
    39983984                declAttributeId = getAttributeId(parser, enc, s, next);
    39993985                if (!declAttributeId)
    4000                     return XML_ERROR_NO_MEMORY;
     3986                    return ERROR_EXPAT_NO_MEMORY;
    40013987                declAttributeIsCdata = 0;
    40023988                declAttributeType = 0;
     
    40474033                    }
    40484034                    if (!poolAppendString(&tempPool, prefix))
    4049                         return XML_ERROR_NO_MEMORY;
     4035                        return ERROR_EXPAT_NO_MEMORY;
    40504036                    if (!poolAppend(&tempPool, enc, s, next))
    4051                         return XML_ERROR_NO_MEMORY;
     4037                        return ERROR_EXPAT_NO_MEMORY;
    40524038                    declAttributeType = tempPool.start;
    40534039                }
     
    40594045                                   declAttributeIsCdata, declAttributeIsId, 0,
    40604046                                        parser))
    4061                     return XML_ERROR_NO_MEMORY;
     4047                    return ERROR_EXPAT_NO_MEMORY;
    40624048                if (attlistDeclHandler && declAttributeType)
    40634049                {
     
    40684054                        if (!poolAppendChar(&tempPool, ')')
    40694055                            || !poolAppendChar(&tempPool, '\0'))
    4070                             return XML_ERROR_NO_MEMORY;
     4056                            return ERROR_EXPAT_NO_MEMORY;
    40714057                        declAttributeType = tempPool.start;
    40724058                        poolFinish(&tempPool);
     
    40834069                {
    40844070                    const XML_Char *attVal;
    4085                     enum XML_Error result
     4071                    XMLERROR result
    40864072                    = storeAttributeValue(parser, enc, declAttributeIsCdata,
    40874073                                          s + enc->minBytesPerChar,
     
    40964082                    /* ID attributes aren't allowed to have a default */
    40974083                        && !defineAttribute(declElementType, declAttributeId, declAttributeIsCdata, 0, attVal, parser))
    4098                         return XML_ERROR_NO_MEMORY;
     4084                        return ERROR_EXPAT_NO_MEMORY;
    40994085                    if (attlistDeclHandler && declAttributeType)
    41004086                    {
     
    41054091                            if (!poolAppendChar(&tempPool, ')')
    41064092                                || !poolAppendChar(&tempPool, '\0'))
    4107                                 return XML_ERROR_NO_MEMORY;
     4093                                return ERROR_EXPAT_NO_MEMORY;
    41084094                            declAttributeType = tempPool.start;
    41094095                            poolFinish(&tempPool);
     
    41204106            case XML_ROLE_ENTITY_VALUE:
    41214107                {
    4122                     enum XML_Error result = storeEntityValue(parser, enc,
     4108                    XMLERROR result = storeEntityValue(parser, enc,
    41234109                                                     s + enc->minBytesPerChar,
    41244110                                                 next - enc->minBytesPerChar);
     
    41424128                    else
    41434129                        poolDiscard(&dtd.pool);
    4144                     if (result != XML_ERROR_NONE)
     4130                    if (result != ERROR_EXPAT_NONE)
    41454131                        return result;
    41464132                }
     
    41514137                    doctypeSysid = poolStoreString(&tempPool, enc, s + 1, next - 1);
    41524138                    if (!doctypeSysid)
    4153                         return XML_ERROR_NO_MEMORY;
     4139                        return ERROR_EXPAT_NO_MEMORY;
    41544140                    poolFinish(&tempPool);
    41554141                }
     
    41604146                    && notStandaloneHandler
    41614147                    && !notStandaloneHandler(handlerArg))
    4162                     return XML_ERROR_NOT_STANDALONE;
     4148                    return ERROR_EXPAT_NOT_STANDALONE;
    41634149                hadExternalDoctype = 1;
    41644150#ifndef XML_DTD
     
    41724158                    declEntity->publicId = 0;
    41734159                    if (!declEntity)
    4174                         return XML_ERROR_NO_MEMORY;
     4160                        return ERROR_EXPAT_NO_MEMORY;
    41754161                }
    41764162                /* fall through */
     
    41834169                                                 next - enc->minBytesPerChar);
    41844170                    if (!declEntity->systemId)
    4185                         return XML_ERROR_NO_MEMORY;
     4171                        return ERROR_EXPAT_NO_MEMORY;
    41864172                    declEntity->base = curBase;
    41874173                    poolFinish(&dtd.pool);
     
    42064192                    declEntity->notation = poolStoreString(&dtd.pool, enc, s, next);
    42074193                    if (!declEntity->notation)
    4208                         return XML_ERROR_NO_MEMORY;
     4194                        return ERROR_EXPAT_NO_MEMORY;
    42094195                    poolFinish(&dtd.pool);
    42104196                    if (unparsedEntityDeclHandler)
     
    42424228                    name = poolStoreString(&dtd.pool, enc, s, next);
    42434229                    if (!name)
    4244                         return XML_ERROR_NO_MEMORY;
     4230                        return ERROR_EXPAT_NO_MEMORY;
    42454231                    if (dtd.complete)
    42464232                    {
    42474233                        declEntity = (ENTITY*)lookup(&dtd.generalEntities, name, sizeof(ENTITY));
    42484234                        if (!declEntity)
    4249                             return XML_ERROR_NO_MEMORY;
     4235                            return ERROR_EXPAT_NO_MEMORY;
    42504236                        if (declEntity->name != name)
    42514237                        {
     
    42744260
    42754261                    if (!name)
    4276                         return XML_ERROR_NO_MEMORY;
     4262                        return ERROR_EXPAT_NO_MEMORY;
    42774263                    declEntity = (ENTITY*)lookup(&dtd.paramEntities,
    42784264                                                   name, sizeof(ENTITY));
    42794265                    if (!declEntity)
    4280                         return XML_ERROR_NO_MEMORY;
     4266                        return ERROR_EXPAT_NO_MEMORY;
    42814267                    if (declEntity->name != name)
    42824268                    {
     
    43024288                    declNotationName = poolStoreString(&tempPool, enc, s, next);
    43034289                    if (!declNotationName)
    4304                         return XML_ERROR_NO_MEMORY;
     4290                        return ERROR_EXPAT_NO_MEMORY;
    43054291                    poolFinish(&tempPool);
    43064292                }
     
    43084294            case XML_ROLE_NOTATION_PUBLIC_ID:
    43094295                if (!XmlIsPublicId(enc, s, next, eventPP))
    4310                     return XML_ERROR_SYNTAX;
     4296                    return ERROR_EXPAT_SYNTAX;
    43114297                if (declNotationName)
    43124298                {
     
    43174303
    43184304                    if (!tem)
    4319                         return XML_ERROR_NO_MEMORY;
     4305                        return ERROR_EXPAT_NO_MEMORY;
    43204306                    normalizePublicId(tem);
    43214307                    declNotationPublicId = tem;
     
    43324318
    43334319                    if (!systemId)
    4334                         return XML_ERROR_NO_MEMORY;
     4320                        return ERROR_EXPAT_NO_MEMORY;
    43354321                    *eventEndPP = s;
    43364322                    notationDeclHandler(handlerArg,
     
    43584344                {
    43594345                    case XML_TOK_PARAM_ENTITY_REF:
    4360                         return XML_ERROR_PARAM_ENTITY_REF;
     4346                        return ERROR_EXPAT_PARAM_ENTITY_REF;
    43614347                    case XML_TOK_XML_DECL:
    4362                         return XML_ERROR_MISPLACED_XML_PI;
     4348                        return ERROR_EXPAT_MISPLACED_XML_PI;
    43634349                    default:
    4364                         return XML_ERROR_SYNTAX;
     4350                        return ERROR_EXPAT_SYNTAX;
    43654351                }
    43664352#ifdef XML_DTD
    43674353            case XML_ROLE_IGNORE_SECT:
    43684354                {
    4369                     enum XML_Error result;
     4355                    XMLERROR result;
    43704356
    43714357                    if (defaultHandler)
     
    43924378                        groupConnector = (char*)MALLOC(groupSize = 32);
    43934379                    if (!groupConnector)
    4394                         return XML_ERROR_NO_MEMORY;
     4380                        return ERROR_EXPAT_NO_MEMORY;
    43954381                }
    43964382                groupConnector[prologState.level] = 0;
     
    44004386
    44014387                    if (myindex < 0)
    4402                         return XML_ERROR_NO_MEMORY;
     4388                        return ERROR_EXPAT_NO_MEMORY;
    44034389                    dtd.scaffIndex[dtd.scaffLevel] = myindex;
    44044390                    dtd.scaffLevel++;
     
    44084394            case XML_ROLE_GROUP_SEQUENCE:
    44094395                if (groupConnector[prologState.level] == '|')
    4410                     return XML_ERROR_SYNTAX;
     4396                    return ERROR_EXPAT_SYNTAX;
    44114397                groupConnector[prologState.level] = ',';
    44124398                break;
    44134399            case XML_ROLE_GROUP_CHOICE:
    44144400                if (groupConnector[prologState.level] == ',')
    4415                     return XML_ERROR_SYNTAX;
     4401                    return ERROR_EXPAT_SYNTAX;
    44164402                if (dtd.in_eldecl
    44174403                    && !groupConnector[prologState.level]
     
    44364422                                           next - enc->minBytesPerChar);
    44374423                    if (!name)
    4438                         return XML_ERROR_NO_MEMORY;
     4424                        return ERROR_EXPAT_NO_MEMORY;
    44394425                    entity = (ENTITY*)lookup(&dtd.paramEntities, name, 0);
    44404426                    poolDiscard(&dtd.pool);
     
    44424428                    {
    44434429                        /* FIXME what to do if !dtd.complete? */
    4444                         return XML_ERROR_UNDEFINED_ENTITY;
     4430                        return ERROR_EXPAT_UNDEFINED_ENTITY;
    44454431                    }
    44464432                    if (entity->open)
    4447                         return XML_ERROR_RECURSIVE_ENTITY_REF;
     4433                        return ERROR_EXPAT_RECURSIVE_ENTITY_REF;
    44484434                    if (entity->textPtr)
    44494435                    {
    4450                         enum XML_Error result;
     4436                        XMLERROR result;
    44514437
    44524438                        result = processInternalParamEntity(parser, entity);
    4453                         if (result != XML_ERROR_NONE)
     4439                        if (result != ERROR_EXPAT_NONE)
    44544440                            return result;
    44554441                        break;
    44564442                    }
    44574443                    if (role == XML_ROLE_INNER_PARAM_ENTITY_REF)
    4458                         return XML_ERROR_PARAM_ENTITY_REF;
     4444                        return ERROR_EXPAT_PARAM_ENTITY_REF;
    44594445                    if (externalEntityRefHandler)
    44604446                    {
     
    44684454                        {
    44694455                            entity->open = 0;
    4470                             return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
     4456                            return ERROR_EXPAT_EXTERNAL_ENTITY_HANDLING;
    44714457                        }
    44724458                        entity->open = 0;
     
    44794465                    && notStandaloneHandler
    44804466                    && !notStandaloneHandler(handlerArg))
    4481                     return XML_ERROR_NOT_STANDALONE;
     4467                    return ERROR_EXPAT_NOT_STANDALONE;
    44824468                dtd.complete = 0;
    44834469                if (defaultHandler)
     
    44924478                    declElementType = getElementType(parser, enc, s, next);
    44934479                    if (!declElementType)
    4494                         return XML_ERROR_NO_MEMORY;
     4480                        return ERROR_EXPAT_NO_MEMORY;
    44954481                    dtd.scaffLevel = 0;
    44964482                    dtd.scaffCount = 0;
     
    45054491                    if (elementDeclHandler)
    45064492                    {
    4507                         XML_Content *content = (XML_Content*)MALLOC(sizeof(XML_Content));
     4493                        XMLCONTENT *content = (XMLCONTENT*)MALLOC(sizeof(XMLCONTENT));
    45084494
    45094495                        if (!content)
    4510                             return XML_ERROR_NO_MEMORY;
     4496                            return ERROR_EXPAT_NO_MEMORY;
    45114497                        content->quant = XML_CQUANT_NONE;
    45124498                        content->name = 0;
     
    45494535
    45504536                    if (myindex < 0)
    4551                         return XML_ERROR_NO_MEMORY;
     4537                        return ERROR_EXPAT_NO_MEMORY;
    45524538                    dtd.scaffold[myindex].type = XML_CTYPE_NAME;
    45534539                    dtd.scaffold[myindex].quant = quant;
    45544540                    el = getElementType(parser, enc, s, nxt);
    45554541                    if (!el)
    4556                         return XML_ERROR_NO_MEMORY;
     4542                        return ERROR_EXPAT_NO_MEMORY;
    45574543                    dtd.scaffold[myindex].name = el->name;
    45584544                    dtd.contentStringLen += nxt - s + 1;
     
    45804566                        if (elementDeclHandler)
    45814567                        {
    4582                             XML_Content *model = build_model(parser);
     4568                            XMLCONTENT *model = build_model(parser);
    45834569
    45844570                            if (!model)
    4585                                 return XML_ERROR_NO_MEMORY;
     4571                                return ERROR_EXPAT_NO_MEMORY;
    45864572                            *eventEndPP = s;
    45874573                            elementDeclHandler(handlerArg, declElementType->name, model);
     
    45994585                    case XML_TOK_PI:
    46004586                        if (!reportProcessingInstruction(parser, enc, s, next))
    4601                             return XML_ERROR_NO_MEMORY;
     4587                            return ERROR_EXPAT_NO_MEMORY;
    46024588                        break;
    46034589                    case XML_TOK_COMMENT:
    46044590                        if (!reportComment(parser, enc, s, next))
    4605                             return XML_ERROR_NO_MEMORY;
     4591                            return ERROR_EXPAT_NO_MEMORY;
    46064592                        break;
    46074593                }
     
    46344620}
    46354621
    4636 static enum XML_Error epilogProcessor(XML_Parser parser,
     4622static XMLERROR epilogProcessor(XML_Parser parser,
    46374623                               const char *s,
    46384624                               const char *end,
     
    46594645                if (nextPtr)
    46604646                    *nextPtr = end;
    4661                 return XML_ERROR_NONE;
     4647                return ERROR_EXPAT_NONE;
    46624648            case XML_TOK_PROLOG_S:
    46634649                if (defaultHandler)
     
    46664652            case XML_TOK_PI:
    46674653                if (!reportProcessingInstruction(parser, encoding, s, next))
    4668                     return XML_ERROR_NO_MEMORY;
     4654                    return ERROR_EXPAT_NO_MEMORY;
    46694655                break;
    46704656            case XML_TOK_COMMENT:
    46714657                if (!reportComment(parser, encoding, s, next))
    4672                     return XML_ERROR_NO_MEMORY;
     4658                    return ERROR_EXPAT_NO_MEMORY;
    46734659                break;
    46744660            case XML_TOK_INVALID:
    46754661                eventPtr = next;
    4676                 return XML_ERROR_INVALID_TOKEN;
     4662                return ERROR_EXPAT_INVALID_TOKEN;
    46774663            case XML_TOK_PARTIAL:
    46784664                if (nextPtr)
    46794665                {
    46804666                    *nextPtr = s;
    4681                     return XML_ERROR_NONE;
    4682                 }
    4683                 return XML_ERROR_UNCLOSED_TOKEN;
     4667                    return ERROR_EXPAT_NONE;
     4668                }
     4669                return ERROR_EXPAT_UNCLOSED_TOKEN;
    46844670            case XML_TOK_PARTIAL_CHAR:
    46854671                if (nextPtr)
    46864672                {
    46874673                    *nextPtr = s;
    4688                     return XML_ERROR_NONE;
    4689                 }
    4690                 return XML_ERROR_PARTIAL_CHAR;
     4674                    return ERROR_EXPAT_NONE;
     4675                }
     4676                return ERROR_EXPAT_PARTIAL_CHAR;
    46914677            default:
    4692                 return XML_ERROR_JUNK_AFTER_DOC_ELEMENT;
     4678                return ERROR_EXPAT_JUNK_AFTER_DOC_ELEMENT;
    46934679        }
    46944680        eventPtr = s = next;
     
    46984684#ifdef XML_DTD
    46994685
    4700 static enum XML_Error processInternalParamEntity(XML_Parser parser, ENTITY * entity)
     4686static XMLERROR processInternalParamEntity(XML_Parser parser, ENTITY * entity)
    47014687{
    47024688    const char *s, *end, *next;
    47034689    int tok;
    4704     enum XML_Error result;
     4690    XMLERROR result;
    47054691    OPEN_INTERNAL_ENTITY openEntity;
    47064692
     
    47224708#endif /* XML_DTD */
    47234709
    4724 static enum XML_Error errorProcessor(XML_Parser parser,
     4710static XMLERROR errorProcessor(XML_Parser parser,
    47254711                              const char *s,
    47264712                              const char *end,
     
    47304716}
    47314717
    4732 static enum XML_Error storeAttributeValue(XML_Parser parser,
     4718static XMLERROR storeAttributeValue(XML_Parser parser,
    47334719                                          const ENCODING * enc,
    47344720                                          int isCdata,
     
    47374723                                          STRING_POOL * pool)
    47384724{
    4739     enum XML_Error result = appendAttributeValue(parser, enc, isCdata, ptr, end, pool);
     4725    XMLERROR result = appendAttributeValue(parser, enc, isCdata, ptr, end, pool);
    47404726
    47414727    if (result)
     
    47444730        poolChop(pool);
    47454731    if (!poolAppendChar(pool, XML_T('\0')))
    4746         return XML_ERROR_NO_MEMORY;
    4747     return XML_ERROR_NONE;
    4748 }
    4749 
    4750 static enum XML_Error appendAttributeValue(XML_Parser parser, const ENCODING * enc, int isCdata,
     4732        return ERROR_EXPAT_NO_MEMORY;
     4733    return ERROR_EXPAT_NONE;
     4734}
     4735
     4736static XMLERROR appendAttributeValue(XML_Parser parser, const ENCODING * enc, int isCdata,
    47514737                      const char *ptr, const char *end,
    47524738                      STRING_POOL * pool)
     
    47604746        {
    47614747            case XML_TOK_NONE:
    4762                 return XML_ERROR_NONE;
     4748                return ERROR_EXPAT_NONE;
    47634749            case XML_TOK_INVALID:
    47644750                if (enc == encoding)
    47654751                    eventPtr = next;
    4766                 return XML_ERROR_INVALID_TOKEN;
     4752                return ERROR_EXPAT_INVALID_TOKEN;
    47674753            case XML_TOK_PARTIAL:
    47684754                if (enc == encoding)
    47694755                    eventPtr = ptr;
    4770                 return XML_ERROR_INVALID_TOKEN;
     4756                return ERROR_EXPAT_INVALID_TOKEN;
    47714757            case XML_TOK_CHAR_REF:
    47724758                {
     
    47794765                        if (enc == encoding)
    47804766                            eventPtr = ptr;
    4781                         return XML_ERROR_BAD_CHAR_REF;
     4767                        return ERROR_EXPAT_BAD_CHAR_REF;
    47824768                    }
    47834769                    if (!isCdata
     
    47904776                        if (enc == encoding)
    47914777                            eventPtr = ptr;
    4792                         return XML_ERROR_BAD_CHAR_REF;
     4778                        return ERROR_EXPAT_BAD_CHAR_REF;
    47934779                    }
    47944780                    for (i = 0; i < n; i++)
    47954781                    {
    47964782                        if (!poolAppendChar(pool, buf[i]))
    4797                             return XML_ERROR_NO_MEMORY;
     4783                            return ERROR_EXPAT_NO_MEMORY;
    47984784                    }
    47994785                }
     
    48014787            case XML_TOK_DATA_CHARS:
    48024788                if (!poolAppend(pool, enc, ptr, next))
    4803                     return XML_ERROR_NO_MEMORY;
     4789                    return ERROR_EXPAT_NO_MEMORY;
    48044790                break;
    48054791            case XML_TOK_TRAILING_CR:
     
    48114797                    break;
    48124798                if (!poolAppendChar(pool, 0x20))
    4813                     return XML_ERROR_NO_MEMORY;
     4799                    return ERROR_EXPAT_NO_MEMORY;
    48144800                break;
    48154801            case XML_TOK_ENTITY_REF:
     
    48244810                    {
    48254811                        if (!poolAppendChar(pool, ch))
    4826                             return XML_ERROR_NO_MEMORY;
     4812                            return ERROR_EXPAT_NO_MEMORY;
    48274813                        break;
    48284814                    }
     
    48314817                                           next - enc->minBytesPerChar);
    48324818                    if (!name)
    4833                         return XML_ERROR_NO_MEMORY;
     4819                        return ERROR_EXPAT_NO_MEMORY;
    48344820                    entity = (ENTITY*)lookup(&dtd.generalEntities, name, 0);
    48354821                    poolDiscard(&temp2Pool);
     
    48404826                            if (enc == encoding)
    48414827                                eventPtr = ptr;
    4842                             return XML_ERROR_UNDEFINED_ENTITY;
     4828                            return ERROR_EXPAT_UNDEFINED_ENTITY;
    48434829                        }
    48444830                    }
     
    48474833                        if (enc == encoding)
    48484834                            eventPtr = ptr;
    4849                         return XML_ERROR_RECURSIVE_ENTITY_REF;
     4835                        return ERROR_EXPAT_RECURSIVE_ENTITY_REF;
    48504836                    }
    48514837                    else if (entity->notation)
     
    48534839                        if (enc == encoding)
    48544840                            eventPtr = ptr;
    4855                         return XML_ERROR_BINARY_ENTITY_REF;
     4841                        return ERROR_EXPAT_BINARY_ENTITY_REF;
    48564842                    }
    48574843                    else if (!entity->textPtr)
     
    48594845                        if (enc == encoding)
    48604846                            eventPtr = ptr;
    4861                         return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF;
     4847                        return ERROR_EXPAT_ATTRIBUTE_EXTERNAL_ENTITY_REF;
    48624848                    }
    48634849                    else
    48644850                    {
    4865                         enum XML_Error result;
     4851                        XMLERROR result;
    48664852                        const XML_Char *textEnd = entity->textPtr + entity->textLen;
    48674853
     
    48774863                if (enc == encoding)
    48784864                    eventPtr = ptr;
    4879                 return XML_ERROR_UNEXPECTED_STATE;
     4865                return ERROR_EXPAT_UNEXPECTED_STATE;
    48804866        }
    48814867        ptr = next;
     
    48844870}
    48854871
    4886 static enum XML_Error storeEntityValue(XML_Parser parser,
     4872static XMLERROR storeEntityValue(XML_Parser parser,
    48874873                                const ENCODING * enc,
    48884874                                const char *entityTextPtr,
     
    49024888                if (parentParser || enc != encoding)
    49034889                {
    4904                     enum XML_Error result;
     4890                    XMLERROR result;
    49054891                    const XML_Char *name;
    49064892                    ENTITY *entity;
     
    49104896                                           next - enc->minBytesPerChar);
    49114897                    if (!name)
    4912                         return XML_ERROR_NO_MEMORY;
     4898                        return ERROR_EXPAT_NO_MEMORY;
    49134899                    entity = (ENTITY*)lookup(&dtd.paramEntities, name, 0);
    49144900                    poolDiscard(&tempPool);
     
    49174903                        if (enc == encoding)
    49184904                            eventPtr = entityTextPtr;
    4919                         return XML_ERROR_UNDEFINED_ENTITY;
     4905                        return ERROR_EXPAT_UNDEFINED_ENTITY;
    49204906                    }
    49214907                    if (entity->open)
     
    49234909                        if (enc == encoding)
    49244910                            eventPtr = entityTextPtr;
    4925                         return XML_ERROR_RECURSIVE_ENTITY_REF;
     4911                        return ERROR_EXPAT_RECURSIVE_ENTITY_REF;
    49264912                    }
    49274913                    if (entity->systemId)
     
    49294915                        if (enc == encoding)
    49304916                            eventPtr = entityTextPtr;
    4931                         return XML_ERROR_PARAM_ENTITY_REF;
     4917                        return ERROR_EXPAT_PARAM_ENTITY_REF;
    49324918                    }
    49334919                    entity->open = 1;
     
    49434929#endif /* XML_DTD */
    49444930                eventPtr = entityTextPtr;
    4945                 return XML_ERROR_SYNTAX;
     4931                return ERROR_EXPAT_SYNTAX;
    49464932            case XML_TOK_NONE:
    4947                 return XML_ERROR_NONE;
     4933                return ERROR_EXPAT_NONE;
    49484934            case XML_TOK_ENTITY_REF:
    49494935            case XML_TOK_DATA_CHARS:
    49504936                if (!poolAppend(pool, enc, entityTextPtr, next))
    4951                     return XML_ERROR_NO_MEMORY;
     4937                    return ERROR_EXPAT_NO_MEMORY;
    49524938                break;
    49534939            case XML_TOK_TRAILING_CR:
     
    49564942            case XML_TOK_DATA_NEWLINE:
    49574943                if (pool->end == pool->ptr && !poolGrow(pool))
    4958                     return XML_ERROR_NO_MEMORY;
     4944                    return ERROR_EXPAT_NO_MEMORY;
    49594945                *(pool->ptr)++ = 0xA;
    49604946                break;
     
    49694955                        if (enc == encoding)
    49704956                            eventPtr = entityTextPtr;
    4971                         return XML_ERROR_BAD_CHAR_REF;
     4957                        return ERROR_EXPAT_BAD_CHAR_REF;
    49724958                    }
    49734959                    n = XmlEncode(n, (ICHAR*)buf);
     
    49764962                        if (enc == encoding)
    49774963                            eventPtr = entityTextPtr;
    4978                         return XML_ERROR_BAD_CHAR_REF;
     4964                        return ERROR_EXPAT_BAD_CHAR_REF;
    49794965                    }
    49804966                    for (i = 0; i < n; i++)
    49814967                    {
    49824968                        if (pool->end == pool->ptr && !poolGrow(pool))
    4983                             return XML_ERROR_NO_MEMORY;
     4969                            return ERROR_EXPAT_NO_MEMORY;
    49844970                        *(pool->ptr)++ = buf[i];
    49854971                    }
     
    49894975                if (enc == encoding)
    49904976                    eventPtr = entityTextPtr;
    4991                 return XML_ERROR_INVALID_TOKEN;
     4977                return ERROR_EXPAT_INVALID_TOKEN;
    49924978            case XML_TOK_INVALID:
    49934979                if (enc == encoding)
    49944980                    eventPtr = next;
    4995                 return XML_ERROR_INVALID_TOKEN;
     4981                return ERROR_EXPAT_INVALID_TOKEN;
    49964982            default:
    49974983                if (enc == encoding)
    49984984                    eventPtr = entityTextPtr;
    4999                 return XML_ERROR_UNEXPECTED_STATE;
     4985                return ERROR_EXPAT_UNEXPECTED_STATE;
    50004986        }
    50014987        entityTextPtr = next;
     
    54865472}
    54875473
    5488 /* Do a deep copy of the DTD.  Return 0 for out of memory; non-zero otherwise.
    5489  * The new DTD has already been initialized. */
     5474/*
     5475 * Do a deep copy of the DTD.  Return 0 for out of memory; non-zero otherwise.
     5476 * The new DTD has already been initialized.
     5477 *
     5478 */
    54905479
    54915480static int dtdCopy(DTD * newDtd, const DTD * oldDtd, XML_Parser parser)
     
    60586047static void build_node(XML_Parser parser,
    60596048            int src_node,
    6060             XML_Content * dest,
    6061             XML_Content ** contpos,
     6049            XMLCONTENT * dest,
     6050            XMLCONTENT ** contpos,
    60626051            char **strpos)
    60636052{
     
    60986087}                               /* End build_node */
    60996088
    6100 static XML_Content * build_model(XML_Parser parser)
    6101 {
    6102     XML_Content *ret;
    6103     XML_Content *cpos;
     6089static XMLCONTENT * build_model(XML_Parser parser)
     6090{
     6091    XMLCONTENT *ret;
     6092    XMLCONTENT *cpos;
    61046093    char *str;
    6105     int allocsize = dtd.scaffCount * sizeof(XML_Content) + dtd.contentStringLen;
    6106 
    6107     ret = (XML_Content*)MALLOC(allocsize);
     6094    int allocsize = dtd.scaffCount * sizeof(XMLCONTENT) + dtd.contentStringLen;
     6095
     6096    ret = (XMLCONTENT*)MALLOC(allocsize);
    61086097    if (!ret)
    61096098        return 0;
Note: See TracChangeset for help on using the changeset viewer.