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