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