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