xref: /PHP-5.5/ext/libxml/php_libxml.h (revision 73c1be26)
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: Shane Caraveo <shane@php.net>                               |
16    |          Wez Furlong <wez@thebrainroom.com>                          |
17    +----------------------------------------------------------------------+
18 */
19 
20 /* $Id$ */
21 
22 #ifndef PHP_LIBXML_H
23 #define PHP_LIBXML_H
24 
25 #if HAVE_LIBXML
26 extern zend_module_entry libxml_module_entry;
27 #define libxml_module_ptr &libxml_module_entry
28 
29 #ifdef PHP_WIN32
30 #	define PHP_LIBXML_API __declspec(dllexport)
31 #elif defined(__GNUC__) && __GNUC__ >= 4
32 #	define PHP_LIBXML_API __attribute__ ((visibility("default")))
33 #else
34 #	define PHP_LIBXML_API
35 #endif
36 
37 #include "ext/standard/php_smart_str.h"
38 #include <libxml/tree.h>
39 
40 #define LIBXML_SAVE_NOEMPTYTAG 1<<2
41 
42 ZEND_BEGIN_MODULE_GLOBALS(libxml)
43 	zval *stream_context;
44 	smart_str error_buffer;
45 	zend_llist *error_list;
46 	struct _php_libxml_entity_resolver {
47 		zend_fcall_info			fci;
48 		zend_fcall_info_cache	fcc;
49 	} entity_loader;
50 	zend_bool entity_loader_disabled;
51 ZEND_END_MODULE_GLOBALS(libxml)
52 
53 typedef struct _libxml_doc_props {
54 	int formatoutput;
55 	int validateonparse;
56 	int resolveexternals;
57 	int preservewhitespace;
58 	int substituteentities;
59 	int stricterror;
60 	int recover;
61 	HashTable *classmap;
62 } libxml_doc_props;
63 
64 typedef struct _php_libxml_ref_obj {
65 	void *ptr;
66 	int   refcount;
67 	libxml_doc_props *doc_props;
68 } php_libxml_ref_obj;
69 
70 typedef struct _php_libxml_node_ptr {
71 	xmlNodePtr node;
72 	int	refcount;
73 	void *_private;
74 } php_libxml_node_ptr;
75 
76 typedef struct _php_libxml_node_object {
77 	zend_object  std;
78 	php_libxml_node_ptr *node;
79 	php_libxml_ref_obj *document;
80 	HashTable *properties;
81 } php_libxml_node_object;
82 
83 typedef void * (*php_libxml_export_node) (zval *object TSRMLS_DC);
84 
85 PHP_LIBXML_API int php_libxml_increment_node_ptr(php_libxml_node_object *object, xmlNodePtr node, void *private_data TSRMLS_DC);
86 PHP_LIBXML_API int php_libxml_decrement_node_ptr(php_libxml_node_object *object TSRMLS_DC);
87 PHP_LIBXML_API int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr docp TSRMLS_DC);
88 PHP_LIBXML_API int php_libxml_decrement_doc_ref(php_libxml_node_object *object TSRMLS_DC);
89 PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object TSRMLS_DC);
90 PHP_LIBXML_API int php_libxml_register_export(zend_class_entry *ce, php_libxml_export_node export_function);
91 /* When an explicit freeing of node and children is required */
92 PHP_LIBXML_API void php_libxml_node_free_resource(xmlNodePtr node TSRMLS_DC);
93 /* When object dtor is called as node may still be referenced */
94 PHP_LIBXML_API void php_libxml_node_decrement_resource(php_libxml_node_object *object TSRMLS_DC);
95 PHP_LIBXML_API void php_libxml_error_handler(void *ctx, const char *msg, ...);
96 PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
97 PHP_LIBXML_API void php_libxml_ctx_error(void *ctx, const char *msg, ...);
98 PHP_LIBXML_API int php_libxml_xmlCheckUTF8(const unsigned char *s);
99 PHP_LIBXML_API zval *php_libxml_switch_context(zval *context TSRMLS_DC);
100 PHP_LIBXML_API void php_libxml_issue_error(int level, const char *msg TSRMLS_DC);
101 PHP_LIBXML_API zend_bool php_libxml_disable_entity_loader(zend_bool disable TSRMLS_DC);
102 
103 /* Init/shutdown functions*/
104 PHP_LIBXML_API void php_libxml_initialize(void);
105 PHP_LIBXML_API void php_libxml_shutdown(void);
106 
107 #ifdef ZTS
108 #define LIBXML(v) TSRMG(libxml_globals_id, zend_libxml_globals *, v)
109 #else
110 #define LIBXML(v) (libxml_globals.v)
111 #endif
112 
113 #else /* HAVE_LIBXML */
114 #define libxml_module_ptr NULL
115 #endif
116 
117 #define phpext_libxml_ptr libxml_module_ptr
118 
119 #endif /* PHP_LIBXML_H */
120 
121 /*
122  * Local variables:
123  * tab-width: 4
124  * c-basic-offset: 4
125  * End:
126  */
127