Annotation of XML/parser.h, revision 1.31
1.1 veillard 1: /*
2: * parser.h : constants and stuff related to the XML parser.
1.6 veillard 3: *
4: * See Copyright for the status of this software.
5: *
1.23 daniel 6: * Daniel.Veillard@w3.org
1.1 veillard 7: */
8:
9: #ifndef __XML_PARSER_H__
10: #define __XML_PARSER_H__
11:
1.2 veillard 12: #include "tree.h"
13:
1.7 daniel 14: #ifdef __cplusplus
15: extern "C" {
16: #endif
17:
1.1 veillard 18: /*
19: * Constants.
20: */
21: #define XML_DEFAULT_VERSION "1.0"
22:
1.25 daniel 23: typedef void (* xmlParserInputDeallocate)(CHAR *);
1.14 daniel 24: typedef struct xmlParserInput {
25: const char *filename; /* The file analyzed, if any */
26: const CHAR *base; /* Base of the array to parse */
27: const CHAR *cur; /* Current char being parsed */
28: int line; /* Current line */
29: int col; /* Current column */
1.25 daniel 30: xmlParserInputDeallocate free; /* function to deallocate the base */
1.24 daniel 31: } xmlParserInput;
32: typedef xmlParserInput *xmlParserInputPtr;
1.7 daniel 33:
1.24 daniel 34: typedef struct _xmlParserNodeInfo {
1.13 daniel 35: const struct xmlNode* node;
36: /* Position & line # that text that created the node begins & ends on */
37: unsigned long begin_pos;
38: unsigned long begin_line;
39: unsigned long end_pos;
40: unsigned long end_line;
1.24 daniel 41: } _xmlParserNodeInfo;
42: typedef _xmlParserNodeInfo xmlParserNodeInfo;
1.13 daniel 43:
44: typedef struct xmlParserNodeInfoSeq {
45: unsigned long maximum;
46: unsigned long length;
47: xmlParserNodeInfo* buffer;
1.24 daniel 48: } _xmlParserNodeInfoSeq;
49: typedef _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
50: typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
1.13 daniel 51:
1.24 daniel 52: typedef struct _xmlParserCtxt {
1.17 daniel 53: struct xmlSAXHandler *sax; /* The SAX handler */
1.27 daniel 54: void *userData; /* the document being built */
55: xmlDocPtr myDoc; /* the document being built */
1.22 daniel 56: int wellFormed; /* is the document well formed */
1.30 daniel 57: int replaceEntities; /* shall we replace entities ? */
1.27 daniel 58: const CHAR *version; /* the XML version string */
59: const CHAR *encoding; /* encoding, if any */
60: int standalone; /* standalone document */
1.16 daniel 61:
1.14 daniel 62: /* Input stream stack */
1.15 daniel 63: xmlParserInputPtr input; /* Current input stream */
1.14 daniel 64: int inputNr; /* Number of current input streams */
65: int inputMax; /* Max number of input streams */
66: xmlParserInputPtr *inputTab; /* stack of inputs */
1.15 daniel 67:
68: /* Node analysis stack */
69: xmlNodePtr node; /* Current parsed Node */
70: int nodeNr; /* Depth of the parsing stack */
71: int nodeMax; /* Max depth of the parsing stack */
72: xmlNodePtr *nodeTab; /* array of nodes */
1.14 daniel 73:
1.13 daniel 74: int record_info; /* Whether node info should be kept */
75: xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
1.24 daniel 76: } _xmlParserCtxt;
77: typedef _xmlParserCtxt xmlParserCtxt;
78: typedef xmlParserCtxt *xmlParserCtxtPtr;
1.7 daniel 79:
80: /*
1.17 daniel 81: * a SAX Locator.
82: */
83:
84: typedef struct xmlSAXLocator {
1.28 daniel 85: const CHAR *(*getPublicId)(void *ctx);
86: const CHAR *(*getSystemId)(void *ctx);
87: int (*getLineNumber)(void *ctx);
88: int (*getColumnNumber)(void *ctx);
1.24 daniel 89: } _xmlSAXLocator;
90: typedef _xmlSAXLocator xmlSAXLocator;
91: typedef xmlSAXLocator *xmlSAXLocatorPtr;
1.17 daniel 92:
93: /*
94: * a SAX Exception.
95: */
96:
1.27 daniel 97: #include "entities.h"
98:
1.28 daniel 99: typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,
1.18 daniel 100: const CHAR *publicId, const CHAR *systemId);
1.28 daniel 101: typedef void (*internalSubsetSAXFunc) (void *ctx, const CHAR *name,
1.27 daniel 102: const CHAR *ExternalID, const CHAR *SystemID);
1.28 daniel 103: typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,
1.27 daniel 104: const CHAR *name);
1.28 daniel 105: typedef void (*entityDeclSAXFunc) (void *ctx,
1.27 daniel 106: const CHAR *name, int type, const CHAR *publicId,
107: const CHAR *systemId, CHAR *content);
1.28 daniel 108: typedef void (*notationDeclSAXFunc)(void *ctx, const CHAR *name,
1.18 daniel 109: const CHAR *publicId, const CHAR *systemId);
1.28 daniel 110: typedef void (*attributeDeclSAXFunc)(void *ctx, const CHAR *elem,
1.27 daniel 111: const CHAR *name, int type, int def,
112: const CHAR *defaultValue, xmlEnumerationPtr tree);
1.28 daniel 113: typedef void (*elementDeclSAXFunc)(void *ctx, const CHAR *name,
1.27 daniel 114: int type, xmlElementContentPtr content);
1.28 daniel 115: typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
1.18 daniel 116: const CHAR *name, const CHAR *publicId,
117: const CHAR *systemId, const CHAR *notationName);
1.28 daniel 118: typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
1.18 daniel 119: xmlSAXLocatorPtr loc);
1.28 daniel 120: typedef void (*startDocumentSAXFunc) (void *ctx);
121: typedef void (*endDocumentSAXFunc) (void *ctx);
122: typedef void (*startElementSAXFunc) (void *ctx, const CHAR *name,
1.27 daniel 123: const CHAR **atts);
1.28 daniel 124: typedef void (*endElementSAXFunc) (void *ctx, const CHAR *name);
125: typedef void (*attributeSAXFunc) (void *ctx, const CHAR *name,
1.19 daniel 126: const CHAR *value);
1.28 daniel 127: typedef void (*referenceSAXFunc) (void *ctx, const CHAR *name);
128: typedef void (*charactersSAXFunc) (void *ctx, const CHAR *ch,
1.27 daniel 129: int len);
1.28 daniel 130: typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
1.27 daniel 131: const CHAR *ch, int len);
1.28 daniel 132: typedef void (*processingInstructionSAXFunc) (void *ctx,
1.18 daniel 133: const CHAR *target, const CHAR *data);
1.28 daniel 134: typedef void (*commentSAXFunc) (void *ctx, const CHAR *value);
135: typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...);
136: typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...);
137: typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...);
138: typedef int (*isStandaloneSAXFunc) (void *ctx);
139: typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
140: typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
1.18 daniel 141:
1.17 daniel 142: typedef struct xmlSAXHandler {
1.27 daniel 143: internalSubsetSAXFunc internalSubset;
144: isStandaloneSAXFunc isStandalone;
145: hasInternalSubsetSAXFunc hasInternalSubset;
146: hasExternalSubsetSAXFunc hasExternalSubset;
1.18 daniel 147: resolveEntitySAXFunc resolveEntity;
1.27 daniel 148: getEntitySAXFunc getEntity;
149: entityDeclSAXFunc entityDecl;
1.18 daniel 150: notationDeclSAXFunc notationDecl;
1.27 daniel 151: attributeDeclSAXFunc attributeDecl;
152: elementDeclSAXFunc elementDecl;
1.18 daniel 153: unparsedEntityDeclSAXFunc unparsedEntityDecl;
154: setDocumentLocatorSAXFunc setDocumentLocator;
155: startDocumentSAXFunc startDocument;
156: endDocumentSAXFunc endDocument;
157: startElementSAXFunc startElement;
158: endElementSAXFunc endElement;
1.27 daniel 159: referenceSAXFunc reference;
1.18 daniel 160: charactersSAXFunc characters;
161: ignorableWhitespaceSAXFunc ignorableWhitespace;
162: processingInstructionSAXFunc processingInstruction;
1.27 daniel 163: commentSAXFunc comment;
1.18 daniel 164: warningSAXFunc warning;
165: errorSAXFunc error;
166: fatalErrorSAXFunc fatalError;
1.24 daniel 167: } xmlSAXHandler;
168: typedef xmlSAXHandler *xmlSAXHandlerPtr;
1.17 daniel 169:
170: /*
171: * Global variables: just the SAX interface tables we are looking for full
172: * reentrancy of the code !
173: */
1.19 daniel 174: extern xmlSAXLocator xmlDefaultSAXLocator;
175: extern xmlSAXHandler xmlDefaultSAXHandler;
176:
177: #include "entities.h"
1.26 daniel 178: #include "xml-error.h"
1.17 daniel 179:
180: /*
1.22 daniel 181: * CHAR handling
1.2 veillard 182: */
1.24 daniel 183: CHAR *xmlStrdup(const CHAR *cur);
184: CHAR *xmlStrndup(const CHAR *cur, int len);
185: CHAR *xmlStrchr(const CHAR *str, CHAR val);
186: int xmlStrcmp(const CHAR *str1, const CHAR *str2);
187: int xmlStrncmp(const CHAR *str1, const CHAR *str2, int len);
188: int xmlStrlen(const CHAR *str);
189: CHAR *xmlStrcat(CHAR *cur, const CHAR *add);
190: CHAR *xmlStrncat(CHAR *cur, const CHAR *add, int len);
1.9 daniel 191:
1.22 daniel 192: /*
193: * Interfaces
194: */
1.24 daniel 195: xmlDocPtr xmlParseDoc(CHAR *cur);
196: xmlDocPtr xmlParseMemory(char *buffer, int size);
197: xmlDocPtr xmlParseFile(const char *filename);
1.31 ! daniel 198: int xmlSubstituteEntitiesDefault(int val);
1.22 daniel 199:
200: /*
201: * Recovery mode
202: */
1.24 daniel 203: xmlDocPtr xmlRecoverDoc(CHAR *cur);
204: xmlDocPtr xmlRecoverMemory(char *buffer, int size);
205: xmlDocPtr xmlRecoverFile(const char *filename);
1.22 daniel 206:
207: /*
208: * Internal routines
209: */
1.24 daniel 210: int xmlParseDocument(xmlParserCtxtPtr ctxt);
211: xmlDocPtr xmlSAXParseDoc(xmlSAXHandlerPtr sax, CHAR *cur, int recovery);
212: xmlDocPtr xmlSAXParseMemory(xmlSAXHandlerPtr sax, char *buffer,
1.22 daniel 213: int size, int recovery);
1.24 daniel 214: xmlDocPtr xmlSAXParseFile(xmlSAXHandlerPtr sax, const char *filename,
1.22 daniel 215: int recovery);
1.29 daniel 216: xmlDtdPtr xmlParseDTD(const CHAR *ExternalID, const CHAR *SystemID);
217: xmlDtdPtr xmlSAXParseDTD(xmlSAXHandlerPtr sax, const CHAR *ExternalID,
218: const CHAR *SystemID);
1.24 daniel 219: void xmlInitParserCtxt(xmlParserCtxtPtr ctxt);
220: void xmlClearParserCtxt(xmlParserCtxtPtr ctxt);
221: void xmlSetupParserForBuffer(xmlParserCtxtPtr ctxt, const CHAR* buffer,
1.9 daniel 222: const char* filename);
223:
1.24 daniel 224: const xmlParserNodeInfo* xmlParserFindNodeInfo(const xmlParserCtxt* ctxt,
225: const xmlNode* node);
226: void xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq);
227: void xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq);
1.13 daniel 228: unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
229: const xmlNode* node);
1.24 daniel 230: void xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
231: const xmlParserNodeInfo* info);
1.7 daniel 232:
1.24 daniel 233: void xmlDefaultSAXHandlerInit(void);
1.7 daniel 234: #ifdef __cplusplus
235: }
236: #endif
1.1 veillard 237:
238: #endif /* __XML_PARSER_H__ */
239:
Webmaster