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