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