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