xml_common.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 7 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2018 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: Christian Stocker <chregu@php.net> |
  16. | Rob Richards <rrichards@php.net> |
  17. +----------------------------------------------------------------------+
  18. */
  19. #ifndef PHP_XML_COMMON_H
  20. #define PHP_XML_COMMON_H
  21. #include "ext/libxml/php_libxml.h"
  22. typedef libxml_doc_props *dom_doc_propsptr;
  23. typedef struct _dom_object {
  24. void *ptr;
  25. php_libxml_ref_obj *document;
  26. HashTable *prop_handler;
  27. zend_object std;
  28. } dom_object;
  29. static inline dom_object *php_dom_obj_from_obj(zend_object *obj) {
  30. return (dom_object*)((char*)(obj) - XtOffsetOf(dom_object, std));
  31. }
  32. #define Z_DOMOBJ_P(zv) php_dom_obj_from_obj(Z_OBJ_P((zv)))
  33. #ifdef PHP_WIN32
  34. # ifdef DOM_EXPORTS
  35. # define PHP_DOM_EXPORT __declspec(dllexport)
  36. # elif !defined(DOM_LOCAL_DEFINES) /* Allow to counteract LNK4049 warning. */
  37. # define PHP_DOM_EXPORT __declspec(dllimport)
  38. # else
  39. # define PHP_DOM_EXPORT
  40. # endif /* DOM_EXPORTS */
  41. #elif defined(__GNUC__) && __GNUC__ >= 4
  42. # define PHP_DOM_EXPORT __attribute__ ((visibility("default")))
  43. #elif defined(PHPAPI)
  44. # define PHP_DOM_EXPORT PHPAPI
  45. #else
  46. # define PHP_DOM_EXPORT
  47. #endif
  48. PHP_DOM_EXPORT extern zend_class_entry *dom_node_class_entry;
  49. PHP_DOM_EXPORT dom_object *php_dom_object_get_data(xmlNodePtr obj);
  50. PHP_DOM_EXPORT zend_bool php_dom_create_object(xmlNodePtr obj, zval* return_value, dom_object *domobj);
  51. PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj);
  52. #define DOM_XMLNS_NAMESPACE \
  53. (const xmlChar *) "http://www.w3.org/2000/xmlns/"
  54. #define NODE_GET_OBJ(__ptr, __id, __prtype, __intern) { \
  55. __intern = Z_LIBXML_NODE_P(__id); \
  56. if (__intern->node == NULL || !(__ptr = (__prtype)__intern->node->node)) { \
  57. php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", \
  58. ZSTR_VAL(__intern->std.ce->name));\
  59. RETURN_NULL();\
  60. } \
  61. }
  62. #define DOC_GET_OBJ(__ptr, __id, __prtype, __intern) { \
  63. __intern = Z_LIBXML_NODE_P(__id); \
  64. if (__intern->document != NULL) { \
  65. if (!(__ptr = (__prtype)__intern->document->ptr)) { \
  66. php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", __intern->std.ce->name);\
  67. RETURN_NULL();\
  68. } \
  69. } \
  70. }
  71. #define DOM_RET_OBJ(obj, ret, domobject) \
  72. *ret = php_dom_create_object(obj, return_value, domobject)
  73. #define DOM_GET_THIS(zval) \
  74. if (NULL == (zval = getThis())) { \
  75. php_error_docref(NULL, E_WARNING, "Underlying object missing"); \
  76. RETURN_FALSE; \
  77. }
  78. #define DOM_GET_THIS_OBJ(__ptr, __id, __prtype, __intern) \
  79. DOM_GET_THIS(__id); \
  80. DOM_GET_OBJ(__ptr, __id, __prtype, __intern);
  81. #endif
  82. /*
  83. * Local variables:
  84. * tab-width: 4
  85. * c-basic-offset: 4
  86. * End:
  87. * vim600: noet sw=4 ts=4 fdm=marker
  88. * vim<600: noet sw=4 ts=4
  89. */