php_dom.h 6.1 KB

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