parser/expat/lib/expat.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial