xref: /PHP-5.3/ext/libxml/php_libxml.h (revision 8e76d040)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 5                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2013 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 	zend_bool entity_loader_disabled;
47 ZEND_END_MODULE_GLOBALS(libxml)
48 
49 typedef struct _libxml_doc_props {
50 	int formatoutput;
51 	int validateonparse;
52 	int resolveexternals;
53 	int preservewhitespace;
54 	int substituteentities;
55 	int stricterror;
56 	int recover;
57 	HashTable *classmap;
58 } libxml_doc_props;
59 
60 typedef struct _php_libxml_ref_obj {
61 	void *ptr;
62 	int   refcount;
63 	libxml_doc_props *doc_props;
64 } php_libxml_ref_obj;
65 
66 typedef struct _php_libxml_node_ptr {
67 	xmlNodePtr node;
68 	int	refcount;
69 	void *_private;
70 } php_libxml_node_ptr;
71 
72 typedef struct _php_libxml_node_object {
73 	zend_object  std;
74 	php_libxml_node_ptr *node;
75 	php_libxml_ref_obj *document;
76 	HashTable *properties;
77 } php_libxml_node_object;
78 
79 typedef void * (*php_libxml_export_node) (zval *object TSRMLS_DC);
80 
81 PHP_LIBXML_API int php_libxml_increment_node_ptr(php_libxml_node_object *object, xmlNodePtr node, void *private_data TSRMLS_DC);
82 PHP_LIBXML_API int php_libxml_decrement_node_ptr(php_libxml_node_object *object TSRMLS_DC);
83 PHP_LIBXML_API int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr docp TSRMLS_DC);
84 PHP_LIBXML_API int php_libxml_decrement_doc_ref(php_libxml_node_object *object TSRMLS_DC);
85 PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object TSRMLS_DC);
86 PHP_LIBXML_API int php_libxml_register_export(zend_class_entry *ce, php_libxml_export_node export_function);
87 /* When an explicit freeing of node and children is required */
88 PHP_LIBXML_API void php_libxml_node_free_resource(xmlNodePtr node TSRMLS_DC);
89 /* When object dtor is called as node may still be referenced */
90 PHP_LIBXML_API void php_libxml_node_decrement_resource(php_libxml_node_object *object TSRMLS_DC);
91 PHP_LIBXML_API void php_libxml_error_handler(void *ctx, const char *msg, ...);
92 PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
93 PHP_LIBXML_API void php_libxml_ctx_error(void *ctx, const char *msg, ...);
94 PHP_LIBXML_API int php_libxml_xmlCheckUTF8(const unsigned char *s);
95 PHP_LIBXML_API zval *php_libxml_switch_context(zval *context TSRMLS_DC);
96 PHP_LIBXML_API void php_libxml_issue_error(int level, const char *msg TSRMLS_DC);
97 PHP_LIBXML_API zend_bool php_libxml_disable_entity_loader(zend_bool disable TSRMLS_DC);
98 
99 /* Init/shutdown functions*/
100 PHP_LIBXML_API void php_libxml_initialize(void);
101 PHP_LIBXML_API void php_libxml_shutdown(void);
102 
103 #ifdef ZTS
104 #define LIBXML(v) TSRMG(libxml_globals_id, zend_libxml_globals *, v)
105 #else
106 #define LIBXML(v) (libxml_globals.v)
107 #endif
108 
109 #else /* HAVE_LIBXML */
110 #define libxml_module_ptr NULL
111 #endif
112 
113 #define phpext_libxml_ptr libxml_module_ptr
114 
115 #endif /* PHP_LIBXML_H */
116 
117 /*
118  * Local variables:
119  * tab-width: 4
120  * c-basic-offset: 4
121  * End:
122  */
123