1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #ifndef PHP_XML_COMMON_H
23 #define PHP_XML_COMMON_H
24
25 #include "ext/libxml/php_libxml.h"
26
27 typedef libxml_doc_props *dom_doc_propsptr;
28
29 typedef struct _dom_object {
30 zend_object std;
31 void *ptr;
32 php_libxml_ref_obj *document;
33 HashTable *prop_handler;
34 zend_object_handle handle;
35 } dom_object;
36
37 #ifdef PHP_WIN32
38 # ifdef PHPAPI
39 # undef PHPAPI
40 # endif
41 # ifdef DOM_EXPORTS
42 # define PHPAPI __declspec(dllexport)
43 # else
44 # define PHPAPI __declspec(dllimport)
45 # endif
46 #elif defined(__GNUC__) && __GNUC__ >= 4
47 # ifdef PHPAPI
48 # undef PHPAPI
49 # endif
50 # define PHPAPI __attribute__ ((visibility("default")))
51 #endif
52
53 #define PHP_DOM_EXPORT PHPAPI
54
55 PHP_DOM_EXPORT extern zend_class_entry *dom_node_class_entry;
56 PHP_DOM_EXPORT dom_object *php_dom_object_get_data(xmlNodePtr obj);
57 PHP_DOM_EXPORT zval *php_dom_create_object(xmlNodePtr obj, int *found, zval* return_value, dom_object *domobj TSRMLS_DC);
58 PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj);
59
60 #define DOM_XMLNS_NAMESPACE \
61 (const xmlChar *) "http://www.w3.org/2000/xmlns/"
62
63 #define NODE_GET_OBJ(__ptr, __id, __prtype, __intern) { \
64 __intern = (php_libxml_node_object *)zend_object_store_get_object(__id TSRMLS_CC); \
65 if (__intern->node == NULL || !(__ptr = (__prtype)__intern->node->node)) { \
66 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", __intern->std.ce->name);\
67 RETURN_NULL();\
68 } \
69 }
70
71 #define DOC_GET_OBJ(__ptr, __id, __prtype, __intern) { \
72 __intern = (php_libxml_node_object *)zend_object_store_get_object(__id TSRMLS_CC); \
73 if (__intern->document != NULL) { \
74 if (!(__ptr = (__prtype)__intern->document->ptr)) { \
75 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", __intern->std.ce->name);\
76 RETURN_NULL();\
77 } \
78 } \
79 }
80
81 #define DOM_RET_OBJ(obj, ret, domobject) \
82 if (!php_dom_create_object(obj, ret, return_value, domobject TSRMLS_CC)) { \
83 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create required DOM object"); \
84 RETURN_FALSE; \
85 }
86
87 #define DOM_GET_THIS(zval) \
88 if (NULL == (zval = getThis())) { \
89 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing"); \
90 RETURN_FALSE; \
91 }
92
93 #define DOM_GET_THIS_OBJ(__ptr, __id, __prtype, __intern) \
94 DOM_GET_THIS(__id); \
95 DOM_GET_OBJ(__ptr, __id, __prtype, __intern);
96
97 #endif
98
99
100
101
102
103
104
105
106