php_libxml.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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: Shane Caraveo <shane@php.net> |
  16. | Wez Furlong <wez@thebrainroom.com> |
  17. +----------------------------------------------------------------------+
  18. */
  19. #ifndef PHP_LIBXML_H
  20. #define PHP_LIBXML_H
  21. #if HAVE_LIBXML
  22. extern zend_module_entry libxml_module_entry;
  23. #define libxml_module_ptr &libxml_module_entry
  24. #include "php_version.h"
  25. #define PHP_LIBXML_VERSION PHP_VERSION
  26. #ifdef PHP_WIN32
  27. # define PHP_LIBXML_API __declspec(dllexport)
  28. #elif defined(__GNUC__) && __GNUC__ >= 4
  29. # define PHP_LIBXML_API __attribute__ ((visibility("default")))
  30. #else
  31. # define PHP_LIBXML_API
  32. #endif
  33. #include "zend_smart_str.h"
  34. #include <libxml/tree.h>
  35. #define LIBXML_SAVE_NOEMPTYTAG 1<<2
  36. ZEND_BEGIN_MODULE_GLOBALS(libxml)
  37. zval stream_context;
  38. smart_str error_buffer;
  39. zend_llist *error_list;
  40. struct _php_libxml_entity_resolver {
  41. zval object;
  42. zend_fcall_info fci;
  43. zend_fcall_info_cache fcc;
  44. } entity_loader;
  45. zend_bool entity_loader_disabled;
  46. ZEND_END_MODULE_GLOBALS(libxml)
  47. typedef struct _libxml_doc_props {
  48. int formatoutput;
  49. int validateonparse;
  50. int resolveexternals;
  51. int preservewhitespace;
  52. int substituteentities;
  53. int stricterror;
  54. int recover;
  55. HashTable *classmap;
  56. } libxml_doc_props;
  57. typedef struct _php_libxml_ref_obj {
  58. void *ptr;
  59. int refcount;
  60. libxml_doc_props *doc_props;
  61. } php_libxml_ref_obj;
  62. typedef struct _php_libxml_node_ptr {
  63. xmlNodePtr node;
  64. int refcount;
  65. void *_private;
  66. } php_libxml_node_ptr;
  67. typedef struct _php_libxml_node_object {
  68. php_libxml_node_ptr *node;
  69. php_libxml_ref_obj *document;
  70. HashTable *properties;
  71. zend_object std;
  72. } php_libxml_node_object;
  73. static inline php_libxml_node_object *php_libxml_node_fetch_object(zend_object *obj) {
  74. return (php_libxml_node_object *)((char*)(obj) - obj->handlers->offset);
  75. }
  76. #define Z_LIBXML_NODE_P(zv) php_libxml_node_fetch_object(Z_OBJ_P((zv)))
  77. typedef void * (*php_libxml_export_node) (zval *object);
  78. PHP_LIBXML_API int php_libxml_increment_node_ptr(php_libxml_node_object *object, xmlNodePtr node, void *private_data);
  79. PHP_LIBXML_API int php_libxml_decrement_node_ptr(php_libxml_node_object *object);
  80. PHP_LIBXML_API int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr docp);
  81. PHP_LIBXML_API int php_libxml_decrement_doc_ref(php_libxml_node_object *object);
  82. PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object);
  83. PHP_LIBXML_API zval *php_libxml_register_export(zend_class_entry *ce, php_libxml_export_node export_function);
  84. /* When an explicit freeing of node and children is required */
  85. PHP_LIBXML_API void php_libxml_node_free_list(xmlNodePtr node);
  86. PHP_LIBXML_API void php_libxml_node_free_resource(xmlNodePtr node);
  87. /* When object dtor is called as node may still be referenced */
  88. PHP_LIBXML_API void php_libxml_node_decrement_resource(php_libxml_node_object *object);
  89. PHP_LIBXML_API void php_libxml_error_handler(void *ctx, const char *msg, ...);
  90. PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
  91. PHP_LIBXML_API void php_libxml_ctx_error(void *ctx, const char *msg, ...);
  92. PHP_LIBXML_API int php_libxml_xmlCheckUTF8(const unsigned char *s);
  93. PHP_LIBXML_API void php_libxml_switch_context(zval *context, zval *oldcontext);
  94. PHP_LIBXML_API void php_libxml_issue_error(int level, const char *msg);
  95. PHP_LIBXML_API zend_bool php_libxml_disable_entity_loader(zend_bool disable);
  96. /* Init/shutdown functions*/
  97. PHP_LIBXML_API void php_libxml_initialize(void);
  98. PHP_LIBXML_API void php_libxml_shutdown(void);
  99. #define LIBXML(v) ZEND_MODULE_GLOBALS_ACCESSOR(libxml, v)
  100. #if defined(ZTS) && defined(COMPILE_DL_LIBXML)
  101. ZEND_TSRMLS_CACHE_EXTERN()
  102. #endif
  103. #else /* HAVE_LIBXML */
  104. #define libxml_module_ptr NULL
  105. #endif
  106. #define phpext_libxml_ptr libxml_module_ptr
  107. #endif /* PHP_LIBXML_H */
  108. /*
  109. * Local variables:
  110. * tab-width: 4
  111. * c-basic-offset: 4
  112. * End:
  113. */