📄 expat.h
字号:
/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd See the file COPYING for copying permission.*/#ifndef XmlParse_INCLUDED#define XmlParse_INCLUDED 1#ifdef __VMS/* 0 1 2 3 0 1 2 3 1234567890123456789012345678901 1234567890123456789012345678901 */#define XML_SetProcessingInstructionHandler XML_SetProcessingInstrHandler#define XML_SetUnparsedEntityDeclHandler XML_SetUnparsedEntDeclHandler#define XML_SetStartNamespaceDeclHandler XML_SetStartNamespcDeclHandler#define XML_SetExternalEntityRefHandlerArg XML_SetExternalEntRefHandlerArg#endif#include <stdlib.h>#ifndef XMLPARSEAPI#define XMLPARSEAPI(type) type#endif /* not defined XMLPARSEAPI */#ifdef __cplusplusextern "C" {#endif#ifdef XML_UNICODE_WCHAR_T#define XML_UNICODE#endifstruct XML_ParserStruct;typedef struct XML_ParserStruct *XML_Parser;#ifdef XML_UNICODE /* Information is UTF-16 encoded. */#ifdef XML_UNICODE_WCHAR_Ttypedef wchar_t XML_Char;typedef wchar_t XML_LChar;#elsetypedef unsigned short XML_Char;typedef char XML_LChar;#endif /* XML_UNICODE_WCHAR_T */#else /* Information is UTF-8 encoded. */typedef char XML_Char;typedef char XML_LChar;#endif /* XML_UNICODE *//* Should this be defined using stdbool.h when C99 is available? */typedef unsigned char XML_Bool;#define XML_TRUE ((XML_Bool) 1)#define XML_FALSE ((XML_Bool) 0)enum XML_Error { XML_ERROR_NONE, XML_ERROR_NO_MEMORY, XML_ERROR_SYNTAX, XML_ERROR_NO_ELEMENTS, XML_ERROR_INVALID_TOKEN, XML_ERROR_UNCLOSED_TOKEN, XML_ERROR_PARTIAL_CHAR, XML_ERROR_TAG_MISMATCH, XML_ERROR_DUPLICATE_ATTRIBUTE, XML_ERROR_JUNK_AFTER_DOC_ELEMENT, XML_ERROR_PARAM_ENTITY_REF, XML_ERROR_UNDEFINED_ENTITY, XML_ERROR_RECURSIVE_ENTITY_REF, XML_ERROR_ASYNC_ENTITY, XML_ERROR_BAD_CHAR_REF, XML_ERROR_BINARY_ENTITY_REF, XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, XML_ERROR_MISPLACED_XML_PI, XML_ERROR_UNKNOWN_ENCODING, XML_ERROR_INCORRECT_ENCODING, XML_ERROR_UNCLOSED_CDATA_SECTION, XML_ERROR_EXTERNAL_ENTITY_HANDLING, XML_ERROR_NOT_STANDALONE, XML_ERROR_UNEXPECTED_STATE, XML_ERROR_ENTITY_DECLARED_IN_PE, XML_ERROR_FEATURE_REQUIRES_XML_DTD, XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING};enum XML_Content_Type { XML_CTYPE_EMPTY = 1, XML_CTYPE_ANY, XML_CTYPE_MIXED, XML_CTYPE_NAME, XML_CTYPE_CHOICE, XML_CTYPE_SEQ};enum XML_Content_Quant { XML_CQUANT_NONE, XML_CQUANT_OPT, XML_CQUANT_REP, XML_CQUANT_PLUS};/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is detected. The last call to XML_Parse must have isFinal true; len may be zero for this call (or any other). The XML_Status enum gives the possible return values for the XML_Parse and XML_ParseBuffer functions. Though the return values for these functions has always been described as a Boolean value, the implementation, at least for the 1.95.x series, has always returned exactly one of these values. The preprocessor #defines are included so this stanza can be added to code that still needs to support older versions of Expat 1.95.x: #ifndef XML_STATUS_OK #define XML_STATUS_OK 1 #define XML_STATUS_ERROR 0 #endif Otherwise, the #define hackery is quite ugly and would have been dropped.*/enum XML_Status { XML_STATUS_ERROR = 0,#define XML_STATUS_ERROR XML_STATUS_ERROR XML_STATUS_OK = 1#define XML_STATUS_OK XML_STATUS_OK};/* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be XML_CQUANT_NONE, and the other fields will be zero or NULL. If type == XML_CTYPE_MIXED, then quant will be NONE or REP and numchildren will contain number of elements that may be mixed in and children point to an array of XML_Content cells that will be all of XML_CTYPE_NAME type with no quantification. If type == XML_CTYPE_NAME, then the name points to the name, and the numchildren field will be zero and children will be NULL. The quant fields indicates any quantifiers placed on the name. CHOICE and SEQ will have name NULL, the number of children in numchildren and children will point, recursively, to an array of XML_Content cells. The EMPTY, ANY, and MIXED types will only occur at top level.*/typedef struct XML_cp XML_Content;struct XML_cp { enum XML_Content_Type type; enum XML_Content_Quant quant; XML_Char * name; unsigned int numchildren; XML_Content * children;};/* This is called for an element declaration. See above for description of the model argument. It's the caller's responsibility to free model when finished with it.*/typedef void (*XML_ElementDeclHandler) (void *userData, const XML_Char *name, XML_Content *model);XMLPARSEAPI(void)XML_SetElementDeclHandler(XML_Parser parser, XML_ElementDeclHandler eldecl);/* The Attlist declaration handler is called for *each* attribute. So a single Attlist declaration with multiple attributes declared will generate multiple calls to this handler. The "default" parameter may be NULL in the case of the "#IMPLIED" or "#REQUIRED" keyword. The "isrequired" parameter will be true and the default value will be NULL in the case of "#REQUIRED". If "isrequired" is true and default is non-NULL, then this is a "#FIXED" default.*/typedef void (*XML_AttlistDeclHandler) (void *userData, const XML_Char *elname, const XML_Char *attname, const XML_Char *att_type, const XML_Char *dflt, int isrequired);XMLPARSEAPI(void)XML_SetAttlistDeclHandler(XML_Parser parser, XML_AttlistDeclHandler attdecl);/* The XML declaration handler is called for *both* XML declarations and text declarations. The way to distinguish is that the version parameter will be NULL for text declarations. The encoding parameter may be NULL for XML declarations. The standalone parameter will be -1, 0, or 1 indicating respectively that there was no standalone parameter in the declaration, that it was given as no, or that it was given as yes.*/typedef void (*XML_XmlDeclHandler) (void *userData, const XML_Char *version, const XML_Char *encoding, int standalone);XMLPARSEAPI(void)XML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler xmldecl);typedef struct { void *(*malloc_fcn)(size_t size); void *(*realloc_fcn)(void *ptr, size_t size); void (*free_fcn)(void *ptr);} XML_Memory_Handling_Suite;/* Constructs a new parser; encoding is the encoding specified by the external protocol or NULL if there is none specified.*/XMLPARSEAPI(XML_Parser)XML_ParserCreate(const XML_Char *encoding);/* Constructs a new parser and namespace processor. Element type names and attribute names that belong to a namespace will be expanded; unprefixed attribute names are never expanded; unprefixed element type names are expanded only if there is a default namespace. The expanded name is the concatenation of the namespace URI, the namespace separator character, and the local part of the name. If the namespace separator is '\0' then the namespace URI and the local part will be concatenated without any separator. When a namespace is not declared, the name and prefix will be passed through without expansion.*/XMLPARSEAPI(XML_Parser)XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);/* Constructs a new parser using the memory management suite referred to by memsuite. If memsuite is NULL, then use the standard library memory suite. If namespaceSeparator is non-NULL it creates a parser with namespace processing as described above. The character pointed at will serve as the namespace separator. All further memory operations used for the created parser will come from the given suite.*/XMLPARSEAPI(XML_Parser)XML_ParserCreate_MM(const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite, const XML_Char *namespaceSeparator);/* Prepare a parser object to be re-used. This is particularly valuable when memory allocation overhead is disproportionatly high, such as when a large number of small documnents need to be parsed. All handlers are cleared from the parser, except for the unknownEncodingHandler. The parser's external state is re-initialized except for the values of ns and ns_triplets. Added in Expat 1.95.3.*/XMLPARSEAPI(XML_Bool)XML_ParserReset(XML_Parser parser, const XML_Char *encoding);/* atts is array of name/value pairs, terminated by 0; names and values are 0 terminated.*/typedef void (*XML_StartElementHandler)(void *userData, const XML_Char *name, const XML_Char **atts);typedef void (*XML_EndElementHandler)(void *userData, const XML_Char *name);/* s is not 0 terminated. */typedef void (*XML_CharacterDataHandler)(void *userData, const XML_Char *s, int len);/* target and data are 0 terminated */typedef void (*XML_ProcessingInstructionHandler)(void *userData, const XML_Char *target, const XML_Char *data);/* data is 0 terminated */typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data);typedef void (*XML_StartCdataSectionHandler)(void *userData);typedef void (*XML_EndCdataSectionHandler)(void *userData);/* This is called for any characters in the XML document for which there is no applicable handler. This includes both characters that are part of markup which is of a kind that is not reported (comments, markup declarations), or characters that are part of a construct which could be reported but for which no handler has been supplied. The characters are passed exactly as they were in the XML document except that they will be encoded in UTF-8 or UTF-16. Line boundaries are not normalized. Note that a byte order mark character is not passed to the default handler. There are no guarantees about how characters are divided between calls to the default handler: for example, a comment might be split between multiple calls.*/typedef void (*XML_DefaultHandler)(void *userData, const XML_Char *s, int len);/* This is called for the start of the DOCTYPE declaration, before any DTD or internal subset is parsed.*/typedef void (*XML_StartDoctypeDeclHandler)(void *userData, const XML_Char *doctypeName, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -