|
|
|||
File indexing completed on 2026-09-10 09:31:21
0001 /* 0002 __ __ _ 0003 ___\ \/ /_ __ __ _| |_ 0004 / _ \\ /| '_ \ / _` | __| 0005 | __// \| |_) | (_| | |_ 0006 \___/_/\_\ .__/ \__,_|\__| 0007 |_| XML parser 0008 0009 Copyright (c) 1997-2000 Thai Open Source Software Center Ltd 0010 Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net> 0011 Copyright (c) 2000-2005 Fred L. Drake, Jr. <fdrake@users.sourceforge.net> 0012 Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net> 0013 Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net> 0014 Copyright (c) 2016-2026 Sebastian Pipping <sebastian@pipping.org> 0015 Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org> 0016 Copyright (c) 2016 Thomas Beutlich <tc@tbeu.de> 0017 Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk> 0018 Copyright (c) 2022 Thijs Schreijer <thijs@thijsschreijer.nl> 0019 Copyright (c) 2023 Hanno Böck <hanno@gentoo.org> 0020 Copyright (c) 2023 Sony Corporation / Snild Dolkow <snild@sony.com> 0021 Copyright (c) 2024 Taichi Haradaguchi <20001722@ymail.ne.jp> 0022 Copyright (c) 2025 Matthew Fernandez <matthew.fernandez@gmail.com> 0023 Licensed under the MIT license: 0024 0025 Permission is hereby granted, free of charge, to any person obtaining 0026 a copy of this software and associated documentation files (the 0027 "Software"), to deal in the Software without restriction, including 0028 without limitation the rights to use, copy, modify, merge, publish, 0029 distribute, sublicense, and/or sell copies of the Software, and to permit 0030 persons to whom the Software is furnished to do so, subject to the 0031 following conditions: 0032 0033 The above copyright notice and this permission notice shall be included 0034 in all copies or substantial portions of the Software. 0035 0036 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 0037 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 0038 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 0039 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 0040 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 0041 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 0042 USE OR OTHER DEALINGS IN THE SOFTWARE. 0043 */ 0044 0045 #ifndef Expat_INCLUDED 0046 # define Expat_INCLUDED 1 0047 0048 # include <stdint.h> // for uint8_t 0049 # include <stdlib.h> 0050 # include "expat_external.h" 0051 0052 # ifdef __cplusplus 0053 extern "C" { 0054 # endif 0055 0056 struct XML_ParserStruct; 0057 typedef struct XML_ParserStruct *XML_Parser; 0058 0059 typedef unsigned char XML_Bool; 0060 # define XML_TRUE ((XML_Bool)1) 0061 # define XML_FALSE ((XML_Bool)0) 0062 0063 /* The XML_Status enum gives the possible return values for several 0064 API functions. The preprocessor #defines are included so this 0065 stanza can be added to code that still needs to support older 0066 versions of Expat 1.95.x: 0067 0068 #ifndef XML_STATUS_OK 0069 #define XML_STATUS_OK 1 0070 #define XML_STATUS_ERROR 0 0071 #endif 0072 0073 Otherwise, the #define hackery is quite ugly and would have been 0074 dropped. 0075 */ 0076 enum XML_Status { 0077 XML_STATUS_ERROR = 0, 0078 # define XML_STATUS_ERROR XML_STATUS_ERROR 0079 XML_STATUS_OK = 1, 0080 # define XML_STATUS_OK XML_STATUS_OK 0081 XML_STATUS_SUSPENDED = 2 0082 # define XML_STATUS_SUSPENDED XML_STATUS_SUSPENDED 0083 }; 0084 0085 enum XML_Error { 0086 XML_ERROR_NONE, 0087 XML_ERROR_NO_MEMORY, 0088 XML_ERROR_SYNTAX, 0089 XML_ERROR_NO_ELEMENTS, 0090 XML_ERROR_INVALID_TOKEN, 0091 XML_ERROR_UNCLOSED_TOKEN, 0092 XML_ERROR_PARTIAL_CHAR, 0093 XML_ERROR_TAG_MISMATCH, 0094 XML_ERROR_DUPLICATE_ATTRIBUTE, 0095 XML_ERROR_JUNK_AFTER_DOC_ELEMENT, 0096 XML_ERROR_PARAM_ENTITY_REF, 0097 XML_ERROR_UNDEFINED_ENTITY, 0098 XML_ERROR_RECURSIVE_ENTITY_REF, 0099 XML_ERROR_ASYNC_ENTITY, 0100 XML_ERROR_BAD_CHAR_REF, 0101 XML_ERROR_BINARY_ENTITY_REF, 0102 XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, 0103 XML_ERROR_MISPLACED_XML_PI, 0104 XML_ERROR_UNKNOWN_ENCODING, 0105 XML_ERROR_INCORRECT_ENCODING, 0106 XML_ERROR_UNCLOSED_CDATA_SECTION, 0107 XML_ERROR_EXTERNAL_ENTITY_HANDLING, 0108 XML_ERROR_NOT_STANDALONE, 0109 XML_ERROR_UNEXPECTED_STATE, 0110 XML_ERROR_ENTITY_DECLARED_IN_PE, 0111 XML_ERROR_FEATURE_REQUIRES_XML_DTD, 0112 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING, 0113 /* Added in 1.95.7. */ 0114 XML_ERROR_UNBOUND_PREFIX, 0115 /* Added in 1.95.8. */ 0116 XML_ERROR_UNDECLARING_PREFIX, 0117 XML_ERROR_INCOMPLETE_PE, 0118 XML_ERROR_XML_DECL, 0119 XML_ERROR_TEXT_DECL, 0120 XML_ERROR_PUBLICID, 0121 XML_ERROR_SUSPENDED, 0122 XML_ERROR_NOT_SUSPENDED, 0123 XML_ERROR_ABORTED, 0124 XML_ERROR_FINISHED, 0125 XML_ERROR_SUSPEND_PE, 0126 /* Added in 2.0. */ 0127 XML_ERROR_RESERVED_PREFIX_XML, 0128 XML_ERROR_RESERVED_PREFIX_XMLNS, 0129 XML_ERROR_RESERVED_NAMESPACE_URI, 0130 /* Added in 2.2.1. */ 0131 XML_ERROR_INVALID_ARGUMENT, 0132 /* Added in 2.3.0. */ 0133 XML_ERROR_NO_BUFFER, 0134 /* Added in 2.4.0. */ 0135 XML_ERROR_AMPLIFICATION_LIMIT_BREACH, 0136 /* Added in 2.6.4. */ 0137 XML_ERROR_NOT_STARTED, 0138 }; 0139 0140 enum XML_Content_Type { 0141 XML_CTYPE_EMPTY = 1, 0142 XML_CTYPE_ANY, 0143 XML_CTYPE_MIXED, 0144 XML_CTYPE_NAME, 0145 XML_CTYPE_CHOICE, 0146 XML_CTYPE_SEQ 0147 }; 0148 0149 enum XML_Content_Quant { 0150 XML_CQUANT_NONE, 0151 XML_CQUANT_OPT, 0152 XML_CQUANT_REP, 0153 XML_CQUANT_PLUS 0154 }; 0155 0156 /* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be 0157 XML_CQUANT_NONE, and the other fields will be zero or NULL. 0158 If type == XML_CTYPE_MIXED, then quant will be NONE or REP and 0159 numchildren will contain number of elements that may be mixed in 0160 and children point to an array of XML_Content cells that will be 0161 all of XML_CTYPE_NAME type with no quantification. 0162 0163 If type == XML_CTYPE_NAME, then the name points to the name, and 0164 the numchildren field will be zero and children will be NULL. The 0165 quant fields indicates any quantifiers placed on the name. 0166 0167 CHOICE and SEQ will have name NULL, the number of children in 0168 numchildren and children will point, recursively, to an array 0169 of XML_Content cells. 0170 0171 The EMPTY, ANY, and MIXED types will only occur at top level. 0172 */ 0173 0174 typedef struct XML_cp XML_Content; 0175 0176 struct XML_cp { 0177 enum XML_Content_Type type; 0178 enum XML_Content_Quant quant; 0179 XML_Char *name; 0180 unsigned int numchildren; 0181 XML_Content *children; 0182 }; 0183 0184 /* This is called for an element declaration. See above for 0185 description of the model argument. It's the user code's responsibility 0186 to free model when finished with it. See XML_FreeContentModel. 0187 There is no need to free the model from the handler, it can be kept 0188 around and freed at a later stage. 0189 */ 0190 typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData, 0191 const XML_Char *name, 0192 XML_Content *model); 0193 0194 XMLPARSEAPI(void) 0195 XML_SetElementDeclHandler(XML_Parser parser, XML_ElementDeclHandler eldecl); 0196 0197 /* The Attlist declaration handler is called for *each* attribute. So 0198 a single Attlist declaration with multiple attributes declared will 0199 generate multiple calls to this handler. The "default" parameter 0200 may be NULL in the case of the "#IMPLIED" or "#REQUIRED" 0201 keyword. The "isrequired" parameter will be true and the default 0202 value will be NULL in the case of "#REQUIRED". If "isrequired" is 0203 true and default is non-NULL, then this is a "#FIXED" default. 0204 */ 0205 typedef void(XMLCALL *XML_AttlistDeclHandler)( 0206 void *userData, const XML_Char *elname, const XML_Char *attname, 0207 const XML_Char *att_type, const XML_Char *dflt, int isrequired); 0208 0209 XMLPARSEAPI(void) 0210 XML_SetAttlistDeclHandler(XML_Parser parser, XML_AttlistDeclHandler attdecl); 0211 0212 /* The XML declaration handler is called for *both* XML declarations 0213 and text declarations. The way to distinguish is that the version 0214 parameter will be NULL for text declarations. The encoding 0215 parameter may be NULL for XML declarations. The standalone 0216 parameter will be -1, 0, or 1 indicating respectively that there 0217 was no standalone parameter in the declaration, that it was given 0218 as no, or that it was given as yes. 0219 */ 0220 typedef void(XMLCALL *XML_XmlDeclHandler)(void *userData, 0221 const XML_Char *version, 0222 const XML_Char *encoding, 0223 int standalone); 0224 0225 XMLPARSEAPI(void) 0226 XML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler xmldecl); 0227 0228 typedef struct { 0229 void *(*malloc_fcn)(size_t size); 0230 void *(*realloc_fcn)(void *ptr, size_t size); 0231 void (*free_fcn)(void *ptr); 0232 } XML_Memory_Handling_Suite; 0233 0234 /* Constructs a new parser; encoding is the encoding specified by the 0235 external protocol or NULL if there is none specified. 0236 */ 0237 XMLPARSEAPI(XML_Parser) 0238 XML_ParserCreate(const XML_Char *encoding); 0239 0240 /* Constructs a new parser and namespace processor. Element type 0241 names and attribute names that belong to a namespace will be 0242 expanded; unprefixed attribute names are never expanded; unprefixed 0243 element type names are expanded only if there is a default 0244 namespace. The expanded name is the concatenation of the namespace 0245 URI, the namespace separator character, and the local part of the 0246 name. If the namespace separator is '\0' then the namespace URI 0247 and the local part will be concatenated without any separator. 0248 It is a programming error to use the separator '\0' with namespace 0249 triplets (see XML_SetReturnNSTriplet). 0250 If a namespace separator is chosen that can be part of a URI or 0251 part of an XML name, splitting an expanded name back into its 0252 1, 2 or 3 original parts on application level in the element handler 0253 may end up vulnerable, so these are advised against; sane choices for 0254 a namespace separator are e.g. '\n' (line feed) and '|' (pipe). 0255 0256 Note that Expat does not validate namespace URIs (beyond encoding) 0257 against RFC 3986 today (and is not required to do so with regard to 0258 the XML 1.0 namespaces specification) but it may start doing that 0259 in future releases. Before that, an application using Expat must 0260 be ready to receive namespace URIs containing non-URI characters. 0261 */ 0262 XMLPARSEAPI(XML_Parser) 0263 XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator); 0264 0265 /* Constructs a new parser using the memory management suite referred to 0266 by memsuite. If memsuite is NULL, then use the standard library memory 0267 suite. If namespaceSeparator is non-NULL it creates a parser with 0268 namespace processing as described above. The character pointed at 0269 will serve as the namespace separator. 0270 0271 All further memory operations used for the created parser will come from 0272 the given suite. 0273 */ 0274 XMLPARSEAPI(XML_Parser) 0275 XML_ParserCreate_MM(const XML_Char *encoding, 0276 const XML_Memory_Handling_Suite *memsuite, 0277 const XML_Char *namespaceSeparator); 0278 0279 /* Prepare a parser object to be reused. This is particularly 0280 valuable when memory allocation overhead is disproportionately high, 0281 such as when a large number of small documents need to be parsed. 0282 All handlers are cleared from the parser, except for the 0283 unknownEncodingHandler. The parser's external state is re-initialized 0284 except for the values of ns and ns_triplets. 0285 0286 Added in Expat 1.95.3. 0287 */ 0288 XMLPARSEAPI(XML_Bool) 0289 XML_ParserReset(XML_Parser parser, const XML_Char *encoding); 0290 0291 /* atts is array of name/value pairs, terminated by 0; 0292 names and values are 0 terminated. 0293 */ 0294 typedef void(XMLCALL *XML_StartElementHandler)(void *userData, 0295 const XML_Char *name, 0296 const XML_Char **atts); 0297 0298 typedef void(XMLCALL *XML_EndElementHandler)(void *userData, 0299 const XML_Char *name); 0300 0301 /* s is not 0 terminated. */ 0302 typedef void(XMLCALL *XML_CharacterDataHandler)(void *userData, 0303 const XML_Char *s, int len); 0304 0305 /* target and data are 0 terminated */ 0306 typedef void(XMLCALL *XML_ProcessingInstructionHandler)(void *userData, 0307 const XML_Char *target, 0308 const XML_Char *data); 0309 0310 /* data is 0 terminated */ 0311 typedef void(XMLCALL *XML_CommentHandler)(void *userData, const XML_Char *data); 0312 0313 typedef void(XMLCALL *XML_StartCdataSectionHandler)(void *userData); 0314 typedef void(XMLCALL *XML_EndCdataSectionHandler)(void *userData); 0315 0316 /* This is called for any characters in the XML document for which 0317 there is no applicable handler. This includes both characters that 0318 are part of markup which is of a kind that is not reported 0319 (comments, markup declarations), or characters that are part of a 0320 construct which could be reported but for which no handler has been 0321 supplied. The characters are passed exactly as they were in the XML 0322 document except that they will be encoded in UTF-8 or UTF-16. 0323 Line boundaries are not normalized. Note that a byte order mark 0324 character is not passed to the default handler. There are no 0325 guarantees about how characters are divided between calls to the 0326 default handler: for example, a comment might be split between 0327 multiple calls. 0328 */ 0329 typedef void(XMLCALL *XML_DefaultHandler)(void *userData, const XML_Char *s, 0330 int len); 0331 0332 /* This is called for the start of the DOCTYPE declaration, before 0333 any DTD or internal subset is parsed. 0334 */ 0335 typedef void(XMLCALL *XML_StartDoctypeDeclHandler)(void *userData, 0336 const XML_Char *doctypeName, 0337 const XML_Char *sysid, 0338 const XML_Char *pubid, 0339 int has_internal_subset); 0340 0341 /* This is called for the end of the DOCTYPE declaration when the 0342 closing > is encountered, but after processing any external 0343 subset. 0344 */ 0345 typedef void(XMLCALL *XML_EndDoctypeDeclHandler)(void *userData); 0346 0347 /* This is called for entity declarations. The is_parameter_entity 0348 argument will be non-zero if the entity is a parameter entity, zero 0349 otherwise. 0350 0351 For internal entities (<!ENTITY foo "bar">), value will 0352 be non-NULL and systemId, publicID, and notationName will be NULL. 0353 The value string is NOT null-terminated; the length is provided in 0354 the value_length argument. Since it is legal to have zero-length 0355 values, do not use this argument to test for internal entities. 0356 0357 For external entities, value will be NULL and systemId will be 0358 non-NULL. The publicId argument will be NULL unless a public 0359 identifier was provided. The notationName argument will have a 0360 non-NULL value only for unparsed entity declarations. 0361 0362 Note that is_parameter_entity can't be changed to XML_Bool, since 0363 that would break binary compatibility. 0364 */ 0365 typedef void(XMLCALL *XML_EntityDeclHandler)( 0366 void *userData, const XML_Char *entityName, int is_parameter_entity, 0367 const XML_Char *value, int value_length, const XML_Char *base, 0368 const XML_Char *systemId, const XML_Char *publicId, 0369 const XML_Char *notationName); 0370 0371 XMLPARSEAPI(void) 0372 XML_SetEntityDeclHandler(XML_Parser parser, XML_EntityDeclHandler handler); 0373 0374 /* OBSOLETE -- OBSOLETE -- OBSOLETE 0375 This handler has been superseded by the EntityDeclHandler above. 0376 It is provided here for backward compatibility. 0377 0378 This is called for a declaration of an unparsed (NDATA) entity. 0379 The base argument is whatever was set by XML_SetBase. The 0380 entityName, systemId and notationName arguments will never be 0381 NULL. The other arguments may be. 0382 */ 0383 typedef void(XMLCALL *XML_UnparsedEntityDeclHandler)( 0384 void *userData, const XML_Char *entityName, const XML_Char *base, 0385 const XML_Char *systemId, const XML_Char *publicId, 0386 const XML_Char *notationName); 0387 0388 /* This is called for a declaration of notation. The base argument is 0389 whatever was set by XML_SetBase. The notationName will never be 0390 NULL. The other arguments can be. 0391 */ 0392 typedef void(XMLCALL *XML_NotationDeclHandler)(void *userData, 0393 const XML_Char *notationName, 0394 const XML_Char *base, 0395 const XML_Char *systemId, 0396 const XML_Char *publicId); 0397 0398 /* When namespace processing is enabled, these are called once for 0399 each namespace declaration. The call to the start and end element 0400 handlers occur between the calls to the start and end namespace 0401 declaration handlers. For an xmlns attribute, prefix will be 0402 NULL. For an xmlns="" attribute, uri will be NULL. 0403 */ 0404 typedef void(XMLCALL *XML_StartNamespaceDeclHandler)(void *userData, 0405 const XML_Char *prefix, 0406 const XML_Char *uri); 0407 0408 typedef void(XMLCALL *XML_EndNamespaceDeclHandler)(void *userData, 0409 const XML_Char *prefix); 0410 0411 /* This is called if the document is not standalone, that is, it has an 0412 external subset or a reference to a parameter entity, but does not 0413 have standalone="yes". If this handler returns XML_STATUS_ERROR, 0414 then processing will not continue, and the parser will return a 0415 XML_ERROR_NOT_STANDALONE error. 0416 If parameter entity parsing is enabled, then in addition to the 0417 conditions above this handler will only be called if the referenced 0418 entity was actually read. 0419 */ 0420 typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData); 0421 0422 /* This is called for a reference to an external parsed general 0423 entity. The referenced entity is not automatically parsed. The 0424 application can parse it immediately or later using 0425 XML_ExternalEntityParserCreate. 0426 0427 The parser argument is the parser parsing the entity containing the 0428 reference; it can be passed as the parser argument to 0429 XML_ExternalEntityParserCreate. The systemId argument is the 0430 system identifier as specified in the entity declaration; it will 0431 not be NULL. 0432 0433 The base argument is the system identifier that should be used as 0434 the base for resolving systemId if systemId was relative; this is 0435 set by XML_SetBase; it may be NULL. 0436 0437 The publicId argument is the public identifier as specified in the 0438 entity declaration, or NULL if none was specified; the whitespace 0439 in the public identifier will have been normalized as required by 0440 the XML spec. 0441 0442 The context argument specifies the parsing context in the format 0443 expected by the context argument to XML_ExternalEntityParserCreate; 0444 context is valid only until the handler returns, so if the 0445 referenced entity is to be parsed later, it must be copied. 0446 context is NULL only when the entity is a parameter entity. 0447 0448 The handler should return XML_STATUS_ERROR if processing should not 0449 continue because of a fatal error in the handling of the external 0450 entity. In this case the calling parser will return an 0451 XML_ERROR_EXTERNAL_ENTITY_HANDLING error. 0452 0453 Note that unlike other handlers the first argument is the parser, 0454 not userData. 0455 */ 0456 typedef int(XMLCALL *XML_ExternalEntityRefHandler)(XML_Parser parser, 0457 const XML_Char *context, 0458 const XML_Char *base, 0459 const XML_Char *systemId, 0460 const XML_Char *publicId); 0461 0462 /* This is called in two situations: 0463 1) An entity reference is encountered for which no declaration 0464 has been read *and* this is not an error. 0465 2) An internal entity reference is read, but not expanded, because 0466 XML_SetDefaultHandler has been called. 0467 Note: skipped parameter entities in declarations and skipped general 0468 entities in attribute values cannot be reported, because 0469 the event would be out of sync with the reporting of the 0470 declarations or attribute values 0471 */ 0472 typedef void(XMLCALL *XML_SkippedEntityHandler)(void *userData, 0473 const XML_Char *entityName, 0474 int is_parameter_entity); 0475 0476 /* This structure is filled in by the XML_UnknownEncodingHandler to 0477 provide information to the parser about encodings that are unknown 0478 to the parser. 0479 0480 The map[b] member gives information about byte sequences whose 0481 first byte is b. 0482 0483 If map[b] is c where c is >= 0, then b by itself encodes the 0484 Unicode scalar value c. 0485 0486 If map[b] is -1, then the byte sequence is malformed. 0487 0488 If map[b] is -n, where n >= 2, then b is the first byte of an 0489 n-byte sequence that encodes a single Unicode scalar value. 0490 0491 The data member will be passed as the first argument to the convert 0492 function. 0493 0494 The convert function is used to convert multibyte sequences; s will 0495 point to a n-byte sequence where map[(unsigned char)*s] == -n. The 0496 convert function must return the Unicode scalar value represented 0497 by this byte sequence or -1 if the byte sequence is malformed. 0498 0499 The convert function may be NULL if the encoding is a single-byte 0500 encoding, that is if map[b] >= -1 for all bytes b. 0501 0502 When the parser is finished with the encoding, then if release is 0503 not NULL, it will call release passing it the data member; once 0504 release has been called, the convert function will not be called 0505 again. 0506 0507 Expat places certain restrictions on the encodings that are supported 0508 using this mechanism. 0509 0510 1. Every ASCII character that can appear in a well-formed XML document, 0511 other than the characters 0512 0513 $@\^`{}~ 0514 0515 must be represented by a single byte, and that byte must be the 0516 same byte that represents that character in ASCII. 0517 0518 2. No character may require more than 4 bytes to encode. 0519 0520 3. All characters encoded must have Unicode scalar values <= 0521 0xFFFF, (i.e., characters that would be encoded by surrogates in 0522 UTF-16 are not allowed). Note that this restriction doesn't 0523 apply to the built-in support for UTF-8 and UTF-16. 0524 0525 4. No Unicode character may be encoded by more than one distinct 0526 sequence of bytes. 0527 */ 0528 typedef struct { 0529 int map[256]; 0530 void *data; 0531 int(XMLCALL *convert)(void *data, const char *s); 0532 void(XMLCALL *release)(void *data); 0533 } XML_Encoding; 0534 0535 /* This is called for an encoding that is unknown to the parser. 0536 0537 The encodingHandlerData argument is that which was passed as the 0538 second argument to XML_SetUnknownEncodingHandler. 0539 0540 The name argument gives the name of the encoding as specified in 0541 the encoding declaration. 0542 0543 If the callback can provide information about the encoding, it must 0544 fill in the XML_Encoding structure, and return XML_STATUS_OK. 0545 Otherwise it must return XML_STATUS_ERROR. 0546 0547 If info does not describe a suitable encoding, then the parser will 0548 return an XML_ERROR_UNKNOWN_ENCODING error. 0549 */ 0550 typedef int(XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData, 0551 const XML_Char *name, 0552 XML_Encoding *info); 0553 0554 XMLPARSEAPI(void) 0555 XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start, 0556 XML_EndElementHandler end); 0557 0558 XMLPARSEAPI(void) 0559 XML_SetStartElementHandler(XML_Parser parser, XML_StartElementHandler handler); 0560 0561 XMLPARSEAPI(void) 0562 XML_SetEndElementHandler(XML_Parser parser, XML_EndElementHandler handler); 0563 0564 XMLPARSEAPI(void) 0565 XML_SetCharacterDataHandler(XML_Parser parser, 0566 XML_CharacterDataHandler handler); 0567 0568 XMLPARSEAPI(void) 0569 XML_SetProcessingInstructionHandler(XML_Parser parser, 0570 XML_ProcessingInstructionHandler handler); 0571 XMLPARSEAPI(void) 0572 XML_SetCommentHandler(XML_Parser parser, XML_CommentHandler handler); 0573 0574 XMLPARSEAPI(void) 0575 XML_SetCdataSectionHandler(XML_Parser parser, 0576 XML_StartCdataSectionHandler start, 0577 XML_EndCdataSectionHandler end); 0578 0579 XMLPARSEAPI(void) 0580 XML_SetStartCdataSectionHandler(XML_Parser parser, 0581 XML_StartCdataSectionHandler start); 0582 0583 XMLPARSEAPI(void) 0584 XML_SetEndCdataSectionHandler(XML_Parser parser, 0585 XML_EndCdataSectionHandler end); 0586 0587 /* This sets the default handler and also inhibits expansion of 0588 internal entities. These entity references will be passed to the 0589 default handler, or to the skipped entity handler, if one is set. 0590 */ 0591 XMLPARSEAPI(void) 0592 XML_SetDefaultHandler(XML_Parser parser, XML_DefaultHandler handler); 0593 0594 /* This sets the default handler but does not inhibit expansion of 0595 internal entities. The entity reference will not be passed to the 0596 default handler. 0597 */ 0598 XMLPARSEAPI(void) 0599 XML_SetDefaultHandlerExpand(XML_Parser parser, XML_DefaultHandler handler); 0600 0601 XMLPARSEAPI(void) 0602 XML_SetDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start, 0603 XML_EndDoctypeDeclHandler end); 0604 0605 XMLPARSEAPI(void) 0606 XML_SetStartDoctypeDeclHandler(XML_Parser parser, 0607 XML_StartDoctypeDeclHandler start); 0608 0609 XMLPARSEAPI(void) 0610 XML_SetEndDoctypeDeclHandler(XML_Parser parser, XML_EndDoctypeDeclHandler end); 0611 0612 XMLPARSEAPI(void) 0613 XML_SetUnparsedEntityDeclHandler(XML_Parser parser, 0614 XML_UnparsedEntityDeclHandler handler); 0615 0616 XMLPARSEAPI(void) 0617 XML_SetNotationDeclHandler(XML_Parser parser, XML_NotationDeclHandler handler); 0618 0619 XMLPARSEAPI(void) 0620 XML_SetNamespaceDeclHandler(XML_Parser parser, 0621 XML_StartNamespaceDeclHandler start, 0622 XML_EndNamespaceDeclHandler end); 0623 0624 XMLPARSEAPI(void) 0625 XML_SetStartNamespaceDeclHandler(XML_Parser parser, 0626 XML_StartNamespaceDeclHandler start); 0627 0628 XMLPARSEAPI(void) 0629 XML_SetEndNamespaceDeclHandler(XML_Parser parser, 0630 XML_EndNamespaceDeclHandler end); 0631 0632 XMLPARSEAPI(void) 0633 XML_SetNotStandaloneHandler(XML_Parser parser, 0634 XML_NotStandaloneHandler handler); 0635 0636 XMLPARSEAPI(void) 0637 XML_SetExternalEntityRefHandler(XML_Parser parser, 0638 XML_ExternalEntityRefHandler handler); 0639 0640 /* If a non-NULL value for arg is specified here, then it will be 0641 passed as the first argument to the external entity ref handler 0642 instead of the parser object. 0643 */ 0644 XMLPARSEAPI(void) 0645 XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg); 0646 0647 XMLPARSEAPI(void) 0648 XML_SetSkippedEntityHandler(XML_Parser parser, 0649 XML_SkippedEntityHandler handler); 0650 0651 XMLPARSEAPI(void) 0652 XML_SetUnknownEncodingHandler(XML_Parser parser, 0653 XML_UnknownEncodingHandler handler, 0654 void *encodingHandlerData); 0655 0656 /* This can be called within a handler for a start element, end 0657 element, processing instruction or character data. It causes the 0658 corresponding markup to be passed to the default handler. 0659 */ 0660 XMLPARSEAPI(void) 0661 XML_DefaultCurrent(XML_Parser parser); 0662 0663 /* If do_nst is non-zero, and namespace processing is in effect, and 0664 a name has a prefix (i.e. an explicit namespace qualifier) then 0665 that name is returned as a triplet in a single string separated by 0666 the separator character specified when the parser was created: URI 0667 + sep + local_name + sep + prefix. 0668 0669 If do_nst is zero, then namespace information is returned in the 0670 default manner (URI + sep + local_name) whether or not the name 0671 has a prefix. 0672 0673 Note: Calling XML_SetReturnNSTriplet after XML_Parse or 0674 XML_ParseBuffer has no effect. 0675 */ 0676 0677 XMLPARSEAPI(void) 0678 XML_SetReturnNSTriplet(XML_Parser parser, int do_nst); 0679 0680 /* This value is passed as the userData argument to callbacks. */ 0681 XMLPARSEAPI(void) 0682 XML_SetUserData(XML_Parser parser, void *userData); 0683 0684 /* Returns the last value set by XML_SetUserData or NULL. */ 0685 # define XML_GetUserData(parser) (*(void **)(parser)) 0686 0687 /* This is equivalent to supplying an encoding argument to 0688 XML_ParserCreate. On success XML_SetEncoding returns non-zero, 0689 zero otherwise. 0690 Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer 0691 has no effect and returns XML_STATUS_ERROR. 0692 */ 0693 XMLPARSEAPI(enum XML_Status) 0694 XML_SetEncoding(XML_Parser parser, const XML_Char *encoding); 0695 0696 /* If this function is called, then the parser will be passed as the 0697 first argument to callbacks instead of userData. The userData will 0698 still be accessible using XML_GetUserData. 0699 */ 0700 XMLPARSEAPI(void) 0701 XML_UseParserAsHandlerArg(XML_Parser parser); 0702 0703 /* If useDTD == XML_TRUE is passed to this function, then the parser 0704 will assume that there is an external subset, even if none is 0705 specified in the document. In such a case the parser will call the 0706 externalEntityRefHandler with a value of NULL for the systemId 0707 argument (the publicId and context arguments will be NULL as well). 0708 Note: For the purpose of checking WFC: Entity Declared, passing 0709 useDTD == XML_TRUE will make the parser behave as if the document 0710 had a DTD with an external subset. 0711 Note: If this function is called, then this must be done before 0712 the first call to XML_Parse or XML_ParseBuffer, since it will 0713 have no effect after that. Returns 0714 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING. 0715 Note: If the document does not have a DOCTYPE declaration at all, 0716 then startDoctypeDeclHandler and endDoctypeDeclHandler will not 0717 be called, despite an external subset being parsed. 0718 Note: If XML_DTD is not defined when Expat is compiled, returns 0719 XML_ERROR_FEATURE_REQUIRES_XML_DTD. 0720 Note: If parser == NULL, returns XML_ERROR_INVALID_ARGUMENT. 0721 */ 0722 XMLPARSEAPI(enum XML_Error) 0723 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD); 0724 0725 /* Sets the base to be used for resolving relative URIs in system 0726 identifiers in declarations. Resolving relative identifiers is 0727 left to the application: this value will be passed through as the 0728 base argument to the XML_ExternalEntityRefHandler, 0729 XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base 0730 argument will be copied. Returns XML_STATUS_ERROR if out of memory, 0731 XML_STATUS_OK otherwise. 0732 */ 0733 XMLPARSEAPI(enum XML_Status) 0734 XML_SetBase(XML_Parser parser, const XML_Char *base); 0735 0736 XMLPARSEAPI(const XML_Char *) 0737 XML_GetBase(XML_Parser parser); 0738 0739 /* Returns the number of the attribute/value pairs passed in last call 0740 to the XML_StartElementHandler that were specified in the start-tag 0741 rather than defaulted. Each attribute/value pair counts as 2; thus 0742 this corresponds to an index into the atts array passed to the 0743 XML_StartElementHandler. Returns -1 if parser == NULL. 0744 */ 0745 XMLPARSEAPI(int) 0746 XML_GetSpecifiedAttributeCount(XML_Parser parser); 0747 0748 /* Returns the index of the ID attribute passed in the last call to 0749 XML_StartElementHandler, or -1 if there is no ID attribute or 0750 parser == NULL. Each attribute/value pair counts as 2; thus this 0751 corresponds to an index into the atts array passed to the 0752 XML_StartElementHandler. 0753 */ 0754 XMLPARSEAPI(int) 0755 XML_GetIdAttributeIndex(XML_Parser parser); 0756 0757 # ifdef XML_ATTR_INFO 0758 /* Source file byte offsets for the start and end of attribute names and values. 0759 The value indices are exclusive of surrounding quotes; thus in a UTF-8 source 0760 file an attribute value of "blah" will yield: 0761 info->valueEnd - info->valueStart = 4 bytes. 0762 */ 0763 typedef struct { 0764 XML_Index nameStart; /* Offset to beginning of the attribute name. */ 0765 XML_Index nameEnd; /* Offset after the attribute name's last byte. */ 0766 XML_Index valueStart; /* Offset to beginning of the attribute value. */ 0767 XML_Index valueEnd; /* Offset after the attribute value's last byte. */ 0768 } XML_AttrInfo; 0769 0770 /* Returns an array of XML_AttrInfo structures for the attribute/value pairs 0771 passed in last call to the XML_StartElementHandler that were specified 0772 in the start-tag rather than defaulted. Each attribute/value pair counts 0773 as 1; thus the number of entries in the array is 0774 XML_GetSpecifiedAttributeCount(parser) / 2. 0775 */ 0776 XMLPARSEAPI(const XML_AttrInfo *) 0777 XML_GetAttributeInfo(XML_Parser parser); 0778 # endif 0779 0780 /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is 0781 detected. The last call to XML_Parse must have isFinal true; len 0782 may be zero for this call (or any other). 0783 0784 Though the return values for these functions has always been 0785 described as a Boolean value, the implementation, at least for the 0786 1.95.x series, has always returned exactly one of the XML_Status 0787 values. 0788 */ 0789 XMLPARSEAPI(enum XML_Status) 0790 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal); 0791 0792 XMLPARSEAPI(void *) 0793 XML_GetBuffer(XML_Parser parser, int len); 0794 0795 XMLPARSEAPI(enum XML_Status) 0796 XML_ParseBuffer(XML_Parser parser, int len, int isFinal); 0797 0798 /* Stops parsing, causing XML_Parse() or XML_ParseBuffer() to return. 0799 Must be called from within a call-back handler, except when aborting 0800 (resumable = 0) an already suspended parser. Some call-backs may 0801 still follow because they would otherwise get lost. Examples: 0802 - endElementHandler() for empty elements when stopped in 0803 startElementHandler(), 0804 - endNameSpaceDeclHandler() when stopped in endElementHandler(), 0805 and possibly others. 0806 0807 Can be called from most handlers, including DTD related call-backs, 0808 except when parsing an external parameter entity and resumable != 0. 0809 Returns XML_STATUS_OK when successful, XML_STATUS_ERROR otherwise. 0810 Possible error codes: 0811 - XML_ERROR_SUSPENDED: when suspending an already suspended parser. 0812 - XML_ERROR_FINISHED: when the parser has already finished. 0813 - XML_ERROR_SUSPEND_PE: when suspending while parsing an external PE. 0814 0815 When resumable != 0 (true) then parsing is suspended, that is, 0816 XML_Parse() and XML_ParseBuffer() return XML_STATUS_SUSPENDED. 0817 Otherwise, parsing is aborted, that is, XML_Parse() and XML_ParseBuffer() 0818 return XML_STATUS_ERROR with error code XML_ERROR_ABORTED. 0819 0820 *Note*: 0821 This will be applied to the current parser instance only, that is, if 0822 there is a parent parser then it will continue parsing when the 0823 externalEntityRefHandler() returns. It is up to the implementation of 0824 the externalEntityRefHandler() to call XML_StopParser() on the parent 0825 parser (recursively), if one wants to stop parsing altogether. 0826 0827 When suspended, parsing can be resumed by calling XML_ResumeParser(). 0828 */ 0829 XMLPARSEAPI(enum XML_Status) 0830 XML_StopParser(XML_Parser parser, XML_Bool resumable); 0831 0832 /* Resumes parsing after it has been suspended with XML_StopParser(). 0833 Must not be called from within a handler call-back. Returns same 0834 status codes as XML_Parse() or XML_ParseBuffer(). 0835 Additional error code XML_ERROR_NOT_SUSPENDED possible. 0836 0837 *Note*: 0838 This must be called on the most deeply nested child parser instance 0839 first, and on its parent parser only after the child parser has finished, 0840 to be applied recursively until the document entity's parser is restarted. 0841 That is, the parent parser will not resume by itself and it is up to the 0842 application to call XML_ResumeParser() on it at the appropriate moment. 0843 */ 0844 XMLPARSEAPI(enum XML_Status) 0845 XML_ResumeParser(XML_Parser parser); 0846 0847 enum XML_Parsing { XML_INITIALIZED, XML_PARSING, XML_FINISHED, XML_SUSPENDED }; 0848 0849 typedef struct { 0850 enum XML_Parsing parsing; 0851 XML_Bool finalBuffer; 0852 } XML_ParsingStatus; 0853 0854 /* Returns status of parser with respect to being initialized, parsing, 0855 finished, or suspended and processing the final buffer. 0856 XXX XML_Parse() and XML_ParseBuffer() should return XML_ParsingStatus, 0857 XXX with XML_FINISHED_OK or XML_FINISHED_ERROR replacing XML_FINISHED 0858 */ 0859 XMLPARSEAPI(void) 0860 XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status); 0861 0862 /* Creates an XML_Parser object that can parse an external general 0863 entity; context is a '\0'-terminated string specifying the parse 0864 context; encoding is a '\0'-terminated string giving the name of 0865 the externally specified encoding, or NULL if there is no 0866 externally specified encoding. The context string consists of a 0867 sequence of tokens separated by formfeeds (\f); a token consisting 0868 of a name specifies that the general entity of the name is open; a 0869 token of the form prefix=uri specifies the namespace for a 0870 particular prefix; a token of the form =uri specifies the default 0871 namespace. This can be called at any point after the first call to 0872 an ExternalEntityRefHandler so longer as the parser has not yet 0873 been freed. The new parser is completely independent and may 0874 safely be used in a separate thread. The handlers and userData are 0875 initialized from the parser argument. Returns NULL if out of memory. 0876 Otherwise returns a new XML_Parser object. 0877 */ 0878 XMLPARSEAPI(XML_Parser) 0879 XML_ExternalEntityParserCreate(XML_Parser parser, const XML_Char *context, 0880 const XML_Char *encoding); 0881 0882 enum XML_ParamEntityParsing { 0883 XML_PARAM_ENTITY_PARSING_NEVER, 0884 XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE, 0885 XML_PARAM_ENTITY_PARSING_ALWAYS 0886 }; 0887 0888 /* Controls parsing of parameter entities (including the external DTD 0889 subset). If parsing of parameter entities is enabled, then 0890 references to external parameter entities (including the external 0891 DTD subset) will be passed to the handler set with 0892 XML_SetExternalEntityRefHandler. The context passed will be 0. 0893 0894 Unlike external general entities, external parameter entities can 0895 only be parsed synchronously. If the external parameter entity is 0896 to be parsed, it must be parsed during the call to the external 0897 entity ref handler: the complete sequence of 0898 XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and 0899 XML_ParserFree calls must be made during this call. After 0900 XML_ExternalEntityParserCreate has been called to create the parser 0901 for the external parameter entity (context must be 0 for this 0902 call), it is illegal to make any calls on the old parser until 0903 XML_ParserFree has been called on the newly created parser. 0904 If the library has been compiled without support for parameter 0905 entity parsing (ie without XML_DTD being defined), then 0906 XML_SetParamEntityParsing will return 0 if parsing of parameter 0907 entities is requested; otherwise it will return non-zero. 0908 Note: If XML_SetParamEntityParsing is called after XML_Parse or 0909 XML_ParseBuffer, then it has no effect and will always return 0. 0910 Note: If parser == NULL, the function will do nothing and return 0. 0911 */ 0912 XMLPARSEAPI(int) 0913 XML_SetParamEntityParsing(XML_Parser parser, 0914 enum XML_ParamEntityParsing parsing); 0915 0916 /* Sets the hash salt to use for internal hash calculations. 0917 Helps in preventing DoS attacks based on predicting hash 0918 function behavior. This must be called before parsing is started. 0919 Returns 1 if successful, 0 when called after parsing has started. 0920 Note: If parser == NULL, the function will do nothing and return 0. 0921 DEPRECATED since Expat 2.8.0. 0922 */ 0923 XMLPARSEAPI(int) 0924 XML_SetHashSalt(XML_Parser parser, unsigned long hash_salt); 0925 0926 /* Sets the hash salt to use for internal hash calculations. 0927 Helps in preventing DoS attacks based on predicting hash function behavior. 0928 This must be called before parsing is started. 0929 Returns XML_TRUE if successful, XML_FALSE when called after parsing has 0930 started or when parser is NULL. 0931 Added in Expat 2.8.0. 0932 */ 0933 XMLPARSEAPI(XML_Bool) 0934 XML_SetHashSalt16Bytes(XML_Parser parser, const uint8_t entropy[16]); 0935 0936 /* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then 0937 XML_GetErrorCode returns information about the error. 0938 */ 0939 XMLPARSEAPI(enum XML_Error) 0940 XML_GetErrorCode(XML_Parser parser); 0941 0942 /* These functions return information about the current parse 0943 location. They may be called from any callback called to report 0944 some parse event; in this case the location is the location of the 0945 first of the sequence of characters that generated the event. When 0946 called from callbacks generated by declarations in the document 0947 prologue, the location identified isn't as neatly defined, but will 0948 be within the relevant markup. When called outside of the callback 0949 functions, the position indicated will be just past the last parse 0950 event (regardless of whether there was an associated callback). 0951 0952 They may also be called after returning from a call to XML_Parse 0953 or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then 0954 the location is the location of the character at which the error 0955 was detected; otherwise the location is the location of the last 0956 parse event, as described above. 0957 0958 Note: XML_GetCurrentLineNumber and XML_GetCurrentColumnNumber 0959 return 0 to indicate an error. 0960 Note: XML_GetCurrentByteIndex returns -1 to indicate an error. 0961 */ 0962 XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser); 0963 XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser); 0964 XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser); 0965 0966 /* Return the number of bytes in the current event. 0967 Returns 0 if the event is in an internal entity. 0968 */ 0969 XMLPARSEAPI(int) 0970 XML_GetCurrentByteCount(XML_Parser parser); 0971 0972 /* If XML_CONTEXT_BYTES is >=1, returns the input buffer, sets 0973 the integer pointed to by offset to the offset within this buffer 0974 of the current parse position, and sets the integer pointed to by size 0975 to the size of this buffer (the number of input bytes). Otherwise 0976 returns a NULL pointer. Also returns a NULL pointer if a parse isn't 0977 active. 0978 0979 NOTE: The character pointer returned should not be used outside 0980 the handler that makes the call. 0981 */ 0982 XMLPARSEAPI(const char *) 0983 XML_GetInputContext(XML_Parser parser, int *offset, int *size); 0984 0985 /* For backwards compatibility with previous versions. */ 0986 # define XML_GetErrorLineNumber XML_GetCurrentLineNumber 0987 # define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber 0988 # define XML_GetErrorByteIndex XML_GetCurrentByteIndex 0989 0990 /* Frees the content model passed to the element declaration handler */ 0991 XMLPARSEAPI(void) 0992 XML_FreeContentModel(XML_Parser parser, XML_Content *model); 0993 0994 /* Exposing the memory handling functions used in Expat */ 0995 XMLPARSEAPI(void *) 0996 XML_ATTR_MALLOC 0997 XML_ATTR_ALLOC_SIZE(2) 0998 XML_MemMalloc(XML_Parser parser, size_t size); 0999 1000 XMLPARSEAPI(void *) 1001 XML_ATTR_ALLOC_SIZE(3) 1002 XML_MemRealloc(XML_Parser parser, void *ptr, size_t size); 1003 1004 XMLPARSEAPI(void) 1005 XML_MemFree(XML_Parser parser, void *ptr); 1006 1007 /* Frees memory used by the parser. */ 1008 XMLPARSEAPI(void) 1009 XML_ParserFree(XML_Parser parser); 1010 1011 /* Returns a string describing the error. */ 1012 XMLPARSEAPI(const XML_LChar *) 1013 XML_ErrorString(enum XML_Error code); 1014 1015 /* Return a string containing the version number of this expat */ 1016 XMLPARSEAPI(const XML_LChar *) 1017 XML_ExpatVersion(void); 1018 1019 typedef struct { 1020 int major; 1021 int minor; 1022 int micro; 1023 } XML_Expat_Version; 1024 1025 /* Return an XML_Expat_Version structure containing numeric version 1026 number information for this version of expat. 1027 */ 1028 XMLPARSEAPI(XML_Expat_Version) 1029 XML_ExpatVersionInfo(void); 1030 1031 /* Added in Expat 1.95.5. */ 1032 enum XML_FeatureEnum { 1033 XML_FEATURE_END = 0, 1034 XML_FEATURE_UNICODE, 1035 XML_FEATURE_UNICODE_WCHAR_T, 1036 XML_FEATURE_DTD, 1037 XML_FEATURE_CONTEXT_BYTES, 1038 XML_FEATURE_MIN_SIZE, 1039 XML_FEATURE_SIZEOF_XML_CHAR, 1040 XML_FEATURE_SIZEOF_XML_LCHAR, 1041 XML_FEATURE_NS, 1042 XML_FEATURE_LARGE_SIZE, 1043 XML_FEATURE_ATTR_INFO, 1044 /* Added in Expat 2.4.0. */ 1045 XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT, 1046 XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT, 1047 /* Added in Expat 2.6.0. */ 1048 XML_FEATURE_GE, 1049 /* Added in Expat 2.7.2. */ 1050 XML_FEATURE_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION_DEFAULT, 1051 XML_FEATURE_ALLOC_TRACKER_ACTIVATION_THRESHOLD_DEFAULT, 1052 /* Additional features must be added to the end of this enum. */ 1053 }; 1054 1055 typedef struct { 1056 enum XML_FeatureEnum feature; 1057 const XML_LChar *name; 1058 long int value; 1059 } XML_Feature; 1060 1061 XMLPARSEAPI(const XML_Feature *) 1062 XML_GetFeatureList(void); 1063 1064 # if defined(XML_DTD) || (defined(XML_GE) && XML_GE == 1) 1065 /* Added in Expat 2.4.0 for XML_DTD defined and 1066 * added in Expat 2.6.0 for XML_GE == 1. */ 1067 XMLPARSEAPI(XML_Bool) 1068 XML_SetBillionLaughsAttackProtectionMaximumAmplification( 1069 XML_Parser parser, float maximumAmplificationFactor); 1070 1071 /* Added in Expat 2.4.0 for XML_DTD defined and 1072 * added in Expat 2.6.0 for XML_GE == 1. */ 1073 XMLPARSEAPI(XML_Bool) 1074 XML_SetBillionLaughsAttackProtectionActivationThreshold( 1075 XML_Parser parser, unsigned long long activationThresholdBytes); 1076 1077 /* Added in Expat 2.7.2. */ 1078 XMLPARSEAPI(XML_Bool) 1079 XML_SetAllocTrackerMaximumAmplification(XML_Parser parser, 1080 float maximumAmplificationFactor); 1081 1082 /* Added in Expat 2.7.2. */ 1083 XMLPARSEAPI(XML_Bool) 1084 XML_SetAllocTrackerActivationThreshold( 1085 XML_Parser parser, unsigned long long activationThresholdBytes); 1086 # endif 1087 1088 /* Added in Expat 2.6.0. */ 1089 XMLPARSEAPI(XML_Bool) 1090 XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled); 1091 1092 /* Expat follows the semantic versioning convention. 1093 See https://semver.org 1094 */ 1095 # define XML_MAJOR_VERSION 2 1096 # define XML_MINOR_VERSION 8 1097 # define XML_MICRO_VERSION 1 1098 1099 # ifdef __cplusplus 1100 } 1101 # endif 1102 1103 #endif /* not Expat_INCLUDED */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|