xref: /freebsd/contrib/expat/lib/expat.h (revision be8aff81c11e51d25e7a134298b6aa0300f4b7fc)
15bb6a25fSPoul-Henning Kamp /* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
25bb6a25fSPoul-Henning Kamp    See the file COPYING for copying permission.
35bb6a25fSPoul-Henning Kamp */
45bb6a25fSPoul-Henning Kamp 
5220ed979SColeman Kane #ifndef Expat_INCLUDED
6220ed979SColeman Kane #define Expat_INCLUDED 1
75bb6a25fSPoul-Henning Kamp 
85bb6a25fSPoul-Henning Kamp #ifdef __VMS
95bb6a25fSPoul-Henning Kamp /*      0        1         2         3      0        1         2         3
105bb6a25fSPoul-Henning Kamp         1234567890123456789012345678901     1234567890123456789012345678901 */
115bb6a25fSPoul-Henning Kamp #define XML_SetProcessingInstructionHandler XML_SetProcessingInstrHandler
125bb6a25fSPoul-Henning Kamp #define XML_SetUnparsedEntityDeclHandler    XML_SetUnparsedEntDeclHandler
135bb6a25fSPoul-Henning Kamp #define XML_SetStartNamespaceDeclHandler    XML_SetStartNamespcDeclHandler
145bb6a25fSPoul-Henning Kamp #define XML_SetExternalEntityRefHandlerArg  XML_SetExternalEntRefHandlerArg
155bb6a25fSPoul-Henning Kamp #endif
165bb6a25fSPoul-Henning Kamp 
175bb6a25fSPoul-Henning Kamp #include <stdlib.h>
18220ed979SColeman Kane #include "expat_external.h"
195bb6a25fSPoul-Henning Kamp 
205bb6a25fSPoul-Henning Kamp #ifdef __cplusplus
215bb6a25fSPoul-Henning Kamp extern "C" {
225bb6a25fSPoul-Henning Kamp #endif
235bb6a25fSPoul-Henning Kamp 
245bb6a25fSPoul-Henning Kamp struct XML_ParserStruct;
255bb6a25fSPoul-Henning Kamp typedef struct XML_ParserStruct *XML_Parser;
265bb6a25fSPoul-Henning Kamp 
275bb6a25fSPoul-Henning Kamp /* Should this be defined using stdbool.h when C99 is available? */
285bb6a25fSPoul-Henning Kamp typedef unsigned char XML_Bool;
295bb6a25fSPoul-Henning Kamp #define XML_TRUE   ((XML_Bool) 1)
305bb6a25fSPoul-Henning Kamp #define XML_FALSE  ((XML_Bool) 0)
315bb6a25fSPoul-Henning Kamp 
32220ed979SColeman Kane /* The XML_Status enum gives the possible return values for several
33220ed979SColeman Kane    API functions.  The preprocessor #defines are included so this
34220ed979SColeman Kane    stanza can be added to code that still needs to support older
35220ed979SColeman Kane    versions of Expat 1.95.x:
36220ed979SColeman Kane 
37220ed979SColeman Kane    #ifndef XML_STATUS_OK
38220ed979SColeman Kane    #define XML_STATUS_OK    1
39220ed979SColeman Kane    #define XML_STATUS_ERROR 0
40220ed979SColeman Kane    #endif
41220ed979SColeman Kane 
42220ed979SColeman Kane    Otherwise, the #define hackery is quite ugly and would have been
43220ed979SColeman Kane    dropped.
44220ed979SColeman Kane */
45220ed979SColeman Kane enum XML_Status {
46220ed979SColeman Kane   XML_STATUS_ERROR = 0,
47220ed979SColeman Kane #define XML_STATUS_ERROR XML_STATUS_ERROR
48220ed979SColeman Kane   XML_STATUS_OK = 1,
49220ed979SColeman Kane #define XML_STATUS_OK XML_STATUS_OK
50220ed979SColeman Kane   XML_STATUS_SUSPENDED = 2
51220ed979SColeman Kane #define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED
52220ed979SColeman Kane };
53220ed979SColeman Kane 
545bb6a25fSPoul-Henning Kamp enum XML_Error {
555bb6a25fSPoul-Henning Kamp   XML_ERROR_NONE,
565bb6a25fSPoul-Henning Kamp   XML_ERROR_NO_MEMORY,
575bb6a25fSPoul-Henning Kamp   XML_ERROR_SYNTAX,
585bb6a25fSPoul-Henning Kamp   XML_ERROR_NO_ELEMENTS,
595bb6a25fSPoul-Henning Kamp   XML_ERROR_INVALID_TOKEN,
605bb6a25fSPoul-Henning Kamp   XML_ERROR_UNCLOSED_TOKEN,
615bb6a25fSPoul-Henning Kamp   XML_ERROR_PARTIAL_CHAR,
625bb6a25fSPoul-Henning Kamp   XML_ERROR_TAG_MISMATCH,
635bb6a25fSPoul-Henning Kamp   XML_ERROR_DUPLICATE_ATTRIBUTE,
645bb6a25fSPoul-Henning Kamp   XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
655bb6a25fSPoul-Henning Kamp   XML_ERROR_PARAM_ENTITY_REF,
665bb6a25fSPoul-Henning Kamp   XML_ERROR_UNDEFINED_ENTITY,
675bb6a25fSPoul-Henning Kamp   XML_ERROR_RECURSIVE_ENTITY_REF,
685bb6a25fSPoul-Henning Kamp   XML_ERROR_ASYNC_ENTITY,
695bb6a25fSPoul-Henning Kamp   XML_ERROR_BAD_CHAR_REF,
705bb6a25fSPoul-Henning Kamp   XML_ERROR_BINARY_ENTITY_REF,
715bb6a25fSPoul-Henning Kamp   XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
725bb6a25fSPoul-Henning Kamp   XML_ERROR_MISPLACED_XML_PI,
735bb6a25fSPoul-Henning Kamp   XML_ERROR_UNKNOWN_ENCODING,
745bb6a25fSPoul-Henning Kamp   XML_ERROR_INCORRECT_ENCODING,
755bb6a25fSPoul-Henning Kamp   XML_ERROR_UNCLOSED_CDATA_SECTION,
765bb6a25fSPoul-Henning Kamp   XML_ERROR_EXTERNAL_ENTITY_HANDLING,
775bb6a25fSPoul-Henning Kamp   XML_ERROR_NOT_STANDALONE,
785bb6a25fSPoul-Henning Kamp   XML_ERROR_UNEXPECTED_STATE,
795bb6a25fSPoul-Henning Kamp   XML_ERROR_ENTITY_DECLARED_IN_PE,
805bb6a25fSPoul-Henning Kamp   XML_ERROR_FEATURE_REQUIRES_XML_DTD,
81220ed979SColeman Kane   XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING,
82220ed979SColeman Kane   /* Added in 1.95.7. */
83220ed979SColeman Kane   XML_ERROR_UNBOUND_PREFIX,
84220ed979SColeman Kane   /* Added in 1.95.8. */
85220ed979SColeman Kane   XML_ERROR_UNDECLARING_PREFIX,
86220ed979SColeman Kane   XML_ERROR_INCOMPLETE_PE,
87220ed979SColeman Kane   XML_ERROR_XML_DECL,
88220ed979SColeman Kane   XML_ERROR_TEXT_DECL,
89220ed979SColeman Kane   XML_ERROR_PUBLICID,
90220ed979SColeman Kane   XML_ERROR_SUSPENDED,
91220ed979SColeman Kane   XML_ERROR_NOT_SUSPENDED,
92220ed979SColeman Kane   XML_ERROR_ABORTED,
93220ed979SColeman Kane   XML_ERROR_FINISHED,
94220ed979SColeman Kane   XML_ERROR_SUSPEND_PE,
95220ed979SColeman Kane   /* Added in 2.0. */
96220ed979SColeman Kane   XML_ERROR_RESERVED_PREFIX_XML,
97220ed979SColeman Kane   XML_ERROR_RESERVED_PREFIX_XMLNS,
98220ed979SColeman Kane   XML_ERROR_RESERVED_NAMESPACE_URI
995bb6a25fSPoul-Henning Kamp };
1005bb6a25fSPoul-Henning Kamp 
1015bb6a25fSPoul-Henning Kamp enum XML_Content_Type {
1025bb6a25fSPoul-Henning Kamp   XML_CTYPE_EMPTY = 1,
1035bb6a25fSPoul-Henning Kamp   XML_CTYPE_ANY,
1045bb6a25fSPoul-Henning Kamp   XML_CTYPE_MIXED,
1055bb6a25fSPoul-Henning Kamp   XML_CTYPE_NAME,
1065bb6a25fSPoul-Henning Kamp   XML_CTYPE_CHOICE,
1075bb6a25fSPoul-Henning Kamp   XML_CTYPE_SEQ
1085bb6a25fSPoul-Henning Kamp };
1095bb6a25fSPoul-Henning Kamp 
1105bb6a25fSPoul-Henning Kamp enum XML_Content_Quant {
1115bb6a25fSPoul-Henning Kamp   XML_CQUANT_NONE,
1125bb6a25fSPoul-Henning Kamp   XML_CQUANT_OPT,
1135bb6a25fSPoul-Henning Kamp   XML_CQUANT_REP,
1145bb6a25fSPoul-Henning Kamp   XML_CQUANT_PLUS
1155bb6a25fSPoul-Henning Kamp };
1165bb6a25fSPoul-Henning Kamp 
1175bb6a25fSPoul-Henning Kamp /* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
1185bb6a25fSPoul-Henning Kamp    XML_CQUANT_NONE, and the other fields will be zero or NULL.
1195bb6a25fSPoul-Henning Kamp    If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
1205bb6a25fSPoul-Henning Kamp    numchildren will contain number of elements that may be mixed in
1215bb6a25fSPoul-Henning Kamp    and children point to an array of XML_Content cells that will be
1225bb6a25fSPoul-Henning Kamp    all of XML_CTYPE_NAME type with no quantification.
1235bb6a25fSPoul-Henning Kamp 
1245bb6a25fSPoul-Henning Kamp    If type == XML_CTYPE_NAME, then the name points to the name, and
1255bb6a25fSPoul-Henning Kamp    the numchildren field will be zero and children will be NULL. The
1265bb6a25fSPoul-Henning Kamp    quant fields indicates any quantifiers placed on the name.
1275bb6a25fSPoul-Henning Kamp 
1285bb6a25fSPoul-Henning Kamp    CHOICE and SEQ will have name NULL, the number of children in
1295bb6a25fSPoul-Henning Kamp    numchildren and children will point, recursively, to an array
1305bb6a25fSPoul-Henning Kamp    of XML_Content cells.
1315bb6a25fSPoul-Henning Kamp 
1325bb6a25fSPoul-Henning Kamp    The EMPTY, ANY, and MIXED types will only occur at top level.
1335bb6a25fSPoul-Henning Kamp */
1345bb6a25fSPoul-Henning Kamp 
1355bb6a25fSPoul-Henning Kamp typedef struct XML_cp XML_Content;
1365bb6a25fSPoul-Henning Kamp 
1375bb6a25fSPoul-Henning Kamp struct XML_cp {
1385bb6a25fSPoul-Henning Kamp   enum XML_Content_Type         type;
1395bb6a25fSPoul-Henning Kamp   enum XML_Content_Quant        quant;
1405bb6a25fSPoul-Henning Kamp   XML_Char *                    name;
1415bb6a25fSPoul-Henning Kamp   unsigned int                  numchildren;
1425bb6a25fSPoul-Henning Kamp   XML_Content *                 children;
1435bb6a25fSPoul-Henning Kamp };
1445bb6a25fSPoul-Henning Kamp 
1455bb6a25fSPoul-Henning Kamp 
1465bb6a25fSPoul-Henning Kamp /* This is called for an element declaration. See above for
1475bb6a25fSPoul-Henning Kamp    description of the model argument. It's the caller's responsibility
1485bb6a25fSPoul-Henning Kamp    to free model when finished with it.
1495bb6a25fSPoul-Henning Kamp */
150220ed979SColeman Kane typedef void (XMLCALL *XML_ElementDeclHandler) (void *userData,
1515bb6a25fSPoul-Henning Kamp                                                 const XML_Char *name,
1525bb6a25fSPoul-Henning Kamp                                                 XML_Content *model);
1535bb6a25fSPoul-Henning Kamp 
1545bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
1555bb6a25fSPoul-Henning Kamp XML_SetElementDeclHandler(XML_Parser parser,
1565bb6a25fSPoul-Henning Kamp                           XML_ElementDeclHandler eldecl);
1575bb6a25fSPoul-Henning Kamp 
1585bb6a25fSPoul-Henning Kamp /* The Attlist declaration handler is called for *each* attribute. So
1595bb6a25fSPoul-Henning Kamp    a single Attlist declaration with multiple attributes declared will
1605bb6a25fSPoul-Henning Kamp    generate multiple calls to this handler. The "default" parameter
1615bb6a25fSPoul-Henning Kamp    may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
1625bb6a25fSPoul-Henning Kamp    keyword. The "isrequired" parameter will be true and the default
1635bb6a25fSPoul-Henning Kamp    value will be NULL in the case of "#REQUIRED". If "isrequired" is
1645bb6a25fSPoul-Henning Kamp    true and default is non-NULL, then this is a "#FIXED" default.
1655bb6a25fSPoul-Henning Kamp */
166220ed979SColeman Kane typedef void (XMLCALL *XML_AttlistDeclHandler) (
167220ed979SColeman Kane                                     void            *userData,
1685bb6a25fSPoul-Henning Kamp                                     const XML_Char  *elname,
1695bb6a25fSPoul-Henning Kamp                                     const XML_Char  *attname,
1705bb6a25fSPoul-Henning Kamp                                     const XML_Char  *att_type,
1715bb6a25fSPoul-Henning Kamp                                     const XML_Char  *dflt,
1725bb6a25fSPoul-Henning Kamp                                     int              isrequired);
1735bb6a25fSPoul-Henning Kamp 
1745bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
1755bb6a25fSPoul-Henning Kamp XML_SetAttlistDeclHandler(XML_Parser parser,
1765bb6a25fSPoul-Henning Kamp                           XML_AttlistDeclHandler attdecl);
1775bb6a25fSPoul-Henning Kamp 
1785bb6a25fSPoul-Henning Kamp /* The XML declaration handler is called for *both* XML declarations
1795bb6a25fSPoul-Henning Kamp    and text declarations. The way to distinguish is that the version
1805bb6a25fSPoul-Henning Kamp    parameter will be NULL for text declarations. The encoding
1815bb6a25fSPoul-Henning Kamp    parameter may be NULL for XML declarations. The standalone
1825bb6a25fSPoul-Henning Kamp    parameter will be -1, 0, or 1 indicating respectively that there
1835bb6a25fSPoul-Henning Kamp    was no standalone parameter in the declaration, that it was given
1845bb6a25fSPoul-Henning Kamp    as no, or that it was given as yes.
1855bb6a25fSPoul-Henning Kamp */
186220ed979SColeman Kane typedef void (XMLCALL *XML_XmlDeclHandler) (void           *userData,
1875bb6a25fSPoul-Henning Kamp                                             const XML_Char *version,
1885bb6a25fSPoul-Henning Kamp                                             const XML_Char *encoding,
1895bb6a25fSPoul-Henning Kamp                                             int             standalone);
1905bb6a25fSPoul-Henning Kamp 
1915bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
1925bb6a25fSPoul-Henning Kamp XML_SetXmlDeclHandler(XML_Parser parser,
1935bb6a25fSPoul-Henning Kamp                       XML_XmlDeclHandler xmldecl);
1945bb6a25fSPoul-Henning Kamp 
1955bb6a25fSPoul-Henning Kamp 
1965bb6a25fSPoul-Henning Kamp typedef struct {
1975bb6a25fSPoul-Henning Kamp   void *(*malloc_fcn)(size_t size);
1985bb6a25fSPoul-Henning Kamp   void *(*realloc_fcn)(void *ptr, size_t size);
1995bb6a25fSPoul-Henning Kamp   void (*free_fcn)(void *ptr);
2005bb6a25fSPoul-Henning Kamp } XML_Memory_Handling_Suite;
2015bb6a25fSPoul-Henning Kamp 
2025bb6a25fSPoul-Henning Kamp /* Constructs a new parser; encoding is the encoding specified by the
2035bb6a25fSPoul-Henning Kamp    external protocol or NULL if there is none specified.
2045bb6a25fSPoul-Henning Kamp */
2055bb6a25fSPoul-Henning Kamp XMLPARSEAPI(XML_Parser)
2065bb6a25fSPoul-Henning Kamp XML_ParserCreate(const XML_Char *encoding);
2075bb6a25fSPoul-Henning Kamp 
2085bb6a25fSPoul-Henning Kamp /* Constructs a new parser and namespace processor.  Element type
2095bb6a25fSPoul-Henning Kamp    names and attribute names that belong to a namespace will be
2105bb6a25fSPoul-Henning Kamp    expanded; unprefixed attribute names are never expanded; unprefixed
2115bb6a25fSPoul-Henning Kamp    element type names are expanded only if there is a default
2125bb6a25fSPoul-Henning Kamp    namespace. The expanded name is the concatenation of the namespace
2135bb6a25fSPoul-Henning Kamp    URI, the namespace separator character, and the local part of the
2145bb6a25fSPoul-Henning Kamp    name.  If the namespace separator is '\0' then the namespace URI
2155bb6a25fSPoul-Henning Kamp    and the local part will be concatenated without any separator.
216220ed979SColeman Kane    It is a programming error to use the separator '\0' with namespace
217220ed979SColeman Kane    triplets (see XML_SetReturnNSTriplet).
2185bb6a25fSPoul-Henning Kamp */
2195bb6a25fSPoul-Henning Kamp XMLPARSEAPI(XML_Parser)
2205bb6a25fSPoul-Henning Kamp XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
2215bb6a25fSPoul-Henning Kamp 
2225bb6a25fSPoul-Henning Kamp 
223220ed979SColeman Kane /* Constructs a new parser using the memory management suite referred to
2245bb6a25fSPoul-Henning Kamp    by memsuite. If memsuite is NULL, then use the standard library memory
2255bb6a25fSPoul-Henning Kamp    suite. If namespaceSeparator is non-NULL it creates a parser with
2265bb6a25fSPoul-Henning Kamp    namespace processing as described above. The character pointed at
2275bb6a25fSPoul-Henning Kamp    will serve as the namespace separator.
2285bb6a25fSPoul-Henning Kamp 
2295bb6a25fSPoul-Henning Kamp    All further memory operations used for the created parser will come from
2305bb6a25fSPoul-Henning Kamp    the given suite.
2315bb6a25fSPoul-Henning Kamp */
2325bb6a25fSPoul-Henning Kamp XMLPARSEAPI(XML_Parser)
2335bb6a25fSPoul-Henning Kamp XML_ParserCreate_MM(const XML_Char *encoding,
2345bb6a25fSPoul-Henning Kamp                     const XML_Memory_Handling_Suite *memsuite,
2355bb6a25fSPoul-Henning Kamp                     const XML_Char *namespaceSeparator);
2365bb6a25fSPoul-Henning Kamp 
2375bb6a25fSPoul-Henning Kamp /* Prepare a parser object to be re-used.  This is particularly
2385bb6a25fSPoul-Henning Kamp    valuable when memory allocation overhead is disproportionatly high,
2395bb6a25fSPoul-Henning Kamp    such as when a large number of small documnents need to be parsed.
2405bb6a25fSPoul-Henning Kamp    All handlers are cleared from the parser, except for the
2415bb6a25fSPoul-Henning Kamp    unknownEncodingHandler. The parser's external state is re-initialized
2425bb6a25fSPoul-Henning Kamp    except for the values of ns and ns_triplets.
2435bb6a25fSPoul-Henning Kamp 
2445bb6a25fSPoul-Henning Kamp    Added in Expat 1.95.3.
2455bb6a25fSPoul-Henning Kamp */
2465bb6a25fSPoul-Henning Kamp XMLPARSEAPI(XML_Bool)
2475bb6a25fSPoul-Henning Kamp XML_ParserReset(XML_Parser parser, const XML_Char *encoding);
2485bb6a25fSPoul-Henning Kamp 
2495bb6a25fSPoul-Henning Kamp /* atts is array of name/value pairs, terminated by 0;
2505bb6a25fSPoul-Henning Kamp    names and values are 0 terminated.
2515bb6a25fSPoul-Henning Kamp */
252220ed979SColeman Kane typedef void (XMLCALL *XML_StartElementHandler) (void *userData,
2535bb6a25fSPoul-Henning Kamp                                                  const XML_Char *name,
2545bb6a25fSPoul-Henning Kamp                                                  const XML_Char **atts);
2555bb6a25fSPoul-Henning Kamp 
256220ed979SColeman Kane typedef void (XMLCALL *XML_EndElementHandler) (void *userData,
2575bb6a25fSPoul-Henning Kamp                                                const XML_Char *name);
2585bb6a25fSPoul-Henning Kamp 
2595bb6a25fSPoul-Henning Kamp 
2605bb6a25fSPoul-Henning Kamp /* s is not 0 terminated. */
261220ed979SColeman Kane typedef void (XMLCALL *XML_CharacterDataHandler) (void *userData,
2625bb6a25fSPoul-Henning Kamp                                                   const XML_Char *s,
2635bb6a25fSPoul-Henning Kamp                                                   int len);
2645bb6a25fSPoul-Henning Kamp 
2655bb6a25fSPoul-Henning Kamp /* target and data are 0 terminated */
266220ed979SColeman Kane typedef void (XMLCALL *XML_ProcessingInstructionHandler) (
267220ed979SColeman Kane                                                 void *userData,
2685bb6a25fSPoul-Henning Kamp                                                 const XML_Char *target,
2695bb6a25fSPoul-Henning Kamp                                                 const XML_Char *data);
2705bb6a25fSPoul-Henning Kamp 
2715bb6a25fSPoul-Henning Kamp /* data is 0 terminated */
272220ed979SColeman Kane typedef void (XMLCALL *XML_CommentHandler) (void *userData,
273220ed979SColeman Kane                                             const XML_Char *data);
2745bb6a25fSPoul-Henning Kamp 
275220ed979SColeman Kane typedef void (XMLCALL *XML_StartCdataSectionHandler) (void *userData);
276220ed979SColeman Kane typedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData);
2775bb6a25fSPoul-Henning Kamp 
2785bb6a25fSPoul-Henning Kamp /* This is called for any characters in the XML document for which
2795bb6a25fSPoul-Henning Kamp    there is no applicable handler.  This includes both characters that
2805bb6a25fSPoul-Henning Kamp    are part of markup which is of a kind that is not reported
2815bb6a25fSPoul-Henning Kamp    (comments, markup declarations), or characters that are part of a
2825bb6a25fSPoul-Henning Kamp    construct which could be reported but for which no handler has been
2835bb6a25fSPoul-Henning Kamp    supplied. The characters are passed exactly as they were in the XML
2845bb6a25fSPoul-Henning Kamp    document except that they will be encoded in UTF-8 or UTF-16.
2855bb6a25fSPoul-Henning Kamp    Line boundaries are not normalized. Note that a byte order mark
2865bb6a25fSPoul-Henning Kamp    character is not passed to the default handler. There are no
2875bb6a25fSPoul-Henning Kamp    guarantees about how characters are divided between calls to the
2885bb6a25fSPoul-Henning Kamp    default handler: for example, a comment might be split between
2895bb6a25fSPoul-Henning Kamp    multiple calls.
2905bb6a25fSPoul-Henning Kamp */
291220ed979SColeman Kane typedef void (XMLCALL *XML_DefaultHandler) (void *userData,
2925bb6a25fSPoul-Henning Kamp                                             const XML_Char *s,
2935bb6a25fSPoul-Henning Kamp                                             int len);
2945bb6a25fSPoul-Henning Kamp 
2955bb6a25fSPoul-Henning Kamp /* This is called for the start of the DOCTYPE declaration, before
2965bb6a25fSPoul-Henning Kamp    any DTD or internal subset is parsed.
2975bb6a25fSPoul-Henning Kamp */
298220ed979SColeman Kane typedef void (XMLCALL *XML_StartDoctypeDeclHandler) (
299220ed979SColeman Kane                                             void *userData,
3005bb6a25fSPoul-Henning Kamp                                             const XML_Char *doctypeName,
3015bb6a25fSPoul-Henning Kamp                                             const XML_Char *sysid,
3025bb6a25fSPoul-Henning Kamp                                             const XML_Char *pubid,
3035bb6a25fSPoul-Henning Kamp                                             int has_internal_subset);
3045bb6a25fSPoul-Henning Kamp 
3055bb6a25fSPoul-Henning Kamp /* This is called for the start of the DOCTYPE declaration when the
3065bb6a25fSPoul-Henning Kamp    closing > is encountered, but after processing any external
3075bb6a25fSPoul-Henning Kamp    subset.
3085bb6a25fSPoul-Henning Kamp */
309220ed979SColeman Kane typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
3105bb6a25fSPoul-Henning Kamp 
3115bb6a25fSPoul-Henning Kamp /* This is called for entity declarations. The is_parameter_entity
3125bb6a25fSPoul-Henning Kamp    argument will be non-zero if the entity is a parameter entity, zero
3135bb6a25fSPoul-Henning Kamp    otherwise.
3145bb6a25fSPoul-Henning Kamp 
3155bb6a25fSPoul-Henning Kamp    For internal entities (<!ENTITY foo "bar">), value will
3165bb6a25fSPoul-Henning Kamp    be non-NULL and systemId, publicID, and notationName will be NULL.
3175bb6a25fSPoul-Henning Kamp    The value string is NOT nul-terminated; the length is provided in
3185bb6a25fSPoul-Henning Kamp    the value_length argument. Since it is legal to have zero-length
3195bb6a25fSPoul-Henning Kamp    values, do not use this argument to test for internal entities.
3205bb6a25fSPoul-Henning Kamp 
3215bb6a25fSPoul-Henning Kamp    For external entities, value will be NULL and systemId will be
3225bb6a25fSPoul-Henning Kamp    non-NULL. The publicId argument will be NULL unless a public
3235bb6a25fSPoul-Henning Kamp    identifier was provided. The notationName argument will have a
3245bb6a25fSPoul-Henning Kamp    non-NULL value only for unparsed entity declarations.
3255bb6a25fSPoul-Henning Kamp 
3265bb6a25fSPoul-Henning Kamp    Note that is_parameter_entity can't be changed to XML_Bool, since
3275bb6a25fSPoul-Henning Kamp    that would break binary compatibility.
3285bb6a25fSPoul-Henning Kamp */
329220ed979SColeman Kane typedef void (XMLCALL *XML_EntityDeclHandler) (
330220ed979SColeman Kane                               void *userData,
3315bb6a25fSPoul-Henning Kamp                               const XML_Char *entityName,
3325bb6a25fSPoul-Henning Kamp                               int is_parameter_entity,
3335bb6a25fSPoul-Henning Kamp                               const XML_Char *value,
3345bb6a25fSPoul-Henning Kamp                               int value_length,
3355bb6a25fSPoul-Henning Kamp                               const XML_Char *base,
3365bb6a25fSPoul-Henning Kamp                               const XML_Char *systemId,
3375bb6a25fSPoul-Henning Kamp                               const XML_Char *publicId,
3385bb6a25fSPoul-Henning Kamp                               const XML_Char *notationName);
3395bb6a25fSPoul-Henning Kamp 
3405bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
3415bb6a25fSPoul-Henning Kamp XML_SetEntityDeclHandler(XML_Parser parser,
3425bb6a25fSPoul-Henning Kamp                          XML_EntityDeclHandler handler);
3435bb6a25fSPoul-Henning Kamp 
3445bb6a25fSPoul-Henning Kamp /* OBSOLETE -- OBSOLETE -- OBSOLETE
345*be8aff81SXin LI    This handler has been superseded by the EntityDeclHandler above.
3465bb6a25fSPoul-Henning Kamp    It is provided here for backward compatibility.
3475bb6a25fSPoul-Henning Kamp 
3485bb6a25fSPoul-Henning Kamp    This is called for a declaration of an unparsed (NDATA) entity.
3495bb6a25fSPoul-Henning Kamp    The base argument is whatever was set by XML_SetBase. The
3505bb6a25fSPoul-Henning Kamp    entityName, systemId and notationName arguments will never be
3515bb6a25fSPoul-Henning Kamp    NULL. The other arguments may be.
3525bb6a25fSPoul-Henning Kamp */
353220ed979SColeman Kane typedef void (XMLCALL *XML_UnparsedEntityDeclHandler) (
354220ed979SColeman Kane                                     void *userData,
3555bb6a25fSPoul-Henning Kamp                                     const XML_Char *entityName,
3565bb6a25fSPoul-Henning Kamp                                     const XML_Char *base,
3575bb6a25fSPoul-Henning Kamp                                     const XML_Char *systemId,
3585bb6a25fSPoul-Henning Kamp                                     const XML_Char *publicId,
3595bb6a25fSPoul-Henning Kamp                                     const XML_Char *notationName);
3605bb6a25fSPoul-Henning Kamp 
3615bb6a25fSPoul-Henning Kamp /* This is called for a declaration of notation.  The base argument is
3625bb6a25fSPoul-Henning Kamp    whatever was set by XML_SetBase. The notationName will never be
3635bb6a25fSPoul-Henning Kamp    NULL.  The other arguments can be.
3645bb6a25fSPoul-Henning Kamp */
365220ed979SColeman Kane typedef void (XMLCALL *XML_NotationDeclHandler) (
366220ed979SColeman Kane                                     void *userData,
3675bb6a25fSPoul-Henning Kamp                                     const XML_Char *notationName,
3685bb6a25fSPoul-Henning Kamp                                     const XML_Char *base,
3695bb6a25fSPoul-Henning Kamp                                     const XML_Char *systemId,
3705bb6a25fSPoul-Henning Kamp                                     const XML_Char *publicId);
3715bb6a25fSPoul-Henning Kamp 
3725bb6a25fSPoul-Henning Kamp /* When namespace processing is enabled, these are called once for
3735bb6a25fSPoul-Henning Kamp    each namespace declaration. The call to the start and end element
3745bb6a25fSPoul-Henning Kamp    handlers occur between the calls to the start and end namespace
3755bb6a25fSPoul-Henning Kamp    declaration handlers. For an xmlns attribute, prefix will be
3765bb6a25fSPoul-Henning Kamp    NULL.  For an xmlns="" attribute, uri will be NULL.
3775bb6a25fSPoul-Henning Kamp */
378220ed979SColeman Kane typedef void (XMLCALL *XML_StartNamespaceDeclHandler) (
379220ed979SColeman Kane                                     void *userData,
3805bb6a25fSPoul-Henning Kamp                                     const XML_Char *prefix,
3815bb6a25fSPoul-Henning Kamp                                     const XML_Char *uri);
3825bb6a25fSPoul-Henning Kamp 
383220ed979SColeman Kane typedef void (XMLCALL *XML_EndNamespaceDeclHandler) (
384220ed979SColeman Kane                                     void *userData,
3855bb6a25fSPoul-Henning Kamp                                     const XML_Char *prefix);
3865bb6a25fSPoul-Henning Kamp 
3875bb6a25fSPoul-Henning Kamp /* This is called if the document is not standalone, that is, it has an
3885bb6a25fSPoul-Henning Kamp    external subset or a reference to a parameter entity, but does not
389220ed979SColeman Kane    have standalone="yes". If this handler returns XML_STATUS_ERROR,
390220ed979SColeman Kane    then processing will not continue, and the parser will return a
3915bb6a25fSPoul-Henning Kamp    XML_ERROR_NOT_STANDALONE error.
3925bb6a25fSPoul-Henning Kamp    If parameter entity parsing is enabled, then in addition to the
3935bb6a25fSPoul-Henning Kamp    conditions above this handler will only be called if the referenced
3945bb6a25fSPoul-Henning Kamp    entity was actually read.
3955bb6a25fSPoul-Henning Kamp */
396220ed979SColeman Kane typedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData);
3975bb6a25fSPoul-Henning Kamp 
3985bb6a25fSPoul-Henning Kamp /* This is called for a reference to an external parsed general
3995bb6a25fSPoul-Henning Kamp    entity.  The referenced entity is not automatically parsed.  The
4005bb6a25fSPoul-Henning Kamp    application can parse it immediately or later using
4015bb6a25fSPoul-Henning Kamp    XML_ExternalEntityParserCreate.
4025bb6a25fSPoul-Henning Kamp 
4035bb6a25fSPoul-Henning Kamp    The parser argument is the parser parsing the entity containing the
4045bb6a25fSPoul-Henning Kamp    reference; it can be passed as the parser argument to
4055bb6a25fSPoul-Henning Kamp    XML_ExternalEntityParserCreate.  The systemId argument is the
4065bb6a25fSPoul-Henning Kamp    system identifier as specified in the entity declaration; it will
4075bb6a25fSPoul-Henning Kamp    not be NULL.
4085bb6a25fSPoul-Henning Kamp 
4095bb6a25fSPoul-Henning Kamp    The base argument is the system identifier that should be used as
4105bb6a25fSPoul-Henning Kamp    the base for resolving systemId if systemId was relative; this is
4115bb6a25fSPoul-Henning Kamp    set by XML_SetBase; it may be NULL.
4125bb6a25fSPoul-Henning Kamp 
4135bb6a25fSPoul-Henning Kamp    The publicId argument is the public identifier as specified in the
4145bb6a25fSPoul-Henning Kamp    entity declaration, or NULL if none was specified; the whitespace
4155bb6a25fSPoul-Henning Kamp    in the public identifier will have been normalized as required by
4165bb6a25fSPoul-Henning Kamp    the XML spec.
4175bb6a25fSPoul-Henning Kamp 
4185bb6a25fSPoul-Henning Kamp    The context argument specifies the parsing context in the format
4195bb6a25fSPoul-Henning Kamp    expected by the context argument to XML_ExternalEntityParserCreate;
4205bb6a25fSPoul-Henning Kamp    context is valid only until the handler returns, so if the
4215bb6a25fSPoul-Henning Kamp    referenced entity is to be parsed later, it must be copied.
422220ed979SColeman Kane    context is NULL only when the entity is a parameter entity.
4235bb6a25fSPoul-Henning Kamp 
424220ed979SColeman Kane    The handler should return XML_STATUS_ERROR if processing should not
425220ed979SColeman Kane    continue because of a fatal error in the handling of the external
426220ed979SColeman Kane    entity.  In this case the calling parser will return an
4275bb6a25fSPoul-Henning Kamp    XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
4285bb6a25fSPoul-Henning Kamp 
4295bb6a25fSPoul-Henning Kamp    Note that unlike other handlers the first argument is the parser,
4305bb6a25fSPoul-Henning Kamp    not userData.
4315bb6a25fSPoul-Henning Kamp */
432220ed979SColeman Kane typedef int (XMLCALL *XML_ExternalEntityRefHandler) (
433220ed979SColeman Kane                                     XML_Parser parser,
4345bb6a25fSPoul-Henning Kamp                                     const XML_Char *context,
4355bb6a25fSPoul-Henning Kamp                                     const XML_Char *base,
4365bb6a25fSPoul-Henning Kamp                                     const XML_Char *systemId,
4375bb6a25fSPoul-Henning Kamp                                     const XML_Char *publicId);
4385bb6a25fSPoul-Henning Kamp 
4395bb6a25fSPoul-Henning Kamp /* This is called in two situations:
4405bb6a25fSPoul-Henning Kamp    1) An entity reference is encountered for which no declaration
4415bb6a25fSPoul-Henning Kamp       has been read *and* this is not an error.
4425bb6a25fSPoul-Henning Kamp    2) An internal entity reference is read, but not expanded, because
4435bb6a25fSPoul-Henning Kamp       XML_SetDefaultHandler has been called.
4445bb6a25fSPoul-Henning Kamp    Note: skipped parameter entities in declarations and skipped general
4455bb6a25fSPoul-Henning Kamp          entities in attribute values cannot be reported, because
4465bb6a25fSPoul-Henning Kamp          the event would be out of sync with the reporting of the
4475bb6a25fSPoul-Henning Kamp          declarations or attribute values
4485bb6a25fSPoul-Henning Kamp */
449220ed979SColeman Kane typedef void (XMLCALL *XML_SkippedEntityHandler) (
450220ed979SColeman Kane                                     void *userData,
4515bb6a25fSPoul-Henning Kamp                                     const XML_Char *entityName,
4525bb6a25fSPoul-Henning Kamp                                     int is_parameter_entity);
4535bb6a25fSPoul-Henning Kamp 
4545bb6a25fSPoul-Henning Kamp /* This structure is filled in by the XML_UnknownEncodingHandler to
4555bb6a25fSPoul-Henning Kamp    provide information to the parser about encodings that are unknown
4565bb6a25fSPoul-Henning Kamp    to the parser.
4575bb6a25fSPoul-Henning Kamp 
4585bb6a25fSPoul-Henning Kamp    The map[b] member gives information about byte sequences whose
4595bb6a25fSPoul-Henning Kamp    first byte is b.
4605bb6a25fSPoul-Henning Kamp 
4615bb6a25fSPoul-Henning Kamp    If map[b] is c where c is >= 0, then b by itself encodes the
4625bb6a25fSPoul-Henning Kamp    Unicode scalar value c.
4635bb6a25fSPoul-Henning Kamp 
4645bb6a25fSPoul-Henning Kamp    If map[b] is -1, then the byte sequence is malformed.
4655bb6a25fSPoul-Henning Kamp 
4665bb6a25fSPoul-Henning Kamp    If map[b] is -n, where n >= 2, then b is the first byte of an
4675bb6a25fSPoul-Henning Kamp    n-byte sequence that encodes a single Unicode scalar value.
4685bb6a25fSPoul-Henning Kamp 
4695bb6a25fSPoul-Henning Kamp    The data member will be passed as the first argument to the convert
4705bb6a25fSPoul-Henning Kamp    function.
4715bb6a25fSPoul-Henning Kamp 
4725bb6a25fSPoul-Henning Kamp    The convert function is used to convert multibyte sequences; s will
4735bb6a25fSPoul-Henning Kamp    point to a n-byte sequence where map[(unsigned char)*s] == -n.  The
4745bb6a25fSPoul-Henning Kamp    convert function must return the Unicode scalar value represented
4755bb6a25fSPoul-Henning Kamp    by this byte sequence or -1 if the byte sequence is malformed.
4765bb6a25fSPoul-Henning Kamp 
4775bb6a25fSPoul-Henning Kamp    The convert function may be NULL if the encoding is a single-byte
4785bb6a25fSPoul-Henning Kamp    encoding, that is if map[b] >= -1 for all bytes b.
4795bb6a25fSPoul-Henning Kamp 
4805bb6a25fSPoul-Henning Kamp    When the parser is finished with the encoding, then if release is
4815bb6a25fSPoul-Henning Kamp    not NULL, it will call release passing it the data member; once
4825bb6a25fSPoul-Henning Kamp    release has been called, the convert function will not be called
4835bb6a25fSPoul-Henning Kamp    again.
4845bb6a25fSPoul-Henning Kamp 
4855bb6a25fSPoul-Henning Kamp    Expat places certain restrictions on the encodings that are supported
4865bb6a25fSPoul-Henning Kamp    using this mechanism.
4875bb6a25fSPoul-Henning Kamp 
4885bb6a25fSPoul-Henning Kamp    1. Every ASCII character that can appear in a well-formed XML document,
4895bb6a25fSPoul-Henning Kamp       other than the characters
4905bb6a25fSPoul-Henning Kamp 
4915bb6a25fSPoul-Henning Kamp       $@\^`{}~
4925bb6a25fSPoul-Henning Kamp 
4935bb6a25fSPoul-Henning Kamp       must be represented by a single byte, and that byte must be the
4945bb6a25fSPoul-Henning Kamp       same byte that represents that character in ASCII.
4955bb6a25fSPoul-Henning Kamp 
4965bb6a25fSPoul-Henning Kamp    2. No character may require more than 4 bytes to encode.
4975bb6a25fSPoul-Henning Kamp 
4985bb6a25fSPoul-Henning Kamp    3. All characters encoded must have Unicode scalar values <=
4995bb6a25fSPoul-Henning Kamp       0xFFFF, (i.e., characters that would be encoded by surrogates in
5005bb6a25fSPoul-Henning Kamp       UTF-16 are  not allowed).  Note that this restriction doesn't
5015bb6a25fSPoul-Henning Kamp       apply to the built-in support for UTF-8 and UTF-16.
5025bb6a25fSPoul-Henning Kamp 
5035bb6a25fSPoul-Henning Kamp    4. No Unicode character may be encoded by more than one distinct
5045bb6a25fSPoul-Henning Kamp       sequence of bytes.
5055bb6a25fSPoul-Henning Kamp */
5065bb6a25fSPoul-Henning Kamp typedef struct {
5075bb6a25fSPoul-Henning Kamp   int map[256];
5085bb6a25fSPoul-Henning Kamp   void *data;
509220ed979SColeman Kane   int (XMLCALL *convert)(void *data, const char *s);
510220ed979SColeman Kane   void (XMLCALL *release)(void *data);
5115bb6a25fSPoul-Henning Kamp } XML_Encoding;
5125bb6a25fSPoul-Henning Kamp 
5135bb6a25fSPoul-Henning Kamp /* This is called for an encoding that is unknown to the parser.
5145bb6a25fSPoul-Henning Kamp 
5155bb6a25fSPoul-Henning Kamp    The encodingHandlerData argument is that which was passed as the
5165bb6a25fSPoul-Henning Kamp    second argument to XML_SetUnknownEncodingHandler.
5175bb6a25fSPoul-Henning Kamp 
5185bb6a25fSPoul-Henning Kamp    The name argument gives the name of the encoding as specified in
5195bb6a25fSPoul-Henning Kamp    the encoding declaration.
5205bb6a25fSPoul-Henning Kamp 
5215bb6a25fSPoul-Henning Kamp    If the callback can provide information about the encoding, it must
522220ed979SColeman Kane    fill in the XML_Encoding structure, and return XML_STATUS_OK.
523220ed979SColeman Kane    Otherwise it must return XML_STATUS_ERROR.
5245bb6a25fSPoul-Henning Kamp 
5255bb6a25fSPoul-Henning Kamp    If info does not describe a suitable encoding, then the parser will
5265bb6a25fSPoul-Henning Kamp    return an XML_UNKNOWN_ENCODING error.
5275bb6a25fSPoul-Henning Kamp */
528220ed979SColeman Kane typedef int (XMLCALL *XML_UnknownEncodingHandler) (
529220ed979SColeman Kane                                     void *encodingHandlerData,
5305bb6a25fSPoul-Henning Kamp                                     const XML_Char *name,
5315bb6a25fSPoul-Henning Kamp                                     XML_Encoding *info);
5325bb6a25fSPoul-Henning Kamp 
5335bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
5345bb6a25fSPoul-Henning Kamp XML_SetElementHandler(XML_Parser parser,
5355bb6a25fSPoul-Henning Kamp                       XML_StartElementHandler start,
5365bb6a25fSPoul-Henning Kamp                       XML_EndElementHandler end);
5375bb6a25fSPoul-Henning Kamp 
5385bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
539220ed979SColeman Kane XML_SetStartElementHandler(XML_Parser parser,
540220ed979SColeman Kane                            XML_StartElementHandler handler);
5415bb6a25fSPoul-Henning Kamp 
5425bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
543220ed979SColeman Kane XML_SetEndElementHandler(XML_Parser parser,
544220ed979SColeman Kane                          XML_EndElementHandler handler);
5455bb6a25fSPoul-Henning Kamp 
5465bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
5475bb6a25fSPoul-Henning Kamp XML_SetCharacterDataHandler(XML_Parser parser,
5485bb6a25fSPoul-Henning Kamp                             XML_CharacterDataHandler handler);
5495bb6a25fSPoul-Henning Kamp 
5505bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
5515bb6a25fSPoul-Henning Kamp XML_SetProcessingInstructionHandler(XML_Parser parser,
5525bb6a25fSPoul-Henning Kamp                                     XML_ProcessingInstructionHandler handler);
5535bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
5545bb6a25fSPoul-Henning Kamp XML_SetCommentHandler(XML_Parser parser,
5555bb6a25fSPoul-Henning Kamp                       XML_CommentHandler handler);
5565bb6a25fSPoul-Henning Kamp 
5575bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
5585bb6a25fSPoul-Henning Kamp XML_SetCdataSectionHandler(XML_Parser parser,
5595bb6a25fSPoul-Henning Kamp                            XML_StartCdataSectionHandler start,
5605bb6a25fSPoul-Henning Kamp                            XML_EndCdataSectionHandler end);
5615bb6a25fSPoul-Henning Kamp 
5625bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
5635bb6a25fSPoul-Henning Kamp XML_SetStartCdataSectionHandler(XML_Parser parser,
5645bb6a25fSPoul-Henning Kamp                                 XML_StartCdataSectionHandler start);
5655bb6a25fSPoul-Henning Kamp 
5665bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
5675bb6a25fSPoul-Henning Kamp XML_SetEndCdataSectionHandler(XML_Parser parser,
5685bb6a25fSPoul-Henning Kamp                               XML_EndCdataSectionHandler end);
5695bb6a25fSPoul-Henning Kamp 
5705bb6a25fSPoul-Henning Kamp /* This sets the default handler and also inhibits expansion of
5715bb6a25fSPoul-Henning Kamp    internal entities. These entity references will be passed to the
5725bb6a25fSPoul-Henning Kamp    default handler, or to the skipped entity handler, if one is set.
5735bb6a25fSPoul-Henning Kamp */
5745bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
5755bb6a25fSPoul-Henning Kamp XML_SetDefaultHandler(XML_Parser parser,
5765bb6a25fSPoul-Henning Kamp                       XML_DefaultHandler handler);
5775bb6a25fSPoul-Henning Kamp 
5785bb6a25fSPoul-Henning Kamp /* This sets the default handler but does not inhibit expansion of
5795bb6a25fSPoul-Henning Kamp    internal entities.  The entity reference will not be passed to the
5805bb6a25fSPoul-Henning Kamp    default handler.
5815bb6a25fSPoul-Henning Kamp */
5825bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
5835bb6a25fSPoul-Henning Kamp XML_SetDefaultHandlerExpand(XML_Parser parser,
5845bb6a25fSPoul-Henning Kamp                             XML_DefaultHandler handler);
5855bb6a25fSPoul-Henning Kamp 
5865bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
5875bb6a25fSPoul-Henning Kamp XML_SetDoctypeDeclHandler(XML_Parser parser,
5885bb6a25fSPoul-Henning Kamp                           XML_StartDoctypeDeclHandler start,
5895bb6a25fSPoul-Henning Kamp                           XML_EndDoctypeDeclHandler end);
5905bb6a25fSPoul-Henning Kamp 
5915bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
5925bb6a25fSPoul-Henning Kamp XML_SetStartDoctypeDeclHandler(XML_Parser parser,
5935bb6a25fSPoul-Henning Kamp                                XML_StartDoctypeDeclHandler start);
5945bb6a25fSPoul-Henning Kamp 
5955bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
5965bb6a25fSPoul-Henning Kamp XML_SetEndDoctypeDeclHandler(XML_Parser parser,
5975bb6a25fSPoul-Henning Kamp                              XML_EndDoctypeDeclHandler end);
5985bb6a25fSPoul-Henning Kamp 
5995bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
6005bb6a25fSPoul-Henning Kamp XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
6015bb6a25fSPoul-Henning Kamp                                  XML_UnparsedEntityDeclHandler handler);
6025bb6a25fSPoul-Henning Kamp 
6035bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
6045bb6a25fSPoul-Henning Kamp XML_SetNotationDeclHandler(XML_Parser parser,
6055bb6a25fSPoul-Henning Kamp                            XML_NotationDeclHandler handler);
6065bb6a25fSPoul-Henning Kamp 
6075bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
6085bb6a25fSPoul-Henning Kamp XML_SetNamespaceDeclHandler(XML_Parser parser,
6095bb6a25fSPoul-Henning Kamp                             XML_StartNamespaceDeclHandler start,
6105bb6a25fSPoul-Henning Kamp                             XML_EndNamespaceDeclHandler end);
6115bb6a25fSPoul-Henning Kamp 
6125bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
6135bb6a25fSPoul-Henning Kamp XML_SetStartNamespaceDeclHandler(XML_Parser parser,
6145bb6a25fSPoul-Henning Kamp                                  XML_StartNamespaceDeclHandler start);
6155bb6a25fSPoul-Henning Kamp 
6165bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
6175bb6a25fSPoul-Henning Kamp XML_SetEndNamespaceDeclHandler(XML_Parser parser,
6185bb6a25fSPoul-Henning Kamp                                XML_EndNamespaceDeclHandler end);
6195bb6a25fSPoul-Henning Kamp 
6205bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
6215bb6a25fSPoul-Henning Kamp XML_SetNotStandaloneHandler(XML_Parser parser,
6225bb6a25fSPoul-Henning Kamp                             XML_NotStandaloneHandler handler);
6235bb6a25fSPoul-Henning Kamp 
6245bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
6255bb6a25fSPoul-Henning Kamp XML_SetExternalEntityRefHandler(XML_Parser parser,
6265bb6a25fSPoul-Henning Kamp                                 XML_ExternalEntityRefHandler handler);
6275bb6a25fSPoul-Henning Kamp 
6285bb6a25fSPoul-Henning Kamp /* If a non-NULL value for arg is specified here, then it will be
6295bb6a25fSPoul-Henning Kamp    passed as the first argument to the external entity ref handler
6305bb6a25fSPoul-Henning Kamp    instead of the parser object.
6315bb6a25fSPoul-Henning Kamp */
6325bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
633220ed979SColeman Kane XML_SetExternalEntityRefHandlerArg(XML_Parser parser,
634220ed979SColeman Kane                                    void *arg);
6355bb6a25fSPoul-Henning Kamp 
6365bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
6375bb6a25fSPoul-Henning Kamp XML_SetSkippedEntityHandler(XML_Parser parser,
6385bb6a25fSPoul-Henning Kamp                             XML_SkippedEntityHandler handler);
6395bb6a25fSPoul-Henning Kamp 
6405bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
6415bb6a25fSPoul-Henning Kamp XML_SetUnknownEncodingHandler(XML_Parser parser,
6425bb6a25fSPoul-Henning Kamp                               XML_UnknownEncodingHandler handler,
6435bb6a25fSPoul-Henning Kamp                               void *encodingHandlerData);
6445bb6a25fSPoul-Henning Kamp 
6455bb6a25fSPoul-Henning Kamp /* This can be called within a handler for a start element, end
6465bb6a25fSPoul-Henning Kamp    element, processing instruction or character data.  It causes the
6475bb6a25fSPoul-Henning Kamp    corresponding markup to be passed to the default handler.
6485bb6a25fSPoul-Henning Kamp */
6495bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
6505bb6a25fSPoul-Henning Kamp XML_DefaultCurrent(XML_Parser parser);
6515bb6a25fSPoul-Henning Kamp 
6525bb6a25fSPoul-Henning Kamp /* If do_nst is non-zero, and namespace processing is in effect, and
6535bb6a25fSPoul-Henning Kamp    a name has a prefix (i.e. an explicit namespace qualifier) then
6545bb6a25fSPoul-Henning Kamp    that name is returned as a triplet in a single string separated by
6555bb6a25fSPoul-Henning Kamp    the separator character specified when the parser was created: URI
6565bb6a25fSPoul-Henning Kamp    + sep + local_name + sep + prefix.
6575bb6a25fSPoul-Henning Kamp 
6585bb6a25fSPoul-Henning Kamp    If do_nst is zero, then namespace information is returned in the
6595bb6a25fSPoul-Henning Kamp    default manner (URI + sep + local_name) whether or not the name
6605bb6a25fSPoul-Henning Kamp    has a prefix.
6615bb6a25fSPoul-Henning Kamp 
6625bb6a25fSPoul-Henning Kamp    Note: Calling XML_SetReturnNSTriplet after XML_Parse or
6635bb6a25fSPoul-Henning Kamp      XML_ParseBuffer has no effect.
6645bb6a25fSPoul-Henning Kamp */
6655bb6a25fSPoul-Henning Kamp 
6665bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
6675bb6a25fSPoul-Henning Kamp XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
6685bb6a25fSPoul-Henning Kamp 
6695bb6a25fSPoul-Henning Kamp /* This value is passed as the userData argument to callbacks. */
6705bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
6715bb6a25fSPoul-Henning Kamp XML_SetUserData(XML_Parser parser, void *userData);
6725bb6a25fSPoul-Henning Kamp 
6735bb6a25fSPoul-Henning Kamp /* Returns the last value set by XML_SetUserData or NULL. */
6745bb6a25fSPoul-Henning Kamp #define XML_GetUserData(parser) (*(void **)(parser))
6755bb6a25fSPoul-Henning Kamp 
6765bb6a25fSPoul-Henning Kamp /* This is equivalent to supplying an encoding argument to
6775bb6a25fSPoul-Henning Kamp    XML_ParserCreate. On success XML_SetEncoding returns non-zero,
6785bb6a25fSPoul-Henning Kamp    zero otherwise.
6795bb6a25fSPoul-Henning Kamp    Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer
680220ed979SColeman Kane      has no effect and returns XML_STATUS_ERROR.
6815bb6a25fSPoul-Henning Kamp */
682220ed979SColeman Kane XMLPARSEAPI(enum XML_Status)
6835bb6a25fSPoul-Henning Kamp XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
6845bb6a25fSPoul-Henning Kamp 
6855bb6a25fSPoul-Henning Kamp /* If this function is called, then the parser will be passed as the
6865bb6a25fSPoul-Henning Kamp    first argument to callbacks instead of userData.  The userData will
6875bb6a25fSPoul-Henning Kamp    still be accessible using XML_GetUserData.
6885bb6a25fSPoul-Henning Kamp */
6895bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
6905bb6a25fSPoul-Henning Kamp XML_UseParserAsHandlerArg(XML_Parser parser);
6915bb6a25fSPoul-Henning Kamp 
6925bb6a25fSPoul-Henning Kamp /* If useDTD == XML_TRUE is passed to this function, then the parser
6935bb6a25fSPoul-Henning Kamp    will assume that there is an external subset, even if none is
6945bb6a25fSPoul-Henning Kamp    specified in the document. In such a case the parser will call the
6955bb6a25fSPoul-Henning Kamp    externalEntityRefHandler with a value of NULL for the systemId
6965bb6a25fSPoul-Henning Kamp    argument (the publicId and context arguments will be NULL as well).
697220ed979SColeman Kane    Note: For the purpose of checking WFC: Entity Declared, passing
698220ed979SColeman Kane      useDTD == XML_TRUE will make the parser behave as if the document
699220ed979SColeman Kane      had a DTD with an external subset.
7005bb6a25fSPoul-Henning Kamp    Note: If this function is called, then this must be done before
7015bb6a25fSPoul-Henning Kamp      the first call to XML_Parse or XML_ParseBuffer, since it will
7025bb6a25fSPoul-Henning Kamp      have no effect after that.  Returns
7035bb6a25fSPoul-Henning Kamp      XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING.
7045bb6a25fSPoul-Henning Kamp    Note: If the document does not have a DOCTYPE declaration at all,
7055bb6a25fSPoul-Henning Kamp      then startDoctypeDeclHandler and endDoctypeDeclHandler will not
7065bb6a25fSPoul-Henning Kamp      be called, despite an external subset being parsed.
7075bb6a25fSPoul-Henning Kamp    Note: If XML_DTD is not defined when Expat is compiled, returns
7085bb6a25fSPoul-Henning Kamp      XML_ERROR_FEATURE_REQUIRES_XML_DTD.
7095bb6a25fSPoul-Henning Kamp */
7105bb6a25fSPoul-Henning Kamp XMLPARSEAPI(enum XML_Error)
7115bb6a25fSPoul-Henning Kamp XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
7125bb6a25fSPoul-Henning Kamp 
7135bb6a25fSPoul-Henning Kamp 
7145bb6a25fSPoul-Henning Kamp /* Sets the base to be used for resolving relative URIs in system
7155bb6a25fSPoul-Henning Kamp    identifiers in declarations.  Resolving relative identifiers is
7165bb6a25fSPoul-Henning Kamp    left to the application: this value will be passed through as the
7175bb6a25fSPoul-Henning Kamp    base argument to the XML_ExternalEntityRefHandler,
7185bb6a25fSPoul-Henning Kamp    XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base
719220ed979SColeman Kane    argument will be copied.  Returns XML_STATUS_ERROR if out of memory,
720220ed979SColeman Kane    XML_STATUS_OK otherwise.
7215bb6a25fSPoul-Henning Kamp */
722220ed979SColeman Kane XMLPARSEAPI(enum XML_Status)
7235bb6a25fSPoul-Henning Kamp XML_SetBase(XML_Parser parser, const XML_Char *base);
7245bb6a25fSPoul-Henning Kamp 
7255bb6a25fSPoul-Henning Kamp XMLPARSEAPI(const XML_Char *)
7265bb6a25fSPoul-Henning Kamp XML_GetBase(XML_Parser parser);
7275bb6a25fSPoul-Henning Kamp 
7285bb6a25fSPoul-Henning Kamp /* Returns the number of the attribute/value pairs passed in last call
7295bb6a25fSPoul-Henning Kamp    to the XML_StartElementHandler that were specified in the start-tag
7305bb6a25fSPoul-Henning Kamp    rather than defaulted. Each attribute/value pair counts as 2; thus
7315bb6a25fSPoul-Henning Kamp    this correspondds to an index into the atts array passed to the
7325bb6a25fSPoul-Henning Kamp    XML_StartElementHandler.
7335bb6a25fSPoul-Henning Kamp */
7345bb6a25fSPoul-Henning Kamp XMLPARSEAPI(int)
7355bb6a25fSPoul-Henning Kamp XML_GetSpecifiedAttributeCount(XML_Parser parser);
7365bb6a25fSPoul-Henning Kamp 
7375bb6a25fSPoul-Henning Kamp /* Returns the index of the ID attribute passed in the last call to
7385bb6a25fSPoul-Henning Kamp    XML_StartElementHandler, or -1 if there is no ID attribute.  Each
7395bb6a25fSPoul-Henning Kamp    attribute/value pair counts as 2; thus this correspondds to an
7405bb6a25fSPoul-Henning Kamp    index into the atts array passed to the XML_StartElementHandler.
7415bb6a25fSPoul-Henning Kamp */
7425bb6a25fSPoul-Henning Kamp XMLPARSEAPI(int)
7435bb6a25fSPoul-Henning Kamp XML_GetIdAttributeIndex(XML_Parser parser);
7445bb6a25fSPoul-Henning Kamp 
745e3466a89SXin LI #ifdef XML_ATTR_INFO
746e3466a89SXin LI /* Source file byte offsets for the start and end of attribute names and values.
747e3466a89SXin LI    The value indices are exclusive of surrounding quotes; thus in a UTF-8 source
748e3466a89SXin LI    file an attribute value of "blah" will yield:
749e3466a89SXin LI    info->valueEnd - info->valueStart = 4 bytes.
750e3466a89SXin LI */
751e3466a89SXin LI typedef struct {
752e3466a89SXin LI   XML_Index  nameStart;  /* Offset to beginning of the attribute name. */
753e3466a89SXin LI   XML_Index  nameEnd;    /* Offset after the attribute name's last byte. */
754e3466a89SXin LI   XML_Index  valueStart; /* Offset to beginning of the attribute value. */
755e3466a89SXin LI   XML_Index  valueEnd;   /* Offset after the attribute value's last byte. */
756e3466a89SXin LI } XML_AttrInfo;
757e3466a89SXin LI 
758e3466a89SXin LI /* Returns an array of XML_AttrInfo structures for the attribute/value pairs
759e3466a89SXin LI    passed in last call to the XML_StartElementHandler that were specified
760e3466a89SXin LI    in the start-tag rather than defaulted. Each attribute/value pair counts
761e3466a89SXin LI    as 1; thus the number of entries in the array is
762e3466a89SXin LI    XML_GetSpecifiedAttributeCount(parser) / 2.
763e3466a89SXin LI */
764e3466a89SXin LI XMLPARSEAPI(const XML_AttrInfo *)
765e3466a89SXin LI XML_GetAttributeInfo(XML_Parser parser);
766e3466a89SXin LI #endif
767e3466a89SXin LI 
7685bb6a25fSPoul-Henning Kamp /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
7695bb6a25fSPoul-Henning Kamp    detected.  The last call to XML_Parse must have isFinal true; len
7705bb6a25fSPoul-Henning Kamp    may be zero for this call (or any other).
7715bb6a25fSPoul-Henning Kamp 
772220ed979SColeman Kane    Though the return values for these functions has always been
773220ed979SColeman Kane    described as a Boolean value, the implementation, at least for the
774220ed979SColeman Kane    1.95.x series, has always returned exactly one of the XML_Status
775220ed979SColeman Kane    values.
7765bb6a25fSPoul-Henning Kamp */
7775bb6a25fSPoul-Henning Kamp XMLPARSEAPI(enum XML_Status)
7785bb6a25fSPoul-Henning Kamp XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
7795bb6a25fSPoul-Henning Kamp 
7805bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void *)
7815bb6a25fSPoul-Henning Kamp XML_GetBuffer(XML_Parser parser, int len);
7825bb6a25fSPoul-Henning Kamp 
7835bb6a25fSPoul-Henning Kamp XMLPARSEAPI(enum XML_Status)
7845bb6a25fSPoul-Henning Kamp XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
7855bb6a25fSPoul-Henning Kamp 
786220ed979SColeman Kane /* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return.
787220ed979SColeman Kane    Must be called from within a call-back handler, except when aborting
788220ed979SColeman Kane    (resumable = 0) an already suspended parser. Some call-backs may
789220ed979SColeman Kane    still follow because they would otherwise get lost. Examples:
790220ed979SColeman Kane    - endElementHandler() for empty elements when stopped in
791220ed979SColeman Kane      startElementHandler(),
792220ed979SColeman Kane    - endNameSpaceDeclHandler() when stopped in endElementHandler(),
793220ed979SColeman Kane    and possibly others.
794220ed979SColeman Kane 
795220ed979SColeman Kane    Can be called from most handlers, including DTD related call-backs,
796220ed979SColeman Kane    except when parsing an external parameter entity and resumable != 0.
797220ed979SColeman Kane    Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise.
798220ed979SColeman Kane    Possible error codes:
799220ed979SColeman Kane    - XML_ERROR_SUSPENDED: when suspending an already suspended parser.
800220ed979SColeman Kane    - XML_ERROR_FINISHED: when the parser has already finished.
801220ed979SColeman Kane    - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE.
802220ed979SColeman Kane 
803220ed979SColeman Kane    When resumable != 0 (true) then parsing is suspended, that is,
804220ed979SColeman Kane    XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED.
805220ed979SColeman Kane    Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer()
806220ed979SColeman Kane    return XML_STATUS_ERROR with error code XML_ERROR_ABORTED.
807220ed979SColeman Kane 
808220ed979SColeman Kane    *Note*:
809220ed979SColeman Kane    This will be applied to the current parser instance only, that is, if
810220ed979SColeman Kane    there is a parent parser then it will continue parsing when the
811220ed979SColeman Kane    externalEntityRefHandler() returns. It is up to the implementation of
812220ed979SColeman Kane    the externalEntityRefHandler() to call XML_StopParser() on the parent
813220ed979SColeman Kane    parser (recursively), if one wants to stop parsing altogether.
814220ed979SColeman Kane 
815220ed979SColeman Kane    When suspended, parsing can be resumed by calling XML_ResumeParser().
816220ed979SColeman Kane */
817220ed979SColeman Kane XMLPARSEAPI(enum XML_Status)
818220ed979SColeman Kane XML_StopParser(XML_Parser parser, XML_Bool resumable);
819220ed979SColeman Kane 
820220ed979SColeman Kane /* Resumes parsing after it has been suspended with XML_StopParser().
821220ed979SColeman Kane    Must not be called from within a handler call-back. Returns same
822220ed979SColeman Kane    status codes as XML_Parse() or XML_ParseBuffer().
823220ed979SColeman Kane    Additional error code XML_ERROR_NOT_SUSPENDED possible.
824220ed979SColeman Kane 
825220ed979SColeman Kane    *Note*:
826220ed979SColeman Kane    This must be called on the most deeply nested child parser instance
827220ed979SColeman Kane    first, and on its parent parser only after the child parser has finished,
828220ed979SColeman Kane    to be applied recursively until the document entity's parser is restarted.
829220ed979SColeman Kane    That is, the parent parser will not resume by itself and it is up to the
830220ed979SColeman Kane    application to call XML_ResumeParser() on it at the appropriate moment.
831220ed979SColeman Kane */
832220ed979SColeman Kane XMLPARSEAPI(enum XML_Status)
833220ed979SColeman Kane XML_ResumeParser(XML_Parser parser);
834220ed979SColeman Kane 
835220ed979SColeman Kane enum XML_Parsing {
836220ed979SColeman Kane   XML_INITIALIZED,
837220ed979SColeman Kane   XML_PARSING,
838220ed979SColeman Kane   XML_FINISHED,
839220ed979SColeman Kane   XML_SUSPENDED
840220ed979SColeman Kane };
841220ed979SColeman Kane 
842220ed979SColeman Kane typedef struct {
843220ed979SColeman Kane   enum XML_Parsing parsing;
844220ed979SColeman Kane   XML_Bool finalBuffer;
845220ed979SColeman Kane } XML_ParsingStatus;
846220ed979SColeman Kane 
847220ed979SColeman Kane /* Returns status of parser with respect to being initialized, parsing,
848220ed979SColeman Kane    finished, or suspended and processing the final buffer.
849220ed979SColeman Kane    XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus,
850220ed979SColeman Kane    XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED
851220ed979SColeman Kane */
852220ed979SColeman Kane XMLPARSEAPI(void)
853220ed979SColeman Kane XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status);
854220ed979SColeman Kane 
8555bb6a25fSPoul-Henning Kamp /* Creates an XML_Parser object that can parse an external general
8565bb6a25fSPoul-Henning Kamp    entity; context is a '\0'-terminated string specifying the parse
8575bb6a25fSPoul-Henning Kamp    context; encoding is a '\0'-terminated string giving the name of
8585bb6a25fSPoul-Henning Kamp    the externally specified encoding, or NULL if there is no
8595bb6a25fSPoul-Henning Kamp    externally specified encoding.  The context string consists of a
8605bb6a25fSPoul-Henning Kamp    sequence of tokens separated by formfeeds (\f); a token consisting
8615bb6a25fSPoul-Henning Kamp    of a name specifies that the general entity of the name is open; a
8625bb6a25fSPoul-Henning Kamp    token of the form prefix=uri specifies the namespace for a
8635bb6a25fSPoul-Henning Kamp    particular prefix; a token of the form =uri specifies the default
8645bb6a25fSPoul-Henning Kamp    namespace.  This can be called at any point after the first call to
8655bb6a25fSPoul-Henning Kamp    an ExternalEntityRefHandler so longer as the parser has not yet
8665bb6a25fSPoul-Henning Kamp    been freed.  The new parser is completely independent and may
8675bb6a25fSPoul-Henning Kamp    safely be used in a separate thread.  The handlers and userData are
868220ed979SColeman Kane    initialized from the parser argument.  Returns NULL if out of memory.
8695bb6a25fSPoul-Henning Kamp    Otherwise returns a new XML_Parser object.
8705bb6a25fSPoul-Henning Kamp */
8715bb6a25fSPoul-Henning Kamp XMLPARSEAPI(XML_Parser)
8725bb6a25fSPoul-Henning Kamp XML_ExternalEntityParserCreate(XML_Parser parser,
8735bb6a25fSPoul-Henning Kamp                                const XML_Char *context,
8745bb6a25fSPoul-Henning Kamp                                const XML_Char *encoding);
8755bb6a25fSPoul-Henning Kamp 
8765bb6a25fSPoul-Henning Kamp enum XML_ParamEntityParsing {
8775bb6a25fSPoul-Henning Kamp   XML_PARAM_ENTITY_PARSING_NEVER,
8785bb6a25fSPoul-Henning Kamp   XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
8795bb6a25fSPoul-Henning Kamp   XML_PARAM_ENTITY_PARSING_ALWAYS
8805bb6a25fSPoul-Henning Kamp };
8815bb6a25fSPoul-Henning Kamp 
8825bb6a25fSPoul-Henning Kamp /* Controls parsing of parameter entities (including the external DTD
8835bb6a25fSPoul-Henning Kamp    subset). If parsing of parameter entities is enabled, then
8845bb6a25fSPoul-Henning Kamp    references to external parameter entities (including the external
8855bb6a25fSPoul-Henning Kamp    DTD subset) will be passed to the handler set with
8865bb6a25fSPoul-Henning Kamp    XML_SetExternalEntityRefHandler.  The context passed will be 0.
8875bb6a25fSPoul-Henning Kamp 
8885bb6a25fSPoul-Henning Kamp    Unlike external general entities, external parameter entities can
8895bb6a25fSPoul-Henning Kamp    only be parsed synchronously.  If the external parameter entity is
8905bb6a25fSPoul-Henning Kamp    to be parsed, it must be parsed during the call to the external
8915bb6a25fSPoul-Henning Kamp    entity ref handler: the complete sequence of
8925bb6a25fSPoul-Henning Kamp    XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
8935bb6a25fSPoul-Henning Kamp    XML_ParserFree calls must be made during this call.  After
8945bb6a25fSPoul-Henning Kamp    XML_ExternalEntityParserCreate has been called to create the parser
8955bb6a25fSPoul-Henning Kamp    for the external parameter entity (context must be 0 for this
8965bb6a25fSPoul-Henning Kamp    call), it is illegal to make any calls on the old parser until
8975bb6a25fSPoul-Henning Kamp    XML_ParserFree has been called on the newly created parser.
8985bb6a25fSPoul-Henning Kamp    If the library has been compiled without support for parameter
8995bb6a25fSPoul-Henning Kamp    entity parsing (ie without XML_DTD being defined), then
9005bb6a25fSPoul-Henning Kamp    XML_SetParamEntityParsing will return 0 if parsing of parameter
9015bb6a25fSPoul-Henning Kamp    entities is requested; otherwise it will return non-zero.
9025bb6a25fSPoul-Henning Kamp    Note: If XML_SetParamEntityParsing is called after XML_Parse or
9035bb6a25fSPoul-Henning Kamp       XML_ParseBuffer, then it has no effect and will always return 0.
9045bb6a25fSPoul-Henning Kamp */
9055bb6a25fSPoul-Henning Kamp XMLPARSEAPI(int)
9065bb6a25fSPoul-Henning Kamp XML_SetParamEntityParsing(XML_Parser parser,
9075bb6a25fSPoul-Henning Kamp                           enum XML_ParamEntityParsing parsing);
9085bb6a25fSPoul-Henning Kamp 
909e3466a89SXin LI /* Sets the hash salt to use for internal hash calculations.
910e3466a89SXin LI    Helps in preventing DoS attacks based on predicting hash
911e3466a89SXin LI    function behavior. This must be called before parsing is started.
912e3466a89SXin LI    Returns 1 if successful, 0 when called after parsing has started.
913e3466a89SXin LI */
914e3466a89SXin LI XMLPARSEAPI(int)
915e3466a89SXin LI XML_SetHashSalt(XML_Parser parser,
916e3466a89SXin LI                 unsigned long hash_salt);
917e3466a89SXin LI 
918220ed979SColeman Kane /* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
9195bb6a25fSPoul-Henning Kamp    XML_GetErrorCode returns information about the error.
9205bb6a25fSPoul-Henning Kamp */
9215bb6a25fSPoul-Henning Kamp XMLPARSEAPI(enum XML_Error)
9225bb6a25fSPoul-Henning Kamp XML_GetErrorCode(XML_Parser parser);
9235bb6a25fSPoul-Henning Kamp 
9245bb6a25fSPoul-Henning Kamp /* These functions return information about the current parse
925220ed979SColeman Kane    location.  They may be called from any callback called to report
926220ed979SColeman Kane    some parse event; in this case the location is the location of the
927220ed979SColeman Kane    first of the sequence of characters that generated the event.  When
928220ed979SColeman Kane    called from callbacks generated by declarations in the document
929220ed979SColeman Kane    prologue, the location identified isn't as neatly defined, but will
930220ed979SColeman Kane    be within the relevant markup.  When called outside of the callback
931220ed979SColeman Kane    functions, the position indicated will be just past the last parse
932220ed979SColeman Kane    event (regardless of whether there was an associated callback).
9335bb6a25fSPoul-Henning Kamp 
934220ed979SColeman Kane    They may also be called after returning from a call to XML_Parse
935220ed979SColeman Kane    or XML_ParseBuffer.  If the return value is XML_STATUS_ERROR then
936220ed979SColeman Kane    the location is the location of the character at which the error
937220ed979SColeman Kane    was detected; otherwise the location is the location of the last
938220ed979SColeman Kane    parse event, as described above.
9395bb6a25fSPoul-Henning Kamp */
940220ed979SColeman Kane XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser);
941220ed979SColeman Kane XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser);
942220ed979SColeman Kane XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser);
9435bb6a25fSPoul-Henning Kamp 
9445bb6a25fSPoul-Henning Kamp /* Return the number of bytes in the current event.
9455bb6a25fSPoul-Henning Kamp    Returns 0 if the event is in an internal entity.
9465bb6a25fSPoul-Henning Kamp */
9475bb6a25fSPoul-Henning Kamp XMLPARSEAPI(int)
9485bb6a25fSPoul-Henning Kamp XML_GetCurrentByteCount(XML_Parser parser);
9495bb6a25fSPoul-Henning Kamp 
9505bb6a25fSPoul-Henning Kamp /* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
9515bb6a25fSPoul-Henning Kamp    the integer pointed to by offset to the offset within this buffer
9525bb6a25fSPoul-Henning Kamp    of the current parse position, and sets the integer pointed to by size
9535bb6a25fSPoul-Henning Kamp    to the size of this buffer (the number of input bytes). Otherwise
9545bb6a25fSPoul-Henning Kamp    returns a NULL pointer. Also returns a NULL pointer if a parse isn't
9555bb6a25fSPoul-Henning Kamp    active.
9565bb6a25fSPoul-Henning Kamp 
9575bb6a25fSPoul-Henning Kamp    NOTE: The character pointer returned should not be used outside
9585bb6a25fSPoul-Henning Kamp    the handler that makes the call.
9595bb6a25fSPoul-Henning Kamp */
9605bb6a25fSPoul-Henning Kamp XMLPARSEAPI(const char *)
9615bb6a25fSPoul-Henning Kamp XML_GetInputContext(XML_Parser parser,
9625bb6a25fSPoul-Henning Kamp                     int *offset,
9635bb6a25fSPoul-Henning Kamp                     int *size);
9645bb6a25fSPoul-Henning Kamp 
9655bb6a25fSPoul-Henning Kamp /* For backwards compatibility with previous versions. */
9665bb6a25fSPoul-Henning Kamp #define XML_GetErrorLineNumber   XML_GetCurrentLineNumber
9675bb6a25fSPoul-Henning Kamp #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
9685bb6a25fSPoul-Henning Kamp #define XML_GetErrorByteIndex    XML_GetCurrentByteIndex
9695bb6a25fSPoul-Henning Kamp 
970220ed979SColeman Kane /* Frees the content model passed to the element declaration handler */
971220ed979SColeman Kane XMLPARSEAPI(void)
972220ed979SColeman Kane XML_FreeContentModel(XML_Parser parser, XML_Content *model);
973220ed979SColeman Kane 
974220ed979SColeman Kane /* Exposing the memory handling functions used in Expat */
975220ed979SColeman Kane XMLPARSEAPI(void *)
976*be8aff81SXin LI XML_ATTR_MALLOC
977*be8aff81SXin LI XML_ATTR_ALLOC_SIZE(2)
978220ed979SColeman Kane XML_MemMalloc(XML_Parser parser, size_t size);
979220ed979SColeman Kane 
980220ed979SColeman Kane XMLPARSEAPI(void *)
981*be8aff81SXin LI XML_ATTR_ALLOC_SIZE(3)
982220ed979SColeman Kane XML_MemRealloc(XML_Parser parser, void *ptr, size_t size);
983220ed979SColeman Kane 
984220ed979SColeman Kane XMLPARSEAPI(void)
985220ed979SColeman Kane XML_MemFree(XML_Parser parser, void *ptr);
986220ed979SColeman Kane 
9875bb6a25fSPoul-Henning Kamp /* Frees memory used by the parser. */
9885bb6a25fSPoul-Henning Kamp XMLPARSEAPI(void)
9895bb6a25fSPoul-Henning Kamp XML_ParserFree(XML_Parser parser);
9905bb6a25fSPoul-Henning Kamp 
9915bb6a25fSPoul-Henning Kamp /* Returns a string describing the error. */
9925bb6a25fSPoul-Henning Kamp XMLPARSEAPI(const XML_LChar *)
9935bb6a25fSPoul-Henning Kamp XML_ErrorString(enum XML_Error code);
9945bb6a25fSPoul-Henning Kamp 
9955bb6a25fSPoul-Henning Kamp /* Return a string containing the version number of this expat */
9965bb6a25fSPoul-Henning Kamp XMLPARSEAPI(const XML_LChar *)
9975bb6a25fSPoul-Henning Kamp XML_ExpatVersion(void);
9985bb6a25fSPoul-Henning Kamp 
9995bb6a25fSPoul-Henning Kamp typedef struct {
10005bb6a25fSPoul-Henning Kamp   int major;
10015bb6a25fSPoul-Henning Kamp   int minor;
10025bb6a25fSPoul-Henning Kamp   int micro;
10035bb6a25fSPoul-Henning Kamp } XML_Expat_Version;
10045bb6a25fSPoul-Henning Kamp 
10055bb6a25fSPoul-Henning Kamp /* Return an XML_Expat_Version structure containing numeric version
10065bb6a25fSPoul-Henning Kamp    number information for this version of expat.
10075bb6a25fSPoul-Henning Kamp */
10085bb6a25fSPoul-Henning Kamp XMLPARSEAPI(XML_Expat_Version)
10095bb6a25fSPoul-Henning Kamp XML_ExpatVersionInfo(void);
10105bb6a25fSPoul-Henning Kamp 
10115bb6a25fSPoul-Henning Kamp /* Added in Expat 1.95.5. */
10125bb6a25fSPoul-Henning Kamp enum XML_FeatureEnum {
10135bb6a25fSPoul-Henning Kamp   XML_FEATURE_END = 0,
10145bb6a25fSPoul-Henning Kamp   XML_FEATURE_UNICODE,
10155bb6a25fSPoul-Henning Kamp   XML_FEATURE_UNICODE_WCHAR_T,
10165bb6a25fSPoul-Henning Kamp   XML_FEATURE_DTD,
10175bb6a25fSPoul-Henning Kamp   XML_FEATURE_CONTEXT_BYTES,
10185bb6a25fSPoul-Henning Kamp   XML_FEATURE_MIN_SIZE,
10195bb6a25fSPoul-Henning Kamp   XML_FEATURE_SIZEOF_XML_CHAR,
1020220ed979SColeman Kane   XML_FEATURE_SIZEOF_XML_LCHAR,
1021220ed979SColeman Kane   XML_FEATURE_NS,
1022e3466a89SXin LI   XML_FEATURE_LARGE_SIZE,
1023e3466a89SXin LI   XML_FEATURE_ATTR_INFO
10245bb6a25fSPoul-Henning Kamp   /* Additional features must be added to the end of this enum. */
10255bb6a25fSPoul-Henning Kamp };
10265bb6a25fSPoul-Henning Kamp 
10275bb6a25fSPoul-Henning Kamp typedef struct {
10285bb6a25fSPoul-Henning Kamp   enum XML_FeatureEnum  feature;
1029220ed979SColeman Kane   const XML_LChar       *name;
10305bb6a25fSPoul-Henning Kamp   long int              value;
10315bb6a25fSPoul-Henning Kamp } XML_Feature;
10325bb6a25fSPoul-Henning Kamp 
10335bb6a25fSPoul-Henning Kamp XMLPARSEAPI(const XML_Feature *)
10345bb6a25fSPoul-Henning Kamp XML_GetFeatureList(void);
10355bb6a25fSPoul-Henning Kamp 
10365bb6a25fSPoul-Henning Kamp 
1037*be8aff81SXin LI /* Expat follows the semantic versioning convention.
1038*be8aff81SXin LI    See http://semver.org.
10395bb6a25fSPoul-Henning Kamp */
1040220ed979SColeman Kane #define XML_MAJOR_VERSION 2
1041*be8aff81SXin LI #define XML_MINOR_VERSION 2
1042e3466a89SXin LI #define XML_MICRO_VERSION 0
10435bb6a25fSPoul-Henning Kamp 
10445bb6a25fSPoul-Henning Kamp #ifdef __cplusplus
10455bb6a25fSPoul-Henning Kamp }
10465bb6a25fSPoul-Henning Kamp #endif
10475bb6a25fSPoul-Henning Kamp 
1048220ed979SColeman Kane #endif /* not Expat_INCLUDED */
1049