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