diff options
Diffstat (limited to 'ext/simplexml')
-rw-r--r-- | ext/simplexml/CREDITS | 2 | ||||
-rw-r--r-- | ext/simplexml/config.m4 | 21 | ||||
-rw-r--r-- | ext/simplexml/examples/book.php | 8 | ||||
-rw-r--r-- | ext/simplexml/examples/book.xml | 10 | ||||
-rw-r--r-- | ext/simplexml/examples/security.php | 6 | ||||
-rw-r--r-- | ext/simplexml/examples/security.xml | 4 | ||||
-rw-r--r-- | ext/simplexml/php_simplexml.h | 86 | ||||
-rw-r--r-- | ext/simplexml/simplexml.c | 1073 | ||||
-rw-r--r-- | ext/simplexml/simplexml.dsp | 110 | ||||
-rw-r--r-- | ext/simplexml/tests/001.phpt | 24 | ||||
-rw-r--r-- | ext/simplexml/tests/bug24392.phpt | 25 | ||||
-rw-r--r-- | ext/simplexml/tests/bug24392.xml | 76 |
12 files changed, 0 insertions, 1445 deletions
diff --git a/ext/simplexml/CREDITS b/ext/simplexml/CREDITS deleted file mode 100644 index 824f4f0a59..0000000000 --- a/ext/simplexml/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -simplexml -Sterling Hughes diff --git a/ext/simplexml/config.m4 b/ext/simplexml/config.m4 deleted file mode 100644 index c12ab76350..0000000000 --- a/ext/simplexml/config.m4 +++ /dev/null @@ -1,21 +0,0 @@ -dnl $Id$ -dnl config.m4 for extension simplexml - -PHP_ARG_ENABLE(simplexml, whether to enable simplexml support, -[ --disable-simplexml Disable simplexml support], yes) - -if test -z "$PHP_LIBXML_DIR"; then - PHP_ARG_WITH(libxml-dir, libxml2 install dir, - [ --with-libxml-dir=DIR SimpleXML: libxml2 install prefix], no, no) -fi - -if test "$PHP_SIMPLEXML" != "no"; then - - PHP_SETUP_LIBXML(SIMPLEXML_SHARED_LIBADD, [ - AC_DEFINE(HAVE_SIMPLEXML,1,[ ]) - PHP_NEW_EXTENSION(simplexml, simplexml.c, $ext_shared) - PHP_SUBST(SIMPLEXML_SHARED_LIBADD) - ], [ - AC_MSG_ERROR([xml2-config not found. Please check your libxml2 installation.]) - ]) -fi diff --git a/ext/simplexml/examples/book.php b/ext/simplexml/examples/book.php deleted file mode 100644 index 0416df861b..0000000000 --- a/ext/simplexml/examples/book.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php -$books = simplexml_load_file('book.xml'); -//var_dump($books); -$books = $books->book; -foreach ($books as $book) { - echo "{$book->title} was written by {$book->author}\n"; -} -?> diff --git a/ext/simplexml/examples/book.xml b/ext/simplexml/examples/book.xml deleted file mode 100644 index ea40508e01..0000000000 --- a/ext/simplexml/examples/book.xml +++ /dev/null @@ -1,10 +0,0 @@ -<books> - <book> - <title>The Grapes of Wrath</title> - <author>John Steinbeck</author> - </book> - <book> - <title>The Pearl</title> - <author>John Steinbeck</author> - </book> -</books> diff --git a/ext/simplexml/examples/security.php b/ext/simplexml/examples/security.php deleted file mode 100644 index cbca9be79f..0000000000 --- a/ext/simplexml/examples/security.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php -$s = simplexml_load_file('security.xml'); -echo $s->id; -$s->id = 20; -simplexml_save_document_file('security.new.xml', $s); -?> diff --git a/ext/simplexml/examples/security.xml b/ext/simplexml/examples/security.xml deleted file mode 100644 index d954a02335..0000000000 --- a/ext/simplexml/examples/security.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0"?> -<security> - <id>15</id> -</security> diff --git a/ext/simplexml/php_simplexml.h b/ext/simplexml/php_simplexml.h deleted file mode 100644 index ec5ac2671c..0000000000 --- a/ext/simplexml/php_simplexml.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sterling Hughes <sterling@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifndef PHP_SIMPLEXML_H -#define PHP_SIMPLEXML_H - -extern zend_module_entry simplexml_module_entry; -#define phpext_simplexml_ptr &simplexml_module_entry - -#ifdef PHP_WIN32 -#define PHP_SIMPLEXML_API __declspec(dllexport) -#else -#define PHP_SIMPLEXML_API -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -#include <libxml/parser.h> -#include <libxml/parserInternals.h> -#include <libxml/tree.h> -#include <libxml/uri.h> -#include <libxml/xmlerror.h> -#include <libxml/xinclude.h> -#include <libxml/xpath.h> -#include <libxml/xpathInternals.h> -#include <libxml/xpointer.h> -#include <libxml/xmlschemas.h> - -PHP_MINIT_FUNCTION(simplexml); -PHP_MSHUTDOWN_FUNCTION(simplexml); -PHP_RINIT_FUNCTION(simplexml); -PHP_RSHUTDOWN_FUNCTION(simplexml); -PHP_MINFO_FUNCTION(simplexml); - -typedef struct { - void *ptr; - int refcount; -} simplexml_ref_obj; - -typedef struct { - zend_object zo; - xmlNodePtr node; - simplexml_ref_obj *document; - xmlHashTablePtr nsmap; - xmlXPathContextPtr xpath; -} php_sxe_object; - - - -#ifdef ZTS -#define SIMPLEXML_G(v) TSRMG(simplexml_globals_id, zend_simplexml_globals *, v) -#else -#define SIMPLEXML_G(v) (simplexml_globals.v) -#endif - -#endif - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * indent-tabs-mode: t - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c deleted file mode 100644 index 5e94cbec62..0000000000 --- a/ext/simplexml/simplexml.c +++ /dev/null @@ -1,1073 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: Sterling Hughes <sterling@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_simplexml.h" -#include "zend_execute_locks.h" - -zend_class_entry *sxe_class_entry; - -#define SKIP_TEXT(__p) \ - if ((__p)->type == XML_TEXT_NODE) { \ - goto next_iter; \ - } - -static php_sxe_object *php_sxe_object_new(TSRMLS_D); -static zend_object_value php_sxe_register_object(php_sxe_object * TSRMLS_DC); - -/* {{{ php_sxe_fetch_object() - */ -static inline php_sxe_object * -php_sxe_fetch_object(zval *object TSRMLS_DC) -{ - return (php_sxe_object *) zend_object_store_get_object(object TSRMLS_CC); -} -/* }}} */ - -/* {{{ _node_as_zval() - */ -static void -_node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value TSRMLS_DC) -{ - php_sxe_object *subnode; - - subnode = php_sxe_object_new(TSRMLS_C); - subnode->document = sxe->document; - subnode->document->refcount++; - subnode->nsmap = sxe->nsmap; - subnode->node = node; - - value->type = IS_OBJECT; - value->value.obj = php_sxe_register_object(subnode TSRMLS_CC); -} -/* }}} */ - -#define APPEND_PREV_ELEMENT(__c, __v) \ - if ((__c) == 1) { \ - array_init(return_value); \ - add_next_index_zval(return_value, __v); \ - } - -#define APPEND_CUR_ELEMENT(__c, __v) \ - if (++(__c) > 1) { \ - add_next_index_zval(return_value, __v); \ - } - -#define GET_NODE(__s, __n) (__n) = (__s)->node ? (__s)->node : xmlDocGetRootElement((xmlDocPtr) (__s)->document->ptr) - - -/* {{{ match_ns() - */ -static inline int -match_ns(php_sxe_object *sxe, xmlNodePtr node, xmlChar *name) -{ - xmlChar *prefix; - - prefix = xmlHashLookup(sxe->nsmap, node->ns->href); - if (prefix == NULL) { - prefix = (xmlChar*)node->ns->prefix; - } - - if (prefix == NULL) { - return 0; - } - - if (!xmlStrcmp(prefix, name)) { - return 1; - } - - return 0; -} -/* }}} */ - -/* {{{ sxe_property_read() - */ -static zval * -sxe_property_read(zval *object, zval *member, zend_bool silent TSRMLS_DC) -{ - zval *return_value; - zval *value = NULL; - php_sxe_object *sxe; - char *name; - char *contents; - xmlNodePtr node; - xmlAttrPtr attr; - int counter = 0; - - MAKE_STD_ZVAL(return_value); - ZVAL_NULL(return_value); - - name = Z_STRVAL_P(member); - - sxe = php_sxe_fetch_object(object TSRMLS_CC); - - GET_NODE(sxe, node); - - attr = node->properties; - while (attr) { - if (!xmlStrcmp(attr->name, name)) { - APPEND_PREV_ELEMENT(counter, value); - - MAKE_STD_ZVAL(value); - contents = xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, attr->children, 1); - ZVAL_STRING(value, contents, 0); - APPEND_CUR_ELEMENT(counter, value); - } - attr = attr->next; - } - - if (!sxe->node) { - sxe->node = node; - } - node = node->children; - - while (node) { - SKIP_TEXT(node); - - do if (node->ns) { - if (node->parent->ns) { - if (!xmlStrcmp(node->ns->href, node->parent->ns->href)) { - break; - } - } - - if (match_ns(sxe, node, name)) { - MAKE_STD_ZVAL(value); - _node_as_zval(sxe, node->parent, value TSRMLS_CC); - APPEND_CUR_ELEMENT(counter, value); - goto next_iter; - } - } while (0); - - if (!xmlStrcmp(node->name, name)) { - APPEND_PREV_ELEMENT(counter, value); - MAKE_STD_ZVAL(value); - _node_as_zval(sxe, node, value TSRMLS_CC); - APPEND_CUR_ELEMENT(counter, value); - } - -next_iter: - node = node->next; - } - - /* Only one value found */ - if (counter == 1) { - SEPARATE_ZVAL(&value); - zval_dtor(return_value); - FREE_ZVAL(return_value); - return_value = value; - } else { - PZVAL_UNLOCK(return_value); - } - - return return_value; -} -/* }}} */ - -/* {{{ change_node_zval() - */ -static void -change_node_zval(xmlNodePtr node, zval *value) -{ - switch (Z_TYPE_P(value)) { - case IS_LONG: - case IS_BOOL: - case IS_DOUBLE: - case IS_NULL: - convert_to_string(value); - case IS_STRING: - xmlNodeSetContentLen(node, Z_STRVAL_P(value), Z_STRLEN_P(value)); - break; - default: - php_error(E_WARNING, "It is not yet possible to assign complex types to attributes"); - break; - } -} -/* }}} */ - -/* {{{ sxe_property_write() - */ -static void -sxe_property_write(zval *object, zval *member, zval *value TSRMLS_DC) -{ - php_sxe_object *sxe; - char *name; - xmlNodePtr node; - xmlNodePtr newnode = NULL; - xmlAttrPtr attr; - int counter = 0; - int is_attr = 0; - - name = Z_STRVAL_P(member); - sxe = php_sxe_fetch_object(object TSRMLS_CC); - - GET_NODE(sxe, node); - - attr = node->properties; - while (attr) { - if (!xmlStrcmp(attr->name, name)) { - is_attr = 1; - ++counter; - break; - } - - attr = attr->next; - } - - node = node->children; - while (node) { - SKIP_TEXT(node); - if (!xmlStrcmp(node->name, name)) { - newnode = node; - ++counter; - } - -next_iter: - node = node->next; - } - - if (counter == 1) { - if (is_attr) { - change_node_zval(attr->children, value); - } else { - change_node_zval(newnode->children, value); - } - } else if (counter > 1) { - php_error(E_WARNING, "Cannot assign to an array of nodes (duplicate subnodes or attr detected)\n"); - } - -} -/* }}} */ - -/* {{{ sxe_property_get_ptr() - */ -static zval ** -sxe_property_get_ptr(zval *object, zval *member TSRMLS_DC) -{ - zval **property_ptr; - zval *property; - - property_ptr = emalloc(sizeof(zval **)); - - property = sxe_property_read(object, member, 0 TSRMLS_CC); - - *property_ptr = property; - - return property_ptr; -} -/* }}} */ - -/* {{{ sxe_property_exists() - */ -static int -sxe_property_exists(zval *object, zval *member, int check_empty TSRMLS_DC) -{ - php_sxe_object *sxe; - char *name; - xmlNodePtr node; - xmlAttrPtr attr; - - sxe = php_sxe_fetch_object(object TSRMLS_CC); - name = Z_STRVAL_P(member); - - GET_NODE(sxe, node); - - attr = node->properties; - while (attr) { - if (!xmlStrcmp(attr->name, name)) { - return 1; - } - - attr = attr->next; - } - - node = node->children; - while (node) { - SKIP_TEXT(node); - - if (!xmlStrcmp(node->name, name)) { - return 1; - } - -next_iter: - node = node->next; - } - - return 0; -} -/* }}} */ - -/* {{{ sxe_property_delete() - */ -static void -sxe_property_delete(zval *object, zval *member TSRMLS_DC) -{ - php_sxe_object *sxe; - xmlNodePtr node; - xmlNodePtr nnext; - xmlAttrPtr attr; - xmlAttrPtr anext; - - sxe = php_sxe_fetch_object(object TSRMLS_CC); - - GET_NODE(sxe, node); - - attr = node->properties; - while (attr) { - anext = attr->next; - if (!xmlStrcmp(attr->name, Z_STRVAL_P(member))) { - xmlUnlinkNode((xmlNodePtr) attr); - xmlFreeProp(attr); - } - attr = anext; - } - - node = node->children; - while (node) { - nnext = node->next; - - SKIP_TEXT(node); - - if (!xmlStrcmp(node->name, Z_STRVAL_P(member))) { - xmlUnlinkNode(node); - xmlFreeNode(node); - } - -next_iter: - node = nnext; - } -} -/* }}} */ - -/* {{{ _get_base_node_value() - */ -static void -_get_base_node_value(xmlNodePtr node, zval **value TSRMLS_DC) -{ - php_sxe_object *subnode; - char *contents; - - MAKE_STD_ZVAL(*value); - - if (node->children && node->children->type == XML_TEXT_NODE && !xmlIsBlankNode(node->children)) { - contents = xmlNodeListGetString(node->doc, node->children, 1); - if (contents) { - ZVAL_STRING(*value, contents, 0); - } - } else { - subnode = php_sxe_object_new(TSRMLS_C); - subnode->document = emalloc(sizeof(simplexml_ref_obj)); - subnode->document->refcount = 1; - subnode->document->ptr = node->doc; - subnode->node = node; - - (*value)->type = IS_OBJECT; - (*value)->value.obj = php_sxe_register_object(subnode TSRMLS_CC); - zval_add_ref(value); - } -} -/* }}} */ - -/* {{{ sxe_properties_get() - */ -static HashTable * -sxe_properties_get(zval *object TSRMLS_DC) -{ - zval **data_ptr; - zval *value; - zval *newptr; - HashTable *rv; - php_sxe_object *sxe; - char *name; - xmlNodePtr node; - ulong h; - int namelen; - - ALLOC_HASHTABLE(rv); - zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0); - - sxe = php_sxe_fetch_object(object TSRMLS_CC); - - GET_NODE(sxe, node); - node = node->children; - - while (node) { - SKIP_TEXT(node); - - _get_base_node_value(node, &value TSRMLS_CC); - - name = (char *) node->name; - namelen = xmlStrlen(node->name) + 1; - - h = zend_hash_func(name, namelen); - if (zend_hash_quick_find(rv, name, namelen, h, (void **) &data_ptr) == SUCCESS) { - if (Z_TYPE_PP(data_ptr) == IS_ARRAY) { - zend_hash_next_index_insert(Z_ARRVAL_PP(data_ptr), &value, sizeof(zval *), NULL); - } else { - MAKE_STD_ZVAL(newptr); - array_init(newptr); - - zend_hash_next_index_insert(Z_ARRVAL_P(newptr), data_ptr, sizeof(zval *), NULL); - zend_hash_next_index_insert(Z_ARRVAL_P(newptr), &value, sizeof(zval *), NULL); - - zend_hash_quick_update(rv, name, namelen, h, &newptr, sizeof(zval *), NULL); - } - } else { - zend_hash_quick_update(rv, name, namelen, h, &value, sizeof(zval *), NULL); - } - -next_iter: - node = node->next; - } - - return rv; -} -/* }}} */ - -/* {{{ sxe_objects_compare() - */ -static int -sxe_objects_compare(zval *object1, zval *object2 TSRMLS_DC) -{ - php_sxe_object *sxe1; - php_sxe_object *sxe2; - - sxe1 = php_sxe_fetch_object(object1 TSRMLS_CC); - sxe2 = php_sxe_fetch_object(object2 TSRMLS_CC); - - if (sxe1->node == NULL) { - if (sxe2->node) { - return 1; - } else if (sxe1->document->ptr == sxe2->document->ptr) { - return 0; - } - } else { - return !(sxe1->node == sxe2->node); - } - return 1; -} -/* }}} */ - -/* {{{ sxe_constructor_get() - */ -static union _zend_function * -sxe_constructor_get(zval *object TSRMLS_DC) -{ - return NULL; -} -/* }}} */ - -/* {{{ sxe_method_get() - */ -static union _zend_function * -sxe_method_get(zval *object, char *name, int len TSRMLS_DC) -{ - zend_internal_function *f; - - f = emalloc(sizeof(zend_internal_function)); - f->type = ZEND_OVERLOADED_FUNCTION; - f->arg_info = NULL; - f->num_args = 0; - f->scope = sxe_class_entry; - f->fn_flags = 0; - f->function_name = estrndup(name, len); - - return (union _zend_function *) f; -} -/* }}} */ - -/* {{{ simplexml_ce_xpath_search() - */ -static void -simplexml_ce_xpath_search(INTERNAL_FUNCTION_PARAMETERS) -{ - php_sxe_object *sxe; - zval *value; - char *query; - int query_len; - int i; - xmlNodeSetPtr result; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &query, &query_len) == FAILURE) { - return; - } - - sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); - if (!sxe->xpath) { - sxe->xpath = xmlXPathNewContext((xmlDocPtr) sxe->document->ptr); - } - if (!sxe->node) { - sxe->node = xmlDocGetRootElement((xmlDocPtr) sxe->document->ptr); - } - sxe->xpath->node = sxe->node; - - result = xmlXPathEval(query, sxe->xpath)->nodesetval; - if (!result) { - RETURN_FALSE; - } - - array_init(return_value); - - for (i = 0; i < result->nodeNr; ++i) { - MAKE_STD_ZVAL(value); - /** - * Detect the case where the last selector is text(), simplexml - * always accesses the text() child by default, therefore we assign - * to the parent node. - */ - if (result->nodeTab[i]->type == XML_TEXT_NODE) { - _node_as_zval(sxe, result->nodeTab[i]->parent, value TSRMLS_CC); - } else { - _node_as_zval(sxe, result->nodeTab[i], value TSRMLS_CC); - } - add_next_index_zval(return_value, value); - } - -} -/* }}} */ - -#define SCHEMA_FILE 0 -#define SCHEMA_BLOB 1 -#define SCHEMA_OBJECT 2 - -#ifdef xmlSchemaParserCtxtPtr - -/* {{{ simplexml_ce_schema_validate_file() - */ -static void -simplexml_ce_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type) -{ - php_sxe_object *sxe; - zval *source; - xmlSchemaParserCtxtPtr parser; - xmlSchemaPtr sptr; - xmlSchemaValidCtxtPtr vptr; - int is_valid; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &source) == FAILURE) { - return; - } - - sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); - - switch (type) { - case SCHEMA_FILE: - convert_to_string_ex(&source); - parser = xmlSchemaNewParserCtxt(Z_STRVAL_P(source)); - sptr = xmlSchemaParse(parser); - xmlSchemaFreeParserCtxt(parser); - break; - case SCHEMA_BLOB: - convert_to_string_ex(&source); - parser = xmlSchemaNewMemParserCtxt(Z_STRVAL_P(source), Z_STRLEN_P(source)); - sptr = xmlSchemaParse(parser); - xmlSchemaFreeParserCtxt(parser); - break; - } - - vptr = xmlSchemaNewValidCtxt(sptr); - is_valid = xmlSchemaValidateDoc(vptr, (xmlDocPtr) sxe->document->ptr); - xmlSchemaFree(sptr); - xmlSchemaFreeValidCtxt(vptr); - xmlSchemaFreeParserCtxt(parser); - - if (is_valid) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} */ - -#endif - -/* {{{ simplexml_ce_register_ns() - */ -static void -simplexml_ce_register_ns(INTERNAL_FUNCTION_PARAMETERS) -{ - php_sxe_object *sxe; - char *nsname; - char *nsvalue; - int nsname_len; - int nsvalue_len; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &nsname, &nsname_len, &nsvalue, &nsvalue_len) == FAILURE) { - return; - } - - sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); - - xmlHashAddEntry(sxe->nsmap, nsvalue, nsname); -} -/* }}} */ - -/* {{{ simplexml_ce_to_xml_string() - */ -static void -simplexml_ce_to_xml_string(INTERNAL_FUNCTION_PARAMETERS) -{ - php_sxe_object *sxe; - - if (ZEND_NUM_ARGS() != 0) { - RETURN_FALSE; - } - - sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); - xmlDocDumpMemory((xmlDocPtr) sxe->document->ptr, (xmlChar **) &Z_STRVAL_P(return_value), &Z_STRLEN_P(return_value)); - Z_TYPE_P(return_value) = IS_STRING; - zval_add_ref(&return_value); -} -/* }}} */ - -/* {{{ simplexml_ce_to_xml_file() - */ -static void -simplexml_ce_to_xml_file(INTERNAL_FUNCTION_PARAMETERS) -{ - php_sxe_object *sxe; - char *filename; - int filename_len; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { - return; - } - - sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); - - xmlSaveFile(filename, (xmlDocPtr) sxe->document->ptr); - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ sxe_call_method() - */ -static int -sxe_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS) -{ - if (!strcmp(method, "xsearch")) { - simplexml_ce_xpath_search(INTERNAL_FUNCTION_PARAM_PASSTHRU); -#ifdef xmlSchemaParserCtxtPtr - } else if (!strcmp(method, "validate_schema_file")) { - simplexml_ce_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, SCHEMA_FILE); - } else if (!strcmp(method, "validate_schema_buffer")) { - simplexml_ce_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, SCHEMA_BLOB); -#endif - } else if (!strcmp(method, "register_ns")) { - simplexml_ce_register_ns(INTERNAL_FUNCTION_PARAM_PASSTHRU); - } else if (!strcmp(method, "to_xml")) { - simplexml_ce_to_xml_string(INTERNAL_FUNCTION_PARAM_PASSTHRU); - } else if (!strcmp(method, "to_xml_file")) { - simplexml_ce_to_xml_file(INTERNAL_FUNCTION_PARAM_PASSTHRU); - } else { - return 0; - } - - return 1; -} -/* }}} */ - -/* {{{ sxe_class_entry_get() - */ -static zend_class_entry * -sxe_class_entry_get(zval *object TSRMLS_DC) -{ - return sxe_class_entry; -} -/* }}} */ - -/* {{{ sxe_class_name_get() - */ -static int -sxe_class_name_get(zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC) -{ - *class_name = estrdup("simplexml_element"); - *class_name_len = sizeof("simplexml_element"); - - return 0; -} -/* }}} */ - -/* {{{ cast_object() - */ -static void -cast_object(zval *object, int type, char *contents TSRMLS_DC) -{ - if (contents) { - ZVAL_STRINGL(object, contents, strlen(contents), 1); - } - - switch (type) { - case IS_STRING: - convert_to_string(object); - break; - case IS_BOOL: - convert_to_boolean(object); - break; - case IS_LONG: - convert_to_long(object); - break; - case IS_DOUBLE: - convert_to_double(object); - break; - } -} -/* }}} */ - -/* {{{ sxe_object_cast() - */ -static void -sxe_object_cast(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC) -{ - php_sxe_object *sxe; - char *contents = NULL; - - sxe = php_sxe_fetch_object(readobj TSRMLS_CC); - if (should_free) { - zval_dtor(writeobj); - } - - if (!sxe->node) { - if (sxe->document) { - sxe->node = xmlDocGetRootElement((xmlDocPtr) sxe->document->ptr); - } - } - - if (sxe->node) { - if (sxe->node->children) { - contents = xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, sxe->node->children, 1); - } - } - - cast_object(writeobj, type, contents TSRMLS_CC); - - if (contents) { - xmlFree(contents); - } -} -/* }}} */ - -/* {{{ sxe_object_set() - */ -static void -sxe_object_set(zval **property, zval *value TSRMLS_DC) -{ - /* XXX: TODO - * This call is not yet implemented in the engine - * so leave it blank for now. - */ -} -/* }}} */ - -/* {{{ sxe_object_get() - */ -static zval * -sxe_object_get(zval *property TSRMLS_DC) -{ - /* XXX: TODO - * This call is not yet implemented in the engine - * so leave it blank for now. - */ - return NULL; -} -/* }}} */ - -static zend_object_handlers sxe_object_handlers = { - ZEND_OBJECTS_STORE_HANDLERS, - sxe_property_read, - sxe_property_write, - NULL, - NULL, - sxe_property_get_ptr, - sxe_property_get_ptr, - sxe_object_get, - sxe_object_set, - sxe_property_exists, - sxe_property_delete, - NULL, - sxe_properties_get, - sxe_method_get, - sxe_call_method, - sxe_constructor_get, - sxe_class_entry_get, - sxe_class_name_get, - sxe_objects_compare, - sxe_object_cast -}; - -/* {{{ sxe_object_clone() - */ -static void -sxe_object_clone(void *object, void **clone_ptr TSRMLS_DC) -{ - php_sxe_object *sxe = (php_sxe_object *) object; - php_sxe_object *clone; - - clone = php_sxe_object_new(TSRMLS_C); - - clone->document = emalloc(sizeof(simplexml_ref_obj)); - clone->document->refcount = 1; - clone->document->ptr = xmlCopyDoc((xmlDocPtr) sxe->document->ptr, 1); - - *clone_ptr = (void *) clone; -} -/* }}} */ - -/* {{{ _free_ns_entry() - */ -static void -_free_ns_entry(void *p, xmlChar *data) -{ - xmlFree(p); -} -/* }}} */ - -/* {{{ sxe_object_dtor() - */ -static void -sxe_object_dtor(void *object, zend_object_handle handle TSRMLS_DC) -{ - php_sxe_object *sxe; - - sxe = (php_sxe_object *) object; - - zend_hash_destroy(sxe->zo.properties); - FREE_HASHTABLE(sxe->zo.properties); - - if (sxe->document) { - if (--sxe->document->refcount == 0) { - if (sxe->document->ptr) { - xmlFreeDoc(sxe->document->ptr); - } - efree(sxe->document); - sxe->document = NULL; - xmlHashFree(sxe->nsmap, _free_ns_entry); - } - } - - if (sxe->xpath) { - xmlXPathFreeContext(sxe->xpath); - } - - efree(object); -} -/* }}} */ - -/* {{{ php_sxe_object_new() - */ -static php_sxe_object * -php_sxe_object_new(TSRMLS_D) -{ - php_sxe_object *intern; - - intern = ecalloc(1, sizeof(php_sxe_object)); - intern->zo.ce = sxe_class_entry; - intern->zo.in_get = 0; - intern->zo.in_set = 0; - intern->document = NULL; - intern->nsmap = NULL; - intern->xpath = NULL; - - ALLOC_HASHTABLE(intern->zo.properties); - zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0); - - return intern; -} -/* }}} */ - -/* {{{ php_sxe_register_object - */ -static zend_object_value -php_sxe_register_object(php_sxe_object *intern TSRMLS_DC) -{ - zend_object_value rv; - - rv.handle = zend_objects_store_put(intern, sxe_object_dtor, sxe_object_clone TSRMLS_CC); - rv.handlers = (zend_object_handlers *) &sxe_object_handlers; - - return rv; -} -/* }}} */ - -/* {{{ sxe_object_new() - */ -static zend_object_value -sxe_object_new(zend_class_entry *ce TSRMLS_DC) -{ - php_sxe_object *intern; - - intern = php_sxe_object_new(TSRMLS_C); - return php_sxe_register_object(intern TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto simplemxml_element simplexml_load_file(string filename) - Load a filename and return a simplexml_element object to allow for processing */ -PHP_FUNCTION(simplexml_load_file) -{ - php_sxe_object *sxe; - char *filename; - int filename_len; - xmlDocPtr docp; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { - return; - } - - docp = xmlParseFile(filename); - if (! docp) { - RETURN_FALSE; - } - - sxe = php_sxe_object_new(TSRMLS_C); - sxe->document = emalloc(sizeof(simplexml_ref_obj)); - sxe->document->ptr = docp; - sxe->document->refcount = 1; - sxe->nsmap = xmlHashCreate(10); - sxe->node = NULL; - - - return_value->type = IS_OBJECT; - return_value->value.obj = php_sxe_register_object(sxe TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto simplemxml_element simplexml_load_string(string data) - Load a string and return a simplexml_element object to allow for processing */ -PHP_FUNCTION(simplexml_load_string) -{ - php_sxe_object *sxe; - char *data; - int data_len; - xmlDocPtr docp; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data, &data_len) == FAILURE) { - return; - } - - docp = xmlParseMemory(data, data_len); - if (! docp) { - RETURN_FALSE; - } - - sxe = php_sxe_object_new(TSRMLS_C); - sxe->document = emalloc(sizeof(simplexml_ref_obj)); - sxe->document->refcount = 1; - sxe->document->ptr = docp; - sxe->nsmap = xmlHashCreate(10); - sxe->node = NULL; - - return_value->type = IS_OBJECT; - return_value->value.obj = php_sxe_register_object(sxe TSRMLS_CC); -} -/* }}} */ - -function_entry simplexml_functions[] = { - PHP_FE(simplexml_load_file, NULL) - PHP_FE(simplexml_load_string, NULL) - {NULL, NULL, NULL} -}; - -zend_module_entry simplexml_module_entry = { - STANDARD_MODULE_HEADER, - "simplexml", - simplexml_functions, - PHP_MINIT(simplexml), - PHP_MSHUTDOWN(simplexml), - PHP_RINIT(simplexml), - PHP_RSHUTDOWN(simplexml), - PHP_MINFO(simplexml), - "0.1", - STANDARD_MODULE_PROPERTIES -}; - -#ifdef COMPILE_DL_SIMPLEXML -ZEND_GET_MODULE(simplexml) -#endif - -/* {{{ PHP_MINIT_FUNCTION(simplexml) - */ -PHP_MINIT_FUNCTION(simplexml) -{ - zend_class_entry sxe; - - INIT_CLASS_ENTRY(sxe, "simplexml_element", NULL); - sxe.create_object = sxe_object_new; - sxe_class_entry = zend_register_internal_class(&sxe TSRMLS_CC); - - xmlInitParser(); - - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_MSHUTDOWN_FUNCTION(simplexml) - */ -PHP_MSHUTDOWN_FUNCTION(simplexml) -{ - xmlCleanupParser(); - - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_RINIT_FUNCTION(simplexml) - */ -PHP_RINIT_FUNCTION(simplexml) -{ - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_RSHUTDOWN_FUNCTION(simplexml) - */ -PHP_RSHUTDOWN_FUNCTION(simplexml) -{ - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_MINFO_FUNCTION(simplexml) - */ -PHP_MINFO_FUNCTION(simplexml) -{ - php_info_print_table_start(); - php_info_print_table_header(2, "Simplexml support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision$"); - php_info_print_table_end(); -} -/* }}} */ - -/** - * Local Variables: - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: t - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/simplexml/simplexml.dsp b/ext/simplexml/simplexml.dsp deleted file mode 100644 index 39a34d83c8..0000000000 --- a/ext/simplexml/simplexml.dsp +++ /dev/null @@ -1,110 +0,0 @@ -# Microsoft Developer Studio Project File - Name="simplexml" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=simplexml - Win32 Debug_TS
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "simplexml.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "simplexml.mak" CFG="simplexml - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "simplexml - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "simplexml - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "simplexml - Win32 Debug_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug_TS"
-# PROP BASE Intermediate_Dir "Debug_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "c:\php\5d\extensions"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIMPLEXML_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\php5" /I "..\..\..\php5\main" /I "..\..\..\php5\Zend" /I "..\..\..\php5\TSRM" /D ZEND_DEBUG=1 /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D COMPILE_DL_SIMPLEXML=1 /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIMPLEXML_EXPORTS" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 php4ts_debug.lib libxml2.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\php5\Debug_TS"
-
-!ELSEIF "$(CFG)" == "simplexml - Win32 Release_TS"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release_TS"
-# PROP BASE Intermediate_Dir "Release_TS"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIMPLEXML_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\php5\main" /I "..\..\..\php5\Zend" /I "..\..\..\php5\TSRM" /I "..\..\..\php5\win32" /I "..\..\..\php5" /D ZTS=1 /D ZEND_DEBUG=0 /D "ZEND_WIN32" /D "PHP_WIN32" /D COMPILE_DL_SIMPLEXML=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIMPLEXML_EXPORTS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
-# ADD LINK32 php4ts.lib libxml2.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /libpath:"..\..\..\php5\Release_TS" /libpath:"..\..\..\php5\Release_TS_Inline"
-
-!ENDIF
-
-# Begin Target
-
-# Name "simplexml - Win32 Debug_TS"
-# Name "simplexml - Win32 Release_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\simplexml.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\php_simplexml.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/ext/simplexml/tests/001.phpt b/ext/simplexml/tests/001.phpt deleted file mode 100644 index 7b53bf1cb7..0000000000 --- a/ext/simplexml/tests/001.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -Check for simplexml presence ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---POST-- ---GET-- ---INI-- ---FILE-- -<?php -echo "simplexml extension is available"; -/* - you can add regression tests for your extension here - - the output of your test code has to be equal to the - text in the --EXPECT-- section below for the tests - to pass, differences between the output and the - expected text are interpreted as failure - - see php4/README.TESTING for further information on - writing regression tests -*/ -?> ---EXPECT-- -simplexml extension is available diff --git a/ext/simplexml/tests/bug24392.phpt b/ext/simplexml/tests/bug24392.phpt deleted file mode 100644 index 7ba12542ad..0000000000 --- a/ext/simplexml/tests/bug24392.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -Bug #24392: empty namespaces causing confusion ---SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> ---POST-- ---GET-- ---INI-- ---FILE-- -<?php -$s = simplexml_load_file('ext/simplexml/tests/bug24392.xml'); -foreach ($s->item as $item) { - echo $item->title . "\n"; -} -?> ---EXPECT-- -EU Parliament to Vote on New Patent Rules -Most Powerful Amateur Rocket in Canada -GF FX 5900 Ultra vs. ATi Radeon 9800 Pro -PHP 5 Beta 1 -Engaging with the OSS Community -Pure Math, Pure Joy -Windows Tech Writer Looks at Linux -US Cell Phone Users Discover SMS Spam -Verizon Sues Nextel For Espionage -Introduction to Debian diff --git a/ext/simplexml/tests/bug24392.xml b/ext/simplexml/tests/bug24392.xml deleted file mode 100644 index d669f1df41..0000000000 --- a/ext/simplexml/tests/bug24392.xml +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0"?> - -<rdf:RDF -xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" -xmlns="http://my.netscape.com/rdf/simple/0.9/"> - -<channel> -<title>Slashdot</title> -<link>http://slashdot.org/</link> -<description>News for nerds, stuff that matters</description> -</channel> - -<image> -<title>Slashdot</title> -<url>http://images.slashdot.org/topics/topicslashdot.gif</url> -<link>http://slashdot.org/</link> -</image> - -<item> -<title>EU Parliament to Vote on New Patent Rules</title> -<link>http://slashdot.org/article.pl?sid=03/06/30/002211</link> -</item> - -<item> -<title>Most Powerful Amateur Rocket in Canada</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/2121211</link> -</item> - -<item> -<title>GF FX 5900 Ultra vs. ATi Radeon 9800 Pro</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/202218</link> -</item> - -<item> -<title>PHP 5 Beta 1</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/1957253</link> -</item> - -<item> -<title>Engaging with the OSS Community</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/1913235</link> -</item> - -<item> -<title>Pure Math, Pure Joy</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/183258</link> -</item> - -<item> -<title>Windows Tech Writer Looks at Linux</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/1554201</link> -</item> - -<item> -<title>US Cell Phone Users Discover SMS Spam</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/1542249</link> -</item> - -<item> -<title>Verizon Sues Nextel For Espionage</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/1443230</link> -</item> - -<item> -<title>Introduction to Debian</title> -<link>http://slashdot.org/article.pl?sid=03/06/29/1424213</link> -</item> - -<textinput> -<title>Search Slashdot</title> -<description>Search Slashdot stories</description> -<name>query</name> -<link>http://slashdot.org/search.pl</link> -</textinput> - -</rdf:RDF>
\ No newline at end of file |