1 | /* |
2 | +----------------------------------------------------------------------+ |
3 | | PHP Version 5 | |
4 | +----------------------------------------------------------------------+ |
5 | | Copyright (c) 1997-2015 The PHP Group | |
6 | +----------------------------------------------------------------------+ |
7 | | This source file is subject to version 3.01 of the PHP license, | |
8 | | that is bundled with this package in the file LICENSE, and is | |
9 | | available through the world-wide-web at the following url: | |
10 | | http://www.php.net/license/3_01.txt | |
11 | | If you did not receive a copy of the PHP license and are unable to | |
12 | | obtain it through the world-wide-web, please send a note to | |
13 | | license@php.net so we can mail you a copy immediately. | |
14 | +----------------------------------------------------------------------+ |
15 | | Authors: Sterling Hughes <sterling@php.net> | |
16 | +----------------------------------------------------------------------+ |
17 | */ |
18 | |
19 | /* $Id$ */ |
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 | #if !defined(HAVE_LIBEXPAT) && defined(HAVE_LIBXML) |
31 | #define LIBXML_EXPAT_COMPAT 1 |
32 | |
33 | #include "php.h" |
34 | #include "php_compat.h" |
35 | |
36 | #include <libxml/parser.h> |
37 | #include <libxml/parserInternals.h> |
38 | #include <libxml/tree.h> |
39 | #include <libxml/hash.h> |
40 | |
41 | /* For compatibility with the misspelled version. */ |
42 | #define _ns_seperator _ns_separator |
43 | |
44 | typedef xmlChar XML_Char; |
45 | |
46 | typedef void (*XML_StartElementHandler)(void *, const XML_Char *, const XML_Char **); |
47 | typedef void (*XML_EndElementHandler)(void *, const XML_Char *); |
48 | typedef void (*XML_CharacterDataHandler)(void *, const XML_Char *, int); |
49 | typedef void (*XML_ProcessingInstructionHandler)(void *, const XML_Char *, const XML_Char *); |
50 | typedef void (*XML_CommentHandler)(void *, const XML_Char *); |
51 | typedef void (*XML_DefaultHandler)(void *, const XML_Char *, int); |
52 | typedef void (*XML_UnparsedEntityDeclHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *); |
53 | typedef void (*XML_NotationDeclHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *); |
54 | typedef int (*XML_ExternalEntityRefHandler)(void *, const XML_Char *, const XML_Char *, const XML_Char *, const XML_Char *); |
55 | typedef void (*XML_StartNamespaceDeclHandler)(void *, const XML_Char *, const XML_Char *); |
56 | typedef void (*XML_EndNamespaceDeclHandler)(void *, const XML_Char *); |
57 | |
58 | typedef struct _XML_Memory_Handling_Suite { |
59 | void *(*malloc_fcn)(size_t size); |
60 | void *(*realloc_fcn)(void *ptr, size_t size); |
61 | void (*free_fcn)(void *ptr); |
62 | } XML_Memory_Handling_Suite; |
63 | |
64 | typedef struct _XML_Parser { |
65 | int use_namespace; |
66 | |
67 | xmlChar *_ns_separator; |
68 | |
69 | void *user; |
70 | xmlParserCtxtPtr parser; |
71 | |
72 | XML_StartElementHandler h_start_element; |
73 | XML_EndElementHandler h_end_element; |
74 | XML_CharacterDataHandler h_cdata; |
75 | XML_ProcessingInstructionHandler h_pi; |
76 | XML_CommentHandler ; |
77 | XML_DefaultHandler h_default; |
78 | XML_UnparsedEntityDeclHandler h_unparsed_entity_decl; |
79 | XML_NotationDeclHandler h_notation_decl; |
80 | XML_ExternalEntityRefHandler h_external_entity_ref; |
81 | XML_StartNamespaceDeclHandler h_start_ns; |
82 | XML_EndNamespaceDeclHandler h_end_ns; |
83 | } *XML_Parser; |
84 | |
85 | enum XML_Error { |
86 | XML_ERROR_NONE, |
87 | XML_ERROR_NO_MEMORY, |
88 | XML_ERROR_SYNTAX, |
89 | XML_ERROR_NO_ELEMENTS, |
90 | XML_ERROR_INVALID_TOKEN, |
91 | XML_ERROR_UNCLOSED_TOKEN, |
92 | XML_ERROR_PARTIAL_CHAR, |
93 | XML_ERROR_TAG_MISMATCH, |
94 | XML_ERROR_DUPLICATE_ATTRIBUTE, |
95 | XML_ERROR_JUNK_AFTER_DOC_ELEMENT, |
96 | XML_ERROR_PARAM_ENTITY_REF, |
97 | XML_ERROR_UNDEFINED_ENTITY, |
98 | XML_ERROR_RECURSIVE_ENTITY_REF, |
99 | XML_ERROR_ASYNC_ENTITY, |
100 | XML_ERROR_BAD_CHAR_REF, |
101 | XML_ERROR_BINARY_ENTITY_REF, |
102 | XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF, |
103 | XML_ERROR_MISPLACED_XML_PI, |
104 | XML_ERROR_UNKNOWN_ENCODING, |
105 | XML_ERROR_INCORRECT_ENCODING, |
106 | XML_ERROR_UNCLOSED_CDATA_SECTION, |
107 | XML_ERROR_EXTERNAL_ENTITY_HANDLING, |
108 | XML_ERROR_NOT_STANDALONE, |
109 | XML_ERROR_UNEXPECTED_STATE, |
110 | XML_ERROR_ENTITY_DECLARED_IN_PE, |
111 | XML_ERROR_FEATURE_REQUIRES_XML_DTD, |
112 | XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING |
113 | }; |
114 | |
115 | enum XML_Content_Type { |
116 | XML_CTYPE_EMPTY = 1, |
117 | XML_CTYPE_ANY, |
118 | XML_CTYPE_MIXED, |
119 | XML_CTYPE_NAME, |
120 | XML_CTYPE_CHOICE, |
121 | XML_CTYPE_SEQ |
122 | }; |
123 | |
124 | PHPAPI XML_Parser XML_ParserCreate(const XML_Char *); |
125 | PHPAPI XML_Parser XML_ParserCreateNS(const XML_Char *, const XML_Char); |
126 | PHPAPI XML_Parser XML_ParserCreate_MM(const XML_Char *, const XML_Memory_Handling_Suite *, const XML_Char *); |
127 | PHPAPI void XML_SetUserData(XML_Parser, void *); |
128 | PHPAPI void *XML_GetUserData(XML_Parser); |
129 | PHPAPI void XML_SetElementHandler(XML_Parser, XML_StartElementHandler, XML_EndElementHandler); |
130 | PHPAPI void XML_SetCharacterDataHandler(XML_Parser, XML_CharacterDataHandler); |
131 | PHPAPI void XML_SetProcessingInstructionHandler(XML_Parser, XML_ProcessingInstructionHandler); |
132 | PHPAPI void XML_SetDefaultHandler(XML_Parser, XML_DefaultHandler); |
133 | PHPAPI void XML_SetUnparsedEntityDeclHandler(XML_Parser, XML_UnparsedEntityDeclHandler); |
134 | PHPAPI void XML_SetNotationDeclHandler(XML_Parser, XML_NotationDeclHandler); |
135 | PHPAPI void XML_SetExternalEntityRefHandler(XML_Parser, XML_ExternalEntityRefHandler); |
136 | PHPAPI void XML_SetStartNamespaceDeclHandler(XML_Parser, XML_StartNamespaceDeclHandler); |
137 | PHPAPI void XML_SetEndNamespaceDeclHandler(XML_Parser, XML_EndNamespaceDeclHandler); |
138 | PHPAPI int XML_Parse(XML_Parser, const XML_Char *, int data_len, int is_final); |
139 | PHPAPI int XML_GetErrorCode(XML_Parser); |
140 | PHPAPI const XML_Char *XML_ErrorString(int); |
141 | PHPAPI int XML_GetCurrentLineNumber(XML_Parser); |
142 | PHPAPI int XML_GetCurrentColumnNumber(XML_Parser); |
143 | PHPAPI int XML_GetCurrentByteIndex(XML_Parser); |
144 | PHPAPI int XML_GetCurrentByteCount(XML_Parser); |
145 | PHPAPI const XML_Char *XML_ExpatVersion(void); |
146 | PHPAPI void XML_ParserFree(XML_Parser); |
147 | |
148 | #elif defined(HAVE_LIBEXPAT) |
149 | #include <expat.h> |
150 | #endif /* HAVE_LIBEXPAT */ |
151 | |
152 | #endif /* PHP_EXPAT_COMPAT_H */ |
153 | |
154 | /* |
155 | * Local variables: |
156 | * tab-width: 4 |
157 | * c-basic-offset: 4 |
158 | * End: |
159 | */ |
160 | |