OSDN Git Service

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