expat.h 43 KB

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