Move the tap infrastructure to the epan directory.
[obnox/wireshark/wip.git] / xmlstub.h
1 /*
2  *  This is part of tree.h from the libxml2 distribution.  It is used
3  *  for structure reference when dynamically linking to libxml.
4  *
5  *  The GPL agreement for this file and for libxml2 can be found at
6  *  http://www.xmlsoft.org
7  */
8
9 #include "config.h"
10
11 /****************** From xml headers ************************************/
12
13 /*
14  * use those to be sure nothing nasty will happen if
15  * your library and includes mismatch
16  */
17 #ifndef LIBXML2_COMPILING_MSCCDEF
18 extern void xmlCheckVersion(int version);
19 #endif /* LIBXML2_COMPILING_MSCCDEF */
20 #define LIBXML_DOTTED_VERSION "2.3.8"
21 #define LIBXML_VERSION 20308
22 #define LIBXML_VERSION_STRING "20308"
23 #define LIBXML_TEST_VERSION xmlCheckVersion(20308);
24
25 /*
26  * Whether the trio support need to be configured in
27  */
28 #if 0
29 #define WITH_TRIO
30 #else
31 #define WITHOUT_TRIO
32 #endif
33
34 /*
35  * Whether the FTP support is configured in
36  */
37 #if 1
38 #define LIBXML_FTP_ENABLED
39 #else
40 #define LIBXML_FTP_DISABLED
41 #endif
42
43 /*
44  * Whether the HTTP support is configured in
45  */
46 #if 1
47 #define LIBXML_HTTP_ENABLED
48 #else
49 #define LIBXML_HTTP_DISABLED
50 #endif
51
52 /*
53  * Whether the HTML support is configured in
54  */
55 #if 1
56 #define LIBXML_HTML_ENABLED
57 #else
58 #define LIBXML_HTML_DISABLED
59 #endif
60
61 /*
62  * Whether the SGML Docbook support is configured in
63  */
64 #if 1
65 #define LIBXML_DOCB_ENABLED
66 #else
67 #define LIBXML_DOCB_DISABLED
68 #endif
69
70 /*
71  * Whether XPath is configured in
72  */
73 #if 1
74 #define LIBXML_XPATH_ENABLED
75 #else
76 #define LIBXML_XPATH_DISABLED
77 #endif
78
79 /*
80  * Whether XPointer is configured in
81  */
82 #if 1
83 #define LIBXML_XPTR_ENABLED
84 #else
85 #define LIBXML_XPTR_DISABLED
86 #endif
87
88 /*
89  * Whether XInclude is configured in
90  */
91 #if 1
92 #define LIBXML_XINCLUDE_ENABLED
93 #else
94 #define LIBXML_XINCLUDE_DISABLED
95 #endif
96
97 /*
98  * Whether iconv support is available
99  */
100 #ifdef HAVE_ICONV_H
101 #define LIBXML_ICONV_ENABLED
102 #include <iconv.h>
103 #else
104 #define LIBXML_ICONV_DISABLED
105 #endif
106
107 /*
108  * Whether Debugging module is configured in
109  */
110 #if 1
111 #define LIBXML_DEBUG_ENABLED
112 #else
113 #define LIBXML_DEBUG_DISABLED
114 #endif
115
116 /*
117  * Whether the memory debugging is configured in
118  */
119 #if 0
120 #define DEBUG_MEMORY_LOCATION
121 #endif
122
123 #ifndef LIBXML_DLL_IMPORT
124 #if defined(_WIN32) && !defined(STATIC)
125 #define LIBXML_DLL_IMPORT __declspec(dllimport)
126 #else
127 #define LIBXML_DLL_IMPORT
128 #endif
129 #endif
130
131 #ifdef __GNUC__
132 #ifdef HAVE_ANSIDECL_H
133 #include <ansidecl.h>
134 #endif
135 #ifndef ATTRIBUTE_UNUSED
136 #define ATTRIBUTE_UNUSED
137 #endif
138 #else
139 #define ATTRIBUTE_UNUSED
140 #endif
141
142
143 #define XML_XML_NAMESPACE \
144     (const xmlChar *) "http://www.w3.org/XML/1998/namespace"
145
146 /*
147  * The different element types carried by an XML tree
148  *
149  * NOTE: This is synchronized with DOM Level1 values
150  *       See http://www.w3.org/TR/REC-DOM-Level-1/
151  *
152  * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should
153  * be deprecated to use an XML_DTD_NODE.
154  */
155 typedef enum {
156     XML_ELEMENT_NODE=           1,
157     XML_ATTRIBUTE_NODE=         2,
158     XML_TEXT_NODE=              3,
159     XML_CDATA_SECTION_NODE=     4,
160     XML_ENTITY_REF_NODE=        5,
161     XML_ENTITY_NODE=            6,
162     XML_PI_NODE=                7,
163     XML_COMMENT_NODE=           8,
164     XML_DOCUMENT_NODE=          9,
165     XML_DOCUMENT_TYPE_NODE=     10,
166     XML_DOCUMENT_FRAG_NODE=     11,
167     XML_NOTATION_NODE=          12,
168     XML_HTML_DOCUMENT_NODE=     13,
169     XML_DTD_NODE=               14,
170     XML_ELEMENT_DECL=           15,
171     XML_ATTRIBUTE_DECL=         16,
172     XML_ENTITY_DECL=            17,
173     XML_NAMESPACE_DECL=         18,
174     XML_XINCLUDE_START=         19,
175     XML_XINCLUDE_END=           20
176 #ifdef LIBXML_DOCB_ENABLED
177    ,XML_DOCB_DOCUMENT_NODE=     21
178 #endif
179 } xmlElementType;
180
181 /*
182  * Size of an internal character representation.
183  *
184  * We use 8bit chars internal representation for memory efficiency,
185  * Note that with 8 bits wide xmlChars one can still use UTF-8 to handle
186  * correctly non ISO-Latin input.
187  */
188
189 typedef unsigned char xmlChar;
190
191 #ifndef _WIN32
192 #ifndef CHAR
193 #define CHAR xmlChar
194 #endif
195 #endif
196
197 #define BAD_CAST (xmlChar *)
198
199 /*
200  * a DTD Notation definition
201  */
202
203 typedef struct _xmlNotation xmlNotation;
204 typedef xmlNotation *xmlNotationPtr;
205 struct _xmlNotation {
206     const xmlChar               *name;          /* Notation name */
207     const xmlChar               *PublicID;      /* Public identifier, if any */
208     const xmlChar               *SystemID;      /* System identifier, if any */
209 };
210
211 /*
212  * a DTD Attribute definition
213  */
214
215 typedef enum {
216     XML_ATTRIBUTE_CDATA = 1,
217     XML_ATTRIBUTE_ID,
218     XML_ATTRIBUTE_IDREF ,
219     XML_ATTRIBUTE_IDREFS,
220     XML_ATTRIBUTE_ENTITY,
221     XML_ATTRIBUTE_ENTITIES,
222     XML_ATTRIBUTE_NMTOKEN,
223     XML_ATTRIBUTE_NMTOKENS,
224     XML_ATTRIBUTE_ENUMERATION,
225     XML_ATTRIBUTE_NOTATION
226 } xmlAttributeType;
227
228 typedef enum {
229     XML_ATTRIBUTE_NONE = 1,
230     XML_ATTRIBUTE_REQUIRED,
231     XML_ATTRIBUTE_IMPLIED,
232     XML_ATTRIBUTE_FIXED
233 } xmlAttributeDefault;
234
235 typedef struct _xmlEnumeration xmlEnumeration;
236 typedef xmlEnumeration *xmlEnumerationPtr;
237 struct _xmlEnumeration {
238     struct _xmlEnumeration    *next;    /* next one */
239     const xmlChar            *name;     /* Enumeration name */
240 };
241
242 typedef struct _xmlAttribute xmlAttribute;
243 typedef xmlAttribute *xmlAttributePtr;
244 struct _xmlAttribute {
245 #ifndef XML_WITHOUT_CORBA
246     void           *_private;           /* for Corba, must be first ! */
247 #endif
248     xmlElementType          type;       /* XML_ATTRIBUTE_DECL, must be second ! */
249     const xmlChar          *name;       /* Attribute name */
250     struct _xmlNode    *children;       /* NULL */
251     struct _xmlNode        *last;       /* NULL */
252     struct _xmlDtd       *parent;       /* -> DTD */
253     struct _xmlNode        *next;       /* next sibling link  */
254     struct _xmlNode        *prev;       /* previous sibling link  */
255     struct _xmlDoc          *doc;       /* the containing document */
256
257     struct _xmlAttribute  *nexth;       /* next in hash table */
258     xmlAttributeType       atype;       /* The attribute type */
259     xmlAttributeDefault      def;       /* the default */
260     const xmlChar  *defaultValue;       /* or the default value */
261     xmlEnumerationPtr       tree;       /* or the enumeration tree if any */
262     const xmlChar        *prefix;       /* the namespace prefix if any */
263     const xmlChar          *elem;       /* Element holding the attribute */
264 };
265
266 /*
267  * a DTD Element definition.
268  */
269 typedef enum {
270     XML_ELEMENT_CONTENT_PCDATA = 1,
271     XML_ELEMENT_CONTENT_ELEMENT,
272     XML_ELEMENT_CONTENT_SEQ,
273     XML_ELEMENT_CONTENT_OR
274 } xmlElementContentType;
275
276 typedef enum {
277     XML_ELEMENT_CONTENT_ONCE = 1,
278     XML_ELEMENT_CONTENT_OPT,
279     XML_ELEMENT_CONTENT_MULT,
280     XML_ELEMENT_CONTENT_PLUS
281 } xmlElementContentOccur;
282
283 typedef struct _xmlElementContent xmlElementContent;
284 typedef xmlElementContent *xmlElementContentPtr;
285 struct _xmlElementContent {
286     xmlElementContentType     type;     /* PCDATA, ELEMENT, SEQ or OR */
287     xmlElementContentOccur    ocur;     /* ONCE, OPT, MULT or PLUS */
288     const xmlChar            *name;     /* Element name */
289     struct _xmlElementContent *c1;      /* first child */
290     struct _xmlElementContent *c2;      /* second child */
291     struct _xmlElementContent *parent;  /* parent */
292 };
293
294 typedef enum {
295     XML_ELEMENT_TYPE_UNDEFINED = 0,
296     XML_ELEMENT_TYPE_EMPTY = 1,
297     XML_ELEMENT_TYPE_ANY,
298     XML_ELEMENT_TYPE_MIXED,
299     XML_ELEMENT_TYPE_ELEMENT
300 } xmlElementTypeVal;
301
302 typedef struct _xmlElement xmlElement;
303 typedef xmlElement *xmlElementPtr;
304 struct _xmlElement {
305 #ifndef XML_WITHOUT_CORBA
306     void           *_private;           /* for Corba, must be first ! */
307 #endif
308     xmlElementType          type;       /* XML_ELEMENT_DECL, must be second ! */
309     const xmlChar          *name;       /* Element name */
310     struct _xmlNode    *children;       /* NULL */
311     struct _xmlNode        *last;       /* NULL */
312     struct _xmlDtd       *parent;       /* -> DTD */
313     struct _xmlNode        *next;       /* next sibling link  */
314     struct _xmlNode        *prev;       /* previous sibling link  */
315     struct _xmlDoc          *doc;       /* the containing document */
316
317     xmlElementTypeVal      etype;       /* The type */
318     xmlElementContentPtr content;       /* the allowed element content */
319     xmlAttributePtr   attributes;       /* List of the declared attributes */
320     const xmlChar        *prefix;       /* the namespace prefix if any */
321 };
322
323 /*
324  * An XML namespace.
325  * Note that prefix == NULL is valid, it defines the default namespace
326  * within the subtree (until overriden).
327  *
328  * XML_GLOBAL_NAMESPACE is now deprecated for good
329  * xmlNsType is unified with xmlElementType
330  */
331
332 #define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL
333 typedef xmlElementType xmlNsType;
334
335 typedef struct _xmlNs xmlNs;
336 typedef xmlNs *xmlNsPtr;
337 struct _xmlNs {
338     struct _xmlNs  *next;       /* next Ns link for this node  */
339     xmlNsType      type;        /* global or local */
340     const xmlChar *href;        /* URL for the namespace */
341     const xmlChar *prefix;      /* prefix for the namespace */
342 };
343
344 /*
345  * An XML DtD, as defined by <!DOCTYPE.
346  */
347 typedef struct _xmlDtd xmlDtd;
348 typedef xmlDtd *xmlDtdPtr;
349 struct _xmlDtd {
350 #ifndef XML_WITHOUT_CORBA
351     void           *_private;   /* for Corba, must be first ! */
352 #endif
353     xmlElementType  type;       /* XML_DTD_NODE, must be second ! */
354     const xmlChar *name;        /* Name of the DTD */
355     struct _xmlNode *children;  /* the value of the property link */
356     struct _xmlNode *last;      /* last child link */
357     struct _xmlDoc  *parent;    /* child->parent link */
358     struct _xmlNode *next;      /* next sibling link  */
359     struct _xmlNode *prev;      /* previous sibling link  */
360     struct _xmlDoc  *doc;       /* the containing document */
361
362     /* End of common part */
363     void          *notations;   /* Hash table for notations if any */
364     void          *elements;    /* Hash table for elements if any */
365     void          *attributes;  /* Hash table for attributes if any */
366     void          *entities;    /* Hash table for entities if any */
367     const xmlChar *ExternalID;  /* External identifier for PUBLIC DTD */
368     const xmlChar *SystemID;    /* URI for a SYSTEM or PUBLIC DTD */
369     void          *pentities;   /* Hash table for param entities if any */
370 };
371
372 /*
373  * A attribute of an XML node.
374  */
375 typedef struct _xmlAttr xmlAttr;
376 typedef xmlAttr *xmlAttrPtr;
377 struct _xmlAttr {
378 #ifndef XML_WITHOUT_CORBA
379     void           *_private;   /* for Corba, must be first ! */
380 #endif
381     xmlElementType   type;      /* XML_ATTRIBUTE_NODE, must be second ! */
382     const xmlChar   *name;      /* the name of the property */
383     struct _xmlNode *children;  /* the value of the property */
384     struct _xmlNode *last;      /* NULL */
385     struct _xmlNode *parent;    /* child->parent link */
386     struct _xmlAttr *next;      /* next sibling link  */
387     struct _xmlAttr *prev;      /* previous sibling link  */
388     struct _xmlDoc  *doc;       /* the containing document */
389     xmlNs           *ns;        /* pointer to the associated namespace */
390     xmlAttributeType atype;     /* the attribute type if validating */
391 };
392
393 /*
394  * An XML ID instance.
395  */
396
397 typedef struct _xmlID xmlID;
398 typedef xmlID *xmlIDPtr;
399 struct _xmlID {
400     struct _xmlID    *next;     /* next ID */
401     const xmlChar    *value;    /* The ID name */
402     xmlAttrPtr        attr;     /* The attribut holding it */
403 };
404
405 /*
406  * An XML IDREF instance.
407  */
408
409 typedef struct _xmlRef xmlRef;
410 typedef xmlRef *xmlRefPtr;
411 struct _xmlRef {
412     struct _xmlRef    *next;    /* next Ref */
413     const xmlChar     *value;   /* The Ref name */
414     xmlAttrPtr        attr;     /* The attribut holding it */
415 };
416
417 /*
418  * A buffer structure
419  */
420
421 typedef enum {
422     XML_BUFFER_ALLOC_DOUBLEIT,
423     XML_BUFFER_ALLOC_EXACT
424 } xmlBufferAllocationScheme;
425
426 typedef struct _xmlBuffer xmlBuffer;
427 typedef xmlBuffer *xmlBufferPtr;
428 struct _xmlBuffer {
429     xmlChar *content;           /* The buffer content UTF8 */
430     unsigned int use;           /* The buffer size used */
431     unsigned int size;          /* The buffer size */
432     xmlBufferAllocationScheme alloc; /* The realloc method */
433 };
434
435 /*
436  * A node in an XML tree.
437  */
438 typedef struct _xmlNode xmlNode;
439 typedef xmlNode *xmlNodePtr;
440 struct _xmlNode {
441 #ifndef XML_WITHOUT_CORBA
442     void           *_private;   /* for Corba, must be first ! */
443 #endif
444     xmlElementType   type;      /* type number, must be second ! */
445     const xmlChar   *name;      /* the name of the node, or the entity */
446     struct _xmlNode *children;  /* parent->childs link */
447     struct _xmlNode *last;      /* last child link */
448     struct _xmlNode *parent;    /* child->parent link */
449     struct _xmlNode *next;      /* next sibling link  */
450     struct _xmlNode *prev;      /* previous sibling link  */
451     struct _xmlDoc  *doc;       /* the containing document */
452     xmlNs           *ns;        /* pointer to the associated namespace */
453 #ifndef XML_USE_BUFFER_CONTENT
454     xmlChar         *content;   /* the content */
455 #else
456     xmlBufferPtr     content;   /* the content in a buffer */
457 #endif
458
459     /* End of common part */
460     struct _xmlAttr *properties;/* properties list */
461     xmlNs           *nsDef;     /* namespace definitions on this node */
462 };
463
464 /*
465  * An XML document.
466  */
467 typedef struct _xmlDoc xmlDoc;
468 typedef xmlDoc *xmlDocPtr;
469 struct _xmlDoc {
470 #ifndef XML_WITHOUT_CORBA
471     void           *_private;   /* for Corba, must be first ! */
472 #endif
473     xmlElementType  type;       /* XML_DOCUMENT_NODE, must be second ! */
474     char           *name;       /* name/filename/URI of the document */
475     struct _xmlNode *children;  /* the document tree */
476     struct _xmlNode *last;      /* last child link */
477     struct _xmlNode *parent;    /* child->parent link */
478     struct _xmlNode *next;      /* next sibling link  */
479     struct _xmlNode *prev;      /* previous sibling link  */
480     struct _xmlDoc  *doc;       /* autoreference to itself */
481
482     /* End of common part */
483     int             compression;/* level of zlib compression */
484     int             standalone; /* standalone document (no external refs) */
485     struct _xmlDtd  *intSubset; /* the document internal subset */
486     struct _xmlDtd  *extSubset; /* the document external subset */
487     struct _xmlNs   *oldNs;     /* Global namespace, the old way */
488     const xmlChar  *version;    /* the XML version string */
489     const xmlChar  *encoding;   /* external initial encoding, if any */
490     void           *ids;        /* Hash table for ID attributes if any */
491     void           *refs;       /* Hash table for IDREFs attributes if any */
492     const xmlChar  *URL;        /* The URI for that document */
493     int             charset;    /* encoding of the in-memory content
494                                    actually an xmlCharEncoding */
495 };
496
497 /**
498  * Predefined values for some standard encodings
499  * Libxml don't do beforehand translation on UTF8, ISOLatinX
500  * It also support UTF16 (LE and BE) by default.
501  *
502  * Anything else would have to be translated to UTF8 before being
503  * given to the parser itself. The BOM for UTF16 and the encoding
504  * declaration are looked at and a converter is looked for at that
505  * point. If not found the parser stops here as asked by the XML REC
506  * Converter can be registered by the user using xmlRegisterCharEncodingHandler
507  * but the currentl form doesn't allow stateful transcoding (a serious
508  * problem agreed !). If iconv has been found it will be used
509  * automatically and allow stateful transcoding, the simplest is then
510  * to be sure to enable icon and to provide iconv libs for the encoding
511  * support needed.
512  */
513 typedef enum {
514     XML_CHAR_ENCODING_ERROR=   -1, /* No char encoding detected */
515     XML_CHAR_ENCODING_NONE=     0, /* No char encoding detected */
516     XML_CHAR_ENCODING_UTF8=     1, /* UTF-8 */
517     XML_CHAR_ENCODING_UTF16LE=  2, /* UTF-16 little endian */
518     XML_CHAR_ENCODING_UTF16BE=  3, /* UTF-16 big endian */
519     XML_CHAR_ENCODING_UCS4LE=   4, /* UCS-4 little endian */
520     XML_CHAR_ENCODING_UCS4BE=   5, /* UCS-4 big endian */
521     XML_CHAR_ENCODING_EBCDIC=   6, /* EBCDIC uh! */
522     XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */
523     XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */
524     XML_CHAR_ENCODING_UCS2=     9, /* UCS-2 */
525     XML_CHAR_ENCODING_8859_1=   10,/* ISO-8859-1 ISO Latin 1 */
526     XML_CHAR_ENCODING_8859_2=   11,/* ISO-8859-2 ISO Latin 2 */
527     XML_CHAR_ENCODING_8859_3=   12,/* ISO-8859-3 */
528     XML_CHAR_ENCODING_8859_4=   13,/* ISO-8859-4 */
529     XML_CHAR_ENCODING_8859_5=   14,/* ISO-8859-5 */
530     XML_CHAR_ENCODING_8859_6=   15,/* ISO-8859-6 */
531     XML_CHAR_ENCODING_8859_7=   16,/* ISO-8859-7 */
532     XML_CHAR_ENCODING_8859_8=   17,/* ISO-8859-8 */
533     XML_CHAR_ENCODING_8859_9=   18,/* ISO-8859-9 */
534     XML_CHAR_ENCODING_2022_JP=  19,/* ISO-2022-JP */
535     XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */
536     XML_CHAR_ENCODING_EUC_JP=   21,/* EUC-JP */
537     XML_CHAR_ENCODING_ASCII=    22 /* pure ASCII */
538 } xmlCharEncoding;
539
540 /**
541  * xmlCharEncodingInputFunc:
542  * @out:  a pointer ot an array of bytes to store the UTF-8 result
543  * @outlen:  the lenght of @out
544  * @in:  a pointer ot an array of chars in the original encoding
545  * @inlen:  the lenght of @in
546  *
547  * Take a block of chars in the original encoding and try to convert
548  * it to an UTF-8 block of chars out.
549  *
550  * Returns the number of byte written, or -1 by lack of space, or -2
551  *     if the transcoding failed.
552  * The value of @inlen after return is the number of octets consumed
553  *     as the return value is positive, else unpredictiable.
554  * The value of @outlen after return is the number of ocetes consumed.
555  */
556 typedef int (* xmlCharEncodingInputFunc)(unsigned char* out, int *outlen,
557                                          const unsigned char* in, int *inlen);
558
559
560 /**
561  * xmlCharEncodingOutputFunc:
562  * @out:  a pointer ot an array of bytes to store the result
563  * @outlen:  the lenght of @out
564  * @in:  a pointer ot an array of UTF-8 chars
565  * @inlen:  the lenght of @in
566  *
567  * Take a block of UTF-8 chars in and try to convert it to an other
568  * encoding.
569  * Note: a first call designed to produce heading info is called with
570  * in = NULL. If stateful this should also initialize the encoder state
571  *
572  * Returns the number of byte written, or -1 by lack of space, or -2
573  *     if the transcoding failed.
574  * The value of @inlen after return is the number of octets consumed
575  *     as the return value is positive, else unpredictiable.
576  * The value of @outlen after return is the number of ocetes consumed.
577  */
578 typedef int (* xmlCharEncodingOutputFunc)(unsigned char* out, int *outlen,
579                                           const unsigned char* in, int *inlen);
580
581
582 /*
583  * Block defining the handlers for non UTF-8 encodings.
584  * If iconv is supported, there is two extra fields
585  */
586
587 typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
588 typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
589 struct _xmlCharEncodingHandler {
590     char                       *name;
591     xmlCharEncodingInputFunc   input;
592     xmlCharEncodingOutputFunc  output;
593 #ifdef LIBXML_ICONV_ENABLED
594     iconv_t                    iconv_in;
595     iconv_t                    iconv_out;
596 #endif /* LIBXML_ICONV_ENABLED */
597 };
598
599 typedef int (*xmlInputMatchCallback) (char const *filename);
600 typedef void * (*xmlInputOpenCallback) (char const *filename);
601 typedef int (*xmlInputReadCallback) (void * context, char * buffer, int len);
602 typedef void (*xmlInputCloseCallback) (void * context);
603
604 typedef struct _xmlParserInputBuffer xmlParserInputBuffer;
605 typedef xmlParserInputBuffer *xmlParserInputBufferPtr;
606 struct _xmlParserInputBuffer {
607     void*                  context;
608     xmlInputReadCallback   readcallback;
609     xmlInputCloseCallback  closecallback;
610
611     xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
612
613     xmlBufferPtr buffer;    /* Local buffer encoded in UTF-8 */
614     xmlBufferPtr raw;       /* if encoder != NULL buffer for raw input */
615 };
616
617
618 /*
619  * Those are the functions and datatypes for the library output
620  * I/O structures.
621  */
622
623 typedef int (*xmlOutputMatchCallback) (char const *filename);
624 typedef void * (*xmlOutputOpenCallback) (char const *filename);
625 typedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,
626                                        int len);
627 typedef void (*xmlOutputCloseCallback) (void * context);
628
629 typedef struct _xmlOutputBuffer xmlOutputBuffer;
630 typedef xmlOutputBuffer *xmlOutputBufferPtr;
631 struct _xmlOutputBuffer {
632     void*                   context;
633     xmlOutputWriteCallback  writecallback;
634     xmlOutputCloseCallback  closecallback;
635
636     xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
637
638     xmlBufferPtr buffer;    /* Local buffer encoded in UTF-8 or ISOLatin */
639     xmlBufferPtr conv;      /* if encoder != NULL buffer for output */
640     int written;            /* total number of byte written */
641 };
642
643 #define XML_DEFAULT_VERSION     "1.0"
644
645 /**
646  * an xmlParserInput is an input flow for the XML processor.
647  * Each entity parsed is associated an xmlParserInput (except the
648  * few predefined ones). This is the case both for internal entities
649  * - in which case the flow is already completely in memory - or
650  * external entities - in which case we use the buf structure for
651  * progressive reading and I18N conversions to the internal UTF-8 format.
652  */
653
654 typedef void (* xmlParserInputDeallocate)(xmlChar *);
655 typedef struct _xmlParserInput xmlParserInput;
656 typedef xmlParserInput *xmlParserInputPtr;
657 struct _xmlParserInput {
658     /* Input buffer */
659     xmlParserInputBufferPtr buf;      /* UTF-8 encoded buffer */
660
661     const char *filename;             /* The file analyzed, if any */
662     const char *directory;            /* the directory/base of teh file */
663     const xmlChar *base;              /* Base of the array to parse */
664     const xmlChar *cur;               /* Current char being parsed */
665     const xmlChar *end;               /* end of the arry to parse */
666     int length;                       /* length if known */
667     int line;                         /* Current line */
668     int col;                          /* Current column */
669     int consumed;                     /* How many xmlChars already consumed */
670     xmlParserInputDeallocate free;    /* function to deallocate the base */
671     const xmlChar *encoding;          /* the encoding string for entity */
672     const xmlChar *version;           /* the version string for entity */
673     int standalone;                   /* Was that entity marked standalone */
674 };
675
676 /**
677  * the parser can be asked to collect Node informations, i.e. at what
678  * place in the file they were detected.
679  * NOTE: This is off by default and not very well tested.
680  */
681 typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
682 typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
683
684 struct _xmlParserNodeInfo {
685   const struct _xmlNode* node;
686   /* Position & line # that text that created the node begins & ends on */
687   unsigned long begin_pos;
688   unsigned long begin_line;
689   unsigned long end_pos;
690   unsigned long end_line;
691 };
692
693 typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
694 typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
695 struct _xmlParserNodeInfoSeq {
696   unsigned long maximum;
697   unsigned long length;
698   xmlParserNodeInfo* buffer;
699 };
700
701 /*
702  * Validation state added for non-determinist content model
703  */
704 typedef struct _xmlValidState xmlValidState;
705 typedef xmlValidState *xmlValidStatePtr;
706
707 /**
708  * an xmlValidCtxt is used for error reporting when validating
709  */
710
711 typedef void (*xmlValidityErrorFunc) (void *ctx, const char *msg, ...);
712 typedef void (*xmlValidityWarningFunc) (void *ctx, const char *msg, ...);
713
714 typedef struct _xmlValidCtxt xmlValidCtxt;
715 typedef xmlValidCtxt *xmlValidCtxtPtr;
716 struct _xmlValidCtxt {
717     void *userData;                     /* user specific data block */
718     xmlValidityErrorFunc error;         /* the callback in case of errors */
719     xmlValidityWarningFunc warning;     /* the callback in case of warning */
720
721     /* Node analysis stack used when validating within entities */
722     xmlNodePtr         node;          /* Current parsed Node */
723     int                nodeNr;        /* Depth of the parsing stack */
724     int                nodeMax;       /* Max depth of the parsing stack */
725     xmlNodePtr        *nodeTab;       /* array of nodes */
726
727     int              finishDtd;       /* finished validating the Dtd ? */
728     xmlDocPtr              doc;       /* the document */
729     int                  valid;       /* temporary validity check result */
730
731     /* state state used for non-determinist content validation */
732     xmlValidState     *vstate;        /* current state */
733     int                vstateNr;      /* Depth of the validation stack */
734     int                vstateMax;     /* Max depth of the validation stack */
735     xmlValidState     *vstateTab;     /* array of validation states */
736 };
737
738 typedef struct _xmlLink xmlLink;
739 typedef xmlLink *xmlLinkPtr;
740
741 typedef struct _xmlList xmlList;
742 typedef xmlList *xmlListPtr;
743
744 typedef void (*xmlListDeallocator) (xmlLinkPtr lk);
745 typedef int  (*xmlListDataCompare) (const void *data0, const void *data1);
746 typedef int (*xmlListWalker) (const void *data, const void *user);
747
748 /*
749  * ALl notation declarations are stored in a table
750  * there is one table per DTD
751  */
752
753 typedef struct _xmlHashTable xmlNotationTable;
754 typedef xmlNotationTable *xmlNotationTablePtr;
755
756 /*
757  * ALl element declarations are stored in a table
758  * there is one table per DTD
759  */
760
761 typedef struct _xmlHashTable xmlElementTable;
762 typedef xmlElementTable *xmlElementTablePtr;
763
764 /*
765  * ALl attribute declarations are stored in a table
766  * there is one table per DTD
767  */
768
769 typedef struct _xmlHashTable xmlAttributeTable;
770 typedef xmlAttributeTable *xmlAttributeTablePtr;
771
772 /*
773  * ALl IDs attributes are stored in a table
774  * there is one table per document
775  */
776
777 typedef struct _xmlHashTable xmlIDTable;
778 typedef xmlIDTable *xmlIDTablePtr;
779
780 /*
781  * ALl Refs attributes are stored in a table
782  * there is one table per document
783  */
784
785 typedef struct _xmlHashTable xmlRefTable;
786 typedef xmlRefTable *xmlRefTablePtr;
787
788 /* helper */
789 xmlChar *           xmlSplitQName2      (const xmlChar *name,
790                                          xmlChar **prefix);
791
792 /**
793  * The parser is now working also as a state based parser
794  * The recursive one use the stagte info for entities processing
795  */
796 typedef enum {
797     XML_PARSER_EOF = -1,        /* nothing is to be parsed */
798     XML_PARSER_START = 0,       /* nothing has been parsed */
799     XML_PARSER_MISC,            /* Misc* before int subset */
800     XML_PARSER_PI,              /* Whithin a processing instruction */
801     XML_PARSER_DTD,             /* within some DTD content */
802     XML_PARSER_PROLOG,          /* Misc* after internal subset */
803     XML_PARSER_COMMENT,         /* within a comment */
804     XML_PARSER_START_TAG,       /* within a start tag */
805     XML_PARSER_CONTENT,         /* within the content */
806     XML_PARSER_CDATA_SECTION,   /* within a CDATA section */
807     XML_PARSER_END_TAG,         /* within a closing tag */
808     XML_PARSER_ENTITY_DECL,     /* within an entity declaration */
809     XML_PARSER_ENTITY_VALUE,    /* within an entity value in a decl */
810     XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
811     XML_PARSER_SYSTEM_LITERAL,  /* within a SYSTEM value */
812     XML_PARSER_EPILOG,          /* the Misc* after the last end tag */
813     XML_PARSER_IGNORE           /* within an IGNORED section */
814 } xmlParserInputState;
815
816 /**
817  * The parser context.
818  * NOTE This doesn't completely defines the parser state, the (current ?)
819  *      design of the parser uses recursive function calls since this allow
820  *      and easy mapping from the production rules of the specification
821  *      to the actual code. The drawback is that the actual function call
822  *      also reflect the parser state. However most of the parsing routines
823  *      takes as the only argument the parser context pointer, so migrating
824  *      to a state based parser for progressive parsing shouldn't be too hard.
825  */
826 typedef struct _xmlParserCtxt xmlParserCtxt;
827 typedef xmlParserCtxt *xmlParserCtxtPtr;
828 struct _xmlParserCtxt {
829     struct _xmlSAXHandler *sax;       /* The SAX handler */
830     void            *userData;        /* For SAX interface only, used by DOM build */
831     xmlDocPtr           myDoc;        /* the document being built */
832     int            wellFormed;        /* is the document well formed */
833     int       replaceEntities;        /* shall we replace entities ? */
834     const xmlChar    *version;        /* the XML version string */
835     const xmlChar   *encoding;        /* the declared encoding, if any */
836     int            standalone;        /* standalone document */
837     int                  html;        /* an HTML(1)/Docbook(2) document */
838
839     /* Input stream stack */
840     xmlParserInputPtr  input;         /* Current input stream */
841     int                inputNr;       /* Number of current input streams */
842     int                inputMax;      /* Max number of input streams */
843     xmlParserInputPtr *inputTab;      /* stack of inputs */
844
845     /* Node analysis stack only used for DOM building */
846     xmlNodePtr         node;          /* Current parsed Node */
847     int                nodeNr;        /* Depth of the parsing stack */
848     int                nodeMax;       /* Max depth of the parsing stack */
849     xmlNodePtr        *nodeTab;       /* array of nodes */
850
851     int record_info;                  /* Whether node info should be kept */
852     xmlParserNodeInfoSeq node_seq;    /* info about each node parsed */
853
854     int errNo;                        /* error code */
855
856     int     hasExternalSubset;        /* reference and external subset */
857     int             hasPErefs;        /* the internal subset has PE refs */
858     int              external;        /* are we parsing an external entity */
859
860     int                 valid;        /* is the document valid */
861     int              validate;        /* shall we try to validate ? */
862     xmlValidCtxt        vctxt;        /* The validity context */
863
864     xmlParserInputState instate;      /* current type of input */
865     int                 token;        /* next char look-ahead */
866
867     char           *directory;        /* the data directory */
868
869     /* Node name stack */
870     xmlChar           *name;          /* Current parsed Node */
871     int                nameNr;        /* Depth of the parsing stack */
872     int                nameMax;       /* Max depth of the parsing stack */
873     xmlChar *         *nameTab;       /* array of nodes */
874
875     long               nbChars;       /* number of xmlChar processed */
876     long            checkIndex;       /* used by progressive parsing lookup */
877     int             keepBlanks;       /* ugly but ... */
878     int             disableSAX;       /* SAX callbacks are disabled */
879     int               inSubset;       /* Parsing is in int 1/ext 2 subset */
880     xmlChar *          intSubName;    /* name of subset */
881     xmlChar *          extSubURI;     /* URI of external subset */
882     xmlChar *          extSubSystem;  /* SYSTEM ID of external subset */
883
884     /* xml:space values */
885     int *              space;         /* Should the parser preserve spaces */
886     int                spaceNr;       /* Depth of the parsing stack */
887     int                spaceMax;      /* Max depth of the parsing stack */
888     int *              spaceTab;      /* array of space infos */
889
890     int                depth;         /* to prevent entity substitution loops */
891     xmlParserInputPtr  entity;        /* used to check entities boundaries */
892     int                charset;       /* encoding of the in-memory content
893                                          actually an xmlCharEncoding */
894     int                nodelen;       /* Those two fields are there to */
895     int                nodemem;       /* Speed up large node parsing */
896     int                pedantic;      /* signal pedantic warnings */
897     void              *_private;      /* For user data, libxml won't touch it */
898
899     int                loadsubset;    /* should the external subset be loaded */
900 };
901
902 /**
903  * a SAX Locator.
904  */
905 typedef struct _xmlSAXLocator xmlSAXLocator;
906 typedef xmlSAXLocator *xmlSAXLocatorPtr;
907 struct _xmlSAXLocator {
908     const xmlChar *(*getPublicId)(void *ctx);
909     const xmlChar *(*getSystemId)(void *ctx);
910     int (*getLineNumber)(void *ctx);
911     int (*getColumnNumber)(void *ctx);
912 };
913
914 /*
915  * The different valid entity types
916  */
917 typedef enum {
918     XML_INTERNAL_GENERAL_ENTITY = 1,
919     XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,
920     XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,
921     XML_INTERNAL_PARAMETER_ENTITY = 4,
922     XML_EXTERNAL_PARAMETER_ENTITY = 5,
923     XML_INTERNAL_PREDEFINED_ENTITY = 6
924 } xmlEntityType;
925
926 /*
927  * An unit of storage for an entity, contains the string, the value
928  * and the linkind data needed for the linking in the hash table.
929  */
930
931 typedef struct _xmlEntity xmlEntity;
932 typedef xmlEntity *xmlEntityPtr;
933 struct _xmlEntity {
934 #ifndef XML_WITHOUT_CORBA
935     void           *_private;           /* for Corba, must be first ! */
936 #endif
937     xmlElementType          type;       /* XML_ENTITY_DECL, must be second ! */
938     const xmlChar          *name;       /* Attribute name */
939     struct _xmlNode    *children;       /* NULL */
940     struct _xmlNode        *last;       /* NULL */
941     struct _xmlDtd       *parent;       /* -> DTD */
942     struct _xmlNode        *next;       /* next sibling link  */
943     struct _xmlNode        *prev;       /* previous sibling link  */
944     struct _xmlDoc          *doc;       /* the containing document */
945
946     xmlChar                *orig;       /* content without ref substitution */
947     xmlChar             *content;       /* content or ndata if unparsed */
948     int                   length;       /* the content length */
949     xmlEntityType          etype;       /* The entity type */
950     const xmlChar    *ExternalID;       /* External identifier for PUBLIC */
951     const xmlChar      *SystemID;       /* URI for a SYSTEM or PUBLIC Entity */
952
953     struct _xmlEntity     *nexte;       /* unused */
954     const xmlChar           *URI;       /* the full URI as computed */
955 };
956
957 /*
958  * ALl entities are stored in an hash table
959  * there is 2 separate hash tables for global and parmeter entities
960  */
961
962 typedef struct _xmlHashTable xmlEntitiesTable;
963 typedef xmlEntitiesTable *xmlEntitiesTablePtr;
964
965 /*
966  * External functions :
967  */
968
969 /**
970  * a SAX handler is bunch of callbacks called by the parser when processing
971  * of the input generate data or structure informations.
972  */
973
974 typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
975                             const xmlChar *publicId, const xmlChar *systemId);
976 typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name,
977                             const xmlChar *ExternalID, const xmlChar *SystemID);
978 typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name,
979                             const xmlChar *ExternalID, const xmlChar *SystemID);
980 typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
981                             const xmlChar *name);
982 typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
983                             const xmlChar *name);
984 typedef void (*entityDeclSAXFunc) (void *ctx,
985                             const xmlChar *name, int type, const xmlChar *publicId,
986                             const xmlChar *systemId, xmlChar *content);
987 typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name,
988                             const xmlChar *publicId, const xmlChar *systemId);
989 typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem,
990                             const xmlChar *name, int type, int def,
991                             const xmlChar *defaultValue, xmlEnumerationPtr tree);
992 typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name,
993                             int type, xmlElementContentPtr content);
994 typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
995                             const xmlChar *name, const xmlChar *publicId,
996                             const xmlChar *systemId, const xmlChar *notationName);
997 typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
998                             xmlSAXLocatorPtr loc);
999 typedef void (*startDocumentSAXFunc) (void *ctx);
1000 typedef void (*endDocumentSAXFunc) (void *ctx);
1001 typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name,
1002                             const xmlChar **atts);
1003 typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name);
1004 typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name,
1005                                   const xmlChar *value);
1006 typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name);
1007 typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch,
1008                             int len);
1009 typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
1010                             const xmlChar *ch, int len);
1011 typedef void (*processingInstructionSAXFunc) (void *ctx,
1012                             const xmlChar *target, const xmlChar *data);
1013 typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value);
1014 typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len);
1015 typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
1016 typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
1017 typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
1018 typedef int (*isStandaloneSAXFunc) (void *ctx);
1019 typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
1020 typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
1021
1022 typedef struct _xmlSAXHandler xmlSAXHandler;
1023 typedef xmlSAXHandler *xmlSAXHandlerPtr;
1024 struct _xmlSAXHandler {
1025     internalSubsetSAXFunc internalSubset;
1026     isStandaloneSAXFunc isStandalone;
1027     hasInternalSubsetSAXFunc hasInternalSubset;
1028     hasExternalSubsetSAXFunc hasExternalSubset;
1029     resolveEntitySAXFunc resolveEntity;
1030     getEntitySAXFunc getEntity;
1031     entityDeclSAXFunc entityDecl;
1032     notationDeclSAXFunc notationDecl;
1033     attributeDeclSAXFunc attributeDecl;
1034     elementDeclSAXFunc elementDecl;
1035     unparsedEntityDeclSAXFunc unparsedEntityDecl;
1036     setDocumentLocatorSAXFunc setDocumentLocator;
1037     startDocumentSAXFunc startDocument;
1038     endDocumentSAXFunc endDocument;
1039     startElementSAXFunc startElement;
1040     endElementSAXFunc endElement;
1041     referenceSAXFunc reference;
1042     charactersSAXFunc characters;
1043     ignorableWhitespaceSAXFunc ignorableWhitespace;
1044     processingInstructionSAXFunc processingInstruction;
1045     commentSAXFunc comment;
1046     warningSAXFunc warning;
1047     errorSAXFunc error;
1048     fatalErrorSAXFunc fatalError;
1049     getParameterEntitySAXFunc getParameterEntity;
1050     cdataBlockSAXFunc cdataBlock;
1051     externalSubsetSAXFunc externalSubset;
1052 };
1053
1054 /**
1055  * External entity loaders types
1056  */
1057 typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL,
1058                                                      const char *ID,
1059                                                      xmlParserCtxtPtr context);
1060
1061 /*
1062  * Compatibility naming layer with libxml1
1063  */
1064 #ifndef xmlChildrenNode
1065 #define xmlChildrenNode children
1066 #define xmlRootNode children
1067 #endif
1068
1069
1070 /*********************Xml routines and function pointers */
1071 #ifdef IN_XMLSTUB
1072 #define XML_EXTERN
1073 #else
1074 #define XML_EXTERN extern
1075 #endif
1076
1077 typedef struct {
1078         /* Functions */
1079         xmlDocPtr         (*xmlParseFile)(const char *filename);
1080         int              (*xmlStrcmp)(const xmlChar *str1, const xmlChar *str2);
1081         xmlParserCtxtPtr  (*xmlCreatePushParserCtxt)(xmlSAXHandlerPtr, void *, const char *,
1082                                                                                                  int, const char *);
1083         int              (*xmlParseChunk)(xmlParserCtxtPtr, const char *, int, int);
1084         void             (*xmlFreeParserCtxt)(xmlParserCtxtPtr);
1085         xmlNodePtr         (*xmlDocGetRootElement)(xmlDocPtr);
1086         void             (*xmlFreeDoc)(xmlDocPtr);
1087         char            *(*xmlNodeListGetString)(xmlDocPtr, xmlNodePtr, int);
1088         char            *(*xmlGetProp)(xmlNodePtr, char *);
1089         int              (*xmlKeepBlanksDefault)(int);
1090         int              (*xmlSubstituteEntitiesDefault)(int);
1091
1092         /* Variables */
1093         int              *xmlDoValidityCheckingDefaultValue;
1094
1095 } XML_STUB;
1096
1097 XML_EXTERN XML_STUB XmlStub;
1098 XML_EXTERN int XmlStubInitialized;
1099
1100 #ifdef _WIN32
1101 /* We're in windows, use the windows filename */
1102 #define XML_LIBRARY "libxml2.dll"
1103 #else
1104 #define XML_LIBRARY "libxml2.so"
1105 #endif
1106
1107 /*
1108  * This needs to be called before the library is used.  It
1109  * returns zero on success.  Any non-zero return means that
1110  * either dynamic libraries are not supported, or that libxml
1111  * is not installed on the current system.  (Or it's not in
1112  * the LD path)
1113  */
1114 int loadLibXML(void);
1115
1116
1117