source: trunk/poppler/expat-1.95.8/lib/expat.h @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 16 years ago

First import

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