LTKCPP-- LLRP Toolkit C Plus Plus Library
parser.h
1 /*
2  * Summary: the core parser module
3  * Description: Interfaces, constants and types related to the XML parser
4  *
5  * Copy: See Copyright for the status of this software.
6  *
7  * Author: Daniel Veillard
8  */
9 
10 #ifndef __XML_PARSER_H__
11 #define __XML_PARSER_H__
12 
13 #include <stdarg.h>
14 
15 #include <libxml/xmlversion.h>
16 #include <libxml/tree.h>
17 #include <libxml/dict.h>
18 #include <libxml/hash.h>
19 #include <libxml/valid.h>
20 #include <libxml/entities.h>
21 #include <libxml/xmlerror.h>
22 #include <libxml/xmlstring.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
33 #define XML_DEFAULT_VERSION "1.0"
34 
52 typedef void (* xmlParserInputDeallocate)(xmlChar *str);
53 
54 struct _xmlParserInput {
55  /* Input buffer */
56  xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */
57 
58  const char *filename; /* The file analyzed, if any */
59  const char *directory; /* the directory/base of the file */
60  const xmlChar *base; /* Base of the array to parse */
61  const xmlChar *cur; /* Current char being parsed */
62  const xmlChar *end; /* end of the array to parse */
63  int length; /* length if known */
64  int line; /* Current line */
65  int col; /* Current column */
66  /*
67  * NOTE: consumed is only tested for equality in the parser code,
68  * so even if there is an overflow this should not give troubles
69  * for parsing very large instances.
70  */
71  unsigned long consumed; /* How many xmlChars already consumed */
72  xmlParserInputDeallocate free; /* function to deallocate the base */
73  const xmlChar *encoding; /* the encoding string for entity */
74  const xmlChar *version; /* the version string for entity */
75  int standalone; /* Was that entity marked standalone */
76  int id; /* an unique identifier for the entity */
77 };
78 
86 typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
87 typedef xmlParserNodeInfo *xmlParserNodeInfoPtr;
88 
89 struct _xmlParserNodeInfo {
90  const struct _xmlNode* node;
91  /* Position & line # that text that created the node begins & ends on */
92  unsigned long begin_pos;
93  unsigned long begin_line;
94  unsigned long end_pos;
95  unsigned long end_line;
96 };
97 
98 typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
99 typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
100 struct _xmlParserNodeInfoSeq {
101  unsigned long maximum;
102  unsigned long length;
103  xmlParserNodeInfo* buffer;
104 };
105 
112 typedef enum {
113  XML_PARSER_EOF = -1, /* nothing is to be parsed */
114  XML_PARSER_START = 0, /* nothing has been parsed */
115  XML_PARSER_MISC, /* Misc* before int subset */
116  XML_PARSER_PI, /* Within a processing instruction */
117  XML_PARSER_DTD, /* within some DTD content */
118  XML_PARSER_PROLOG, /* Misc* after internal subset */
119  XML_PARSER_COMMENT, /* within a comment */
120  XML_PARSER_START_TAG, /* within a start tag */
121  XML_PARSER_CONTENT, /* within the content */
122  XML_PARSER_CDATA_SECTION, /* within a CDATA section */
123  XML_PARSER_END_TAG, /* within a closing tag */
124  XML_PARSER_ENTITY_DECL, /* within an entity declaration */
125  XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
126  XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
127  XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
128  XML_PARSER_EPILOG, /* the Misc* after the last end tag */
129  XML_PARSER_IGNORE, /* within an IGNORED section */
130  XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
131 } xmlParserInputState;
132 
139 #define XML_DETECT_IDS 2
140 
148 #define XML_COMPLETE_ATTRS 4
149 
156 #define XML_SKIP_IDS 8
157 
163 typedef enum {
164  XML_PARSE_UNKNOWN = 0,
165  XML_PARSE_DOM = 1,
166  XML_PARSE_SAX = 2,
167  XML_PARSE_PUSH_DOM = 3,
168  XML_PARSE_PUSH_SAX = 4,
169  XML_PARSE_READER = 5
170 } xmlParserMode;
171 
185  struct _xmlSAXHandler *sax; /* The SAX handler */
186  void *userData; /* For SAX interface only, used by DOM build */
187  xmlDocPtr myDoc; /* the document being built */
188  int wellFormed; /* is the document well formed */
189  int replaceEntities; /* shall we replace entities ? */
190  const xmlChar *version; /* the XML version string */
191  const xmlChar *encoding; /* the declared encoding, if any */
192  int standalone; /* standalone document */
193  int html; /* an HTML(1)/Docbook(2) document
194  * 3 is HTML after <head>
195  * 10 is HTML after <body>
196  */
197 
198  /* Input stream stack */
199  xmlParserInputPtr input; /* Current input stream */
200  int inputNr; /* Number of current input streams */
201  int inputMax; /* Max number of input streams */
202  xmlParserInputPtr *inputTab; /* stack of inputs */
203 
204  /* Node analysis stack only used for DOM building */
205  xmlNodePtr node; /* Current parsed Node */
206  int nodeNr; /* Depth of the parsing stack */
207  int nodeMax; /* Max depth of the parsing stack */
208  xmlNodePtr *nodeTab; /* array of nodes */
209 
210  int record_info; /* Whether node info should be kept */
211  xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
212 
213  int errNo; /* error code */
214 
215  int hasExternalSubset; /* reference and external subset */
216  int hasPErefs; /* the internal subset has PE refs */
217  int external; /* are we parsing an external entity */
218 
219  int valid; /* is the document valid */
220  int validate; /* shall we try to validate ? */
221  xmlValidCtxt vctxt; /* The validity context */
222 
223  xmlParserInputState instate; /* current type of input */
224  int token; /* next char look-ahead */
225 
226  char *directory; /* the data directory */
227 
228  /* Node name stack */
229  const xmlChar *name; /* Current parsed Node */
230  int nameNr; /* Depth of the parsing stack */
231  int nameMax; /* Max depth of the parsing stack */
232  const xmlChar * *nameTab; /* array of nodes */
233 
234  long nbChars; /* number of xmlChar processed */
235  long checkIndex; /* used by progressive parsing lookup */
236  int keepBlanks; /* ugly but ... */
237  int disableSAX; /* SAX callbacks are disabled */
238  int inSubset; /* Parsing is in int 1/ext 2 subset */
239  const xmlChar * intSubName; /* name of subset */
240  xmlChar * extSubURI; /* URI of external subset */
241  xmlChar * extSubSystem; /* SYSTEM ID of external subset */
242 
243  /* xml:space values */
244  int * space; /* Should the parser preserve spaces */
245  int spaceNr; /* Depth of the parsing stack */
246  int spaceMax; /* Max depth of the parsing stack */
247  int * spaceTab; /* array of space infos */
248 
249  int depth; /* to prevent entity substitution loops */
250  xmlParserInputPtr entity; /* used to check entities boundaries */
251  int charset; /* encoding of the in-memory content
252  actually an xmlCharEncoding */
253  int nodelen; /* Those two fields are there to */
254  int nodemem; /* Speed up large node parsing */
255  int pedantic; /* signal pedantic warnings */
256  void *_private; /* For user data, libxml won't touch it */
257 
258  int loadsubset; /* should the external subset be loaded */
259  int linenumbers; /* set line number in element content */
260  void *catalogs; /* document's own catalog */
261  int recovery; /* run in recovery mode */
262  int progressive; /* is this a progressive parsing */
263  xmlDictPtr dict; /* dictionnary for the parser */
264  const xmlChar * *atts; /* array for the attributes callbacks */
265  int maxatts; /* the size of the array */
266  int docdict; /* use strings from dict to build tree */
267 
268  /*
269  * pre-interned strings
270  */
271  const xmlChar *str_xml;
272  const xmlChar *str_xmlns;
273  const xmlChar *str_xml_ns;
274 
275  /*
276  * Everything below is used only by the new SAX mode
277  */
278  int sax2; /* operating in the new SAX mode */
279  int nsNr; /* the number of inherited namespaces */
280  int nsMax; /* the size of the arrays */
281  const xmlChar * *nsTab; /* the array of prefix/namespace name */
282  int *attallocs; /* which attribute were allocated */
283  void * *pushTab; /* array of data for push */
284  xmlHashTablePtr attsDefault; /* defaulted attributes if any */
285  xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
286  int nsWellFormed; /* is the document XML Nanespace okay */
287  int options; /* Extra options */
288 
289  /*
290  * Those fields are needed only for treaming parsing so far
291  */
292  int dictNames; /* Use dictionary names for the tree */
293  int freeElemsNr; /* number of freed element nodes */
294  xmlNodePtr freeElems; /* List of freed element nodes */
295  int freeAttrsNr; /* number of freed attributes nodes */
296  xmlAttrPtr freeAttrs; /* List of freed attributes nodes */
297 
298  /*
299  * the complete error informations for the last error.
300  */
301  xmlError lastError;
302  xmlParserMode parseMode; /* the parser mode */
303  unsigned long nbentities; /* number of entities references */
304  unsigned long sizeentities; /* size of parsed entities */
305 };
306 
313  const xmlChar *(*getPublicId)(void *ctx);
314  const xmlChar *(*getSystemId)(void *ctx);
315  int (*getLineNumber)(void *ctx);
316  int (*getColumnNumber)(void *ctx);
317 };
318 
341 typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
342  const xmlChar *publicId,
343  const xmlChar *systemId);
353 typedef void (*internalSubsetSAXFunc) (void *ctx,
354  const xmlChar *name,
355  const xmlChar *ExternalID,
356  const xmlChar *SystemID);
366 typedef void (*externalSubsetSAXFunc) (void *ctx,
367  const xmlChar *name,
368  const xmlChar *ExternalID,
369  const xmlChar *SystemID);
379 typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
380  const xmlChar *name);
390 typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
391  const xmlChar *name);
403 typedef void (*entityDeclSAXFunc) (void *ctx,
404  const xmlChar *name,
405  int type,
406  const xmlChar *publicId,
407  const xmlChar *systemId,
408  xmlChar *content);
418 typedef void (*notationDeclSAXFunc)(void *ctx,
419  const xmlChar *name,
420  const xmlChar *publicId,
421  const xmlChar *systemId);
434 typedef void (*attributeDeclSAXFunc)(void *ctx,
435  const xmlChar *elem,
436  const xmlChar *fullname,
437  int type,
438  int def,
439  const xmlChar *defaultValue,
440  xmlEnumerationPtr tree);
450 typedef void (*elementDeclSAXFunc)(void *ctx,
451  const xmlChar *name,
452  int type,
453  xmlElementContentPtr content);
464 typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
465  const xmlChar *name,
466  const xmlChar *publicId,
467  const xmlChar *systemId,
468  const xmlChar *notationName);
477 typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
478  xmlSAXLocatorPtr loc);
485 typedef void (*startDocumentSAXFunc) (void *ctx);
492 typedef void (*endDocumentSAXFunc) (void *ctx);
501 typedef void (*startElementSAXFunc) (void *ctx,
502  const xmlChar *name,
503  const xmlChar **atts);
511 typedef void (*endElementSAXFunc) (void *ctx,
512  const xmlChar *name);
524 typedef void (*attributeSAXFunc) (void *ctx,
525  const xmlChar *name,
526  const xmlChar *value);
534 typedef void (*referenceSAXFunc) (void *ctx,
535  const xmlChar *name);
544 typedef void (*charactersSAXFunc) (void *ctx,
545  const xmlChar *ch,
546  int len);
556 typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
557  const xmlChar *ch,
558  int len);
567 typedef void (*processingInstructionSAXFunc) (void *ctx,
568  const xmlChar *target,
569  const xmlChar *data);
577 typedef void (*commentSAXFunc) (void *ctx,
578  const xmlChar *value);
587 typedef void (*cdataBlockSAXFunc) (
588  void *ctx,
589  const xmlChar *value,
590  int len);
599 typedef void (XMLCDECL *warningSAXFunc) (void *ctx,
600  const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
609 typedef void (XMLCDECL *errorSAXFunc) (void *ctx,
610  const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
621 typedef void (XMLCDECL *fatalErrorSAXFunc) (void *ctx,
622  const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
631 typedef int (*isStandaloneSAXFunc) (void *ctx);
640 typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
641 
650 typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
651 
652 /************************************************************************
653  * *
654  * The SAX version 2 API extensions *
655  * *
656  ************************************************************************/
662 #define XML_SAX2_MAGIC 0xDEEDBEAF
663 
683 typedef void (*startElementNsSAX2Func) (void *ctx,
684  const xmlChar *localname,
685  const xmlChar *prefix,
686  const xmlChar *URI,
687  int nb_namespaces,
688  const xmlChar **namespaces,
689  int nb_attributes,
690  int nb_defaulted,
691  const xmlChar **attributes);
692 
704 typedef void (*endElementNsSAX2Func) (void *ctx,
705  const xmlChar *localname,
706  const xmlChar *prefix,
707  const xmlChar *URI);
708 
709 
710 struct _xmlSAXHandler {
711  internalSubsetSAXFunc internalSubset;
712  isStandaloneSAXFunc isStandalone;
713  hasInternalSubsetSAXFunc hasInternalSubset;
714  hasExternalSubsetSAXFunc hasExternalSubset;
715  resolveEntitySAXFunc resolveEntity;
716  getEntitySAXFunc getEntity;
717  entityDeclSAXFunc entityDecl;
718  notationDeclSAXFunc notationDecl;
719  attributeDeclSAXFunc attributeDecl;
720  elementDeclSAXFunc elementDecl;
721  unparsedEntityDeclSAXFunc unparsedEntityDecl;
722  setDocumentLocatorSAXFunc setDocumentLocator;
723  startDocumentSAXFunc startDocument;
724  endDocumentSAXFunc endDocument;
725  startElementSAXFunc startElement;
726  endElementSAXFunc endElement;
727  referenceSAXFunc reference;
728  charactersSAXFunc characters;
729  ignorableWhitespaceSAXFunc ignorableWhitespace;
730  processingInstructionSAXFunc processingInstruction;
731  commentSAXFunc comment;
732  warningSAXFunc warning;
733  errorSAXFunc error;
734  fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
735  getParameterEntitySAXFunc getParameterEntity;
736  cdataBlockSAXFunc cdataBlock;
737  externalSubsetSAXFunc externalSubset;
738  unsigned int initialized;
739  /* The following fields are extensions available only on version 2 */
740  void *_private;
741  startElementNsSAX2Func startElementNs;
742  endElementNsSAX2Func endElementNs;
743  xmlStructuredErrorFunc serror;
744 };
745 
746 /*
747  * SAX Version 1
748  */
749 typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
750 typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
751 struct _xmlSAXHandlerV1 {
752  internalSubsetSAXFunc internalSubset;
753  isStandaloneSAXFunc isStandalone;
754  hasInternalSubsetSAXFunc hasInternalSubset;
755  hasExternalSubsetSAXFunc hasExternalSubset;
756  resolveEntitySAXFunc resolveEntity;
757  getEntitySAXFunc getEntity;
758  entityDeclSAXFunc entityDecl;
759  notationDeclSAXFunc notationDecl;
760  attributeDeclSAXFunc attributeDecl;
761  elementDeclSAXFunc elementDecl;
762  unparsedEntityDeclSAXFunc unparsedEntityDecl;
763  setDocumentLocatorSAXFunc setDocumentLocator;
764  startDocumentSAXFunc startDocument;
765  endDocumentSAXFunc endDocument;
766  startElementSAXFunc startElement;
767  endElementSAXFunc endElement;
768  referenceSAXFunc reference;
769  charactersSAXFunc characters;
770  ignorableWhitespaceSAXFunc ignorableWhitespace;
771  processingInstructionSAXFunc processingInstruction;
772  commentSAXFunc comment;
773  warningSAXFunc warning;
774  errorSAXFunc error;
775  fatalErrorSAXFunc fatalError; /* unused error() get all the errors */
776  getParameterEntitySAXFunc getParameterEntity;
777  cdataBlockSAXFunc cdataBlock;
778  externalSubsetSAXFunc externalSubset;
779  unsigned int initialized;
780 };
781 
782 
793 typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,
794  const char *ID,
795  xmlParserCtxtPtr context);
796 
797 #ifdef __cplusplus
798 }
799 #endif
800 
801 #include <libxml/encoding.h>
802 #include <libxml/xmlIO.h>
803 #include <libxml/globals.h>
804 
805 #ifdef __cplusplus
806 extern "C" {
807 #endif
808 
809 
810 /*
811  * Init/Cleanup
812  */
813 XMLPUBFUN void XMLCALL
814  xmlInitParser (void);
815 XMLPUBFUN void XMLCALL
816  xmlCleanupParser (void);
817 
818 /*
819  * Input functions
820  */
821 XMLPUBFUN int XMLCALL
822  xmlParserInputRead (xmlParserInputPtr in,
823  int len);
824 XMLPUBFUN int XMLCALL
825  xmlParserInputGrow (xmlParserInputPtr in,
826  int len);
827 
828 /*
829  * Basic parsing Interfaces
830  */
831 #ifdef LIBXML_SAX1_ENABLED
832 XMLPUBFUN xmlDocPtr XMLCALL
833  xmlParseDoc (const xmlChar *cur);
834 XMLPUBFUN xmlDocPtr XMLCALL
835  xmlParseFile (const char *filename);
836 XMLPUBFUN xmlDocPtr XMLCALL
837  xmlParseMemory (const char *buffer,
838  int size);
839 #endif /* LIBXML_SAX1_ENABLED */
840 XMLPUBFUN int XMLCALL
841  xmlSubstituteEntitiesDefault(int val);
842 XMLPUBFUN int XMLCALL
843  xmlKeepBlanksDefault (int val);
844 XMLPUBFUN void XMLCALL
845  xmlStopParser (xmlParserCtxtPtr ctxt);
846 XMLPUBFUN int XMLCALL
847  xmlPedanticParserDefault(int val);
848 XMLPUBFUN int XMLCALL
849  xmlLineNumbersDefault (int val);
850 
851 #ifdef LIBXML_SAX1_ENABLED
852 /*
853  * Recovery mode
854  */
855 XMLPUBFUN xmlDocPtr XMLCALL
856  xmlRecoverDoc (const xmlChar *cur);
857 XMLPUBFUN xmlDocPtr XMLCALL
858  xmlRecoverMemory (const char *buffer,
859  int size);
860 XMLPUBFUN xmlDocPtr XMLCALL
861  xmlRecoverFile (const char *filename);
862 #endif /* LIBXML_SAX1_ENABLED */
863 
864 /*
865  * Less common routines and SAX interfaces
866  */
867 XMLPUBFUN int XMLCALL
868  xmlParseDocument (xmlParserCtxtPtr ctxt);
869 XMLPUBFUN int XMLCALL
870  xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
871 #ifdef LIBXML_SAX1_ENABLED
872 XMLPUBFUN int XMLCALL
873  xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
874  void *user_data,
875  const char *filename);
876 XMLPUBFUN int XMLCALL
877  xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
878  void *user_data,
879  const char *buffer,
880  int size);
881 XMLPUBFUN xmlDocPtr XMLCALL
882  xmlSAXParseDoc (xmlSAXHandlerPtr sax,
883  const xmlChar *cur,
884  int recovery);
885 XMLPUBFUN xmlDocPtr XMLCALL
886  xmlSAXParseMemory (xmlSAXHandlerPtr sax,
887  const char *buffer,
888  int size,
889  int recovery);
890 XMLPUBFUN xmlDocPtr XMLCALL
891  xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
892  const char *buffer,
893  int size,
894  int recovery,
895  void *data);
896 XMLPUBFUN xmlDocPtr XMLCALL
897  xmlSAXParseFile (xmlSAXHandlerPtr sax,
898  const char *filename,
899  int recovery);
900 XMLPUBFUN xmlDocPtr XMLCALL
901  xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
902  const char *filename,
903  int recovery,
904  void *data);
905 XMLPUBFUN xmlDocPtr XMLCALL
906  xmlSAXParseEntity (xmlSAXHandlerPtr sax,
907  const char *filename);
908 XMLPUBFUN xmlDocPtr XMLCALL
909  xmlParseEntity (const char *filename);
910 #endif /* LIBXML_SAX1_ENABLED */
911 
912 #ifdef LIBXML_VALID_ENABLED
913 XMLPUBFUN xmlDtdPtr XMLCALL
914  xmlSAXParseDTD (xmlSAXHandlerPtr sax,
915  const xmlChar *ExternalID,
916  const xmlChar *SystemID);
917 XMLPUBFUN xmlDtdPtr XMLCALL
918  xmlParseDTD (const xmlChar *ExternalID,
919  const xmlChar *SystemID);
920 XMLPUBFUN xmlDtdPtr XMLCALL
921  xmlIOParseDTD (xmlSAXHandlerPtr sax,
922  xmlParserInputBufferPtr input,
923  xmlCharEncoding enc);
924 #endif /* LIBXML_VALID_ENABLE */
925 #ifdef LIBXML_SAX1_ENABLED
926 XMLPUBFUN int XMLCALL
927  xmlParseBalancedChunkMemory(xmlDocPtr doc,
928  xmlSAXHandlerPtr sax,
929  void *user_data,
930  int depth,
931  const xmlChar *string,
932  xmlNodePtr *lst);
933 #endif /* LIBXML_SAX1_ENABLED */
934 XMLPUBFUN xmlParserErrors XMLCALL
935  xmlParseInNodeContext (xmlNodePtr node,
936  const char *data,
937  int datalen,
938  int options,
939  xmlNodePtr *lst);
940 #ifdef LIBXML_SAX1_ENABLED
941 XMLPUBFUN int XMLCALL
942  xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
943  xmlSAXHandlerPtr sax,
944  void *user_data,
945  int depth,
946  const xmlChar *string,
947  xmlNodePtr *lst,
948  int recover);
949 XMLPUBFUN int XMLCALL
950  xmlParseExternalEntity (xmlDocPtr doc,
951  xmlSAXHandlerPtr sax,
952  void *user_data,
953  int depth,
954  const xmlChar *URL,
955  const xmlChar *ID,
956  xmlNodePtr *lst);
957 #endif /* LIBXML_SAX1_ENABLED */
958 XMLPUBFUN int XMLCALL
959  xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
960  const xmlChar *URL,
961  const xmlChar *ID,
962  xmlNodePtr *lst);
963 
964 /*
965  * Parser contexts handling.
966  */
967 XMLPUBFUN xmlParserCtxtPtr XMLCALL
968  xmlNewParserCtxt (void);
969 XMLPUBFUN int XMLCALL
970  xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
971 XMLPUBFUN void XMLCALL
972  xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
973 XMLPUBFUN void XMLCALL
974  xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
975 #ifdef LIBXML_SAX1_ENABLED
976 XMLPUBFUN void XMLCALL
977  xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
978  const xmlChar* buffer,
979  const char *filename);
980 #endif /* LIBXML_SAX1_ENABLED */
981 XMLPUBFUN xmlParserCtxtPtr XMLCALL
982  xmlCreateDocParserCtxt (const xmlChar *cur);
983 
984 #ifdef LIBXML_LEGACY_ENABLED
985 /*
986  * Reading/setting optional parsing features.
987  */
988 XMLPUBFUN int XMLCALL
989  xmlGetFeaturesList (int *len,
990  const char **result);
991 XMLPUBFUN int XMLCALL
992  xmlGetFeature (xmlParserCtxtPtr ctxt,
993  const char *name,
994  void *result);
995 XMLPUBFUN int XMLCALL
996  xmlSetFeature (xmlParserCtxtPtr ctxt,
997  const char *name,
998  void *value);
999 #endif /* LIBXML_LEGACY_ENABLED */
1000 
1001 #ifdef LIBXML_PUSH_ENABLED
1002 /*
1003  * Interfaces for the Push mode.
1004  */
1005 XMLPUBFUN xmlParserCtxtPtr XMLCALL
1006  xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
1007  void *user_data,
1008  const char *chunk,
1009  int size,
1010  const char *filename);
1011 XMLPUBFUN int XMLCALL
1012  xmlParseChunk (xmlParserCtxtPtr ctxt,
1013  const char *chunk,
1014  int size,
1015  int terminate);
1016 #endif /* LIBXML_PUSH_ENABLED */
1017 
1018 /*
1019  * Special I/O mode.
1020  */
1021 
1022 XMLPUBFUN xmlParserCtxtPtr XMLCALL
1023  xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
1024  void *user_data,
1025  xmlInputReadCallback ioread,
1026  xmlInputCloseCallback ioclose,
1027  void *ioctx,
1028  xmlCharEncoding enc);
1029 
1030 XMLPUBFUN xmlParserInputPtr XMLCALL
1031  xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
1032  xmlParserInputBufferPtr input,
1033  xmlCharEncoding enc);
1034 
1035 /*
1036  * Node infos.
1037  */
1038 XMLPUBFUN const xmlParserNodeInfo* XMLCALL
1039  xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
1040  const xmlNodePtr node);
1041 XMLPUBFUN void XMLCALL
1042  xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1043 XMLPUBFUN void XMLCALL
1044  xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
1045 XMLPUBFUN unsigned long XMLCALL
1046  xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
1047  const xmlNodePtr node);
1048 XMLPUBFUN void XMLCALL
1049  xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
1050  const xmlParserNodeInfoPtr info);
1051 
1052 /*
1053  * External entities handling actually implemented in xmlIO.
1054  */
1055 
1056 XMLPUBFUN void XMLCALL
1057  xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
1058 XMLPUBFUN xmlExternalEntityLoader XMLCALL
1059  xmlGetExternalEntityLoader(void);
1060 XMLPUBFUN xmlParserInputPtr XMLCALL
1061  xmlLoadExternalEntity (const char *URL,
1062  const char *ID,
1063  xmlParserCtxtPtr ctxt);
1064 
1065 /*
1066  * Index lookup, actually implemented in the encoding module
1067  */
1068 XMLPUBFUN long XMLCALL
1069  xmlByteConsumed (xmlParserCtxtPtr ctxt);
1070 
1071 /*
1072  * New set of simpler/more flexible APIs
1073  */
1080 typedef enum {
1081  XML_PARSE_RECOVER = 1<<0, /* recover on errors */
1082  XML_PARSE_NOENT = 1<<1, /* substitute entities */
1083  XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */
1084  XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */
1085  XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */
1086  XML_PARSE_NOERROR = 1<<5, /* suppress error reports */
1087  XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
1088  XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
1089  XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
1090  XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
1091  XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
1092  XML_PARSE_NONET = 1<<11,/* Forbid network access */
1093  XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */
1094  XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
1095  XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */
1096  XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */
1097  XML_PARSE_COMPACT = 1<<16,/* compact small text nodes; no modification of
1098  the tree allowed afterwards (will possibly
1099  crash if you try to modify the tree) */
1100  XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */
1101  XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */
1102  XML_PARSE_HUGE = 1<<19, /* relax any hardcoded limit from the parser */
1103  XML_PARSE_OLDSAX = 1<<20 /* parse using SAX2 interface from before 2.7.0 */
1104 } xmlParserOption;
1105 
1106 XMLPUBFUN void XMLCALL
1107  xmlCtxtReset (xmlParserCtxtPtr ctxt);
1108 XMLPUBFUN int XMLCALL
1109  xmlCtxtResetPush (xmlParserCtxtPtr ctxt,
1110  const char *chunk,
1111  int size,
1112  const char *filename,
1113  const char *encoding);
1114 XMLPUBFUN int XMLCALL
1115  xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
1116  int options);
1117 XMLPUBFUN xmlDocPtr XMLCALL
1118  xmlReadDoc (const xmlChar *cur,
1119  const char *URL,
1120  const char *encoding,
1121  int options);
1122 XMLPUBFUN xmlDocPtr XMLCALL
1123  xmlReadFile (const char *URL,
1124  const char *encoding,
1125  int options);
1126 XMLPUBFUN xmlDocPtr XMLCALL
1127  xmlReadMemory (const char *buffer,
1128  int size,
1129  const char *URL,
1130  const char *encoding,
1131  int options);
1132 XMLPUBFUN xmlDocPtr XMLCALL
1133  xmlReadFd (int fd,
1134  const char *URL,
1135  const char *encoding,
1136  int options);
1137 XMLPUBFUN xmlDocPtr XMLCALL
1138  xmlReadIO (xmlInputReadCallback ioread,
1139  xmlInputCloseCallback ioclose,
1140  void *ioctx,
1141  const char *URL,
1142  const char *encoding,
1143  int options);
1144 XMLPUBFUN xmlDocPtr XMLCALL
1145  xmlCtxtReadDoc (xmlParserCtxtPtr ctxt,
1146  const xmlChar *cur,
1147  const char *URL,
1148  const char *encoding,
1149  int options);
1150 XMLPUBFUN xmlDocPtr XMLCALL
1151  xmlCtxtReadFile (xmlParserCtxtPtr ctxt,
1152  const char *filename,
1153  const char *encoding,
1154  int options);
1155 XMLPUBFUN xmlDocPtr XMLCALL
1156  xmlCtxtReadMemory (xmlParserCtxtPtr ctxt,
1157  const char *buffer,
1158  int size,
1159  const char *URL,
1160  const char *encoding,
1161  int options);
1162 XMLPUBFUN xmlDocPtr XMLCALL
1163  xmlCtxtReadFd (xmlParserCtxtPtr ctxt,
1164  int fd,
1165  const char *URL,
1166  const char *encoding,
1167  int options);
1168 XMLPUBFUN xmlDocPtr XMLCALL
1169  xmlCtxtReadIO (xmlParserCtxtPtr ctxt,
1170  xmlInputReadCallback ioread,
1171  xmlInputCloseCallback ioclose,
1172  void *ioctx,
1173  const char *URL,
1174  const char *encoding,
1175  int options);
1176 
1177 /*
1178  * Library wide options
1179  */
1187 typedef enum {
1188  XML_WITH_THREAD = 1,
1189  XML_WITH_TREE = 2,
1190  XML_WITH_OUTPUT = 3,
1191  XML_WITH_PUSH = 4,
1192  XML_WITH_READER = 5,
1193  XML_WITH_PATTERN = 6,
1194  XML_WITH_WRITER = 7,
1195  XML_WITH_SAX1 = 8,
1196  XML_WITH_FTP = 9,
1197  XML_WITH_HTTP = 10,
1198  XML_WITH_VALID = 11,
1199  XML_WITH_HTML = 12,
1200  XML_WITH_LEGACY = 13,
1201  XML_WITH_C14N = 14,
1202  XML_WITH_CATALOG = 15,
1203  XML_WITH_XPATH = 16,
1204  XML_WITH_XPTR = 17,
1205  XML_WITH_XINCLUDE = 18,
1206  XML_WITH_ICONV = 19,
1207  XML_WITH_ISO8859X = 20,
1208  XML_WITH_UNICODE = 21,
1209  XML_WITH_REGEXP = 22,
1210  XML_WITH_AUTOMATA = 23,
1211  XML_WITH_EXPR = 24,
1212  XML_WITH_SCHEMAS = 25,
1213  XML_WITH_SCHEMATRON = 26,
1214  XML_WITH_MODULES = 27,
1215  XML_WITH_DEBUG = 28,
1216  XML_WITH_DEBUG_MEM = 29,
1217  XML_WITH_DEBUG_RUN = 30,
1218  XML_WITH_ZLIB = 31,
1219  XML_WITH_NONE = 99999 /* just to be sure of allocation size */
1220 } xmlFeature;
1221 
1222 XMLPUBFUN int XMLCALL
1223  xmlHasFeature (xmlFeature feature);
1224 
1225 #ifdef __cplusplus
1226 }
1227 #endif
1228 #endif /* __XML_PARSER_H__ */
1229