expat.h 43 KB

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