Back to index

php5  5.3.10
xml_common.h
Go to the documentation of this file.
00001 /*
00002   +----------------------------------------------------------------------+
00003   | PHP Version 5                                                        |
00004   +----------------------------------------------------------------------+
00005   | Copyright (c) 1997-2012 The PHP Group                                |
00006   +----------------------------------------------------------------------+
00007   | This source file is subject to version 3.01 of the PHP license,      |
00008   | that is bundled with this package in the file LICENSE, and is        |
00009   | available through the world-wide-web at the following url:           |
00010   | http://www.php.net/license/3_01.txt                                  |
00011   | If you did not receive a copy of the PHP license and are unable to   |
00012   | obtain it through the world-wide-web, please send a note to          |
00013   | license@php.net so we can mail you a copy immediately.               |
00014   +----------------------------------------------------------------------+
00015   | Authors: Christian Stocker <chregu@php.net>                          |
00016   |          Rob Richards <rrichards@php.net>                            |
00017   +----------------------------------------------------------------------+
00018 */
00019 
00020 /* $Id: xml_common.h 321634 2012-01-01 13:15:04Z felipe $ */
00021 
00022 #ifndef PHP_XML_COMMON_H
00023 #define PHP_XML_COMMON_H
00024 
00025 #include "ext/libxml/php_libxml.h"
00026 
00027 typedef libxml_doc_props *dom_doc_propsptr;
00028 
00029 typedef struct _dom_object {
00030        zend_object  std;
00031        void *ptr;
00032        php_libxml_ref_obj *document;
00033        HashTable *prop_handler;
00034        zend_object_handle handle;
00035 } dom_object;
00036 
00037 #ifdef PHP_WIN32
00038 #      ifdef PHPAPI
00039 #             undef PHPAPI
00040 #      endif
00041 #      ifdef DOM_EXPORTS
00042 #             define PHPAPI __declspec(dllexport)
00043 #      else
00044 #             define PHPAPI __declspec(dllimport)
00045 #      endif /* DOM_EXPORTS */
00046 #elif defined(__GNUC__) && __GNUC__ >= 4
00047 #      ifdef PHPAPI
00048 #             undef PHPAPI
00049 #      endif
00050 #      define PHPAPI __attribute__ ((visibility("default")))
00051 #endif /* PHP_WIN32 */
00052 
00053 #define PHP_DOM_EXPORT PHPAPI
00054 
00055 PHP_DOM_EXPORT extern zend_class_entry *dom_node_class_entry;
00056 PHP_DOM_EXPORT dom_object *php_dom_object_get_data(xmlNodePtr obj);
00057 PHP_DOM_EXPORT zval *php_dom_create_object(xmlNodePtr obj, int *found, zval *in, zval* return_value, dom_object *domobj TSRMLS_DC);
00058 PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj);
00059 
00060 #define DOM_XMLNS_NAMESPACE \
00061     (const xmlChar *) "http://www.w3.org/2000/xmlns/"
00062 
00063 #define NODE_GET_OBJ(__ptr, __id, __prtype, __intern) { \
00064        __intern = (php_libxml_node_object *)zend_object_store_get_object(__id TSRMLS_CC); \
00065        if (__intern->node == NULL || !(__ptr = (__prtype)__intern->node->node)) { \
00066               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", __intern->std.ce->name);\
00067               RETURN_NULL();\
00068        } \
00069 }
00070 
00071 #define DOC_GET_OBJ(__ptr, __id, __prtype, __intern) { \
00072        __intern = (php_libxml_node_object *)zend_object_store_get_object(__id TSRMLS_CC); \
00073        if (__intern->document != NULL) { \
00074               if (!(__ptr = (__prtype)__intern->document->ptr)) { \
00075                      php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", __intern->std.ce->name);\
00076                      RETURN_NULL();\
00077               } \
00078        } \
00079 }
00080 
00081 #define DOM_RET_OBJ_EX(obj, ret, domobject) \
00082        if (!php_dom_create_object(obj, ret, NULL, return_value, domobject TSRMLS_CC)) { \
00083               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create required DOM object"); \
00084               RETURN_FALSE; \
00085        }
00086 
00087 #define DOM_RET_OBJ(zval, obj, ret, domobject) DOM_RET_OBJ_EX(obj, ret, domobject)
00088 
00089 #define DOM_GET_THIS(zval) \
00090        if (NULL == (zval = getThis())) { \
00091               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Underlying object missing"); \
00092               RETURN_FALSE; \
00093        }
00094 
00095 #define DOM_GET_THIS_OBJ(__ptr, __id, __prtype, __intern) \
00096        DOM_GET_THIS(__id); \
00097        DOM_GET_OBJ(__ptr, __id, __prtype, __intern);
00098 
00099 #endif
00100 
00101 /*
00102  * Local variables:
00103  * tab-width: 4
00104  * c-basic-offset: 4
00105  * End:
00106  * vim600: noet sw=4 ts=4 fdm=marker
00107  * vim<600: noet sw=4 ts=4
00108  */