php_dom.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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: Christian Stocker <chregu@php.net> |
  16. | Rob Richards <rrichards@php.net> |
  17. | Marcus Borger <helly@php.net> |
  18. +----------------------------------------------------------------------+
  19. */
  20. /* $Id$ */
  21. #ifndef PHP_DOM_H
  22. #define PHP_DOM_H
  23. extern zend_module_entry dom_module_entry;
  24. #define phpext_dom_ptr &dom_module_entry
  25. #ifdef ZTS
  26. #include "TSRM.h"
  27. #endif
  28. #include <libxml/parser.h>
  29. #include <libxml/parserInternals.h>
  30. #include <libxml/tree.h>
  31. #include <libxml/uri.h>
  32. #include <libxml/xmlerror.h>
  33. #include <libxml/xinclude.h>
  34. #include <libxml/hash.h>
  35. #include <libxml/c14n.h>
  36. #if defined(LIBXML_HTML_ENABLED)
  37. #include <libxml/HTMLparser.h>
  38. #include <libxml/HTMLtree.h>
  39. #endif
  40. #if defined(LIBXML_XPATH_ENABLED)
  41. #include <libxml/xpath.h>
  42. #include <libxml/xpathInternals.h>
  43. #endif
  44. #if defined(LIBXML_XPTR_ENABLED)
  45. #include <libxml/xpointer.h>
  46. #endif
  47. #ifdef PHP_WIN32
  48. #ifndef DOM_EXPORTS
  49. #define DOM_EXPORTS
  50. #endif
  51. #endif
  52. #include "xml_common.h"
  53. #include "ext/libxml/php_libxml.h"
  54. #include "zend_exceptions.h"
  55. #include "dom_ce.h"
  56. /* DOM API_VERSION, please bump it up, if you change anything in the API
  57. therefore it's easier for the script-programmers to check, what's working how
  58. Can be checked with phpversion("dom");
  59. */
  60. #define DOM_API_VERSION "20031129"
  61. /* Define a custom type for iterating using an unused nodetype */
  62. #define DOM_NODESET XML_XINCLUDE_START
  63. typedef struct _dom_xpath_object {
  64. zend_object std;
  65. void *ptr;
  66. php_libxml_ref_obj *document;
  67. HashTable *prop_handler;
  68. zend_object_handle handle;
  69. int registerPhpFunctions;
  70. HashTable *registered_phpfunctions;
  71. HashTable *node_list;
  72. } dom_xpath_object;
  73. typedef struct _dom_nnodemap_object {
  74. dom_object *baseobj;
  75. int nodetype;
  76. xmlHashTable *ht;
  77. xmlChar *local;
  78. xmlChar *ns;
  79. zval *baseobjptr;
  80. } dom_nnodemap_object;
  81. typedef struct {
  82. zend_object_iterator intern;
  83. zval *curobj;
  84. } php_dom_iterator;
  85. #include "dom_fe.h"
  86. dom_object *dom_object_get_data(xmlNodePtr obj);
  87. dom_doc_propsptr dom_get_doc_props(php_libxml_ref_obj *document);
  88. zend_object_value dom_objects_new(zend_class_entry *class_type TSRMLS_DC);
  89. zend_object_value dom_nnodemap_objects_new(zend_class_entry *class_type TSRMLS_DC);
  90. #if defined(LIBXML_XPATH_ENABLED)
  91. zend_object_value dom_xpath_objects_new(zend_class_entry *class_type TSRMLS_DC);
  92. #endif
  93. int dom_get_strict_error(php_libxml_ref_obj *document);
  94. void php_dom_throw_error(int error_code, int strict_error TSRMLS_DC);
  95. void php_dom_throw_error_with_message(int error_code, char *error_message, int strict_error TSRMLS_DC);
  96. void node_list_unlink(xmlNodePtr node TSRMLS_DC);
  97. int dom_check_qname(char *qname, char **localname, char **prefix, int uri_len, int name_len);
  98. xmlNsPtr dom_get_ns(xmlNodePtr node, char *uri, int *errorcode, char *prefix);
  99. void dom_set_old_ns(xmlDoc *doc, xmlNs *ns);
  100. xmlNsPtr dom_get_nsdecl(xmlNode *node, xmlChar *localName);
  101. void dom_normalize (xmlNodePtr nodep TSRMLS_DC);
  102. xmlNode *dom_get_elements_by_tag_name_ns_raw(xmlNodePtr nodep, char *ns, char *local, int *cur, int index);
  103. void php_dom_create_implementation(zval **retval TSRMLS_DC);
  104. int dom_hierarchy(xmlNodePtr parent, xmlNodePtr child);
  105. int dom_has_feature(char *feature, char *version);
  106. int dom_node_is_read_only(xmlNodePtr node);
  107. int dom_node_children_valid(xmlNodePtr node);
  108. void php_dom_create_interator(zval *return_value, int ce_type TSRMLS_DC);
  109. void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xmlHashTablePtr ht, xmlChar *local, xmlChar *ns TSRMLS_DC);
  110. xmlNodePtr create_notation(const xmlChar *name, const xmlChar *ExternalID, const xmlChar *SystemID);
  111. xmlNode *php_dom_libxml_hash_iter(xmlHashTable *ht, int index);
  112. xmlNode *php_dom_libxml_notation_iter(xmlHashTable *ht, int index);
  113. zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC);
  114. int dom_set_doc_classmap(php_libxml_ref_obj *document, zend_class_entry *basece, zend_class_entry *ce TSRMLS_DC);
  115. zval *dom_nodelist_read_dimension(zval *object, zval *offset, int type TSRMLS_DC);
  116. int dom_nodelist_has_dimension(zval *object, zval *member, int check_empty TSRMLS_DC);
  117. #define REGISTER_DOM_CLASS(ce, name, parent_ce, funcs, entry) \
  118. INIT_CLASS_ENTRY(ce, name, funcs); \
  119. ce.create_object = dom_objects_new; \
  120. entry = zend_register_internal_class_ex(&ce, parent_ce, NULL TSRMLS_CC);
  121. #define DOM_GET_OBJ(__ptr, __id, __prtype, __intern) { \
  122. __intern = (dom_object *)zend_object_store_get_object(__id TSRMLS_CC); \
  123. if (__intern->ptr == NULL || !(__ptr = (__prtype)((php_libxml_node_ptr *)__intern->ptr)->node)) { \
  124. php_error_docref(NULL TSRMLS_CC, E_WARNING, "Couldn't fetch %s", __intern->std.ce->name);\
  125. RETURN_NULL();\
  126. } \
  127. }
  128. #define DOM_NO_ARGS() \
  129. if (zend_parse_parameters_none() == FAILURE) { \
  130. return; \
  131. }
  132. #define DOM_NOT_IMPLEMENTED() \
  133. php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not yet implemented"); \
  134. return;
  135. #define convert_to_copy_master(orig, copy, lower_type, upper_type) \
  136. if (Z_TYPE_P(orig) != IS_##upper_type) { \
  137. if (Z_REFCOUNT_P(orig) > 1) { \
  138. copy = *orig; \
  139. zval_copy_ctor(&copy); \
  140. orig = &copy; \
  141. } \
  142. convert_to_##lower_type(orig); \
  143. }
  144. #define convert_to_string_copy(orig, copy) convert_to_copy_master(orig, copy, string, STRING);
  145. #define convert_to_long_copy(orig, copy) convert_to_copy_master(orig, copy, long, LONG);
  146. #define convert_to_boolean_copy(orig, copy) convert_to_copy_master(orig, copy, boolean, BOOL);
  147. #define DOM_NODELIST 0
  148. #define DOM_NAMEDNODEMAP 1
  149. PHP_MINIT_FUNCTION(dom);
  150. PHP_MSHUTDOWN_FUNCTION(dom);
  151. PHP_MINFO_FUNCTION(dom);
  152. #endif /* PHP_DOM_H */
  153. /*
  154. * Local variables:
  155. * tab-width: 4
  156. * c-basic-offset: 4
  157. * End:
  158. * vim600: noet sw=4 ts=4 fdm=marker
  159. * vim<600: noet sw=4 ts=4
  160. */