Home | History | Annotate | Line # | Download | only in lib
      1 /*
      2                             __  __            _
      3                          ___\ \/ /_ __   __ _| |_
      4                         / _ \\  /| '_ \ / _` | __|
      5                        |  __//  \| |_) | (_| | |_
      6                         \___/_/\_\ .__/ \__,_|\__|
      7                                  |_| XML parser
      8 
      9    Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
     10    Copyright (c) 2000      Clark Cooper <coopercc (at) users.sourceforge.net>
     11    Copyright (c) 2000-2005 Fred L. Drake, Jr. <fdrake (at) users.sourceforge.net>
     12    Copyright (c) 2001-2002 Greg Stein <gstein (at) users.sourceforge.net>
     13    Copyright (c) 2002-2016 Karl Waclawek <karl (at) waclawek.net>
     14    Copyright (c) 2016-2025 Sebastian Pipping <sebastian (at) pipping.org>
     15    Copyright (c) 2016      Cristian Rodrguez <crrodriguez (at) opensuse.org>
     16    Copyright (c) 2016      Thomas Beutlich <tc (at) tbeu.de>
     17    Copyright (c) 2017      Rhodri James <rhodri (at) wildebeest.org.uk>
     18    Copyright (c) 2022      Thijs Schreijer <thijs (at) thijsschreijer.nl>
     19    Copyright (c) 2023      Hanno Bck <hanno (at) gentoo.org>
     20    Copyright (c) 2023      Sony Corporation / Snild Dolkow <snild (at) sony.com>
     21    Copyright (c) 2024      Taichi Haradaguchi <20001722 (at) ymail.ne.jp>
     22    Licensed under the MIT license:
     23 
     24    Permission is  hereby granted,  free of charge,  to any  person obtaining
     25    a  copy  of  this  software   and  associated  documentation  files  (the
     26    "Software"),  to  deal in  the  Software  without restriction,  including
     27    without  limitation the  rights  to use,  copy,  modify, merge,  publish,
     28    distribute, sublicense, and/or sell copies of the Software, and to permit
     29    persons  to whom  the Software  is  furnished to  do so,  subject to  the
     30    following conditions:
     31 
     32    The above copyright  notice and this permission notice  shall be included
     33    in all copies or substantial portions of the Software.
     34 
     35    THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
     36    EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
     37    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
     38    NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
     39    DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
     40    OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
     41    USE OR OTHER DEALINGS IN THE SOFTWARE.
     42 */
     43 
     44 #ifndef Expat_INCLUDED
     45 #define Expat_INCLUDED 1
     46 
     47 #include <stdlib.h>
     48 #include "expat_external.h"
     49 
     50 #ifdef __cplusplus
     51 extern "C" {
     52 #endif
     53 
     54 struct XML_ParserStruct;
     55 typedef struct XML_ParserStruct *XML_Parser;
     56 
     57 typedef unsigned char XML_Bool;
     58 #define XML_TRUE ((XML_Bool)1)
     59 #define XML_FALSE ((XML_Bool)0)
     60 
     61 /* The XML_Status enum gives the possible return values for several
     62    API functions.  The preprocessor #defines are included so this
     63    stanza can be added to code that still needs to support older
     64    versions of Expat 1.95.x:
     65 
     66    #ifndef XML_STATUS_OK
     67    #define XML_STATUS_OK    1
     68    #define XML_STATUS_ERROR 0
     69    #endif
     70 
     71    Otherwise, the #define hackery is quite ugly and would have been
     72    dropped.
     73 */
     74 enum XML_Status {
     75   XML_STATUS_ERROR = 0,
     76 #define XML_STATUS_ERROR XML_STATUS_ERROR
     77   XML_STATUS_OK = 1,
     78 #define XML_STATUS_OK XML_STATUS_OK
     79   XML_STATUS_SUSPENDED = 2
     80 #define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED
     81 };
     82 
     83 enum XML_Error {
     84   XML_ERROR_NONE,
     85   XML_ERROR_NO_MEMORY,
     86   XML_ERROR_SYNTAX,
     87   XML_ERROR_NO_ELEMENTS,
     88   XML_ERROR_INVALID_TOKEN,
     89   XML_ERROR_UNCLOSED_TOKEN,
     90   XML_ERROR_PARTIAL_CHAR,
     91   XML_ERROR_TAG_MISMATCH,
     92   XML_ERROR_DUPLICATE_ATTRIBUTE,
     93   XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
     94   XML_ERROR_PARAM_ENTITY_REF,
     95   XML_ERROR_UNDEFINED_ENTITY,
     96   XML_ERROR_RECURSIVE_ENTITY_REF,
     97   XML_ERROR_ASYNC_ENTITY,
     98   XML_ERROR_BAD_CHAR_REF,
     99   XML_ERROR_BINARY_ENTITY_REF,
    100   XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
    101   XML_ERROR_MISPLACED_XML_PI,
    102   XML_ERROR_UNKNOWN_ENCODING,
    103   XML_ERROR_INCORRECT_ENCODING,
    104   XML_ERROR_UNCLOSED_CDATA_SECTION,
    105   XML_ERROR_EXTERNAL_ENTITY_HANDLING,
    106   XML_ERROR_NOT_STANDALONE,
    107   XML_ERROR_UNEXPECTED_STATE,
    108   XML_ERROR_ENTITY_DECLARED_IN_PE,
    109   XML_ERROR_FEATURE_REQUIRES_XML_DTD,
    110   XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING,
    111   /* Added in 1.95.7. */
    112   XML_ERROR_UNBOUND_PREFIX,
    113   /* Added in 1.95.8. */
    114   XML_ERROR_UNDECLARING_PREFIX,
    115   XML_ERROR_INCOMPLETE_PE,
    116   XML_ERROR_XML_DECL,
    117   XML_ERROR_TEXT_DECL,
    118   XML_ERROR_PUBLICID,
    119   XML_ERROR_SUSPENDED,
    120   XML_ERROR_NOT_SUSPENDED,
    121   XML_ERROR_ABORTED,
    122   XML_ERROR_FINISHED,
    123   XML_ERROR_SUSPEND_PE,
    124   /* Added in 2.0. */
    125   XML_ERROR_RESERVED_PREFIX_XML,
    126   XML_ERROR_RESERVED_PREFIX_XMLNS,
    127   XML_ERROR_RESERVED_NAMESPACE_URI,
    128   /* Added in 2.2.1. */
    129   XML_ERROR_INVALID_ARGUMENT,
    130   /* Added in 2.3.0. */
    131   XML_ERROR_NO_BUFFER,
    132   /* Added in 2.4.0. */
    133   XML_ERROR_AMPLIFICATION_LIMIT_BREACH,
    134   /* Added in 2.6.4. */
    135   XML_ERROR_NOT_STARTED,
    136 };
    137 
    138 enum XML_Content_Type {
    139   XML_CTYPE_EMPTY = 1,
    140   XML_CTYPE_ANY,
    141   XML_CTYPE_MIXED,
    142   XML_CTYPE_NAME,
    143   XML_CTYPE_CHOICE,
    144   XML_CTYPE_SEQ
    145 };
    146 
    147 enum XML_Content_Quant {
    148   XML_CQUANT_NONE,
    149   XML_CQUANT_OPT,
    150   XML_CQUANT_REP,
    151   XML_CQUANT_PLUS
    152 };
    153 
    154 /* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
    155    XML_CQUANT_NONE, and the other fields will be zero or NULL.
    156    If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
    157    numchildren will contain number of elements that may be mixed in
    158    and children point to an array of XML_Content cells that will be
    159    all of XML_CTYPE_NAME type with no quantification.
    160 
    161    If type == XML_CTYPE_NAME, then the name points to the name, and
    162    the numchildren field will be zero and children will be NULL. The
    163    quant fields indicates any quantifiers placed on the name.
    164 
    165    CHOICE and SEQ will have name NULL, the number of children in
    166    numchildren and children will point, recursively, to an array
    167    of XML_Content cells.
    168 
    169    The EMPTY, ANY, and MIXED types will only occur at top level.
    170 */
    171 
    172 typedef struct XML_cp XML_Content;
    173 
    174 struct XML_cp {
    175   enum XML_Content_Type type;
    176   enum XML_Content_Quant quant;
    177   XML_Char *name;
    178   unsigned int numchildren;
    179   XML_Content *children;
    180 };
    181 
    182 /* This is called for an element declaration. See above for
    183    description of the model argument. It's the user code's responsibility
    184    to free model when finished with it. See XML_FreeContentModel.
    185    There is no need to free the model from the handler, it can be kept
    186    around and freed at a later stage.
    187 */
    188 typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData,
    189                                               const XML_Char *name,
    190                                               XML_Content *model);
    191 
    192 XMLPARSEAPI(void)
    193 XML_SetElementDeclHandler(XML_Parser parser, XML_ElementDeclHandler eldecl);
    194 
    195 /* The Attlist declaration handler is called for *each* attribute. So
    196    a single Attlist declaration with multiple attributes declared will
    197    generate multiple calls to this handler. The "default" parameter
    198    may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
    199    keyword. The "isrequired" parameter will be true and the default
    200    value will be NULL in the case of "#REQUIRED". If "isrequired" is
    201    true and default is non-NULL, then this is a "#FIXED" default.
    202 */
    203 typedef void(XMLCALL *XML_AttlistDeclHandler)(
    204     void *userData, const XML_Char *elname, const XML_Char *attname,
    205     const XML_Char *att_type, const XML_Char *dflt, int isrequired);
    206 
    207 XMLPARSEAPI(void)
    208 XML_SetAttlistDeclHandler(XML_Parser parser, XML_AttlistDeclHandler attdecl);
    209 
    210 /* The XML declaration handler is called for *both* XML declarations
    211    and text declarations. The way to distinguish is that the version
    212    parameter will be NULL for text declarations. The encoding
    213    parameter may be NULL for XML declarations. The standalone
    214    parameter will be -1, 0, or 1 indicating respectively that there
    215    was no standalone parameter in the declaration, that it was given
    216    as no, or that it was given as yes.
    217 */
    218 typedef void(XMLCALL *XML_XmlDeclHandler)(void *userData,
    219                                           const XML_Char *version,
    220                                           const XML_Char *encoding,
    221                                           int standalone);
    222 
    223 XMLPARSEAPI(void)
    224 XML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler xmldecl);
    225 
    226 typedef struct {
    227   void *(*malloc_fcn)(size_t size);
    228   void *(*realloc_fcn)(void *ptr, size_t size);
    229   void (*free_fcn)(void *ptr);
    230 } XML_Memory_Handling_Suite;
    231 
    232 /* Constructs a new parser; encoding is the encoding specified by the
    233    external protocol or NULL if there is none specified.
    234 */
    235 XMLPARSEAPI(XML_Parser)
    236 XML_ParserCreate(const XML_Char *encoding);
    237 
    238 /* Constructs a new parser and namespace processor.  Element type
    239    names and attribute names that belong to a namespace will be
    240    expanded; unprefixed attribute names are never expanded; unprefixed
    241    element type names are expanded only if there is a default
    242    namespace. The expanded name is the concatenation of the namespace
    243    URI, the namespace separator character, and the local part of the
    244    name.  If the namespace separator is '\0' then the namespace URI
    245    and the local part will be concatenated without any separator.
    246    It is a programming error to use the separator '\0' with namespace
    247    triplets (see XML_SetReturnNSTriplet).
    248    If a namespace separator is chosen that can be part of a URI or
    249    part of an XML name, splitting an expanded name back into its
    250    1, 2 or 3 original parts on application level in the element handler
    251    may end up vulnerable, so these are advised against;  sane choices for
    252    a namespace separator are e.g. '\n' (line feed) and '|' (pipe).
    253 
    254    Note that Expat does not validate namespace URIs (beyond encoding)
    255    against RFC 3986 today (and is not required to do so with regard to
    256    the XML 1.0 namespaces specification) but it may start doing that
    257    in future releases.  Before that, an application using Expat must
    258    be ready to receive namespace URIs containing non-URI characters.
    259 */
    260 XMLPARSEAPI(XML_Parser)
    261 XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
    262 
    263 /* Constructs a new parser using the memory management suite referred to
    264    by memsuite. If memsuite is NULL, then use the standard library memory
    265    suite. If namespaceSeparator is non-NULL it creates a parser with
    266    namespace processing as described above. The character pointed at
    267    will serve as the namespace separator.
    268 
    269    All further memory operations used for the created parser will come from
    270    the given suite.
    271 */
    272 XMLPARSEAPI(XML_Parser)
    273 XML_ParserCreate_MM(const XML_Char *encoding,
    274                     const XML_Memory_Handling_Suite *memsuite,
    275                     const XML_Char *namespaceSeparator);
    276 
    277 /* Prepare a parser object to be reused.  This is particularly
    278    valuable when memory allocation overhead is disproportionately high,
    279    such as when a large number of small documnents need to be parsed.
    280    All handlers are cleared from the parser, except for the
    281    unknownEncodingHandler. The parser's external state is re-initialized
    282    except for the values of ns and ns_triplets.
    283 
    284    Added in Expat 1.95.3.
    285 */
    286 XMLPARSEAPI(XML_Bool)
    287 XML_ParserReset(XML_Parser parser, const XML_Char *encoding);
    288 
    289 /* atts is array of name/value pairs, terminated by 0;
    290    names and values are 0 terminated.
    291 */
    292 typedef void(XMLCALL *XML_StartElementHandler)(void *userData,
    293                                                const XML_Char *name,
    294                                                const XML_Char **atts);
    295 
    296 typedef void(XMLCALL *XML_EndElementHandler)(void *userData,
    297                                              const XML_Char *name);
    298 
    299 /* s is not 0 terminated. */
    300 typedef void(XMLCALL *XML_CharacterDataHandler)(void *userData,
    301                                                 const XML_Char *s, int len);
    302 
    303 /* target and data are 0 terminated */
    304 typedef void(XMLCALL *XML_ProcessingInstructionHandler)(void *userData,
    305                                                         const XML_Char *target,
    306                                                         const XML_Char *data);
    307 
    308 /* data is 0 terminated */
    309 typedef void(XMLCALL *XML_CommentHandler)(void *userData, const XML_Char *data);
    310 
    311 typedef void(XMLCALL *XML_StartCdataSectionHandler)(void *userData);
    312 typedef void(XMLCALL *XML_EndCdataSectionHandler)(void *userData);
    313 
    314 /* This is called for any characters in the XML document for which
    315    there is no applicable handler.  This includes both characters that
    316    are part of markup which is of a kind that is not reported
    317    (comments, markup declarations), or characters that are part of a
    318    construct which could be reported but for which no handler has been
    319    supplied. The characters are passed exactly as they were in the XML
    320    document except that they will be encoded in UTF-8 or UTF-16.
    321    Line boundaries are not normalized. Note that a byte order mark
    322    character is not passed to the default handler. There are no
    323    guarantees about how characters are divided between calls to the
    324    default handler: for example, a comment might be split between
    325    multiple calls.
    326 */
    327 typedef void(XMLCALL *XML_DefaultHandler)(void *userData, const XML_Char *s,
    328                                           int len);
    329 
    330 /* This is called for the start of the DOCTYPE declaration, before
    331    any DTD or internal subset is parsed.
    332 */
    333 typedef void(XMLCALL *XML_StartDoctypeDeclHandler)(void *userData,
    334                                                    const XML_Char *doctypeName,
    335                                                    const XML_Char *sysid,
    336                                                    const XML_Char *pubid,
    337                                                    int has_internal_subset);
    338 
    339 /* This is called for the end of the DOCTYPE declaration when the
    340    closing > is encountered, but after processing any external
    341    subset.
    342 */
    343 typedef void(XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
    344 
    345 /* This is called for entity declarations. The is_parameter_entity
    346    argument will be non-zero if the entity is a parameter entity, zero
    347    otherwise.
    348 
    349    For internal entities (<!ENTITY foo "bar">), value will
    350    be non-NULL and systemId, publicID, and notationName will be NULL.
    351    The value string is NOT null-terminated; the length is provided in
    352    the value_length argument. Since it is legal to have zero-length
    353    values, do not use this argument to test for internal entities.
    354 
    355    For external entities, value will be NULL and systemId will be
    356    non-NULL. The publicId argument will be NULL unless a public
    357    identifier was provided. The notationName argument will have a
    358    non-NULL value only for unparsed entity declarations.
    359 
    360    Note that is_parameter_entity can't be changed to XML_Bool, since
    361    that would break binary compatibility.
    362 */
    363 typedef void(XMLCALL *XML_EntityDeclHandler)(
    364     void *userData, const XML_Char *entityName, int is_parameter_entity,
    365     const XML_Char *value, int value_length, const XML_Char *base,
    366     const XML_Char *systemId, const XML_Char *publicId,
    367     const XML_Char *notationName);
    368 
    369 XMLPARSEAPI(void)
    370 XML_SetEntityDeclHandler(XML_Parser parser, XML_EntityDeclHandler handler);
    371 
    372 /* OBSOLETE -- OBSOLETE -- OBSOLETE
    373    This handler has been superseded by the EntityDeclHandler above.
    374    It is provided here for backward compatibility.
    375 
    376    This is called for a declaration of an unparsed (NDATA) entity.
    377    The base argument is whatever was set by XML_SetBase. The
    378    entityName, systemId and notationName arguments will never be
    379    NULL. The other arguments may be.
    380 */
    381 typedef void(XMLCALL *XML_UnparsedEntityDeclHandler)(
    382     void *userData, const XML_Char *entityName, const XML_Char *base,
    383     const XML_Char *systemId, const XML_Char *publicId,
    384     const XML_Char *notationName);
    385 
    386 /* This is called for a declaration of notation.  The base argument is
    387    whatever was set by XML_SetBase. The notationName will never be
    388    NULL.  The other arguments can be.
    389 */
    390 typedef void(XMLCALL *XML_NotationDeclHandler)(void *userData,
    391                                                const XML_Char *notationName,
    392                                                const XML_Char *base,
    393                                                const XML_Char *systemId,
    394                                                const XML_Char *publicId);
    395 
    396 /* When namespace processing is enabled, these are called once for
    397    each namespace declaration. The call to the start and end element
    398    handlers occur between the calls to the start and end namespace
    399    declaration handlers. For an xmlns attribute, prefix will be
    400    NULL.  For an xmlns="" attribute, uri will be NULL.
    401 */
    402 typedef void(XMLCALL *XML_StartNamespaceDeclHandler)(void *userData,
    403                                                      const XML_Char *prefix,
    404                                                      const XML_Char *uri);
    405 
    406 typedef void(XMLCALL *XML_EndNamespaceDeclHandler)(void *userData,
    407                                                    const XML_Char *prefix);
    408 
    409 /* This is called if the document is not standalone, that is, it has an
    410    external subset or a reference to a parameter entity, but does not
    411    have standalone="yes". If this handler returns XML_STATUS_ERROR,
    412    then processing will not continue, and the parser will return a
    413    XML_ERROR_NOT_STANDALONE error.
    414    If parameter entity parsing is enabled, then in addition to the
    415    conditions above this handler will only be called if the referenced
    416    entity was actually read.
    417 */
    418 typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData);
    419 
    420 /* This is called for a reference to an external parsed general
    421    entity.  The referenced entity is not automatically parsed.  The
    422    application can parse it immediately or later using
    423    XML_ExternalEntityParserCreate.
    424 
    425    The parser argument is the parser parsing the entity containing the
    426    reference; it can be passed as the parser argument to
    427    XML_ExternalEntityParserCreate.  The systemId argument is the
    428    system identifier as specified in the entity declaration; it will
    429    not be NULL.
    430 
    431    The base argument is the system identifier that should be used as
    432    the base for resolving systemId if systemId was relative; this is
    433    set by XML_SetBase; it may be NULL.
    434 
    435    The publicId argument is the public identifier as specified in the
    436    entity declaration, or NULL if none was specified; the whitespace
    437    in the public identifier will have been normalized as required by
    438    the XML spec.
    439 
    440    The context argument specifies the parsing context in the format
    441    expected by the context argument to XML_ExternalEntityParserCreate;
    442    context is valid only until the handler returns, so if the
    443    referenced entity is to be parsed later, it must be copied.
    444    context is NULL only when the entity is a parameter entity.
    445 
    446    The handler should return XML_STATUS_ERROR if processing should not
    447    continue because of a fatal error in the handling of the external
    448    entity.  In this case the calling parser will return an
    449    XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
    450 
    451    Note that unlike other handlers the first argument is the parser,
    452    not userData.
    453 */
    454 typedef int(XMLCALL *XML_ExternalEntityRefHandler)(XML_Parser parser,
    455                                                    const XML_Char *context,
    456                                                    const XML_Char *base,
    457                                                    const XML_Char *systemId,
    458                                                    const XML_Char *publicId);
    459 
    460 /* This is called in two situations:
    461    1) An entity reference is encountered for which no declaration
    462       has been read *and* this is not an error.
    463    2) An internal entity reference is read, but not expanded, because
    464       XML_SetDefaultHandler has been called.
    465    Note: skipped parameter entities in declarations and skipped general
    466          entities in attribute values cannot be reported, because
    467          the event would be out of sync with the reporting of the
    468          declarations or attribute values
    469 */
    470 typedef void(XMLCALL *XML_SkippedEntityHandler)(void *userData,
    471                                                 const XML_Char *entityName,
    472                                                 int is_parameter_entity);
    473 
    474 /* This structure is filled in by the XML_UnknownEncodingHandler to
    475    provide information to the parser about encodings that are unknown
    476    to the parser.
    477 
    478    The map[b] member gives information about byte sequences whose
    479    first byte is b.
    480 
    481    If map[b] is c where c is >= 0, then b by itself encodes the
    482    Unicode scalar value c.
    483 
    484    If map[b] is -1, then the byte sequence is malformed.
    485 
    486    If map[b] is -n, where n >= 2, then b is the first byte of an
    487    n-byte sequence that encodes a single Unicode scalar value.
    488 
    489    The data member will be passed as the first argument to the convert
    490    function.
    491 
    492    The convert function is used to convert multibyte sequences; s will
    493    point to a n-byte sequence where map[(unsigned char)*s] == -n.  The
    494    convert function must return the Unicode scalar value represented
    495    by this byte sequence or -1 if the byte sequence is malformed.
    496 
    497    The convert function may be NULL if the encoding is a single-byte
    498    encoding, that is if map[b] >= -1 for all bytes b.
    499 
    500    When the parser is finished with the encoding, then if release is
    501    not NULL, it will call release passing it the data member; once
    502    release has been called, the convert function will not be called
    503    again.
    504 
    505    Expat places certain restrictions on the encodings that are supported
    506    using this mechanism.
    507 
    508    1. Every ASCII character that can appear in a well-formed XML document,
    509       other than the characters
    510 
    511       $@\^`{}~
    512 
    513       must be represented by a single byte, and that byte must be the
    514       same byte that represents that character in ASCII.
    515 
    516    2. No character may require more than 4 bytes to encode.
    517 
    518    3. All characters encoded must have Unicode scalar values <=
    519       0xFFFF, (i.e., characters that would be encoded by surrogates in
    520       UTF-16 are  not allowed).  Note that this restriction doesn't
    521       apply to the built-in support for UTF-8 and UTF-16.
    522 
    523    4. No Unicode character may be encoded by more than one distinct
    524       sequence of bytes.
    525 */
    526 typedef struct {
    527   int map[256];
    528   void *data;
    529   int(XMLCALL *convert)(void *data, const char *s);
    530   void(XMLCALL *release)(void *data);
    531 } XML_Encoding;
    532 
    533 /* This is called for an encoding that is unknown to the parser.
    534 
    535    The encodingHandlerData argument is that which was passed as the
    536    second argument to XML_SetUnknownEncodingHandler.
    537 
    538    The name argument gives the name of the encoding as specified in
    539    the encoding declaration.
    540 
    541    If the callback can provide information about the encoding, it must
    542    fill in the XML_Encoding structure, and return XML_STATUS_OK.
    543    Otherwise it must return XML_STATUS_ERROR.
    544 
    545    If info does not describe a suitable encoding, then the parser will
    546    return an XML_ERROR_UNKNOWN_ENCODING error.
    547 */
    548 typedef int(XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData,
    549                                                  const XML_Char *name,
    550                                                  XML_Encoding *info);
    551 
    552 XMLPARSEAPI(void)
    553 XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start,
    554                       XML_EndElementHandler end);
    555 
    556 XMLPARSEAPI(void)
    557 XML_SetStartElementHandler(XML_Parser parser, XML_StartElementHandler handler);
    558 
    559 XMLPARSEAPI(void)
    560 XML_SetEndElementHandler(XML_Parser parser, XML_EndElementHandler handler);
    561 
    562 XMLPARSEAPI(void)
    563 XML_SetCharacterDataHandler(XML_Parser parser,
    564                             XML_CharacterDataHandler handler);
    565 
    566 XMLPARSEAPI(void)
    567 XML_SetProcessingInstructionHandler(XML_Parser parser,
    568                                     XML_ProcessingInstructionHandler handler);
    569 XMLPARSEAPI(void)
    570 XML_SetCommentHandler(XML_Parser parser, XML_CommentHandler handler);
    571 
    572 XMLPARSEAPI(void)
    573 XML_SetCdataSectionHandler(XML_Parser parser,
    574                            XML_StartCdataSectionHandler start,
    575                            XML_EndCdataSectionHandler end);
    576 
    577 XMLPARSEAPI(void)
    578 XML_SetStartCdataSectionHandler(XML_Parser parser,
    579                                 XML_StartCdataSectionHandler start);
    580 
    581 XMLPARSEAPI(void)
    582 XML_SetEndCdataSectionHandler(XML_Parser parser,
    583                               XML_EndCdataSectionHandler end);
    584 
    585 /* This sets the default handler and also inhibits expansion of
    586    internal entities. These entity references will be passed to the
    587    default handler, or to the skipped entity handler, if one is set.
    588 */
    589 XMLPARSEAPI(void)
    590 XML_SetDefaultHandler(XML_Parser parser, XML_DefaultHandler handler);
    591 
    592 /* This sets the default handler but does not inhibit expansion of
    593    internal entities.  The entity reference will not be passed to the
    594    default handler.
    595 */
    596 XMLPARSEAPI(void)
    597 XML_SetDefaultHandlerExpand(XML_Parser parser, XML_DefaultHandler handler);
    598 
    599 XMLPARSEAPI(void)
    600 XML_SetDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start,
    601                           XML_EndDoctypeDeclHandler end);
    602 
    603 XMLPARSEAPI(void)
    604 XML_SetStartDoctypeDeclHandler(XML_Parser parser,
    605                                XML_StartDoctypeDeclHandler start);
    606 
    607 XMLPARSEAPI(void)
    608 XML_SetEndDoctypeDeclHandler(XML_Parser parser, XML_EndDoctypeDeclHandler end);
    609 
    610 XMLPARSEAPI(void)
    611 XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
    612                                  XML_UnparsedEntityDeclHandler handler);
    613 
    614 XMLPARSEAPI(void)
    615 XML_SetNotationDeclHandler(XML_Parser parser, XML_NotationDeclHandler handler);
    616 
    617 XMLPARSEAPI(void)
    618 XML_SetNamespaceDeclHandler(XML_Parser parser,
    619                             XML_StartNamespaceDeclHandler start,
    620                             XML_EndNamespaceDeclHandler end);
    621 
    622 XMLPARSEAPI(void)
    623 XML_SetStartNamespaceDeclHandler(XML_Parser parser,
    624                                  XML_StartNamespaceDeclHandler start);
    625 
    626 XMLPARSEAPI(void)
    627 XML_SetEndNamespaceDeclHandler(XML_Parser parser,
    628                                XML_EndNamespaceDeclHandler end);
    629 
    630 XMLPARSEAPI(void)
    631 XML_SetNotStandaloneHandler(XML_Parser parser,
    632                             XML_NotStandaloneHandler handler);
    633 
    634 XMLPARSEAPI(void)
    635 XML_SetExternalEntityRefHandler(XML_Parser parser,
    636                                 XML_ExternalEntityRefHandler handler);
    637 
    638 /* If a non-NULL value for arg is specified here, then it will be
    639    passed as the first argument to the external entity ref handler
    640    instead of the parser object.
    641 */
    642 XMLPARSEAPI(void)
    643 XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg);
    644 
    645 XMLPARSEAPI(void)
    646 XML_SetSkippedEntityHandler(XML_Parser parser,
    647                             XML_SkippedEntityHandler handler);
    648 
    649 XMLPARSEAPI(void)
    650 XML_SetUnknownEncodingHandler(XML_Parser parser,
    651                               XML_UnknownEncodingHandler handler,
    652                               void *encodingHandlerData);
    653 
    654 /* This can be called within a handler for a start element, end
    655    element, processing instruction or character data.  It causes the
    656    corresponding markup to be passed to the default handler.
    657 */
    658 XMLPARSEAPI(void)
    659 XML_DefaultCurrent(XML_Parser parser);
    660 
    661 /* If do_nst is non-zero, and namespace processing is in effect, and
    662    a name has a prefix (i.e. an explicit namespace qualifier) then
    663    that name is returned as a triplet in a single string separated by
    664    the separator character specified when the parser was created: URI
    665    + sep + local_name + sep + prefix.
    666 
    667    If do_nst is zero, then namespace information is returned in the
    668    default manner (URI + sep + local_name) whether or not the name
    669    has a prefix.
    670 
    671    Note: Calling XML_SetReturnNSTriplet after XML_Parse or
    672      XML_ParseBuffer has no effect.
    673 */
    674 
    675 XMLPARSEAPI(void)
    676 XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
    677 
    678 /* This value is passed as the userData argument to callbacks. */
    679 XMLPARSEAPI(void)
    680 XML_SetUserData(XML_Parser parser, void *userData);
    681 
    682 /* Returns the last value set by XML_SetUserData or NULL. */
    683 #define XML_GetUserData(parser) (*(void **)(parser))
    684 
    685 /* This is equivalent to supplying an encoding argument to
    686    XML_ParserCreate. On success XML_SetEncoding returns non-zero,
    687    zero otherwise.
    688    Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer
    689      has no effect and returns XML_STATUS_ERROR.
    690 */
    691 XMLPARSEAPI(enum XML_Status)
    692 XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
    693 
    694 /* If this function is called, then the parser will be passed as the
    695    first argument to callbacks instead of userData.  The userData will
    696    still be accessible using XML_GetUserData.
    697 */
    698 XMLPARSEAPI(void)
    699 XML_UseParserAsHandlerArg(XML_Parser parser);
    700 
    701 /* If useDTD == XML_TRUE is passed to this function, then the parser
    702    will assume that there is an external subset, even if none is
    703    specified in the document. In such a case the parser will call the
    704    externalEntityRefHandler with a value of NULL for the systemId
    705    argument (the publicId and context arguments will be NULL as well).
    706    Note: For the purpose of checking WFC: Entity Declared, passing
    707      useDTD == XML_TRUE will make the parser behave as if the document
    708      had a DTD with an external subset.
    709    Note: If this function is called, then this must be done before
    710      the first call to XML_Parse or XML_ParseBuffer, since it will
    711      have no effect after that.  Returns
    712      XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING.
    713    Note: If the document does not have a DOCTYPE declaration at all,
    714      then startDoctypeDeclHandler and endDoctypeDeclHandler will not
    715      be called, despite an external subset being parsed.
    716    Note: If XML_DTD is not defined when Expat is compiled, returns
    717      XML_ERROR_FEATURE_REQUIRES_XML_DTD.
    718    Note: If parser == NULL, returns XML_ERROR_INVALID_ARGUMENT.
    719 */
    720 XMLPARSEAPI(enum XML_Error)
    721 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
    722 
    723 /* Sets the base to be used for resolving relative URIs in system
    724    identifiers in declarations.  Resolving relative identifiers is
    725    left to the application: this value will be passed through as the
    726    base argument to the XML_ExternalEntityRefHandler,
    727    XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base
    728    argument will be copied.  Returns XML_STATUS_ERROR if out of memory,
    729    XML_STATUS_OK otherwise.
    730 */
    731 XMLPARSEAPI(enum XML_Status)
    732 XML_SetBase(XML_Parser parser, const XML_Char *base);
    733 
    734 XMLPARSEAPI(const XML_Char *)
    735 XML_GetBase(XML_Parser parser);
    736 
    737 /* Returns the number of the attribute/value pairs passed in last call
    738    to the XML_StartElementHandler that were specified in the start-tag
    739    rather than defaulted. Each attribute/value pair counts as 2; thus
    740    this corresponds to an index into the atts array passed to the
    741    XML_StartElementHandler.  Returns -1 if parser == NULL.
    742 */
    743 XMLPARSEAPI(int)
    744 XML_GetSpecifiedAttributeCount(XML_Parser parser);
    745 
    746 /* Returns the index of the ID attribute passed in the last call to
    747    XML_StartElementHandler, or -1 if there is no ID attribute or
    748    parser == NULL.  Each attribute/value pair counts as 2; thus this
    749    corresponds to an index into the atts array passed to the
    750    XML_StartElementHandler.
    751 */
    752 XMLPARSEAPI(int)
    753 XML_GetIdAttributeIndex(XML_Parser parser);
    754 
    755 #ifdef XML_ATTR_INFO
    756 /* Source file byte offsets for the start and end of attribute names and values.
    757    The value indices are exclusive of surrounding quotes; thus in a UTF-8 source
    758    file an attribute value of "blah" will yield:
    759    info->valueEnd - info->valueStart = 4 bytes.
    760 */
    761 typedef struct {
    762   XML_Index nameStart;  /* Offset to beginning of the attribute name. */
    763   XML_Index nameEnd;    /* Offset after the attribute name's last byte. */
    764   XML_Index valueStart; /* Offset to beginning of the attribute value. */
    765   XML_Index valueEnd;   /* Offset after the attribute value's last byte. */
    766 } XML_AttrInfo;
    767 
    768 /* Returns an array of XML_AttrInfo structures for the attribute/value pairs
    769    passed in last call to the XML_StartElementHandler that were specified
    770    in the start-tag rather than defaulted. Each attribute/value pair counts
    771    as 1; thus the number of entries in the array is
    772    XML_GetSpecifiedAttributeCount(parser) / 2.
    773 */
    774 XMLPARSEAPI(const XML_AttrInfo *)
    775 XML_GetAttributeInfo(XML_Parser parser);
    776 #endif
    777 
    778 /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
    779    detected.  The last call to XML_Parse must have isFinal true; len
    780    may be zero for this call (or any other).
    781 
    782    Though the return values for these functions has always been
    783    described as a Boolean value, the implementation, at least for the
    784    1.95.x series, has always returned exactly one of the XML_Status
    785    values.
    786 */
    787 XMLPARSEAPI(enum XML_Status)
    788 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
    789 
    790 XMLPARSEAPI(void *)
    791 XML_GetBuffer(XML_Parser parser, int len);
    792 
    793 XMLPARSEAPI(enum XML_Status)
    794 XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
    795 
    796 /* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return.
    797    Must be called from within a call-back handler, except when aborting
    798    (resumable = 0) an already suspended parser. Some call-backs may
    799    still follow because they would otherwise get lost. Examples:
    800    - endElementHandler() for empty elements when stopped in
    801      startElementHandler(),
    802    - endNameSpaceDeclHandler() when stopped in endElementHandler(),
    803    and possibly others.
    804 
    805    Can be called from most handlers, including DTD related call-backs,
    806    except when parsing an external parameter entity and resumable != 0.
    807    Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise.
    808    Possible error codes:
    809    - XML_ERROR_SUSPENDED: when suspending an already suspended parser.
    810    - XML_ERROR_FINISHED: when the parser has already finished.
    811    - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE.
    812 
    813    When resumable != 0 (true) then parsing is suspended, that is,
    814    XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED.
    815    Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer()
    816    return XML_STATUS_ERROR with error code XML_ERROR_ABORTED.
    817 
    818    *Note*:
    819    This will be applied to the current parser instance only, that is, if
    820    there is a parent parser then it will continue parsing when the
    821    externalEntityRefHandler() returns. It is up to the implementation of
    822    the externalEntityRefHandler() to call XML_StopParser() on the parent
    823    parser (recursively), if one wants to stop parsing altogether.
    824 
    825    When suspended, parsing can be resumed by calling XML_ResumeParser().
    826 */
    827 XMLPARSEAPI(enum XML_Status)
    828 XML_StopParser(XML_Parser parser, XML_Bool resumable);
    829 
    830 /* Resumes parsing after it has been suspended with XML_StopParser().
    831    Must not be called from within a handler call-back. Returns same
    832    status codes as XML_Parse() or XML_ParseBuffer().
    833    Additional error code XML_ERROR_NOT_SUSPENDED possible.
    834 
    835    *Note*:
    836    This must be called on the most deeply nested child parser instance
    837    first, and on its parent parser only after the child parser has finished,
    838    to be applied recursively until the document entity's parser is restarted.
    839    That is, the parent parser will not resume by itself and it is up to the
    840    application to call XML_ResumeParser() on it at the appropriate moment.
    841 */
    842 XMLPARSEAPI(enum XML_Status)
    843 XML_ResumeParser(XML_Parser parser);
    844 
    845 enum XML_Parsing { XML_INITIALIZED, XML_PARSING, XML_FINISHED, XML_SUSPENDED };
    846 
    847 typedef struct {
    848   enum XML_Parsing parsing;
    849   XML_Bool finalBuffer;
    850 } XML_ParsingStatus;
    851 
    852 /* Returns status of parser with respect to being initialized, parsing,
    853    finished, or suspended and processing the final buffer.
    854    XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus,
    855    XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED
    856 */
    857 XMLPARSEAPI(void)
    858 XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status);
    859 
    860 /* Creates an XML_Parser object that can parse an external general
    861    entity; context is a '\0'-terminated string specifying the parse
    862    context; encoding is a '\0'-terminated string giving the name of
    863    the externally specified encoding, or NULL if there is no
    864    externally specified encoding.  The context string consists of a
    865    sequence of tokens separated by formfeeds (\f); a token consisting
    866    of a name specifies that the general entity of the name is open; a
    867    token of the form prefix=uri specifies the namespace for a
    868    particular prefix; a token of the form =uri specifies the default
    869    namespace.  This can be called at any point after the first call to
    870    an ExternalEntityRefHandler so longer as the parser has not yet
    871    been freed.  The new parser is completely independent and may
    872    safely be used in a separate thread.  The handlers and userData are
    873    initialized from the parser argument.  Returns NULL if out of memory.
    874    Otherwise returns a new XML_Parser object.
    875 */
    876 XMLPARSEAPI(XML_Parser)
    877 XML_ExternalEntityParserCreate(XML_Parser parser, const XML_Char *context,
    878                                const XML_Char *encoding);
    879 
    880 enum XML_ParamEntityParsing {
    881   XML_PARAM_ENTITY_PARSING_NEVER,
    882   XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
    883   XML_PARAM_ENTITY_PARSING_ALWAYS
    884 };
    885 
    886 /* Controls parsing of parameter entities (including the external DTD
    887    subset). If parsing of parameter entities is enabled, then
    888    references to external parameter entities (including the external
    889    DTD subset) will be passed to the handler set with
    890    XML_SetExternalEntityRefHandler.  The context passed will be 0.
    891 
    892    Unlike external general entities, external parameter entities can
    893    only be parsed synchronously.  If the external parameter entity is
    894    to be parsed, it must be parsed during the call to the external
    895    entity ref handler: the complete sequence of
    896    XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
    897    XML_ParserFree calls must be made during this call.  After
    898    XML_ExternalEntityParserCreate has been called to create the parser
    899    for the external parameter entity (context must be 0 for this
    900    call), it is illegal to make any calls on the old parser until
    901    XML_ParserFree has been called on the newly created parser.
    902    If the library has been compiled without support for parameter
    903    entity parsing (ie without XML_DTD being defined), then
    904    XML_SetParamEntityParsing will return 0 if parsing of parameter
    905    entities is requested; otherwise it will return non-zero.
    906    Note: If XML_SetParamEntityParsing is called after XML_Parse or
    907       XML_ParseBuffer, then it has no effect and will always return 0.
    908    Note: If parser == NULL, the function will do nothing and return 0.
    909 */
    910 XMLPARSEAPI(int)
    911 XML_SetParamEntityParsing(XML_Parser parser,
    912                           enum XML_ParamEntityParsing parsing);
    913 
    914 /* Sets the hash salt to use for internal hash calculations.
    915    Helps in preventing DoS attacks based on predicting hash
    916    function behavior. This must be called before parsing is started.
    917    Returns 1 if successful, 0 when called after parsing has started.
    918    Note: If parser == NULL, the function will do nothing and return 0.
    919 */
    920 XMLPARSEAPI(int)
    921 XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt);
    922 
    923 /* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
    924    XML_GetErrorCode returns information about the error.
    925 */
    926 XMLPARSEAPI(enum XML_Error)
    927 XML_GetErrorCode(XML_Parser parser);
    928 
    929 /* These functions return information about the current parse
    930    location.  They may be called from any callback called to report
    931    some parse event; in this case the location is the location of the
    932    first of the sequence of characters that generated the event.  When
    933    called from callbacks generated by declarations in the document
    934    prologue, the location identified isn't as neatly defined, but will
    935    be within the relevant markup.  When called outside of the callback
    936    functions, the position indicated will be just past the last parse
    937    event (regardless of whether there was an associated callback).
    938 
    939    They may also be called after returning from a call to XML_Parse
    940    or XML_ParseBuffer.  If the return value is XML_STATUS_ERROR then
    941    the location is the location of the character at which the error
    942    was detected; otherwise the location is the location of the last
    943    parse event, as described above.
    944 
    945    Note: XML_GetCurrentLineNumber and XML_GetCurrentColumnNumber
    946    return 0 to indicate an error.
    947    Note: XML_GetCurrentByteIndex returns -1 to indicate an error.
    948 */
    949 XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser);
    950 XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser);
    951 XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser);
    952 
    953 /* Return the number of bytes in the current event.
    954    Returns 0 if the event is in an internal entity.
    955 */
    956 XMLPARSEAPI(int)
    957 XML_GetCurrentByteCount(XML_Parser parser);
    958 
    959 /* If XML_CONTEXT_BYTES is >=1, returns the input buffer, sets
    960    the integer pointed to by offset to the offset within this buffer
    961    of the current parse position, and sets the integer pointed to by size
    962    to the size of this buffer (the number of input bytes). Otherwise
    963    returns a NULL pointer. Also returns a NULL pointer if a parse isn't
    964    active.
    965 
    966    NOTE: The character pointer returned should not be used outside
    967    the handler that makes the call.
    968 */
    969 XMLPARSEAPI(const char *)
    970 XML_GetInputContext(XML_Parser parser, int *offset, int *size);
    971 
    972 /* For backwards compatibility with previous versions. */
    973 #define XML_GetErrorLineNumber XML_GetCurrentLineNumber
    974 #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
    975 #define XML_GetErrorByteIndex XML_GetCurrentByteIndex
    976 
    977 /* Frees the content model passed to the element declaration handler */
    978 XMLPARSEAPI(void)
    979 XML_FreeContentModel(XML_Parser parser, XML_Content *model);
    980 
    981 /* Exposing the memory handling functions used in Expat */
    982 XMLPARSEAPI(void *)
    983 XML_ATTR_MALLOC
    984 XML_ATTR_ALLOC_SIZE(2)
    985 XML_MemMalloc(XML_Parser parser, size_t size);
    986 
    987 XMLPARSEAPI(void *)
    988 XML_ATTR_ALLOC_SIZE(3)
    989 XML_MemRealloc(XML_Parser parser, void *ptr, size_t size);
    990 
    991 XMLPARSEAPI(void)
    992 XML_MemFree(XML_Parser parser, void *ptr);
    993 
    994 /* Frees memory used by the parser. */
    995 XMLPARSEAPI(void)
    996 XML_ParserFree(XML_Parser parser);
    997 
    998 /* Returns a string describing the error. */
    999 XMLPARSEAPI(const XML_LChar *)
   1000 XML_ErrorString(enum XML_Error code);
   1001 
   1002 /* Return a string containing the version number of this expat */
   1003 XMLPARSEAPI(const XML_LChar *)
   1004 XML_ExpatVersion(void);
   1005 
   1006 typedef struct {
   1007   int major;
   1008   int minor;
   1009   int micro;
   1010 } XML_Expat_Version;
   1011 
   1012 /* Return an XML_Expat_Version structure containing numeric version
   1013    number information for this version of expat.
   1014 */
   1015 XMLPARSEAPI(XML_Expat_Version)
   1016 XML_ExpatVersionInfo(void);
   1017 
   1018 /* Added in Expat 1.95.5. */
   1019 enum XML_FeatureEnum {
   1020   XML_FEATURE_END = 0,
   1021   XML_FEATURE_UNICODE,
   1022   XML_FEATURE_UNICODE_WCHAR_T,
   1023   XML_FEATURE_DTD,
   1024   XML_FEATURE_CONTEXT_BYTES,
   1025   XML_FEATURE_MIN_SIZE,
   1026   XML_FEATURE_SIZEOF_XML_CHAR,
   1027   XML_FEATURE_SIZEOF_XML_LCHAR,
   1028   XML_FEATURE_NS,
   1029   XML_FEATURE_LARGE_SIZE,
   1030   XML_FEATURE_ATTR_INFO,
   1031   /* Added in Expat 2.4.0. */
   1032   XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT,
   1033   XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT,
   1034   /* Added in Expat 2.6.0. */
   1035   XML_FEATURE_GE
   1036   /* Additional features must be added to the end of this enum. */
   1037 };
   1038 
   1039 typedef struct {
   1040   enum XML_FeatureEnum feature;
   1041   const XML_LChar *name;
   1042   long int value;
   1043 } XML_Feature;
   1044 
   1045 XMLPARSEAPI(const XML_Feature *)
   1046 XML_GetFeatureList(void);
   1047 
   1048 #if defined(XML_DTD) || (defined(XML_GE) && XML_GE == 1)
   1049 /* Added in Expat 2.4.0 for XML_DTD defined and
   1050  * added in Expat 2.6.0 for XML_GE == 1. */
   1051 XMLPARSEAPI(XML_Bool)
   1052 XML_SetBillionLaughsAttackProtectionMaximumAmplification(
   1053     XML_Parser parser, float maximumAmplificationFactor);
   1054 
   1055 /* Added in Expat 2.4.0 for XML_DTD defined and
   1056  * added in Expat 2.6.0 for XML_GE == 1. */
   1057 XMLPARSEAPI(XML_Bool)
   1058 XML_SetBillionLaughsAttackProtectionActivationThreshold(
   1059     XML_Parser parser, unsigned long long activationThresholdBytes);
   1060 #endif
   1061 
   1062 /* Added in Expat 2.6.0. */
   1063 XMLPARSEAPI(XML_Bool)
   1064 XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled);
   1065 
   1066 /* Expat follows the semantic versioning convention.
   1067    See https://semver.org
   1068 */
   1069 #define XML_MAJOR_VERSION 2
   1070 #define XML_MINOR_VERSION 7
   1071 #define XML_MICRO_VERSION 1
   1072 
   1073 #ifdef __cplusplus
   1074 }
   1075 #endif
   1076 
   1077 #endif /* not Expat_INCLUDED */
   1078