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: Stig Sæther Bakken <ssb@php.net> |
16 | Thies C. Arntzen <thies@thieso.net> |
17 | Sterling Hughes <sterling@php.net> |
18 +----------------------------------------------------------------------+
19*/
20
21/* $Id$ */
22
23#ifndef PHP_XML_H
24#define PHP_XML_H
25
26#ifdef HAVE_XML
27extern zend_module_entry xml_module_entry;
28#define xml_module_ptr &xml_module_entry
29#else
30#define xml_module_ptr NULL
31#endif
32
33#ifdef HAVE_XML
34
35#include "ext/xml/expat_compat.h"
36
37
38#ifdef XML_UNICODE
39#error "UTF-16 Unicode support not implemented!"
40#endif
41
42ZEND_BEGIN_MODULE_GLOBALS(xml)
43 XML_Char *default_encoding;
44ZEND_END_MODULE_GLOBALS(xml)
45
46typedef struct {
47 int index;
48 int case_folding;
49 XML_Parser parser;
50 XML_Char *target_encoding;
51
52 zval *startElementHandler;
53 zval *endElementHandler;
54 zval *characterDataHandler;
55 zval *processingInstructionHandler;
56 zval *defaultHandler;
57 zval *unparsedEntityDeclHandler;
58 zval *notationDeclHandler;
59 zval *externalEntityRefHandler;
60 zval *unknownEncodingHandler;
61 zval *startNamespaceDeclHandler;
62 zval *endNamespaceDeclHandler;
63
64 zend_function *startElementPtr;
65 zend_function *endElementPtr;
66 zend_function *characterDataPtr;
67 zend_function *processingInstructionPtr;
68 zend_function *defaultPtr;
69 zend_function *unparsedEntityDeclPtr;
70 zend_function *notationDeclPtr;
71 zend_function *externalEntityRefPtr;
72 zend_function *unknownEncodingPtr;
73 zend_function *startNamespaceDeclPtr;
74 zend_function *endNamespaceDeclPtr;
75
76 zval *object;
77
78 zval *data;
79 zval *info;
80 int level;
81 int toffset;
82 int curtag;
83 zval **ctag;
84 char **ltags;
85 int lastwasopen;
86 int skipwhite;
87 int isparsing;
88
89 XML_Char *baseURI;
90} xml_parser;
91
92
93typedef struct {
94 XML_Char *name;
95 char (*decoding_function)(unsigned short);
96 unsigned short (*encoding_function)(unsigned char);
97} xml_encoding;
98
99
100enum php_xml_option {
101 PHP_XML_OPTION_CASE_FOLDING = 1,
102 PHP_XML_OPTION_TARGET_ENCODING,
103 PHP_XML_OPTION_SKIP_TAGSTART,
104 PHP_XML_OPTION_SKIP_WHITE
105};
106
107/* for xml_parse_into_struct */
108
109#define XML_MAXLEVEL 255 /* XXX this should be dynamic */
110
111PHP_FUNCTION(xml_parser_create);
112PHP_FUNCTION(xml_parser_create_ns);
113PHP_FUNCTION(xml_set_object);
114PHP_FUNCTION(xml_set_element_handler);
115PHP_FUNCTION(xml_set_character_data_handler);
116PHP_FUNCTION(xml_set_processing_instruction_handler);
117PHP_FUNCTION(xml_set_default_handler);
118PHP_FUNCTION(xml_set_unparsed_entity_decl_handler);
119PHP_FUNCTION(xml_set_notation_decl_handler);
120PHP_FUNCTION(xml_set_external_entity_ref_handler);
121PHP_FUNCTION(xml_set_start_namespace_decl_handler);
122PHP_FUNCTION(xml_set_end_namespace_decl_handler);
123PHP_FUNCTION(xml_parse);
124PHP_FUNCTION(xml_get_error_code);
125PHP_FUNCTION(xml_error_string);
126PHP_FUNCTION(xml_get_current_line_number);
127PHP_FUNCTION(xml_get_current_column_number);
128PHP_FUNCTION(xml_get_current_byte_index);
129PHP_FUNCTION(xml_parser_free);
130PHP_FUNCTION(xml_parser_set_option);
131PHP_FUNCTION(xml_parser_get_option);
132PHP_FUNCTION(utf8_encode);
133PHP_FUNCTION(utf8_decode);
134PHP_FUNCTION(xml_parse_into_struct);
135
136PHPAPI char *_xml_zval_strdup(zval *val);
137PHPAPI char *xml_utf8_decode(const XML_Char *, int, int *, const XML_Char *);
138PHPAPI char *xml_utf8_encode(const char *s, int len, int *newlen, const XML_Char *encoding);
139
140#endif /* HAVE_LIBEXPAT */
141
142#define phpext_xml_ptr xml_module_ptr
143
144#ifdef ZTS
145#define XML(v) TSRMG(xml_globals_id, zend_xml_globals *, v)
146#else
147#define XML(v) (xml_globals.v)
148#endif
149
150#endif /* PHP_XML_H */
151
152/*
153 * Local variables:
154 * tab-width: 4
155 * c-basic-offset: 4
156 * End:
157 */
158