php_libxml.h 4.5 KB

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