summaryrefslogtreecommitdiff
path: root/ext/dom/php_dom.c
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:34:59 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:34:59 -0400
commitce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61 (patch)
treeacdb9a8816483652a9db1a47db71df5df43707c5 /ext/dom/php_dom.c
parent10f5b47dc7c1cf2b9a00991629f43652710322d3 (diff)
downloadphp-ce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61.tar.gz
Imported Upstream version 5.1.1upstream/5.1.1
Diffstat (limited to 'ext/dom/php_dom.c')
-rw-r--r--ext/dom/php_dom.c74
1 files changed, 58 insertions, 16 deletions
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index 95a7f7602..fec631871 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_dom.c,v 1.60.2.8 2005/06/22 19:58:33 rrichards Exp $ */
+/* $Id: php_dom.c,v 1.73.2.6 2005/11/23 03:12:45 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -161,6 +161,7 @@ dom_doc_propsptr dom_get_doc_props(php_libxml_ref_obj *document)
doc_props->preservewhitespace = 1;
doc_props->substituteentities = 0;
doc_props->stricterror = 1;
+ doc_props->recover = 0;
if (document) {
document->doc_props = doc_props;
}
@@ -294,6 +295,7 @@ zval *dom_read_property(zval *object, zval *member, int type TSRMLS_DC)
if (ret == SUCCESS) {
/* ensure we're creating a temporary variable */
retval->refcount = 0;
+ retval->is_ref = 0;
} else {
retval = EG(uninitialized_zval_ptr);
}
@@ -344,6 +346,41 @@ void dom_write_property(zval *object, zval *member, zval *value TSRMLS_DC)
}
/* }}} */
+/* {{{ dom_property_exists */
+static int dom_property_exists(zval *object, zval *member, int check_empty TSRMLS_DC)
+{
+ dom_object *obj;
+ zval tmp_member;
+ dom_prop_handler *hnd;
+ zend_object_handlers *std_hnd;
+ int ret, retval=0;
+
+ if (member->type != IS_STRING) {
+ tmp_member = *member;
+ zval_copy_ctor(&tmp_member);
+ convert_to_string(&tmp_member);
+ member = &tmp_member;
+ }
+
+ ret = FAILURE;
+ obj = (dom_object *)zend_objects_get_address(object TSRMLS_CC);
+
+ if (obj->prop_handler != NULL) {
+ ret = zend_hash_find((HashTable *)obj->prop_handler, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &hnd);
+ }
+ if (ret == SUCCESS) {
+ retval = 1;
+ } else {
+ std_hnd = zend_get_std_object_handlers();
+ retval = std_hnd->has_property(object, member, check_empty TSRMLS_CC);
+ }
+
+ if (member == &tmp_member) {
+ zval_dtor(member);
+ }
+ return retval;
+}
+/* }}} */
void *php_dom_export_node(zval *object TSRMLS_DC)
{
@@ -362,7 +399,6 @@ void *php_dom_export_node(zval *object TSRMLS_DC)
Get a simplexml_element object from dom to allow for processing */
PHP_FUNCTION(dom_import_simplexml)
{
-#ifdef HAVE_SIMPLEXML
zval *rv = NULL;
zval *node;
xmlNodePtr nodep = NULL;
@@ -379,13 +415,9 @@ PHP_FUNCTION(dom_import_simplexml)
if (nodep && nodeobj && (nodep->type == XML_ELEMENT_NODE || nodep->type == XML_ATTRIBUTE_NODE)) {
DOM_RET_OBJ(rv, (xmlNodePtr) nodep, &ret, (dom_object *)nodeobj);
} else {
- php_error(E_WARNING, "Invalid Nodetype to import");
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Nodetype to import");
RETURN_NULL();
}
-#else
- php_error(E_WARNING, "SimpleXML support is not enabled");
- return;
-#endif
}
/* }}} */
@@ -437,8 +469,15 @@ static zend_object_handlers* dom_get_obj_handlers(TSRMLS_D) {
}
}
+static zend_module_dep dom_deps[] = {
+ ZEND_MOD_REQUIRED("libxml")
+ ZEND_MOD_CONFLICTS("domxml")
+ {NULL, NULL, NULL}
+};
+
zend_module_entry dom_module_entry = {
- STANDARD_MODULE_HEADER,
+ STANDARD_MODULE_HEADER_EX, NULL,
+ dom_deps,
"dom",
dom_functions,
PHP_MINIT(dom),
@@ -464,12 +503,14 @@ PHP_MINIT_FUNCTION(dom)
dom_object_handlers.write_property = dom_write_property;
dom_object_handlers.get_property_ptr_ptr = dom_get_property_ptr_ptr;
dom_object_handlers.clone_obj = dom_objects_store_clone_obj;
+ dom_object_handlers.has_property = dom_property_exists;
memcpy(&dom_ze1_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
dom_ze1_object_handlers.read_property = dom_read_property;
dom_ze1_object_handlers.write_property = dom_write_property;
dom_object_handlers.get_property_ptr_ptr = dom_get_property_ptr_ptr;
dom_ze1_object_handlers.clone_obj = dom_objects_ze1_clone_obj;
+ dom_ze1_object_handlers.has_property = dom_property_exists;
zend_hash_init(&classes, 0, NULL, NULL, 1);
@@ -541,12 +582,13 @@ PHP_MINIT_FUNCTION(dom)
dom_register_prop_handler(&dom_document_prop_handlers, "doctype", dom_document_doctype_read, NULL TSRMLS_CC);
dom_register_prop_handler(&dom_document_prop_handlers, "implementation", dom_document_implementation_read, NULL TSRMLS_CC);
dom_register_prop_handler(&dom_document_prop_handlers, "documentElement", dom_document_document_element_read, NULL TSRMLS_CC);
-/* actualEncoding currently set as read only alias to encoding
- dom_register_prop_handler(&dom_document_prop_handlers, "actualEncoding", dom_document_actual_encoding_read, dom_document_actual_encoding_write TSRMLS_CC); */
dom_register_prop_handler(&dom_document_prop_handlers, "actualEncoding", dom_document_encoding_read, NULL TSRMLS_CC);
dom_register_prop_handler(&dom_document_prop_handlers, "encoding", dom_document_encoding_read, dom_document_encoding_write TSRMLS_CC);
+ dom_register_prop_handler(&dom_document_prop_handlers, "xmlEncoding", dom_document_encoding_read, NULL TSRMLS_CC);
dom_register_prop_handler(&dom_document_prop_handlers, "standalone", dom_document_standalone_read, dom_document_standalone_write TSRMLS_CC);
+ dom_register_prop_handler(&dom_document_prop_handlers, "xmlStandalone", dom_document_standalone_read, dom_document_standalone_write TSRMLS_CC);
dom_register_prop_handler(&dom_document_prop_handlers, "version", dom_document_version_read, dom_document_version_write TSRMLS_CC);
+ dom_register_prop_handler(&dom_document_prop_handlers, "xmlVersion", dom_document_version_read, dom_document_version_write TSRMLS_CC);
dom_register_prop_handler(&dom_document_prop_handlers, "strictErrorChecking", dom_document_strict_error_checking_read, dom_document_strict_error_checking_write TSRMLS_CC);
dom_register_prop_handler(&dom_document_prop_handlers, "documentURI", dom_document_document_uri_read, dom_document_document_uri_write TSRMLS_CC);
dom_register_prop_handler(&dom_document_prop_handlers, "config", dom_document_config_read, NULL TSRMLS_CC);
@@ -554,6 +596,7 @@ PHP_MINIT_FUNCTION(dom)
dom_register_prop_handler(&dom_document_prop_handlers, "validateOnParse", dom_document_validate_on_parse_read, dom_document_validate_on_parse_write TSRMLS_CC);
dom_register_prop_handler(&dom_document_prop_handlers, "resolveExternals", dom_document_resolve_externals_read, dom_document_resolve_externals_write TSRMLS_CC);
dom_register_prop_handler(&dom_document_prop_handlers, "preserveWhiteSpace", dom_document_preserve_whitespace_read, dom_document_preserve_whitespace_write TSRMLS_CC);
+ dom_register_prop_handler(&dom_document_prop_handlers, "recover", dom_document_recover_read, dom_document_recover_write TSRMLS_CC);
dom_register_prop_handler(&dom_document_prop_handlers, "substituteEntities", dom_document_substitue_entities_read, dom_document_substitue_entities_write TSRMLS_CC);
zend_hash_merge(&dom_document_prop_handlers, &dom_node_prop_handlers, NULL, NULL, sizeof(dom_prop_handler), 0);
@@ -928,8 +971,7 @@ static dom_object* dom_objects_set_class(zend_class_entry *class_type, zend_bool
intern = emalloc(sizeof(dom_object));
intern->std.ce = class_type;
- intern->std.in_get = 0;
- intern->std.in_set = 0;
+ intern->std.guards = NULL;
intern->ptr = NULL;
intern->prop_handler = NULL;
intern->document = NULL;
@@ -988,7 +1030,7 @@ zend_object_value dom_objects_new(zend_class_entry *class_type TSRMLS_DC)
intern = dom_objects_set_class(class_type, 1 TSRMLS_CC);
- retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t)dom_objects_free_storage, dom_objects_clone TSRMLS_CC);
+ retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)dom_objects_free_storage, dom_objects_clone TSRMLS_CC);
intern->handle = retval.handle;
retval.handlers = dom_get_obj_handlers(TSRMLS_C);
@@ -1005,7 +1047,7 @@ zend_object_value dom_xpath_objects_new(zend_class_entry *class_type TSRMLS_DC)
intern = dom_objects_set_class(class_type, 1 TSRMLS_CC);
- retval.handle = zend_objects_store_put(intern, NULL, (zend_objects_free_object_storage_t)dom_xpath_objects_free_storage, dom_objects_clone TSRMLS_CC);
+ retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)dom_xpath_objects_free_storage, dom_objects_clone TSRMLS_CC);
intern->handle = retval.handle;
retval.handlers = dom_get_obj_handlers(TSRMLS_C);
@@ -1186,7 +1228,7 @@ zval *php_dom_create_object(xmlNodePtr obj, int *found, zval *wrapper_in, zval *
break;
}
default:
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported node type: %d\n", Z_TYPE_P(obj));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported node type: %d", Z_TYPE_P(obj));
ZVAL_NULL(wrapper);
return wrapper;
}