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