PageRenderTime 57ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/ext/dom/xml_common.h

https://github.com/php/php-src
C Header | 88 lines | 58 code | 14 blank | 16 comment | 7 complexity | 07feed6c0a080eecf7f0de1d8529228b MD5 | raw file
Possible License(s): BSD-2-Clause, BSD-3-Clause, MPL-2.0-no-copyleft-exception, LGPL-2.1
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Copyright (c) The PHP Group |
  4. +----------------------------------------------------------------------+
  5. | This source file is subject to version 3.01 of the PHP license, |
  6. | that is bundled with this package in the file LICENSE, and is |
  7. | available through the world-wide-web at the following url: |
  8. | https://www.php.net/license/3_01.txt |
  9. | If you did not receive a copy of the PHP license and are unable to |
  10. | obtain it through the world-wide-web, please send a note to |
  11. | license@php.net so we can mail you a copy immediately. |
  12. +----------------------------------------------------------------------+
  13. | Authors: Christian Stocker <chregu@php.net> |
  14. | Rob Richards <rrichards@php.net> |
  15. +----------------------------------------------------------------------+
  16. */
  17. #ifndef PHP_XML_COMMON_H
  18. #define PHP_XML_COMMON_H
  19. #include "ext/libxml/php_libxml.h"
  20. typedef libxml_doc_props *dom_doc_propsptr;
  21. typedef struct _dom_object {
  22. void *ptr;
  23. php_libxml_ref_obj *document;
  24. HashTable *prop_handler;
  25. zend_object std;
  26. } dom_object;
  27. static inline dom_object *php_dom_obj_from_obj(zend_object *obj) {
  28. return (dom_object*)((char*)(obj) - XtOffsetOf(dom_object, std));
  29. }
  30. #define Z_DOMOBJ_P(zv) php_dom_obj_from_obj(Z_OBJ_P((zv)))
  31. #ifdef PHP_WIN32
  32. # ifdef DOM_EXPORTS
  33. # define PHP_DOM_EXPORT __declspec(dllexport)
  34. # elif !defined(DOM_LOCAL_DEFINES) /* Allow to counteract LNK4049 warning. */
  35. # define PHP_DOM_EXPORT __declspec(dllimport)
  36. # else
  37. # define PHP_DOM_EXPORT
  38. # endif /* DOM_EXPORTS */
  39. #elif defined(__GNUC__) && __GNUC__ >= 4
  40. # define PHP_DOM_EXPORT __attribute__ ((visibility("default")))
  41. #elif defined(PHPAPI)
  42. # define PHP_DOM_EXPORT PHPAPI
  43. #else
  44. # define PHP_DOM_EXPORT
  45. #endif
  46. PHP_DOM_EXPORT extern zend_class_entry *dom_node_class_entry;
  47. PHP_DOM_EXPORT dom_object *php_dom_object_get_data(xmlNodePtr obj);
  48. PHP_DOM_EXPORT bool php_dom_create_object(xmlNodePtr obj, zval* return_value, dom_object *domobj);
  49. PHP_DOM_EXPORT xmlNodePtr dom_object_get_node(dom_object *obj);
  50. #define DOM_XMLNS_NAMESPACE \
  51. (const xmlChar *) "http://www.w3.org/2000/xmlns/"
  52. #define NODE_GET_OBJ(__ptr, __id, __prtype, __intern) { \
  53. __intern = Z_LIBXML_NODE_P(__id); \
  54. if (__intern->node == NULL || !(__ptr = (__prtype)__intern->node->node)) { \
  55. php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", \
  56. ZSTR_VAL(__intern->std.ce->name));\
  57. RETURN_NULL();\
  58. } \
  59. }
  60. #define DOC_GET_OBJ(__ptr, __id, __prtype, __intern) { \
  61. __intern = Z_LIBXML_NODE_P(__id); \
  62. if (__intern->document != NULL) { \
  63. if (!(__ptr = (__prtype)__intern->document->ptr)) { \
  64. php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", __intern->std.ce->name);\
  65. RETURN_NULL();\
  66. } \
  67. } \
  68. }
  69. #define DOM_RET_OBJ(obj, ret, domobject) \
  70. *ret = php_dom_create_object(obj, return_value, domobject)
  71. #define DOM_GET_THIS_OBJ(__ptr, __id, __prtype, __intern) \
  72. __id = ZEND_THIS; \
  73. DOM_GET_OBJ(__ptr, __id, __prtype, __intern);
  74. #endif