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