php_libxml.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 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. /* $Id$ */
  20. #ifndef PHP_LIBXML_H
  21. #define PHP_LIBXML_H
  22. #if HAVE_LIBXML
  23. extern zend_module_entry libxml_module_entry;
  24. #define libxml_module_ptr &libxml_module_entry
  25. #ifdef PHP_WIN32
  26. # define PHP_LIBXML_API __declspec(dllexport)
  27. #elif defined(__GNUC__) && __GNUC__ >= 4
  28. # define PHP_LIBXML_API __attribute__ ((visibility("default")))
  29. #else
  30. # define PHP_LIBXML_API
  31. #endif
  32. #include "ext/standard/php_smart_str.h"
  33. #include <libxml/tree.h>
  34. #define LIBXML_SAVE_NOEMPTYTAG 1<<2
  35. ZEND_BEGIN_MODULE_GLOBALS(libxml)
  36. zval *stream_context;
  37. smart_str error_buffer;
  38. zend_llist *error_list;
  39. struct _php_libxml_entity_resolver {
  40. zend_fcall_info fci;
  41. zend_fcall_info_cache fcc;
  42. } entity_loader;
  43. zend_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. zend_object std;
  67. php_libxml_node_ptr *node;
  68. php_libxml_ref_obj *document;
  69. HashTable *properties;
  70. } php_libxml_node_object;
  71. typedef void * (*php_libxml_export_node) (zval *object TSRMLS_DC);
  72. PHP_LIBXML_API int php_libxml_increment_node_ptr(php_libxml_node_object *object, xmlNodePtr node, void *private_data TSRMLS_DC);
  73. PHP_LIBXML_API int php_libxml_decrement_node_ptr(php_libxml_node_object *object TSRMLS_DC);
  74. PHP_LIBXML_API int php_libxml_increment_doc_ref(php_libxml_node_object *object, xmlDocPtr docp TSRMLS_DC);
  75. PHP_LIBXML_API int php_libxml_decrement_doc_ref(php_libxml_node_object *object TSRMLS_DC);
  76. PHP_LIBXML_API xmlNodePtr php_libxml_import_node(zval *object TSRMLS_DC);
  77. PHP_LIBXML_API int php_libxml_register_export(zend_class_entry *ce, php_libxml_export_node export_function);
  78. /* When an explicit freeing of node and children is required */
  79. PHP_LIBXML_API void php_libxml_node_free_resource(xmlNodePtr node TSRMLS_DC);
  80. /* When object dtor is called as node may still be referenced */
  81. PHP_LIBXML_API void php_libxml_node_decrement_resource(php_libxml_node_object *object TSRMLS_DC);
  82. PHP_LIBXML_API void php_libxml_error_handler(void *ctx, const char *msg, ...);
  83. PHP_LIBXML_API void php_libxml_ctx_warning(void *ctx, const char *msg, ...);
  84. PHP_LIBXML_API void php_libxml_ctx_error(void *ctx, const char *msg, ...);
  85. PHP_LIBXML_API int php_libxml_xmlCheckUTF8(const unsigned char *s);
  86. PHP_LIBXML_API zval *php_libxml_switch_context(zval *context TSRMLS_DC);
  87. PHP_LIBXML_API void php_libxml_issue_error(int level, const char *msg TSRMLS_DC);
  88. PHP_LIBXML_API zend_bool php_libxml_disable_entity_loader(zend_bool disable TSRMLS_DC);
  89. /* Init/shutdown functions*/
  90. PHP_LIBXML_API void php_libxml_initialize(void);
  91. PHP_LIBXML_API void php_libxml_shutdown(void);
  92. #ifdef ZTS
  93. #define LIBXML(v) TSRMG(libxml_globals_id, zend_libxml_globals *, v)
  94. #else
  95. #define LIBXML(v) (libxml_globals.v)
  96. #endif
  97. #else /* HAVE_LIBXML */
  98. #define libxml_module_ptr NULL
  99. #endif
  100. #define phpext_libxml_ptr libxml_module_ptr
  101. #endif /* PHP_LIBXML_H */
  102. /*
  103. * Local variables:
  104. * tab-width: 4
  105. * c-basic-offset: 4
  106. * End:
  107. */