expat.h revision 303975
198524Sfenner/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd 298524Sfenner See the file COPYING for copying permission. 398524Sfenner*/ 498524Sfenner 598524Sfenner#ifndef Expat_INCLUDED 698524Sfenner#define Expat_INCLUDED 1 798524Sfenner 898524Sfenner#ifdef __VMS 998524Sfenner/* 0 1 2 3 0 1 2 3 1098524Sfenner 1234567890123456789012345678901 1234567890123456789012345678901 */ 1198524Sfenner#define XML_SetProcessingInstructionHandler XML_SetProcessingInstrHandler 1298524Sfenner#define XML_SetUnparsedEntityDeclHandler XML_SetUnparsedEntDeclHandler 1398524Sfenner#define XML_SetStartNamespaceDeclHandler XML_SetStartNamespcDeclHandler 1498524Sfenner#define XML_SetExternalEntityRefHandlerArg XML_SetExternalEntRefHandlerArg 1598524Sfenner#endif 1698524Sfenner 1798524Sfenner#include <stdlib.h> 1898524Sfenner#include "expat_external.h" 1998524Sfenner 2098524Sfenner#ifdef __cplusplus 2198524Sfennerextern "C" { 2298524Sfenner#endif 2398524Sfenner 2498524Sfennerstruct XML_ParserStruct; 2598524Sfennertypedef struct XML_ParserStruct *XML_Parser; 2698524Sfenner 2798524Sfenner/* Should this be defined using stdbool.h when C99 is available? */ 2898524Sfennertypedef unsigned char XML_Bool; 2998524Sfenner#define XML_TRUE ((XML_Bool) 1) 30276788Sdelphij#define XML_FALSE ((XML_Bool) 0) 3198524Sfenner 3298524Sfenner/* The XML_Status enum gives the possible return values for several 3398524Sfenner API functions. The preprocessor #defines are included so this 3498524Sfenner stanza can be added to code that still needs to support older 35127668Sbms versions of Expat 1.95.x: 3698524Sfenner 3798524Sfenner #ifndef XML_STATUS_OK 3898524Sfenner #define XML_STATUS_OK 1 3998524Sfenner #define XML_STATUS_ERROR 0 4098524Sfenner #endif 4198524Sfenner 4298524Sfenner Otherwise, the #define hackery is quite ugly and would have been 4398524Sfenner dropped. 4498524Sfenner*/ 4598524Sfennerenum XML_Status { 4698524Sfenner XML_STATUS_ERROR = 0, 47276788Sdelphij#define XML_STATUS_ERROR XML_STATUS_ERROR 48276788Sdelphij XML_STATUS_OK = 1, 49276788Sdelphij#define XML_STATUS_OK XML_STATUS_OK 5098524Sfenner XML_STATUS_SUSPENDED = 2 5198524Sfenner#define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED 5298524Sfenner}; 5398524Sfenner 5498524Sfennerenum XML_Error { 5598524Sfenner XML_ERROR_NONE, 5698524Sfenner XML_ERROR_NO_MEMORY, 5798524Sfenner XML_ERROR_SYNTAX, 5898524Sfenner XML_ERROR_NO_ELEMENTS, 5998524Sfenner XML_ERROR_INVALID_TOKEN, 6098524Sfenner XML_ERROR_UNCLOSED_TOKEN, 6198524Sfenner XML_ERROR_PARTIAL_CHAR, 6298524Sfenner XML_ERROR_TAG_MISMATCH, 6398524Sfenner XML_ERROR_DUPLICATE_ATTRIBUTE, 6498524Sfenner XML_ERROR_JUNK_AFTER_DOC_ELEMENT, 6598524Sfenner XML_ERROR_PARAM_ENTITY_REF, 6698524Sfenner XML_ERROR_UNDEFINED_ENTITY, 6798524Sfenner XML_ERROR_RECURSIVE_ENTITY_REF, 6898524Sfenner XML_ERROR_ASYNC_ENTITY, 6998524Sfenner XML_ERROR_BAD_CHAR_REF, 7098524Sfenner XML_ERROR_BINARY_ENTITY_REF, 7198524Sfenner XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, 7298524Sfenner XML_ERROR_MISPLACED_XML_PI, 7398524Sfenner XML_ERROR_UNKNOWN_ENCODING, 7498524Sfenner XML_ERROR_INCORRECT_ENCODING, 7598524Sfenner XML_ERROR_UNCLOSED_CDATA_SECTION, 7698524Sfenner XML_ERROR_EXTERNAL_ENTITY_HANDLING, 7798524Sfenner XML_ERROR_NOT_STANDALONE, 7898524Sfenner XML_ERROR_UNEXPECTED_STATE, 7998524Sfenner XML_ERROR_ENTITY_DECLARED_IN_PE, 8098524Sfenner XML_ERROR_FEATURE_REQUIRES_XML_DTD, 8198524Sfenner XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING, 8298524Sfenner /* Added in 1.95.7. */ 8398524Sfenner XML_ERROR_UNBOUND_PREFIX, 8498524Sfenner /* Added in 1.95.8. */ 8598524Sfenner XML_ERROR_UNDECLARING_PREFIX, 8698524Sfenner XML_ERROR_INCOMPLETE_PE, 8798524Sfenner XML_ERROR_XML_DECL, 8898524Sfenner XML_ERROR_TEXT_DECL, 8998524Sfenner XML_ERROR_PUBLICID, 9098524Sfenner XML_ERROR_SUSPENDED, 9198524Sfenner XML_ERROR_NOT_SUSPENDED, 9298524Sfenner XML_ERROR_ABORTED, 9398524Sfenner XML_ERROR_FINISHED, 9498524Sfenner XML_ERROR_SUSPEND_PE, 9598524Sfenner /* Added in 2.0. */ 9698524Sfenner XML_ERROR_RESERVED_PREFIX_XML, 9798524Sfenner XML_ERROR_RESERVED_PREFIX_XMLNS, 9898524Sfenner XML_ERROR_RESERVED_NAMESPACE_URI 9998524Sfenner}; 10098524Sfenner 10198524Sfennerenum XML_Content_Type { 10298524Sfenner XML_CTYPE_EMPTY = 1, 10398524Sfenner XML_CTYPE_ANY, 10498524Sfenner XML_CTYPE_MIXED, 10598524Sfenner XML_CTYPE_NAME, 10698524Sfenner XML_CTYPE_CHOICE, 10798524Sfenner XML_CTYPE_SEQ 10898524Sfenner}; 10998524Sfenner 11098524Sfennerenum XML_Content_Quant { 11198524Sfenner XML_CQUANT_NONE, 11298524Sfenner XML_CQUANT_OPT, 11398524Sfenner XML_CQUANT_REP, 11498524Sfenner XML_CQUANT_PLUS 11598524Sfenner}; 11698524Sfenner 11798524Sfenner/* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be 11898524Sfenner XML_CQUANT_NONE, and the other fields will be zero or NULL. 11998524Sfenner If type == XML_CTYPE_MIXED, then quant will be NONE or REP and 12098524Sfenner numchildren will contain number of elements that may be mixed in 12198524Sfenner and children point to an array of XML_Content cells that will be 12298524Sfenner all of XML_CTYPE_NAME type with no quantification. 12398524Sfenner 12498524Sfenner If type == XML_CTYPE_NAME, then the name points to the name, and 12598524Sfenner the numchildren field will be zero and children will be NULL. The 12698524Sfenner quant fields indicates any quantifiers placed on the name. 12798524Sfenner 12898524Sfenner CHOICE and SEQ will have name NULL, the number of children in 12998524Sfenner numchildren and children will point, recursively, to an array 13098524Sfenner of XML_Content cells. 13198524Sfenner 13298524Sfenner The EMPTY, ANY, and MIXED types will only occur at top level. 13398524Sfenner*/ 13498524Sfenner 13598524Sfennertypedef struct XML_cp XML_Content; 13698524Sfenner 13798524Sfennerstruct XML_cp { 13898524Sfenner enum XML_Content_Type type; 13998524Sfenner enum XML_Content_Quant quant; 14098524Sfenner XML_Char * name; 14198524Sfenner unsigned int numchildren; 14298524Sfenner XML_Content * children; 14398524Sfenner}; 14498524Sfenner 14598524Sfenner 14698524Sfenner/* This is called for an element declaration. See above for 14798524Sfenner description of the model argument. It's the caller's responsibility 14898524Sfenner to free model when finished with it. 14998524Sfenner*/ 15098524Sfennertypedef void (XMLCALL *XML_ElementDeclHandler) (void *userData, 15198524Sfenner const XML_Char *name, 15298524Sfenner XML_Content *model); 15398524Sfenner 15498524SfennerXMLPARSEAPI(void) 15598524SfennerXML_SetElementDeclHandler(XML_Parser parser, 15698524Sfenner XML_ElementDeclHandler eldecl); 15798524Sfenner 15898524Sfenner/* The Attlist declaration handler is called for *each* attribute. So 15998524Sfenner a single Attlist declaration with multiple attributes declared will 16098524Sfenner generate multiple calls to this handler. The "default" parameter 16198524Sfenner may be NULL in the case of the "#IMPLIED" or "#REQUIRED" 16298524Sfenner keyword. The "isrequired" parameter will be true and the default 16398524Sfenner value will be NULL in the case of "#REQUIRED". If "isrequired" is 16498524Sfenner true and default is non-NULL, then this is a "#FIXED" default. 16598524Sfenner*/ 16698524Sfennertypedef void (XMLCALL *XML_AttlistDeclHandler) ( 16798524Sfenner void *userData, 16898524Sfenner const XML_Char *elname, 16998524Sfenner const XML_Char *attname, 17098524Sfenner const XML_Char *att_type, 17198524Sfenner const XML_Char *dflt, 17298524Sfenner int isrequired); 17398524Sfenner 174276788SdelphijXMLPARSEAPI(void) 17598524SfennerXML_SetAttlistDeclHandler(XML_Parser parser, 17698524Sfenner XML_AttlistDeclHandler attdecl); 17798524Sfenner 17898524Sfenner/* The XML declaration handler is called for *both* XML declarations 17998524Sfenner and text declarations. The way to distinguish is that the version 18098524Sfenner parameter will be NULL for text declarations. The encoding 18198524Sfenner parameter may be NULL for XML declarations. The standalone 18298524Sfenner parameter will be -1, 0, or 1 indicating respectively that there 183276788Sdelphij was no standalone parameter in the declaration, that it was given 184276788Sdelphij as no, or that it was given as yes. 18598524Sfenner*/ 18698524Sfennertypedef void (XMLCALL *XML_XmlDeclHandler) (void *userData, 187276788Sdelphij const XML_Char *version, 188276788Sdelphij const XML_Char *encoding, 18998524Sfenner int standalone); 19098524Sfenner 191127668SbmsXMLPARSEAPI(void) 19298524SfennerXML_SetXmlDeclHandler(XML_Parser parser, 19398524Sfenner XML_XmlDeclHandler xmldecl); 19498524Sfenner 195276788Sdelphij 19698524Sfennertypedef struct { 19798524Sfenner void *(*malloc_fcn)(size_t size); 198276788Sdelphij void *(*realloc_fcn)(void *ptr, size_t size); 19998524Sfenner void (*free_fcn)(void *ptr); 200276788Sdelphij} XML_Memory_Handling_Suite; 20198524Sfenner 20298524Sfenner/* Constructs a new parser; encoding is the encoding specified by the 20398524Sfenner external protocol or NULL if there is none specified. 20498524Sfenner*/ 20598524SfennerXMLPARSEAPI(XML_Parser) 20698524SfennerXML_ParserCreate(const XML_Char *encoding); 20798524Sfenner 20898524Sfenner/* Constructs a new parser and namespace processor. Element type 20998524Sfenner names and attribute names that belong to a namespace will be 210276788Sdelphij expanded; unprefixed attribute names are never expanded; unprefixed 211276788Sdelphij element type names are expanded only if there is a default 21298524Sfenner namespace. The expanded name is the concatenation of the namespace 213276788Sdelphij URI, the namespace separator character, and the local part of the 21498524Sfenner name. If the namespace separator is '\0' then the namespace URI 21598524Sfenner and the local part will be concatenated without any separator. 216276788Sdelphij It is a programming error to use the separator '\0' with namespace 21798524Sfenner triplets (see XML_SetReturnNSTriplet). 21898524Sfenner*/ 219276788SdelphijXMLPARSEAPI(XML_Parser) 22098524SfennerXML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator); 22198524Sfenner 22298524Sfenner 22398524Sfenner/* Constructs a new parser using the memory management suite referred to 22498524Sfenner by memsuite. If memsuite is NULL, then use the standard library memory 22598524Sfenner suite. If namespaceSeparator is non-NULL it creates a parser with 22698524Sfenner namespace processing as described above. The character pointed at 22798524Sfenner will serve as the namespace separator. 22898524Sfenner 229276788Sdelphij All further memory operations used for the created parser will come from 230276788Sdelphij the given suite. 23198524Sfenner*/ 23298524SfennerXMLPARSEAPI(XML_Parser) 233276788SdelphijXML_ParserCreate_MM(const XML_Char *encoding, 23498524Sfenner const XML_Memory_Handling_Suite *memsuite, 23598524Sfenner const XML_Char *namespaceSeparator); 23698524Sfenner 237276788Sdelphij/* Prepare a parser object to be re-used. This is particularly 23898524Sfenner valuable when memory allocation overhead is disproportionatly high, 23998524Sfenner such as when a large number of small documnents need to be parsed. 240276788Sdelphij All handlers are cleared from the parser, except for the 24198524Sfenner unknownEncodingHandler. The parser's external state is re-initialized 24298524Sfenner except for the values of ns and ns_triplets. 24398524Sfenner 244276788Sdelphij Added in Expat 1.95.3. 24598524Sfenner*/ 24698524SfennerXMLPARSEAPI(XML_Bool) 24798524SfennerXML_ParserReset(XML_Parser parser, const XML_Char *encoding); 24898524Sfenner 24998524Sfenner/* atts is array of name/value pairs, terminated by 0; 25098524Sfenner names and values are 0 terminated. 25198524Sfenner*/ 252276788Sdelphijtypedef void (XMLCALL *XML_StartElementHandler) (void *userData, 253276788Sdelphij const XML_Char *name, 25498524Sfenner const XML_Char **atts); 255276788Sdelphij 25698524Sfennertypedef void (XMLCALL *XML_EndElementHandler) (void *userData, 25798524Sfenner const XML_Char *name); 25898524Sfenner 259276788Sdelphij 260127668Sbms/* s is not 0 terminated. */ 26198524Sfennertypedef void (XMLCALL *XML_CharacterDataHandler) (void *userData, 26298524Sfenner const XML_Char *s, 263276788Sdelphij int len); 26498524Sfenner 265127668Sbms/* target and data are 0 terminated */ 26698524Sfennertypedef void (XMLCALL *XML_ProcessingInstructionHandler) ( 267127668Sbms void *userData, 268127668Sbms const XML_Char *target, 269276788Sdelphij const XML_Char *data); 27098524Sfenner 27198524Sfenner/* data is 0 terminated */ 27298524Sfennertypedef void (XMLCALL *XML_CommentHandler) (void *userData, 27398524Sfenner const XML_Char *data); 274127668Sbms 275127668Sbmstypedef void (XMLCALL *XML_StartCdataSectionHandler) (void *userData); 276276788Sdelphijtypedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData); 27798524Sfenner 27898524Sfenner/* This is called for any characters in the XML document for which 27998524Sfenner there is no applicable handler. This includes both characters that 28098524Sfenner are part of markup which is of a kind that is not reported 281276788Sdelphij (comments, markup declarations), or characters that are part of a 28298524Sfenner construct which could be reported but for which no handler has been 283276788Sdelphij supplied. The characters are passed exactly as they were in the XML 28498524Sfenner document except that they will be encoded in UTF-8 or UTF-16. 28598524Sfenner Line boundaries are not normalized. Note that a byte order mark 28698524Sfenner character is not passed to the default handler. There are no 28798524Sfenner guarantees about how characters are divided between calls to the 28898524Sfenner default handler: for example, a comment might be split between 28998524Sfenner multiple calls. 29098524Sfenner*/ 29198524Sfennertypedef void (XMLCALL *XML_DefaultHandler) (void *userData, 29298524Sfenner const XML_Char *s, 293276788Sdelphij int len); 294276788Sdelphij 29598524Sfenner/* This is called for the start of the DOCTYPE declaration, before 29698524Sfenner any DTD or internal subset is parsed. 297276788Sdelphij*/ 29898524Sfennertypedef void (XMLCALL *XML_StartDoctypeDeclHandler) ( 29998524Sfenner void *userData, 30098524Sfenner const XML_Char *doctypeName, 30198524Sfenner const XML_Char *sysid, 30298524Sfenner const XML_Char *pubid, 30398524Sfenner int has_internal_subset); 304276788Sdelphij 30598524Sfenner/* This is called for the start of the DOCTYPE declaration when the 306276788Sdelphij closing > is encountered, but after processing any external 307127668Sbms subset. 308276788Sdelphij*/ 309276788Sdelphijtypedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData); 31098524Sfenner 311127668Sbms/* This is called for entity declarations. The is_parameter_entity 31298524Sfenner argument will be non-zero if the entity is a parameter entity, zero 31398524Sfenner otherwise. 31498524Sfenner 315127668Sbms For internal entities (<!ENTITY foo "bar">), value will 31698524Sfenner be non-NULL and systemId, publicID, and notationName will be NULL. 31798524Sfenner The value string is NOT nul-terminated; the length is provided in 318127668Sbms the value_length argument. Since it is legal to have zero-length 31998524Sfenner values, do not use this argument to test for internal entities. 320276788Sdelphij 32198524Sfenner For external entities, value will be NULL and systemId will be 32298524Sfenner non-NULL. The publicId argument will be NULL unless a public 323127668Sbms identifier was provided. The notationName argument will have a 32498524Sfenner non-NULL value only for unparsed entity declarations. 325276788Sdelphij 32698524Sfenner Note that is_parameter_entity can't be changed to XML_Bool, since 327276788Sdelphij that would break binary compatibility. 328276788Sdelphij*/ 329276788Sdelphijtypedef void (XMLCALL *XML_EntityDeclHandler) ( 330276788Sdelphij void *userData, 331276788Sdelphij const XML_Char *entityName, 33298524Sfenner int is_parameter_entity, 333276788Sdelphij const XML_Char *value, 334276788Sdelphij int value_length, 335276788Sdelphij const XML_Char *base, 33698524Sfenner const XML_Char *systemId, 33798524Sfenner const XML_Char *publicId, 338276788Sdelphij const XML_Char *notationName); 33998524Sfenner 34098524SfennerXMLPARSEAPI(void) 34198524SfennerXML_SetEntityDeclHandler(XML_Parser parser, 34298524Sfenner XML_EntityDeclHandler handler); 34398524Sfenner 34498524Sfenner/* OBSOLETE -- OBSOLETE -- OBSOLETE 34598524Sfenner This handler has been superseded by the EntityDeclHandler above. 34698524Sfenner It is provided here for backward compatibility. 34798524Sfenner 34898524Sfenner This is called for a declaration of an unparsed (NDATA) entity. 349276788Sdelphij The base argument is whatever was set by XML_SetBase. The 35098524Sfenner entityName, systemId and notationName arguments will never be 35198524Sfenner NULL. The other arguments may be. 35298524Sfenner*/ 35398524Sfennertypedef void (XMLCALL *XML_UnparsedEntityDeclHandler) ( 35498524Sfenner void *userData, 355127668Sbms const XML_Char *entityName, 35698524Sfenner const XML_Char *base, 35798524Sfenner const XML_Char *systemId, 35898524Sfenner const XML_Char *publicId, 35998524Sfenner const XML_Char *notationName); 360276788Sdelphij 36198524Sfenner/* This is called for a declaration of notation. The base argument is 36298524Sfenner whatever was set by XML_SetBase. The notationName will never be 36398524Sfenner NULL. The other arguments can be. 364127668Sbms*/ 36598524Sfennertypedef void (XMLCALL *XML_NotationDeclHandler) ( 36698524Sfenner void *userData, 367276788Sdelphij const XML_Char *notationName, 368276788Sdelphij const XML_Char *base, 369276788Sdelphij const XML_Char *systemId, 37098524Sfenner const XML_Char *publicId); 37198524Sfenner 372127668Sbms/* When namespace processing is enabled, these are called once for 37398524Sfenner each namespace declaration. The call to the start and end element 37498524Sfenner handlers occur between the calls to the start and end namespace 375276788Sdelphij declaration handlers. For an xmlns attribute, prefix will be 37698524Sfenner NULL. For an xmlns="" attribute, uri will be NULL. 37798524Sfenner*/ 378276788Sdelphijtypedef void (XMLCALL *XML_StartNamespaceDeclHandler) ( 37998524Sfenner void *userData, 38098524Sfenner const XML_Char *prefix, 381276788Sdelphij const XML_Char *uri); 38298524Sfenner 38398524Sfennertypedef void (XMLCALL *XML_EndNamespaceDeclHandler) ( 38498524Sfenner void *userData, 385276788Sdelphij const XML_Char *prefix); 38698524Sfenner 387276788Sdelphij/* This is called if the document is not standalone, that is, it has an 38898524Sfenner external subset or a reference to a parameter entity, but does not 38998524Sfenner have standalone="yes". If this handler returns XML_STATUS_ERROR, 39098524Sfenner then processing will not continue, and the parser will return a 39198524Sfenner XML_ERROR_NOT_STANDALONE error. 39298524Sfenner If parameter entity parsing is enabled, then in addition to the 39398524Sfenner conditions above this handler will only be called if the referenced 394276788Sdelphij entity was actually read. 39598524Sfenner*/ 39698524Sfennertypedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData); 397276788Sdelphij 398276788Sdelphij/* This is called for a reference to an external parsed general 399276788Sdelphij entity. The referenced entity is not automatically parsed. The 40098524Sfenner application can parse it immediately or later using 40198524Sfenner XML_ExternalEntityParserCreate. 40298524Sfenner 40398524Sfenner The parser argument is the parser parsing the entity containing the 404276788Sdelphij reference; it can be passed as the parser argument to 40598524Sfenner XML_ExternalEntityParserCreate. The systemId argument is the 40698524Sfenner system identifier as specified in the entity declaration; it will 40798524Sfenner not be NULL. 40898524Sfenner 40998524Sfenner The base argument is the system identifier that should be used as 41098524Sfenner the base for resolving systemId if systemId was relative; this is 41198524Sfenner set by XML_SetBase; it may be NULL. 412276788Sdelphij 41398524Sfenner The publicId argument is the public identifier as specified in the 41498524Sfenner entity declaration, or NULL if none was specified; the whitespace 415276788Sdelphij in the public identifier will have been normalized as required by 416276788Sdelphij the XML spec. 417276788Sdelphij 41898524Sfenner The context argument specifies the parsing context in the format 41998524Sfenner expected by the context argument to XML_ExternalEntityParserCreate; 420276788Sdelphij context is valid only until the handler returns, so if the 421276788Sdelphij referenced entity is to be parsed later, it must be copied. 422127668Sbms context is NULL only when the entity is a parameter entity. 423276788Sdelphij 424276788Sdelphij The handler should return XML_STATUS_ERROR if processing should not 425127668Sbms continue because of a fatal error in the handling of the external 42698524Sfenner entity. In this case the calling parser will return an 42798524Sfenner XML_ERROR_EXTERNAL_ENTITY_HANDLING error. 42898524Sfenner 42998524Sfenner Note that unlike other handlers the first argument is the parser, 430127668Sbms not userData. 43198524Sfenner*/ 432276788Sdelphijtypedef int (XMLCALL *XML_ExternalEntityRefHandler) ( 43398524Sfenner XML_Parser parser, 43498524Sfenner const XML_Char *context, 43598524Sfenner const XML_Char *base, 43698524Sfenner const XML_Char *systemId, 43798524Sfenner const XML_Char *publicId); 43898524Sfenner 43998524Sfenner/* This is called in two situations: 44098524Sfenner 1) An entity reference is encountered for which no declaration 44198524Sfenner has been read *and* this is not an error. 44298524Sfenner 2) An internal entity reference is read, but not expanded, because 44398524Sfenner XML_SetDefaultHandler has been called. 44498524Sfenner Note: skipped parameter entities in declarations and skipped general 44598524Sfenner entities in attribute values cannot be reported, because 44698524Sfenner the event would be out of sync with the reporting of the 44798524Sfenner declarations or attribute values 448276788Sdelphij*/ 449276788Sdelphijtypedef void (XMLCALL *XML_SkippedEntityHandler) ( 45098524Sfenner void *userData, 45198524Sfenner const XML_Char *entityName, 45298524Sfenner int is_parameter_entity); 45398524Sfenner 45498524Sfenner/* This structure is filled in by the XML_UnknownEncodingHandler to 455127668Sbms provide information to the parser about encodings that are unknown 45698524Sfenner to the parser. 45798524Sfenner 45898524Sfenner The map[b] member gives information about byte sequences whose 45998524Sfenner first byte is b. 460276788Sdelphij 46198524Sfenner If map[b] is c where c is >= 0, then b by itself encodes the 46298524Sfenner Unicode scalar value c. 46398524Sfenner 464127668Sbms If map[b] is -1, then the byte sequence is malformed. 46598524Sfenner 46698524Sfenner If map[b] is -n, where n >= 2, then b is the first byte of an 467276788Sdelphij n-byte sequence that encodes a single Unicode scalar value. 468276788Sdelphij 469276788Sdelphij The data member will be passed as the first argument to the convert 47098524Sfenner function. 47198524Sfenner 472276788Sdelphij The convert function is used to convert multibyte sequences; s will 473276788Sdelphij point to a n-byte sequence where map[(unsigned char)*s] == -n. The 47498524Sfenner convert function must return the Unicode scalar value represented 475276788Sdelphij by this byte sequence or -1 if the byte sequence is malformed. 47698524Sfenner 47798524Sfenner The convert function may be NULL if the encoding is a single-byte 47898524Sfenner encoding, that is if map[b] >= -1 for all bytes b. 47998524Sfenner 48098524Sfenner When the parser is finished with the encoding, then if release is 481127668Sbms not NULL, it will call release passing it the data member; once 48298524Sfenner release has been called, the convert function will not be called 483276788Sdelphij again. 48498524Sfenner 48598524Sfenner Expat places certain restrictions on the encodings that are supported 48698524Sfenner using this mechanism. 48798524Sfenner 48898524Sfenner 1. Every ASCII character that can appear in a well-formed XML document, 48998524Sfenner other than the characters 490127668Sbms 49198524Sfenner $@\^`{}~ 492276788Sdelphij 49398524Sfenner must be represented by a single byte, and that byte must be the 49498524Sfenner same byte that represents that character in ASCII. 49598524Sfenner 49698524Sfenner 2. No character may require more than 4 bytes to encode. 49798524Sfenner 49898524Sfenner 3. All characters encoded must have Unicode scalar values <= 49998524Sfenner 0xFFFF, (i.e., characters that would be encoded by surrogates in 500276788Sdelphij UTF-16 are not allowed). Note that this restriction doesn't 50198524Sfenner apply to the built-in support for UTF-8 and UTF-16. 50298524Sfenner 50398524Sfenner 4. No Unicode character may be encoded by more than one distinct 504127668Sbms sequence of bytes. 50598524Sfenner*/ 50698524Sfennertypedef struct { 507276788Sdelphij int map[256]; 508276788Sdelphij void *data; 509276788Sdelphij int (XMLCALL *convert)(void *data, const char *s); 51098524Sfenner void (XMLCALL *release)(void *data); 51198524Sfenner} XML_Encoding; 512276788Sdelphij 51398524Sfenner/* This is called for an encoding that is unknown to the parser. 514276788Sdelphij 51598524Sfenner The encodingHandlerData argument is that which was passed as the 51698524Sfenner second argument to XML_SetUnknownEncodingHandler. 51798524Sfenner 51898524Sfenner The name argument gives the name of the encoding as specified in 51998524Sfenner the encoding declaration. 520127668Sbms 52198524Sfenner If the callback can provide information about the encoding, it must 522276788Sdelphij fill in the XML_Encoding structure, and return XML_STATUS_OK. 52398524Sfenner Otherwise it must return XML_STATUS_ERROR. 52498524Sfenner 52598524Sfenner If info does not describe a suitable encoding, then the parser will 52698524Sfenner return an XML_UNKNOWN_ENCODING error. 52798524Sfenner*/ 52898524Sfennertypedef int (XMLCALL *XML_UnknownEncodingHandler) ( 52998524Sfenner void *encodingHandlerData, 53098524Sfenner const XML_Char *name, 531276788Sdelphij XML_Encoding *info); 53298524Sfenner 53398524SfennerXMLPARSEAPI(void) 534276788SdelphijXML_SetElementHandler(XML_Parser parser, 535276788Sdelphij XML_StartElementHandler start, 536276788Sdelphij XML_EndElementHandler end); 53798524Sfenner 53898524SfennerXMLPARSEAPI(void) 539276788SdelphijXML_SetStartElementHandler(XML_Parser parser, 540276788Sdelphij XML_StartElementHandler handler); 541127668Sbms 542276788SdelphijXMLPARSEAPI(void) 543276788SdelphijXML_SetEndElementHandler(XML_Parser parser, 544127668Sbms XML_EndElementHandler handler); 545276788Sdelphij 546276788SdelphijXMLPARSEAPI(void) 547276788SdelphijXML_SetCharacterDataHandler(XML_Parser parser, 548276788Sdelphij XML_CharacterDataHandler handler); 54998524Sfenner 55098524SfennerXMLPARSEAPI(void) 55198524SfennerXML_SetProcessingInstructionHandler(XML_Parser parser, 55298524Sfenner XML_ProcessingInstructionHandler handler); 553276788SdelphijXMLPARSEAPI(void) 55498524SfennerXML_SetCommentHandler(XML_Parser parser, 55598524Sfenner XML_CommentHandler handler); 55698524Sfenner 55798524SfennerXMLPARSEAPI(void) 55898524SfennerXML_SetCdataSectionHandler(XML_Parser parser, 559127668Sbms XML_StartCdataSectionHandler start, 56098524Sfenner XML_EndCdataSectionHandler end); 56198524Sfenner 562276788SdelphijXMLPARSEAPI(void) 56398524SfennerXML_SetStartCdataSectionHandler(XML_Parser parser, 56498524Sfenner XML_StartCdataSectionHandler start); 56598524Sfenner 56698524SfennerXMLPARSEAPI(void) 56798524SfennerXML_SetEndCdataSectionHandler(XML_Parser parser, 56898524Sfenner XML_EndCdataSectionHandler end); 569127668Sbms 57098524Sfenner/* This sets the default handler and also inhibits expansion of 57198524Sfenner internal entities. These entity references will be passed to the 572276788Sdelphij default handler, or to the skipped entity handler, if one is set. 57398524Sfenner*/ 57498524SfennerXMLPARSEAPI(void) 57598524SfennerXML_SetDefaultHandler(XML_Parser parser, 57698524Sfenner XML_DefaultHandler handler); 57798524Sfenner 57898524Sfenner/* This sets the default handler but does not inhibit expansion of 57998524Sfenner internal entities. The entity reference will not be passed to the 58098524Sfenner default handler. 58198524Sfenner*/ 58298524SfennerXMLPARSEAPI(void) 58398524SfennerXML_SetDefaultHandlerExpand(XML_Parser parser, 58498524Sfenner XML_DefaultHandler handler); 58598524Sfenner 586127668SbmsXMLPARSEAPI(void) 587276788SdelphijXML_SetDoctypeDeclHandler(XML_Parser parser, 588276788Sdelphij XML_StartDoctypeDeclHandler start, 58998524Sfenner XML_EndDoctypeDeclHandler end); 590127668Sbms 591276788SdelphijXMLPARSEAPI(void) 59298524SfennerXML_SetStartDoctypeDeclHandler(XML_Parser parser, 59398524Sfenner XML_StartDoctypeDeclHandler start); 59498524Sfenner 595276788SdelphijXMLPARSEAPI(void) 59698524SfennerXML_SetEndDoctypeDeclHandler(XML_Parser parser, 597 XML_EndDoctypeDeclHandler end); 598 599XMLPARSEAPI(void) 600XML_SetUnparsedEntityDeclHandler(XML_Parser parser, 601 XML_UnparsedEntityDeclHandler handler); 602 603XMLPARSEAPI(void) 604XML_SetNotationDeclHandler(XML_Parser parser, 605 XML_NotationDeclHandler handler); 606 607XMLPARSEAPI(void) 608XML_SetNamespaceDeclHandler(XML_Parser parser, 609 XML_StartNamespaceDeclHandler start, 610 XML_EndNamespaceDeclHandler end); 611 612XMLPARSEAPI(void) 613XML_SetStartNamespaceDeclHandler(XML_Parser parser, 614 XML_StartNamespaceDeclHandler start); 615 616XMLPARSEAPI(void) 617XML_SetEndNamespaceDeclHandler(XML_Parser parser, 618 XML_EndNamespaceDeclHandler end); 619 620XMLPARSEAPI(void) 621XML_SetNotStandaloneHandler(XML_Parser parser, 622 XML_NotStandaloneHandler handler); 623 624XMLPARSEAPI(void) 625XML_SetExternalEntityRefHandler(XML_Parser parser, 626 XML_ExternalEntityRefHandler handler); 627 628/* If a non-NULL value for arg is specified here, then it will be 629 passed as the first argument to the external entity ref handler 630 instead of the parser object. 631*/ 632XMLPARSEAPI(void) 633XML_SetExternalEntityRefHandlerArg(XML_Parser parser, 634 void *arg); 635 636XMLPARSEAPI(void) 637XML_SetSkippedEntityHandler(XML_Parser parser, 638 XML_SkippedEntityHandler handler); 639 640XMLPARSEAPI(void) 641XML_SetUnknownEncodingHandler(XML_Parser parser, 642 XML_UnknownEncodingHandler handler, 643 void *encodingHandlerData); 644 645/* This can be called within a handler for a start element, end 646 element, processing instruction or character data. It causes the 647 corresponding markup to be passed to the default handler. 648*/ 649XMLPARSEAPI(void) 650XML_DefaultCurrent(XML_Parser parser); 651 652/* If do_nst is non-zero, and namespace processing is in effect, and 653 a name has a prefix (i.e. an explicit namespace qualifier) then 654 that name is returned as a triplet in a single string separated by 655 the separator character specified when the parser was created: URI 656 + sep + local_name + sep + prefix. 657 658 If do_nst is zero, then namespace information is returned in the 659 default manner (URI + sep + local_name) whether or not the name 660 has a prefix. 661 662 Note: Calling XML_SetReturnNSTriplet after XML_Parse or 663 XML_ParseBuffer has no effect. 664*/ 665 666XMLPARSEAPI(void) 667XML_SetReturnNSTriplet(XML_Parser parser, int do_nst); 668 669/* This value is passed as the userData argument to callbacks. */ 670XMLPARSEAPI(void) 671XML_SetUserData(XML_Parser parser, void *userData); 672 673/* Returns the last value set by XML_SetUserData or NULL. */ 674#define XML_GetUserData(parser) (*(void **)(parser)) 675 676/* This is equivalent to supplying an encoding argument to 677 XML_ParserCreate. On success XML_SetEncoding returns non-zero, 678 zero otherwise. 679 Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer 680 has no effect and returns XML_STATUS_ERROR. 681*/ 682XMLPARSEAPI(enum XML_Status) 683XML_SetEncoding(XML_Parser parser, const XML_Char *encoding); 684 685/* If this function is called, then the parser will be passed as the 686 first argument to callbacks instead of userData. The userData will 687 still be accessible using XML_GetUserData. 688*/ 689XMLPARSEAPI(void) 690XML_UseParserAsHandlerArg(XML_Parser parser); 691 692/* If useDTD == XML_TRUE is passed to this function, then the parser 693 will assume that there is an external subset, even if none is 694 specified in the document. In such a case the parser will call the 695 externalEntityRefHandler with a value of NULL for the systemId 696 argument (the publicId and context arguments will be NULL as well). 697 Note: For the purpose of checking WFC: Entity Declared, passing 698 useDTD == XML_TRUE will make the parser behave as if the document 699 had a DTD with an external subset. 700 Note: If this function is called, then this must be done before 701 the first call to XML_Parse or XML_ParseBuffer, since it will 702 have no effect after that. Returns 703 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING. 704 Note: If the document does not have a DOCTYPE declaration at all, 705 then startDoctypeDeclHandler and endDoctypeDeclHandler will not 706 be called, despite an external subset being parsed. 707 Note: If XML_DTD is not defined when Expat is compiled, returns 708 XML_ERROR_FEATURE_REQUIRES_XML_DTD. 709*/ 710XMLPARSEAPI(enum XML_Error) 711XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD); 712 713 714/* Sets the base to be used for resolving relative URIs in system 715 identifiers in declarations. Resolving relative identifiers is 716 left to the application: this value will be passed through as the 717 base argument to the XML_ExternalEntityRefHandler, 718 XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base 719 argument will be copied. Returns XML_STATUS_ERROR if out of memory, 720 XML_STATUS_OK otherwise. 721*/ 722XMLPARSEAPI(enum XML_Status) 723XML_SetBase(XML_Parser parser, const XML_Char *base); 724 725XMLPARSEAPI(const XML_Char *) 726XML_GetBase(XML_Parser parser); 727 728/* Returns the number of the attribute/value pairs passed in last call 729 to the XML_StartElementHandler that were specified in the start-tag 730 rather than defaulted. Each attribute/value pair counts as 2; thus 731 this correspondds to an index into the atts array passed to the 732 XML_StartElementHandler. 733*/ 734XMLPARSEAPI(int) 735XML_GetSpecifiedAttributeCount(XML_Parser parser); 736 737/* Returns the index of the ID attribute passed in the last call to 738 XML_StartElementHandler, or -1 if there is no ID attribute. Each 739 attribute/value pair counts as 2; thus this correspondds to an 740 index into the atts array passed to the XML_StartElementHandler. 741*/ 742XMLPARSEAPI(int) 743XML_GetIdAttributeIndex(XML_Parser parser); 744 745#ifdef XML_ATTR_INFO 746/* Source file byte offsets for the start and end of attribute names and values. 747 The value indices are exclusive of surrounding quotes; thus in a UTF-8 source 748 file an attribute value of "blah" will yield: 749 info->valueEnd - info->valueStart = 4 bytes. 750*/ 751typedef struct { 752 XML_Index nameStart; /* Offset to beginning of the attribute name. */ 753 XML_Index nameEnd; /* Offset after the attribute name's last byte. */ 754 XML_Index valueStart; /* Offset to beginning of the attribute value. */ 755 XML_Index valueEnd; /* Offset after the attribute value's last byte. */ 756} XML_AttrInfo; 757 758/* Returns an array of XML_AttrInfo structures for the attribute/value pairs 759 passed in last call to the XML_StartElementHandler that were specified 760 in the start-tag rather than defaulted. Each attribute/value pair counts 761 as 1; thus the number of entries in the array is 762 XML_GetSpecifiedAttributeCount(parser) / 2. 763*/ 764XMLPARSEAPI(const XML_AttrInfo *) 765XML_GetAttributeInfo(XML_Parser parser); 766#endif 767 768/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is 769 detected. The last call to XML_Parse must have isFinal true; len 770 may be zero for this call (or any other). 771 772 Though the return values for these functions has always been 773 described as a Boolean value, the implementation, at least for the 774 1.95.x series, has always returned exactly one of the XML_Status 775 values. 776*/ 777XMLPARSEAPI(enum XML_Status) 778XML_Parse(XML_Parser parser, const char *s, int len, int isFinal); 779 780XMLPARSEAPI(void *) 781XML_GetBuffer(XML_Parser parser, int len); 782 783XMLPARSEAPI(enum XML_Status) 784XML_ParseBuffer(XML_Parser parser, int len, int isFinal); 785 786/* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return. 787 Must be called from within a call-back handler, except when aborting 788 (resumable = 0) an already suspended parser. Some call-backs may 789 still follow because they would otherwise get lost. Examples: 790 - endElementHandler() for empty elements when stopped in 791 startElementHandler(), 792 - endNameSpaceDeclHandler() when stopped in endElementHandler(), 793 and possibly others. 794 795 Can be called from most handlers, including DTD related call-backs, 796 except when parsing an external parameter entity and resumable != 0. 797 Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise. 798 Possible error codes: 799 - XML_ERROR_SUSPENDED: when suspending an already suspended parser. 800 - XML_ERROR_FINISHED: when the parser has already finished. 801 - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE. 802 803 When resumable != 0 (true) then parsing is suspended, that is, 804 XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED. 805 Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer() 806 return XML_STATUS_ERROR with error code XML_ERROR_ABORTED. 807 808 *Note*: 809 This will be applied to the current parser instance only, that is, if 810 there is a parent parser then it will continue parsing when the 811 externalEntityRefHandler() returns. It is up to the implementation of 812 the externalEntityRefHandler() to call XML_StopParser() on the parent 813 parser (recursively), if one wants to stop parsing altogether. 814 815 When suspended, parsing can be resumed by calling XML_ResumeParser(). 816*/ 817XMLPARSEAPI(enum XML_Status) 818XML_StopParser(XML_Parser parser, XML_Bool resumable); 819 820/* Resumes parsing after it has been suspended with XML_StopParser(). 821 Must not be called from within a handler call-back. Returns same 822 status codes as XML_Parse() or XML_ParseBuffer(). 823 Additional error code XML_ERROR_NOT_SUSPENDED possible. 824 825 *Note*: 826 This must be called on the most deeply nested child parser instance 827 first, and on its parent parser only after the child parser has finished, 828 to be applied recursively until the document entity's parser is restarted. 829 That is, the parent parser will not resume by itself and it is up to the 830 application to call XML_ResumeParser() on it at the appropriate moment. 831*/ 832XMLPARSEAPI(enum XML_Status) 833XML_ResumeParser(XML_Parser parser); 834 835enum XML_Parsing { 836 XML_INITIALIZED, 837 XML_PARSING, 838 XML_FINISHED, 839 XML_SUSPENDED 840}; 841 842typedef struct { 843 enum XML_Parsing parsing; 844 XML_Bool finalBuffer; 845} XML_ParsingStatus; 846 847/* Returns status of parser with respect to being initialized, parsing, 848 finished, or suspended and processing the final buffer. 849 XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus, 850 XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED 851*/ 852XMLPARSEAPI(void) 853XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status); 854 855/* Creates an XML_Parser object that can parse an external general 856 entity; context is a '\0'-terminated string specifying the parse 857 context; encoding is a '\0'-terminated string giving the name of 858 the externally specified encoding, or NULL if there is no 859 externally specified encoding. The context string consists of a 860 sequence of tokens separated by formfeeds (\f); a token consisting 861 of a name specifies that the general entity of the name is open; a 862 token of the form prefix=uri specifies the namespace for a 863 particular prefix; a token of the form =uri specifies the default 864 namespace. This can be called at any point after the first call to 865 an ExternalEntityRefHandler so longer as the parser has not yet 866 been freed. The new parser is completely independent and may 867 safely be used in a separate thread. The handlers and userData are 868 initialized from the parser argument. Returns NULL if out of memory. 869 Otherwise returns a new XML_Parser object. 870*/ 871XMLPARSEAPI(XML_Parser) 872XML_ExternalEntityParserCreate(XML_Parser parser, 873 const XML_Char *context, 874 const XML_Char *encoding); 875 876enum XML_ParamEntityParsing { 877 XML_PARAM_ENTITY_PARSING_NEVER, 878 XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE, 879 XML_PARAM_ENTITY_PARSING_ALWAYS 880}; 881 882/* Controls parsing of parameter entities (including the external DTD 883 subset). If parsing of parameter entities is enabled, then 884 references to external parameter entities (including the external 885 DTD subset) will be passed to the handler set with 886 XML_SetExternalEntityRefHandler. The context passed will be 0. 887 888 Unlike external general entities, external parameter entities can 889 only be parsed synchronously. If the external parameter entity is 890 to be parsed, it must be parsed during the call to the external 891 entity ref handler: the complete sequence of 892 XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and 893 XML_ParserFree calls must be made during this call. After 894 XML_ExternalEntityParserCreate has been called to create the parser 895 for the external parameter entity (context must be 0 for this 896 call), it is illegal to make any calls on the old parser until 897 XML_ParserFree has been called on the newly created parser. 898 If the library has been compiled without support for parameter 899 entity parsing (ie without XML_DTD being defined), then 900 XML_SetParamEntityParsing will return 0 if parsing of parameter 901 entities is requested; otherwise it will return non-zero. 902 Note: If XML_SetParamEntityParsing is called after XML_Parse or 903 XML_ParseBuffer, then it has no effect and will always return 0. 904*/ 905XMLPARSEAPI(int) 906XML_SetParamEntityParsing(XML_Parser parser, 907 enum XML_ParamEntityParsing parsing); 908 909/* Sets the hash salt to use for internal hash calculations. 910 Helps in preventing DoS attacks based on predicting hash 911 function behavior. This must be called before parsing is started. 912 Returns 1 if successful, 0 when called after parsing has started. 913*/ 914XMLPARSEAPI(int) 915XML_SetHashSalt(XML_Parser parser, 916 unsigned long hash_salt); 917 918/* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then 919 XML_GetErrorCode returns information about the error. 920*/ 921XMLPARSEAPI(enum XML_Error) 922XML_GetErrorCode(XML_Parser parser); 923 924/* These functions return information about the current parse 925 location. They may be called from any callback called to report 926 some parse event; in this case the location is the location of the 927 first of the sequence of characters that generated the event. When 928 called from callbacks generated by declarations in the document 929 prologue, the location identified isn't as neatly defined, but will 930 be within the relevant markup. When called outside of the callback 931 functions, the position indicated will be just past the last parse 932 event (regardless of whether there was an associated callback). 933 934 They may also be called after returning from a call to XML_Parse 935 or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then 936 the location is the location of the character at which the error 937 was detected; otherwise the location is the location of the last 938 parse event, as described above. 939*/ 940XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser); 941XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser); 942XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser); 943 944/* Return the number of bytes in the current event. 945 Returns 0 if the event is in an internal entity. 946*/ 947XMLPARSEAPI(int) 948XML_GetCurrentByteCount(XML_Parser parser); 949 950/* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets 951 the integer pointed to by offset to the offset within this buffer 952 of the current parse position, and sets the integer pointed to by size 953 to the size of this buffer (the number of input bytes). Otherwise 954 returns a NULL pointer. Also returns a NULL pointer if a parse isn't 955 active. 956 957 NOTE: The character pointer returned should not be used outside 958 the handler that makes the call. 959*/ 960XMLPARSEAPI(const char *) 961XML_GetInputContext(XML_Parser parser, 962 int *offset, 963 int *size); 964 965/* For backwards compatibility with previous versions. */ 966#define XML_GetErrorLineNumber XML_GetCurrentLineNumber 967#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber 968#define XML_GetErrorByteIndex XML_GetCurrentByteIndex 969 970/* Frees the content model passed to the element declaration handler */ 971XMLPARSEAPI(void) 972XML_FreeContentModel(XML_Parser parser, XML_Content *model); 973 974/* Exposing the memory handling functions used in Expat */ 975XMLPARSEAPI(void *) 976XML_ATTR_MALLOC 977XML_ATTR_ALLOC_SIZE(2) 978XML_MemMalloc(XML_Parser parser, size_t size); 979 980XMLPARSEAPI(void *) 981XML_ATTR_ALLOC_SIZE(3) 982XML_MemRealloc(XML_Parser parser, void *ptr, size_t size); 983 984XMLPARSEAPI(void) 985XML_MemFree(XML_Parser parser, void *ptr); 986 987/* Frees memory used by the parser. */ 988XMLPARSEAPI(void) 989XML_ParserFree(XML_Parser parser); 990 991/* Returns a string describing the error. */ 992XMLPARSEAPI(const XML_LChar *) 993XML_ErrorString(enum XML_Error code); 994 995/* Return a string containing the version number of this expat */ 996XMLPARSEAPI(const XML_LChar *) 997XML_ExpatVersion(void); 998 999typedef struct { 1000 int major; 1001 int minor; 1002 int micro; 1003} XML_Expat_Version; 1004 1005/* Return an XML_Expat_Version structure containing numeric version 1006 number information for this version of expat. 1007*/ 1008XMLPARSEAPI(XML_Expat_Version) 1009XML_ExpatVersionInfo(void); 1010 1011/* Added in Expat 1.95.5. */ 1012enum XML_FeatureEnum { 1013 XML_FEATURE_END = 0, 1014 XML_FEATURE_UNICODE, 1015 XML_FEATURE_UNICODE_WCHAR_T, 1016 XML_FEATURE_DTD, 1017 XML_FEATURE_CONTEXT_BYTES, 1018 XML_FEATURE_MIN_SIZE, 1019 XML_FEATURE_SIZEOF_XML_CHAR, 1020 XML_FEATURE_SIZEOF_XML_LCHAR, 1021 XML_FEATURE_NS, 1022 XML_FEATURE_LARGE_SIZE, 1023 XML_FEATURE_ATTR_INFO 1024 /* Additional features must be added to the end of this enum. */ 1025}; 1026 1027typedef struct { 1028 enum XML_FeatureEnum feature; 1029 const XML_LChar *name; 1030 long int value; 1031} XML_Feature; 1032 1033XMLPARSEAPI(const XML_Feature *) 1034XML_GetFeatureList(void); 1035 1036 1037/* Expat follows the semantic versioning convention. 1038 See http://semver.org. 1039*/ 1040#define XML_MAJOR_VERSION 2 1041#define XML_MINOR_VERSION 2 1042#define XML_MICRO_VERSION 0 1043 1044#ifdef __cplusplus 1045} 1046#endif 1047 1048#endif /* not Expat_INCLUDED */ 1049