]> git.saurik.com Git - wxWidgets.git/blob - src/expat/lib/expat.h
applied Mandrake patch to expat, fixes compilation
[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 /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
107 detected. The last call to XML_Parse must have isFinal true; len
108 may be zero for this call (or any other).
109
110 The XML_Status enum gives the possible return values for the
111 XML_Parse and XML_ParseBuffer functions. Though the return values
112 for these functions has always been described as a Boolean value,
113 the implementation, at least for the 1.95.x series, has always
114 returned exactly one of these values. The preprocessor #defines
115 are included so this stanza can be added to code that still needs
116 to support older versions of Expat 1.95.x:
117
118 #ifndef XML_STATUS_OK
119 #define XML_STATUS_OK 1
120 #define XML_STATUS_ERROR 0
121 #endif
122
123 Otherwise, the #define hackery is quite ugly and would have been dropped.
124 */
125 enum XML_Status {
126 XML_STATUS_ERROR = 0,
127 #define XML_STATUS_ERROR XML_STATUS_ERROR
128 XML_STATUS_OK = 1
129 #define XML_STATUS_OK XML_STATUS_OK
130 };
131
132 /* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
133 XML_CQUANT_NONE, and the other fields will be zero or NULL.
134 If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
135 numchildren will contain number of elements that may be mixed in
136 and children point to an array of XML_Content cells that will be
137 all of XML_CTYPE_NAME type with no quantification.
138
139 If type == XML_CTYPE_NAME, then the name points to the name, and
140 the numchildren field will be zero and children will be NULL. The
141 quant fields indicates any quantifiers placed on the name.
142
143 CHOICE and SEQ will have name NULL, the number of children in
144 numchildren and children will point, recursively, to an array
145 of XML_Content cells.
146
147 The EMPTY, ANY, and MIXED types will only occur at top level.
148 */
149
150 typedef struct XML_cp XML_Content;
151
152 struct XML_cp {
153 enum XML_Content_Type type;
154 enum XML_Content_Quant quant;
155 XML_Char * name;
156 unsigned int numchildren;
157 XML_Content * children;
158 };
159
160
161 /* This is called for an element declaration. See above for
162 description of the model argument. It's the caller's responsibility
163 to free model when finished with it.
164 */
165 typedef void (*XML_ElementDeclHandler) (void *userData,
166 const XML_Char *name,
167 XML_Content *model);
168
169 XMLPARSEAPI(void)
170 XML_SetElementDeclHandler(XML_Parser parser,
171 XML_ElementDeclHandler eldecl);
172
173 /* The Attlist declaration handler is called for *each* attribute. So
174 a single Attlist declaration with multiple attributes declared will
175 generate multiple calls to this handler. The "default" parameter
176 may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
177 keyword. The "isrequired" parameter will be true and the default
178 value will be NULL in the case of "#REQUIRED". If "isrequired" is
179 true and default is non-NULL, then this is a "#FIXED" default.
180 */
181 typedef void (*XML_AttlistDeclHandler) (void *userData,
182 const XML_Char *elname,
183 const XML_Char *attname,
184 const XML_Char *att_type,
185 const XML_Char *dflt,
186 int isrequired);
187
188 XMLPARSEAPI(void)
189 XML_SetAttlistDeclHandler(XML_Parser parser,
190 XML_AttlistDeclHandler attdecl);
191
192 /* The XML declaration handler is called for *both* XML declarations
193 and text declarations. The way to distinguish is that the version
194 parameter will be NULL for text declarations. The encoding
195 parameter may be NULL for XML declarations. The standalone
196 parameter will be -1, 0, or 1 indicating respectively that there
197 was no standalone parameter in the declaration, that it was given
198 as no, or that it was given as yes.
199 */
200 typedef void (*XML_XmlDeclHandler) (void *userData,
201 const XML_Char *version,
202 const XML_Char *encoding,
203 int standalone);
204
205 XMLPARSEAPI(void)
206 XML_SetXmlDeclHandler(XML_Parser parser,
207 XML_XmlDeclHandler xmldecl);
208
209
210 typedef struct {
211 void *(*malloc_fcn)(size_t size);
212 void *(*realloc_fcn)(void *ptr, size_t size);
213 void (*free_fcn)(void *ptr);
214 } XML_Memory_Handling_Suite;
215
216 /* Constructs a new parser; encoding is the encoding specified by the
217 external protocol or NULL if there is none specified.
218 */
219 XMLPARSEAPI(XML_Parser)
220 XML_ParserCreate(const XML_Char *encoding);
221
222 /* Constructs a new parser and namespace processor. Element type
223 names and attribute names that belong to a namespace will be
224 expanded; unprefixed attribute names are never expanded; unprefixed
225 element type names are expanded only if there is a default
226 namespace. The expanded name is the concatenation of the namespace
227 URI, the namespace separator character, and the local part of the
228 name. If the namespace separator is '\0' then the namespace URI
229 and the local part will be concatenated without any separator.
230 When a namespace is not declared, the name and prefix will be
231 passed through without expansion.
232 */
233 XMLPARSEAPI(XML_Parser)
234 XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
235
236
237 /* Constructs a new parser using the memory management suite referred to
238 by memsuite. If memsuite is NULL, then use the standard library memory
239 suite. If namespaceSeparator is non-NULL it creates a parser with
240 namespace processing as described above. The character pointed at
241 will serve as the namespace separator.
242
243 All further memory operations used for the created parser will come from
244 the given suite.
245 */
246 XMLPARSEAPI(XML_Parser)
247 XML_ParserCreate_MM(const XML_Char *encoding,
248 const XML_Memory_Handling_Suite *memsuite,
249 const XML_Char *namespaceSeparator);
250
251 /* Prepare a parser object to be re-used. This is particularly
252 valuable when memory allocation overhead is disproportionatly high,
253 such as when a large number of small documnents need to be parsed.
254 All handlers are cleared from the parser, except for the
255 unknownEncodingHandler. The parser's external state is re-initialized
256 except for the values of ns and ns_triplets.
257
258 Added in Expat 1.95.3.
259 */
260 XMLPARSEAPI(XML_Bool)
261 XML_ParserReset(XML_Parser parser, const XML_Char *encoding);
262
263 /* atts is array of name/value pairs, terminated by 0;
264 names and values are 0 terminated.
265 */
266 typedef void (*XML_StartElementHandler)(void *userData,
267 const XML_Char *name,
268 const XML_Char **atts);
269
270 typedef void (*XML_EndElementHandler)(void *userData,
271 const XML_Char *name);
272
273
274 /* s is not 0 terminated. */
275 typedef void (*XML_CharacterDataHandler)(void *userData,
276 const XML_Char *s,
277 int len);
278
279 /* target and data are 0 terminated */
280 typedef void (*XML_ProcessingInstructionHandler)(void *userData,
281 const XML_Char *target,
282 const XML_Char *data);
283
284 /* data is 0 terminated */
285 typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data);
286
287 typedef void (*XML_StartCdataSectionHandler)(void *userData);
288 typedef void (*XML_EndCdataSectionHandler)(void *userData);
289
290 /* This is called for any characters in the XML document for which
291 there is no applicable handler. This includes both characters that
292 are part of markup which is of a kind that is not reported
293 (comments, markup declarations), or characters that are part of a
294 construct which could be reported but for which no handler has been
295 supplied. The characters are passed exactly as they were in the XML
296 document except that they will be encoded in UTF-8 or UTF-16.
297 Line boundaries are not normalized. Note that a byte order mark
298 character is not passed to the default handler. There are no
299 guarantees about how characters are divided between calls to the
300 default handler: for example, a comment might be split between
301 multiple calls.
302 */
303 typedef void (*XML_DefaultHandler)(void *userData,
304 const XML_Char *s,
305 int len);
306
307 /* This is called for the start of the DOCTYPE declaration, before
308 any DTD or internal subset is parsed.
309 */
310 typedef void (*XML_StartDoctypeDeclHandler)(void *userData,
311 const XML_Char *doctypeName,
312 const XML_Char *sysid,
313 const XML_Char *pubid,
314 int has_internal_subset);
315
316 /* This is called for the start of the DOCTYPE declaration when the
317 closing > is encountered, but after processing any external
318 subset.
319 */
320 typedef void (*XML_EndDoctypeDeclHandler)(void *userData);
321
322 /* This is called for entity declarations. The is_parameter_entity
323 argument will be non-zero if the entity is a parameter entity, zero
324 otherwise.
325
326 For internal entities (<!ENTITY foo "bar">), value will
327 be non-NULL and systemId, publicID, and notationName will be NULL.
328 The value string is NOT nul-terminated; the length is provided in
329 the value_length argument. Since it is legal to have zero-length
330 values, do not use this argument to test for internal entities.
331
332 For external entities, value will be NULL and systemId will be
333 non-NULL. The publicId argument will be NULL unless a public
334 identifier was provided. The notationName argument will have a
335 non-NULL value only for unparsed entity declarations.
336
337 Note that is_parameter_entity can't be changed to XML_Bool, since
338 that would break binary compatibility.
339 */
340 typedef void (*XML_EntityDeclHandler) (void *userData,
341 const XML_Char *entityName,
342 int is_parameter_entity,
343 const XML_Char *value,
344 int value_length,
345 const XML_Char *base,
346 const XML_Char *systemId,
347 const XML_Char *publicId,
348 const XML_Char *notationName);
349
350 XMLPARSEAPI(void)
351 XML_SetEntityDeclHandler(XML_Parser parser,
352 XML_EntityDeclHandler handler);
353
354 /* OBSOLETE -- OBSOLETE -- OBSOLETE
355 This handler has been superceded by the EntityDeclHandler above.
356 It is provided here for backward compatibility.
357
358 This is called for a declaration of an unparsed (NDATA) entity.
359 The base argument is whatever was set by XML_SetBase. The
360 entityName, systemId and notationName arguments will never be
361 NULL. The other arguments may be.
362 */
363 typedef void (*XML_UnparsedEntityDeclHandler)(void *userData,
364 const XML_Char *entityName,
365 const XML_Char *base,
366 const XML_Char *systemId,
367 const XML_Char *publicId,
368 const XML_Char *notationName);
369
370 /* This is called for a declaration of notation. The base argument is
371 whatever was set by XML_SetBase. The notationName will never be
372 NULL. The other arguments can be.
373 */
374 typedef void (*XML_NotationDeclHandler)(void *userData,
375 const XML_Char *notationName,
376 const XML_Char *base,
377 const XML_Char *systemId,
378 const XML_Char *publicId);
379
380 /* When namespace processing is enabled, these are called once for
381 each namespace declaration. The call to the start and end element
382 handlers occur between the calls to the start and end namespace
383 declaration handlers. For an xmlns attribute, prefix will be
384 NULL. For an xmlns="" attribute, uri will be NULL.
385 */
386 typedef void (*XML_StartNamespaceDeclHandler)(void *userData,
387 const XML_Char *prefix,
388 const XML_Char *uri);
389
390 typedef void (*XML_EndNamespaceDeclHandler)(void *userData,
391 const XML_Char *prefix);
392
393 /* This is called if the document is not standalone, that is, it has an
394 external subset or a reference to a parameter entity, but does not
395 have standalone="yes". If this handler returns XML_STATUS_ERROR,
396 then processing will not continue, and the parser will return a
397 XML_ERROR_NOT_STANDALONE error.
398 If parameter entity parsing is enabled, then in addition to the
399 conditions above this handler will only be called if the referenced
400 entity was actually read.
401 */
402 typedef int (*XML_NotStandaloneHandler)(void *userData);
403
404 /* This is called for a reference to an external parsed general
405 entity. The referenced entity is not automatically parsed. The
406 application can parse it immediately or later using
407 XML_ExternalEntityParserCreate.
408
409 The parser argument is the parser parsing the entity containing the
410 reference; it can be passed as the parser argument to
411 XML_ExternalEntityParserCreate. The systemId argument is the
412 system identifier as specified in the entity declaration; it will
413 not be NULL.
414
415 The base argument is the system identifier that should be used as
416 the base for resolving systemId if systemId was relative; this is
417 set by XML_SetBase; it may be NULL.
418
419 The publicId argument is the public identifier as specified in the
420 entity declaration, or NULL if none was specified; the whitespace
421 in the public identifier will have been normalized as required by
422 the XML spec.
423
424 The context argument specifies the parsing context in the format
425 expected by the context argument to XML_ExternalEntityParserCreate;
426 context is valid only until the handler returns, so if the
427 referenced entity is to be parsed later, it must be copied.
428 context is NULL only when the entity is a parameter entity.
429
430 The handler should return XML_STATUS_ERROR if processing should not
431 continue because of a fatal error in the handling of the external
432 entity. In this case the calling parser will return an
433 XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
434
435 Note that unlike other handlers the first argument is the parser,
436 not userData.
437 */
438 typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
439 const XML_Char *context,
440 const XML_Char *base,
441 const XML_Char *systemId,
442 const XML_Char *publicId);
443
444 /* This is called in two situations:
445 1) An entity reference is encountered for which no declaration
446 has been read *and* this is not an error.
447 2) An internal entity reference is read, but not expanded, because
448 XML_SetDefaultHandler has been called.
449 Note: skipped parameter entities in declarations and skipped general
450 entities in attribute values cannot be reported, because
451 the event would be out of sync with the reporting of the
452 declarations or attribute values
453 */
454 typedef void (*XML_SkippedEntityHandler)(void *userData,
455 const XML_Char *entityName,
456 int is_parameter_entity);
457
458 /* This structure is filled in by the XML_UnknownEncodingHandler to
459 provide information to the parser about encodings that are unknown
460 to the parser.
461
462 The map[b] member gives information about byte sequences whose
463 first byte is b.
464
465 If map[b] is c where c is >= 0, then b by itself encodes the
466 Unicode scalar value c.
467
468 If map[b] is -1, then the byte sequence is malformed.
469
470 If map[b] is -n, where n >= 2, then b is the first byte of an
471 n-byte sequence that encodes a single Unicode scalar value.
472
473 The data member will be passed as the first argument to the convert
474 function.
475
476 The convert function is used to convert multibyte sequences; s will
477 point to a n-byte sequence where map[(unsigned char)*s] == -n. The
478 convert function must return the Unicode scalar value represented
479 by this byte sequence or -1 if the byte sequence is malformed.
480
481 The convert function may be NULL if the encoding is a single-byte
482 encoding, that is if map[b] >= -1 for all bytes b.
483
484 When the parser is finished with the encoding, then if release is
485 not NULL, it will call release passing it the data member; once
486 release has been called, the convert function will not be called
487 again.
488
489 Expat places certain restrictions on the encodings that are supported
490 using this mechanism.
491
492 1. Every ASCII character that can appear in a well-formed XML document,
493 other than the characters
494
495 $@\^`{}~
496
497 must be represented by a single byte, and that byte must be the
498 same byte that represents that character in ASCII.
499
500 2. No character may require more than 4 bytes to encode.
501
502 3. All characters encoded must have Unicode scalar values <=
503 0xFFFF, (i.e., characters that would be encoded by surrogates in
504 UTF-16 are not allowed). Note that this restriction doesn't
505 apply to the built-in support for UTF-8 and UTF-16.
506
507 4. No Unicode character may be encoded by more than one distinct
508 sequence of bytes.
509 */
510 typedef struct {
511 int map[256];
512 void *data;
513 int (*convert)(void *data, const char *s);
514 void (*release)(void *data);
515 } XML_Encoding;
516
517 /* This is called for an encoding that is unknown to the parser.
518
519 The encodingHandlerData argument is that which was passed as the
520 second argument to XML_SetUnknownEncodingHandler.
521
522 The name argument gives the name of the encoding as specified in
523 the encoding declaration.
524
525 If the callback can provide information about the encoding, it must
526 fill in the XML_Encoding structure, and return XML_STATUS_OK.
527 Otherwise it must return XML_STATUS_ERROR.
528
529 If info does not describe a suitable encoding, then the parser will
530 return an XML_UNKNOWN_ENCODING error.
531 */
532 typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData,
533 const XML_Char *name,
534 XML_Encoding *info);
535
536 XMLPARSEAPI(void)
537 XML_SetElementHandler(XML_Parser parser,
538 XML_StartElementHandler start,
539 XML_EndElementHandler end);
540
541 XMLPARSEAPI(void)
542 XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
543
544 XMLPARSEAPI(void)
545 XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
546
547 XMLPARSEAPI(void)
548 XML_SetCharacterDataHandler(XML_Parser parser,
549 XML_CharacterDataHandler handler);
550
551 XMLPARSEAPI(void)
552 XML_SetProcessingInstructionHandler(XML_Parser parser,
553 XML_ProcessingInstructionHandler handler);
554 XMLPARSEAPI(void)
555 XML_SetCommentHandler(XML_Parser parser,
556 XML_CommentHandler handler);
557
558 XMLPARSEAPI(void)
559 XML_SetCdataSectionHandler(XML_Parser parser,
560 XML_StartCdataSectionHandler start,
561 XML_EndCdataSectionHandler end);
562
563 XMLPARSEAPI(void)
564 XML_SetStartCdataSectionHandler(XML_Parser parser,
565 XML_StartCdataSectionHandler start);
566
567 XMLPARSEAPI(void)
568 XML_SetEndCdataSectionHandler(XML_Parser parser,
569 XML_EndCdataSectionHandler end);
570
571 /* This sets the default handler and also inhibits expansion of
572 internal entities. These entity references will be passed to the
573 default handler, or to the skipped entity handler, if one is set.
574 */
575 XMLPARSEAPI(void)
576 XML_SetDefaultHandler(XML_Parser parser,
577 XML_DefaultHandler handler);
578
579 /* This sets the default handler but does not inhibit expansion of
580 internal entities. The entity reference will not be passed to the
581 default handler.
582 */
583 XMLPARSEAPI(void)
584 XML_SetDefaultHandlerExpand(XML_Parser parser,
585 XML_DefaultHandler handler);
586
587 XMLPARSEAPI(void)
588 XML_SetDoctypeDeclHandler(XML_Parser parser,
589 XML_StartDoctypeDeclHandler start,
590 XML_EndDoctypeDeclHandler end);
591
592 XMLPARSEAPI(void)
593 XML_SetStartDoctypeDeclHandler(XML_Parser parser,
594 XML_StartDoctypeDeclHandler start);
595
596 XMLPARSEAPI(void)
597 XML_SetEndDoctypeDeclHandler(XML_Parser parser,
598 XML_EndDoctypeDeclHandler end);
599
600 XMLPARSEAPI(void)
601 XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
602 XML_UnparsedEntityDeclHandler handler);
603
604 XMLPARSEAPI(void)
605 XML_SetNotationDeclHandler(XML_Parser parser,
606 XML_NotationDeclHandler handler);
607
608 XMLPARSEAPI(void)
609 XML_SetNamespaceDeclHandler(XML_Parser parser,
610 XML_StartNamespaceDeclHandler start,
611 XML_EndNamespaceDeclHandler end);
612
613 XMLPARSEAPI(void)
614 XML_SetStartNamespaceDeclHandler(XML_Parser parser,
615 XML_StartNamespaceDeclHandler start);
616
617 XMLPARSEAPI(void)
618 XML_SetEndNamespaceDeclHandler(XML_Parser parser,
619 XML_EndNamespaceDeclHandler end);
620
621 XMLPARSEAPI(void)
622 XML_SetNotStandaloneHandler(XML_Parser parser,
623 XML_NotStandaloneHandler handler);
624
625 XMLPARSEAPI(void)
626 XML_SetExternalEntityRefHandler(XML_Parser parser,
627 XML_ExternalEntityRefHandler handler);
628
629 /* If a non-NULL value for arg is specified here, then it will be
630 passed as the first argument to the external entity ref handler
631 instead of the parser object.
632 */
633 XMLPARSEAPI(void)
634 XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
635
636 XMLPARSEAPI(void)
637 XML_SetSkippedEntityHandler(XML_Parser parser,
638 XML_SkippedEntityHandler handler);
639
640 XMLPARSEAPI(void)
641 XML_SetUnknownEncodingHandler(XML_Parser parser,
642 XML_UnknownEncodingHandler handler,
643 void *encodingHandlerData);
644
645 /* This can be called within a handler for a start element, end
646 element, processing instruction or character data. It causes the
647 corresponding markup to be passed to the default handler.
648 */
649 XMLPARSEAPI(void)
650 XML_DefaultCurrent(XML_Parser parser);
651
652 /* If do_nst is non-zero, and namespace processing is in effect, and
653 a name has a prefix (i.e. an explicit namespace qualifier) then
654 that name is returned as a triplet in a single string separated by
655 the separator character specified when the parser was created: URI
656 + sep + local_name + sep + prefix.
657
658 If do_nst is zero, then namespace information is returned in the
659 default manner (URI + sep + local_name) whether or not the name
660 has a prefix.
661
662 Note: Calling XML_SetReturnNSTriplet after XML_Parse or
663 XML_ParseBuffer has no effect.
664 */
665
666 XMLPARSEAPI(void)
667 XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
668
669 /* This value is passed as the userData argument to callbacks. */
670 XMLPARSEAPI(void)
671 XML_SetUserData(XML_Parser parser, void *userData);
672
673 /* Returns the last value set by XML_SetUserData or NULL. */
674 #define XML_GetUserData(parser) (*(void **)(parser))
675
676 /* This is equivalent to supplying an encoding argument to
677 XML_ParserCreate. On success XML_SetEncoding returns non-zero,
678 zero otherwise.
679 Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer
680 has no effect and returns XML_STATUS_ERROR.
681 */
682 XMLPARSEAPI(enum XML_Status)
683 XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
684
685 /* If this function is called, then the parser will be passed as the
686 first argument to callbacks instead of userData. The userData will
687 still be accessible using XML_GetUserData.
688 */
689 XMLPARSEAPI(void)
690 XML_UseParserAsHandlerArg(XML_Parser parser);
691
692 /* If useDTD == XML_TRUE is passed to this function, then the parser
693 will assume that there is an external subset, even if none is
694 specified in the document. In such a case the parser will call the
695 externalEntityRefHandler with a value of NULL for the systemId
696 argument (the publicId and context arguments will be NULL as well).
697 Note: If this function is called, then this must be done before
698 the first call to XML_Parse or XML_ParseBuffer, since it will
699 have no effect after that. Returns
700 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING.
701 Note: If the document does not have a DOCTYPE declaration at all,
702 then startDoctypeDeclHandler and endDoctypeDeclHandler will not
703 be called, despite an external subset being parsed.
704 Note: If XML_DTD is not defined when Expat is compiled, returns
705 XML_ERROR_FEATURE_REQUIRES_XML_DTD.
706 */
707 XMLPARSEAPI(enum XML_Error)
708 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
709
710
711 /* Sets the base to be used for resolving relative URIs in system
712 identifiers in declarations. Resolving relative identifiers is
713 left to the application: this value will be passed through as the
714 base argument to the XML_ExternalEntityRefHandler,
715 XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base
716 argument will be copied. Returns XML_STATUS_ERROR if out of memory,
717 XML_STATUS_OK otherwise.
718 */
719 XMLPARSEAPI(enum XML_Status)
720 XML_SetBase(XML_Parser parser, const XML_Char *base);
721
722 XMLPARSEAPI(const XML_Char *)
723 XML_GetBase(XML_Parser parser);
724
725 /* Returns the number of the attribute/value pairs passed in last call
726 to the XML_StartElementHandler that were specified in the start-tag
727 rather than defaulted. Each attribute/value pair counts as 2; thus
728 this correspondds to an index into the atts array passed to the
729 XML_StartElementHandler.
730 */
731 XMLPARSEAPI(int)
732 XML_GetSpecifiedAttributeCount(XML_Parser parser);
733
734 /* Returns the index of the ID attribute passed in the last call to
735 XML_StartElementHandler, or -1 if there is no ID attribute. Each
736 attribute/value pair counts as 2; thus this correspondds to an
737 index into the atts array passed to the XML_StartElementHandler.
738 */
739 XMLPARSEAPI(int)
740 XML_GetIdAttributeIndex(XML_Parser parser);
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 */