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