Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:41:49

0001 /*
0002  * Summary: the core parser module
0003  * Description: Interfaces, constants and types related to the XML parser
0004  *
0005  * Copy: See Copyright for the status of this software.
0006  *
0007  * Author: Daniel Veillard
0008  */
0009 
0010 #ifndef __XML_PARSER_H__
0011 #define __XML_PARSER_H__
0012 
0013 /** DOC_DISABLE */
0014 #include <libxml/xmlversion.h>
0015 #define XML_TREE_INTERNALS
0016 #include <libxml/tree.h>
0017 #undef XML_TREE_INTERNALS
0018 #include <libxml/dict.h>
0019 #include <libxml/hash.h>
0020 #include <libxml/valid.h>
0021 #include <libxml/entities.h>
0022 #include <libxml/xmlerror.h>
0023 #include <libxml/xmlstring.h>
0024 #include <libxml/xmlmemory.h>
0025 #include <libxml/encoding.h>
0026 #include <libxml/xmlIO.h>
0027 /* for compatibility */
0028 #include <libxml/SAX2.h>
0029 #include <libxml/threads.h>
0030 /** DOC_ENABLE */
0031 
0032 #ifdef __cplusplus
0033 extern "C" {
0034 #endif
0035 
0036 /**
0037  * XML_DEFAULT_VERSION:
0038  *
0039  * The default version of XML used: 1.0
0040  */
0041 #define XML_DEFAULT_VERSION "1.0"
0042 
0043 /**
0044  * xmlParserInput:
0045  *
0046  * An xmlParserInput is an input flow for the XML processor.
0047  * Each entity parsed is associated an xmlParserInput (except the
0048  * few predefined ones). This is the case both for internal entities
0049  * - in which case the flow is already completely in memory - or
0050  * external entities - in which case we use the buf structure for
0051  * progressive reading and I18N conversions to the internal UTF-8 format.
0052  */
0053 
0054 /**
0055  * xmlParserInputDeallocate:
0056  * @str:  the string to deallocate
0057  *
0058  * Callback for freeing some parser input allocations.
0059  */
0060 typedef void (* xmlParserInputDeallocate)(xmlChar *str);
0061 
0062 struct _xmlParserInput {
0063     /* Input buffer */
0064     xmlParserInputBufferPtr buf;      /* UTF-8 encoded buffer */
0065 
0066     const char *filename;             /* The file analyzed, if any */
0067     const char *directory;            /* unused */
0068     const xmlChar *base;              /* Base of the array to parse */
0069     const xmlChar *cur;               /* Current char being parsed */
0070     const xmlChar *end;               /* end of the array to parse */
0071     int length;                       /* unused */
0072     int line;                         /* Current line */
0073     int col;                          /* Current column */
0074     unsigned long consumed;           /* How many xmlChars already consumed */
0075     xmlParserInputDeallocate free;    /* function to deallocate the base */
0076     const xmlChar *encoding;          /* unused */
0077     const xmlChar *version;           /* the version string for entity */
0078     int flags;                        /* Flags */
0079     int id;                           /* an unique identifier for the entity */
0080     unsigned long parentConsumed;     /* unused */
0081     xmlEntityPtr entity;              /* entity, if any */
0082 };
0083 
0084 /**
0085  * xmlParserNodeInfo:
0086  *
0087  * The parser can be asked to collect Node information, i.e. at what
0088  * place in the file they were detected.
0089  * NOTE: This is off by default and not very well tested.
0090  */
0091 typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
0092 typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
0093 
0094 struct _xmlParserNodeInfo {
0095   const struct _xmlNode* node;
0096   /* Position & line # that text that created the node begins & ends on */
0097   unsigned long begin_pos;
0098   unsigned long begin_line;
0099   unsigned long end_pos;
0100   unsigned long end_line;
0101 };
0102 
0103 typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
0104 typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
0105 struct _xmlParserNodeInfoSeq {
0106   unsigned long maximum;
0107   unsigned long length;
0108   xmlParserNodeInfo* buffer;
0109 };
0110 
0111 /**
0112  * xmlParserInputState:
0113  *
0114  * The parser is now working also as a state based parser.
0115  * The recursive one use the state info for entities processing.
0116  */
0117 typedef enum {
0118     XML_PARSER_EOF = -1,    /* nothing is to be parsed */
0119     XML_PARSER_START = 0,   /* nothing has been parsed */
0120     XML_PARSER_MISC,        /* Misc* before int subset */
0121     XML_PARSER_PI,      /* Within a processing instruction */
0122     XML_PARSER_DTD,     /* within some DTD content */
0123     XML_PARSER_PROLOG,      /* Misc* after internal subset */
0124     XML_PARSER_COMMENT,     /* within a comment */
0125     XML_PARSER_START_TAG,   /* within a start tag */
0126     XML_PARSER_CONTENT,     /* within the content */
0127     XML_PARSER_CDATA_SECTION,   /* within a CDATA section */
0128     XML_PARSER_END_TAG,     /* within a closing tag */
0129     XML_PARSER_ENTITY_DECL, /* within an entity declaration */
0130     XML_PARSER_ENTITY_VALUE,    /* within an entity value in a decl */
0131     XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
0132     XML_PARSER_SYSTEM_LITERAL,  /* within a SYSTEM value */
0133     XML_PARSER_EPILOG,      /* the Misc* after the last end tag */
0134     XML_PARSER_IGNORE,      /* within an IGNORED section */
0135     XML_PARSER_PUBLIC_LITERAL,  /* within a PUBLIC value */
0136     XML_PARSER_XML_DECL         /* before XML decl (but after BOM) */
0137 } xmlParserInputState;
0138 
0139 /** DOC_DISABLE */
0140 /*
0141  * Internal bits in the 'loadsubset' context member
0142  */
0143 #define XML_DETECT_IDS      2
0144 #define XML_COMPLETE_ATTRS  4
0145 #define XML_SKIP_IDS        8
0146 /** DOC_ENABLE */
0147 
0148 /**
0149  * xmlParserMode:
0150  *
0151  * A parser can operate in various modes
0152  */
0153 typedef enum {
0154     XML_PARSE_UNKNOWN = 0,
0155     XML_PARSE_DOM = 1,
0156     XML_PARSE_SAX = 2,
0157     XML_PARSE_PUSH_DOM = 3,
0158     XML_PARSE_PUSH_SAX = 4,
0159     XML_PARSE_READER = 5
0160 } xmlParserMode;
0161 
0162 typedef struct _xmlStartTag xmlStartTag;
0163 typedef struct _xmlParserNsData xmlParserNsData;
0164 typedef struct _xmlAttrHashBucket xmlAttrHashBucket;
0165 
0166 /**
0167  * xmlParserCtxt:
0168  *
0169  * The parser context.
0170  * NOTE This doesn't completely define the parser state, the (current ?)
0171  *      design of the parser uses recursive function calls since this allow
0172  *      and easy mapping from the production rules of the specification
0173  *      to the actual code. The drawback is that the actual function call
0174  *      also reflect the parser state. However most of the parsing routines
0175  *      takes as the only argument the parser context pointer, so migrating
0176  *      to a state based parser for progressive parsing shouldn't be too hard.
0177  */
0178 struct _xmlParserCtxt {
0179     struct _xmlSAXHandler *sax;       /* The SAX handler */
0180     void            *userData;        /* For SAX interface only, used by DOM build */
0181     xmlDocPtr           myDoc;        /* the document being built */
0182     int            wellFormed;        /* is the document well formed */
0183     int       replaceEntities;        /* shall we replace entities ? */
0184     const xmlChar    *version;        /* the XML version string */
0185     const xmlChar   *encoding;        /* the declared encoding, if any */
0186     int            standalone;        /* standalone document */
0187     int                  html;        /* an HTML(1) document
0188                                        * 3 is HTML after <head>
0189                                        * 10 is HTML after <body>
0190                                        */
0191 
0192     /* Input stream stack */
0193     xmlParserInputPtr  input;         /* Current input stream */
0194     int                inputNr;       /* Number of current input streams */
0195     int                inputMax;      /* Max number of input streams */
0196     xmlParserInputPtr *inputTab;      /* stack of inputs */
0197 
0198     /* Node analysis stack only used for DOM building */
0199     xmlNodePtr         node;          /* Current parsed Node */
0200     int                nodeNr;        /* Depth of the parsing stack */
0201     int                nodeMax;       /* Max depth of the parsing stack */
0202     xmlNodePtr        *nodeTab;       /* array of nodes */
0203 
0204     int record_info;                  /* Whether node info should be kept */
0205     xmlParserNodeInfoSeq node_seq;    /* info about each node parsed */
0206 
0207     int errNo;                        /* error code */
0208 
0209     int     hasExternalSubset;        /* reference and external subset */
0210     int             hasPErefs;        /* the internal subset has PE refs */
0211     int              external;        /* unused */
0212 
0213     int                 valid;        /* is the document valid */
0214     int              validate;        /* shall we try to validate ? */
0215     xmlValidCtxt        vctxt;        /* The validity context */
0216 
0217     xmlParserInputState instate;      /* push parser state */
0218     int                 token;        /* unused */
0219 
0220     char           *directory;        /* unused */
0221 
0222     /* Node name stack */
0223     const xmlChar     *name;          /* Current parsed Node */
0224     int                nameNr;        /* Depth of the parsing stack */
0225     int                nameMax;       /* Max depth of the parsing stack */
0226     const xmlChar *   *nameTab;       /* array of nodes */
0227 
0228     long               nbChars;       /* unused */
0229     long            checkIndex;       /* used by progressive parsing lookup */
0230     int             keepBlanks;       /* ugly but ... */
0231     int             disableSAX;       /* SAX callbacks are disabled */
0232     int               inSubset;       /* Parsing is in int 1/ext 2 subset */
0233     const xmlChar *    intSubName;    /* name of subset */
0234     xmlChar *          extSubURI;     /* URI of external subset */
0235     xmlChar *          extSubSystem;  /* SYSTEM ID of external subset */
0236 
0237     /* xml:space values */
0238     int *              space;         /* Should the parser preserve spaces */
0239     int                spaceNr;       /* Depth of the parsing stack */
0240     int                spaceMax;      /* Max depth of the parsing stack */
0241     int *              spaceTab;      /* array of space infos */
0242 
0243     int                depth;         /* to prevent entity substitution loops */
0244     xmlParserInputPtr  entity;        /* unused */
0245     int                charset;       /* unused */
0246     int                nodelen;       /* Those two fields are there to */
0247     int                nodemem;       /* Speed up large node parsing */
0248     int                pedantic;      /* signal pedantic warnings */
0249     void              *_private;      /* For user data, libxml won't touch it */
0250 
0251     int                loadsubset;    /* should the external subset be loaded */
0252     int                linenumbers;   /* set line number in element content */
0253     void              *catalogs;      /* document's own catalog */
0254     int                recovery;      /* run in recovery mode */
0255     int                progressive;   /* unused */
0256     xmlDictPtr         dict;          /* dictionary for the parser */
0257     const xmlChar *   *atts;          /* array for the attributes callbacks */
0258     int                maxatts;       /* the size of the array */
0259     int                docdict;       /* unused */
0260 
0261     /*
0262      * pre-interned strings
0263      */
0264     const xmlChar *str_xml;
0265     const xmlChar *str_xmlns;
0266     const xmlChar *str_xml_ns;
0267 
0268     /*
0269      * Everything below is used only by the new SAX mode
0270      */
0271     int                sax2;          /* operating in the new SAX mode */
0272     int                nsNr;          /* the number of inherited namespaces */
0273     int                nsMax;         /* the size of the arrays */
0274     const xmlChar *   *nsTab;         /* the array of prefix/namespace name */
0275     unsigned          *attallocs;     /* which attribute were allocated */
0276     xmlStartTag       *pushTab;       /* array of data for push */
0277     xmlHashTablePtr    attsDefault;   /* defaulted attributes if any */
0278     xmlHashTablePtr    attsSpecial;   /* non-CDATA attributes if any */
0279     int                nsWellFormed;  /* is the document XML Namespace okay */
0280     int                options;       /* Extra options */
0281 
0282     /*
0283      * Those fields are needed only for streaming parsing so far
0284      */
0285     int               dictNames;    /* Use dictionary names for the tree */
0286     int               freeElemsNr;  /* number of freed element nodes */
0287     xmlNodePtr        freeElems;    /* List of freed element nodes */
0288     int               freeAttrsNr;  /* number of freed attributes nodes */
0289     xmlAttrPtr        freeAttrs;    /* List of freed attributes nodes */
0290 
0291     /*
0292      * the complete error information for the last error.
0293      */
0294     xmlError          lastError;
0295     xmlParserMode     parseMode;    /* the parser mode */
0296     unsigned long    nbentities;    /* unused */
0297     unsigned long  sizeentities;    /* size of external entities */
0298 
0299     /* for use by HTML non-recursive parser */
0300     xmlParserNodeInfo *nodeInfo;      /* Current NodeInfo */
0301     int                nodeInfoNr;    /* Depth of the parsing stack */
0302     int                nodeInfoMax;   /* Max depth of the parsing stack */
0303     xmlParserNodeInfo *nodeInfoTab;   /* array of nodeInfos */
0304 
0305     int                input_id;      /* we need to label inputs */
0306     unsigned long      sizeentcopy;   /* volume of entity copy */
0307 
0308     int           endCheckState;    /* quote state for push parser */
0309     unsigned short     nbErrors;    /* number of errors */
0310     unsigned short   nbWarnings;    /* number of warnings */
0311     unsigned            maxAmpl;    /* maximum amplification factor */
0312 
0313     xmlParserNsData       *nsdb;    /* namespace database */
0314     unsigned        attrHashMax;    /* allocated size */
0315     xmlAttrHashBucket *attrHash;    /* atttribute hash table */
0316 
0317     xmlStructuredErrorFunc errorHandler;
0318     void *errorCtxt;
0319 };
0320 
0321 /**
0322  * xmlSAXLocator:
0323  *
0324  * A SAX Locator.
0325  */
0326 struct _xmlSAXLocator {
0327     const xmlChar *(*getPublicId)(void *ctx);
0328     const xmlChar *(*getSystemId)(void *ctx);
0329     int (*getLineNumber)(void *ctx);
0330     int (*getColumnNumber)(void *ctx);
0331 };
0332 
0333 /**
0334  * xmlSAXHandler:
0335  *
0336  * A SAX handler is bunch of callbacks called by the parser when processing
0337  * of the input generate data or structure information.
0338  */
0339 
0340 /**
0341  * resolveEntitySAXFunc:
0342  * @ctx:  the user data (XML parser context)
0343  * @publicId: The public ID of the entity
0344  * @systemId: The system ID of the entity
0345  *
0346  * Callback:
0347  * The entity loader, to control the loading of external entities,
0348  * the application can either:
0349  *    - override this resolveEntity() callback in the SAX block
0350  *    - or better use the xmlSetExternalEntityLoader() function to
0351  *      set up it's own entity resolution routine
0352  *
0353  * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
0354  */
0355 typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
0356                 const xmlChar *publicId,
0357                 const xmlChar *systemId);
0358 /**
0359  * internalSubsetSAXFunc:
0360  * @ctx:  the user data (XML parser context)
0361  * @name:  the root element name
0362  * @ExternalID:  the external ID
0363  * @SystemID:  the SYSTEM ID (e.g. filename or URL)
0364  *
0365  * Callback on internal subset declaration.
0366  */
0367 typedef void (*internalSubsetSAXFunc) (void *ctx,
0368                 const xmlChar *name,
0369                 const xmlChar *ExternalID,
0370                 const xmlChar *SystemID);
0371 /**
0372  * externalSubsetSAXFunc:
0373  * @ctx:  the user data (XML parser context)
0374  * @name:  the root element name
0375  * @ExternalID:  the external ID
0376  * @SystemID:  the SYSTEM ID (e.g. filename or URL)
0377  *
0378  * Callback on external subset declaration.
0379  */
0380 typedef void (*externalSubsetSAXFunc) (void *ctx,
0381                 const xmlChar *name,
0382                 const xmlChar *ExternalID,
0383                 const xmlChar *SystemID);
0384 /**
0385  * getEntitySAXFunc:
0386  * @ctx:  the user data (XML parser context)
0387  * @name: The entity name
0388  *
0389  * Get an entity by name.
0390  *
0391  * Returns the xmlEntityPtr if found.
0392  */
0393 typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
0394                 const xmlChar *name);
0395 /**
0396  * getParameterEntitySAXFunc:
0397  * @ctx:  the user data (XML parser context)
0398  * @name: The entity name
0399  *
0400  * Get a parameter entity by name.
0401  *
0402  * Returns the xmlEntityPtr if found.
0403  */
0404 typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
0405                 const xmlChar *name);
0406 /**
0407  * entityDeclSAXFunc:
0408  * @ctx:  the user data (XML parser context)
0409  * @name:  the entity name
0410  * @type:  the entity type
0411  * @publicId: The public ID of the entity
0412  * @systemId: The system ID of the entity
0413  * @content: the entity value (without processing).
0414  *
0415  * An entity definition has been parsed.
0416  */
0417 typedef void (*entityDeclSAXFunc) (void *ctx,
0418                 const xmlChar *name,
0419                 int type,
0420                 const xmlChar *publicId,
0421                 const xmlChar *systemId,
0422                 xmlChar *content);
0423 /**
0424  * notationDeclSAXFunc:
0425  * @ctx:  the user data (XML parser context)
0426  * @name: The name of the notation
0427  * @publicId: The public ID of the entity
0428  * @systemId: The system ID of the entity
0429  *
0430  * What to do when a notation declaration has been parsed.
0431  */
0432 typedef void (*notationDeclSAXFunc)(void *ctx,
0433                 const xmlChar *name,
0434                 const xmlChar *publicId,
0435                 const xmlChar *systemId);
0436 /**
0437  * attributeDeclSAXFunc:
0438  * @ctx:  the user data (XML parser context)
0439  * @elem:  the name of the element
0440  * @fullname:  the attribute name
0441  * @type:  the attribute type
0442  * @def:  the type of default value
0443  * @defaultValue: the attribute default value
0444  * @tree:  the tree of enumerated value set
0445  *
0446  * An attribute definition has been parsed.
0447  */
0448 typedef void (*attributeDeclSAXFunc)(void *ctx,
0449                 const xmlChar *elem,
0450                 const xmlChar *fullname,
0451                 int type,
0452                 int def,
0453                 const xmlChar *defaultValue,
0454                 xmlEnumerationPtr tree);
0455 /**
0456  * elementDeclSAXFunc:
0457  * @ctx:  the user data (XML parser context)
0458  * @name:  the element name
0459  * @type:  the element type
0460  * @content: the element value tree
0461  *
0462  * An element definition has been parsed.
0463  */
0464 typedef void (*elementDeclSAXFunc)(void *ctx,
0465                 const xmlChar *name,
0466                 int type,
0467                 xmlElementContentPtr content);
0468 /**
0469  * unparsedEntityDeclSAXFunc:
0470  * @ctx:  the user data (XML parser context)
0471  * @name: The name of the entity
0472  * @publicId: The public ID of the entity
0473  * @systemId: The system ID of the entity
0474  * @notationName: the name of the notation
0475  *
0476  * What to do when an unparsed entity declaration is parsed.
0477  */
0478 typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
0479                 const xmlChar *name,
0480                 const xmlChar *publicId,
0481                 const xmlChar *systemId,
0482                 const xmlChar *notationName);
0483 /**
0484  * setDocumentLocatorSAXFunc:
0485  * @ctx:  the user data (XML parser context)
0486  * @loc: A SAX Locator
0487  *
0488  * Receive the document locator at startup, actually xmlDefaultSAXLocator.
0489  * Everything is available on the context, so this is useless in our case.
0490  */
0491 typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
0492                 xmlSAXLocatorPtr loc);
0493 /**
0494  * startDocumentSAXFunc:
0495  * @ctx:  the user data (XML parser context)
0496  *
0497  * Called when the document start being processed.
0498  */
0499 typedef void (*startDocumentSAXFunc) (void *ctx);
0500 /**
0501  * endDocumentSAXFunc:
0502  * @ctx:  the user data (XML parser context)
0503  *
0504  * Called when the document end has been detected.
0505  */
0506 typedef void (*endDocumentSAXFunc) (void *ctx);
0507 /**
0508  * startElementSAXFunc:
0509  * @ctx:  the user data (XML parser context)
0510  * @name:  The element name, including namespace prefix
0511  * @atts:  An array of name/value attributes pairs, NULL terminated
0512  *
0513  * Called when an opening tag has been processed.
0514  */
0515 typedef void (*startElementSAXFunc) (void *ctx,
0516                 const xmlChar *name,
0517                 const xmlChar **atts);
0518 /**
0519  * endElementSAXFunc:
0520  * @ctx:  the user data (XML parser context)
0521  * @name:  The element name
0522  *
0523  * Called when the end of an element has been detected.
0524  */
0525 typedef void (*endElementSAXFunc) (void *ctx,
0526                 const xmlChar *name);
0527 /**
0528  * attributeSAXFunc:
0529  * @ctx:  the user data (XML parser context)
0530  * @name:  The attribute name, including namespace prefix
0531  * @value:  The attribute value
0532  *
0533  * Handle an attribute that has been read by the parser.
0534  * The default handling is to convert the attribute into an
0535  * DOM subtree and past it in a new xmlAttr element added to
0536  * the element.
0537  */
0538 typedef void (*attributeSAXFunc) (void *ctx,
0539                 const xmlChar *name,
0540                 const xmlChar *value);
0541 /**
0542  * referenceSAXFunc:
0543  * @ctx:  the user data (XML parser context)
0544  * @name:  The entity name
0545  *
0546  * Called when an entity reference is detected.
0547  */
0548 typedef void (*referenceSAXFunc) (void *ctx,
0549                 const xmlChar *name);
0550 /**
0551  * charactersSAXFunc:
0552  * @ctx:  the user data (XML parser context)
0553  * @ch:  a xmlChar string
0554  * @len: the number of xmlChar
0555  *
0556  * Receiving some chars from the parser.
0557  */
0558 typedef void (*charactersSAXFunc) (void *ctx,
0559                 const xmlChar *ch,
0560                 int len);
0561 /**
0562  * ignorableWhitespaceSAXFunc:
0563  * @ctx:  the user data (XML parser context)
0564  * @ch:  a xmlChar string
0565  * @len: the number of xmlChar
0566  *
0567  * Receiving some ignorable whitespaces from the parser.
0568  * UNUSED: by default the DOM building will use characters.
0569  */
0570 typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
0571                 const xmlChar *ch,
0572                 int len);
0573 /**
0574  * processingInstructionSAXFunc:
0575  * @ctx:  the user data (XML parser context)
0576  * @target:  the target name
0577  * @data: the PI data's
0578  *
0579  * A processing instruction has been parsed.
0580  */
0581 typedef void (*processingInstructionSAXFunc) (void *ctx,
0582                 const xmlChar *target,
0583                 const xmlChar *data);
0584 /**
0585  * commentSAXFunc:
0586  * @ctx:  the user data (XML parser context)
0587  * @value:  the comment content
0588  *
0589  * A comment has been parsed.
0590  */
0591 typedef void (*commentSAXFunc) (void *ctx,
0592                 const xmlChar *value);
0593 /**
0594  * cdataBlockSAXFunc:
0595  * @ctx:  the user data (XML parser context)
0596  * @value:  The pcdata content
0597  * @len:  the block length
0598  *
0599  * Called when a pcdata block has been parsed.
0600  */
0601 typedef void (*cdataBlockSAXFunc) (
0602                             void *ctx,
0603                 const xmlChar *value,
0604                 int len);
0605 /**
0606  * warningSAXFunc:
0607  * @ctx:  an XML parser context
0608  * @msg:  the message to display/transmit
0609  * @...:  extra parameters for the message display
0610  *
0611  * Display and format a warning messages, callback.
0612  */
0613 typedef void (*warningSAXFunc) (void *ctx,
0614                 const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
0615 /**
0616  * errorSAXFunc:
0617  * @ctx:  an XML parser context
0618  * @msg:  the message to display/transmit
0619  * @...:  extra parameters for the message display
0620  *
0621  * Display and format an error messages, callback.
0622  */
0623 typedef void (*errorSAXFunc) (void *ctx,
0624                 const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
0625 /**
0626  * fatalErrorSAXFunc:
0627  * @ctx:  an XML parser context
0628  * @msg:  the message to display/transmit
0629  * @...:  extra parameters for the message display
0630  *
0631  * Display and format fatal error messages, callback.
0632  * Note: so far fatalError() SAX callbacks are not used, error()
0633  *       get all the callbacks for errors.
0634  */
0635 typedef void (*fatalErrorSAXFunc) (void *ctx,
0636                 const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
0637 /**
0638  * isStandaloneSAXFunc:
0639  * @ctx:  the user data (XML parser context)
0640  *
0641  * Is this document tagged standalone?
0642  *
0643  * Returns 1 if true
0644  */
0645 typedef int (*isStandaloneSAXFunc) (void *ctx);
0646 /**
0647  * hasInternalSubsetSAXFunc:
0648  * @ctx:  the user data (XML parser context)
0649  *
0650  * Does this document has an internal subset.
0651  *
0652  * Returns 1 if true
0653  */
0654 typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
0655 
0656 /**
0657  * hasExternalSubsetSAXFunc:
0658  * @ctx:  the user data (XML parser context)
0659  *
0660  * Does this document has an external subset?
0661  *
0662  * Returns 1 if true
0663  */
0664 typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
0665 
0666 /************************************************************************
0667  *                                  *
0668  *          The SAX version 2 API extensions        *
0669  *                                  *
0670  ************************************************************************/
0671 /**
0672  * XML_SAX2_MAGIC:
0673  *
0674  * Special constant found in SAX2 blocks initialized fields
0675  */
0676 #define XML_SAX2_MAGIC 0xDEEDBEAF
0677 
0678 /**
0679  * startElementNsSAX2Func:
0680  * @ctx:  the user data (XML parser context)
0681  * @localname:  the local name of the element
0682  * @prefix:  the element namespace prefix if available
0683  * @URI:  the element namespace name if available
0684  * @nb_namespaces:  number of namespace definitions on that node
0685  * @namespaces:  pointer to the array of prefix/URI pairs namespace definitions
0686  * @nb_attributes:  the number of attributes on that node
0687  * @nb_defaulted:  the number of defaulted attributes. The defaulted
0688  *                  ones are at the end of the array
0689  * @attributes:  pointer to the array of (localname/prefix/URI/value/end)
0690  *               attribute values.
0691  *
0692  * SAX2 callback when an element start has been detected by the parser.
0693  * It provides the namespace information for the element, as well as
0694  * the new namespace declarations on the element.
0695  */
0696 
0697 typedef void (*startElementNsSAX2Func) (void *ctx,
0698                     const xmlChar *localname,
0699                     const xmlChar *prefix,
0700                     const xmlChar *URI,
0701                     int nb_namespaces,
0702                     const xmlChar **namespaces,
0703                     int nb_attributes,
0704                     int nb_defaulted,
0705                     const xmlChar **attributes);
0706 
0707 /**
0708  * endElementNsSAX2Func:
0709  * @ctx:  the user data (XML parser context)
0710  * @localname:  the local name of the element
0711  * @prefix:  the element namespace prefix if available
0712  * @URI:  the element namespace name if available
0713  *
0714  * SAX2 callback when an element end has been detected by the parser.
0715  * It provides the namespace information for the element.
0716  */
0717 
0718 typedef void (*endElementNsSAX2Func)   (void *ctx,
0719                     const xmlChar *localname,
0720                     const xmlChar *prefix,
0721                     const xmlChar *URI);
0722 
0723 
0724 struct _xmlSAXHandler {
0725     internalSubsetSAXFunc internalSubset;
0726     isStandaloneSAXFunc isStandalone;
0727     hasInternalSubsetSAXFunc hasInternalSubset;
0728     hasExternalSubsetSAXFunc hasExternalSubset;
0729     resolveEntitySAXFunc resolveEntity;
0730     getEntitySAXFunc getEntity;
0731     entityDeclSAXFunc entityDecl;
0732     notationDeclSAXFunc notationDecl;
0733     attributeDeclSAXFunc attributeDecl;
0734     elementDeclSAXFunc elementDecl;
0735     unparsedEntityDeclSAXFunc unparsedEntityDecl;
0736     setDocumentLocatorSAXFunc setDocumentLocator;
0737     startDocumentSAXFunc startDocument;
0738     endDocumentSAXFunc endDocument;
0739     /*
0740      * `startElement` and `endElement` are only used by the legacy SAX1
0741      * interface and should not be used in new software. If you really
0742      * have to enable SAX1, the preferred way is set the `initialized`
0743      * member to 1 instead of XML_SAX2_MAGIC.
0744      *
0745      * For backward compatibility, it's also possible to set the
0746      * `startElementNs` and `endElementNs` handlers to NULL.
0747      *
0748      * You can also set the XML_PARSE_SAX1 parser option, but versions
0749      * older than 2.12.0 will probably crash if this option is provided
0750      * together with custom SAX callbacks.
0751      */
0752     startElementSAXFunc startElement;
0753     endElementSAXFunc endElement;
0754     referenceSAXFunc reference;
0755     charactersSAXFunc characters;
0756     ignorableWhitespaceSAXFunc ignorableWhitespace;
0757     processingInstructionSAXFunc processingInstruction;
0758     commentSAXFunc comment;
0759     warningSAXFunc warning;
0760     errorSAXFunc error;
0761     fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
0762     getParameterEntitySAXFunc getParameterEntity;
0763     cdataBlockSAXFunc cdataBlock;
0764     externalSubsetSAXFunc externalSubset;
0765     /*
0766      * `initialized` should always be set to XML_SAX2_MAGIC to enable the
0767      * modern SAX2 interface.
0768      */
0769     unsigned int initialized;
0770     /*
0771      * The following members are only used by the SAX2 interface.
0772      */
0773     void *_private;
0774     startElementNsSAX2Func startElementNs;
0775     endElementNsSAX2Func endElementNs;
0776     xmlStructuredErrorFunc serror;
0777 };
0778 
0779 /*
0780  * SAX Version 1
0781  */
0782 typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
0783 typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
0784 struct _xmlSAXHandlerV1 {
0785     internalSubsetSAXFunc internalSubset;
0786     isStandaloneSAXFunc isStandalone;
0787     hasInternalSubsetSAXFunc hasInternalSubset;
0788     hasExternalSubsetSAXFunc hasExternalSubset;
0789     resolveEntitySAXFunc resolveEntity;
0790     getEntitySAXFunc getEntity;
0791     entityDeclSAXFunc entityDecl;
0792     notationDeclSAXFunc notationDecl;
0793     attributeDeclSAXFunc attributeDecl;
0794     elementDeclSAXFunc elementDecl;
0795     unparsedEntityDeclSAXFunc unparsedEntityDecl;
0796     setDocumentLocatorSAXFunc setDocumentLocator;
0797     startDocumentSAXFunc startDocument;
0798     endDocumentSAXFunc endDocument;
0799     startElementSAXFunc startElement;
0800     endElementSAXFunc endElement;
0801     referenceSAXFunc reference;
0802     charactersSAXFunc characters;
0803     ignorableWhitespaceSAXFunc ignorableWhitespace;
0804     processingInstructionSAXFunc processingInstruction;
0805     commentSAXFunc comment;
0806     warningSAXFunc warning;
0807     errorSAXFunc error;
0808     fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
0809     getParameterEntitySAXFunc getParameterEntity;
0810     cdataBlockSAXFunc cdataBlock;
0811     externalSubsetSAXFunc externalSubset;
0812     unsigned int initialized;
0813 };
0814 
0815 
0816 /**
0817  * xmlExternalEntityLoader:
0818  * @URL: The System ID of the resource requested
0819  * @ID: The Public ID of the resource requested
0820  * @context: the XML parser context
0821  *
0822  * External entity loaders types.
0823  *
0824  * Returns the entity input parser.
0825  */
0826 typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
0827                      const char *ID,
0828                      xmlParserCtxtPtr context);
0829 
0830 /*
0831  * Variables
0832  */
0833 
0834 XMLPUBVAR const char *const xmlParserVersion;
0835 XML_DEPRECATED
0836 XMLPUBVAR const int oldXMLWDcompatibility;
0837 XML_DEPRECATED
0838 XMLPUBVAR const int xmlParserDebugEntities;
0839 XML_DEPRECATED
0840 XMLPUBVAR const xmlSAXLocator xmlDefaultSAXLocator;
0841 #ifdef LIBXML_SAX1_ENABLED
0842 XML_DEPRECATED
0843 XMLPUBVAR const xmlSAXHandlerV1 xmlDefaultSAXHandler;
0844 #endif
0845 
0846 #ifdef LIBXML_THREAD_ENABLED
0847 /* backward compatibility */
0848 XMLPUBFUN const char *const *__xmlParserVersion(void);
0849 XML_DEPRECATED
0850 XMLPUBFUN const int *__oldXMLWDcompatibility(void);
0851 XML_DEPRECATED
0852 XMLPUBFUN const int *__xmlParserDebugEntities(void);
0853 XML_DEPRECATED
0854 XMLPUBFUN const xmlSAXLocator *__xmlDefaultSAXLocator(void);
0855 #ifdef LIBXML_SAX1_ENABLED
0856 XML_DEPRECATED
0857 XMLPUBFUN const xmlSAXHandlerV1 *__xmlDefaultSAXHandler(void);
0858 #endif
0859 #endif
0860 
0861 /** DOC_DISABLE */
0862 #define XML_GLOBALS_PARSER_CORE \
0863   XML_OP(xmlDoValidityCheckingDefaultValue, int, XML_DEPRECATED) \
0864   XML_OP(xmlGetWarningsDefaultValue, int, XML_DEPRECATED) \
0865   XML_OP(xmlKeepBlanksDefaultValue, int, XML_DEPRECATED) \
0866   XML_OP(xmlLineNumbersDefaultValue, int, XML_DEPRECATED) \
0867   XML_OP(xmlLoadExtDtdDefaultValue, int, XML_DEPRECATED) \
0868   XML_OP(xmlPedanticParserDefaultValue, int, XML_DEPRECATED) \
0869   XML_OP(xmlSubstituteEntitiesDefaultValue, int, XML_DEPRECATED)
0870 
0871 #ifdef LIBXML_OUTPUT_ENABLED
0872   #define XML_GLOBALS_PARSER_OUTPUT \
0873     XML_OP(xmlIndentTreeOutput, int, XML_NO_ATTR) \
0874     XML_OP(xmlTreeIndentString, const char *, XML_NO_ATTR) \
0875     XML_OP(xmlSaveNoEmptyTags, int, XML_NO_ATTR)
0876 #else
0877   #define XML_GLOBALS_PARSER_OUTPUT
0878 #endif
0879 
0880 #define XML_GLOBALS_PARSER \
0881   XML_GLOBALS_PARSER_CORE \
0882   XML_GLOBALS_PARSER_OUTPUT
0883 
0884 #define XML_OP XML_DECLARE_GLOBAL
0885 XML_GLOBALS_PARSER
0886 #undef XML_OP
0887 
0888 #if defined(LIBXML_THREAD_ENABLED) && !defined(XML_GLOBALS_NO_REDEFINITION)
0889   #define xmlDoValidityCheckingDefaultValue \
0890     XML_GLOBAL_MACRO(xmlDoValidityCheckingDefaultValue)
0891   #define xmlGetWarningsDefaultValue \
0892     XML_GLOBAL_MACRO(xmlGetWarningsDefaultValue)
0893   #define xmlKeepBlanksDefaultValue XML_GLOBAL_MACRO(xmlKeepBlanksDefaultValue)
0894   #define xmlLineNumbersDefaultValue \
0895     XML_GLOBAL_MACRO(xmlLineNumbersDefaultValue)
0896   #define xmlLoadExtDtdDefaultValue XML_GLOBAL_MACRO(xmlLoadExtDtdDefaultValue)
0897   #define xmlPedanticParserDefaultValue \
0898     XML_GLOBAL_MACRO(xmlPedanticParserDefaultValue)
0899   #define xmlSubstituteEntitiesDefaultValue \
0900     XML_GLOBAL_MACRO(xmlSubstituteEntitiesDefaultValue)
0901   #ifdef LIBXML_OUTPUT_ENABLED
0902     #define xmlIndentTreeOutput XML_GLOBAL_MACRO(xmlIndentTreeOutput)
0903     #define xmlTreeIndentString XML_GLOBAL_MACRO(xmlTreeIndentString)
0904     #define xmlSaveNoEmptyTags XML_GLOBAL_MACRO(xmlSaveNoEmptyTags)
0905   #endif
0906 #endif
0907 /** DOC_ENABLE */
0908 
0909 /*
0910  * Init/Cleanup
0911  */
0912 XMLPUBFUN void
0913         xmlInitParser       (void);
0914 XMLPUBFUN void
0915         xmlCleanupParser    (void);
0916 XML_DEPRECATED
0917 XMLPUBFUN void
0918         xmlInitGlobals      (void);
0919 XML_DEPRECATED
0920 XMLPUBFUN void
0921         xmlCleanupGlobals   (void);
0922 
0923 /*
0924  * Input functions
0925  */
0926 XML_DEPRECATED
0927 XMLPUBFUN int
0928         xmlParserInputRead  (xmlParserInputPtr in,
0929                      int len);
0930 XML_DEPRECATED
0931 XMLPUBFUN int
0932         xmlParserInputGrow  (xmlParserInputPtr in,
0933                      int len);
0934 
0935 /*
0936  * Basic parsing Interfaces
0937  */
0938 #ifdef LIBXML_SAX1_ENABLED
0939 XMLPUBFUN xmlDocPtr
0940         xmlParseDoc     (const xmlChar *cur);
0941 XMLPUBFUN xmlDocPtr
0942         xmlParseFile        (const char *filename);
0943 XMLPUBFUN xmlDocPtr
0944         xmlParseMemory      (const char *buffer,
0945                      int size);
0946 #endif /* LIBXML_SAX1_ENABLED */
0947 XML_DEPRECATED XMLPUBFUN int
0948         xmlSubstituteEntitiesDefault(int val);
0949 XML_DEPRECATED XMLPUBFUN int
0950                 xmlThrDefSubstituteEntitiesDefaultValue(int v);
0951 XMLPUBFUN int
0952         xmlKeepBlanksDefault    (int val);
0953 XML_DEPRECATED XMLPUBFUN int
0954         xmlThrDefKeepBlanksDefaultValue(int v);
0955 XMLPUBFUN void
0956         xmlStopParser       (xmlParserCtxtPtr ctxt);
0957 XML_DEPRECATED XMLPUBFUN int
0958         xmlPedanticParserDefault(int val);
0959 XML_DEPRECATED XMLPUBFUN int
0960                 xmlThrDefPedanticParserDefaultValue(int v);
0961 XML_DEPRECATED XMLPUBFUN int
0962         xmlLineNumbersDefault   (int val);
0963 XML_DEPRECATED XMLPUBFUN int
0964                 xmlThrDefLineNumbersDefaultValue(int v);
0965 XML_DEPRECATED XMLPUBFUN int
0966                 xmlThrDefDoValidityCheckingDefaultValue(int v);
0967 XML_DEPRECATED XMLPUBFUN int
0968                 xmlThrDefGetWarningsDefaultValue(int v);
0969 XML_DEPRECATED XMLPUBFUN int
0970                 xmlThrDefLoadExtDtdDefaultValue(int v);
0971 XML_DEPRECATED XMLPUBFUN int
0972                 xmlThrDefParserDebugEntities(int v);
0973 
0974 #ifdef LIBXML_SAX1_ENABLED
0975 /*
0976  * Recovery mode
0977  */
0978 XML_DEPRECATED
0979 XMLPUBFUN xmlDocPtr
0980         xmlRecoverDoc       (const xmlChar *cur);
0981 XML_DEPRECATED
0982 XMLPUBFUN xmlDocPtr
0983         xmlRecoverMemory    (const char *buffer,
0984                      int size);
0985 XML_DEPRECATED
0986 XMLPUBFUN xmlDocPtr
0987         xmlRecoverFile      (const char *filename);
0988 #endif /* LIBXML_SAX1_ENABLED */
0989 
0990 /*
0991  * Less common routines and SAX interfaces
0992  */
0993 XMLPUBFUN int
0994         xmlParseDocument    (xmlParserCtxtPtr ctxt);
0995 XMLPUBFUN int
0996         xmlParseExtParsedEnt    (xmlParserCtxtPtr ctxt);
0997 #ifdef LIBXML_SAX1_ENABLED
0998 XML_DEPRECATED
0999 XMLPUBFUN int
1000         xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
1001                      void *user_data,
1002                      const char *filename);
1003 XML_DEPRECATED
1004 XMLPUBFUN int
1005         xmlSAXUserParseMemory   (xmlSAXHandlerPtr sax,
1006                      void *user_data,
1007                      const char *buffer,
1008                      int size);
1009 XML_DEPRECATED
1010 XMLPUBFUN xmlDocPtr
1011         xmlSAXParseDoc      (xmlSAXHandlerPtr sax,
1012                      const xmlChar *cur,
1013                      int recovery);
1014 XML_DEPRECATED
1015 XMLPUBFUN xmlDocPtr
1016         xmlSAXParseMemory   (xmlSAXHandlerPtr sax,
1017                      const char *buffer,
1018                      int size,
1019                      int recovery);
1020 XML_DEPRECATED
1021 XMLPUBFUN xmlDocPtr
1022         xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
1023                      const char *buffer,
1024                      int size,
1025                      int recovery,
1026                      void *data);
1027 XML_DEPRECATED
1028 XMLPUBFUN xmlDocPtr
1029         xmlSAXParseFile     (xmlSAXHandlerPtr sax,
1030                      const char *filename,
1031                      int recovery);
1032 XML_DEPRECATED
1033 XMLPUBFUN xmlDocPtr
1034         xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
1035                      const char *filename,
1036                      int recovery,
1037                      void *data);
1038 XML_DEPRECATED
1039 XMLPUBFUN xmlDocPtr
1040         xmlSAXParseEntity   (xmlSAXHandlerPtr sax,
1041                      const char *filename);
1042 XML_DEPRECATED
1043 XMLPUBFUN xmlDocPtr
1044         xmlParseEntity      (const char *filename);
1045 #endif /* LIBXML_SAX1_ENABLED */
1046 
1047 #ifdef LIBXML_VALID_ENABLED
1048 XML_DEPRECATED
1049 XMLPUBFUN xmlDtdPtr
1050         xmlSAXParseDTD      (xmlSAXHandlerPtr sax,
1051                      const xmlChar *ExternalID,
1052                      const xmlChar *SystemID);
1053 XMLPUBFUN xmlDtdPtr
1054         xmlParseDTD     (const xmlChar *ExternalID,
1055                      const xmlChar *SystemID);
1056 XMLPUBFUN xmlDtdPtr
1057         xmlIOParseDTD       (xmlSAXHandlerPtr sax,
1058                      xmlParserInputBufferPtr input,
1059                      xmlCharEncoding enc);
1060 #endif /* LIBXML_VALID_ENABLE */
1061 #ifdef LIBXML_SAX1_ENABLED
1062 XMLPUBFUN int
1063         xmlParseBalancedChunkMemory(xmlDocPtr doc,
1064                      xmlSAXHandlerPtr sax,
1065                      void *user_data,
1066                      int depth,
1067                      const xmlChar *string,
1068                      xmlNodePtr *lst);
1069 #endif /* LIBXML_SAX1_ENABLED */
1070 XMLPUBFUN xmlParserErrors
1071         xmlParseInNodeContext   (xmlNodePtr node,
1072                      const char *data,
1073                      int datalen,
1074                      int options,
1075                      xmlNodePtr *lst);
1076 #ifdef LIBXML_SAX1_ENABLED
1077 XMLPUBFUN int
1078         xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
1079                      xmlSAXHandlerPtr sax,
1080                      void *user_data,
1081                      int depth,
1082                      const xmlChar *string,
1083                      xmlNodePtr *lst,
1084                      int recover);
1085 XML_DEPRECATED
1086 XMLPUBFUN int
1087         xmlParseExternalEntity  (xmlDocPtr doc,
1088                      xmlSAXHandlerPtr sax,
1089                      void *user_data,
1090                      int depth,
1091                      const xmlChar *URL,
1092                      const xmlChar *ID,
1093                      xmlNodePtr *lst);
1094 #endif /* LIBXML_SAX1_ENABLED */
1095 XMLPUBFUN int
1096         xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
1097                      const xmlChar *URL,
1098                      const xmlChar *ID,
1099                      xmlNodePtr *lst);
1100 
1101 /*
1102  * Parser contexts handling.
1103  */
1104 XMLPUBFUN xmlParserCtxtPtr
1105         xmlNewParserCtxt    (void);
1106 XMLPUBFUN xmlParserCtxtPtr
1107         xmlNewSAXParserCtxt (const xmlSAXHandler *sax,
1108                      void *userData);
1109 XMLPUBFUN int
1110         xmlInitParserCtxt   (xmlParserCtxtPtr ctxt);
1111 XMLPUBFUN void
1112         xmlClearParserCtxt  (xmlParserCtxtPtr ctxt);
1113 XMLPUBFUN void
1114         xmlFreeParserCtxt   (xmlParserCtxtPtr ctxt);
1115 #ifdef LIBXML_SAX1_ENABLED
1116 XML_DEPRECATED
1117 XMLPUBFUN void
1118         xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
1119                      const xmlChar* buffer,
1120                      const char *filename);
1121 #endif /* LIBXML_SAX1_ENABLED */
1122 XMLPUBFUN xmlParserCtxtPtr
1123         xmlCreateDocParserCtxt  (const xmlChar *cur);
1124 
1125 #ifdef LIBXML_LEGACY_ENABLED
1126 /*
1127  * Reading/setting optional parsing features.
1128  */
1129 XML_DEPRECATED
1130 XMLPUBFUN int
1131         xmlGetFeaturesList  (int *len,
1132                      const char **result);
1133 XML_DEPRECATED
1134 XMLPUBFUN int
1135         xmlGetFeature       (xmlParserCtxtPtr ctxt,
1136                      const char *name,
1137                      void *result);
1138 XML_DEPRECATED
1139 XMLPUBFUN int
1140         xmlSetFeature       (xmlParserCtxtPtr ctxt,
1141                      const char *name,
1142                      void *value);
1143 #endif /* LIBXML_LEGACY_ENABLED */
1144 
1145 #ifdef LIBXML_PUSH_ENABLED
1146 /*
1147  * Interfaces for the Push mode.
1148  */
1149 XMLPUBFUN xmlParserCtxtPtr
1150         xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
1151                      void *user_data,
1152                      const char *chunk,
1153                      int size,
1154                      const char *filename);
1155 XMLPUBFUN int
1156         xmlParseChunk       (xmlParserCtxtPtr ctxt,
1157                      const char *chunk,
1158                      int size,
1159                      int terminate);
1160 #endif /* LIBXML_PUSH_ENABLED */
1161 
1162 /*
1163  * Special I/O mode.
1164  */
1165 
1166 XMLPUBFUN xmlParserCtxtPtr
1167         xmlCreateIOParserCtxt   (xmlSAXHandlerPtr sax,
1168                      void *user_data,
1169                      xmlInputReadCallback   ioread,
1170                      xmlInputCloseCallback  ioclose,
1171                      void *ioctx,
1172                      xmlCharEncoding enc);
1173 
1174 XMLPUBFUN xmlParserInputPtr
1175         xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
1176                      xmlParserInputBufferPtr input,
1177                      xmlCharEncoding enc);
1178 
1179 /*
1180  * Node infos.
1181  */
1182 XMLPUBFUN const xmlParserNodeInfo*
1183         xmlParserFindNodeInfo   (xmlParserCtxtPtr ctxt,
1184                          xmlNodePtr node);
1185 XMLPUBFUN void
1186         xmlInitNodeInfoSeq  (xmlParserNodeInfoSeqPtr seq);
1187 XMLPUBFUN void
1188         xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1189 XMLPUBFUN unsigned long
1190         xmlParserFindNodeInfoIndex(xmlParserNodeInfoSeqPtr seq,
1191                                          xmlNodePtr node);
1192 XMLPUBFUN void
1193         xmlParserAddNodeInfo    (xmlParserCtxtPtr ctxt,
1194                      xmlParserNodeInfoPtr info);
1195 
1196 /*
1197  * External entities handling actually implemented in xmlIO.
1198  */
1199 
1200 XMLPUBFUN void
1201         xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1202 XMLPUBFUN xmlExternalEntityLoader
1203         xmlGetExternalEntityLoader(void);
1204 XMLPUBFUN xmlParserInputPtr
1205         xmlLoadExternalEntity   (const char *URL,
1206                      const char *ID,
1207                      xmlParserCtxtPtr ctxt);
1208 
1209 /*
1210  * Index lookup, actually implemented in the encoding module
1211  */
1212 XMLPUBFUN long
1213         xmlByteConsumed     (xmlParserCtxtPtr ctxt);
1214 
1215 /*
1216  * New set of simpler/more flexible APIs
1217  */
1218 /**
1219  * xmlParserOption:
1220  *
1221  * This is the set of XML parser options that can be passed down
1222  * to the xmlReadDoc() and similar calls.
1223  */
1224 typedef enum {
1225     XML_PARSE_RECOVER   = 1<<0, /* recover on errors */
1226     XML_PARSE_NOENT = 1<<1, /* substitute entities */
1227     XML_PARSE_DTDLOAD   = 1<<2, /* load the external subset */
1228     XML_PARSE_DTDATTR   = 1<<3, /* default DTD attributes */
1229     XML_PARSE_DTDVALID  = 1<<4, /* validate with the DTD */
1230     XML_PARSE_NOERROR   = 1<<5, /* suppress error reports */
1231     XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1232     XML_PARSE_PEDANTIC  = 1<<7, /* pedantic error reporting */
1233     XML_PARSE_NOBLANKS  = 1<<8, /* remove blank nodes */
1234     XML_PARSE_SAX1  = 1<<9, /* use the SAX1 interface internally */
1235     XML_PARSE_XINCLUDE  = 1<<10,/* Implement XInclude substitution  */
1236     XML_PARSE_NONET = 1<<11,/* Forbid network access */
1237     XML_PARSE_NODICT    = 1<<12,/* Do not reuse the context dictionary */
1238     XML_PARSE_NSCLEAN   = 1<<13,/* remove redundant namespaces declarations */
1239     XML_PARSE_NOCDATA   = 1<<14,/* merge CDATA as text nodes */
1240     XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */
1241     XML_PARSE_COMPACT   = 1<<16,/* compact small text nodes; no modification of
1242                                    the tree allowed afterwards (will possibly
1243                    crash if you try to modify the tree) */
1244     XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */
1245     XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */
1246     XML_PARSE_HUGE      = 1<<19,/* relax any hardcoded limit from the parser */
1247     XML_PARSE_OLDSAX    = 1<<20,/* parse using SAX2 interface before 2.7.0 */
1248     XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */
1249     XML_PARSE_BIG_LINES = 1<<22,/* Store big lines numbers in text PSVI field */
1250     XML_PARSE_NO_XXE    = 1<<23 /* disable loading of external content */
1251 } xmlParserOption;
1252 
1253 XMLPUBFUN void
1254         xmlCtxtReset        (xmlParserCtxtPtr ctxt);
1255 XMLPUBFUN int
1256         xmlCtxtResetPush    (xmlParserCtxtPtr ctxt,
1257                      const char *chunk,
1258                      int size,
1259                      const char *filename,
1260                      const char *encoding);
1261 XMLPUBFUN int
1262         xmlCtxtSetOptions   (xmlParserCtxtPtr ctxt,
1263                      int options);
1264 XMLPUBFUN int
1265         xmlCtxtUseOptions   (xmlParserCtxtPtr ctxt,
1266                      int options);
1267 XMLPUBFUN void
1268         xmlCtxtSetErrorHandler  (xmlParserCtxtPtr ctxt,
1269                      xmlStructuredErrorFunc handler,
1270                      void *data);
1271 XMLPUBFUN void
1272         xmlCtxtSetMaxAmplification(xmlParserCtxtPtr ctxt,
1273                      unsigned maxAmpl);
1274 XMLPUBFUN xmlDocPtr
1275         xmlReadDoc      (const xmlChar *cur,
1276                      const char *URL,
1277                      const char *encoding,
1278                      int options);
1279 XMLPUBFUN xmlDocPtr
1280         xmlReadFile     (const char *URL,
1281                      const char *encoding,
1282                      int options);
1283 XMLPUBFUN xmlDocPtr
1284         xmlReadMemory       (const char *buffer,
1285                      int size,
1286                      const char *URL,
1287                      const char *encoding,
1288                      int options);
1289 XMLPUBFUN xmlDocPtr
1290         xmlReadFd       (int fd,
1291                      const char *URL,
1292                      const char *encoding,
1293                      int options);
1294 XMLPUBFUN xmlDocPtr
1295         xmlReadIO       (xmlInputReadCallback ioread,
1296                      xmlInputCloseCallback ioclose,
1297                      void *ioctx,
1298                      const char *URL,
1299                      const char *encoding,
1300                      int options);
1301 XMLPUBFUN xmlDocPtr
1302         xmlCtxtParseDocument    (xmlParserCtxtPtr ctxt,
1303                      xmlParserInputPtr input);
1304 XMLPUBFUN xmlDocPtr
1305         xmlCtxtReadDoc      (xmlParserCtxtPtr ctxt,
1306                      const xmlChar *cur,
1307                      const char *URL,
1308                      const char *encoding,
1309                      int options);
1310 XMLPUBFUN xmlDocPtr
1311         xmlCtxtReadFile     (xmlParserCtxtPtr ctxt,
1312                      const char *filename,
1313                      const char *encoding,
1314                      int options);
1315 XMLPUBFUN xmlDocPtr
1316         xmlCtxtReadMemory       (xmlParserCtxtPtr ctxt,
1317                      const char *buffer,
1318                      int size,
1319                      const char *URL,
1320                      const char *encoding,
1321                      int options);
1322 XMLPUBFUN xmlDocPtr
1323         xmlCtxtReadFd       (xmlParserCtxtPtr ctxt,
1324                      int fd,
1325                      const char *URL,
1326                      const char *encoding,
1327                      int options);
1328 XMLPUBFUN xmlDocPtr
1329         xmlCtxtReadIO       (xmlParserCtxtPtr ctxt,
1330                      xmlInputReadCallback ioread,
1331                      xmlInputCloseCallback ioclose,
1332                      void *ioctx,
1333                      const char *URL,
1334                      const char *encoding,
1335                      int options);
1336 
1337 /*
1338  * Library wide options
1339  */
1340 /**
1341  * xmlFeature:
1342  *
1343  * Used to examine the existence of features that can be enabled
1344  * or disabled at compile-time.
1345  * They used to be called XML_FEATURE_xxx but this clashed with Expat
1346  */
1347 typedef enum {
1348     XML_WITH_THREAD = 1,
1349     XML_WITH_TREE = 2,
1350     XML_WITH_OUTPUT = 3,
1351     XML_WITH_PUSH = 4,
1352     XML_WITH_READER = 5,
1353     XML_WITH_PATTERN = 6,
1354     XML_WITH_WRITER = 7,
1355     XML_WITH_SAX1 = 8,
1356     XML_WITH_FTP = 9,
1357     XML_WITH_HTTP = 10,
1358     XML_WITH_VALID = 11,
1359     XML_WITH_HTML = 12,
1360     XML_WITH_LEGACY = 13,
1361     XML_WITH_C14N = 14,
1362     XML_WITH_CATALOG = 15,
1363     XML_WITH_XPATH = 16,
1364     XML_WITH_XPTR = 17,
1365     XML_WITH_XINCLUDE = 18,
1366     XML_WITH_ICONV = 19,
1367     XML_WITH_ISO8859X = 20,
1368     XML_WITH_UNICODE = 21,
1369     XML_WITH_REGEXP = 22,
1370     XML_WITH_AUTOMATA = 23,
1371     XML_WITH_EXPR = 24,
1372     XML_WITH_SCHEMAS = 25,
1373     XML_WITH_SCHEMATRON = 26,
1374     XML_WITH_MODULES = 27,
1375     XML_WITH_DEBUG = 28,
1376     XML_WITH_DEBUG_MEM = 29,
1377     XML_WITH_DEBUG_RUN = 30, /* unused */
1378     XML_WITH_ZLIB = 31,
1379     XML_WITH_ICU = 32,
1380     XML_WITH_LZMA = 33,
1381     XML_WITH_NONE = 99999 /* just to be sure of allocation size */
1382 } xmlFeature;
1383 
1384 XMLPUBFUN int
1385         xmlHasFeature       (xmlFeature feature);
1386 
1387 #ifdef __cplusplus
1388 }
1389 #endif
1390 #endif /* __XML_PARSER_H__ */