blob: 455e5b8fe2ea27d3bdf8192d691f16dcff56fc1a [file] [log] [blame]
Martin v. Löwisfc03a942003-01-25 22:41:29 +00001/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
2 See the file COPYING for copying permission.
Martin v. Löwisb48d1982002-02-12 09:52:22 +00003*/
4
5#ifndef XmlParse_INCLUDED
6#define XmlParse_INCLUDED 1
7
Martin v. Löwisfc03a942003-01-25 22:41:29 +00008#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
Martin v. Löwisb48d1982002-02-12 09:52:22 +000017#include <stdlib.h>
18
Martin v. Löwisfc03a942003-01-25 22:41:29 +000019#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
Fred Drake08317ae2003-10-21 15:38:55 +000020#define XML_USE_MSC_EXTENSIONS 1
Martin v. Löwisfc03a942003-01-25 22:41:29 +000021#endif
Fred Drake08317ae2003-10-21 15:38:55 +000022
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__)
49#define XMLCALL __attribute__((cdecl))
Martin v. Löwisfc03a942003-01-25 22:41:29 +000050#else
Fred Drake08317ae2003-10-21 15:38:55 +000051/* For any platform which uses this definition and supports more than
52 one calling convention, we need to extend this definition to
53 declare the convention used on that platform, if it's possible to
54 do so.
55
56 If this is the case for your platform, please file a bug report
57 with information on how to identify your platform via the C
58 pre-processor and how to specify the same calling convention as the
59 platform's malloc() implementation.
60*/
61#define XMLCALL
Martin v. Löwisfc03a942003-01-25 22:41:29 +000062#endif
Fred Drake08317ae2003-10-21 15:38:55 +000063#endif /* not defined XMLCALL */
64
65
66#if !defined(XML_STATIC) && !defined(XMLIMPORT)
67#ifndef XML_BUILDING_EXPAT
68/* using Expat from an application */
69
70#ifdef XML_USE_MSC_EXTENSIONS
71#define XMLIMPORT __declspec(dllimport)
72#endif
73
74#endif
75#endif /* not defined XML_STATIC */
76
77/* If we didn't define it above, define it away: */
78#ifndef XMLIMPORT
79#define XMLIMPORT
80#endif
81
82
83#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
Martin v. Löwisb48d1982002-02-12 09:52:22 +000084
85#ifdef __cplusplus
86extern "C" {
87#endif
88
Martin v. Löwisfc03a942003-01-25 22:41:29 +000089#ifdef XML_UNICODE_WCHAR_T
90#define XML_UNICODE
91#endif
Martin v. Löwisb48d1982002-02-12 09:52:22 +000092
Martin v. Löwisfc03a942003-01-25 22:41:29 +000093struct XML_ParserStruct;
94typedef struct XML_ParserStruct *XML_Parser;
95
96#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
97#ifdef XML_UNICODE_WCHAR_T
98typedef wchar_t XML_Char;
99typedef wchar_t XML_LChar;
100#else
101typedef unsigned short XML_Char;
102typedef char XML_LChar;
103#endif /* XML_UNICODE_WCHAR_T */
104#else /* Information is UTF-8 encoded. */
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000105typedef char XML_Char;
106typedef char XML_LChar;
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000107#endif /* XML_UNICODE */
108
109/* Should this be defined using stdbool.h when C99 is available? */
110typedef unsigned char XML_Bool;
111#define XML_TRUE ((XML_Bool) 1)
112#define XML_FALSE ((XML_Bool) 0)
113
Fred Drakedab8b0a2003-02-07 02:15:56 +0000114/* The XML_Status enum gives the possible return values for several
115 API functions. The preprocessor #defines are included so this
116 stanza can be added to code that still needs to support older
117 versions of Expat 1.95.x:
118
119 #ifndef XML_STATUS_OK
120 #define XML_STATUS_OK 1
121 #define XML_STATUS_ERROR 0
122 #endif
123
124 Otherwise, the #define hackery is quite ugly and would have been
125 dropped.
126*/
127enum XML_Status {
128 XML_STATUS_ERROR = 0,
129#define XML_STATUS_ERROR XML_STATUS_ERROR
130 XML_STATUS_OK = 1
131#define XML_STATUS_OK XML_STATUS_OK
132};
133
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000134enum XML_Error {
135 XML_ERROR_NONE,
136 XML_ERROR_NO_MEMORY,
137 XML_ERROR_SYNTAX,
138 XML_ERROR_NO_ELEMENTS,
139 XML_ERROR_INVALID_TOKEN,
140 XML_ERROR_UNCLOSED_TOKEN,
141 XML_ERROR_PARTIAL_CHAR,
142 XML_ERROR_TAG_MISMATCH,
143 XML_ERROR_DUPLICATE_ATTRIBUTE,
144 XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
145 XML_ERROR_PARAM_ENTITY_REF,
146 XML_ERROR_UNDEFINED_ENTITY,
147 XML_ERROR_RECURSIVE_ENTITY_REF,
148 XML_ERROR_ASYNC_ENTITY,
149 XML_ERROR_BAD_CHAR_REF,
150 XML_ERROR_BINARY_ENTITY_REF,
151 XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
152 XML_ERROR_MISPLACED_XML_PI,
153 XML_ERROR_UNKNOWN_ENCODING,
154 XML_ERROR_INCORRECT_ENCODING,
155 XML_ERROR_UNCLOSED_CDATA_SECTION,
156 XML_ERROR_EXTERNAL_ENTITY_HANDLING,
157 XML_ERROR_NOT_STANDALONE,
158 XML_ERROR_UNEXPECTED_STATE,
159 XML_ERROR_ENTITY_DECLARED_IN_PE,
160 XML_ERROR_FEATURE_REQUIRES_XML_DTD,
Fred Drake08317ae2003-10-21 15:38:55 +0000161 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING,
162 XML_ERROR_UNBOUND_PREFIX
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000163};
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000164
165enum XML_Content_Type {
166 XML_CTYPE_EMPTY = 1,
167 XML_CTYPE_ANY,
168 XML_CTYPE_MIXED,
169 XML_CTYPE_NAME,
170 XML_CTYPE_CHOICE,
171 XML_CTYPE_SEQ
172};
173
174enum XML_Content_Quant {
175 XML_CQUANT_NONE,
176 XML_CQUANT_OPT,
177 XML_CQUANT_REP,
178 XML_CQUANT_PLUS
179};
180
181/* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
182 XML_CQUANT_NONE, and the other fields will be zero or NULL.
183 If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
184 numchildren will contain number of elements that may be mixed in
185 and children point to an array of XML_Content cells that will be
186 all of XML_CTYPE_NAME type with no quantification.
187
188 If type == XML_CTYPE_NAME, then the name points to the name, and
189 the numchildren field will be zero and children will be NULL. The
190 quant fields indicates any quantifiers placed on the name.
191
192 CHOICE and SEQ will have name NULL, the number of children in
193 numchildren and children will point, recursively, to an array
194 of XML_Content cells.
195
196 The EMPTY, ANY, and MIXED types will only occur at top level.
197*/
198
199typedef struct XML_cp XML_Content;
200
201struct XML_cp {
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000202 enum XML_Content_Type type;
203 enum XML_Content_Quant quant;
204 XML_Char * name;
205 unsigned int numchildren;
206 XML_Content * children;
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000207};
208
209
210/* This is called for an element declaration. See above for
211 description of the model argument. It's the caller's responsibility
212 to free model when finished with it.
213*/
Fred Drake08317ae2003-10-21 15:38:55 +0000214typedef void (XMLCALL *XML_ElementDeclHandler) (void *userData,
215 const XML_Char *name,
216 XML_Content *model);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000217
218XMLPARSEAPI(void)
219XML_SetElementDeclHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000220 XML_ElementDeclHandler eldecl);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000221
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000222/* The Attlist declaration handler is called for *each* attribute. So
223 a single Attlist declaration with multiple attributes declared will
224 generate multiple calls to this handler. The "default" parameter
225 may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
226 keyword. The "isrequired" parameter will be true and the default
227 value will be NULL in the case of "#REQUIRED". If "isrequired" is
228 true and default is non-NULL, then this is a "#FIXED" default.
229*/
Fred Drake08317ae2003-10-21 15:38:55 +0000230typedef void (XMLCALL *XML_AttlistDeclHandler) (
231 void *userData,
232 const XML_Char *elname,
233 const XML_Char *attname,
234 const XML_Char *att_type,
235 const XML_Char *dflt,
236 int isrequired);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000237
238XMLPARSEAPI(void)
239XML_SetAttlistDeclHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000240 XML_AttlistDeclHandler attdecl);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000241
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000242/* The XML declaration handler is called for *both* XML declarations
243 and text declarations. The way to distinguish is that the version
244 parameter will be NULL for text declarations. The encoding
245 parameter may be NULL for XML declarations. The standalone
246 parameter will be -1, 0, or 1 indicating respectively that there
247 was no standalone parameter in the declaration, that it was given
248 as no, or that it was given as yes.
249*/
Fred Drake08317ae2003-10-21 15:38:55 +0000250typedef void (XMLCALL *XML_XmlDeclHandler) (void *userData,
251 const XML_Char *version,
252 const XML_Char *encoding,
253 int standalone);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000254
255XMLPARSEAPI(void)
256XML_SetXmlDeclHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000257 XML_XmlDeclHandler xmldecl);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000258
259
260typedef struct {
Fred Drake08317ae2003-10-21 15:38:55 +0000261 void *(XMLCALL *malloc_fcn)(size_t size);
262 void *(XMLCALL *realloc_fcn)(void *ptr, size_t size);
263 void (XMLCALL *free_fcn)(void *ptr);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000264} XML_Memory_Handling_Suite;
265
266/* Constructs a new parser; encoding is the encoding specified by the
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000267 external protocol or NULL if there is none specified.
268*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000269XMLPARSEAPI(XML_Parser)
270XML_ParserCreate(const XML_Char *encoding);
271
272/* Constructs a new parser and namespace processor. Element type
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000273 names and attribute names that belong to a namespace will be
274 expanded; unprefixed attribute names are never expanded; unprefixed
275 element type names are expanded only if there is a default
276 namespace. The expanded name is the concatenation of the namespace
277 URI, the namespace separator character, and the local part of the
278 name. If the namespace separator is '\0' then the namespace URI
279 and the local part will be concatenated without any separator.
280 When a namespace is not declared, the name and prefix will be
281 passed through without expansion.
282*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000283XMLPARSEAPI(XML_Parser)
284XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
285
286
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000287/* Constructs a new parser using the memory management suite referred to
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000288 by memsuite. If memsuite is NULL, then use the standard library memory
289 suite. If namespaceSeparator is non-NULL it creates a parser with
290 namespace processing as described above. The character pointed at
291 will serve as the namespace separator.
292
293 All further memory operations used for the created parser will come from
294 the given suite.
295*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000296XMLPARSEAPI(XML_Parser)
297XML_ParserCreate_MM(const XML_Char *encoding,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000298 const XML_Memory_Handling_Suite *memsuite,
299 const XML_Char *namespaceSeparator);
300
301/* Prepare a parser object to be re-used. This is particularly
302 valuable when memory allocation overhead is disproportionatly high,
303 such as when a large number of small documnents need to be parsed.
304 All handlers are cleared from the parser, except for the
305 unknownEncodingHandler. The parser's external state is re-initialized
306 except for the values of ns and ns_triplets.
307
308 Added in Expat 1.95.3.
309*/
310XMLPARSEAPI(XML_Bool)
311XML_ParserReset(XML_Parser parser, const XML_Char *encoding);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000312
313/* atts is array of name/value pairs, terminated by 0;
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000314 names and values are 0 terminated.
315*/
Fred Drake08317ae2003-10-21 15:38:55 +0000316typedef void (XMLCALL *XML_StartElementHandler) (void *userData,
317 const XML_Char *name,
318 const XML_Char **atts);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000319
Fred Drake08317ae2003-10-21 15:38:55 +0000320typedef void (XMLCALL *XML_EndElementHandler) (void *userData,
321 const XML_Char *name);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000322
323
324/* s is not 0 terminated. */
Fred Drake08317ae2003-10-21 15:38:55 +0000325typedef void (XMLCALL *XML_CharacterDataHandler) (void *userData,
326 const XML_Char *s,
327 int len);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000328
329/* target and data are 0 terminated */
Fred Drake08317ae2003-10-21 15:38:55 +0000330typedef void (XMLCALL *XML_ProcessingInstructionHandler) (
331 void *userData,
332 const XML_Char *target,
333 const XML_Char *data);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000334
335/* data is 0 terminated */
Fred Drake08317ae2003-10-21 15:38:55 +0000336typedef void (XMLCALL *XML_CommentHandler) (void *userData,
337 const XML_Char *data);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000338
Fred Drake08317ae2003-10-21 15:38:55 +0000339typedef void (XMLCALL *XML_StartCdataSectionHandler) (void *userData);
340typedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000341
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000342/* This is called for any characters in the XML document for which
343 there is no applicable handler. This includes both characters that
344 are part of markup which is of a kind that is not reported
345 (comments, markup declarations), or characters that are part of a
346 construct which could be reported but for which no handler has been
347 supplied. The characters are passed exactly as they were in the XML
348 document except that they will be encoded in UTF-8 or UTF-16.
349 Line boundaries are not normalized. Note that a byte order mark
350 character is not passed to the default handler. There are no
351 guarantees about how characters are divided between calls to the
352 default handler: for example, a comment might be split between
353 multiple calls.
354*/
Fred Drake08317ae2003-10-21 15:38:55 +0000355typedef void (XMLCALL *XML_DefaultHandler) (void *userData,
356 const XML_Char *s,
357 int len);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000358
359/* This is called for the start of the DOCTYPE declaration, before
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000360 any DTD or internal subset is parsed.
361*/
Fred Drake08317ae2003-10-21 15:38:55 +0000362typedef void (XMLCALL *XML_StartDoctypeDeclHandler) (
363 void *userData,
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000364 const XML_Char *doctypeName,
365 const XML_Char *sysid,
366 const XML_Char *pubid,
367 int has_internal_subset);
368
369/* This is called for the start of the DOCTYPE declaration when the
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000370 closing > is encountered, but after processing any external
371 subset.
372*/
Fred Drake08317ae2003-10-21 15:38:55 +0000373typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000374
375/* This is called for entity declarations. The is_parameter_entity
376 argument will be non-zero if the entity is a parameter entity, zero
377 otherwise.
378
379 For internal entities (<!ENTITY foo "bar">), value will
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000380 be non-NULL and systemId, publicID, and notationName will be NULL.
381 The value string is NOT nul-terminated; the length is provided in
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000382 the value_length argument. Since it is legal to have zero-length
383 values, do not use this argument to test for internal entities.
384
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000385 For external entities, value will be NULL and systemId will be
386 non-NULL. The publicId argument will be NULL unless a public
387 identifier was provided. The notationName argument will have a
388 non-NULL value only for unparsed entity declarations.
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000389
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000390 Note that is_parameter_entity can't be changed to XML_Bool, since
391 that would break binary compatibility.
392*/
Fred Drake08317ae2003-10-21 15:38:55 +0000393typedef void (XMLCALL *XML_EntityDeclHandler) (
394 void *userData,
395 const XML_Char *entityName,
396 int is_parameter_entity,
397 const XML_Char *value,
398 int value_length,
399 const XML_Char *base,
400 const XML_Char *systemId,
401 const XML_Char *publicId,
402 const XML_Char *notationName);
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000403
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000404XMLPARSEAPI(void)
405XML_SetEntityDeclHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000406 XML_EntityDeclHandler handler);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000407
408/* OBSOLETE -- OBSOLETE -- OBSOLETE
409 This handler has been superceded by the EntityDeclHandler above.
410 It is provided here for backward compatibility.
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000411
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000412 This is called for a declaration of an unparsed (NDATA) entity.
413 The base argument is whatever was set by XML_SetBase. The
414 entityName, systemId and notationName arguments will never be
415 NULL. The other arguments may be.
416*/
Fred Drake08317ae2003-10-21 15:38:55 +0000417typedef void (XMLCALL *XML_UnparsedEntityDeclHandler) (
418 void *userData,
419 const XML_Char *entityName,
420 const XML_Char *base,
421 const XML_Char *systemId,
422 const XML_Char *publicId,
423 const XML_Char *notationName);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000424
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000425/* This is called for a declaration of notation. The base argument is
426 whatever was set by XML_SetBase. The notationName will never be
427 NULL. The other arguments can be.
428*/
Fred Drake08317ae2003-10-21 15:38:55 +0000429typedef void (XMLCALL *XML_NotationDeclHandler) (
430 void *userData,
431 const XML_Char *notationName,
432 const XML_Char *base,
433 const XML_Char *systemId,
434 const XML_Char *publicId);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000435
436/* When namespace processing is enabled, these are called once for
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000437 each namespace declaration. The call to the start and end element
438 handlers occur between the calls to the start and end namespace
439 declaration handlers. For an xmlns attribute, prefix will be
440 NULL. For an xmlns="" attribute, uri will be NULL.
441*/
Fred Drake08317ae2003-10-21 15:38:55 +0000442typedef void (XMLCALL *XML_StartNamespaceDeclHandler) (
443 void *userData,
444 const XML_Char *prefix,
445 const XML_Char *uri);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000446
Fred Drake08317ae2003-10-21 15:38:55 +0000447typedef void (XMLCALL *XML_EndNamespaceDeclHandler) (
448 void *userData,
449 const XML_Char *prefix);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000450
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000451/* This is called if the document is not standalone, that is, it has an
452 external subset or a reference to a parameter entity, but does not
453 have standalone="yes". If this handler returns XML_STATUS_ERROR,
454 then processing will not continue, and the parser will return a
455 XML_ERROR_NOT_STANDALONE error.
456 If parameter entity parsing is enabled, then in addition to the
457 conditions above this handler will only be called if the referenced
458 entity was actually read.
459*/
Fred Drake08317ae2003-10-21 15:38:55 +0000460typedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000461
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000462/* This is called for a reference to an external parsed general
463 entity. The referenced entity is not automatically parsed. The
464 application can parse it immediately or later using
465 XML_ExternalEntityParserCreate.
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000466
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000467 The parser argument is the parser parsing the entity containing the
468 reference; it can be passed as the parser argument to
469 XML_ExternalEntityParserCreate. The systemId argument is the
470 system identifier as specified in the entity declaration; it will
471 not be NULL.
472
473 The base argument is the system identifier that should be used as
474 the base for resolving systemId if systemId was relative; this is
475 set by XML_SetBase; it may be NULL.
476
477 The publicId argument is the public identifier as specified in the
478 entity declaration, or NULL if none was specified; the whitespace
479 in the public identifier will have been normalized as required by
480 the XML spec.
481
482 The context argument specifies the parsing context in the format
483 expected by the context argument to XML_ExternalEntityParserCreate;
484 context is valid only until the handler returns, so if the
485 referenced entity is to be parsed later, it must be copied.
486 context is NULL only when the entity is a parameter entity.
487
488 The handler should return XML_STATUS_ERROR if processing should not
489 continue because of a fatal error in the handling of the external
490 entity. In this case the calling parser will return an
491 XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
492
493 Note that unlike other handlers the first argument is the parser,
494 not userData.
495*/
Fred Drake08317ae2003-10-21 15:38:55 +0000496typedef int (XMLCALL *XML_ExternalEntityRefHandler) (
497 XML_Parser parser,
498 const XML_Char *context,
499 const XML_Char *base,
500 const XML_Char *systemId,
501 const XML_Char *publicId);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000502
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000503/* This is called in two situations:
504 1) An entity reference is encountered for which no declaration
505 has been read *and* this is not an error.
506 2) An internal entity reference is read, but not expanded, because
507 XML_SetDefaultHandler has been called.
508 Note: skipped parameter entities in declarations and skipped general
509 entities in attribute values cannot be reported, because
510 the event would be out of sync with the reporting of the
511 declarations or attribute values
512*/
Fred Drake08317ae2003-10-21 15:38:55 +0000513typedef void (XMLCALL *XML_SkippedEntityHandler) (
514 void *userData,
515 const XML_Char *entityName,
516 int is_parameter_entity);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000517
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000518/* This structure is filled in by the XML_UnknownEncodingHandler to
519 provide information to the parser about encodings that are unknown
520 to the parser.
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000521
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000522 The map[b] member gives information about byte sequences whose
523 first byte is b.
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000524
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000525 If map[b] is c where c is >= 0, then b by itself encodes the
526 Unicode scalar value c.
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000527
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000528 If map[b] is -1, then the byte sequence is malformed.
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000529
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000530 If map[b] is -n, where n >= 2, then b is the first byte of an
531 n-byte sequence that encodes a single Unicode scalar value.
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000532
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000533 The data member will be passed as the first argument to the convert
534 function.
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000535
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000536 The convert function is used to convert multibyte sequences; s will
537 point to a n-byte sequence where map[(unsigned char)*s] == -n. The
538 convert function must return the Unicode scalar value represented
539 by this byte sequence or -1 if the byte sequence is malformed.
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000540
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000541 The convert function may be NULL if the encoding is a single-byte
542 encoding, that is if map[b] >= -1 for all bytes b.
543
544 When the parser is finished with the encoding, then if release is
545 not NULL, it will call release passing it the data member; once
546 release has been called, the convert function will not be called
547 again.
548
549 Expat places certain restrictions on the encodings that are supported
550 using this mechanism.
551
552 1. Every ASCII character that can appear in a well-formed XML document,
553 other than the characters
554
555 $@\^`{}~
556
557 must be represented by a single byte, and that byte must be the
558 same byte that represents that character in ASCII.
559
560 2. No character may require more than 4 bytes to encode.
561
562 3. All characters encoded must have Unicode scalar values <=
563 0xFFFF, (i.e., characters that would be encoded by surrogates in
564 UTF-16 are not allowed). Note that this restriction doesn't
565 apply to the built-in support for UTF-8 and UTF-16.
566
567 4. No Unicode character may be encoded by more than one distinct
568 sequence of bytes.
569*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000570typedef struct {
571 int map[256];
572 void *data;
Fred Drake08317ae2003-10-21 15:38:55 +0000573 int (XMLCALL *convert)(void *data, const char *s);
574 void (XMLCALL *release)(void *data);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000575} XML_Encoding;
576
577/* This is called for an encoding that is unknown to the parser.
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000578
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000579 The encodingHandlerData argument is that which was passed as the
580 second argument to XML_SetUnknownEncodingHandler.
581
582 The name argument gives the name of the encoding as specified in
583 the encoding declaration.
584
585 If the callback can provide information about the encoding, it must
586 fill in the XML_Encoding structure, and return XML_STATUS_OK.
587 Otherwise it must return XML_STATUS_ERROR.
588
589 If info does not describe a suitable encoding, then the parser will
590 return an XML_UNKNOWN_ENCODING error.
591*/
Fred Drake08317ae2003-10-21 15:38:55 +0000592typedef int (XMLCALL *XML_UnknownEncodingHandler) (
593 void *encodingHandlerData,
594 const XML_Char *name,
595 XML_Encoding *info);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000596
597XMLPARSEAPI(void)
598XML_SetElementHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000599 XML_StartElementHandler start,
600 XML_EndElementHandler end);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000601
602XMLPARSEAPI(void)
603XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
604
605XMLPARSEAPI(void)
606XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
607
608XMLPARSEAPI(void)
609XML_SetCharacterDataHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000610 XML_CharacterDataHandler handler);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000611
612XMLPARSEAPI(void)
613XML_SetProcessingInstructionHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000614 XML_ProcessingInstructionHandler handler);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000615XMLPARSEAPI(void)
616XML_SetCommentHandler(XML_Parser parser,
617 XML_CommentHandler handler);
618
619XMLPARSEAPI(void)
620XML_SetCdataSectionHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000621 XML_StartCdataSectionHandler start,
622 XML_EndCdataSectionHandler end);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000623
624XMLPARSEAPI(void)
625XML_SetStartCdataSectionHandler(XML_Parser parser,
626 XML_StartCdataSectionHandler start);
627
628XMLPARSEAPI(void)
629XML_SetEndCdataSectionHandler(XML_Parser parser,
630 XML_EndCdataSectionHandler end);
631
632/* This sets the default handler and also inhibits expansion of
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000633 internal entities. These entity references will be passed to the
634 default handler, or to the skipped entity handler, if one is set.
635*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000636XMLPARSEAPI(void)
637XML_SetDefaultHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000638 XML_DefaultHandler handler);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000639
640/* This sets the default handler but does not inhibit expansion of
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000641 internal entities. The entity reference will not be passed to the
642 default handler.
643*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000644XMLPARSEAPI(void)
645XML_SetDefaultHandlerExpand(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000646 XML_DefaultHandler handler);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000647
648XMLPARSEAPI(void)
649XML_SetDoctypeDeclHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000650 XML_StartDoctypeDeclHandler start,
651 XML_EndDoctypeDeclHandler end);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000652
653XMLPARSEAPI(void)
654XML_SetStartDoctypeDeclHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000655 XML_StartDoctypeDeclHandler start);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000656
657XMLPARSEAPI(void)
658XML_SetEndDoctypeDeclHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000659 XML_EndDoctypeDeclHandler end);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000660
661XMLPARSEAPI(void)
662XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000663 XML_UnparsedEntityDeclHandler handler);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000664
665XMLPARSEAPI(void)
666XML_SetNotationDeclHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000667 XML_NotationDeclHandler handler);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000668
669XMLPARSEAPI(void)
670XML_SetNamespaceDeclHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000671 XML_StartNamespaceDeclHandler start,
672 XML_EndNamespaceDeclHandler end);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000673
674XMLPARSEAPI(void)
675XML_SetStartNamespaceDeclHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000676 XML_StartNamespaceDeclHandler start);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000677
678XMLPARSEAPI(void)
679XML_SetEndNamespaceDeclHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000680 XML_EndNamespaceDeclHandler end);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000681
682XMLPARSEAPI(void)
683XML_SetNotStandaloneHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000684 XML_NotStandaloneHandler handler);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000685
686XMLPARSEAPI(void)
687XML_SetExternalEntityRefHandler(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000688 XML_ExternalEntityRefHandler handler);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000689
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000690/* If a non-NULL value for arg is specified here, then it will be
691 passed as the first argument to the external entity ref handler
692 instead of the parser object.
693*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000694XMLPARSEAPI(void)
695XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
696
697XMLPARSEAPI(void)
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000698XML_SetSkippedEntityHandler(XML_Parser parser,
699 XML_SkippedEntityHandler handler);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000700
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000701XMLPARSEAPI(void)
702XML_SetUnknownEncodingHandler(XML_Parser parser,
703 XML_UnknownEncodingHandler handler,
704 void *encodingHandlerData);
705
706/* This can be called within a handler for a start element, end
707 element, processing instruction or character data. It causes the
708 corresponding markup to be passed to the default handler.
709*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000710XMLPARSEAPI(void)
711XML_DefaultCurrent(XML_Parser parser);
712
713/* If do_nst is non-zero, and namespace processing is in effect, and
714 a name has a prefix (i.e. an explicit namespace qualifier) then
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000715 that name is returned as a triplet in a single string separated by
716 the separator character specified when the parser was created: URI
717 + sep + local_name + sep + prefix.
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000718
719 If do_nst is zero, then namespace information is returned in the
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000720 default manner (URI + sep + local_name) whether or not the name
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000721 has a prefix.
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000722
723 Note: Calling XML_SetReturnNSTriplet after XML_Parse or
724 XML_ParseBuffer has no effect.
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000725*/
726
727XMLPARSEAPI(void)
728XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
729
730/* This value is passed as the userData argument to callbacks. */
731XMLPARSEAPI(void)
732XML_SetUserData(XML_Parser parser, void *userData);
733
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000734/* Returns the last value set by XML_SetUserData or NULL. */
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000735#define XML_GetUserData(parser) (*(void **)(parser))
736
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000737/* This is equivalent to supplying an encoding argument to
738 XML_ParserCreate. On success XML_SetEncoding returns non-zero,
739 zero otherwise.
740 Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer
741 has no effect and returns XML_STATUS_ERROR.
742*/
743XMLPARSEAPI(enum XML_Status)
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000744XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
745
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000746/* If this function is called, then the parser will be passed as the
747 first argument to callbacks instead of userData. The userData will
748 still be accessible using XML_GetUserData.
749*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000750XMLPARSEAPI(void)
751XML_UseParserAsHandlerArg(XML_Parser parser);
752
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000753/* If useDTD == XML_TRUE is passed to this function, then the parser
754 will assume that there is an external subset, even if none is
755 specified in the document. In such a case the parser will call the
756 externalEntityRefHandler with a value of NULL for the systemId
757 argument (the publicId and context arguments will be NULL as well).
758 Note: If this function is called, then this must be done before
759 the first call to XML_Parse or XML_ParseBuffer, since it will
760 have no effect after that. Returns
761 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING.
762 Note: If the document does not have a DOCTYPE declaration at all,
763 then startDoctypeDeclHandler and endDoctypeDeclHandler will not
764 be called, despite an external subset being parsed.
765 Note: If XML_DTD is not defined when Expat is compiled, returns
766 XML_ERROR_FEATURE_REQUIRES_XML_DTD.
767*/
768XMLPARSEAPI(enum XML_Error)
769XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000770
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000771
772/* Sets the base to be used for resolving relative URIs in system
773 identifiers in declarations. Resolving relative identifiers is
774 left to the application: this value will be passed through as the
775 base argument to the XML_ExternalEntityRefHandler,
776 XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base
777 argument will be copied. Returns XML_STATUS_ERROR if out of memory,
778 XML_STATUS_OK otherwise.
779*/
780XMLPARSEAPI(enum XML_Status)
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000781XML_SetBase(XML_Parser parser, const XML_Char *base);
782
783XMLPARSEAPI(const XML_Char *)
784XML_GetBase(XML_Parser parser);
785
786/* Returns the number of the attribute/value pairs passed in last call
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000787 to the XML_StartElementHandler that were specified in the start-tag
788 rather than defaulted. Each attribute/value pair counts as 2; thus
789 this correspondds to an index into the atts array passed to the
790 XML_StartElementHandler.
791*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000792XMLPARSEAPI(int)
793XML_GetSpecifiedAttributeCount(XML_Parser parser);
794
795/* Returns the index of the ID attribute passed in the last call to
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000796 XML_StartElementHandler, or -1 if there is no ID attribute. Each
797 attribute/value pair counts as 2; thus this correspondds to an
798 index into the atts array passed to the XML_StartElementHandler.
799*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000800XMLPARSEAPI(int)
801XML_GetIdAttributeIndex(XML_Parser parser);
802
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000803/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
804 detected. The last call to XML_Parse must have isFinal true; len
805 may be zero for this call (or any other).
806
Fred Drakedab8b0a2003-02-07 02:15:56 +0000807 Though the return values for these functions has always been
808 described as a Boolean value, the implementation, at least for the
809 1.95.x series, has always returned exactly one of the XML_Status
810 values.
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000811*/
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000812XMLPARSEAPI(enum XML_Status)
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000813XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
814
815XMLPARSEAPI(void *)
816XML_GetBuffer(XML_Parser parser, int len);
817
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000818XMLPARSEAPI(enum XML_Status)
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000819XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
820
821/* Creates an XML_Parser object that can parse an external general
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000822 entity; context is a '\0'-terminated string specifying the parse
823 context; encoding is a '\0'-terminated string giving the name of
824 the externally specified encoding, or NULL if there is no
825 externally specified encoding. The context string consists of a
826 sequence of tokens separated by formfeeds (\f); a token consisting
827 of a name specifies that the general entity of the name is open; a
828 token of the form prefix=uri specifies the namespace for a
829 particular prefix; a token of the form =uri specifies the default
830 namespace. This can be called at any point after the first call to
831 an ExternalEntityRefHandler so longer as the parser has not yet
832 been freed. The new parser is completely independent and may
833 safely be used in a separate thread. The handlers and userData are
834 initialized from the parser argument. Returns NULL if out of memory.
835 Otherwise returns a new XML_Parser object.
836*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000837XMLPARSEAPI(XML_Parser)
838XML_ExternalEntityParserCreate(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000839 const XML_Char *context,
840 const XML_Char *encoding);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000841
842enum XML_ParamEntityParsing {
843 XML_PARAM_ENTITY_PARSING_NEVER,
844 XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
845 XML_PARAM_ENTITY_PARSING_ALWAYS
846};
847
848/* Controls parsing of parameter entities (including the external DTD
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000849 subset). If parsing of parameter entities is enabled, then
850 references to external parameter entities (including the external
851 DTD subset) will be passed to the handler set with
852 XML_SetExternalEntityRefHandler. The context passed will be 0.
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000853
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000854 Unlike external general entities, external parameter entities can
855 only be parsed synchronously. If the external parameter entity is
856 to be parsed, it must be parsed during the call to the external
857 entity ref handler: the complete sequence of
858 XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
859 XML_ParserFree calls must be made during this call. After
860 XML_ExternalEntityParserCreate has been called to create the parser
861 for the external parameter entity (context must be 0 for this
862 call), it is illegal to make any calls on the old parser until
863 XML_ParserFree has been called on the newly created parser.
864 If the library has been compiled without support for parameter
865 entity parsing (ie without XML_DTD being defined), then
866 XML_SetParamEntityParsing will return 0 if parsing of parameter
867 entities is requested; otherwise it will return non-zero.
868 Note: If XML_SetParamEntityParsing is called after XML_Parse or
869 XML_ParseBuffer, then it has no effect and will always return 0.
870*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000871XMLPARSEAPI(int)
872XML_SetParamEntityParsing(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000873 enum XML_ParamEntityParsing parsing);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000874
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000875/* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
876 XML_GetErrorCode returns information about the error.
877*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000878XMLPARSEAPI(enum XML_Error)
879XML_GetErrorCode(XML_Parser parser);
880
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000881/* These functions return information about the current parse
882 location. They may be called from any callback called to report
Fred Drake08317ae2003-10-21 15:38:55 +0000883 some parse event; in this case the location is the location of the
884 first of the sequence of characters that generated the event. When
885 called from callbacks generated by declarations in the document
886 prologue, the location identified isn't as neatly defined, but will
887 be within the relevant markup. When called outside of the callback
888 functions, the position indicated will be just past the last parse
889 event (regardless of whether there was an associated callback).
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000890
891 They may also be called after returning from a call to XML_Parse
892 or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then
893 the location is the location of the character at which the error
894 was detected; otherwise the location is the location of the last
895 parse event, as described above.
896*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000897XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser);
898XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser);
899XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser);
900
901/* Return the number of bytes in the current event.
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000902 Returns 0 if the event is in an internal entity.
903*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000904XMLPARSEAPI(int)
905XML_GetCurrentByteCount(XML_Parser parser);
906
907/* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
908 the integer pointed to by offset to the offset within this buffer
909 of the current parse position, and sets the integer pointed to by size
910 to the size of this buffer (the number of input bytes). Otherwise
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000911 returns a NULL pointer. Also returns a NULL pointer if a parse isn't
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000912 active.
913
914 NOTE: The character pointer returned should not be used outside
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000915 the handler that makes the call.
916*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000917XMLPARSEAPI(const char *)
918XML_GetInputContext(XML_Parser parser,
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000919 int *offset,
920 int *size);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000921
922/* For backwards compatibility with previous versions. */
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000923#define XML_GetErrorLineNumber XML_GetCurrentLineNumber
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000924#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000925#define XML_GetErrorByteIndex XML_GetCurrentByteIndex
926
927/* Frees the content model passed to the element declaration handler */
928XMLPARSEAPI(void)
929XML_FreeContentModel(XML_Parser parser, XML_Content *model);
930
931/* Exposing the memory handling functions used in Expat */
932XMLPARSEAPI(void *)
933XML_MemMalloc(XML_Parser parser, size_t size);
934
935XMLPARSEAPI(void *)
936XML_MemRealloc(XML_Parser parser, void *ptr, size_t size);
937
938XMLPARSEAPI(void)
939XML_MemFree(XML_Parser parser, void *ptr);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000940
941/* Frees memory used by the parser. */
942XMLPARSEAPI(void)
943XML_ParserFree(XML_Parser parser);
944
945/* Returns a string describing the error. */
946XMLPARSEAPI(const XML_LChar *)
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000947XML_ErrorString(enum XML_Error code);
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000948
949/* Return a string containing the version number of this expat */
950XMLPARSEAPI(const XML_LChar *)
951XML_ExpatVersion(void);
952
953typedef struct {
954 int major;
955 int minor;
956 int micro;
957} XML_Expat_Version;
958
959/* Return an XML_Expat_Version structure containing numeric version
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000960 number information for this version of expat.
961*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000962XMLPARSEAPI(XML_Expat_Version)
963XML_ExpatVersionInfo(void);
964
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000965/* Added in Expat 1.95.5. */
966enum XML_FeatureEnum {
967 XML_FEATURE_END = 0,
968 XML_FEATURE_UNICODE,
969 XML_FEATURE_UNICODE_WCHAR_T,
970 XML_FEATURE_DTD,
971 XML_FEATURE_CONTEXT_BYTES,
972 XML_FEATURE_MIN_SIZE,
973 XML_FEATURE_SIZEOF_XML_CHAR,
974 XML_FEATURE_SIZEOF_XML_LCHAR
975 /* Additional features must be added to the end of this enum. */
976};
Martin v. Löwis8fef47b2002-02-13 07:47:16 +0000977
Martin v. Löwisfc03a942003-01-25 22:41:29 +0000978typedef struct {
979 enum XML_FeatureEnum feature;
980 const XML_LChar *name;
981 long int value;
982} XML_Feature;
983
984XMLPARSEAPI(const XML_Feature *)
985XML_GetFeatureList(void);
986
987
988/* Expat follows the GNU/Linux convention of odd number minor version for
989 beta/development releases and even number minor version for stable
990 releases. Micro is bumped with each release, and set to 0 with each
991 change to major or minor version.
992*/
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000993#define XML_MAJOR_VERSION 1
994#define XML_MINOR_VERSION 95
Fred Drake08317ae2003-10-21 15:38:55 +0000995#define XML_MICRO_VERSION 7
Martin v. Löwisb48d1982002-02-12 09:52:22 +0000996
997#ifdef __cplusplus
998}
999#endif
1000
1001#endif /* not XmlParse_INCLUDED */