~ubuntu-branches/ubuntu/natty/expat/natty

« back to all changes in this revision

Viewing changes to lib/expat.h.in

  • Committer: Bazaar Package Importer
  • Author(s): Ardo van Rangelrooij
  • Date: 2004-02-29 11:01:15 UTC
  • mto: (2.1.1 warty) (4.1.4 hardy)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20040229110115-5lvfwtlieqsljx6c
Tags: upstream-1.95.6
ImportĀ upstreamĀ versionĀ 1.95.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
3
 
See the file COPYING for copying permission.
4
 
*/
5
 
 
6
 
#ifndef XmlParse_INCLUDED
7
 
#define XmlParse_INCLUDED 1
8
 
 
9
 
#include <stdlib.h>
10
 
 
11
 
#ifndef XMLPARSEAPI
12
 
#  if defined(__declspec) && !defined(__BEOS__)
13
 
#    define XMLPARSEAPI(type) __declspec(dllimport) type __cdecl
14
 
#  else
15
 
#    define XMLPARSEAPI(type) type
16
 
#  endif
17
 
#endif  /* not defined XMLPARSEAPI */
18
 
 
19
 
#ifdef __cplusplus
20
 
extern "C" {
21
 
#endif
22
 
 
23
 
typedef void *XML_Parser;
24
 
 
25
 
/* Information is UTF-8 encoded. */
26
 
typedef char XML_Char;
27
 
typedef char XML_LChar;
28
 
 
29
 
enum XML_Content_Type {
30
 
  XML_CTYPE_EMPTY = 1,
31
 
  XML_CTYPE_ANY,
32
 
  XML_CTYPE_MIXED,
33
 
  XML_CTYPE_NAME,
34
 
  XML_CTYPE_CHOICE,
35
 
  XML_CTYPE_SEQ
36
 
};
37
 
 
38
 
enum XML_Content_Quant {
39
 
  XML_CQUANT_NONE,
40
 
  XML_CQUANT_OPT,
41
 
  XML_CQUANT_REP,
42
 
  XML_CQUANT_PLUS
43
 
};
44
 
 
45
 
/* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
46
 
   XML_CQUANT_NONE, and the other fields will be zero or NULL.
47
 
   If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
48
 
   numchildren will contain number of elements that may be mixed in
49
 
   and children point to an array of XML_Content cells that will be
50
 
   all of XML_CTYPE_NAME type with no quantification.
51
 
 
52
 
   If type == XML_CTYPE_NAME, then the name points to the name, and
53
 
   the numchildren field will be zero and children will be NULL. The
54
 
   quant fields indicates any quantifiers placed on the name.
55
 
 
56
 
   CHOICE and SEQ will have name NULL, the number of children in
57
 
   numchildren and children will point, recursively, to an array
58
 
   of XML_Content cells.
59
 
 
60
 
   The EMPTY, ANY, and MIXED types will only occur at top level.
61
 
*/
62
 
 
63
 
typedef struct XML_cp XML_Content;
64
 
 
65
 
struct XML_cp {
66
 
  enum XML_Content_Type         type;
67
 
  enum XML_Content_Quant        quant;
68
 
  XML_Char *                    name;
69
 
  unsigned int                  numchildren;
70
 
  XML_Content *                 children;
71
 
};
72
 
 
73
 
 
74
 
/* This is called for an element declaration. See above for
75
 
   description of the model argument. It's the caller's responsibility
76
 
   to free model when finished with it.
77
 
*/
78
 
 
79
 
typedef void (*XML_ElementDeclHandler) (void *userData,
80
 
                                        const XML_Char *name,
81
 
                                        XML_Content *model);
82
 
 
83
 
XMLPARSEAPI(void)
84
 
XML_SetElementDeclHandler(XML_Parser parser,
85
 
                          XML_ElementDeclHandler eldecl);
86
 
 
87
 
/*
88
 
  The Attlist declaration handler is called for *each* attribute. So
89
 
  a single Attlist declaration with multiple attributes declared will
90
 
  generate multiple calls to this handler. The "default" parameter
91
 
  may be NULL in the case of the "#IMPLIED" or "#REQUIRED" keyword.
92
 
  The "isrequired" parameter will be true and the default value will
93
 
  be NULL in the case of "#REQUIRED". If "isrequired" is true and
94
 
  default is non-NULL, then this is a "#FIXED" default.
95
 
 */
96
 
 
97
 
typedef void (*XML_AttlistDeclHandler) (void           *userData,
98
 
                                        const XML_Char *elname,
99
 
                                        const XML_Char *attname,
100
 
                                        const XML_Char *att_type,
101
 
                                        const XML_Char *dflt,
102
 
                                        int             isrequired);
103
 
 
104
 
XMLPARSEAPI(void)
105
 
XML_SetAttlistDeclHandler(XML_Parser parser,
106
 
                          XML_AttlistDeclHandler attdecl);
107
 
 
108
 
 
109
 
  /* The XML declaration handler is called for *both* XML declarations and
110
 
     text declarations. The way to distinguish is that the version parameter
111
 
     will be null for text declarations. The encoding parameter may be null
112
 
     for XML declarations. The standalone parameter will be -1, 0, or 1
113
 
     indicating respectively that there was no standalone parameter in
114
 
     the declaration, that it was given as no, or that it was given as yes.
115
 
  */
116
 
 
117
 
typedef void (*XML_XmlDeclHandler) (void                *userData,
118
 
                                    const XML_Char      *version,
119
 
                                    const XML_Char      *encoding,
120
 
                                    int                  standalone);
121
 
 
122
 
XMLPARSEAPI(void)
123
 
XML_SetXmlDeclHandler(XML_Parser parser,
124
 
                      XML_XmlDeclHandler xmldecl);
125
 
 
126
 
 
127
 
typedef struct {
128
 
  void *(*malloc_fcn)(size_t size);
129
 
  void *(*realloc_fcn)(void *ptr, size_t size);
130
 
  void (*free_fcn)(void *ptr);
131
 
} XML_Memory_Handling_Suite;
132
 
 
133
 
/* Constructs a new parser; encoding is the encoding specified by the
134
 
external protocol or null if there is none specified. */
135
 
 
136
 
XMLPARSEAPI(XML_Parser)
137
 
XML_ParserCreate(const XML_Char *encoding);
138
 
 
139
 
/* Constructs a new parser and namespace processor.  Element type
140
 
names and attribute names that belong to a namespace will be expanded;
141
 
unprefixed attribute names are never expanded; unprefixed element type
142
 
names are expanded only if there is a default namespace. The expanded
143
 
name is the concatenation of the namespace URI, the namespace
144
 
separator character, and the local part of the name.  If the namespace
145
 
separator is '\0' then the namespace URI and the local part will be
146
 
concatenated without any separator.  When a namespace is not declared,
147
 
the name and prefix will be passed through without expansion. */
148
 
 
149
 
XMLPARSEAPI(XML_Parser)
150
 
XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
151
 
 
152
 
 
153
 
/* Constructs a new parser using the memory management suit referred to
154
 
   by memsuite. If memsuite is NULL, then use the standard library memory
155
 
   suite. If namespaceSeparator is non-NULL it creates a parser with
156
 
   namespace processing as described above. The character pointed at
157
 
   will serve as the namespace separator.
158
 
 
159
 
   All further memory operations used for the created parser will come from
160
 
   the given suite.
161
 
*/
162
 
 
163
 
XMLPARSEAPI(XML_Parser)
164
 
XML_ParserCreate_MM(const XML_Char *encoding,
165
 
                    const XML_Memory_Handling_Suite *memsuite,
166
 
                    const XML_Char *namespaceSeparator);
167
 
 
168
 
/* atts is array of name/value pairs, terminated by 0;
169
 
   names and values are 0 terminated. */
170
 
 
171
 
typedef void (*XML_StartElementHandler)(void *userData,
172
 
                                        const XML_Char *name,
173
 
                                        const XML_Char **atts);
174
 
 
175
 
typedef void (*XML_EndElementHandler)(void *userData,
176
 
                                      const XML_Char *name);
177
 
 
178
 
 
179
 
/* s is not 0 terminated. */
180
 
typedef void (*XML_CharacterDataHandler)(void *userData,
181
 
                                         const XML_Char *s,
182
 
                                         int len);
183
 
 
184
 
/* target and data are 0 terminated */
185
 
typedef void (*XML_ProcessingInstructionHandler)(void *userData,
186
 
                                                 const XML_Char *target,
187
 
                                                 const XML_Char *data);
188
 
 
189
 
/* data is 0 terminated */
190
 
typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data);
191
 
 
192
 
typedef void (*XML_StartCdataSectionHandler)(void *userData);
193
 
typedef void (*XML_EndCdataSectionHandler)(void *userData);
194
 
 
195
 
/* This is called for any characters in the XML document for
196
 
which there is no applicable handler.  This includes both
197
 
characters that are part of markup which is of a kind that is
198
 
not reported (comments, markup declarations), or characters
199
 
that are part of a construct which could be reported but
200
 
for which no handler has been supplied. The characters are passed
201
 
exactly as they were in the XML document except that
202
 
they will be encoded in UTF-8.  Line boundaries are not normalized.
203
 
Note that a byte order mark character is not passed to the default handler.
204
 
There are no guarantees about how characters are divided between calls
205
 
to the default handler: for example, a comment might be split between
206
 
multiple calls. */
207
 
 
208
 
typedef void (*XML_DefaultHandler)(void *userData,
209
 
                                   const XML_Char *s,
210
 
                                   int len);
211
 
 
212
 
/* This is called for the start of the DOCTYPE declaration, before
213
 
   any DTD or internal subset is parsed. */
214
 
 
215
 
typedef void (*XML_StartDoctypeDeclHandler)(void *userData,
216
 
                                            const XML_Char *doctypeName,
217
 
                                            const XML_Char *sysid,
218
 
                                            const XML_Char *pubid,
219
 
                                            int has_internal_subset);
220
 
 
221
 
/* This is called for the start of the DOCTYPE declaration when the
222
 
closing > is encountered, but after processing any external subset. */
223
 
typedef void (*XML_EndDoctypeDeclHandler)(void *userData);
224
 
 
225
 
/* This is called for entity declarations. The is_parameter_entity
226
 
   argument will be non-zero if the entity is a parameter entity, zero
227
 
   otherwise.
228
 
 
229
 
   For internal entities (<!ENTITY foo "bar">), value will
230
 
   be non-null and systemId, publicID, and notationName will be null.
231
 
   The value string is NOT null terminated; the length is provided in
232
 
   the value_length argument. Since it is legal to have zero-length
233
 
   values, do not use this argument to test for internal entities.
234
 
 
235
 
   For external entities, value will be null and systemId will be non-null.
236
 
   The publicId argument will be null unless a public identifier was
237
 
   provided. The notationName argument will have a non-null value only
238
 
   for unparsed entity declarations.
239
 
*/
240
 
 
241
 
typedef void (*XML_EntityDeclHandler) (void *userData,
242
 
                                       const XML_Char *entityName,
243
 
                                       int is_parameter_entity,
244
 
                                       const XML_Char *value,
245
 
                                       int value_length,
246
 
                                       const XML_Char *base,
247
 
                                       const XML_Char *systemId,
248
 
                                       const XML_Char *publicId,
249
 
                                       const XML_Char *notationName);
250
 
                                       
251
 
XMLPARSEAPI(void)
252
 
XML_SetEntityDeclHandler(XML_Parser parser,
253
 
                         XML_EntityDeclHandler handler);
254
 
 
255
 
/* OBSOLETE -- OBSOLETE -- OBSOLETE
256
 
   This handler has been superceded by the EntityDeclHandler above.
257
 
   It is provided here for backward compatibility.
258
 
This is called for a declaration of an unparsed (NDATA)
259
 
entity.  The base argument is whatever was set by XML_SetBase.
260
 
The entityName, systemId and notationName arguments will never be null.
261
 
The other arguments may be. */
262
 
 
263
 
typedef void (*XML_UnparsedEntityDeclHandler)(void *userData,
264
 
                                              const XML_Char *entityName,
265
 
                                              const XML_Char *base,
266
 
                                              const XML_Char *systemId,
267
 
                                              const XML_Char *publicId,
268
 
                                              const XML_Char *notationName);
269
 
 
270
 
/* This is called for a declaration of notation.
271
 
The base argument is whatever was set by XML_SetBase.
272
 
The notationName will never be null.  The other arguments can be. */
273
 
 
274
 
typedef void (*XML_NotationDeclHandler)(void *userData,
275
 
                                        const XML_Char *notationName,
276
 
                                        const XML_Char *base,
277
 
                                        const XML_Char *systemId,
278
 
                                        const XML_Char *publicId);
279
 
 
280
 
/* When namespace processing is enabled, these are called once for
281
 
each namespace declaration. The call to the start and end element
282
 
handlers occur between the calls to the start and end namespace
283
 
declaration handlers. For an xmlns attribute, prefix will be null.
284
 
For an xmlns="" attribute, uri will be null. */
285
 
 
286
 
typedef void (*XML_StartNamespaceDeclHandler)(void *userData,
287
 
                                              const XML_Char *prefix,
288
 
                                              const XML_Char *uri);
289
 
 
290
 
typedef void (*XML_EndNamespaceDeclHandler)(void *userData,
291
 
                                            const XML_Char *prefix);
292
 
 
293
 
/* This is called if the document is not standalone (it has an
294
 
external subset or a reference to a parameter entity, but does not
295
 
have standalone="yes"). If this handler returns 0, then processing
296
 
will not continue, and the parser will return a
297
 
XML_ERROR_NOT_STANDALONE error. */
298
 
 
299
 
typedef int (*XML_NotStandaloneHandler)(void *userData);
300
 
 
301
 
/* This is called for a reference to an external parsed general entity.
302
 
The referenced entity is not automatically parsed.
303
 
The application can parse it immediately or later using
304
 
XML_ExternalEntityParserCreate.
305
 
The parser argument is the parser parsing the entity containing the reference;
306
 
it can be passed as the parser argument to XML_ExternalEntityParserCreate.
307
 
The systemId argument is the system identifier as specified in the entity
308
 
declaration; it will not be null.
309
 
The base argument is the system identifier that should be used as the base for
310
 
resolving systemId if systemId was relative; this is set by XML_SetBase;
311
 
it may be null.
312
 
The publicId argument is the public identifier as specified in the entity
313
 
declaration, or null if none was specified; the whitespace in the public
314
 
identifier will have been normalized as required by the XML spec.
315
 
The context argument specifies the parsing context in the format
316
 
expected by the context argument to
317
 
XML_ExternalEntityParserCreate; context is valid only until the handler
318
 
returns, so if the referenced entity is to be parsed later, it must be copied.
319
 
The handler should return 0 if processing should not continue because of
320
 
a fatal error in the handling of the external entity.
321
 
In this case the calling parser will return an
322
 
XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
323
 
Note that unlike other handlers the first argument is the parser, not
324
 
userData. */
325
 
 
326
 
typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
327
 
                                            const XML_Char *context,
328
 
                                            const XML_Char *base,
329
 
                                            const XML_Char *systemId,
330
 
                                            const XML_Char *publicId);
331
 
 
332
 
/* This structure is filled in by the XML_UnknownEncodingHandler
333
 
to provide information to the parser about encodings that are unknown
334
 
to the parser.
335
 
The map[b] member gives information about byte sequences
336
 
whose first byte is b.
337
 
If map[b] is c where c is >= 0, then b by itself encodes the Unicode scalar
338
 
value c.
339
 
If map[b] is -1, then the byte sequence is malformed.
340
 
If map[b] is -n, where n >= 2, then b is the first byte of an n-byte
341
 
sequence that encodes a single Unicode scalar value.
342
 
The data member will be passed as the first argument to the convert function.
343
 
The convert function is used to convert multibyte sequences;
344
 
s will point to a n-byte sequence where map[(unsigned char)*s] == -n.
345
 
The convert function must return the Unicode scalar value
346
 
represented by this byte sequence or -1 if the byte sequence is malformed.
347
 
The convert function may be null if the encoding is a single-byte encoding,
348
 
that is if map[b] >= -1 for all bytes b.
349
 
When the parser is finished with the encoding, then if release is not null,
350
 
it will call release passing it the data member;
351
 
once release has been called, the convert function will not be called again.
352
 
 
353
 
Expat places certain restrictions on the encodings that are supported
354
 
using this mechanism.
355
 
 
356
 
1. Every ASCII character that can appear in a well-formed XML document,
357
 
other than the characters
358
 
 
359
 
  $@\^`{}~
360
 
 
361
 
must be represented by a single byte, and that byte must be the
362
 
same byte that represents that character in ASCII.
363
 
 
364
 
2. No character may require more than 4 bytes to encode.
365
 
 
366
 
3. All characters encoded must have Unicode scalar values <= 0xFFFF, (i.e.,
367
 
characters that would be encoded by surrogates in UTF-16 are  not
368
 
allowed).  Note that this restriction doesn't apply to the built-in
369
 
support for UTF-8 and UTF-16.
370
 
 
371
 
4. No Unicode character may be encoded by more than one distinct sequence
372
 
of bytes. */
373
 
 
374
 
typedef struct {
375
 
  int map[256];
376
 
  void *data;
377
 
  int (*convert)(void *data, const char *s);
378
 
  void (*release)(void *data);
379
 
} XML_Encoding;
380
 
 
381
 
/* This is called for an encoding that is unknown to the parser.
382
 
The encodingHandlerData argument is that which was passed as the
383
 
second argument to XML_SetUnknownEncodingHandler.
384
 
The name argument gives the name of the encoding as specified in
385
 
the encoding declaration.
386
 
If the callback can provide information about the encoding,
387
 
it must fill in the XML_Encoding structure, and return 1.
388
 
Otherwise it must return 0.
389
 
If info does not describe a suitable encoding,
390
 
then the parser will return an XML_UNKNOWN_ENCODING error. */
391
 
 
392
 
typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData,
393
 
                                          const XML_Char *name,
394
 
                                          XML_Encoding *info);
395
 
 
396
 
XMLPARSEAPI(void)
397
 
XML_SetElementHandler(XML_Parser parser,
398
 
                      XML_StartElementHandler start,
399
 
                      XML_EndElementHandler end);
400
 
 
401
 
XMLPARSEAPI(void)
402
 
XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
403
 
 
404
 
XMLPARSEAPI(void)
405
 
XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
406
 
 
407
 
XMLPARSEAPI(void)
408
 
XML_SetCharacterDataHandler(XML_Parser parser,
409
 
                            XML_CharacterDataHandler handler);
410
 
 
411
 
XMLPARSEAPI(void)
412
 
XML_SetProcessingInstructionHandler(XML_Parser parser,
413
 
                                    XML_ProcessingInstructionHandler handler);
414
 
XMLPARSEAPI(void)
415
 
XML_SetCommentHandler(XML_Parser parser,
416
 
                      XML_CommentHandler handler);
417
 
 
418
 
XMLPARSEAPI(void)
419
 
XML_SetCdataSectionHandler(XML_Parser parser,
420
 
                           XML_StartCdataSectionHandler start,
421
 
                           XML_EndCdataSectionHandler end);
422
 
 
423
 
XMLPARSEAPI(void)
424
 
XML_SetStartCdataSectionHandler(XML_Parser parser,
425
 
                                XML_StartCdataSectionHandler start);
426
 
 
427
 
XMLPARSEAPI(void)
428
 
XML_SetEndCdataSectionHandler(XML_Parser parser,
429
 
                              XML_EndCdataSectionHandler end);
430
 
 
431
 
/* This sets the default handler and also inhibits expansion of
432
 
internal entities.  The entity reference will be passed to the default
433
 
handler. */
434
 
 
435
 
XMLPARSEAPI(void)
436
 
XML_SetDefaultHandler(XML_Parser parser,
437
 
                      XML_DefaultHandler handler);
438
 
 
439
 
/* This sets the default handler but does not inhibit expansion of
440
 
internal entities.  The entity reference will not be passed to the
441
 
default handler. */
442
 
 
443
 
XMLPARSEAPI(void)
444
 
XML_SetDefaultHandlerExpand(XML_Parser parser,
445
 
                            XML_DefaultHandler handler);
446
 
 
447
 
XMLPARSEAPI(void)
448
 
XML_SetDoctypeDeclHandler(XML_Parser parser,
449
 
                          XML_StartDoctypeDeclHandler start,
450
 
                          XML_EndDoctypeDeclHandler end);
451
 
 
452
 
XMLPARSEAPI(void)
453
 
XML_SetStartDoctypeDeclHandler(XML_Parser parser,
454
 
                               XML_StartDoctypeDeclHandler start);
455
 
 
456
 
XMLPARSEAPI(void)
457
 
XML_SetEndDoctypeDeclHandler(XML_Parser parser,
458
 
                             XML_EndDoctypeDeclHandler end);
459
 
 
460
 
XMLPARSEAPI(void)
461
 
XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
462
 
                                 XML_UnparsedEntityDeclHandler handler);
463
 
 
464
 
XMLPARSEAPI(void)
465
 
XML_SetNotationDeclHandler(XML_Parser parser,
466
 
                           XML_NotationDeclHandler handler);
467
 
 
468
 
XMLPARSEAPI(void)
469
 
XML_SetNamespaceDeclHandler(XML_Parser parser,
470
 
                            XML_StartNamespaceDeclHandler start,
471
 
                            XML_EndNamespaceDeclHandler end);
472
 
 
473
 
XMLPARSEAPI(void)
474
 
XML_SetStartNamespaceDeclHandler(XML_Parser parser,
475
 
                                 XML_StartNamespaceDeclHandler start);
476
 
 
477
 
XMLPARSEAPI(void)
478
 
XML_SetEndNamespaceDeclHandler(XML_Parser parser,
479
 
                               XML_EndNamespaceDeclHandler end);
480
 
 
481
 
XMLPARSEAPI(void)
482
 
XML_SetNotStandaloneHandler(XML_Parser parser,
483
 
                            XML_NotStandaloneHandler handler);
484
 
 
485
 
XMLPARSEAPI(void)
486
 
XML_SetExternalEntityRefHandler(XML_Parser parser,
487
 
                                XML_ExternalEntityRefHandler handler);
488
 
 
489
 
/* If a non-null value for arg is specified here, then it will be passed
490
 
as the first argument to the external entity ref handler instead
491
 
of the parser object. */
492
 
XMLPARSEAPI(void)
493
 
XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
494
 
 
495
 
XMLPARSEAPI(void)
496
 
XML_SetUnknownEncodingHandler(XML_Parser parser,
497
 
                              XML_UnknownEncodingHandler handler,
498
 
                              void *encodingHandlerData);
499
 
 
500
 
/* This can be called within a handler for a start element, end element,
501
 
processing instruction or character data.  It causes the corresponding
502
 
markup to be passed to the default handler. */
503
 
XMLPARSEAPI(void)
504
 
XML_DefaultCurrent(XML_Parser parser);
505
 
 
506
 
/* If do_nst is non-zero, and namespace processing is in effect, and
507
 
   a name has a prefix (i.e. an explicit namespace qualifier) then
508
 
   that name is returned as a triplet in a single
509
 
   string separated by the separator character specified when the parser
510
 
   was created: URI + sep + local_name + sep + prefix.
511
 
 
512
 
   If do_nst is zero, then namespace information is returned in the
513
 
   default manner (URI + sep + local_name) whether or not the names
514
 
   has a prefix.
515
 
*/
516
 
 
517
 
XMLPARSEAPI(void)
518
 
XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
519
 
 
520
 
/* This value is passed as the userData argument to callbacks. */
521
 
XMLPARSEAPI(void)
522
 
XML_SetUserData(XML_Parser parser, void *userData);
523
 
 
524
 
/* Returns the last value set by XML_SetUserData or null. */
525
 
#define XML_GetUserData(parser) (*(void **)(parser))
526
 
 
527
 
/* This is equivalent to supplying an encoding argument
528
 
to XML_ParserCreate. It must not be called after XML_Parse
529
 
or XML_ParseBuffer. */
530
 
 
531
 
XMLPARSEAPI(int)
532
 
XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
533
 
 
534
 
/* If this function is called, then the parser will be passed
535
 
as the first argument to callbacks instead of userData.
536
 
The userData will still be accessible using XML_GetUserData. */
537
 
 
538
 
XMLPARSEAPI(void)
539
 
XML_UseParserAsHandlerArg(XML_Parser parser);
540
 
 
541
 
/* Sets the base to be used for resolving relative URIs in system
542
 
identifiers in declarations.  Resolving relative identifiers is left
543
 
to the application: this value will be passed through as the base
544
 
argument to the XML_ExternalEntityRefHandler, XML_NotationDeclHandler
545
 
and XML_UnparsedEntityDeclHandler. The base argument will be copied.
546
 
Returns zero if out of memory, non-zero otherwise. */
547
 
 
548
 
XMLPARSEAPI(int)
549
 
XML_SetBase(XML_Parser parser, const XML_Char *base);
550
 
 
551
 
XMLPARSEAPI(const XML_Char *)
552
 
XML_GetBase(XML_Parser parser);
553
 
 
554
 
/* Returns the number of the attribute/value pairs passed in last call
555
 
to the XML_StartElementHandler that were specified in the start-tag
556
 
rather than defaulted. Each attribute/value pair counts as 2; thus
557
 
this correspondds to an index into the atts array passed to the
558
 
XML_StartElementHandler. */
559
 
 
560
 
XMLPARSEAPI(int)
561
 
XML_GetSpecifiedAttributeCount(XML_Parser parser);
562
 
 
563
 
/* Returns the index of the ID attribute passed in the last call to
564
 
XML_StartElementHandler, or -1 if there is no ID attribute.  Each
565
 
attribute/value pair counts as 2; thus this correspondds to an index
566
 
into the atts array passed to the XML_StartElementHandler. */
567
 
 
568
 
XMLPARSEAPI(int)
569
 
XML_GetIdAttributeIndex(XML_Parser parser);
570
 
 
571
 
/* Parses some input. Returns 0 if a fatal error is detected.
572
 
The last call to XML_Parse must have isFinal true;
573
 
len may be zero for this call (or any other). */
574
 
XMLPARSEAPI(int)
575
 
XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
576
 
 
577
 
XMLPARSEAPI(void *)
578
 
XML_GetBuffer(XML_Parser parser, int len);
579
 
 
580
 
XMLPARSEAPI(int)
581
 
XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
582
 
 
583
 
/* Creates an XML_Parser object that can parse an external general
584
 
entity; context is a '\0'-terminated string specifying the parse
585
 
context; encoding is a '\0'-terminated string giving the name of the
586
 
externally specified encoding, or null if there is no externally
587
 
specified encoding.  The context string consists of a sequence of
588
 
tokens separated by formfeeds (\f); a token consisting of a name
589
 
specifies that the general entity of the name is open; a token of the
590
 
form prefix=uri specifies the namespace for a particular prefix; a
591
 
token of the form =uri specifies the default namespace.  This can be
592
 
called at any point after the first call to an
593
 
ExternalEntityRefHandler so longer as the parser has not yet been
594
 
freed.  The new parser is completely independent and may safely be
595
 
used in a separate thread.  The handlers and userData are initialized
596
 
from the parser argument.  Returns 0 if out of memory.  Otherwise
597
 
returns a new XML_Parser object. */
598
 
XMLPARSEAPI(XML_Parser)
599
 
XML_ExternalEntityParserCreate(XML_Parser parser,
600
 
                               const XML_Char *context,
601
 
                               const XML_Char *encoding);
602
 
 
603
 
enum XML_ParamEntityParsing {
604
 
  XML_PARAM_ENTITY_PARSING_NEVER,
605
 
  XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
606
 
  XML_PARAM_ENTITY_PARSING_ALWAYS
607
 
};
608
 
 
609
 
/* Controls parsing of parameter entities (including the external DTD
610
 
subset). If parsing of parameter entities is enabled, then references
611
 
to external parameter entities (including the external DTD subset)
612
 
will be passed to the handler set with
613
 
XML_SetExternalEntityRefHandler.  The context passed will be 0.
614
 
Unlike external general entities, external parameter entities can only
615
 
be parsed synchronously.  If the external parameter entity is to be
616
 
parsed, it must be parsed during the call to the external entity ref
617
 
handler: the complete sequence of XML_ExternalEntityParserCreate,
618
 
XML_Parse/XML_ParseBuffer and XML_ParserFree calls must be made during
619
 
this call.  After XML_ExternalEntityParserCreate has been called to
620
 
create the parser for the external parameter entity (context must be 0
621
 
for this call), it is illegal to make any calls on the old parser
622
 
until XML_ParserFree has been called on the newly created parser.  If
623
 
the library has been compiled without support for parameter entity
624
 
parsing (ie without XML_DTD being defined), then
625
 
XML_SetParamEntityParsing will return 0 if parsing of parameter
626
 
entities is requested; otherwise it will return non-zero. */
627
 
 
628
 
XMLPARSEAPI(int)
629
 
XML_SetParamEntityParsing(XML_Parser parser,
630
 
                          enum XML_ParamEntityParsing parsing);
631
 
 
632
 
enum XML_Error {
633
 
  XML_ERROR_NONE,
634
 
  XML_ERROR_NO_MEMORY,
635
 
  XML_ERROR_SYNTAX,
636
 
  XML_ERROR_NO_ELEMENTS,
637
 
  XML_ERROR_INVALID_TOKEN,
638
 
  XML_ERROR_UNCLOSED_TOKEN,
639
 
  XML_ERROR_PARTIAL_CHAR,
640
 
  XML_ERROR_TAG_MISMATCH,
641
 
  XML_ERROR_DUPLICATE_ATTRIBUTE,
642
 
  XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
643
 
  XML_ERROR_PARAM_ENTITY_REF,
644
 
  XML_ERROR_UNDEFINED_ENTITY,
645
 
  XML_ERROR_RECURSIVE_ENTITY_REF,
646
 
  XML_ERROR_ASYNC_ENTITY,
647
 
  XML_ERROR_BAD_CHAR_REF,
648
 
  XML_ERROR_BINARY_ENTITY_REF,
649
 
  XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
650
 
  XML_ERROR_MISPLACED_XML_PI,
651
 
  XML_ERROR_UNKNOWN_ENCODING,
652
 
  XML_ERROR_INCORRECT_ENCODING,
653
 
  XML_ERROR_UNCLOSED_CDATA_SECTION,
654
 
  XML_ERROR_EXTERNAL_ENTITY_HANDLING,
655
 
  XML_ERROR_NOT_STANDALONE,
656
 
  XML_ERROR_UNEXPECTED_STATE
657
 
};
658
 
 
659
 
/* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode
660
 
returns information about the error. */
661
 
 
662
 
XMLPARSEAPI(enum XML_Error)
663
 
XML_GetErrorCode(XML_Parser parser);
664
 
 
665
 
/* These functions return information about the current parse location.
666
 
They may be called when XML_Parse or XML_ParseBuffer return 0;
667
 
in this case the location is the location of the character at which
668
 
the error was detected.
669
 
They may also be called from any other callback called to report
670
 
some parse event; in this the location is the location of the first
671
 
of the sequence of characters that generated the event. */
672
 
 
673
 
XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser);
674
 
XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser);
675
 
XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser);
676
 
 
677
 
/* Return the number of bytes in the current event.
678
 
Returns 0 if the event is in an internal entity. */
679
 
 
680
 
XMLPARSEAPI(int)
681
 
XML_GetCurrentByteCount(XML_Parser parser);
682
 
 
683
 
/* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
684
 
   the integer pointed to by offset to the offset within this buffer
685
 
   of the current parse position, and sets the integer pointed to by size
686
 
   to the size of this buffer (the number of input bytes). Otherwise
687
 
   returns a null pointer. Also returns a null pointer if a parse isn't
688
 
   active.
689
 
 
690
 
   NOTE: The character pointer returned should not be used outside
691
 
   the handler that makes the call. */
692
 
 
693
 
XMLPARSEAPI(const char *)
694
 
XML_GetInputContext(XML_Parser parser,
695
 
                    int *offset,
696
 
                    int *size);
697
 
 
698
 
/* For backwards compatibility with previous versions. */
699
 
#define XML_GetErrorLineNumber XML_GetCurrentLineNumber
700
 
#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
701
 
#define XML_GetErrorByteIndex XML_GetCurrentByteIndex
702
 
 
703
 
/* Frees memory used by the parser. */
704
 
XMLPARSEAPI(void)
705
 
XML_ParserFree(XML_Parser parser);
706
 
 
707
 
/* Returns a string describing the error. */
708
 
XMLPARSEAPI(const XML_LChar *)
709
 
XML_ErrorString(int code);
710
 
 
711
 
/* Return a string containing the version number of this expat */
712
 
XMLPARSEAPI(const XML_LChar *)
713
 
XML_ExpatVersion(void);
714
 
 
715
 
typedef struct {
716
 
  int major;
717
 
  int minor;
718
 
  int micro;
719
 
} XML_Expat_Version;
720
 
 
721
 
/* Return an XML_Expat_Version structure containing numeric version
722
 
   number information for this version of expat */
723
 
 
724
 
XMLPARSEAPI(XML_Expat_Version)
725
 
XML_ExpatVersionInfo(void);
726
 
 
727
 
#define XML_MAJOR_VERSION @EXPAT_MAJOR_VERSION@
728
 
#define XML_MINOR_VERSION @EXPAT_MINOR_VERSION@
729
 
#define XML_MICRO_VERSION @EXPAT_EDIT@
730
 
 
731
 
#ifdef __cplusplus
732
 
}
733
 
#endif
734
 
 
735
 
#endif /* not XmlParse_INCLUDED */