1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #ifndef PHP_EXPAT_COMPAT_H
22 #define PHP_EXPAT_COMPAT_H
23
24 #ifdef PHP_WIN32
25 #include "config.w32.h"
26 #else
27 #include <php_config.h>
28 #endif
29
30 #ifdef PHP_WIN32
31 # define PHP_XML_API __declspec(dllexport)
32 #elif defined(__GNUC__) && __GNUC__ >= 4
33 # define PHP_XML_API __attribute__ ((visibility("default")))
34 #else
35 # define PHP_XML_API
36 #endif
37
38 #if !defined(HAVE_LIBEXPAT) && defined(HAVE_LIBXML)
39 #define LIBXML_EXPAT_COMPAT 1
40
41 #include "php.h"
42 #include "php_compat.h"
43
44 #include <libxml/parser.h>
45 #include <libxml/parserInternals.h>
46 #include <libxml/tree.h>
47 #include <libxml/hash.h>
48
49
50 #define _ns_seperator _ns_separator
51
52 typedef xmlChar XML_Char;
53
54 typedef void (*XML_StartElementHandler)(void *, const XML_Char *, const XML_Char **);
55 typedef void (*XML_EndElementHandler)(void *, const XML_Char *);
56 typedef void (*XML_CharacterDataHandler)(void *, const XML_Char *, int);
57 typedef void (*XML_ProcessingInstructionHandler)(void *, const XML_Char *, const XML_Char *);
58 typedef void (*XML_CommentHandler)(void *, const XML_Char *);
59 typedef void (*XML_DefaultHandler)(void *, const XML_Char *, int);
60 typedef void (*XML_UnparsedEntityDeclHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
61 typedef void (*XML_NotationDeclHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
62 typedef int (*XML_ExternalEntityRefHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *);
63 typedef void (*XML_StartNamespaceDeclHandler)(void *, const XML_Char *, const XML_Char *);
64 typedef void (*XML_EndNamespaceDeclHandler)(void *, const XML_Char *);
65
66 typedef struct _XML_Memory_Handling_Suite {
67 void *(*malloc_fcn)(size_t size);
68 void *(*realloc_fcn)(void *ptr, size_t size);
69 void (*free_fcn)(void *ptr);
70 } XML_Memory_Handling_Suite;
71
72 typedef struct _XML_Parser {
73 int use_namespace;
74
75 xmlChar *_ns_separator;
76
77 void *user;
78 xmlParserCtxtPtr parser;
79
80 XML_StartElementHandler h_start_element;
81 XML_EndElementHandler h_end_element;
82 XML_CharacterDataHandler h_cdata;
83 XML_ProcessingInstructionHandler h_pi;
84 XML_CommentHandler h_comment;
85 XML_DefaultHandler h_default;
86 XML_UnparsedEntityDeclHandler h_unparsed_entity_decl;
87 XML_NotationDeclHandler h_notation_decl;
88 XML_ExternalEntityRefHandler h_external_entity_ref;
89 XML_StartNamespaceDeclHandler h_start_ns;
90 XML_EndNamespaceDeclHandler h_end_ns;
91 } *XML_Parser;
92
93 enum XML_Error {
94 XML_ERROR_NONE,
95 XML_ERROR_NO_MEMORY,
96 XML_ERROR_SYNTAX,
97 XML_ERROR_NO_ELEMENTS,
98 XML_ERROR_INVALID_TOKEN,
99 XML_ERROR_UNCLOSED_TOKEN,
100 XML_ERROR_PARTIAL_CHAR,
101 XML_ERROR_TAG_MISMATCH,
102 XML_ERROR_DUPLICATE_ATTRIBUTE,
103 XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
104 XML_ERROR_PARAM_ENTITY_REF,
105 XML_ERROR_UNDEFINED_ENTITY,
106 XML_ERROR_RECURSIVE_ENTITY_REF,
107 XML_ERROR_ASYNC_ENTITY,
108 XML_ERROR_BAD_CHAR_REF,
109 XML_ERROR_BINARY_ENTITY_REF,
110 XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
111 XML_ERROR_MISPLACED_XML_PI,
112 XML_ERROR_UNKNOWN_ENCODING,
113 XML_ERROR_INCORRECT_ENCODING,
114 XML_ERROR_UNCLOSED_CDATA_SECTION,
115 XML_ERROR_EXTERNAL_ENTITY_HANDLING,
116 XML_ERROR_NOT_STANDALONE,
117 XML_ERROR_UNEXPECTED_STATE,
118 XML_ERROR_ENTITY_DECLARED_IN_PE,
119 XML_ERROR_FEATURE_REQUIRES_XML_DTD,
120 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING
121 };
122
123 enum XML_Content_Type {
124 XML_CTYPE_EMPTY = 1,
125 XML_CTYPE_ANY,
126 XML_CTYPE_MIXED,
127 XML_CTYPE_NAME,
128 XML_CTYPE_CHOICE,
129 XML_CTYPE_SEQ
130 };
131
132 PHP_XML_API XML_Parser XML_ParserCreate(const XML_Char *);
133 PHP_XML_API XML_Parser XML_ParserCreateNS(const XML_Char *, const XML_Char);
134 PHP_XML_API XML_Parser XML_ParserCreate_MM(const XML_Char *, const XML_Memory_Handling_Suite *, const XML_Char *);
135 PHP_XML_API void XML_SetUserData(XML_Parser, void *);
136 PHP_XML_API void *XML_GetUserData(XML_Parser);
137 PHP_XML_API void XML_SetElementHandler(XML_Parser, XML_StartElementHandler, XML_EndElementHandler);
138 PHP_XML_API void XML_SetCharacterDataHandler(XML_Parser, XML_CharacterDataHandler);
139 PHP_XML_API void XML_SetProcessingInstructionHandler(XML_Parser, XML_ProcessingInstructionHandler);
140 PHP_XML_API void XML_SetDefaultHandler(XML_Parser, XML_DefaultHandler);
141 PHP_XML_API void XML_SetUnparsedEntityDeclHandler(XML_Parser, XML_UnparsedEntityDeclHandler);
142 PHP_XML_API void XML_SetNotationDeclHandler(XML_Parser, XML_NotationDeclHandler);
143 PHP_XML_API void XML_SetExternalEntityRefHandler(XML_Parser, XML_ExternalEntityRefHandler);
144 PHP_XML_API void XML_SetStartNamespaceDeclHandler(XML_Parser, XML_StartNamespaceDeclHandler);
145 PHP_XML_API void XML_SetEndNamespaceDeclHandler(XML_Parser, XML_EndNamespaceDeclHandler);
146 PHP_XML_API int XML_Parse(XML_Parser, const XML_Char *, int data_len, int is_final);
147 PHP_XML_API int XML_GetErrorCode(XML_Parser);
148 PHP_XML_API const XML_Char *XML_ErrorString(int);
149 PHP_XML_API int XML_GetCurrentLineNumber(XML_Parser);
150 PHP_XML_API int XML_GetCurrentColumnNumber(XML_Parser);
151 PHP_XML_API int XML_GetCurrentByteIndex(XML_Parser);
152 PHP_XML_API int XML_GetCurrentByteCount(XML_Parser);
153 PHP_XML_API const XML_Char *XML_ExpatVersion(void);
154 PHP_XML_API void XML_ParserFree(XML_Parser);
155
156 #elif defined(HAVE_LIBEXPAT)
157 #include <expat.h>
158 #endif
159
160 #endif
161
162
163
164
165
166
167