diff options
119 files changed, 0 insertions, 18854 deletions
diff --git a/ext/imap/imap.h b/ext/imap/imap.h deleted file mode 100644 index 914d128316..0000000000 --- a/ext/imap/imap.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef _INCLUDED_IMAP_H -#define _INCLUDED_IMAP_H - -#if COMPILE_DL -#undef HAVE_IMAP -#define HAVE_IMAP 1 -#endif - -#if HAVE_IMAP - -#ifndef PHP_WIN32 -#include "build-defs.h" -#endif - -/* Functions accessable to PHP */ -extern zend_module_entry imap_module_entry; -#define imap_module_ptr &imap_module_entry - -extern PHP_MINIT_FUNCTION(imap); -extern PHP_RINIT_FUNCTION(imap); -extern PHP_RSHUTDOWN_FUNCTION(imap); -PHP_MINFO_FUNCTION(imap); -PHP_FUNCTION(imap_open); -PHP_FUNCTION(imap_popen); -PHP_FUNCTION(imap_reopen); -PHP_FUNCTION(imap_num_msg); -PHP_FUNCTION(imap_num_recent); -PHP_FUNCTION(imap_headers); -PHP_FUNCTION(imap_headerinfo); -PHP_FUNCTION(imap_rfc822_parse_headers); -PHP_FUNCTION(imap_body); -PHP_FUNCTION(imap_fetchstructure); -PHP_FUNCTION(imap_fetchbody); -PHP_FUNCTION(imap_expunge); -PHP_FUNCTION(imap_delete); -PHP_FUNCTION(imap_undelete); -PHP_FUNCTION(imap_check); -PHP_FUNCTION(imap_close); -PHP_FUNCTION(imap_mail_copy); -PHP_FUNCTION(imap_mail_move); -PHP_FUNCTION(imap_createmailbox); -PHP_FUNCTION(imap_renamemailbox); -PHP_FUNCTION(imap_deletemailbox); -PHP_FUNCTION(imap_listmailbox); -PHP_FUNCTION(imap_scanmailbox); -PHP_FUNCTION(imap_subscribe); -PHP_FUNCTION(imap_unsubscribe); -PHP_FUNCTION(imap_append); -PHP_FUNCTION(imap_ping); -PHP_FUNCTION(imap_base64); -PHP_FUNCTION(imap_qprint); -PHP_FUNCTION(imap_8bit); -PHP_FUNCTION(imap_binary); -PHP_FUNCTION(imap_mailboxmsginfo); -PHP_FUNCTION(imap_rfc822_write_address); -PHP_FUNCTION(imap_rfc822_parse_adrlist); -PHP_FUNCTION(imap_setflag_full); -PHP_FUNCTION(imap_clearflag_full); -PHP_FUNCTION(imap_sort); -PHP_FUNCTION(imap_fetchheader); -PHP_FUNCTION(imap_fetchtext); -PHP_FUNCTION(imap_uid); -PHP_FUNCTION(imap_msgno); -PHP_FUNCTION(imap_list); -PHP_FUNCTION(imap_list_full); -PHP_FUNCTION(imap_listscan); -PHP_FUNCTION(imap_lsub); -PHP_FUNCTION(imap_lsub_full); -PHP_FUNCTION(imap_create); -PHP_FUNCTION(imap_rename); -PHP_FUNCTION(imap_status); -PHP_FUNCTION(imap_bodystruct); -PHP_FUNCTION(imap_fetch_overview); -PHP_FUNCTION(imap_mail_compose); -PHP_FUNCTION(imap_alerts); -PHP_FUNCTION(imap_errors); -PHP_FUNCTION(imap_last_error); -PHP_FUNCTION(imap_mail); -PHP_FUNCTION(imap_search); -PHP_FUNCTION(imap_utf8); -PHP_FUNCTION(imap_utf7_decode); -PHP_FUNCTION(imap_utf7_encode); -PHP_FUNCTION(imap_mime_header_decode); -#else -#define imap_module_ptr NULL -#endif /* HAVE_IMAP */ - -#endif - - - - - - -#define phpext_imap_ptr imap_module_ptr - - - - - - - - diff --git a/ext/pcre/config0.m4 b/ext/pcre/config0.m4 deleted file mode 100644 index 02e71bd25b..0000000000 --- a/ext/pcre/config0.m4 +++ /dev/null @@ -1,56 +0,0 @@ -dnl -dnl $Id$ -dnl - -dnl By default we'll compile and link against the bundled PCRE library -dnl if DIR is supplied, we'll use that for linking - -PHP_ARG_WITH(pcre-regex,for PCRE support, -[ --without-pcre-regex Do not include Perl Compatible Regular Expressions - support. Use --with-pcre-regex=DIR to specify DIR - where PCRE's include and library files are located, - if not using bundled library.],yes) - -if test "$PHP_PCRE_REGEX" != "no"; then - if test "$PHP_PCRE_REGEX" = "yes"; then - PHP_NEW_EXTENSION(pcre, pcrelib/maketables.c pcrelib/get.c pcrelib/study.c pcrelib/pcre.c php_pcre.c, $ext_shared,,-DSUPPORT_UTF8 -DLINK_SIZE=2 -DPOSIX_MALLOC_THRESHOLD=10 -I@ext_srcdir@/pcrelib) - PHP_ADD_BUILD_DIR($ext_builddir/pcrelib) - AC_DEFINE(HAVE_BUNDLED_PCRE, 1, [ ]) - else - for i in $PHP_PCRE_REGEX $PHP_PCRE_REGEX/include $PHP_PCRE_REGEX/include/pcre; do - test -f $i/pcre.h && PCRE_INCDIR=$i - done - - if test -z "$PCRE_INCDIR"; then - AC_MSG_ERROR([Could not find pcre.h in $PHP_PCRE_REGEX]) - fi - - for j in $PHP_PCRE_REGEX $PHP_PCRE_REGEX/lib; do - test -f $j/libpcre.a -o -f $j/libpcre.$SHLIB_SUFFIX_NAME && PCRE_LIBDIR=$j - done - - if test -z "$PCRE_LIBDIR" ; then - AC_MSG_ERROR([Could not find libpcre.(a|$SHLIB_SUFFIX_NAME) in $PHP_PCRE_REGEX]) - fi - - changequote({,}) - pcre_major=`grep PCRE_MAJOR $PCRE_INCDIR/pcre.h | sed -e 's/[^0-9]//g'` - pcre_minor=`grep PCRE_MINOR $PCRE_INCDIR/pcre.h | sed -e 's/[^0-9]//g'` - changequote([,]) - pcre_minor_length=`echo "$pcre_minor" | wc -c | sed -e 's/[^0-9]//g'` - if test "$pcre_minor_length" -eq 2 ; then - pcre_minor="$pcre_minor"0 - fi - pcre_version=$pcre_major$pcre_minor - if test "$pcre_version" -lt 208; then - AC_MSG_ERROR([The PCRE extension requires PCRE library version >= 2.08]) - fi - - PHP_ADD_LIBRARY_WITH_PATH(pcre, $PCRE_LIBDIR, PCRE_SHARED_LIBADD) - - AC_DEFINE(HAVE_PCRE, 1, [ ]) - PHP_ADD_INCLUDE($PCRE_INCDIR) - PHP_NEW_EXTENSION(pcre, php_pcre.c, $ext_shared,,-DSUPPORT_UTF8 -DLINK_SIZE=2 -DPOSIX_MALLOC_THRESHOLD=10) - fi - PHP_SUBST(PCRE_SHARED_LIBADD) -fi diff --git a/ext/soap/EXPERIMENTAL b/ext/soap/EXPERIMENTAL deleted file mode 100644 index e69de29bb2..0000000000 --- a/ext/soap/EXPERIMENTAL +++ /dev/null diff --git a/ext/soap/Makefile.in b/ext/soap/Makefile.in deleted file mode 100644 index eb52167d2d..0000000000 --- a/ext/soap/Makefile.in +++ /dev/null @@ -1,8 +0,0 @@ -# $Id$ - -LTLIBRARY_NAME = libsoap.la -LTLIBRARY_SOURCES = soap.c php_sdl.c php_schema.c php_xml.c php_encoding.c php_http.c php_packet_soap.c -LTLIBRARY_SHARED_NAME = soap.la -LTLIBRARY_SHARED_LIBADD = $(SOAP_SHARED_LIBADD) - -include $(top_srcdir)/build/dynlib.mk diff --git a/ext/soap/TODO b/ext/soap/TODO deleted file mode 100644 index 00ee6adae0..0000000000 --- a/ext/soap/TODO +++ /dev/null @@ -1,39 +0,0 @@ -TODO: -make sure soap 1.1 and 1.2 is supported fully -Better WSDL support Client and server (how much validation is needed here?) -UDDI?? -make internal refrences for soap encoding (use seralization logic) -add ini option for always soap_error_handler -provide user space overriding of serialization certin objects and types -serialization in general needs to be polished/finished... all xsd types -make perstistant objects and work with or without register_globals on -look to see if php-soap will work with out always_populate_raw_post_data on -see if client will work with ssl.. should be eaiser with php_streams -work on soap seralizer (php serialization) -work on a soap-service 'regiestry' and 'proxy' (apache soap style) -convert all string mainpulation to use smart_str -make the 'soap' packet abstract.. maybe incorperate xml-rpc -make the transport layer abstract.. what other transport layers are needed?... who uses smtp? what about jabber? -make $soap_object->data = 'text'; maybe invoke a set_*() and/or get_*() method -when using wsdls and function names are similar find the best match - void test(int); - void test(string); - maybe use the same alogrithim as ext/java. -investigate further http keep_alive... inital testing proved slower.. maybe php_streams will speed things up.. -provide schema 1999/2001 support.... -through memory leak testing -possible using shared memory for sdl caching... -api for clearing/checking sdl caching... -make php-soap work as a standalone server using php_streams and the new socket extension -http authication -proxy support -wsdl generation static and auto (.net style (http://server.com/soapserver.php?WSDL)) using phpdoc parsing engine -interpo testing... -BENCHMARKING...... lets prove how fast it is. -do some more work on website - -does this list stop... what exactly have i done? -im sure im forgetting 20 thousand more things.... - - - - brad diff --git a/ext/soap/config.m4 b/ext/soap/config.m4 deleted file mode 100644 index 0b27165bcb..0000000000 --- a/ext/soap/config.m4 +++ /dev/null @@ -1,33 +0,0 @@ -dnl $Id$ -dnl config.m4 for extension soap - -PHP_ARG_ENABLE(soap, whether to enable soap support, -[ --enable-soap[=DIR] Enable soap support. DIR is libxml2 - library directory.]) - -if test "$PHP_SOAP" != "no"; then - if test "$PHP_SOAP" = "yes"; then - for i in /usr/local /usr; do - if test -d "$i/include/libxml2/libxml"; then - XML2_INCDIR=$i/include/libxml2 - XML2_LIBDIR=$i/lib - fi - done - else - if test -d "$PHP_SOAP/include/libxml2/libxml"; then - XML2_INCDIR=$PHP_SOAP/include/libxml2 - XML2_LIBDIR=$PHP_SOAP/lib - fi - fi - - if test -z "$XML2_INCDIR"; then - AC_MSG_ERROR(Cannot find libxml2 header. Please specify correct libxml2 installation path) - fi - - AC_DEFINE(HAVE_PHP_SOAP,1,[Whether you have soap module]) - - PHP_ADD_INCLUDE($XML2_INCDIR) - PHP_ADD_LIBRARY_WITH_PATH(xml2,$XML2_LIBDIR,SOAP_SHARED_LIBADD) - PHP_NEW_EXTENSION(soap, soap.c php_encoding.c php_http.c php_packet_soap.c php_schema.c php_sdl.c php_xml.c, $ext_shared) - PHP_SUBST(SOAP_SHARED_LIBADD) -fi diff --git a/ext/soap/interop/base.php b/ext/soap/interop/base.php deleted file mode 100644 index a2bbb8a54a..0000000000 --- a/ext/soap/interop/base.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | 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. | -// +----------------------------------------------------------------------+ -// | Authors: Shane Caraveo <Shane@Caraveo.com> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// -class Interop_Base -{ -} - -?>
\ No newline at end of file diff --git a/ext/soap/interop/client_round2.php b/ext/soap/interop/client_round2.php deleted file mode 100644 index 5583bb6c17..0000000000 --- a/ext/soap/interop/client_round2.php +++ /dev/null @@ -1,102 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> - -<html> -<head> - <title>Round 2 Interop Client Tests</title> -</head> - -<body> -<a href="index.php">Back to Interop Index</a><br> -<p> </p> -<?php -require_once 'SOAP/interop/client_round2_interop.php'; - -$iop = new Interop_Client(); - -function endpointList($test,$sel_endpoint) -{ - global $iop; - $iop->getEndpoints($test); - echo "<select name='endpoint'>\n"; - foreach ($iop->endpoints as $epname => $epinfo) { - $selected = ''; - if ($sel_endpoint == $epname) $selected = ' SELECTED'; - echo "<option value='$epname'$selected>$epname</option>\n"; - } - echo "</select>\n"; -} -function methodList($test,$sel_method) -{ - global $iop; - - $ml = $iop->getMethodList($test); - echo "<select name='method'>\n"; - foreach ($ml as $method) { - $selected = ''; - if ($sel_method == $method) $selected = ' SELECTED'; - echo "<option value='$method'$selected>$method</option>\n"; - } - echo "<option value='ALL'>Run All Methods</option>\n"; - echo "</select>\n"; -} - -function endpointTestForm($test, $endpoint, $method, $paramType, $useWSDL) -{ - global $PHP_SELF; - if (!$test) $test = 'base'; - echo "Round 2 '$test' Selected<br>\n"; - echo "Select endpoint and method to run:<br>\n"; - echo "<form action='$PHP_SELF' method='post'>\n"; - echo "<input type='hidden' name='test' value='$test'>\n"; - endpointList($test, $endpoint); - methodList($test, $method); - echo "<select name='paramType'><option value='soapval'>soap value</option>"; - echo "<option value='php'".($paramType=='php'?' selected':'').">php internal type</option></select>\n"; - echo "<select name='useWSDL'><option value='0'>go Direct</option><option value='1'".($useWSDL?' selected':'').">use WSDL</option></select>\n"; - echo "<input type='submit' value='Go'>\n"; - echo "</form><br>\n"; -} - -function testSelectForm($selected_test = NULL) -{ - global $iop, $PHP_SELF; - echo "Select a Round 2 test case to run:<br>\n"; - echo "<form action='$PHP_SELF' method='post'>\n"; - echo "<select name='test'>\n"; - foreach ($iop->tests as $test) { - $selected = ''; - if ($selected_test == $test) $selected = ' SELECTED'; - echo "<option value='$test'$selected>$test</option>\n"; - } - echo "</select>\n"; - echo "<input type='submit' value='Go'>\n"; - echo "</form><br>\n"; -} - -testSelectForm($_POST['test']); -endpointTestForm($_POST['test'],$_POST['endpoint'],$_POST['method'],$_POST['paramType'],$_POST['useWSDL']); - -if ($_POST['test'] && array_key_exists('endpoint', $_POST) && array_key_exists('method', $_POST)) { - // here we execute the orders - echo "<h2>Calling {$_POST['method']} at {$_POST['endpoint']}</h2>\n"; - echo "NOTE: wire's are slightly modified to display better in web browsers.<br>\n"; - - $iop->currentTest = $_POST['test']; // see $tests above - $iop->paramType = $_POST['paramType']; // 'php' or 'soapval' - $iop->useWSDL = $_POST['useWSDL']; // 1= do wsdl tests - $iop->numServers = 0; // 0 = all - $iop->specificEndpoint = $_POST['endpoint']; // test only this endpoint - $iop->testMethod = $_POST['method']=='ALL'?'':$_POST['method']; // test only this method - $iop->skipEndpointList = array(); // endpoints to skip - $this->nosave = 0; // 1= disable saving results to database - // debug output - $iop->show = 1; - $iop->debug = 1; - $iop->showFaults = 0; // used in result table output - echo '<pre>'; - $iop->doTest(); // run a single set of tests using above options - echo '</pre>'; -} -?> -</body> -</html> diff --git a/ext/soap/interop/client_round2_interop.php b/ext/soap/interop/client_round2_interop.php deleted file mode 100644 index b3bd98b4fc..0000000000 --- a/ext/soap/interop/client_round2_interop.php +++ /dev/null @@ -1,796 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | 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. | -// +----------------------------------------------------------------------+ -// | Authors: Shane Caraveo <Shane@Caraveo.com> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// -require_once 'DB.php'; // PEAR/DB -require_once 'base.php'; -require_once 'client_round2_params.php'; -require_once 'test.utility.php'; - -error_reporting(E_ALL ^ E_NOTICE); - -class Interop_Client extends Interop_Base -{ - // database DNS - var $DSN = 'mysql://user@localhost/interop2'; - - // our central interop server, where we can get the list of endpoints - var $interopServer = "http://www.whitemesa.net/interopInfo"; - - // our local endpoint, will always get added to the database for all tests - var $localEndpoint; - - // specify testing - var $currentTest = 'base'; // see $tests above - var $paramType = 'php'; // 'php' or 'soapval' - var $useWSDL = 0; // 1= do wsdl tests - var $numServers = 0; // 0 = all - var $specificEndpoint = ''; // test only this endpoint - var $testMethod = ''; // test only this method - var $skipEndpointList = array(); // endpoints to skip - var $nosave = 0; - var $startAt = ''; // start in list at this endpoint - // debug output - var $show = 1; - var $debug = 0; - var $showFaults = 0; // used in result table output - - // PRIVATE VARIABLES - var $dbc = NULL; - var $totals = array(); - var $tests = array('base','GroupB', 'GroupC'); - var $paramTypes = array('php', 'soapval'); - var $endpoints = array(); - - function Interop_Client() { - // set up the database connection - $this->dbc = DB::connect($this->DSN, true); - // if it errors out, just ignore it and rely on regular methods - if (DB::isError($this->dbc)) { - echo $this->dbc->getMessage(); - $this->dbc = NULL; - } - // set up local endpoint - $this->localEndpoint['base'] = array( - 'endpointName'=>'PEAR SOAP', - 'endpointURL'=>'http://localhost/soap_interop/server_round2.php', - 'wsdlURL'=>'http://localhost/soap_interop/interop.wsdl' - ); - $this->localEndpoint['GroupB'] = array( - 'endpointName'=>'PEAR SOAP', - 'endpointURL'=>'http://localhost/soap_interop/server_round2.php', - 'wsdlURL'=>'http://localhost/soap_interop/interopB.wsdl' - ); - $this->localEndpoint['GroupC'] = array( - 'endpointName'=>'PEAR SOAP', - 'endpointURL'=>'http://localhost/soap_interop/server_round2.php', - 'wsdlURL'=>'http://localhost/soap_interop/echoheadersvc.wsdl' - ); - } - - function _fetchEndpoints(&$soapclient, $test) { - $this->_getEndpoints($test, 1); - - // retreive endpoints from the endpoint server - $endpointArray = $soapclient->call("GetEndpointInfo",array("groupName"=>$test),"http://soapinterop.org/info/","http://soapinterop.org/info/"); - if (PEAR::isError($endpointArray)) { - print $soapclient->wire; - print_r($endpointArray); - return; - } - - // add our local endpoint - if ($this->localEndpoint[$test]) { - array_push($endpointArray, $this->localEndpoint[$test]); - } - - if (!$endpointArray) return; - - // reset the status to zero - $res = $this->dbc->query("update endpoints set status = 0 where class='$test'"); - if (DB::isError($res)) { - die ($res->getMessage()); - } - if (is_object($res)) $res->free(); - // save new endpoints into database - foreach($endpointArray as $k => $v){ - if (array_key_exists($v['endpointName'],$this->endpoints)) { - $res = $this->dbc->query("update endpoints set endpointURL='{$v['endpointURL']}', wsdlURL='{$v['wsdlURL']}', status=1 where id={$this->endpoints[$v['endpointName']]['id']}"); - } else { - $res = $this->dbc->query("insert into endpoints (endpointName,endpointURL,wsdlURL,class) values('{$v['endpointName']}','{$v['endpointURL']}','{$v['wsdlURL']}','$test')"); - } - if (DB::isError($res)) { - die ($res->getMessage()); - } - if (is_object($res)) $res->free(); - } - } - - /** - * fetchEndpoints - * retreive endpoints interop server - * - * @return boolean result - * @access private - */ - function fetchEndpoints($test = NULL) { - // fetch from the interop server - $soapclient = new SoapObject($this->interopServer); - - if ($test) { - $this->_fetchEndpoints($soapclient, $test); - } else { - foreach ($this->tests as $test) { - $this->_fetchEndpoints($soapclient, $test); - } - $test = 'base'; - } - - // retreive all endpoints now - $this->currentTest = $test; - return $this->_getEndpoints($test); - } - - /** - * getEndpoints - * retreive endpoints from either database or interop server - * - * @param string base (see local var $tests) - * @param boolean all (if false, only get valid endpoints, status=1) - * @return boolean result - * @access private - */ - function getEndpoints($base = 'base', $all = 0) { - if (!$this->_getEndpoints($base, $all)) { - return $this->fetchEndpoints($base); - } - return TRUE; - } - - /** - * _getEndpoints - * retreive endpoints from database - * - * @param string base (see local var $tests) - * @param boolean all (if false, only get valid endpoints, status=1) - * @return boolean result - * @access private - */ - function _getEndpoints($base = "", $all = 0) { - $this->endpoints = array(); - - // build sql - $sql = "select * from endpoints "; - if ($base) { - $sql .= "where class='$base' "; - if (!$all) $sql .= "and status=1"; - } else - if (!$all) $sql .= "where status=1"; - - $db_ep = $this->dbc->getAll($sql,NULL, DB_FETCHMODE_ASSOC ); - if (DB::isError($db_ep)) { - echo $sql."\n"; - echo $db_ep->getMessage(); - return FALSE; - } - // rearange the array - foreach ($db_ep as $entry) { - $this->endpoints[$entry['endpointName']] = $entry; - } - if (count($this->endpoints) > 0) { - $this->currentTest = $base; - return TRUE; - } - return FALSE; - } - - /** - * getResults - * retreive results from the database, stuff them into the endpoint array - * - * @access private - */ - function getResults($test = 'base', $type = 'php', $wsdl = 0) { - // be sure we have the right endpoints for this test result - $this->getEndpoints($test); - - // retreive the results and put them into the endpoint info - $sql = "select * from results where class='$test' and type='$type' and wsdl=$wsdl"; - $results = $this->dbc->getAll($sql,NULL, DB_FETCHMODE_ASSOC ); - foreach ($results as $result) { - // find the endpoint - foreach ($this->endpoints as $epn => $epi) { - if ($epi['id'] == $result['endpoint']) { - // store the info - $this->endpoints[$epn]['methods'][$result['function']] = $result; - break; - } - } - } - } - - /** - * saveResults - * save the results of a method test into the database - * - * @access private - */ - function _saveResults($endpoint_id, &$soap_test) { - if ($this->nosave) return; - - $result = $soap_test->result; - $wire = $result['wire']; - if ($result['success']) { - $success = 'OK'; - $error = ''; - } else { - $success = $result['fault']->faultcode; - $error = $result['fault']->faultstring; - if (!$wire) $wire= $result['fault']->detail; - } - - $test_name = $soap_test->test_name; - // add header info to the test name - if ($soap_test->headers) { - foreach ($soap_test->headers as $h) { - $destination = 0; - if (get_class($h) == 'soap_header') { - if ($h->attributes['SOAP-ENV:actor'] == 'http://schemas.xmlsoap.org/soap/actor/next') $destination = 1; - $test_name .= ":{$h->name},$destination,{$h->attributes['SOAP-ENV:mustUnderstand']}"; - } else { - if (!$h[3] || $h[3] == 'http://schemas.xmlsoap.org/soap/actor/next') $destination = 1; - if (!$h[2]) $h[2] = 0; - $qn = new QName($h[0]); - $test_name .= ":{$qn->name},$destination,".(int)$h[2]; - } - } - } - - $sql = "delete from results where endpoint=$endpoint_id ". - "and class='$this->currentTest' and type='$this->paramType' ". - "and wsdl=$this->useWSDL and function=". - $this->dbc->quote($test_name); - #echo "\n".$sql; - $res = $this->dbc->query($sql); - if (DB::isError($res)) { - die ($res->getMessage()); - } - if (is_object($res)) $res->free(); - - $sql = "insert into results (endpoint,stamp,class,type,wsdl,function,result,error,wire) ". - "values($endpoint_id,".time().",'$this->currentTest',". - "'$this->paramType',$this->useWSDL,". - $this->dbc->quote($test_name).",". - $this->dbc->quote($success).",". - $this->dbc->quote($error).",". - ($wire?$this->dbc->quote($wire):"''").")"; - #echo "\n".$sql; - $res = $this->dbc->query($sql); - - if (DB::isError($res)) { - die ($res->getMessage()); - } - if (is_object($res)) $res->free(); - } - - /** - * decodeSoapval - * decodes a soap value to php type, used for test result comparisions - * - * @param SOAP_Value soapval - * @return mixed result - * @access public - */ - function decodeSoapval($soapval) - { - if (gettype($soapval) == "object" && - (strcasecmp(get_class($soapval),"soapparam") == 0 || - strcasecmp(get_class($soapval),"soapvar") == 0)) { - if (strcasecmp(get_class($soapval),"soapparam") == 0) - $val = $soapval->param_data->enc_value; - else - $val = $soapval->enc_value; - } else { - $val = $soapval; - } - if (is_array($val)) { - foreach($val as $k => $v) { - if (gettype($v) == "object" && - (strcasecmp(get_class($soapval),"soapparam") == 0 || - strcasecmp(get_class($soapval),"soapvar") == 0)) { - $val[$k] = $this->decodeSoapval($v); - } - } - } - return $val; - } - - /** - * compareResult - * compare two php types for a match - * - * @param string expect - * @param string test_result - * @return boolean result - * @access public - */ - function compareResult($expect, $result, $type = NULL) - { - $ok = 0; - $expect_type = gettype($expect); - $result_type = gettype($result); - if ($expect_type == "array" && $result_type == "array") { - # compare arrays - $ok = array_compare($expect, $result); - } else { - if ($type == 'boolean') - $ok = boolean_compare($expect, $result); - else - $ok = string_compare($expect, $result); - } - return $ok; - } - - - /** - * doEndpointMethod - * run a method on an endpoint and store it's results to the database - * - * @param array endpoint_info - * @param SOAP_Test test - * @return boolean result - * @access public - */ - function doEndpointMethod(&$endpoint_info, &$soap_test) { - $ok = FALSE; - - // prepare a holder for the test results - $soap_test->result['class'] = $this->currentTest; - $soap_test->result['type'] = $this->paramType; - $soap_test->result['wsdl'] = $this->useWSDL; - - if ($this->useWSDL) { - if (array_key_exists('wsdlURL',$endpoint_info)) { - if (!array_key_exists('client',$endpoint_info)) { - $endpoint_info['client'] = new SoapObject($endpoint_info['wsdlURL']); - } - $soap =& $endpoint_info['client']; - - # XXX how do we determine a failure on retreiving/parsing wsdl? - if ($soap->wsdl->fault) { - $fault = $soap->wsdl->fault->getFault(); - $soap_test->setResult(0,'WSDL', - $fault->faultstring."\n\n".$fault->detail, - $fault->faultstring, - $fault - ); - return FALSE; - } - } else { - $fault = new SoapFault('WSDL',"no WSDL defined for $endpoint"); - $soap_test->setResult(0,'WSDL', - $fault->faultstring, - $fault->faultstring, - $fault - ); - return FALSE; - } - $namespace = false; - $soapaction = false; - } else { - $namespace = $soapaction = 'http://soapinterop.org/'; - // hack to make tests work with MS SoapToolkit - // it's the only one that uses this soapaction, and breaks if - // it isn't right. Can't wait for soapaction to be fully depricated - if ($this->currentTest == 'base' && - strstr($endpoint_info['endpointName'],'MS SOAP ToolKit 2.0')) { - $soapaction = 'urn:soapinterop'; - } - if (!array_key_exists('client',$endpoint_info)) { - $endpoint_info['client'] = new SoapObject($endpoint_info['endpointURL'],$soapaction); - } - $soap = $endpoint_info['client']; - } - // add headers to the test - if ($soap_test->headers) { - // $header is already a SOAP_Header class - foreach ($soap_test->headers as $header) { - $soap->addHeader($header); - } - } - // XXX no way to set encoding - // this lets us set UTF-8, US-ASCII or other - //$soap->setEncoding($soap_test->encoding); - - if ($this->useWSDL) { - $args = ''; - foreach ($soap_test->method_params as $pname => $param) { - $arg = '$soap_test->method_params["'.$pname.'"]'; - $args .= $args?','.$arg:$arg; - } - $return = eval('return $soap->'.$soap_test->method_name.'('.$args.');'); - } else { - $return = $soap->__call($soap_test->method_name,$soap_test->method_params,$soapaction, $namespace); - } - - // save the wire - $wire = $soap->__getlastrequest()."\n\n".$soap->__getlastresponse(); - $wire = str_replace('>',">\n",$wire); - $wire = str_replace('" ',"\" \n",$wire); - #print $wire; - - if(!$soap->__isfault()){ - if (is_array($soap_test->method_params) && count($soap_test->method_params) == 1) { - $sent = array_shift($soap_test->method_params); - } else { - $sent = $soap_test->method_params; - } - - // compare header results - $header_result = array(); - $headers_ok = TRUE; - - # XXX need to implement header support! - # - #if ($soap_test->headers) { - # // $header is already a SOAP_Header class - # foreach ($soap_test->headers as $header) { - # if (get_class($header) != 'soap_header') { - # // assume it's an array - # $header = new SOAP_Header($header[0], NULL, $header[1], $header[2], $header[3], $header[4]); - # } - # $expect = $soap_test->headers_expect[$header->name]; - # $header_result[$header->name] = array(); - # // XXX need to fix need_result to identify the actor correctly - # $need_result = $hresult || - # ($header->attributes['SOAP-ENV:actor'] == 'http://schemas.xmlsoap.org/soap/actor/next' - # && $header->attributes['SOAP-ENV:mustUnderstand']); - # if ($expect) { - # $hresult = $soap->headers[key($expect)]; - # $ok = !$need_result || $this->compareResult($hresult ,$expect[key($expect)]); - # } else { - # $hresult = $soap->headers[$header->name]; - # $expect = $this->decodeSoapval($header); - # $ok = !$need_result || $this->compareResult($hresult ,$expect); - # } - # $header_result[$header->name]['ok'] = $ok; - # if (!$ok) $headers_ok = FALSE; - # } - #} - - # we need to decode what we sent so we can compare! - $sent_d = $this->decodeSoapval($sent); - - $soap_test->result['sent'] = $sent; - $soap_test->result['return'] = $return; - // compare the results with what we sent - $ok = $this->compareResult($sent_d,$return, $sent->type); - if (!$ok && $soap_test->expect) { - $ok = $this->compareResult($soap_test->expect,$return); - } - - if($ok){ - if (!$headers_ok) { - $fault = new SoapFault('HEADER','The returned result did not match what we expected to receive'); - $soap_test->setResult(0,$fault->faultcode, - $wire, - $fault->faultstring, - $fault - ); - } else { - $soap_test->setResult(1,'OK',$wire); - $success = TRUE; - } - } else { - $fault = new SoapFault('RESULT','The returned result did not match what we expected to receive'); - $soap_test->setResult(0,$fault->faultcode, - $wire, - $fault->faultstring, - $fault - ); - } - } else { - $fault = $soap->__getfault(); - if ($soap_test->expect_fault) { - $ok = 1; - $res = 'OK'; - } else { - $ok = 0; - $res =$fault->faultcode; - } - $soap_test->setResult($ok,$res, $wire,$fault->faultstring, $fault); - } - return $ok; - } - - - /** - * doTest - * run a single round of tests - * - * @access public - */ - function doTest() { - global $soap_tests; - // get endpoints for this test - $this->getEndpoints($this->currentTest); - #clear totals - $this->totals = array(); - - $i = 0; - foreach($this->endpoints as $endpoint => $endpoint_info){ - - // if we specify an endpoint, skip until we find it - if ($this->specificEndpoint && $endpoint != $this->specificEndpoint) continue; - if ($this->useWSDL && !$endpoint_info['endpointURL']) continue; - - $skipendpoint = FALSE; - $this->totals['servers']++; - #$endpoint_info['tests'] = array(); - - if ($this->show) print "Processing $endpoint at {$endpoint_info['endpointURL']}<br>\n"; - - foreach($soap_tests[$this->currentTest] as $soap_test) { - //foreach(array_keys($method_params[$this->currentTest][$this->paramType]) as $method) - - // only run the type of test we're looking for (php or soapval) - if ($soap_test->type != $this->paramType) continue; - - // if we haven't reached our startpoint, skip - if ($this->startAt && $this->startAt != $endpoint_info['endpointName']) continue; - $this->startAt = ''; - - // if this is in our skip list, skip it - if (in_array($endpoint, $this->skipEndpointList)) { - $skipendpoint = TRUE; - $skipfault = new SoapFault('SKIP','endpoint skipped'); - $soap_test->setResult(0,$fault->faultcode, '', - $skipfault->faultstring, - $skipfault - ); - #$endpoint_info['tests'][] = &$soap_test; - #$soap_test->showTestResult($this->debug); - #$this->_saveResults($endpoint_info['id'], $soap_test->method_name); - $soap_test->result = NULL; - continue; - } - - // if we're looking for a specific method, skip unless we have it - if ($this->testMethod && !strstr($this->testMethod,$soap_test->test_name)) continue; - if ($this->testMethod && $this->currentTest == 'GroupC') { - // we have to figure things out now - if (!preg_match('/(.*):(.*),(\d),(\d)/',$this->testMethod, $m)) continue; - - // is the header in the headers list? - $gotit = FALSE; - foreach ($soap_test->headers as $header) { - if (get_class($header) == 'soap_header') { - if ($header->name == $m[2]) { - $gotit = $header->attributes['SOAP-ENV:actor'] == ($m[3]?SOAP_TEST_ACTOR_NEXT:SOAP_TEST_ACTOR_OTHER); - $gotit = $gotit && $header->attributes['SOAP-ENV:mustUnderstand'] == $m[4]; - } - } else { - if ($header[0] == $m[2]) { - $gotit = $gotit && $header[3] == ($m[3]?SOAP_TEST_ACTOR_NEXT:SOAP_TEST_ACTOR_OTHER); - $gotit = $gotit && $header[4] == $m[4]; - } - } - } - if (!$gotit) continue; - } - - // if we are skipping the rest of the tests (due to error) note a fault - if ($skipendpoint) { - $soap_test->setResult(0,$fault->faultcode, '', - $skipfault->faultstring, - $skipfault - ); - #$endpoint_info['tests'][] = &$soap_test; - $this->totals['fail']++; - } else { - // run the endpoint test - if ($this->doEndpointMethod($endpoint_info, $soap_test)) { - $this->totals['success']++; - } else { - $skipendpoint = $soap_test->result['fault']->faultcode=='HTTP' - && strstr($soap_test->result['fault']->faultstring,'Connect Error'); - $skipfault = $soap_test->result['fault']; - $this->totals['fail']++; - } - #$endpoint_info['tests'][] = &$soap_test; - } - $soap_test->showTestResult($this->debug); - $this->_saveResults($endpoint_info['id'], $soap_test); - $soap_test->result = NULL; - $this->totals['calls']++; - } - if ($this->numservers && ++$i >= $this->numservers) break; - } - } - - function doGroupTests() { - $dowsdl = array(0,1); - foreach($dowsdl as $usewsdl) { - $this->useWSDL = $usewsdl; - foreach($this->paramTypes as $ptype) { - // skip a pointless test - if ($usewsdl && $ptype == 'soapval') break; - $this->paramType = $ptype; - $this->doTest(); - } - } - } - - /** - * doTests - * go all out. This takes time. - * - * @access public - */ - function doTests() { - // the mother of all interop tests - $dowsdl = array(0,1); - foreach($this->tests as $test) { - $this->currentTest = $test; - foreach($dowsdl as $usewsdl) { - $this->useWSDL = $usewsdl; - foreach($this->paramTypes as $ptype) { - // skip a pointless test - if ($usewsdl && $ptype == 'soapval') break; - $this->paramType = $ptype; - $this->doTest(); - } - } - } - } - - // *********************************************************** - // output functions - - /** - * getResults - * retreive results from the database, stuff them into the endpoint array - * - * @access private - */ - function getMethodList($test = 'base') { - // retreive the results and put them into the endpoint info - $sql = "select distinct(function) from results where class='$test' order by function"; - $results = $this->dbc->getAll($sql); - $ar = array(); - foreach($results as $result) { - $ar[] = $result[0]; - } - return $ar; - } - - function outputTable() - { - $methods = $this->getMethodList($this->currentTest); - if (!$methods) return; - $this->getResults($this->currentTest,$this->paramType,$this->useWSDL); - - echo "<b>Testing $this->currentTest "; - if ($this->useWSDL) echo "using WSDL "; - else echo "using Direct calls "; - echo "with $this->paramType values</b><br>\n"; - - // calculate totals for this table - $this->totals['success'] = 0; - $this->totals['fail'] = 0; - $this->totals['servers'] = 0; #count($this->endpoints); - foreach ($this->endpoints as $endpoint => $endpoint_info) { - if (count($endpoint_info['methods']) > 0) { - $this->totals['servers']++; - foreach ($methods as $method) { - $r = $endpoint_info['methods'][$method]['result']; - if ($r == 'OK') $this->totals['success']++; - else $this->totals['fail']++; - } - } else { - unset($this->endpoints[$endpoint]); - } - } - $this->totals['calls'] = count($methods) * $this->totals['servers']; - - if ($this->totals['fail'] == $this->totals['calls']) { - // assume tests have not run, skip outputing table - print "No Data Available<br>\n"; - return; - } - - echo "\n\n<b>Servers: {$this->totals['servers']} Calls: {$this->totals['calls']} Success: {$this->totals['success']} Fail: {$this->totals['fail']}</b><br>\n"; - - echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n"; - echo "<tr><td class=\"BLANK\">Endpoint</td>\n"; - foreach ($methods as $method) { - $info = split(':', $method); - echo "<td class='BLANK' valign='top'>"; - foreach ($info as $m) { - $hi = split(',',$m); - echo '<b>'.$hi[0]."</b><br>\n"; - if (count($hi) > 1) { - echo " Actor=".($hi[1]?'Target':'Not Target')."<br>\n"; - echo " MustUnderstand=$hi[2]<br>\n"; - } - } - echo "</td>\n"; - } - echo "</tr>\n"; - $faults = array(); - $fi = 0; - foreach ($this->endpoints as $endpoint => $endpoint_info) { - if (array_key_exists('wsdlURL',$endpoint_info)) { - echo "<tr><td class=\"BLANK\"><a href=\"{$endpoint_info['wsdlURL']}\">$endpoint</a></td>\n"; - } else { - echo "<tr><td class=\"BLANK\">$endpoint</td>\n"; - } - foreach ($methods as $method) { - $id = $endpoint_info['methods'][$method]['id']; - $r = $endpoint_info['methods'][$method]['result']; - $e = $endpoint_info['methods'][$method]['error']; - if ($e) { - $faults[$fi++] = $e; - } - if ($r) { - echo "<td class='$r'><a href='$PHP_SELF?wire=$id'>$r</a></td>\n"; - } else { - echo "<td class='untested'>untested</td>\n"; - } - } - echo "</tr>\n"; - } - echo "</table><br>\n"; - if ($this->showFaults && count($faults) > 0) { - echo "<b>ERROR Details:</b><br>\n<ul>\n"; - # output more error detail - foreach ($faults as $fault) { - echo '<li>'.HTMLSpecialChars($fault)."</li>\n"; - } - } - echo "</ul><br><br>\n"; - } - - function outputTables() { - // the mother of all interop tests - $dowsdl = array(0,1); - foreach($this->tests as $test) { - $this->currentTest = $test; - foreach($dowsdl as $usewsdl) { - $this->useWSDL = $usewsdl; - foreach($this->paramTypes as $ptype) { - // skip a pointless test - if ($usewsdl && $ptype == 'soapval') break; - $this->paramType = $ptype; - $this->outputTable(); - } - } - } - } - - function showWire($id) { - $results = $this->dbc->getAll("select * from results where id=$id",NULL, DB_FETCHMODE_ASSOC ); - #$wire = preg_replace("/>/",">\n",$results[0]['wire']); - $wire = $results[0]['wire']; - echo "<pre>\n".HTMLSpecialChars($wire)."</pre>\n"; - } - -} - -?>
\ No newline at end of file diff --git a/ext/soap/interop/client_round2_params.php b/ext/soap/interop/client_round2_params.php deleted file mode 100644 index 262093c0b7..0000000000 --- a/ext/soap/interop/client_round2_params.php +++ /dev/null @@ -1,636 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | 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. | -// +----------------------------------------------------------------------+ -// | Authors: Shane Caraveo <Shane@Caraveo.com> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - -define('SOAP_TEST_ACTOR_NEXT','http://schemas.xmlsoap.org/soap/actor/next'); -define('SOAP_TEST_ACTOR_OTHER','http://some/other/actor'); - -class SOAP_Test { - var $type = 'php'; - var $test_name = NULL; - var $method_name = NULL; - var $method_params = NULL; - var $expect = NULL; - var $expect_fault = FALSE; - var $headers = NULL; - var $headers_expect = NULL; - var $result = array(); - var $show = 1; - var $debug = 0; - var $encoding = 'UTF-8'; - - function SOAP_Test($methodname, $params, $expect = NULL) { - # XXX we have to do this to make php-soap happy with NULL params - if (!$params) $params = array(); - - if (strchr($methodname,'(')) { - preg_match('/(.*)\((.*)\)/',$methodname,$matches); - $this->test_name = $methodname; - $this->method_name = $matches[1]; - } else { - $this->test_name = $this->method_name = $methodname; - } - $this->method_params = $params; - $this->expect = $expect; - - // determine test type - if ($params) { - $v = array_values($params); - if (gettype($v[0]) == 'object' && - (get_class($v[0]) == 'soapvar' || get_class($v[0]) == 'soapparam')) - $this->type = 'soapval'; - } - } - - function setResult($ok, $result, $wire, $error = '', $fault = NULL) - { - $this->result['success'] = $ok; - $this->result['result'] = $result; - $this->result['error'] = $error; - $this->result['wire'] = $wire; - $this->result['fault'] = $fault; - } - - /** - * showMethodResult - * print simple output about a methods result - * - * @param array endpoint_info - * @param string method - * @access public - */ - function showTestResult($debug = 0) { - // debug output - if ($debug) $this->show = 1; - if ($debug) { - echo str_repeat("-",50)."<br>\n"; - } - - echo "testing $this->test_name : "; - if ($this->headers) { - foreach ($this->headers as $h) { - if (get_class($h) == 'soap_header') { - - echo "\n {$h->name},{$h->attributes['SOAP-ENV:actor']},{$h->attributes['SOAP-ENV:mustUnderstand']} : "; - } else { - if (!$h[4]) $h[4] = SOAP_TEST_ACTOR_NEXT; - if (!$h[3]) $h[3] = 0; - echo "\n $h[0],$h[4],$h[3] : "; - } - } - } - - if ($debug) { - print "method params: "; - print_r($this->params); - print "\n"; - } - - $ok = $this->result['success']; - if ($ok) { - print "SUCCESS\n"; - } else { - $fault = $this->result['fault']; - if ($fault) { - print "FAILED: {$fault->faultcode} {$fault->faultstring}\n"; - } else { - print "FAILED: ".$this->result['result']."\n"; - } - } - if ($debug) { - echo "<pre>\n".htmlentities($this->result['wire'])."</pre>\n"; - } - } -} - -# XXX I know this isn't quite right, need to deal with this better -function make_2d($x, $y) -{ - for ($_x = 0; $_x < $x; $_x++) { - for ($_y = 0; $_y < $y; $_y++) { - $a[$_x][$_y] = "x{$_x}y{$_y}"; - } - } - return $a; -} - -function soap_value($name, $value, $type) { - return new soapparam(new soapvar($value,$type),$name); -} - -class SOAPStruct { - var $varString; - var $varInt; - var $varFloat; - function SOAPStruct($s, $i, $f) { - $this->varString = $s; - $this->varInt = $i; - $this->varFloat = $f; - } -} - -//*********************************************************** -// Base echoString - -$soap_tests['base'][] = new SOAP_Test('echoString', array('inputString' => 'hello world!')); -$soap_tests['base'][] = new SOAP_Test('echoString', array('inputString' => soap_value('inputString','hello world',XSD_STRING))); -$soap_tests['base'][] = new SOAP_Test('echoString(null)', array('inputString' => "")); -$soap_tests['base'][] = new SOAP_Test('echoString(null)', array('inputString' => soap_value('inputString','',XSD_STRING))); -$soap_tests['base'][] = new SOAP_Test('echoString(entities)', array('inputString' => 'hello world\nline 2\n')); -$soap_tests['base'][] = new SOAP_Test('echoString(entities)', array('inputString' => soap_value('inputString','hello world\nline 2\n',XSD_STRING))); -$test = new SOAP_Test('echoString(utf-8)', array('inputString' => utf8_encode('ỗÈéóÒ₧⅜ỗỸ'))); -$test->encoding = 'UTF-8'; -$soap_tests['base'][] = $test; -$test = new SOAP_Test('echoString(utf-8)', array('inputString' => soap_value('inputString',utf8_encode('ỗÈéóÒ₧⅜ỗỸ'),XSD_STRING))); -$test->encoding = 'UTF-8'; -$soap_tests['base'][] = $test; - -//*********************************************************** -// Base echoStringArray - -$soap_tests['base'][] = new SOAP_Test('echoStringArray', - array('inputStringArray' => array('good','bad'))); -$soap_tests['base'][] = new SOAP_Test('echoStringArray', - array('inputStringArray' => - soap_value('inputStringArray',array('good','bad'),SOAP_ENC_ARRAY))); - -// null array test -# XXX NULL Arrays not supported -#$soap_tests['base'][] = new SOAP_Test('echoStringArray(null)', array('inputStringArray' => NULL)); -#$soap_tests['base'][] = new SOAP_Test('echoStringArray(null)', array('inputStringArray' => soap_value('inputStringArray',NULL,XSD_STRING))); - -//*********************************************************** -// Base echoInteger - -$soap_tests['base'][] = new SOAP_Test('echoInteger', array('inputInteger' => 34345)); -$soap_tests['base'][] = new SOAP_Test('echoInteger', array('inputInteger' => soap_value('inputInteger',12345,XSD_INT))); - -//*********************************************************** -// Base echoIntegerArray - -$soap_tests['base'][] = new SOAP_Test('echoIntegerArray', array('inputIntegerArray' => array(1,234324324,2))); -$soap_tests['base'][] = new SOAP_Test('echoIntegerArray', - array('inputIntegerArray' => - soap_value('inputIntegerArray', - array(new soapvar(12345,XSD_INT),new soapvar(654321,XSD_INT)), - SOAP_ENC_ARRAY))); -# -#// null array test -# XXX NULL Arrays not supported -#$soap_tests['base'][] = new SOAP_Test('echoIntegerArray(null)', array('inputIntegerArray' => NULL)); -#$soap_tests['base'][] = new SOAP_Test('echoIntegerArray(null)', array('inputIntegerArray' => new SOAP_Value('inputIntegerArray','Array',NULL))); -# -//*********************************************************** -// Base echoFloat - -$soap_tests['base'][] = new SOAP_Test('echoFloat', array('inputFloat' => 342.23)); -$soap_tests['base'][] = new SOAP_Test('echoFloat', array('inputFloat' => soap_value('inputFloat',123.45,XSD_FLOAT))); - -//*********************************************************** -// Base echoFloatArray - -$soap_tests['base'][] = new SOAP_Test('echoFloatArray', array('inputFloatArray' => array(1.3223,34.2,325.325))); -$soap_tests['base'][] = new SOAP_Test('echoFloatArray', - array('inputFloatArray' => - soap_value('inputFloatArray', - array(new soapvar(123.45,XSD_FLOAT),new soapvar(654.321,XSD_FLOAT)), - SOAP_ENC_ARRAY))); -//*********************************************************** -// Base echoStruct - -$soapstruct = new SOAPStruct('arg',34,325.325); -# XXX no way to set a namespace!!! -$soapsoapstruct = soap_value('inputStruct',$soapstruct,SOAP_ENC_OBJECT); -$soap_tests['base'][] = new SOAP_Test('echoStruct', array('inputStruct' =>$soapstruct)); -$soap_tests['base'][] = new SOAP_Test('echoStruct', array('inputStruct' =>$soapsoapstruct)); - -//*********************************************************** -// Base echoStructArray - -$soap_tests['base'][] = new SOAP_Test('echoStructArray', array('inputStructArray' => array( - $soapstruct,$soapstruct,$soapstruct))); -$soap_tests['base'][] = new SOAP_Test('echoStructArray', array('inputStructArray' => - soap_value('inputStructArray',array($soapstruct,$soapstruct,$soapstruct),SOAP_ENC_ARRAY))); - - -//*********************************************************** -// Base echoVoid - -$soap_tests['base'][] = new SOAP_Test('echoVoid', NULL); -$test = new SOAP_Test('echoVoid', NULL); -$test->type = 'soapval'; -$soap_tests['base'][] = $test; - -//*********************************************************** -// Base echoBase64 - -$soap_tests['base'][] = new SOAP_Test('echoBase64', array('inputBase64' => 'TmVicmFza2E=')); -$soap_tests['base'][] = new SOAP_Test('echoBase64', array('inputBase64' => - soap_value('inputBase64','TmVicmFza2E=',XSD_BASE64BINARY))); - -//*********************************************************** -// Base echoHexBinary - -$soap_tests['base'][] = new SOAP_Test('echoHexBinary', array('inputHexBinary' => '736F61707834')); -$soap_tests['base'][] = new SOAP_Test('echoHexBinary', array('inputHexBinary' => - soap_value('inputHexBinary','736F61707834',XSD_HEXBINARY))); - -//*********************************************************** -// Base echoDecimal - -# XXX test fails because php-soap incorrectly sets decimal to long rather than float -$soap_tests['base'][] = new SOAP_Test('echoDecimal', array('inputDecimal' => 12345.67890)); -$soap_tests['base'][] = new SOAP_Test('echoDecimal', array('inputDecimal' => - soap_value('inputDecimal',12345.67890,XSD_DECIMAL))); - -//*********************************************************** -// Base echoDate - -# php-soap doesn't handle datetime types properly yet -$soap_tests['base'][] = new SOAP_Test('echoDate', array('inputDate' => '2001-05-24T17:31:41Z')); -$soap_tests['base'][] = new SOAP_Test('echoDate', array('inputDate' => - soap_value('inputDate','2001-05-24T17:31:41Z',XSD_DATETIME)));#'2001-04-25T13:31:41-0700' - -//*********************************************************** -// Base echoBoolean - -# php-soap sends boolean as zero or one, which is ok, but to be explicit, send true or false. -$soap_tests['base'][] = new SOAP_Test('echoBoolean', array('inputBoolean' => TRUE)); -$soap_tests['base'][] = new SOAP_Test('echoBoolean', array('inputBoolean' => - soap_value('inputBoolean',TRUE,XSD_BOOLEAN))); -$soap_tests['base'][] = new SOAP_Test('echoBoolean', array('inputBoolean' => FALSE)); -$soap_tests['base'][] = new SOAP_Test('echoBoolean', array('inputBoolean' => - soap_value('inputBoolean',FALSE,XSD_BOOLEAN))); - -# -# -#//*********************************************************** -#// GROUP B -# -# -#//*********************************************************** -#// GroupB echoStructAsSimpleTypes -# -#$expect = array( -# 'outputString'=>'arg', -# 'outputInteger'=>34, -# 'outputFloat'=>325.325 -# ); -#$soap_tests['GroupB'][] = new SOAP_Test('echoStructAsSimpleTypes', -# array('inputStruct' => array( -# 'varString'=>'arg', -# 'varInt'=>34, -# 'varFloat'=>325.325 -# )), $expect); -#$soap_tests['GroupB'][] = new SOAP_Test('echoStructAsSimpleTypes', -# array('inputStruct' => -# new SOAP_Value('inputStruct','SOAPStruct', -# array( #push struct elements into one soap value -# new SOAP_Value('varString','string','arg'), -# new SOAP_Value('varInt','int',34), -# new SOAP_Value('varFloat','float',325.325) -# ))), $expect); -# -#//*********************************************************** -#// GroupB echoSimpleTypesAsStruct -# -#$expect = -# array( -# 'varString'=>'arg', -# 'varInt'=>34, -# 'varFloat'=>325.325 -# ); -#$soap_tests['GroupB'][] = new SOAP_Test('echoSimpleTypesAsStruct', -# array( -# 'inputString'=>'arg', -# 'inputInteger'=>34, -# 'inputFloat'=>325.325 -# ), $expect); -#$soap_tests['GroupB'][] = new SOAP_Test('echoSimpleTypesAsStruct', -# array( -# new SOAP_Value('inputString','string','arg'), -# new SOAP_Value('inputInteger','int',34), -# new SOAP_Value('inputFloat','float',325.325) -# ), $expect); -# -#//*********************************************************** -#// GroupB echo2DStringArray -# -#$soap_tests['GroupB'][] = new SOAP_Test('echo2DStringArray', -# array('input2DStringArray' => make_2d(3,3))); -# -#$multidimarray = -# new SOAP_Value('input2DStringArray','Array', -# array( -# array( -# new SOAP_Value('item','string','row0col0'), -# new SOAP_Value('item','string','row0col1'), -# new SOAP_Value('item','string','row0col2') -# ), -# array( -# new SOAP_Value('item','string','row1col0'), -# new SOAP_Value('item','string','row1col1'), -# new SOAP_Value('item','string','row1col2') -# ) -# ) -# ); -#$multidimarray->options['flatten'] = TRUE; -#$soap_tests['GroupB'][] = new SOAP_Test('echo2DStringArray', -# array('input2DStringArray' => $multidimarray)); -# -#//*********************************************************** -#// GroupB echoNestedStruct -# -#$soap_tests['GroupB'][] = new SOAP_Test('echoNestedStruct', -# array('inputStruct' => array( -# 'varString'=>'arg', -# 'varInt'=>34, -# 'varFloat'=>325.325, -# 'varStruct' => array( -# 'varString'=>'arg', -# 'varInt'=>34, -# 'varFloat'=>325.325 -# ) -# ))); -#$soap_tests['GroupB'][] = new SOAP_Test('echoNestedStruct', -# array('inputStruct' => -# new SOAP_Value('inputStruct','struct', -# array( #push struct elements into one soap value -# new SOAP_Value('varString','string','arg'), -# new SOAP_Value('varInt','int',34), -# new SOAP_Value('varFloat','float',325.325), -# new SOAP_Value('varStruct','SOAPStruct', -# array( #push struct elements into one soap value -# new SOAP_Value('varString','string','arg'), -# new SOAP_Value('varInt','int',34), -# new SOAP_Value('varFloat','float',325.325) -# ) -# /*,NULL,'http://soapinterop.org/xsd'*/) -# ) -# ))); -# -#//*********************************************************** -#// GroupB echoNestedArray -# -#$soap_tests['GroupB'][] = new SOAP_Test('echoNestedArray', -# array('inputStruct' => array( -# 'varString'=>'arg', -# 'varInt'=>34, -# 'varFloat'=>325.325, -# 'varArray' => array('red','blue','green') -# ))); -#$soap_tests['GroupB'][] = new SOAP_Test('echoNestedArray', -# array('inputStruct' => -# new SOAP_Value('inputStruct','struct', -# array( #push struct elements into one soap value -# new SOAP_Value('varString','string','arg'), -# new SOAP_Value('varInt','int',34), -# new SOAP_Value('varFloat','float',325.325), -# new SOAP_Value('varArray','Array', -# array( #push struct elements into one soap value -# new SOAP_Value('item','string','red'), -# new SOAP_Value('item','string','blue'), -# new SOAP_Value('item','string','green') -# ) -# ) -# ) -# ))); -# -# -#//*********************************************************** -#// GROUP C header tests -# -#//*********************************************************** -#// echoMeStringRequest php val tests -# -#// echoMeStringRequest with endpoint as header destination, doesn't have to understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->headers[] = array('{http://soapinterop.org/echoheader/}echoMeStringRequest', 'hello world', 0,SOAP_TEST_ACTOR_NEXT); -#$test->headers_expect['echoMeStringRequest'] = array('echoMeStringResponse'=>'hello world'); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeStringRequest with endpoint as header destination, must understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->headers[] = array('{http://soapinterop.org/echoheader/}echoMeStringRequest', 'hello world', 1,SOAP_TEST_ACTOR_NEXT); -#$this->type = 'soapval'; // force a soapval version of this test -#$test->headers_expect['echoMeStringRequest'] = array('echoMeStringResponse'=>'hello world'); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeStringRequest with endpoint NOT header destination, doesn't have to understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->headers[] = array('{http://soapinterop.org/echoheader/}echoMeStringRequest', 'hello world', 0, SOAP_TEST_ACTOR_OTHER); -#$test->headers_expect['echoMeStringRequest'] = array(); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeStringRequest with endpoint NOT header destination, must understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->headers[] = array('{http://soapinterop.org/echoheader/}echoMeStringRequest', 'hello world', 1, SOAP_TEST_ACTOR_OTHER); -#$test->headers_expect['echoMeStringRequest'] = array(); -#$soap_tests['GroupC'][] = $test; -# -#//*********************************************************** -#// echoMeStringRequest soapval tests -# -#// echoMeStringRequest with endpoint as header destination, doesn't have to understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->type = 'soapval'; -#$test->headers[] = new SOAP_Header('{http://soapinterop.org/echoheader/}echoMeStringRequest', 'string', 'hello world'); -#$test->headers_expect['echoMeStringRequest'] = array('echoMeStringResponse'=>'hello world'); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeStringRequest with endpoint as header destination, must understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->type = 'soapval'; -#$test->headers[] = new SOAP_Header('{http://soapinterop.org/echoheader/}echoMeStringRequest', 'string', 'hello world', 1); -#$this->type = 'soapval'; // force a soapval version of this test -#$test->headers_expect['echoMeStringRequest'] = array('echoMeStringResponse'=>'hello world'); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeStringRequest with endpoint NOT header destination, doesn't have to understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->type = 'soapval'; -#$test->headers[] = new SOAP_Header('{http://soapinterop.org/echoheader/}echoMeStringRequest', 'string', 'hello world', 0, SOAP_TEST_ACTOR_OTHER); -#$test->headers_expect['echoMeStringRequest'] = array(); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeStringRequest with endpoint NOT header destination, must understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->type = 'soapval'; -#$test->headers[] = new SOAP_Header('{http://soapinterop.org/echoheader/}echoMeStringRequest', 'string', 'hello world', 1, SOAP_TEST_ACTOR_OTHER); -#$test->headers_expect['echoMeStringRequest'] = array(); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeStringRequest with endpoint header destination, must understand, -#// invalid namespace, should recieve a fault -##$test = new SOAP_Test('echoVoid', NULL); -##$test->type = 'soapval'; -##$test->headers[] = new SOAP_Header('{http://unknown.org/echoheader/}echoMeStringRequest', 'string', 'hello world', 1); -##$test->headers_expect['echoMeStringRequest'] = array(); -##$test->expect_fault = TRUE; -##$soap_tests['GroupC'][] = $test; -# -#//*********************************************************** -#// php val tests -#// echoMeStructRequest with endpoint as header destination, doesn't have to understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->headers[] = array('{http://soapinterop.org/echoheader/}echoMeStructRequest', -# array('varString'=>'arg', 'varInt'=>34, 'varFloat'=>325.325), -# 0,SOAP_TEST_ACTOR_NEXT); -#$test->headers_expect['echoMeStructRequest'] = -# array('echoMeStructResponse'=> array('varString'=>'arg','varInt'=>34,'varFloat'=>325.325)); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeStructRequest with endpoint as header destination, must understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->headers[] = array('{http://soapinterop.org/echoheader/}echoMeStructRequest', -# array('varString'=>'arg', 'varInt'=>34, 'varFloat'=>325.325), -# 1,SOAP_TEST_ACTOR_NEXT); -#$test->headers_expect['echoMeStructRequest'] = -# array('echoMeStructResponse'=> array('varString'=>'arg','varInt'=>34,'varFloat'=>325.325)); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeStructRequest with endpoint NOT header destination, doesn't have to understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->headers[] = array('{http://soapinterop.org/echoheader/}echoMeStructRequest', -# array('varString'=>'arg', 'varInt'=>34, 'varFloat'=>325.325), -# 0, SOAP_TEST_ACTOR_OTHER); -#$test->headers_expect['echoMeStructRequest'] = array(); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeStructRequest with endpoint NOT header destination, must understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->headers[] = array('{http://soapinterop.org/echoheader/}echoMeStructRequest', -# array('varString'=>'arg', 'varInt'=>34, 'varFloat'=>325.325), -# 1, SOAP_TEST_ACTOR_OTHER); -#$test->headers_expect['echoMeStructRequest'] = array(); -#$soap_tests['GroupC'][] = $test; -# -#//*********************************************************** -#// soapval tests -#// echoMeStructRequest with endpoint as header destination, doesn't have to understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->type = 'soapval'; -#$test->headers[] = new SOAP_Header('{http://soapinterop.org/echoheader/}echoMeStructRequest',NULL, -# array( #push struct elements into one soap value -# new SOAP_Value('varString','string','arg'), -# new SOAP_Value('varInt','int',34), -# new SOAP_Value('varFloat','float',325.325) -# )); -#$test->headers_expect['echoMeStructRequest'] = -# array('echoMeStructResponse'=> array('varString'=>'arg','varInt'=>34,'varFloat'=>325.325)); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeStructRequest with endpoint as header destination, must understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->type = 'soapval'; -#$test->headers[] = new SOAP_Header('{http://soapinterop.org/echoheader/}echoMeStructRequest',NULL, -# array( #push struct elements into one soap value -# new SOAP_Value('varString','string','arg'), -# new SOAP_Value('varInt','int',34), -# new SOAP_Value('varFloat','float',325.325) -# ), 1); -#$test->headers_expect['echoMeStructRequest'] = -# array('echoMeStructResponse'=> array('varString'=>'arg','varInt'=>34,'varFloat'=>325.325)); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeStructRequest with endpoint NOT header destination, doesn't have to understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->type = 'soapval'; -#$test->headers[] = new SOAP_Header('{http://soapinterop.org/echoheader/}echoMeStructRequest',NULL, -# array( #push struct elements into one soap value -# new SOAP_Value('varString','string','arg'), -# new SOAP_Value('varInt','int',34), -# new SOAP_Value('varFloat','float',325.325) -# ), 0, SOAP_TEST_ACTOR_OTHER); -#$test->headers_expect['echoMeStructRequest'] = array(); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeStructRequest with endpoint NOT header destination, must understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->type = 'soapval'; -#$test->headers[] = new SOAP_Header('{http://soapinterop.org/echoheader/}echoMeStructRequest',NULL, -# array( #push struct elements into one soap value -# new SOAP_Value('varString','string','arg'), -# new SOAP_Value('varInt','int',34), -# new SOAP_Value('varFloat','float',325.325) -# ), 1, SOAP_TEST_ACTOR_OTHER); -#$test->headers_expect['echoMeStructRequest'] = array(); -#$soap_tests['GroupC'][] = $test; -# -#//*********************************************************** -#// echoMeUnknown php val tests -#// echoMeUnknown with endpoint as header destination, doesn't have to understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->headers[] = array('{http://soapinterop.org/echoheader/}echoMeUnknown', 'nobody understands me!',0,SOAP_TEST_ACTOR_NEXT); -#$test->headers_expect['echoMeUnknown'] = array(); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeUnknown with endpoint as header destination, must understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->headers[] = array('{http://soapinterop.org/echoheader/}echoMeUnknown', 'nobody understands me!',1,SOAP_TEST_ACTOR_NEXT); -#$test->headers_expect['echoMeUnknown'] = array(); -#$test->expect_fault = TRUE; -#$soap_tests['GroupC'][] = $test; -# -#// echoMeUnknown with endpoint NOT header destination, doesn't have to understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->headers[] = array('{http://soapinterop.org/echoheader/}echoMeUnknown', 'nobody understands me!',0, SOAP_TEST_ACTOR_OTHER); -#$test->headers_expect['echoMeUnknown'] = array(); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeUnknown with endpoint NOT header destination, must understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->headers[] = array('{http://soapinterop.org/echoheader/}echoMeUnknown', 'nobody understands me!', 1, SOAP_TEST_ACTOR_OTHER); -#$test->headers_expect['echoMeUnknown'] = array(); -#$soap_tests['GroupC'][] = $test; -# -#//*********************************************************** -#// echoMeUnknown soapval tests -#// echoMeUnknown with endpoint as header destination, doesn't have to understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->type = 'soapval'; -#$test->headers[] = new SOAP_Header('{http://soapinterop.org/echoheader/}echoMeUnknown','string','nobody understands me!'); -#$test->headers_expect['echoMeUnknown'] = array(); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeUnknown with endpoint as header destination, must understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->type = 'soapval'; -#$test->headers[] = new SOAP_Header('{http://soapinterop.org/echoheader/}echoMeUnknown','string','nobody understands me!',1); -#$test->headers_expect['echoMeUnknown'] = array(); -#$test->expect_fault = TRUE; -#$soap_tests['GroupC'][] = $test; -# -#// echoMeUnknown with endpoint NOT header destination, doesn't have to understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->type = 'soapval'; -#$test->headers[] = new SOAP_Header('{http://soapinterop.org/echoheader/}echoMeUnknown','string','nobody understands me!', 0, SOAP_TEST_ACTOR_OTHER); -#$test->headers_expect['echoMeUnknown'] = array(); -#$soap_tests['GroupC'][] = $test; -# -#// echoMeUnknown with endpoint NOT header destination, must understand -#$test = new SOAP_Test('echoVoid', NULL); -#$test->type = 'soapval'; -#$test->headers[] = new SOAP_Header('{http://soapinterop.org/echoheader/}echoMeUnknown','string','nobody understands me!', 1, SOAP_TEST_ACTOR_OTHER); -#$test->headers_expect['echoMeUnknown'] = array(); -#$soap_tests['GroupC'][] = $test; - - -?>
\ No newline at end of file diff --git a/ext/soap/interop/client_round2_results.php b/ext/soap/interop/client_round2_results.php deleted file mode 100644 index 69f82ab582..0000000000 --- a/ext/soap/interop/client_round2_results.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php -// NOTE: do not run this directly under a web server, as it will take a very long -// time to execute. Run from a command line or something, and redirect output -// to an html file. -// -// +----------------------------------------------------------------------+ -// | 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. | -// +----------------------------------------------------------------------+ -// | Authors: Shane Caraveo <Shane@Caraveo.com> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// -require_once 'client_round2_interop.php'; -?> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> - -<html> -<head> -<style> -TD { background-color: Red; } -TD.BLANK { background-color: White; } -TD.OK { background-color: Lime; } -TD.RESULT { background-color: Green; } -TD.untested { background-color: White; } -TD.CONNECT { background-color: Yellow; } -TD.TRANSPORT { background-color: Yellow; } -TD.WSDL { background-color: Yellow; } -TD.WSDLCACHE { background-color: Yellow; } -TD.WSDLPARSER { background-color: Yellow; } -TD.HTTP { background-color: Yellow; } -TD.SMTP { background-color: Yellow; } -</style> - <title>PEAR-PHP SOAP Interop Tests</title> -</head> - -<body bgcolor="White" text="Black"> -<h2 align="center">SOAP Client Interop Test Results: Round2</h2> - -<a href="index.php">Back to Interop Index</a><br> -<p> </p> - -<?php -$iop = new Interop_Client(); - -if ($_GET['detail'] == 1) $iop->showFaults = 1; - -if ($_GET['wire']) { - $iop->showWire($_GET['wire']); -} else { - $iop->getEndpoints(); - $iop->getResults(); - - if ($_GET['test']) { - $iop->currentTest = $_GET['test']; - $iop->useWSDL = $_GET['wsdl']?$_GET['wsdl']:0; - $iop->paramType = $_GET['type']?$_GET['type']:'php'; - $iop->outputTable(); - } else { - $iop->outputTables(); - } -} -?> -</body> -</html> diff --git a/ext/soap/interop/client_round2_run.php b/ext/soap/interop/client_round2_run.php deleted file mode 100644 index ab773c7e21..0000000000 --- a/ext/soap/interop/client_round2_run.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php -// this script is usefull for quickly testing stuff, use the 'pretty' file for html output -// -// +----------------------------------------------------------------------+ -// | 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. | -// +----------------------------------------------------------------------+ -// | Authors: Shane Caraveo <Shane@Caraveo.com> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// -set_time_limit(0); -require_once 'client_round2_interop.php'; - -$iop = new Interop_Client(); -// force a fetch of endpoints, this happens irregardless if no endpoints in database -#$iop->fetchEndpoints(); - -// set some options -$iop->currentTest = 'base'; // see $tests above -$iop->paramType = 'php'; // 'php' or 'soapval' -$iop->useWSDL = 1; // 1= do wsdl tests -$iop->numServers = 0; // 0 = all -$iop->specificEndpoint = '4s4c'; // test only this endpoint -$iop->testMethod = 'echoString'; // test only this method - -#XXX MS SOAP ToolKit 2.0/3.0 crashes php-soap in __getfault! - -// endpoints to skip -$iop->skipEndpointList = array('Apache Axis','IONA XMLBus','IONA XMLBus (CORBA)','MS SOAP ToolKit 2.0','MS SOAP ToolKit 3.0','Spheon JSOAP','SQLData SOAP Server','WASP Advanced 3.0'); -$iop->startAt=''; -$this->nosave = 0; // 1= disable saving results to database -// debug output -$iop->show = 1; -$iop->debug = 0; -$iop->showFaults = 0; // used in result table output - -$iop->doTest(); // run a single set of tests using above options -#$iop->doGroupTests(); // run a group of tests set in $currentTest -#$iop->doTests(); // run all tests, ignore above options -#$iop->outputTables(); -echo "done"; - -?> diff --git a/ext/soap/interop/database_round2.sql b/ext/soap/interop/database_round2.sql deleted file mode 100644 index 79669a04c2..0000000000 --- a/ext/soap/interop/database_round2.sql +++ /dev/null @@ -1,45 +0,0 @@ -# phpMyAdmin MySQL-Dump -# version 2.2.5 -# http://phpwizard.net/phpMyAdmin/ -# http://phpmyadmin.sourceforge.net/ (download page) -# -# Host: localhost -# Generation Time: Apr 08, 2002 at 08:32 PM -# Server version: 3.23.49 -# PHP Version: 4.1.1 -# Database : `interop` -# -------------------------------------------------------- - -# -# Table structure for table `endpoints` -# - -CREATE TABLE endpoints ( - id int(11) NOT NULL auto_increment, - endpointName varchar(50) NOT NULL default '', - endpointURL varchar(255) NOT NULL default '', - wsdlURL varchar(255) NOT NULL default '', - class varchar(20) NOT NULL default '', - status int(11) NOT NULL default '1', - PRIMARY KEY (id) -) TYPE=MyISAM; -# -------------------------------------------------------- - -# -# Table structure for table `results` -# - -CREATE TABLE results ( - id int(11) NOT NULL auto_increment, - endpoint int(11) NOT NULL default '0', - stamp int(11) NOT NULL default '0', - class varchar(10) NOT NULL default '', - type varchar(10) default NULL, - wsdl int(11) NOT NULL default '0', - function varchar(255) NOT NULL default '', - result varchar(25) NOT NULL default '', - error text, - wire text NOT NULL, - PRIMARY KEY (id) -) TYPE=MyISAM; - diff --git a/ext/soap/interop/echoheadersvc.wsdl b/ext/soap/interop/echoheadersvc.wsdl deleted file mode 100644 index a279580dc3..0000000000 --- a/ext/soap/interop/echoheadersvc.wsdl +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0"?> -<definitions name="InteropTest" targetNamespace="http://soapinterop.org/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://soapinterop.org/" xmlns:s="http://soapinterop.org/xsd" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> - - <import location="http://www.whitemesa.com/interop/InteropTest.wsdl" namespace="http://soapinterop.org/"/> - <import location="http://www.whitemesa.com/interop/InteropTest.wsdl" namespace="http://soapinterop.org/xsd"/> - <import location="http://www.whitemesa.com/interop/InteropTestC.wsdl" namespace="http://soapinterop.org/"/> - - <service name="interopLabEchoHeader"> - - <port name="interopPortEchoHdr" binding="tns:InteropEchoHeaderBinding"> - <soap:address location="http://localhost/soap_interop/server_round2.php"/> - </port> - - </service> - -</definitions> diff --git a/ext/soap/interop/endpointdata.sql b/ext/soap/interop/endpointdata.sql deleted file mode 100644 index 80d9d5ac9c..0000000000 --- a/ext/soap/interop/endpointdata.sql +++ /dev/null @@ -1,85 +0,0 @@ -# phpMyAdmin MySQL-Dump -# version 2.2.5 -# http://phpwizard.net/phpMyAdmin/ -# http://phpmyadmin.sourceforge.net/ (download page) -# -# Host: localhost -# Generation Time: Jul 14, 2002 at 03:13 PM -# Server version: 3.23.49 -# PHP Version: 4.2.1 -# Database : `interop2` - -# -# Dumping data for table `endpoints` -# - -INSERT INTO endpoints VALUES (1, '4s4c', 'http://soap.4s4c.com/ilab/soap.asp', 'http://www.pocketsoap.com/services/ilab.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (2, '4s4c v2.0', 'http://soap.4s4c.com/ilab2/soap.asp', 'http://soap.4s4c.com/ilab2/ilab.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (3, 'Apache Axis', 'http://nagoya.apache.org:5049/axis/services/echo', 'http://nagoya.apache.org:5049/axis/services/echo?wsdl', 'base', 1); -INSERT INTO endpoints VALUES (4, 'Apache SOAP 2.2', 'http://nagoya.apache.org:5049/soap/servlet/rpcrouter', 'http://www.apache.org/~rubys/ApacheSoap.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (5, 'ASP.NET Web Services', 'http://www.mssoapinterop.org/asmx/simple.asmx', 'http://www.mssoapinterop.org/asmx/simple.asmx?wsdl', 'base', 1); -INSERT INTO endpoints VALUES (6, 'CapeConnect', 'http://interop.capeclear.com/ccx/soapbuilders-round2', 'http://interop.capeclear.com/wsdl/soapbuilders-round2.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (7, 'Delphi SOAP', 'http://soap-server.borland.com/WebServices/Interop/cgi-bin/InteropService.exe/soap/InteropTestPortType', 'http://soap-server.borland.com/WebServices/Interop/cgi-bin/InteropService.exe/wsdl/InteropTestPortType', 'base', 1); -INSERT INTO endpoints VALUES (8, 'EasySoap++', 'http://easysoap.sourceforge.net/cgi-bin/interopserver', 'http://easysoap.sourceforge.net/interopA.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (9, 'eSOAP', 'http://www.quakersoft.net/cgi-bin/interop2_server.cgi', 'http://www.quakersoft.net/wsdl/interop2.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (10, 'gSOAP', 'http://websrv.cs.fsu.edu/~engelen/interop2.cgi', 'http://www.cs.fsu.edu/~engelen/interop2.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (11, 'Frontier', 'http://www.soapware.org/xmethodsInterop', '', 'base', 1); -INSERT INTO endpoints VALUES (12, 'GLUE', 'http://www.themindelectric.net:8005/glue/round2', 'http://www.themindelectric.net:8005/glue/round2.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (13, 'HP SOAP', 'http://soap.bluestone.com/hpws/soap/EchoService', 'http://soap.bluestone.com/hpws/soap/EchoService.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (14, 'IONA XMLBus', 'http://interop.xmlbus.com:7002/xmlbus/container/InteropTest/BaseService/BasePort', 'http://interop.xmlbus.com:7002/xmlbus/container/InteropTest/BaseService/BasePort', 'base', 1); -INSERT INTO endpoints VALUES (15, 'IONA XMLBus (CORBA)', 'http://interop.xmlbus.com:7002/xmlbus/container/CORBAInterop/BaseService/BasePort', 'http://interop.xmlbus.com:7002/xmlbus/container/CORBAInterop/BaseService/BasePort', 'base', 1); -INSERT INTO endpoints VALUES (16, 'kSOAP', 'http://kissen.cs.uni-dortmund.de:8080/ksoapinterop', 'http://www.whitemesa.com/interop/kSOAP.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (17, 'MS .NET Remoting', 'http://www.mssoapinterop.org/remoting/ServiceA.soap', 'http://www.mssoapinterop.org/remoting/ServiceA.soap?wsdl', 'base', 1); -INSERT INTO endpoints VALUES (18, 'MS SOAP ToolKit 2.0', 'http://mssoapinterop.org/stk/Interop.wsdl', 'http://mssoapinterop.org/stk/Interop.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (19, 'MS SOAP ToolKit 3.0', 'http://mssoapinterop.org/stkV3/Interop.wsdl', 'http://mssoapinterop.org/stkV3/Interop.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (20, 'NuSOAP', 'http://dietrich.ganx4.com/nusoap/testbed/round2_base_server.php', 'http://dietrich.ganx4.com/nusoap/testbed/round2_base.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (21, 'OpenLink', 'http://demo.openlinksw.com:8890/Interop', 'http://demo.openlinksw.com:8890/Interop/services.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (24, 'SIM', 'http://soapinterop.simdb.com/round2', 'http://soapinterop.simdb.com/round2?WSDL', 'base', 1); -INSERT INTO endpoints VALUES (25, 'SOAP4R', 'http://www.jin.gr.jp/~nahi/Ruby/SOAP4R/SOAPBuildersInterop/', 'http://www.jin.gr.jp/~nahi/Ruby/SOAP4R/SOAPBuildersInterop/SOAP4R_SOAPBuildersInteropTest_R2base.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (26, 'SOAP:Lite', 'http://services.soaplite.com/interop.cgi', 'http://services.soaplite.com/interop2.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (27, 'Spheon JSOAP', 'http://213.23.125.181:8081/RPC', 'http://213.23.125.181:8081/interop.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (28, 'Spray 2001', 'http://www.dolphinharbor.org/services/interop2001', 'http://www.dolphinharbor.org/services/interop2001/service.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (29, 'SQLData SOAP Server', 'http://soapclient.com/interop/sqldatainterop.wsdl', 'http://soapclient.com/interop/sqldatainterop.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (30, 'WASP Advanced 3.0', 'http://soap.systinet.net:6060/InteropService/', 'http://soap.systinet.net:6060/InteropService/', 'base', 1); -INSERT INTO endpoints VALUES (32, 'White Mesa SOAP Server', 'http://www.whitemesa.net/interop/std', 'http://www.whitemesa.net/wsdl/std/interop.wsdl', 'base', 1); -INSERT INTO endpoints VALUES (33, 'PEAR SOAP', 'http://localhost/soap_interop/server_round2.php', 'http://localhost/soap_interop/interop.wsdl.php', 'base', 1); -INSERT INTO endpoints VALUES (34, '4s4c', 'http://soap.4s4c.com/ilab/soap.asp', 'http://www.pocketsoap.com/services/ilab_b.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (35, '4s4c v2.0', 'http://soap.4s4c.com/ilab2/soap.asp', 'http://soap.4s4c.com/ilab2/ilab_b.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (36, 'Apache Axis', 'http://nagoya.apache.org:5049/axis/services/echo', 'http://nagoya.apache.org:5049/axis/services/echo?wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (37, 'ASP.NET Web Services', 'http://www.mssoapinterop.org/asmx/simpleB.asmx', 'http://www.mssoapinterop.org/asmx/simpleb.asmx?wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (38, 'Delphi SOAP', 'http://soap-server.borland.com/WebServices/Interop/cgi-bin/InteropGroupB.exe/soap/InteropTestPortTypeB', 'http://soap-server.borland.com/WebServices/Interop/cgi-bin/InteropGroupB.exe/wsdl/InteropTestPortTypeB', 'GroupB', 1); -INSERT INTO endpoints VALUES (39, 'EasySoap++', 'http://easysoap.sourceforge.net/cgi-bin/interopserver', 'http://easysoap.sourceforge.net/interopB.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (40, 'GLUE', 'http://www.themindelectric.net:8005/glue/round2B', 'http://www.themindelectric.net:8005/glue/round2B.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (41, 'gSOAP', 'http://websrv.cs.fsu.edu/~engelen/interop2B.cgi', 'http://www.cs.fsu.edu/~engelen/interop2B.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (42, 'HP SOAP', 'http://soap.bluestone.com/hpws/soap/EchoService', 'http://soap.bluestone.com/hpws/soap/EchoService.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (43, 'IONA XMLBus', 'http://interop.xmlbus.com:7002/xmlbus/container/InteropTest/GroupBService/GroupBPort', 'http://interop.xmlbus.com:7002/xmlbus/container/InteropTest/GroupBService/GroupBPort', 'GroupB', 1); -INSERT INTO endpoints VALUES (44, 'MS .NET Remoting', 'http://www.mssoapinterop.org/remoting/ServiceB.soap', 'http://www.mssoapinterop.org/remoting/ServiceB.soap?wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (45, 'MS SOAP ToolKit 2.0', 'http://mssoapinterop.org/stk/InteropBtyped.wsdl', 'http://mssoapinterop.org/stk/InteropBtyped.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (46, 'MS SOAP ToolKit 3.0', 'http://mssoapinterop.org/stkV3/InteropB.wsdl', 'http://mssoapinterop.org/stkV3/InteropB.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (47, 'NuSOAP', 'http://dietrich.ganx4.com/nusoap/testbed/round2_groupb_server.php', 'http://dietrich.ganx4.com/nusoap/testbed/round2_groupb.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (48, 'OpenLink', 'http://demo.openlinksw.com:8890/Interop', 'http://demo.openlinksw.com:8890/Interop/services.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (50, 'SIM', 'http://soapinterop.simdb.com/round2B', 'http://soapinterop.simdb.com/round2B?WSDL', 'GroupB', 1); -INSERT INTO endpoints VALUES (51, 'SOAP4R', 'http://www.jin.gr.jp/~nahi/Ruby/SOAP4R/SOAPBuildersInterop/', 'http://www.jin.gr.jp/~nahi/Ruby/SOAP4R/SOAPBuildersInterop/SOAP4R_SOAPBuildersInteropTest_R2GroupB.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (52, 'SOAP:Lite', 'http://services.soaplite.com/interop.cgi', 'http://services.soaplite.com/InteropTestB.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (53, 'Spheon JSOAP', 'http://213.23.125.181:8081/RPC', 'http://213.23.125.181:8081/interopb.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (54, 'Spray 2001', 'http://www.dolphinharbor.org/services/interopB2001', 'http://www.dolphinharbor.org/services/interopB2001/service.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (55, 'SQLData SOAP Server', 'http://soapclient.com/interop/InteropB.wsdl', 'http://soapclient.com/interop/InteropB.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (56, 'WASP Advanced 3.0', 'http://soap.systinet.net:6060/InteropBService/', 'http://soap.systinet.net:6060/InteropBService/', 'GroupB', 1); -INSERT INTO endpoints VALUES (58, 'White Mesa SOAP Server', 'http://www.whitemesa.net/interop/std/groupB', 'http://www.whitemesa.net/wsdl/std/interopB.wsdl', 'GroupB', 1); -INSERT INTO endpoints VALUES (59, 'PEAR SOAP', 'http://localhost/soap_interop/server_round2.php', 'http://localhost/soap_interop/interopB.wsdl.php', 'GroupB', 1); -INSERT INTO endpoints VALUES (60, '4s4c v2.0', 'http://soap.4s4c.com/ilab2/soap.asp', 'http://soap.4s4c.com/ilab2/ilab_c.wsdl', 'GroupC', 1); -INSERT INTO endpoints VALUES (61, 'Apache Axis', 'http://nagoya.apache.org:5049/axis/services/echo', 'http://nagoya.apache.org:5049/axis/services/echo?wsdl', 'GroupC', 1); -INSERT INTO endpoints VALUES (62, 'ASP.NET Web Services', 'http://mssoapinterop.org/asmx/header.asmx', 'http://mssoapinterop.org/asmx/header.asmx?wsdl', 'GroupC', 1); -INSERT INTO endpoints VALUES (63, 'EasySoap++', 'http://easysoap.sourceforge.net/cgi-bin/interopserver', 'http://easysoap.sourceforge.net/interopC.wsdl', 'GroupC', 1); -INSERT INTO endpoints VALUES (64, 'MS SOAP ToolKit 2.0', 'http://mssoapinterop.org/stk/InteropC.wsdl', 'http://mssoapinterop.org/stk/InteropC.wsdl', 'GroupC', 1); -INSERT INTO endpoints VALUES (65, 'MS SOAP ToolKit 3.0', 'http://mssoapinterop.org/stkV3/InteropC.wsdl', 'http://mssoapinterop.org/stkV3/InteropC.wsdl', 'GroupC', 1); -INSERT INTO endpoints VALUES (66, 'OpenLink', 'http://demo.openlinksw.com:8890/Interop', 'http://demo.openlinksw.com:8890/Interop/services.wsdl', 'GroupC', 1); -INSERT INTO endpoints VALUES (67, 'SOAP:Lite', 'http://services.soaplite.com/interopC.cgi', 'http://services.soaplite.com/InteropTestC.wsdl', 'GroupC', 1); -INSERT INTO endpoints VALUES (68, 'Spray 2001', 'http://www.dolphinharbor.org/services/interopC', 'http://www.dolphinharbor.org/services/interopC/service.wsdl', 'GroupC', 1); -INSERT INTO endpoints VALUES (69, 'SQLData SOAP Server', 'http://soapclient.com/interop/interopC.wsdl', 'http://soapclient.com/interop/interopC.wsdl', 'GroupC', 1); -INSERT INTO endpoints VALUES (70, 'WASP Advanced 3.0', 'http://soap.systinet.net:6060/InteropCService/', 'http://soap.systinet.net:6060/InteropCService/', 'GroupC', 1); -INSERT INTO endpoints VALUES (71, 'White Mesa SOAP Server', 'http://www.whitemesa.net/interop/std/echohdr', 'http://www.whitemesa.net/wsdl/std/echoheadersvc.wsdl', 'GroupC', 1); -INSERT INTO endpoints VALUES (72, 'PEAR SOAP', 'http://localhost/soap_interop/server_round2.php', 'http://localhost/soap_interop/echoheadersvc.wsdl.php', 'GroupC', 1); - - - diff --git a/ext/soap/interop/index.php b/ext/soap/interop/index.php deleted file mode 100644 index ed222479b2..0000000000 --- a/ext/soap/interop/index.php +++ /dev/null @@ -1,70 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> - -<html> -<head> - <title>PEAR SOAP Interop</title> -</head> -<?php -// get our endpoint -$server = $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT']; -$endpoint = 'http://'.$server."/soap_interop/server_round2.php"; -$base = 'http://'.$server."/soap_interop/interop.wsdl"; -$groupb = 'http://'.$server."/soap_interop/interopB.wsdl"; -$groupc = 'http://'.$server."/soap_interop/echoheadersvc.wsdl"; -?> -<body> - -<h2 align='center'>PEAR SOAP Interop</h2> -<p>Welcome to the PEAR SOAP Interop pages. These pages are set up for -SOAP Builder interop tests. You can find out more about the interop tests -at <a href="http://www.whitemesa.com/interop.htm">White Mesa</a>.</p> -<p>Currently Round 2 base, Group B and Group C interop tests are enabled.</p> - -<h3>Round 2 Interop Server</h3> -Endpoint: <?php echo $endpoint; ?><br> -Base WSDL: <a href="<?php echo $base ?>"><?php echo $base ?></a><br> -Group B WSDL: <a href="<?php echo $groupb ?>"><?php echo $groupb ?></a><br> -Group C WSDL: <a href="<?php echo $groupc ?>"><?php echo $groupc ?></a><br> - -<h3>Interop Client</h3> - -<p> -Notes: -Tests are done both "Direct" and with "WSDL". WSDL tests use the supplied interop WSDL -to run the tests against. The Direct method uses an internal prebuilt list of methods and parameters -for the test.</p> -<p> -Tests are also run against two methods of generating method parameters. The first, 'php', attempts -to directly serialize PHP variables into soap values. The second method, 'soapval', uses a SOAP_Value -class to define what the type of the value is. The second method is more interopable than the first -by nature. -</p> - -<h3>Client Test Interface</h3> -<p>The <a href="client_round2.php">client interface</a> allows you to run the PEAR SOAP -Client against a choosen interop server. Each run updates the results database below.</p> - -<h3>Interop Client Test Results</h3> -<p>This is a database of the current test results using PEAR SOAP Clients against interop servers.</p> -<p> -More detail (wire) about errors (marked yellow or red) can be obtained by clicking on the -link in the result box. If we have an HTTP error -attempting to connect to the endpoint, we will mark all consecutive attempts as errors, and skip -testing that endpoint. This reduces the time it takes to run the tests if a server is unavailable. -WSDLCACHE errors mean we cannot retreive the WSDL file specified for the endpoint. -</p> - -<ul> -<li><a href="client_round2_results.php?test=base&type=php&wsdl=0">Base results using PHP native types</a></li> -<li><a href="client_round2_results.php?test=base&type=soapval&wsdl=0">Base results using SOAP types</a></li> -<li><a href="client_round2_results.php?test=base&type=php&wsdl=1">Base results using PHP native types with WSDL</a></li> -<li><a href="client_round2_results.php?test=GroupB&type=php&wsdl=0">Group B results using PHP native types</a></li> -<li><a href="client_round2_results.php?test=GroupB&type=soapval&wsdl=0">Group B results using SOAP types</a></li> -<li><a href="client_round2_results.php?test=GroupB&type=php&wsdl=1">Group B results using PHP native types with WSDL</a></li> -<li><a href="client_round2_results.php?test=GroupC&type=php&wsdl=0">Group C results using PHP native types</a></li> -<li><a href="client_round2_results.php?test=GroupC&type=soapval&wsdl=0">Group C results using SOAP types</a></li> -<li><a href="client_round2_results.php?test=GroupC&type=php&wsdl=1">Group C results using PHP native types with WSDL</a></li> -<li><a href="client_round2_results.php">Show All Results</a></li> -</ul> -</body> -</html> diff --git a/ext/soap/interop/info.php b/ext/soap/interop/info.php deleted file mode 100644 index 147cebcdd4..0000000000 --- a/ext/soap/interop/info.php +++ /dev/null @@ -1 +0,0 @@ -<?php phpinfo(); ?> diff --git a/ext/soap/interop/interop.wsdl b/ext/soap/interop/interop.wsdl deleted file mode 100644 index 6a835b571f..0000000000 --- a/ext/soap/interop/interop.wsdl +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0"?> - -<definitions name="InteropTest" targetNamespace="http://soapinterop.org/" - xmlns="http://schemas.xmlsoap.org/wsdl/" - xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" - xmlns:tns="http://soapinterop.org/"> - - <import location="http://www.whitemesa.com/wsdl/wmmsgrouter.xsd" namespace="http://whitemesa.com/headers/soapmsgrouter.xsd"/> - <import location="http://www.whitemesa.com/interop/InteropTest.wsdl" namespace="http://soapinterop.org/"/> - <import location="http://www.whitemesa.com/interop/InteropTest.wsdl" namespace="http://soapinterop.org/xsd"/> - - <service name="interopLab"> - <port name="interopTestPort" binding="tns:InteropTestSoapBinding"> - <soap:address location="http://localhost/soap_interop/server_round2.php"/> - </port> - </service> - -</definitions> diff --git a/ext/soap/interop/interopB.wsdl b/ext/soap/interop/interopB.wsdl deleted file mode 100644 index 92301af334..0000000000 --- a/ext/soap/interop/interopB.wsdl +++ /dev/null @@ -1,13 +0,0 @@ -<?xml version="1.0"?> -<definitions name="InteropTest" targetNamespace="http://soapinterop.org/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://soapinterop.org/" xmlns:s="http://soapinterop.org/xsd" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> - - <import location="http://www.whitemesa.com/interop/InteropTestB.wsdl" namespace="http://soapinterop.org/"/> - <import location="http://www.whitemesa.com/interop/InteropTestB.wsdl" namespace="http://soapinterop.org/xsd"/> - - <service name="interopLabB"> - <port name="interopTestPortB" binding="tns:InteropTestSoapBindingB"> - <soap:address location="http://localhost/soap_interop/server_round2.php"/> - </port> - </service> - -</definitions> diff --git a/ext/soap/interop/server_round2.php b/ext/soap/interop/server_round2.php deleted file mode 100644 index a8eafe1eb2..0000000000 --- a/ext/soap/interop/server_round2.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | 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. | -// +----------------------------------------------------------------------+ -// | Authors: Shane Caraveo <Shane@Caraveo.com> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - -require_once 'SOAP/Server.php'; - -$server = new SOAP_Server; - -require_once 'server_round2_base.php'; -require_once 'server_round2_groupB.php'; -require_once 'server_round2_groupC.php'; - -$server->service(isset($HTTP_RAW_POST_DATA)?$HTTP_RAW_POST_DATA:NULL); -#echo "Content-Length is {$_SERVER['CONTENT_LENGTH']}\n\n"; -#echo "<!---\n\nlen:".strlen($HTTP_RAW_POST_DATA)."\n\n"; -#echo "[$HTTP_RAW_POST_DATA"; -#print "]\n\nend of input data-->"; -?>
\ No newline at end of file diff --git a/ext/soap/interop/server_round2_base.php b/ext/soap/interop/server_round2_base.php deleted file mode 100644 index 15dc48e565..0000000000 --- a/ext/soap/interop/server_round2_base.php +++ /dev/null @@ -1,184 +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. | -// +----------------------------------------------------------------------+ -// | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | -// | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | -// +----------------------------------------------------------------------+ -// -// $Id$ -// -require_once 'SOAP/Server.php'; - -function generateFault($short, $long) -{ - $params = array( - "faultcode" => "Server", - "faultstring" => $short, - "detail" => $long - ); - - $faultmsg = new SOAP_Message("Fault",$params,"http://schemas.xmlsoap.org/soap/envelope/"); - return $faultmsg; -} - -function hex2bin($data) -{ - $len = strlen($data); - return pack("H" . $len, $data); -} - - -class SOAP_Interop_Base { - var $method_namespace = 'http://soapinterop.org/'; - - function SOAP_Interop_Base() { - #if ($server) { - # $server->addToMap("echoString",array("string"),array("string")); - # $server->addToMap("echoStringArray",array(),array()); - # $server->addToMap("echoInteger",array("int"),array("int")); - # $server->addToMap("echoIntegerArray",array(),array()); - # $server->addToMap("echoFloat",array("float"),array("float")); - # $server->addToMap("echoFloatArray",array(),array()); - # $server->addToMap("echoStruct",array(),array()); - # $server->addToMap("echoStructArray",array(),array()); - # $server->addToMap("echoVoid",array(),array()); - # $server->addToMap("echoBase64",array("base64Binary"),array("base64Binary")); - # $server->addToMap("echoDate",array("dateTime"),array("dateTime")); - # $server->addToMap("echoHexBinary",array("hexBinary"),array("hexBinary")); - # $server->addToMap("echoDecimal",array("decimal"),array("decimal")); - # $server->addToMap("echoBoolean",array("boolean"),array("boolean")); - #} - } - - function echoString($inputString) - { - return new SOAP_Value('outputString','string',$inputString); - } - - function echoStringArray($inputStringArray) - { - $ra = array(); - if ($inputStringArray) { - foreach($inputStringArray as $s) { - $ra[] = new SOAP_Value('item','string',$s); - } - } - return new SOAP_Value('outputStringArray',NULL,$ra); - } - - - function echoInteger($inputInteger) - { - return new SOAP_Value('outputInteger','int',(integer)$inputInteger); - } - - function echoIntegerArray($inputIntegerArray) - { - $ra = array(); - if ($inputIntegerArray) { - foreach ($inputIntegerArray as $i) { - $ra[] = new SOAP_Value('item','int',$i); - } - } - return new SOAP_Value('outputIntArray',NULL,$ra); - } - - function echoFloat($inputFloat) - { - return new SOAP_Value('outputFloat','float',(FLOAT)$inputFloat); - } - - function echoFloatArray($inputFloatArray) - { - $ra = array(); - if ($inputFloatArray) { - foreach($inputFloatArray as $float) { - $ra[] = new SOAP_Value('item','float',(FLOAT)$float); - } - } - return new SOAP_Value('outputFloatArray',NULL,$ra); - } - - function echoStruct($inputStruct) - { - return new SOAP_Value('return','{http://soapinterop.org/xsd}SOAPStruct', - array( - new SOAP_Value('varInt','int',$inputStruct['varInt']), - new SOAP_Value('varFloat','float',$inputStruct['varFloat']), - new SOAP_Value('varString','string',$inputStruct['varString']) - )); - } - - function echoStructArray($inputStructArray) - { - $ra = array(); - if ($inputStructArray) { - foreach($inputStructArray as $struct) { - $ra[] = new SOAP_Value('item','{http://soapinterop.org/xsd}SOAPStruct', - array( - new SOAP_Value('varInt','int',$struct['varInt']), - new SOAP_Value('varFloat','float',$struct['varFloat']), - new SOAP_Value('varString','string',$struct['varString']) - )); - } - } - return $ra; - } - - function echoVoid() - { - return NULL; - } - - function echoBase64($b_encoded) - { - return new SOAP_Value('return','base64Binary',base64_encode(base64_decode($b_encoded))); - } - - function echoDate($timeInstant) - { - $dt = new SOAP_Type_dateTime($timeInstant); - if ($dt->toUnixtime() != -1) { - $value = $dt->toSOAP(); - return new SOAP_Value('return','dateTime',$value); - } else { - return new SOAP_Fault("Value $timeInstant is not a dateTime value"); - } - } - - function echoHexBinary($hb) - { - return new SOAP_Value('return','hexBinary',bin2hex(hex2bin($hb))); - } - - function echoDecimal($dec) - { - return new SOAP_Value('return','decimal',(FLOAT)$dec); - } - - function echoBoolean($boolean) - { - return new SOAP_Value('return','boolean',$boolean); - } - - function echoMimeAttachment($stuff) - { - return new SOAP_Attachment('return','application/octet-stream',NULL,$stuff); - } -} - -$base = new SOAP_Interop_Base(); -$server->addObjectMap($base); -?>
\ No newline at end of file diff --git a/ext/soap/interop/server_round2_groupB.php b/ext/soap/interop/server_round2_groupB.php deleted file mode 100644 index fa5856a26e..0000000000 --- a/ext/soap/interop/server_round2_groupB.php +++ /dev/null @@ -1,87 +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. | -// +----------------------------------------------------------------------+ -// | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | -// | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | -// +----------------------------------------------------------------------+ -// -// $Id$ -// -require_once 'SOAP/Server.php'; - -class SOAP_Interop_GroupB { - var $method_namespace = 'http://soapinterop.org/'; - var $dispatch_map = array(); - - function SOAP_Interop_GroupB() { - $this->dispatch_map['echoStructAsSimpleTypes'] = - array('in' => array('inputStruct' => 'SOAPStruct'), - 'out' => array('outputString' => 'string', 'outputInteger' => 'int', 'outputFloat' => 'float') - ); - -# $server->addToMap('echoSimpleTypesAsStruct', -# array('outputString' => 'string', 'outputInteger' => 'int', 'outputFloat' => 'float'), -# array('return' => 'struct')); -# $server->addToMap('echoNestedStruct', array(), array()); -# $server->addToMap('echo2DStringArray', array(), array()); -# $server->addToMap('echoNestedArray', array(), array()); - } - function echoStructAsSimpleTypes ($struct) - { - # convert a SOAPStruct to an array - $vals = array_values($struct); - return array( - new SOAP_Value('outputString','string',$struct['varString']), - new SOAP_Value('outputInteger','int',$struct['varInt']), - new SOAP_Value('outputFloat','float',$struct['varFloat']) - ); - return array_values($struct); - } - - function echoSimpleTypesAsStruct($string, $int, $float) - { - # convert a input into struct - $ret = new SOAP_Value('return','{http://soapinterop.org/xsd}SOAPStruct', - array( #push struct elements into one soap value - new SOAP_Value('varString','string',$string), - new SOAP_Value('varInt','int',(int)$int), - new SOAP_Value('varFloat','float',(FLOAT)$float) - ) - ); - return $ret; - } - - function echoNestedStruct($struct) - { - return $struct; - } - - function echo2DStringArray($ary) - { - $ret = new SOAP_Value('return','Array',$ary); - $ret->options['flatten'] = TRUE; - return $ret; - } - - function echoNestedArray($ary) - { - return $ary; - } -} - -$groupb = new SOAP_Interop_GroupB(); -$server->addObjectMap($groupb); - -?>
\ No newline at end of file diff --git a/ext/soap/interop/server_round2_groupC.php b/ext/soap/interop/server_round2_groupC.php deleted file mode 100644 index b323f9ba06..0000000000 --- a/ext/soap/interop/server_round2_groupC.php +++ /dev/null @@ -1,41 +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. | -// +----------------------------------------------------------------------+ -// | Authors: Shane Caraveo <Shane@Caraveo.com> | -// +----------------------------------------------------------------------+ -// -// $Id$ -// -require_once 'SOAP/Server.php'; -require_once 'SOAP/Value.php'; - -class SOAP_Interop_GroupC { - var $method_namespace = 'http://soapinterop.org/echoheader/'; - - function echoMeStringRequest($string) - { - return new SOAP_Value('{'.$this->method_namespace.'}echoMeStringResponse','string',$string); - } - - function echoMeStructRequest($struct) - { - return new SOAP_Value('{'.$this->method_namespace.'}echoMeStructResponse','SOAPStruct',$struct); - } -} - -$groupc = new SOAP_Interop_GroupC(); -$server->addObjectMap($groupc); - -?>
\ No newline at end of file diff --git a/ext/soap/interop/server_round2_test.php b/ext/soap/interop/server_round2_test.php deleted file mode 100644 index 3c050f7a1b..0000000000 --- a/ext/soap/interop/server_round2_test.php +++ /dev/null @@ -1,258 +0,0 @@ -<?php -// -// +----------------------------------------------------------------------+ -// | 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. | -// +----------------------------------------------------------------------+ -// | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | -// +----------------------------------------------------------------------+ -// -// $Id$ -// - -require_once 'SOAP/Server.php'; - -$server = new SOAP_Server; - -require_once 'server_round2_base.php'; -require_once 'server_round2_groupB.php'; -require_once 'server_round2_groupC.php'; - -$test = '<?xml version="1.0"?> - -<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" - xmlns:si="http://soapinterop.org/xsd" - xmlns:ns6="http://soapinterop.org/echoheader/" - SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> -<SOAP-ENV:Header> - -<ns6:echoMeStringRequest xsi:type="xsd:string" SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" SOAP-ENV:mustUnderstand="0">hello world</ns6:echoMeStringRequest> -</SOAP-ENV:Header> -<SOAP-ENV:Body> - -<echoVoid></echoVoid> -</SOAP-ENV:Body> -</SOAP-ENV:Envelope>'; - -$test = '<?xml version="1.0"?> - -<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" - xmlns:si="http://soapinterop.org/xsd" - xmlns:ns6="http://soapinterop.org/echoheader/" - SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> -<SOAP-ENV:Header> - -<ns6:echoMeStructRequest xsi:type="si:SOAPStruct" - SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" - SOAP-ENV:mustUnderstand="1"> -<varString xsi:type="xsd:string">arg</varString> - -<varInt xsi:type="xsd:int">34</varInt> - -<varFloat xsi:type="xsd:float">325.325</varFloat> -</ns6:echoMeStructRequest> -</SOAP-ENV:Header> -<SOAP-ENV:Body> - -<echoVoid></echoVoid> -</SOAP-ENV:Body> -</SOAP-ENV:Envelope> -'; - -$test = '<?xml version="1.0"?> - -<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" - xmlns:si="http://soapinterop.org/xsd" - xmlns:ns6="http://soapinterop.org/echoheader/" - xmlns:ns7="http://soapinterop.org/" - SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> -<SOAP-ENV:Body> - -<ns7:echoString> -<inputString xsi:type="xsd:string"></inputString> -</ns7:echoString> -</SOAP-ENV:Body> -</SOAP-ENV:Envelope> -'; -$test = '<?xml version="1.0" encoding="US-ASCII"?> - -<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" - xmlns:si="http://soapinterop.org/xsd" - xmlns:ns6="http://soapinterop.org/" - SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> -<SOAP-ENV:Body> -<ns6:echoVoid/> -</SOAP-ENV:Body> -</SOAP-ENV:Envelope>'; - -$test = '<?xml version="1.0" encoding="US-ASCII"?> - -<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" - xmlns:si="http://soapinterop.org/xsd" - xmlns:ns6="http://soapinterop.org/" - SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> -<SOAP-ENV:Body> -<ns6:echoIntegerArray><inputIntegerArray xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:int[3]" SOAP-ENC:offset="[0]"><item xsi:type="xsd:int">1</item> -<item xsi:type="xsd:int">234324324</item> -<item xsi:type="xsd:int">2</item> -</inputIntegerArray> -</ns6:echoIntegerArray> -</SOAP-ENV:Body> -</SOAP-ENV:Envelope>'; - -#$test = "<S:Envelope -#S:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' -#xmlns:Enc='http://schemas.xmlsoap.org/soap/encoding/' -#xmlns:S='http://schemas.xmlsoap.org/soap/envelope/' -#xmlns:a='http://soapinterop.org/' -#xmlns:b='http://soapinterop.org/xsd' -#xmlns:XS='http://www.w3.org/2001/XMLSchema' -#xmlns:XI='http://www.w3.org/2001/XMLSchema-instance'> -#<S:Body> -#<b:SOAPStruct Enc:root='0' id='21b56c4' XI:type='b:SOAPStruct'> -#<varInt XI:type='XS:int'>1</varInt> -#<varFloat XI:type='XS:float'>2</varFloat> -#<varString XI:type='XS:string'>wilma</varString> -#</b:SOAPStruct> -#<a:echoStructArray> -#<inputStructArray XI:type='Enc:Array' Enc:arrayType='XS:anyType[3]'> -#<fred href='#21b56c4'/> -#<i href='#21b56c4'/> -#<i href='#21b56c4'/> -#</inputStructArray> -#</a:echoStructArray> -#</S:Body></S:Envelope>"; - -#$test = "<S:Envelope S:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:Enc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:S='http://schemas.xmlsoap.org/soap/envelope/' xmlns:a='http://soapinterop.org/' xmlns:b='http://soapinterop.org/xsd' xmlns:XS='http://www.w3.org/2001/XMLSchema' xmlns:XI='http://www.w3.org/2001/XMLSchema-instance'> <S:Body><a:echoStructArray><inputStructArray XI:type='Enc:Array' Enc:arrayType='b:SOAPStruct[2]'><inputStruct href='#213e654'/> <inputStruct href='#21b8c4c'/> </inputStructArray> </a:echoStructArray> <b:SOAPStruct Enc:root='0' id='21b8c4c' XI:type='b:SOAPStruct'><varInt XI:type='XS:int'>-1</varInt> <varFloat XI:type='XS:float'>-1</varFloat> <varString XI:type='XS:string'>lean on into the groove y'all</varString> </b:SOAPStruct> <b:SOAPStruct Enc:root='0' id='213e654' XI:type='b:SOAPStruct'><varInt XI:type='XS:int'>1073741824</varInt> <varFloat XI:type='XS:float'>-42.24</varFloat> <varString XI:type='XS:string'>pocketSOAP rocks!<g></varString> </b:SOAPStruct> </S:Body></S:Envelope>"; - -#$test = "<S:Envelope S:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:S='http://schemas.xmlsoap.org/soap/envelope/' xmlns:b='http://soapinterop.org/' xmlns:a='http://soapinterop.org/headers/' xmlns:XS='http://www.w3.org/2001/XMLSchema' xmlns:XI='http://www.w3.org/2001/XMLSchema-instance'> <S:Header> <a:Transaction S:mustUnderstand='1' XI:type='XS:short'>5</a:Transaction> </S:Header> <S:Body><b:echoString><inputString XI:type='XS:string'>Opps, should never see me</inputString> </b:echoString> </S:Body></S:Envelope>"; -#$test = "<S:Envelope S:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:S='http://schemas.xmlsoap.org/soap/envelope/' xmlns:b='http://soapinterop.org/' xmlns:a='http://soapinterop.org/headers/' xmlns:XS='http://www.w3.org/2001/XMLSchema' xmlns:XI='http://www.w3.org/2001/XMLSchema-instance'> <S:Header> <a:Transaction XI:type='XS:short'>5</a:Transaction> </S:Header> <S:Body><b:echoString><inputString XI:type='XS:string'>Opps, should never see me</inputString> </b:echoString> </S:Body></S:Envelope>"; -#$test = "<S:Envelope S:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:Enc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:S='http://schemas.xmlsoap.org/soap/envelope/' xmlns:a='http://soapinterop.org/' xmlns:b='http://soapinterop.org/xsd' xmlns:XS='http://www.w3.org/2001/XMLSchema' xmlns:XI='http://www.w3.org/2001/XMLSchema-instance'> <S:Body><a:echoStructAsSimpleTypes><inputStruct href='#213e59c'/> </a:echoStructAsSimpleTypes> <b:SOAPStruct Enc:root='0' id='213e59c' XI:type='b:SOAPStruct'><varInt XI:type='XS:int'>42</varInt> <varString XI:type='XS:string'>Orbital</varString> <varFloat XI:type='XS:float'>-42.42</varFloat> </b:SOAPStruct> </S:Body></S:Envelope>"; - -// white mesa failures -/*$test = '<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header><h:echoMeStringRequest SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:mustUnderstand="1" xmlns:h="http://unknown.org/">White Mesa Test Header String.</h:echoMeStringRequest></SOAP-ENV:Header><SOAP-ENV:Body><m:echoVoid SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:m="http://soapinterop.org/" /></SOAP-ENV:Body></SOAP-ENV:Envelope>'; -*/ -/* -$test = '<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header><h:echoMeStringRequest SOAP-ENV:actor="http://schemas.xmlsoap.org/soap/actor/next" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:mustUnderstand="1" xmlns:h="http://unknown.org/">White Mesa Test Header String.</h:echoMeStringRequest></SOAP-ENV:Header><SOAP-ENV:Body><m:echoVoid SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:m="http://soapinterop.org/" /></SOAP-ENV:Body></SOAP-ENV:Envelope>'; -*/ -//$test = "<S:Envelope S:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:S='http://schemas.xmlsoap.org/soap/envelope/' xmlns:a='http://soapinterop.org/' xmlns:XI='http://www.w3.org/2001/XMLSchema-instance'> <S:Body><a:echoIntegerArray><inputIntegerArray XI:nil='true'></inputIntegerArray> </a:echoIntegerArray> </S:Body></S:Envelope>"; - -$test = '<?xml version="1.0" encoding="UTF-8"?> - -<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" - xmlns:ns4="http://soapinterop.org/" - SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> -<SOAP-ENV:Body> - -<ns4:echo2DStringArray> -<input2DStringArray xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[2,3]"> -<item xsi:type="xsd:string">row0col0</item> -<item xsi:type="xsd:string">row0col1</item> -<item xsi:type="xsd:string">row0col2</item> -<item xsi:type="xsd:string">row1col0</item> -<item xsi:type="xsd:string">row1col1</item> -<item xsi:type="xsd:string">row1col2</item></input2DStringArray></ns4:echo2DStringArray> -</SOAP-ENV:Body> -</SOAP-ENV:Envelope>'; - -$_SERVER['REQUEST_METHOD'] = "POST"; -$_SERVER['CONTENT_TYPE'] = 'multipart/related; type=text/xml; boundary="=_d624611fe466a88d956a205651c74fdb"'; - -$test = '--=_d624611fe466a88d956a205651c74fdb -Content-Type: text/xml; charset="UTF-8" -Content-Transfer-Encoding: base64 - -PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCg0KPFNPQVAtRU5WOkVudmVs -b3BlICB4bWxuczpTT0FQLUVOVj0iaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcvc29hcC9lbnZl -bG9wZS8iDQogIHhtbG5zOnhzZD0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiDQog -IHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiDQog -IHhtbG5zOlNPQVAtRU5DPSJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy9zb2FwL2VuY29kaW5n -LyINCiAgU09BUC1FTlY6ZW5jb2RpbmdTdHlsZT0iaHR0cDovL3NjaGVtYXMueG1sc29hcC5vcmcv -c29hcC9lbmNvZGluZy8iPg0KPFNPQVAtRU5WOkJvZHk+DQoNCjxlY2hvTWltZUF0dGFjaG1lbnQ+ -DQo8dGVzdCBocmVmPSJjaWQ6ZTZiOTg0M2JiYzUxY2JiMDAzOTk0MGVmN2VlNzY2MDMiLz48L2Vj -aG9NaW1lQXR0YWNobWVudD4NCjwvU09BUC1FTlY6Qm9keT4NCjwvU09BUC1FTlY6RW52ZWxvcGU+ -DQo= ---=_d624611fe466a88d956a205651c74fdb -Content-Disposition: attachment.php -Content-Type: text/plain -Content-Transfer-Encoding: base64 -Content-ID: <e6b9843bbc51cbb0039940ef7ee76603> - -PD9waHANCnJlcXVpcmVfb25jZSgiU09BUC9DbGllbnQucGhwIik7DQpyZXF1aXJlX29uY2UoIlNP -QVAvdGVzdC90ZXN0LnV0aWxpdHkucGhwIik7DQpyZXF1aXJlX29uY2UoIlNPQVAvVmFsdWUucGhw -Iik7DQokc29hcF9iYXNlID0gbmV3IFNPQVBfQmFzZSgpOw0KDQokdiA9ICBuZXcgU09BUF9BdHRh -Y2htZW50KCd0ZXN0JywndGV4dC9wbGFpbicsJ2F0dGFjaG1lbnQucGhwJyk7DQokbWV0aG9kVmFs -dWUgPSBuZXcgU09BUF9WYWx1ZSgndGVzdGF0dGFjaCcsICdTdHJ1Y3QnLCBhcnJheSgkdikpOw0K -DQovLyBzZWUgdGhlIG1pbWUgYXJyYXkNCi8vJHZhbCA9ICRzb2FwX2Jhc2UtPl9tYWtlRW52ZWxv -cGUoJG1ldGhvZFZhbHVlKTsNCi8vcHJpbnRfcigkdmFsKTsNCg0KJGNsaWVudCA9IG5ldyBTT0FQ -X0NsaWVudCgnaHR0cDovL2xvY2FsaG9zdC9zb2FwX2ludGVyb3Avc2VydmVyX3JvdW5kMi5waHAn -KTsNCiRyZXNwID0gJGNsaWVudC0+Y2FsbCgnZWNob01pbWVBdHRhY2htZW50JyxhcnJheSgkdikp -Ow0KcHJpbnRfcigkcmVzcCk7DQpwcmludCAkY2xpZW50LT53aXJlOw0KPz4= ---=_d624611fe466a88d956a205651c74fdb--'; - -$_SERVER['CONTENT_TYPE'] = 'multipart/related; type=text/xml; boundary="=_a2cbb051424cc43e72d3c8c8d0b8f70e"'; -$test='--=_a2cbb051424cc43e72d3c8c8d0b8f70e -Content-Type: text/xml; charset="UTF-8" - -<?xml version="1.0" encoding="UTF-8"?> - -<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" - SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> -<SOAP-ENV:Body> - -<echoMimeAttachment> -<test href="cid:a223fea3c35b5f0e6dedf8da75efd6b3"/></echoMimeAttachment> -</SOAP-ENV:Body> -</SOAP-ENV:Envelope> - ---=_a2cbb051424cc43e72d3c8c8d0b8f70e -Content-Disposition: attachment.php -Content-Type: text/plain -Content-Transfer-Encoding: base64 -Content-ID: <a223fea3c35b5f0e6dedf8da75efd6b3> - -PD9waHANCnJlcXVpcmVfb25jZSgiU09BUC9DbGllbnQucGhwIik7DQpyZXF1aXJlX29uY2UoIlNP -QVAvdGVzdC90ZXN0LnV0aWxpdHkucGhwIik7DQpyZXF1aXJlX29uY2UoIlNPQVAvVmFsdWUucGhw -Iik7DQokc29hcF9iYXNlID0gbmV3IFNPQVBfQmFzZSgpOw0KDQokdiA9ICBuZXcgU09BUF9BdHRh -Y2htZW50KCd0ZXN0JywndGV4dC9wbGFpbicsJ2F0dGFjaG1lbnQucGhwJyk7DQokbWV0aG9kVmFs -dWUgPSBuZXcgU09BUF9WYWx1ZSgndGVzdGF0dGFjaCcsICdTdHJ1Y3QnLCBhcnJheSgkdikpOw0K -DQovLyBzZWUgdGhlIG1pbWUgYXJyYXkNCi8vJHZhbCA9ICRzb2FwX2Jhc2UtPl9tYWtlRW52ZWxv -cGUoJG1ldGhvZFZhbHVlKTsNCi8vcHJpbnRfcigkdmFsKTsNCg0KJGNsaWVudCA9IG5ldyBTT0FQ -X0NsaWVudCgnaHR0cDovL2xvY2FsaG9zdC9zb2FwX2ludGVyb3Avc2VydmVyX3JvdW5kMi5waHAn -KTsNCiRyZXNwID0gJGNsaWVudC0+Y2FsbCgnZWNob01pbWVBdHRhY2htZW50JyxhcnJheSgkdikp -Ow0KI3ByaW50X3IoJHJlc3ApOw0KcHJpbnQgJGNsaWVudC0+d2lyZTsNCj8+ ---=_a2cbb051424cc43e72d3c8c8d0b8f70e-- -'; -$server->service($test, '',TRUE); -print $server->response; -?>
\ No newline at end of file diff --git a/ext/soap/interop/test.utility.php b/ext/soap/interop/test.utility.php deleted file mode 100644 index 9af61c22fb..0000000000 --- a/ext/soap/interop/test.utility.php +++ /dev/null @@ -1,81 +0,0 @@ -<?php -require_once("SOAP/Parser.php"); -require_once("SOAP/Value.php"); - -function number_compare($f1, $f2) -{ - # figure out which has the least fractional digits - preg_match('/.*?\.(.*)/',$f1,$m1); - preg_match('/.*?\.(.*)/',$f2,$m2); - #print_r($m1); - # always use at least 2 digits of precision - $d = max(min(strlen(count($m1)?$m1[1]:'0'),strlen(count($m2)?$m2[1]:'0')),2); - $f1 = round($f1, $d); - $f2 = round($f2, $d); - return bccomp($f1, $f2, $d) == 0; -} - -function boolean_compare($f1, $f2) -{ - if (($f1 == 'true' || $f1 === TRUE || $f1 != 0) && - ($f2 == 'true' || $f2 === TRUE || $f2 != 0)) return TRUE; - if (($f1 == 'false' || $f1 === FALSE || $f1 == 0) && - ($f2 == 'false' || $f2 === FALSE || $f2 == 0)) return TRUE; - return FALSE; -} - -function string_compare($e1, $e2) -{ - if (is_numeric($e1) && is_numeric($e2)) { - return number_compare($e1, $e2); - } - # handle dateTime comparison - $e1_type = gettype($e1); - $e2_type = gettype($e2); - $ok = FALSE; - if ($e1_type == "string") { - $dt = new SOAP_Type_dateTime(); - $ok = $dt->compare($e1, $e2) == 0; - } - return $ok || $e1 == $e2 || strcasecmp(trim($e1), trim($e2)) == 0; -} - -function array_compare(&$ar1, &$ar2) -{ - if (gettype($ar1) != 'array' || gettype($ar2) != 'array') return FALSE; - # first a shallow diff - if (count($ar1) != count($ar2)) return FALSE; - $diff = array_diff($ar1, $ar2); - if (count($diff) == 0) return TRUE; - - # diff failed, do a full check of the array - foreach ($ar1 as $k => $v) { - #print "comparing $v == $ar2[$k]\n"; - if (gettype($v) == "array") { - if (!array_compare($v, $ar2[$k])) return FALSE; - } else { - if (!string_compare($v, $ar2[$k])) return FALSE; - } - } - return TRUE; -} - - -function parseMessage($msg) -{ - # strip line endings - #$msg = preg_replace('/\r|\n/', ' ', $msg); - $response = new SOAP_Parser($msg); - if ($response->fault) { - return $response->fault->getFault(); - } - $return = $response->getResponse(); - $v = $response->decode($return); - if (gettype($v) == 'array' && count($v)==1) { - return array_shift($v); - } - return $v; -} - - -?>
\ No newline at end of file diff --git a/ext/soap/interop/testclient.php b/ext/soap/interop/testclient.php deleted file mode 100644 index b70c628ee5..0000000000 --- a/ext/soap/interop/testclient.php +++ /dev/null @@ -1,17 +0,0 @@ -<html><body> -<? -error_reporting(2039); -include("SOAP/Client.php"); - -$txt = "Bjoern"; - -$soapc = new SOAP_Client("http://localhost/soap_interop/testserver.php"); -$soapc->debug_flag = TRUE; -print_r($soapc->call("testMethod",array("txt" => $txt))); -print "<br>Debug: "; -print $soapc->wire; -print "<br><br>"; -unset($soapc); - -?> -</html></body>
\ No newline at end of file diff --git a/ext/soap/interop/testserver.php b/ext/soap/interop/testserver.php deleted file mode 100644 index 03973c8863..0000000000 --- a/ext/soap/interop/testserver.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php -include "SOAP/Server.php"; - -function testMethod($arg) { - if ($arg != "") { - return crypt($arg); - } else { - return "Please supply a text"; - } -} - -$server = new soap_server(); - -$server->addToMap("testMethod",array("string"),array("string")); -$server->service($HTTP_RAW_POST_DATA); -echo "<!-- this is a test -->"; -?>
\ No newline at end of file diff --git a/ext/soap/package.xml b/ext/soap/package.xml deleted file mode 100644 index 965670fcc8..0000000000 --- a/ext/soap/package.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!-- do not use the "Type" attribute here, that one is only for - generated package.xml files --> -<package> - <name>ext_soap</name> - <summary>Provides SOAP Services</summary> - <description> - Description of package.... - </description> - <status>beta</status> - <maintainers> - <maintainer> - <user>rodif_bl</user> - <name>Brad Lafountain</name> - <email>rodif_bl@yahoo.com</email> - <role>lead</role> - </maintainer> - <maintainer> - <user>shane</user> - <name>Shane Caraveo</name> - <email>shane@caraveo.com</email> - <role>lead</role> - </maintainer> - </maintainers> - <license>PHP</license> - <release> - <version>0.1</version> - <date>2002-07-07</date> - <state>alpha</state> - <notes> - - First offical PEAR/PECL release - </notes> - </release> - <filelist> - <dir name="/"> - <file role="doc">EXPERIMENTAL</file> - <file role="doc">TODO</file> - <file role="src">config.m4</file> - <file role="src">Makefile.in</file> - <file role="src">php_encoding.c</file> - <file role="src">php_encoding.h</file> - <file role="src">php_http.c</file> - <file role="src">php_http.h</file> - <file role="src">php_packet_soap.c</file> - <file role="src">php_packet_soap.h</file> - <file role="src">php_schema.c</file> - <file role="src">php_schema.h</file> - <file role="src">php_sdl.c</file> - <file role="src">php_sdl.h</file> - <file role="src">php_soap.h</file> - <file role="src">php_soap.h</file> - <file role="src">php_xml.c</file> - <file role="src">php_xml.h</file> - <file role="src">soap.c</file> - <file role="src">php_soap.dsp</file> - </dir> - </filelist> -</package> - diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c deleted file mode 100644 index 3b4909f3d6..0000000000 --- a/ext/soap/php_encoding.c +++ /dev/null @@ -1,1135 +0,0 @@ -#include <time.h> - -#include "php_soap.h" - -encode defaultEncoding[] = { - {{UNKNOWN_TYPE, NULL, NULL, NULL}, guess_zval_convert, guess_xml_convert}, - - {{IS_NULL, "null", "null", NULL}, to_zval_null, to_xml_null}, - {{IS_STRING, XSD_STRING_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_string}, - {{IS_LONG, XSD_INT_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long}, - {{IS_DOUBLE, XSD_FLOAT_STRING, XSD_NAMESPACE, NULL}, to_zval_double, to_xml_string}, - {{IS_BOOL, XSD_BOOLEAN_STRING, XSD_NAMESPACE, NULL}, to_zval_bool, to_xml_bool}, - {{IS_CONSTANT, XSD_STRING_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_string}, - {{IS_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_ENC_NAMESPACE, NULL}, to_zval_array, guess_array_map}, - {{IS_CONSTANT_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_ENC_NAMESPACE, NULL}, to_zval_array, to_xml_array}, - {{IS_OBJECT, SOAP_ENC_OBJECT_STRING, SOAP_ENC_NAMESPACE, NULL}, to_zval_object, to_xml_object}, - - {{XSD_STRING, XSD_STRING_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_string}, - {{XSD_BOOLEAN, XSD_BOOLEAN_STRING, XSD_NAMESPACE, NULL}, to_zval_bool, to_xml_bool}, - {{XSD_DECIMAL, XSD_DECIMAL_STRING, XSD_NAMESPACE, NULL}, to_zval_double, to_xml_string}, - {{XSD_FLOAT, XSD_FLOAT_STRING, XSD_NAMESPACE, NULL}, to_zval_double, to_xml_string}, - {{XSD_DOUBLE, XSD_DOUBLE_STRING, XSD_NAMESPACE, NULL}, to_zval_double, to_xml_string}, - {{XSD_DATETIME, XSD_DATETIME_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_datetime}, - {{XSD_TIME, XSD_TIME_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_time}, - {{XSD_DATE, XSD_DATE_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_date}, - {{XSD_GYEARMONTH, XSD_GYEARMONTH_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_gyearmonth}, - {{XSD_GYEAR, XSD_GYEAR_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_gyear}, - {{XSD_GMONTHDAY, XSD_GMONTHDAY_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_gmonthday}, - {{XSD_GDAY, XSD_GDAY_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_gday}, - {{XSD_GMONTH, XSD_GMONTH_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_gmonth}, - {{XSD_HEXBINARY, XSD_HEXBINARY_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_stringl}, - {{XSD_BASE64BINARY, XSD_BASE64BINARY_STRING, XSD_NAMESPACE, NULL}, to_zval_string, to_xml_stringl}, - - {{XSD_LONG, XSD_LONG_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_long}, - {{XSD_INT, XSD_INT_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_string}, - {{XSD_SHORT, XSD_SHORT_STRING, XSD_NAMESPACE, NULL}, to_zval_long, to_xml_string}, - - {{APACHE_MAP, APACHE_MAP_STRING, APACHE_NAMESPACE, NULL}, to_zval_map, to_xml_map}, - - {{SOAP_ENC_OBJECT, SOAP_ENC_OBJECT_STRING, SOAP_ENC_NAMESPACE, NULL}, to_zval_object, to_xml_object}, - {{SOAP_ENC_ARRAY, SOAP_ENC_ARRAY_STRING, SOAP_ENC_NAMESPACE, NULL}, to_zval_array, to_xml_array}, - - /* support some of the 1999 data types */ - {{XSD_STRING, XSD_STRING_STRING, XSD_1999_NAMESPACE, NULL}, to_zval_string, to_xml_string}, - {{XSD_BOOLEAN, XSD_BOOLEAN_STRING, XSD_1999_NAMESPACE, NULL}, to_zval_bool, to_xml_bool}, - {{XSD_DECIMAL, XSD_DECIMAL_STRING, XSD_1999_NAMESPACE, NULL}, to_zval_long, to_xml_string}, - {{XSD_FLOAT, XSD_FLOAT_STRING, XSD_1999_NAMESPACE, NULL}, to_zval_double, to_xml_string}, - {{XSD_DOUBLE, XSD_DOUBLE_STRING, XSD_1999_NAMESPACE, NULL}, to_zval_double, to_xml_string}, - {{XSD_LONG, XSD_LONG_STRING, XSD_1999_NAMESPACE, NULL}, to_zval_long, to_xml_long}, - {{XSD_INT, XSD_INT_STRING, XSD_1999_NAMESPACE, NULL}, to_zval_long, to_xml_string}, - {{XSD_SHORT, XSD_SHORT_STRING, XSD_1999_NAMESPACE, NULL}, to_zval_long, to_xml_string}, - {{XSD_1999_TIMEINSTANT, XSD_1999_TIMEINSTANT_STRING, XSD_1999_NAMESPACE, NULL}, to_zval_string, to_xml_string}, - - {{END_KNOWN_TYPES, NULL, NULL, NULL}, guess_zval_convert, guess_xml_convert} - -/* TODO: finish off encoding */ -/* -#define XSD_DURATION 107 -#define XSD_DURATION_STRING "duration" -#define XSD_ANYURI 118 -#define XSD_ANYURI_STRING "anyURI" -#define XSD_QNAME 119 -#define XSD_QNAME_STRING "QName" -#define XSD_NOTATION 120 -#define XSD_NOTATION_STRING "NOTATION" -*/ - -/* -#define XSD_NORMALIZEDSTRING 121 -#define XSD_NORMALIZEDSTRING_STRING "normalizedString" -#define XSD_TOKEN 122 -#define XSD_TOKEN_STRING "token" -#define XSD_LANGUAGE 123 -#define XSD_LANGUAGE_STRING "language" -#define XSD_NMTOKEN 124 -#define XSD_NMTOKEN_STRING "NMTOKEN" -#define XSD_NAME 124 -#define XSD_NAME_STRING "Name" -#define XSD_NCNAME 125 -#define XSD_NCNAME_STRING "NCName" -#define XSD_ID 126 -#define XSD_ID_STRING "ID" -#define XSD_IDREF 127 -#define XSD_IDREF_STRING "IDREF" -#define XSD_IDREFS 127 -#define XSD_IDREFS_STRING "IDREFS" -#define XSD_ENTITY 128 -#define XSD_ENTITY_STRING "ENTITY" -#define XSD_ENTITYS 129 -#define XSD_ENTITYS_STRING "ENTITYS" -#define XSD_INTEGER 130 -#define XSD_INTEGER_STRING "integer" -#define XSD_NONPOSITIVEINTEGER 131 -#define XSD_NONPOSITIVEINTEGER_STRING "nonPositiveInteger" -#define XSD_NEGATIVEINTEGER 132 -#define XSD_NEGATIVEINTEGER_STRING "negativeInteger" -#define XSD_NONNEGATIVEINTEGER 137 -#define XSD_NONNEGATIVEINTEGER_STRING "nonNegativeInteger" -#define XSD_UNSIGNEDLONG 138 -#define XSD_UNSIGNEDLONG_STRING "unsignedLong" -#define XSD_UNSIGNEDINT 139 -#define XSD_UNSIGNEDINT_STRING "unsignedInt" -#define XSD_UNSIGNEDSHORT 140 -#define XSD_UNSIGNEDSHORT_STRING "unsignedShort" -#define XSD_UNSIGNEDBYTE 141 -#define XSD_UNSIGNEDBYTE_STRING "unsignedByte" -#define XSD_POSITIVEINTEGER 142 -#define XSD_POSITIVEINTEGER_STRING "positiveInteger" -*/ -}; - -xmlNodePtr master_to_xml(encodePtr encode, zval *data, int style) -{ - xmlNodePtr node; - - if(encode->to_xml_before) - data = encode->to_xml_before(encode->details, data); - if(encode->to_xml) - node = encode->to_xml(encode->details, data, style); - if(encode->to_xml_after) - node = encode->to_xml_after(encode->details, node, style); - - return node; -} - -zval *master_to_zval(encodePtr encode, xmlNodePtr data) -{ - zval *ret; - - data = check_and_resolve_href(data); - if(encode->to_zval_before) - data = encode->to_zval_before(encode->details, data, 0); - if(encode->to_zval) - ret = encode->to_zval(encode->details, data); - if(encode->to_zval_after) - ret = encode->to_zval_after(encode->details, ret); - - return ret; -} - -#ifdef HAVE_PHP_DOMXML -zval *to_xml_before_user(encodeType type, zval *data) -{ - TSRMLS_FETCH(); - - if(type.map->map_functions.to_xml_before) - { - if(call_user_function(EG(function_table), NULL, type.map->map_functions.to_xml_before, data, 1, &data TSRMLS_CC) == FAILURE) - php_error(E_ERROR, "Error calling to_xml_before"); - } - return data; -} - -xmlNodePtr to_xml_user(encodeType type, zval *data, int style) -{ - zval *ret, **addr; - xmlNodePtr node; - TSRMLS_FETCH(); - - if(type.map->map_functions.to_xml) - { - MAKE_STD_ZVAL(ret); - if(call_user_function(EG(function_table), NULL, type.map->map_functions.to_xml, ret, 1, &data TSRMLS_CC) == FAILURE) - php_error(E_ERROR, "Error calling to_xml"); - - if(Z_TYPE_P(ret) != IS_OBJECT) - php_error(E_ERROR, "Error serializing object from to_xml_user"); - - if(zend_hash_index_find(Z_OBJPROP_P(ret), 1, (void **)&addr) == SUCCESS) - { - node = (xmlNodePtr)Z_LVAL_PP(addr); - node = xmlCopyNode(node, 1); - set_ns_and_type(node, type); - } - zval_ptr_dtor(&ret); - } - return node; -} - -xmlNodePtr to_xml_after_user(encodeType type, xmlNodePtr node, int style) -{ - zval *ret, *param, **addr; - int found; - TSRMLS_FETCH(); - - if(type.map->map_functions.to_xml_after) - { - MAKE_STD_ZVAL(ret); - MAKE_STD_ZVAL(param); - param = php_domobject_new(node, &found, NULL TSRMLS_CC); - - if(call_user_function(EG(function_table), NULL, type.map->map_functions.to_xml_after, ret, 1, ¶m TSRMLS_CC) == FAILURE) - php_error(E_ERROR, "Error calling to_xml_after"); - if(zend_hash_index_find(Z_OBJPROP_P(ret), 1, (void **)&addr) == SUCCESS) - { - node = (xmlNodePtr)Z_LVAL_PP(addr); - set_ns_and_type(node, type); - } - zval_ptr_dtor(&ret); - zval_ptr_dtor(¶m); - } - return node; -} - -xmlNodePtr to_zval_before_user(encodeType type, xmlNodePtr node, int style) -{ - zval *ret, *param, **addr; - int found; - TSRMLS_FETCH(); - - if(type.map->map_functions.to_zval_before) - { - MAKE_STD_ZVAL(ret); - MAKE_STD_ZVAL(param); - param = php_domobject_new(node, &found, NULL TSRMLS_CC); - - if(call_user_function(EG(function_table), NULL, type.map->map_functions.to_zval_before, ret, 1, ¶m TSRMLS_CC) == FAILURE) - php_error(E_ERROR, "Error calling to_zval_before"); - if(zend_hash_index_find(Z_OBJPROP_P(ret), 1, (void **)&addr) == SUCCESS) - { - node = (xmlNodePtr)Z_LVAL_PP(addr); - set_ns_and_type(node, type); - } - zval_ptr_dtor(&ret); - zval_ptr_dtor(¶m); - } - return node; -} - -zval *to_zval_user(encodeType type, xmlNodePtr node) -{ - zval *ret, *param; - int found; - TSRMLS_FETCH(); - - if(type.map->map_functions.to_zval) - { - MAKE_STD_ZVAL(ret); - MAKE_STD_ZVAL(param); - param = php_domobject_new(node, &found, NULL TSRMLS_CC); - - if(call_user_function(EG(function_table), NULL, type.map->map_functions.to_zval, ret, 1, ¶m TSRMLS_CC) == FAILURE) - php_error(E_ERROR, "Error calling to_zval"); - zval_ptr_dtor(¶m); - efree(param); - } - return ret; -} - -zval *to_zval_after_user(encodeType type, zval *data) -{ - TSRMLS_FETCH(); - - if(type.map->map_functions.to_zval_after) - { - if(call_user_function(EG(function_table), NULL, type.map->map_functions.to_zval_after, data, 1, &data TSRMLS_CC) == FAILURE) - php_error(E_ERROR, "Error calling to_xml_before"); - } - return data; -} -#endif - -/* TODO: get rid of "bogus".. ither by passing in the already created xmlnode or passing in the node name */ -/* String encode/decode */ -zval *to_zval_string(encodeType type, xmlNodePtr data) -{ - zval *ret; - MAKE_STD_ZVAL(ret); - FIND_XML_NULL(data, ret); - - if(data && data->children) - ZVAL_STRING(ret, data->children->content, 1); - return ret; -} - -zval *to_zval_stringl(encodeType type, xmlNodePtr data) -{ - zval *ret; - MAKE_STD_ZVAL(ret); - FIND_XML_NULL(data, ret); - - if(data && data->children) - ZVAL_STRINGL(ret, data->children->content, xmlStrlen(data->children->content), 1); - return ret; -} - -xmlNodePtr to_xml_string(encodeType type, zval *data, int style) -{ - xmlNodePtr ret; - char *str, *pstr; - int new_len; - TSRMLS_FETCH(); - - ret = xmlNewNode(NULL, "BOGUS"); - FIND_ZVAL_NULL(data, ret); - - convert_to_string(data); - str = php_escape_html_entities(Z_STRVAL_P(data), Z_STRLEN_P(data), &new_len, 0, 0, NULL TSRMLS_CC); - - pstr = malloc(new_len + 1); - memcpy(pstr, str, new_len); - pstr[new_len] = '\0'; - efree(str); - - xmlNodeSetContentLen(ret, pstr, new_len); - - if(style == SOAP_ENCODED) - set_ns_and_type(ret, type); - return ret; -} - -xmlNodePtr to_xml_stringl(encodeType type, zval *data, int style) -{ - xmlNodePtr ret; - - ret = xmlNewNode(NULL, "BOGUS"); - FIND_ZVAL_NULL(data, ret); - - convert_to_string(data); - xmlNodeSetContentLen(ret, estrndup(Z_STRVAL_P(data), Z_STRLEN_P(data)), Z_STRLEN_P(data)); - - if(style == SOAP_ENCODED) - set_ns_and_type(ret, type); - return ret; -} - -zval *to_zval_double(encodeType type, xmlNodePtr data) -{ - zval *ret; - MAKE_STD_ZVAL(ret); - FIND_XML_NULL(data, ret); - - ZVAL_DOUBLE(ret, atof(data->children->content)); - return ret; -} - -zval *to_zval_long(encodeType type, xmlNodePtr data) -{ - zval *ret; - MAKE_STD_ZVAL(ret); - FIND_XML_NULL(data, ret); - - ZVAL_LONG(ret, atol(data->children->content)); - return ret; -} - -xmlNodePtr to_xml_long(encodeType type, zval *data, int style) -{ - xmlNodePtr ret; - - ret = xmlNewNode(NULL, "BOGUS"); - FIND_ZVAL_NULL(data, ret); - - convert_to_long(data); - convert_to_string(data); - xmlNodeSetContentLen(ret, Z_STRVAL_P(data), Z_STRLEN_P(data)); - - if(style == SOAP_ENCODED) - set_ns_and_type(ret, type); - return ret; -} - -zval *to_zval_bool(encodeType type, xmlNodePtr data) -{ - zval *ret; - MAKE_STD_ZVAL(ret); - FIND_XML_NULL(data, ret); - - if(stricmp(data->children->content,"true") == 0 || - stricmp(data->children->content,"t") == 0 || - strcmp(data->children->content,"1") == 0) - { - ZVAL_BOOL(ret, 1); - } - else - { - ZVAL_BOOL(ret, 0); - } - return ret; -} - -xmlNodePtr to_xml_bool(encodeType type, zval *data, int style) -{ - xmlNodePtr ret; - - ret = xmlNewNode(NULL, "BOGUS"); - FIND_ZVAL_NULL(data, ret); - - convert_to_boolean(data); - if(data->value.lval == 1) - xmlNodeSetContent(ret, "1"); - else - xmlNodeSetContent(ret, "0"); - - if(style == SOAP_ENCODED) - set_ns_and_type(ret, type); - return ret; -} - -/* Null encode/decode */ -zval *to_zval_null(encodeType type, xmlNodePtr data) -{ - zval *ret; - MAKE_STD_ZVAL(ret); - ZVAL_NULL(ret); - return ret; -} - -xmlNodePtr to_xml_null(encodeType type, zval *data, int style) -{ - xmlNodePtr ret; - - ret = xmlNewNode(NULL, "BOGUS"); - FIND_ZVAL_NULL(data, ret); - - if(style == SOAP_ENCODED) - xmlSetProp(ret, "xsi:null", "1"); - return ret; -} - -/* Struct encode/decode */ -zval *to_zval_object(encodeType type, xmlNodePtr data) -{ - zval *ret; - xmlNodePtr trav; - encodePtr enc; - TSRMLS_FETCH(); - - MAKE_STD_ZVAL(ret); - FIND_XML_NULL(data, ret); - - object_init(ret); - trav = data->children; - - enc = get_conversion(UNKNOWN_TYPE); - do - { - if(trav->type == XML_ELEMENT_NODE) - { - zval *tmpVal; - - tmpVal = master_to_zval(enc, trav); - add_property_zval(ret, (char *)trav->name, tmpVal); - } - } - while(trav = trav->next); - - return ret; -} - -xmlNodePtr to_xml_object(encodeType type, zval *data, int style) -{ - xmlNodePtr xmlParam; - HashTable *prop; - int i; - TSRMLS_FETCH(); - - /* Special handling of class SoapVar */ - if(data && Z_TYPE_P(data) == IS_OBJECT && !strcmp(Z_OBJCE_P(data)->name, soap_var_class_entry.name)) - { - zval **ztype, **zdata, **zns, **zstype, **zname, **znamens; - encodePtr enc; - - if(zend_hash_find(Z_OBJPROP_P(data), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) - php_error(E_ERROR, "error encoding SoapVar"); - if(zend_hash_find(Z_OBJPROP_P(data), "enc_value", sizeof("enc_value"), (void **)&zdata) == FAILURE) - php_error(E_ERROR, "error encoding SoapVar"); - - enc = get_conversion(Z_LVAL_P(*ztype)); - xmlParam = master_to_xml(enc, *zdata, style); - - if(zend_hash_find(Z_OBJPROP_P(data), "enc_stype", sizeof("enc_stype"), (void **)&zstype) == SUCCESS) - { - if(zend_hash_find(Z_OBJPROP_P(data), "enc_ns", sizeof("enc_ns"), (void **)&zns) == SUCCESS) - set_ns_and_type_ex(xmlParam, Z_STRVAL_PP(zns), Z_STRVAL_PP(zstype)); - else - set_ns_and_type_ex(xmlParam, NULL, Z_STRVAL_PP(zstype)); - } - - if(zend_hash_find(Z_OBJPROP_P(data), "enc_name", sizeof("enc_name"), (void **)&zname) == SUCCESS) - xmlNodeSetName(xmlParam, Z_STRVAL_PP(zname)); - if(zend_hash_find(Z_OBJPROP_P(data), "enc_namens", sizeof("enc_namens"), (void **)&znamens) == SUCCESS) - { - smart_str *ns; - xmlNsPtr nsp; - - ns = encode_new_ns(); - nsp = xmlNewNs(xmlParam, Z_STRVAL_PP(znamens), ns->c); - xmlSetNs(xmlParam, nsp); - smart_str_free(ns); - efree(ns); - } - } - else - { - xmlParam = xmlNewNode(NULL, "BOGUS"); - FIND_ZVAL_NULL(data, xmlParam); - - if(Z_TYPE_P(data) == IS_OBJECT) - { - prop = Z_OBJPROP_P(data); - i = zend_hash_num_elements(prop); - zend_hash_internal_pointer_reset(prop); - - for(;i > 0;i--) - { - xmlNodePtr property; - encodePtr enc; - zval **zprop; - char *str_key; - - zend_hash_get_current_key(prop, &str_key, NULL, FALSE); - zend_hash_get_current_data(prop, (void **)&zprop); - - enc = get_conversion((*zprop)->type); - property = master_to_xml(enc, (*zprop), style); - - xmlNodeSetName(property, str_key); - xmlAddChild(xmlParam, property); - zend_hash_move_forward(prop); - } - } - - if(style == SOAP_ENCODED) - set_ns_and_type(xmlParam, type); - } - return xmlParam; -} - -/* Array encode/decode */ -xmlNodePtr guess_array_map(encodeType type, zval *data, int style) -{ - encodePtr enc = NULL; - TSRMLS_FETCH(); - - if(data && Z_TYPE_P(data) == IS_ARRAY) - { - if(zend_hash_num_elements(Z_ARRVAL_P(data)) > 0) - { - if(is_map(data)) - enc = get_conversion(APACHE_MAP); - else - enc = get_conversion(SOAP_ENC_ARRAY); - } - } - if(!enc) - enc = get_conversion(IS_NULL); - - return master_to_xml(enc, data, style); -} - -xmlNodePtr to_xml_array(encodeType type, zval *data, int style) -{ - smart_str array_type_and_size = {0}, array_type = {0}; - int i; - xmlNodePtr xmlParam; - TSRMLS_FETCH(); - - xmlParam = xmlNewNode(NULL,"BOGUS"); - - FIND_ZVAL_NULL(data, xmlParam); - - if(Z_TYPE_P(data) == IS_ARRAY) - { - i = zend_hash_num_elements(Z_ARRVAL_P(data)); - - if(style == SOAP_ENCODED) - { - get_array_type(data, &array_type TSRMLS_CC); - smart_str_append(&array_type_and_size, &array_type); - smart_str_appendc(&array_type_and_size, '['); - smart_str_append_long(&array_type_and_size, i); - smart_str_appendc(&array_type_and_size, ']'); - smart_str_0(&array_type_and_size); - - xmlSetProp(xmlParam, "SOAP-ENC:arrayType", array_type_and_size.c); - - smart_str_free(&array_type_and_size); - smart_str_free(&array_type); - } - - zend_hash_internal_pointer_reset(data->value.ht); - for(;i > 0;i--) - { - xmlNodePtr xparam; - zval **zdata; - encodePtr enc; - zend_hash_get_current_data(data->value.ht, (void **)&zdata); - - enc = get_conversion((*zdata)->type); - xparam = master_to_xml(enc, (*zdata), style); - - if(style == SOAP_LITERAL) - xmlNodeSetName(xparam, enc->details.type_str); - else - xmlNodeSetName(xparam, "val"); - - xmlAddChild(xmlParam, xparam); - zend_hash_move_forward(data->value.ht); - } - } - if(style == SOAP_ENCODED) - set_ns_and_type(xmlParam, type); - return xmlParam; -} - -zval *to_zval_array(encodeType type, xmlNodePtr data) -{ - zval *ret; - xmlNodePtr trav; - encodePtr enc; - TSRMLS_FETCH(); - - MAKE_STD_ZVAL(ret); - FIND_XML_NULL(data, ret); - - array_init(ret); - trav = data->children; - - enc = get_conversion(UNKNOWN_TYPE); - while(trav) - { - if(trav->type == XML_ELEMENT_NODE) - { - zval *tmpVal; - tmpVal = master_to_zval(enc, trav); - zend_hash_next_index_insert(Z_ARRVAL_P(ret), &tmpVal, sizeof(zval *), NULL); - } - trav = trav->next; - } - - return ret; -} - -/* Map encode/decode */ -xmlNodePtr to_xml_map(encodeType type, zval *data, int style) -{ - xmlNodePtr xmlParam; - int i; - TSRMLS_FETCH(); - - xmlParam = xmlNewNode(NULL, "BOGUS"); - FIND_ZVAL_NULL(data, xmlParam); - - if(Z_TYPE_P(data) == IS_ARRAY) - { - i = zend_hash_num_elements(Z_ARRVAL_P(data)); - /* TODO: Register namespace...??? */ - xmlSetProp(xmlParam, "xmlns:apache", "http://xml.apache.org/xml-soap"); - zend_hash_internal_pointer_reset(data->value.ht); - for(;i > 0;i--) - { - xmlNodePtr xparam, item; - xmlNodePtr key; - zval **temp_data; - char *key_val; - int int_val; - encodePtr enc; - - zend_hash_get_current_data(data->value.ht, (void **)&temp_data); - if(Z_TYPE_PP(temp_data) != IS_NULL) - { - item = xmlNewNode(NULL, "item"); - key = xmlNewNode(NULL, "key"); - if(zend_hash_get_current_key(data->value.ht, &key_val, (long *)&int_val, FALSE) == HASH_KEY_IS_STRING) - { - if(style == SOAP_ENCODED) - xmlSetProp(key, "xsi:type", "xsd:string"); - xmlNodeSetContent(key, key_val); - } - else - { - smart_str tmp = {0}; - smart_str_append_long(&tmp, int_val); - smart_str_0(&tmp); - - if(style == SOAP_ENCODED) - xmlSetProp(key, "xsi:type", "xsd:int"); - xmlNodeSetContentLen(key, tmp.c, tmp.len); - - smart_str_free(&tmp); - } - - - enc = get_conversion((*temp_data)->type); - xparam = master_to_xml(enc, (*temp_data), style); - - xmlNodeSetName(xparam, "value"); - xmlAddChild(item, key); - xmlAddChild(item, xparam); - xmlAddChild(xmlParam, item); - } - zend_hash_move_forward(data->value.ht); - } - } - if(style == SOAP_ENCODED) - set_ns_and_type(xmlParam, type); - - return xmlParam; -} - -zval *to_zval_map(encodeType type, xmlNodePtr data) -{ - zval *ret, *key, *value; - xmlNodePtr trav, item, xmlKey, xmlValue; - encodePtr enc; - TSRMLS_FETCH(); - - MAKE_STD_ZVAL(ret); - FIND_XML_NULL(data, ret); - - array_init(ret); - trav = data->children; - - enc = get_conversion(UNKNOWN_TYPE); - trav = data->children; - FOREACHNODE(trav, "item", item) - { - xmlKey = get_node(item->children, "key"); - if(!xmlKey) - php_error(E_ERROR, "Error encoding apache map, missing key"); - - xmlValue = get_node(item->children, "value"); - if(!xmlKey) - php_error(E_ERROR, "Error encoding apache map, missing value"); - - key = master_to_zval(enc, xmlKey); - value = master_to_zval(enc, xmlValue); - - if(Z_TYPE_P(key) == IS_STRING) - zend_hash_update(Z_ARRVAL_P(ret), Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &value, sizeof(zval *), NULL); - else if(Z_TYPE_P(key) == IS_LONG) - zend_hash_index_update(Z_ARRVAL_P(ret), Z_LVAL_P(key), &value, sizeof(zval *), NULL); - else - php_error(E_ERROR, "Error encoding apache map, only Strings or Longs are allowd as keys"); - } - ENDFOREACH(trav); - - return ret; -} - -/* Unknown encode/decode */ -xmlNodePtr guess_xml_convert(encodeType type, zval *data, int style) -{ - encodePtr enc; - TSRMLS_FETCH(); - - if(data) - enc = get_conversion(data->type); - else - enc = get_conversion(IS_NULL); - return master_to_xml(enc, data, style); -} - -zval *guess_zval_convert(encodeType type, xmlNodePtr data) -{ - encodePtr enc = NULL; - xmlAttrPtr tmpattr; - TSRMLS_FETCH(); - - data = check_and_resolve_href(data); - - if(data == NULL || data->children == NULL) - enc = get_conversion(IS_NULL); - else - { - tmpattr = get_attribute(data->properties,"type"); - if(tmpattr != NULL) - { - enc = get_conversion_from_type(data, tmpattr->children->content); - /* - if(enc == NULL) - php_error(E_ERROR, "Error (Don't know how to encode/decode \"%s\")", tmpattr->children->content); - */ - } - - if(enc == NULL) - { - /* Didn't have a type, totally guess here */ - /* Logic: has children = IS_OBJECT else IS_STRING */ - xmlNodePtr trav; - - if(get_attribute(data->properties, "arrayType")) - enc = get_conversion(SOAP_ENC_ARRAY); - else - { - enc = get_conversion(XSD_STRING); - trav = data->children; - do - { - if(trav->type == XML_ELEMENT_NODE) - { - enc = get_conversion(SOAP_ENC_OBJECT); - break; - } - } - while(trav = trav->next); - } - } - } - return master_to_zval(enc, data); -} - -/* Time encode/decode */ -xmlNodePtr to_xml_datetime_ex(encodeType type, zval *data, char *format, int style) -{ - /* logic hacked from ext/standard/datetime.c */ - struct tm *ta, tmbuf; - time_t timestamp; - int max_reallocs = 5; - size_t buf_len=64, real_len; - char *buf; - xmlNodePtr xmlParam; - - xmlParam = xmlNewNode(NULL, "BOGUS"); - FIND_ZVAL_NULL(data, xmlParam); - - timestamp = Z_LVAL_P(data); - - time(×tamp); - ta = php_localtime_r(×tamp, &tmbuf); - - buf = (char *) emalloc(buf_len); - while ((real_len = strftime(buf, buf_len, format, ta)) == buf_len || real_len == 0) - { - buf_len *= 2; - buf = (char *) erealloc(buf, buf_len); - if(!--max_reallocs) break; - } - - xmlNodeSetContent(xmlParam, buf); - efree(buf); - - if(style == SOAP_ENCODED) - set_ns_and_type(xmlParam, type); - return xmlParam; -} - -xmlNodePtr to_xml_datetime(encodeType type, zval *data, int style) -{ - return to_xml_datetime_ex(type, data, "%Y-%m-%dT%H:%M:%S", style); -} - -xmlNodePtr to_xml_time(encodeType type, zval *data, int style) -{ - return to_xml_datetime_ex(type, data, "%H:%M:%S", style); -} - -xmlNodePtr to_xml_date(encodeType type, zval *data, int style) -{ - return to_xml_datetime_ex(type, data, "%Y-%m-%d", style); -} - -xmlNodePtr to_xml_gyearmonth(encodeType type, zval *data, int style) -{ - return to_xml_datetime_ex(type, data, "%Y-%m", style); -} - -xmlNodePtr to_xml_gyear(encodeType type, zval *data, int style) -{ - return to_xml_datetime_ex(type, data, "%Y", style); -} - -xmlNodePtr to_xml_gmonthday(encodeType type, zval *data, int style) -{ - return to_xml_datetime_ex(type, data, "--%m-%d", style); -} - -xmlNodePtr to_xml_gday(encodeType type, zval *data, int style) -{ - return to_xml_datetime_ex(type, data, "%d", style); -} - -xmlNodePtr to_xml_gmonth(encodeType type, zval *data, int style) -{ - return to_xml_datetime_ex(type, data, "%m", style); -} - -void set_ns_and_type(xmlNodePtr node, encodeType type) -{ - set_ns_and_type_ex(node, type.ns, type.type_str); -} - -void set_ns_and_type_ex(xmlNodePtr node, char *ns, char *type) -{ - if(ns != NULL) - { - char *sprefix; - smart_str *prefix; - smart_str xmlns = {0}, nstype = {0}; - - TSRMLS_FETCH(); - - if(zend_hash_find(SOAP_GLOBAL(defEncNs), ns, strlen(ns) + 1, (void **)&sprefix) == FAILURE) - { - prefix = encode_new_ns(); - smart_str_appendl(&xmlns, "xmlns:", 6); - smart_str_append(&xmlns, prefix); - smart_str_0(&xmlns); - - xmlSetProp(node, xmlns.c, ns); - } - else - { - prefix = emalloc(sizeof(smart_str)); - memset(prefix, 0, sizeof(smart_str)); - smart_str_appends(prefix, sprefix); - } - - smart_str_append(&nstype, prefix); - smart_str_appendc(&nstype, ':'); - smart_str_appends(&nstype, type); - smart_str_0(&nstype); - xmlSetProp(node, "xsi:type", nstype.c); - smart_str_free(&nstype); - smart_str_free(&xmlns); - smart_str_free(prefix); - efree(prefix); - } - else - xmlSetProp(node, "xsi:type", type); -} - -smart_str *encode_new_ns() -{ - int num; - smart_str *ns = emalloc(sizeof(smart_str)); - - TSRMLS_FETCH(); - - memset(ns, 0, sizeof(smart_str)); - num = ++SOAP_GLOBAL(cur_uniq_ns); - smart_str_appendl(ns, "ns", 2); - smart_str_append_long(ns, num); - smart_str_0(ns); - return ns; -} - -void encode_reset_ns() -{ - TSRMLS_FETCH(); - SOAP_GLOBAL(cur_uniq_ns) = 0; -} - -encodePtr get_conversion_ex(HashTable *encoding, int encode) -{ - encodePtr *enc; - TSRMLS_FETCH(); - - if(zend_hash_index_find(encoding, encode, (void **)&enc) == FAILURE) - php_error(E_ERROR, "Cannot find encoding"); - - if(SOAP_GLOBAL(overrides)) - { - smart_str nscat = {0}; - - smart_str_appendl(&nscat, (*enc)->details.ns, strlen((*enc)->details.ns)); - smart_str_appendc(&nscat, ':'); - smart_str_appendl(&nscat, (*enc)->details.type_str, strlen((*enc)->details.type_str)); - smart_str_0(&nscat); - - zend_hash_find(SOAP_GLOBAL(overrides), nscat.c, nscat.len + 1, (void **)&enc); - smart_str_free(&nscat); - } - - return *enc; -} - -encodePtr get_conversion_from_href_type_ex(HashTable *encoding, char *type, int len) -{ - encodePtr *enc = NULL; - - if(encoding == NULL) - return NULL; - - if(zend_hash_find(encoding, type, len + 1, (void **)&enc) == FAILURE) - return NULL; - - return (*enc); -} - -encodePtr get_conversion_from_type_ex(HashTable *encoding, xmlNodePtr node, char *type) -{ - encodePtr *enc = NULL; - xmlNsPtr nsptr; - char *ns, *cptype; - smart_str nscat = {0}; - - if(encoding == NULL) - return NULL; - - parse_namespace(type, &cptype, &ns); - nsptr = xmlSearchNs(node->doc, node, ns); - if(nsptr != NULL) - { - smart_str_appends(&nscat, nsptr->href); - smart_str_appendc(&nscat, ':'); - smart_str_appends(&nscat, cptype); - smart_str_0(&nscat); - - if(zend_hash_find(encoding, nscat.c, nscat.len + 1, (void **)&enc) == FAILURE) - { - if(zend_hash_find(encoding, type, strlen(type) + 1, (void **)&enc) == FAILURE) - enc = NULL; - } - smart_str_free(&nscat); - } - else - { - if(zend_hash_find(encoding, type, strlen(type) + 1, (void **)&enc) == FAILURE) - enc = NULL; - } - - if(cptype) efree(cptype); - if(ns) efree(ns); - if(enc == NULL) - return NULL; - else - return (*enc); -} - -int is_map(zval *array) -{ - int i, count = zend_hash_num_elements(Z_ARRVAL_P(array)); - for(i = 0;i < count;i++) - { - if(zend_hash_get_current_key_type(Z_ARRVAL_P(array)) == HASH_KEY_IS_STRING) - return TRUE; - zend_hash_move_forward(Z_ARRVAL_P(array)); - } - return FALSE; -} - -void get_array_type(zval *array, smart_str *type TSRMLS_DC) -{ - HashTable *ht = HASH_OF(array); - int i, count, cur_type, prev_type, different; - char *name = NULL; - zval **tmp; -/* TSRMLS_FETCH();*/ - - if(!array || Z_TYPE_P(array) != IS_ARRAY) - smart_str_appendl(type, "xsd:ur-type", 11); - - different = FALSE; - cur_type = prev_type = 0; - count = zend_hash_num_elements(ht); - - zend_hash_internal_pointer_reset(ht); - for(i = 0;i < count;i++) - { - zend_hash_get_current_data(ht, (void **)&tmp); - - if(Z_TYPE_PP(tmp) == IS_OBJECT && !strcmp(Z_OBJCE_PP(tmp)->name, soap_var_class_entry.name)) - { - zval **ztype; - - if(zend_hash_find(Z_OBJPROP_PP(tmp), "enc_type", sizeof("enc_type"), (void **)&ztype) == FAILURE) - php_error(E_ERROR, "error encoding SoapVar"); - cur_type = Z_LVAL_P(*ztype); - } - else if(Z_TYPE_PP(tmp) == IS_ARRAY && is_map(*tmp)) - cur_type = APACHE_MAP; - else - cur_type = Z_TYPE_PP(tmp); - - if(i > 0) - { - if(cur_type != prev_type) - { - different = TRUE; - break; - } - } - - prev_type = cur_type; - zend_hash_move_forward(ht); - } - - if(different) - smart_str_appendl(type, "xsd:ur-type", 11); - else - { - encodePtr enc; - char *prefix; - - enc = get_conversion(cur_type); - - if(enc->details.ns != NULL) - { - if(zend_hash_find(SOAP_GLOBAL(defEncNs), enc->details.ns, strlen(enc->details.ns) + 1, (void **)&prefix) == FAILURE) - php_error(E_ERROR, "fix me"); - - smart_str_appendl(type, prefix, strlen(prefix)); - smart_str_appendc(type, ':'); - smart_str_appendl(type, enc->details.type_str, strlen(enc->details.type_str)); - smart_str_0(type); - } - else - smart_str_appendl(type, enc->details.type_str, strlen(enc->details.type_str)); - } -} - - -smart_str *build_soap_action(zval *this_ptr, char *soapaction) -{ - zval **uri; - smart_str *tmp; - - tmp = emalloc(sizeof(smart_str)); - memset(tmp, 0, sizeof(smart_str)); - - if(zend_hash_find(Z_OBJPROP_P(this_ptr), "uri", sizeof("uri"), (void *)&uri) == FAILURE) - php_error(E_ERROR, "Error finding uri"); - - smart_str_appendl(tmp, Z_STRVAL_PP(uri), Z_STRLEN_PP(uri)); - smart_str_appends(tmp, "#"); - smart_str_appendl(tmp, soapaction, strlen(soapaction)); - smart_str_0(tmp); - - return tmp; -} - -void delete_encoder(void *encode) -{ - encodePtr t = *((encodePtr*)encode); - if(t->details.ns) - free(t->details.ns); - if(t->details.type_str) - free(t->details.type_str); - if(t->details.map) - delete_mapping(t->details.map); - free(t); -} - diff --git a/ext/soap/php_encoding.h b/ext/soap/php_encoding.h deleted file mode 100644 index 4a9bfc72a5..0000000000 --- a/ext/soap/php_encoding.h +++ /dev/null @@ -1,256 +0,0 @@ -#ifndef PHP_ENCODING_H -#define PHP_ENCODING_H - -#define XSD_1999_NAMESPACE "http://www.w3.org/1999/XMLSchema" -#define XSD_1999_TIMEINSTANT 401 -#define XSD_1999_TIMEINSTANT_STRING "timeInstant" - -#define XSD_NAMESPACE "http://www.w3.org/2001/XMLSchema" -#define XSD_NS_PREFIX "xsd" -#define XSD_STRING 101 -#define XSD_STRING_STRING "string" -#define XSD_BOOLEAN 103 -#define XSD_BOOLEAN_STRING "boolean" -#define XSD_DECIMAL 104 -#define XSD_DECIMAL_STRING "decimal" -#define XSD_FLOAT 105 -#define XSD_FLOAT_STRING "float" -#define XSD_DOUBLE 106 -#define XSD_DOUBLE_STRING "double" -#define XSD_DURATION 107 -#define XSD_DURATION_STRING "duration" -#define XSD_DATETIME 108 -#define XSD_DATETIME_STRING "dateTime" -#define XSD_TIME 109 -#define XSD_TIME_STRING "time" -#define XSD_DATE 110 -#define XSD_DATE_STRING "date" -#define XSD_GYEARMONTH 111 -#define XSD_GYEARMONTH_STRING "gYearMonth" -#define XSD_GYEAR 112 -#define XSD_GYEAR_STRING "gYear" -#define XSD_GMONTHDAY 113 -#define XSD_GMONTHDAY_STRING "gMonthDay" -#define XSD_GDAY 114 -#define XSD_GDAY_STRING "gDay" -#define XSD_GMONTH 115 -#define XSD_GMONTH_STRING "gMonth" -#define XSD_HEXBINARY 116 -#define XSD_HEXBINARY_STRING "hexBinary" -#define XSD_BASE64BINARY 117 -#define XSD_BASE64BINARY_STRING "base64Binary" -#define XSD_ANYURI 118 -#define XSD_ANYURI_STRING "anyURI" -#define XSD_QNAME 119 -#define XSD_QNAME_STRING "QName" -#define XSD_NOTATION 120 -#define XSD_NOTATION_STRING "NOTATION" -#define XSD_NORMALIZEDSTRING 121 -#define XSD_NORMALIZEDSTRING_STRING "normalizedString" -#define XSD_TOKEN 122 -#define XSD_TOKEN_STRING "token" -#define XSD_LANGUAGE 123 -#define XSD_LANGUAGE_STRING "language" -#define XSD_NMTOKEN 124 -#define XSD_NMTOKEN_STRING "NMTOKEN" -#define XSD_NAME 124 -#define XSD_NAME_STRING "Name" -#define XSD_NCNAME 125 -#define XSD_NCNAME_STRING "NCName" -#define XSD_ID 126 -#define XSD_ID_STRING "ID" -#define XSD_IDREF 127 -#define XSD_IDREF_STRING "IDREF" -#define XSD_IDREFS 127 -#define XSD_IDREFS_STRING "IDREFS" -#define XSD_ENTITY 128 -#define XSD_ENTITY_STRING "ENTITY" -#define XSD_ENTITYS 129 -#define XSD_ENTITYS_STRING "ENTITYS" -#define XSD_INTEGER 130 -#define XSD_INTEGER_STRING "integer" -#define XSD_NONPOSITIVEINTEGER 131 -#define XSD_NONPOSITIVEINTEGER_STRING "nonPositiveInteger" -#define XSD_NEGATIVEINTEGER 132 -#define XSD_NEGATIVEINTEGER_STRING "negativeInteger" -#define XSD_LONG 133 -#define XSD_LONG_STRING "long" -#define XSD_INT 134 -#define XSD_INT_STRING "int" -#define XSD_SHORT 135 -#define XSD_SHORT_STRING "short" -#define XSD_BYTE 136 -#define XSD_BYTE_STRING "byte" -#define XSD_NONNEGATIVEINTEGER 137 -#define XSD_NONNEGATIVEINTEGER_STRING "nonNegativeInteger" -#define XSD_UNSIGNEDLONG 138 -#define XSD_UNSIGNEDLONG_STRING "unsignedLong" -#define XSD_UNSIGNEDINT 139 -#define XSD_UNSIGNEDINT_STRING "unsignedInt" -#define XSD_UNSIGNEDSHORT 140 -#define XSD_UNSIGNEDSHORT_STRING "unsignedShort" -#define XSD_UNSIGNEDBYTE 141 -#define XSD_UNSIGNEDBYTE_STRING "unsignedByte" -#define XSD_POSITIVEINTEGER 142 -#define XSD_POSITIVEINTEGER_STRING "positiveInteger" - -#define APACHE_NAMESPACE "http://xml.apache.org/xml-soap" -#define APACHE_NS_PREFIX "apache" -#define APACHE_MAP 200 -#define APACHE_MAP_STRING "Map" - -#define SOAP_ENC_NAMESPACE "http://schemas.xmlsoap.org/soap/encoding/" -#define SOAP_ENC_NS_PREFIX "SOAP-ENC" -#define SOAP_ENC_ARRAY 300 -#define SOAP_ENC_ARRAY_STRING "Array" -#define SOAP_ENC_OBJECT 301 -#define SOAP_ENC_OBJECT_STRING "Struct" - -#define SCHEMA_NAMESPACE "http://www.w3.org/2001/XMLSchema" -#define SCHEMA_NS_PREFIX "s" - -#define WSDL_NAMESPACE "http://schemas.xmlsoap.org/wsdl/" -#define WSDL_NS_PREFIX "wsdl" - -#define WSDL_SOAP_NAMESPACE "http://schemas.xmlsoap.org/wsdl/soap/" -#define WSDL_SOAP_NS_PREFIX "wsdlSoap" - -#define WSDL_HTTP_NAMESPACE "http://schemas.xmlsoap.org/wsdl/http/" -#define WSDL_HTTP_NS_PREFIX "http" - -#define WSDL_HTTP_TRANSPORT "http://schemas.xmlsoap.org/soap/http" - -#define UNKNOWN_TYPE 999998 -#define END_KNOWN_TYPES 999999 - -struct _encodeType -{ - int type; - char *type_str; - char *ns; - sdlTypePtr sdl_type; - soapMappingPtr map; -}; - -struct _encode -{ - encodeType details; - zval *(*to_zval)(encodeType type, xmlNodePtr data); - xmlNodePtr (*to_xml)(encodeType type, zval *data, int style); - - xmlNodePtr (*to_zval_before)(encodeType type, xmlNodePtr data, int style); - zval *(*to_zval_after)(encodeType type, zval *data); - - zval *(*to_xml_before)(encodeType type, zval *data); - xmlNodePtr (*to_xml_after)(encodeType type, xmlNodePtr data, int style); -}; - -smart_str *build_soap_action(zval *this_ptr, char *soapaction); - -/* Master functions all encode/decode should be called thur these functions */ -xmlNodePtr master_to_xml(encodePtr encode, zval *data, int style); -zval *master_to_zval(encodePtr encode, xmlNodePtr data); - -#ifdef HAVE_PHP_DOMXML -/* user defined mapping */ -zval *to_xml_before_user(encodeType type, zval *data); -xmlNodePtr to_xml_user(encodeType type, zval *data, int style); -xmlNodePtr to_xml_after_user(encodeType type, xmlNodePtr node, int style); -xmlNodePtr to_zval_before_user(encodeType type, xmlNodePtr node, int style); -zval *to_zval_user(encodeType type, xmlNodePtr node); -zval *to_zval_after_user(encodeType type, zval *data); -#endif - -/* zval type decode */ -zval *to_zval_double(encodeType type, xmlNodePtr data); -zval *to_zval_long(encodeType type, xmlNodePtr data); -zval *to_zval_bool(encodeType type, xmlNodePtr data); -zval *to_zval_object(encodeType type, xmlNodePtr data); -zval *to_zval_string(encodeType type, xmlNodePtr data); -zval *to_zval_array(encodeType type, xmlNodePtr data); -zval *to_zval_map(encodeType type, xmlNodePtr data); -zval *to_zval_null(encodeType type, xmlNodePtr data); -zval *guess_zval_convert(encodeType type, xmlNodePtr data); - -xmlNodePtr to_xml_long(encodeType type, zval *data, int style); -xmlNodePtr to_xml_bool(encodeType type, zval *data, int style); - -/* String encode */ -xmlNodePtr to_xml_string(encodeType type, zval *data, int style); -xmlNodePtr to_xml_stringl(encodeType type, zval *data, int style); - -/* Null encode */ -xmlNodePtr to_xml_null(encodeType type, zval *data, int style); - -/* Struct encode */ -xmlNodePtr to_xml_object(encodeType type, zval *data, int style); - -/* Array encode */ -xmlNodePtr guess_array_map(encodeType type, zval *data, int style); -xmlNodePtr to_xml_array(encodeType type, zval *data, int style); -xmlNodePtr to_xml_map(encodeType type, zval *data, int style); - -/* Try and guess for non-wsdl clients and servers */ -xmlNodePtr guess_xml_convert(encodeType type, zval *data, int style); - -/* Datetime encode/decode */ -xmlNodePtr to_xml_datetime_ex(encodeType type, zval *data, char *format, int style); -xmlNodePtr to_xml_datetime(encodeType type, zval *data, int style); -xmlNodePtr to_xml_time(encodeType type, zval *data, int style); -xmlNodePtr to_xml_date(encodeType type, zval *data, int style); -xmlNodePtr to_xml_gyearmonth(encodeType type, zval *data, int style); -xmlNodePtr to_xml_gyear(encodeType type, zval *data, int style); -xmlNodePtr to_xml_gmonthday(encodeType type, zval *data, int style); -xmlNodePtr to_xml_gday(encodeType type, zval *data, int style); -xmlNodePtr to_xml_gmonth(encodeType type, zval *data, int style); - -#define get_conversion(e) get_conversion_ex(SOAP_GLOBAL(defEncIndex), e) -#define get_conversion_from_type(n, t) get_conversion_from_type_ex(SOAP_GLOBAL(defEnc), n, t) -#define get_conversion_from_href_type(t) get_conversion_from_href_type_ex(SOAP_GLOBAL(defEnc), t, strlen(t)) - -void encode_reset_ns(); -smart_str *encode_new_ns(); - -void set_ns_and_type(xmlNodePtr node, encodeType type); -void set_ns_and_type_ex(xmlNodePtr node, char *ns, char *type); -encodePtr get_conversion_ex(HashTable *encoding, int encode); -encodePtr get_conversion_from_type_ex(HashTable *encoding, xmlNodePtr node, char *type); -encodePtr get_conversion_from_href_type_ex(HashTable *encoding, char *type, int len); - -int is_map(zval *array); -void get_array_type(zval *array, smart_str *out_type TSRMLS_DC); - -void delete_encoder(void *handle); - -extern encode defaultEncoding[]; - -#define FIND_XML_NULL(xml,zval) \ - { \ - xmlAttrPtr null; \ - if(!xml || !xml->children) \ - { \ - ZVAL_NULL(zval); \ - return zval; \ - } \ - if(xml->properties) \ - { \ - null = get_attribute(xml->properties, "null"); \ - if(null) \ - { \ - ZVAL_NULL(zval); \ - return zval; \ - } \ - } \ - } - -#define FIND_ZVAL_NULL(zval, xml) \ -{ \ - if(!zval) \ - { \ - xmlSetProp(xml, "xsi:null", "1"); \ - return xml; \ - } \ -} - - -#endif diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c deleted file mode 100644 index 5f68e94e84..0000000000 --- a/ext/soap/php_http.c +++ /dev/null @@ -1,456 +0,0 @@ -#include "php_soap.h" - -void send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *function_name, char *soapaction TSRMLS_DC) -{ - xmlChar *buf; - char *soap_headers; - int buf_size,err,ret; - sdlPtr sdl; - php_url *phpurl = NULL; - php_stream *stream; - zval **trace; - - FETCH_THIS_SOCKET(stream); - FETCH_THIS_URL(phpurl); - FETCH_THIS_SDL(sdl); - - xmlDocDumpMemory(doc, &buf, &buf_size); - - if(!buf) - php_error(E_ERROR, "Error build soap request"); - - if(zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS - && Z_LVAL_PP(trace) > 0) - add_property_stringl(this_ptr, "__last_request", buf, buf_size, 1); - - if(!stream) - { - char *url; - int use_ssl; - - if(!sdl) - { - zval **location; - if(zend_hash_find(Z_OBJPROP_P(this_ptr), "location", sizeof("location"),(void **) &location) == FAILURE) - php_error(E_ERROR, "Error could not find location"); - url = Z_STRVAL_PP(location); - } - else - { - sdlBindingPtr binding; - FETCH_THIS_PORT(binding); - url = binding->location; - } - - phpurl = php_url_parse(url); - if (phpurl == NULL) { - php_error(E_ERROR, "Unable to parse URL \"%s\"", url); - } - - use_ssl = strcmp(phpurl->scheme, "https") == 0; -#if !HAVE_OPENSSL_EXT - if (use_ssl) { - php_error(E_ERROR, "SSL support not available in this build"); - } -#endif - - if (phpurl->port == 0) { - phpurl->port = use_ssl ? 443 : 80; - } - - stream = php_stream_sock_open_host(phpurl->host, (unsigned short)phpurl->port, SOCK_STREAM, NULL, NULL); - - if(stream) - { - -#if HAVE_OPENSSL_EXT - /* fire up SSL, if requested */ - if (use_ssl) { - if (FAILURE == php_stream_sock_ssl_activate(stream, 1)) { - php_error(E_ERROR, "SSL Connection attempt failed"); - } - } -#endif - - add_property_resource(this_ptr, "httpsocket", php_stream_get_resource_id(stream)); - - ret = zend_list_insert(phpurl, le_url); - add_property_resource(this_ptr, "httpurl", ret); - zend_list_addref(ret); - } else { - php_error(E_ERROR, "Could not connect to host"); - } - } - - if (stream) { - zval **cookies; - char *header = "POST %s HTTP/1.1\r\nConnection: close\r\nAccept: text/html; text/xml; text/plain\r\nUser-Agent: PHP SOAP 0.1\r\nHost: %s\r\nContent-Type: text/xml\r\nContent-Length: %d\r\nSOAPAction: \"%s\"\r\n"; - int size = strlen(header) + strlen(phpurl->host) + strlen(phpurl->path) + 10; - - /* TODO: Add authentication */ - if(sdl != NULL) - { - /* TODO: need to grab soap action from wsdl....*/ - soap_headers = emalloc(size + strlen(soapaction)); - sprintf(soap_headers, header, phpurl->path, phpurl->host, buf_size, soapaction); - } - else - { - soap_headers = emalloc(size + strlen(soapaction)); - sprintf(soap_headers, header, phpurl->path, phpurl->host, buf_size, soapaction); - } - - err = php_stream_write(stream, soap_headers, strlen(soap_headers)); - - if(err != (int)strlen(soap_headers)) - php_error(E_ERROR,"Failed Sending HTTP Headers"); - - /* Send cookies along with request */ - if(zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == SUCCESS) - { - smart_str cookie_str = {0}; - zval **data; - char *key; - int index, i; - - zend_hash_internal_pointer_reset(Z_ARRVAL_PP(cookies)); - for(i = 0;i < (int)Z_ARRVAL_PP(cookies)->nNumOfElements;i++) - { - zend_hash_get_current_data(Z_ARRVAL_PP(cookies), (void **)&data); - zend_hash_get_current_key(Z_ARRVAL_PP(cookies), &key, (long *)&index, FALSE); - - smart_str_appendl(&cookie_str, "Cookie: ", 8); - smart_str_appendl(&cookie_str, key, strlen(key)); - smart_str_appendc(&cookie_str, '='); - smart_str_appendl(&cookie_str, Z_STRVAL_PP(data), Z_STRLEN_PP(data)); - smart_str_appendc(&cookie_str, ';'); - zend_hash_move_forward(Z_ARRVAL_PP(cookies)); - } - smart_str_appendl(&cookie_str, "\r\n", 2); - smart_str_0(&cookie_str); - - err = php_stream_write(stream, cookie_str.c, cookie_str.len); - - if(err != (int)cookie_str.len) - php_error(E_ERROR,"Failed Sending HTTP Headers"); - - smart_str_free(&cookie_str); - } - - err = php_stream_write(stream, "\r\n", 2); - - if(err != 2) - php_error(E_ERROR,"Failed Sending HTTP Headers"); - - - err = php_stream_write(stream, buf, buf_size); - - if(err != (int)strlen(buf)) - php_error(E_ERROR,"Failed Sending HTTP Content"); - - efree(soap_headers); - } - xmlFree(buf); -} - -void get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len TSRMLS_DC) -{ - char *http_headers, *http_body, *content_type, *http_version, http_status[4], *cookie_itt; - int http_header_size, http_body_size, http_close; - sdlPtr sdl; - zval **socket_ref; - php_stream *stream; - zval **trace; - - FETCH_THIS_SDL(sdl); - - if(FIND_SOCKET_PROPERTY(this_ptr, socket_ref) != FAILURE) - { - FETCH_SOCKET_RES(stream, socket_ref); - } - - if(!get_http_headers(stream, &http_headers, &http_header_size TSRMLS_CC)) - php_error(E_ERROR, "Error Fetching http headers"); - - /* Check to see what HTTP status was sent */ - http_version = get_http_header_value(http_headers,"HTTP/"); - if(http_version) - { - char *tmp; - - tmp = strstr(http_version," "); - - if(tmp != NULL) - { - tmp++; - strncpy(http_status,tmp,4); - http_status[3] = '\0'; - } - - /* - Try and process any respsone that is xml might contain fault code - - Maybe try and test for some of the 300's 400's specfics but not - right now. - - if(strcmp(http_status,"200")) - { - zval *err; - char *http_err; - - MAKE_STD_ZVAL(err); - ZVAL_STRING(err, http_body, 1); - http_err = emalloc(strlen("HTTP request failed ()") + 4); - sprintf(http_err, "HTTP request failed (%s)", http_status); - add_soap_fault(thisObj, "SOAP-ENV:Client", http_err, NULL, err TSRMLS_CC); - efree(http_err); - return; - }*/ - - /* Try and get headers again */ - if(!strcmp(http_status, "100")) - { - if(!get_http_headers(stream, &http_headers, &http_header_size TSRMLS_CC)) - php_error(E_ERROR, "Error Fetching http headers"); - } - - efree(http_version); - } - - if(!get_http_body(stream, http_headers, &http_body, &http_body_size TSRMLS_CC)) - php_error(E_ERROR, "Error Fetching http body"); - - if(zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS - && Z_LVAL_PP(trace) > 0) - add_property_stringl(this_ptr, "__last_response", http_body, http_body_size, 1); - - /* Close every time right now till i can spend more time on it - it works.. it's just slower?? - */ - /* See if the server requested a close */ - http_close = TRUE; - /* - connection = get_http_header_value(http_headers,"Connection: "); - if(connection) - { - if(!strcmp(connection, "Keep-Alive")) - http_close = FALSE; - efree(connection); - } - else - { - if(!strncmp(http_version,"1.1", 3)) - http_close = FALSE; - } - */ - - if (http_close) { - php_stream_close(stream); - zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket")); - } - - /* Check and see if the server even sent a xml document */ - content_type = get_http_header_value(http_headers,"Content-Type: "); - if(content_type) - { - char *pos = NULL; - int cmplen; - pos = strstr(content_type,";"); - if(pos != NULL) - cmplen = pos - content_type; - else - cmplen = strlen(content_type); - - if(strncmp(content_type, "text/xml", cmplen)) - { - if(strncmp(http_body, "<?xml", 5)) - { - zval *err; - MAKE_STD_ZVAL(err); - ZVAL_STRINGL(err, http_body, http_body_size, 1); - add_soap_fault(this_ptr, "SOAP-ENV:Client", "Didn't recieve an xml document", NULL, err TSRMLS_CC); - efree(content_type); - return; - } - } - efree(content_type); - } - - /* Grab and send back every cookie */ - - /* Not going to worry about Path: because - we shouldn't be changing urls so path dont - matter too much - */ - cookie_itt = strstr(http_headers,"Set-Cookie: "); - while(cookie_itt) - { - char *end_pos, *cookie; - char *eqpos, *sempos; - smart_str name = {0}, value = {0}; - zval **cookies, *z_cookie; - - if(zend_hash_find(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), (void **)&cookies) == FAILURE) - { - zval *tmp_cookies; - MAKE_STD_ZVAL(tmp_cookies); - array_init(tmp_cookies); - zend_hash_update(Z_OBJPROP_P(this_ptr), "_cookies", sizeof("_cookies"), &tmp_cookies, sizeof(zval *), (void **)&cookies); - } - - end_pos = strstr(cookie_itt,"\r\n"); - cookie = get_http_header_value(cookie_itt,"Set-Cookie: "); - - eqpos = strstr(cookie, "="); - sempos = strstr(cookie, ";"); - - smart_str_appendl(&name, cookie, eqpos - cookie); - smart_str_0(&name); - - smart_str_appendl(&value, eqpos + 1, sempos - (eqpos + 1)); - smart_str_0(&value); - - MAKE_STD_ZVAL(z_cookie); - ZVAL_STRINGL(z_cookie, value.c, value.len, 1); - - zend_hash_update(Z_ARRVAL_PP(cookies), name.c, name.len + 1, &z_cookie, sizeof(zval *), NULL); - - cookie_itt = strstr(cookie_itt + sizeof("Set-Cookie: "), "Set-Cookie: "); - - smart_str_free(&value); - smart_str_free(&name); - efree(cookie); - cookie_itt = FALSE; - } - - *buffer = http_body; - *buffer_len = http_body_size; - efree(http_headers); -} - -char *get_http_header_value(char *headers, char *type) -{ - char *pos, *tmp = NULL; - int typelen, headerslen; - - typelen = strlen(type); - headerslen = strlen(headers); - - /* header `titles' can be lower case, or any case combination, according - * to the various RFC's. */ - pos = headers; - do { - /* start of buffer or start of line */ - if (strncasecmp(pos, type, typelen) == 0) { - char *eol; - - /* match */ - tmp = pos + typelen; - eol = strstr(tmp, "\r\n"); - if (eol == NULL) { - eol = headers + headerslen; - } - return estrndup(tmp, eol - tmp); - } - - /* find next line */ - pos = strstr(pos, "\r\n"); - if (pos) - pos += 2; - - } while (pos); - - return NULL; -} - -int get_http_body(php_stream *stream, char *headers, char **response, int *out_size TSRMLS_DC) -{ - char *trans_enc, *content_length, *http_buf = NULL; - int http_buf_size = 0; - - trans_enc = get_http_header_value(headers, "Transfer-Encoding: "); - content_length = get_http_header_value(headers, "Content-Length: "); - - if (trans_enc && !strcmp(trans_enc, "chunked")) { - int cur = 0, size = 0, buf_size = 0, len_size; - char done, chunk_size[10]; - - done = FALSE; - http_buf = NULL; - - while (!done) { - php_stream_gets(stream, chunk_size, sizeof(chunk_size)); - - if (sscanf(chunk_size, "%x", &buf_size) != -1) { - http_buf = erealloc(http_buf, http_buf_size + buf_size + 1); - len_size = 0; - - while (http_buf_size < buf_size) { - len_size += php_stream_read(stream, http_buf + http_buf_size, buf_size - len_size); - http_buf_size += len_size; - } - - /* Eat up '\r' '\n' */ - php_stream_getc(stream);php_stream_getc(stream); - } - if (buf_size == 0) { - done = TRUE; - } - } - efree(trans_enc); - - if (http_buf == NULL) { - http_buf = estrndup("", 1); - http_buf_size = 1; - } else { - http_buf[http_buf_size] = '\0'; - } - - } else if (content_length) { - int size; - size = atoi(content_length); - http_buf = emalloc(size + 1); - - while(http_buf_size < size) { - http_buf_size += php_stream_read(stream, http_buf + http_buf_size, size - http_buf_size); - } - http_buf[size] = '\0'; - efree(content_length); - } else { - php_error(E_ERROR, "Don't know how to read http body, No Content-Length or chunked data"); - } - - (*response) = http_buf; - (*out_size) = http_buf_size; - return TRUE; -} - -int get_http_headers(php_stream *stream, char **response, int *out_size TSRMLS_DC) -{ - int done = FALSE; - char chr; - smart_str tmp_response = {0}; - char headerbuf[8192]; - - while(!done) - { - if (!php_stream_gets(stream, headerbuf, sizeof(headerbuf))) { - break; - } - - if (strcmp(headerbuf, "\r\n") == 0) { - /* empty line marks end of headers */ - done = TRUE; - break; - } - - /* add header to collection */ - smart_str_appends(&tmp_response, headerbuf); - } - smart_str_0(&tmp_response); - (*response) = tmp_response.c; - (*out_size) = tmp_response.len; - return done; -} - - diff --git a/ext/soap/php_http.h b/ext/soap/php_http.h deleted file mode 100644 index 2aa3f75ae1..0000000000 --- a/ext/soap/php_http.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef PHP_HTTP_H -#define PHP_HTTP_H - -void send_http_soap_request(zval *this_ptr, xmlDoc *doc, char *function_name, char *soapaction TSRMLS_DC); -void get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len TSRMLS_DC); - -char *get_http_header_value(char *headers, char *type); -int get_http_body(php_stream *socketd, char *headers, char **response, int *out_size TSRMLS_DC); -int get_http_headers(php_stream *socketd,char **response, int *out_size TSRMLS_DC); - -#endif diff --git a/ext/soap/php_packet_soap.c b/ext/soap/php_packet_soap.c deleted file mode 100644 index 5411c31ee9..0000000000 --- a/ext/soap/php_packet_soap.c +++ /dev/null @@ -1,141 +0,0 @@ -#include "php_soap.h" - -int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctionPtr fn, char *fn_name, zval ***ret, int *num_params TSRMLS_DC) -{ - xmlDocPtr response; - xmlNodePtr trav, trav2, env, body, resp, cur, fault; - zval **tmp_ret; - - response = xmlParseMemory(buffer, buffer_size); - xmlCleanupParser(); - - if (!response) { - php_error(E_ERROR, "looks like we got no XML document"); - } - - (*num_params) = 0; - - trav = response->children; - FOREACHNODE(trav,"Envelope",env) - { - trav2 = env->children; - FOREACHNODE(trav2,"Body",body) - { - fault = get_node(body->children,"Fault"); - if(fault != NULL) - { - char *faultcode = NULL, *faultstring = NULL, *faultactor = NULL; - zval *details = NULL; - xmlNodePtr tmp; - - tmp = get_node(fault->children,"faultcode"); - if(tmp != NULL && tmp->children != NULL) - faultcode = tmp->children->content; - - tmp = get_node(fault->children,"faultstring"); - if(tmp != NULL && tmp->children != NULL) - faultstring = tmp->children->content; - - tmp = get_node(fault->children,"faultactor"); - if(tmp != NULL && tmp->children != NULL) - faultactor = tmp->children->content; - - tmp = get_node(fault->children,"detail"); - if(tmp != NULL) - { - encodePtr enc; - enc = get_conversion(UNKNOWN_TYPE); - details = enc->to_zval(enc->details, tmp); - } - - add_soap_fault(this_ptr, faultcode, faultstring, faultactor, details TSRMLS_CC); - } - else - { - resp = body->children; - if(fn != NULL) - { - sdlParamPtr *h_param, param = NULL; - xmlNodePtr val = NULL; - encodePtr enc; - char *name, *ns = NULL; - - if(fn->bindingType == BINDING_SOAP) - { - sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)fn->bindingAttributes; - - zend_hash_internal_pointer_reset(fn->responseParameters); - if(zend_hash_get_current_data(fn->responseParameters, (void **)&h_param) != SUCCESS) - php_error(E_ERROR, "Can't find response parameter \"%s\"", param->paramName); - - param = (*h_param); - if(fnb->style == SOAP_DOCUMENT) - { - name = (*h_param)->encode->details.type_str; - ns = (*h_param)->encode->details.ns; - } - else - { - name = fn->responseName; - /* ns = ? */ - } - - cur = get_node_ex(resp, name, ns); - /* TODO: produce warning invalid ns */ - if(!cur) - cur = get_node(resp, name); - - if(!cur) - php_error(E_ERROR, "Can't find response data"); - - - if(fnb->style == SOAP_DOCUMENT) - val = cur; - else - val = get_node(cur->children, param->paramName); - - if(!val) - php_error(E_ERROR, "Can't find response data"); - - tmp_ret = emalloc(sizeof(zval **)); - if(param != NULL) - enc = param->encode; - else - enc = get_conversion(UNKNOWN_TYPE); - - tmp_ret[0] = master_to_zval(enc, val); - (*ret) = tmp_ret; - (*num_params) = 1; - } - } - else - { - cur = resp; - while(cur && cur->type != XML_ELEMENT_NODE) - cur = cur->next; - if(cur != NULL) - { - xmlNodePtr val; - val = cur->children; - while(val && val->type != XML_ELEMENT_NODE) - val = val->next; - - if(val != NULL) - { - encodePtr enc; - enc = get_conversion(UNKNOWN_TYPE); - tmp_ret = emalloc(sizeof(zval **)); - tmp_ret[0] = master_to_zval(enc, val); - (*ret) = tmp_ret; - (*num_params) = 1; - } - } - } - } - } - ENDFOREACH(trav2); - } - ENDFOREACH(trav); - xmlFreeDoc(response); - return TRUE; -} diff --git a/ext/soap/php_packet_soap.h b/ext/soap/php_packet_soap.h deleted file mode 100644 index 3d0ec74673..0000000000 --- a/ext/soap/php_packet_soap.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef PHP_PACKET_SOAP_H -#define PHP_PACKET_SOAP_H - -int parse_packet_soap(zval *this_ptr, char *buffer, int buffer_size, sdlFunctionPtr fn, char *fn_name, zval ***ret, int *num_params TSRMLS_DC); - -#endif
\ No newline at end of file diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c deleted file mode 100644 index da634941c1..0000000000 --- a/ext/soap/php_schema.c +++ /dev/null @@ -1,1080 +0,0 @@ -#include "php_soap.h" -/* -2.6.1 xsi:type -2.6.2 xsi:nil -2.6.3 xsi:schemaLocation, xsi:noNamespaceSchemaLocation -*/ - -/* -<schema - attributeFormDefault = (qualified | unqualified) : unqualified - blockDefault = (#all | List of (extension | restriction | substitution)) : '' - elementFormDefault = (qualified | unqualified) : unqualified - finalDefault = (#all | List of (extension | restriction)) : '' - id = ID - targetNamespace = anyURI - version = token - xml:lang = language - {any attributes with non-schema namespace . . .}> - Content: ((include | import | redefine | annotation)*, (((simpleType | complexType | group | attributeGroup) | element | attribute | notation), annotation*)*) -</schema> -*/ -int load_schema(sdlPtr *sdl,xmlNodePtr schema) -{ - xmlNodePtr trav, element, compType, simpleType, attribute; - xmlAttrPtr tns; - - if(!(*sdl)->types) - { - (*sdl)->types = malloc(sizeof(HashTable)); - zend_hash_init((*sdl)->types, 0, NULL, delete_type, 1); - } - - tns = get_attribute(schema->properties, "targetNamespace"); - - trav = schema->children; - FOREACHNODE(trav,"complexType",compType) - { - schema_complexType(sdl, tns, compType, NULL); - } - ENDFOREACH(trav); - - trav = schema->children; - FOREACHNODE(trav,"simpleType",simpleType) - { - schema_simpleType(sdl, tns, simpleType, NULL); - } - ENDFOREACH(trav); - - trav = schema->children; - FOREACHNODE(trav,"element",element) - { - schema_element(sdl, tns, element, NULL); - } - ENDFOREACH(trav); - - trav = schema->children; - FOREACHNODE(trav, "attribute", attribute) - { - schema_attribute(sdl, tns, attribute, NULL); - } - ENDFOREACH(trav); - return FALSE; -} -/* -<simpleType - final = (#all | (list | union | restriction)) - id = ID - name = NCName - {any attributes with non-schema namespace . . .}> - Content: (annotation?, (restriction | list | union)) -</simpleType> -*/ -int schema_simpleType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr simpleType, sdlTypePtr cur_type) -{ - xmlNodePtr content; - xmlAttrPtr name, ns; - - ns = get_attribute(simpleType->properties, "targetNamespace"); - if(ns == NULL) - ns = tsn; - - name = get_attribute(simpleType->properties, "name"); - if(name != NULL) - { - HashTable *ht; - smart_str key = {0}; - sdlTypePtr newType, *ptr; - - newType = malloc(sizeof(sdlType)); - memset(newType, 0, sizeof(sdlType)); - newType->name = strdup(name->children->content); - newType->namens = strdup(ns->children->content); - - if(cur_type == NULL) - { - ht = (*sdl)->types; - smart_str_appends(&key, newType->namens); - smart_str_appendc(&key, ':'); - smart_str_appends(&key, newType->name); - smart_str_0(&key); - } - else - { - if(cur_type->elements == NULL) - { - cur_type->elements = malloc(sizeof(HashTable)); - zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1); - } - ht = cur_type->elements; - smart_str_appends(&key, cur_type->name); - } - - zend_hash_add(ht, key.c, key.len + 1, &newType, sizeof(sdlTypePtr), (void **)&ptr); - cur_type = (*ptr); - smart_str_free(&key); - } - - content = get_node(simpleType->children, "restriction"); - if(content != NULL) - { - schema_restriction_simpleType(sdl, tsn, content, cur_type); - return TRUE; - } - - content = get_node(simpleType->children, "list"); - if(content != NULL) - { - schema_list(sdl, tsn, content, cur_type); - return TRUE; - } - - content = get_node(simpleType->children, "union"); - if(content != NULL) - { - schema_union(sdl, tsn, content, cur_type); - return TRUE; - } - - return FALSE; -} - -/* -<list - id = ID - itemType = QName - {any attributes with non-schema namespace . . .}> - Content: (annotation?, (simpleType?)) -</list> -*/ -int schema_list(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr listType, sdlTypePtr cur_type) -{ - return TRUE; -} - -/* -<union - id = ID - memberTypes = List of QName - {any attributes with non-schema namespace . . .}> - Content: (annotation?, (simpleType*)) -</union> -*/ -int schema_union(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr unionType, sdlTypePtr cur_type) -{ - return TRUE; -} - -/* -<simpleContent - id = ID - {any attributes with non-schema namespace . . .}> - Content: (annotation?, (restriction | extension)) -</simpleContent> -*/ -int schema_simpleContent(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr simpCompType, sdlTypePtr cur_type) -{ - xmlNodePtr content; - - content = get_node(simpCompType->children, "restriction"); - if(content == NULL) - { - schema_restriction_simpleContent(sdl, tsn, content, cur_type); - return TRUE; - } - - content = get_node(simpCompType->children, "extension"); - if(content == NULL) - { - /* schema_extension(sdl, tsn, content, cur_type); */ - php_error(E_ERROR, "Error parsing schema (doesn't support extensions on simpleContent)"); - return TRUE; - } - - php_error(E_ERROR, "Error parsing schema (simpleContent)"); - return FALSE; -} - -/* -<restriction - base = QName - id = ID - {any attributes with non-schema namespace . . .}> - Content: (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern)*)?, ((attribute | attributeGroup)*, anyAttribute?)) -</restriction> -*/ -int schema_restriction_simpleType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr restType, sdlTypePtr cur_type) -{ - xmlNodePtr content, trav; - xmlAttrPtr base; - - content = get_node(restType->children, "simpleType"); - if(content != NULL) - { - schema_simpleType(sdl, tsn, content, cur_type); - return TRUE; - } - - base = get_attribute(restType->properties, "base"); - if(base != NULL) - { - /* - cur_type->base = estrdup(base->children->content); - */ - } - - if(cur_type->restrictions == NULL) - { - cur_type->restrictions = malloc(sizeof(sdlRestrictions)); - memset(cur_type->restrictions, 0, sizeof(sdlRestrictions)); - } - - trav = restType->children; - do - { - if(trav->type == XML_ELEMENT_NODE) - { - if(!strcmp(trav->name, "minExclusive")) - schema_restriction_var_int(trav, &cur_type->restrictions->minExclusive); - else if(!strcmp(trav->name, "minInclusive")) - schema_restriction_var_int(trav, &cur_type->restrictions->minInclusive); - else if(!strcmp(trav->name, "maxExclusive")) - schema_restriction_var_int(trav, &cur_type->restrictions->maxExclusive); - else if(!strcmp(trav->name, "maxInclusive")) - schema_restriction_var_int(trav, &cur_type->restrictions->maxInclusive); - else if(!strcmp(trav->name, "totalDigits")) - schema_restriction_var_int(trav, &cur_type->restrictions->totalDigits); - else if(!strcmp(trav->name, "fractionDigits")) - schema_restriction_var_int(trav, &cur_type->restrictions->fractionDigits); - else if(!strcmp(trav->name, "length")) - schema_restriction_var_int(trav, &cur_type->restrictions->length); - else if(!strcmp(trav->name, "minLength")) - schema_restriction_var_int(trav, &cur_type->restrictions->minLength); - else if(!strcmp(trav->name, "maxLength")) - schema_restriction_var_int(trav, &cur_type->restrictions->maxLength); - else if(!strcmp(trav->name, "whiteSpace")) - schema_restriction_var_char(trav, &cur_type->restrictions->whiteSpace); - else if(!strcmp(trav->name, "pattern")) - schema_restriction_var_char(trav, &cur_type->restrictions->pattern); - else if(!strcmp(trav->name, "enumeration")) - { - sdlRestrictionCharPtr enumval = NULL; - - schema_restriction_var_char(trav, &enumval); - if(cur_type->restrictions->enumeration == NULL) - { - cur_type->restrictions->enumeration = malloc(sizeof(HashTable)); - zend_hash_init(cur_type->restrictions->enumeration, 0, NULL, delete_schema_restriction_var_char, 1); - } - zend_hash_next_index_insert(cur_type->restrictions->enumeration, &enumval, sizeof(sdlRestrictionCharPtr), NULL); - } - } - }while(trav = trav->next); - - return TRUE; -} - -/* -<restriction - base = QName - id = ID - {any attributes with non-schema namespace . . .}> - Content: (annotation?, (group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)) -</restriction> -*/ -int schema_restriction_complexContent(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr restType, sdlTypePtr cur_type) -{ - xmlAttrPtr base; - xmlNodePtr trav; - - base = get_attribute(restType->properties, "base"); - if(base != NULL) - { - char *type, *ns; - xmlNsPtr nsptr; - - parse_namespace(base->children->content, &type, &ns); - nsptr = xmlSearchNs(restType->doc, restType, ns); - if(nsptr != NULL) - { - cur_type->encode = get_encoder((*sdl), (char *)nsptr->href, type); - } - if(type) efree(type); - if(ns) efree(ns); - } - - trav = restType->children; - do - { - if(trav->type == XML_ELEMENT_NODE) - { - if(!strcmp(trav->name, "group")) - { - schema_group(sdl, tsn, trav, cur_type); - return TRUE; - } - else if(!strcmp(trav->name, "all")) - { - schema_all(sdl, tsn, trav, cur_type); - return TRUE; - } - else if(!strcmp(trav->name, "choice")) - { - schema_choice(sdl, tsn, trav, cur_type); - return TRUE; - } - else if(!strcmp(trav->name, "sequence")) - { - schema_sequence(sdl, tsn, trav, cur_type); - return TRUE; - } - else if(!strcmp(trav->name, "attribute")) - { - schema_attribute(sdl, tsn, trav, cur_type); - } - } - }while(trav = trav->next); - - return TRUE; -} - -/* -<restriction - base = QName - id = ID - {any attributes with non-schema Namespace . . .}> - Content: (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern)*)) -</restriction> -*/ -int schema_restriction_simpleContent(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr restType, sdlTypePtr cur_type) -{ - xmlNodePtr content, trav; - xmlAttrPtr base; - - base = get_attribute(restType->properties, "base"); - if(base != NULL) - cur_type->encode = get_encoder_from_prefix((*sdl), restType, base->children->content); - - content = get_node(restType->children, "simpleType"); - if(content != NULL) - { - schema_simpleType(sdl, tsn, content, cur_type); - return TRUE; - } - - if(cur_type->restrictions == NULL) - cur_type->restrictions = malloc(sizeof(sdlRestrictions)); - - trav = restType->children; - do - { - if(trav->type == XML_ELEMENT_NODE) - { - if(!strcmp(trav->name, "minExclusive")) - schema_restriction_var_int(trav, &cur_type->restrictions->minExclusive); - else if(!strcmp(trav->name, "minInclusive")) - schema_restriction_var_int(trav, &cur_type->restrictions->minInclusive); - else if(!strcmp(trav->name, "maxExclusive")) - schema_restriction_var_int(trav, &cur_type->restrictions->maxExclusive); - else if(!strcmp(trav->name, "maxInclusive")) - schema_restriction_var_int(trav, &cur_type->restrictions->maxInclusive); - else if(!strcmp(trav->name, "totalDigits")) - schema_restriction_var_int(trav, &cur_type->restrictions->totalDigits); - else if(!strcmp(trav->name, "fractionDigits")) - schema_restriction_var_int(trav, &cur_type->restrictions->fractionDigits); - else if(!strcmp(trav->name, "length")) - schema_restriction_var_int(trav, &cur_type->restrictions->length); - else if(!strcmp(trav->name, "minLength")) - schema_restriction_var_int(trav, &cur_type->restrictions->minLength); - else if(!strcmp(trav->name, "maxLength")) - schema_restriction_var_int(trav, &cur_type->restrictions->maxLength); - else if(!strcmp(trav->name, "whiteSpace")) - schema_restriction_var_char(trav, &cur_type->restrictions->whiteSpace); - else if(!strcmp(trav->name, "pattern")) - schema_restriction_var_char(trav, &cur_type->restrictions->pattern); - else if(!strcmp(trav->name, "enumeration")) - { - sdlRestrictionCharPtr enumval = NULL; - - schema_restriction_var_char(trav, &enumval); - if(cur_type->restrictions->enumeration == NULL) - { - cur_type->restrictions->enumeration = malloc(sizeof(HashTable)); - zend_hash_init(cur_type->restrictions->enumeration, 0, NULL, delete_schema_restriction_var_char, 1); - } - zend_hash_next_index_insert(cur_type->restrictions->enumeration, &enumval, sizeof(sdlRestrictionCharPtr), NULL); - } - } - }while(trav = trav->next); - - return TRUE; -} - -int schema_restriction_var_int(xmlNodePtr val, sdlRestrictionIntPtr *valptr) -{ - xmlAttrPtr fixed, value, id; - - if((*valptr) == NULL) - (*valptr) = malloc(sizeof(sdlRestrictionInt)); - - fixed = get_attribute(val->properties, "fixed"); - (*valptr)->fixed = FALSE; - if(fixed != NULL) - { - if(!strcmp(fixed->children->content, "true") || - !strcmp(fixed->children->content, "1")) - (*valptr)->fixed = TRUE; - } - - id = get_attribute(val->properties, "id"); - if(id != NULL) - (*valptr)->id = strdup(id->children->content); - - value = get_attribute(val->properties, "value"); - if(value == NULL) - php_error(E_ERROR, "Error parsing wsdl schema \"missing value for minExclusive\""); - - (*valptr)->value = atoi(value->children->content); - - return TRUE; -} - -void delete_restriction_var_int(void *rvi) -{ - sdlRestrictionIntPtr ptr = *((sdlRestrictionIntPtr*)rvi); - if(ptr->id); - free(ptr->id); - free(ptr); -} - -int schema_restriction_var_char(xmlNodePtr val, sdlRestrictionCharPtr *valptr) -{ - xmlAttrPtr fixed, value, id; - - if((*valptr) == NULL) - (*valptr) = malloc(sizeof(sdlRestrictionChar)); - - fixed = get_attribute(val->properties, "fixed"); - (*valptr)->fixed = FALSE; - if(fixed != NULL) - { - if(!strcmp(fixed->children->content, "true") || - !strcmp(fixed->children->content, "1")) - (*valptr)->fixed = TRUE; - } - - id = get_attribute(val->properties, "id"); - if(id != NULL) - (*valptr)->id = strdup(id->children->content); - - value = get_attribute(val->properties, "value"); - if(value == NULL) - php_error(E_ERROR, "Error parsing wsdl schema \"missing value restriction\""); - - (*valptr)->value = strdup(value->children->content); - return TRUE; -} - -void delete_schema_restriction_var_char(void *srvc) -{ - sdlRestrictionCharPtr ptr = *((sdlRestrictionCharPtr*)srvc); - if(ptr->id) - free(ptr->id); - if(ptr->value) - free(ptr->value); - free(ptr); -} - -/* -From simpleContent (not supported): -<extension - base = QName - id = ID - {any attributes with non-schema namespace . . .}> - Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?)) -</extension> - -From complexContent: -<extension - base = QName - id = ID - {any attributes with non-schema namespace . . .}> - Content: (annotation?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))) -</extension> -*/ -int schema_extension(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr extType, sdlTypePtr cur_type) -{ - xmlNodePtr content; - xmlAttrPtr base; - - base = get_attribute(extType->properties, "base"); - - content = get_node(extType->children, "group"); - if(content != NULL) - { - schema_group(sdl, tsn, content, cur_type); - return TRUE; - } - - content = get_node(extType->children, "all"); - if(content != NULL) - { - schema_all(sdl, tsn, content, cur_type); - return TRUE; - } - - content = get_node(extType->children, "choice"); - if(content != NULL) - { - schema_choice(sdl, tsn, content, cur_type); - return TRUE; - } - - content = get_node(extType->children, "sequence"); - if(content != NULL) - { - schema_sequence(sdl, tsn, content, cur_type); - return TRUE; - } - return FALSE; -} - -/* -<all - id = ID - maxOccurs = 1 : 1 - minOccurs = (0 | 1) : 1 - {any attributes with non-schema namespace . . .}> - Content: (annotation?, element*) -</all> -*/ -int schema_all(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr all, sdlTypePtr cur_type) -{ - xmlNodePtr element, trav; - - trav = all->children; - FOREACHNODE(trav, "element", element) - { - schema_element(sdl, tsn, element, cur_type); - } - ENDFOREACH(trav); - return TRUE; -} - -/* -<group - name = NCName> - Content: (annotation?, (all | choice | sequence)) -</group> -*/ -int schema_group(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr groupType, sdlTypePtr cur_type) -{ - xmlNodePtr content; - xmlAttrPtr name; - - name = get_attribute(groupType->properties, "name"); - if(name != NULL) - { - - } - - content = get_node(groupType->children, "all"); - if(content != NULL) - { - schema_all(sdl, tsn, content, cur_type); - return TRUE; - } - - content = get_node(groupType->children, "choice"); - if(content != NULL) - { - schema_choice(sdl, tsn, content, cur_type); - return TRUE; - } - - content = get_node(groupType->children, "sequence"); - if(content != NULL) - { - schema_sequence(sdl, tsn, content, cur_type); - return TRUE; - } - return FALSE; -} -/* -<choice - id = ID - maxOccurs = (nonNegativeInteger | unbounded) : 1 - minOccurs = nonNegativeInteger : 1 - {any attributes with non-schema namespace . . .}> - Content: (annotation?, (element | group | choice | sequence | any)*) -</choice> -*/ -int schema_choice(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr choiceType, sdlTypePtr cur_type) -{ - xmlNodePtr trav, data; - - /* - cur_type->property_type = CHOICE; - */ - - trav = choiceType->children; - FOREACHNODE(trav, "element", data) - { - schema_element(sdl, tsn, data, cur_type); - } - ENDFOREACH(trav); - - trav = choiceType->children; - FOREACHNODE(trav, "group", data) - { - schema_group(sdl, tsn, data, cur_type); - } - ENDFOREACH(trav); - - trav = choiceType->children; - FOREACHNODE(trav, "choice", data) - { - schema_choice(sdl, tsn, data, cur_type); - } - ENDFOREACH(trav); - - trav = choiceType->children; - FOREACHNODE(trav, "sequence", data) - { - schema_sequence(sdl, tsn, data, cur_type); - } - ENDFOREACH(trav); - - trav = choiceType->children; - FOREACHNODE(trav, "any", data) - { - schema_any(sdl, tsn, data, cur_type); - } - ENDFOREACH(trav); - - return TRUE; -} - -/* -<sequence - id = ID - maxOccurs = (nonNegativeInteger | unbounded) : 1 - minOccurs = nonNegativeInteger : 1 - {any attributes with non-schema namespace . . .}> - Content: (annotation?, (element | group | choice | sequence | any)*) -</sequence> -*/ -int schema_sequence(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr seqType, sdlTypePtr cur_type) -{ - xmlNodePtr trav; - - trav = seqType->children; - do - { - if(trav->type == XML_ELEMENT_NODE) - { - if(!strcmp(trav->name, "element")) - { - schema_element(sdl, tsn, trav, cur_type); - } - else if(!strcmp(trav->name, "group")) - { - schema_group(sdl, tsn, trav, cur_type); - } - else if(!strcmp(trav->name, "choice")) - { - schema_choice(sdl, tsn, trav, cur_type); - } - else if(!strcmp(trav->name, "sequence")) - { - schema_sequence(sdl, tsn, trav, cur_type); - } - else if(!strcmp(trav->name, "any")) - { - schema_any(sdl, tsn, trav, cur_type); - } - } - } - while(trav = trav->next); - - return TRUE; -} - -int schema_any(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr extType, sdlTypePtr cur_type) -{ - return TRUE; -} - -/* -<complexContent - id = ID - mixed = boolean - {any attributes with non-schema namespace . . .}> - Content: (annotation?, (restriction | extension)) -</complexContent> -*/ -int schema_complexContent(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr compCont, sdlTypePtr cur_type) -{ - xmlNodePtr content; - - content = get_node(compCont->children, "restriction"); - if(content != NULL) - { - schema_restriction_complexContent(sdl, tsn, content, cur_type); - return TRUE; - } - - return TRUE; -} - -/* -<complexType - abstract = boolean : false - block = (#all | List of (extension | restriction)) - final = (#all | List of (extension | restriction)) - id = ID - mixed = boolean : false - name = NCName - {any attributes with non-schema namespace . . .}> - Content: (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)))) -</complexType> -*/ -int schema_complexType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr compType, sdlTypePtr cur_type) -{ - xmlNodePtr content; - xmlAttrPtr attrs, name, ns; - - attrs = compType->properties; - ns = get_attribute(attrs, "targetNamespace"); - if(ns == NULL) - ns = tsn; - - name = get_attribute(attrs, "name"); - if(name) - { - HashTable *ht; - sdlTypePtr newType, *ptr; - smart_str key = {0}; - - newType = malloc(sizeof(sdlType)); - memset(newType, 0, sizeof(sdlType)); - newType->name = strdup(name->children->content); - newType->namens = strdup(ns->children->content); - - if(cur_type == NULL) - { - ht = (*sdl)->types; - smart_str_appends(&key, newType->namens); - smart_str_appendc(&key, ':'); - smart_str_appends(&key, newType->name); - smart_str_0(&key); - } - else - { - if(cur_type->elements == NULL) - { - cur_type->elements = malloc(sizeof(HashTable)); - zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1); - } - ht = cur_type->elements; - smart_str_appends(&key, newType->name); - } - - zend_hash_add(ht, key.c, key.len + 1, &newType, sizeof(sdlTypePtr), (void **)&ptr); - cur_type = (*ptr); - create_encoder((*sdl), cur_type, ns->children->content, name->children->content); - smart_str_free(&key); - } - - content = get_node(compType->children, "simpleContent"); - if(content != NULL) - { - schema_simpleContent(sdl, tsn, content, cur_type); - return TRUE; - } - - content = get_node(compType->children, "complexContent"); - if(content != NULL) - { - schema_complexContent(sdl, tsn, content, cur_type); - return TRUE; - } - - /* (group | all | choice | sequence) */ - content = get_node(compType->children, "group"); - if(content != NULL) - { - schema_group(sdl, tsn, content, cur_type); - return TRUE; - } - - content = get_node(compType->children, "all"); - if(content != NULL) - { - schema_all(sdl, tsn, content, cur_type); - return TRUE; - } - - content = get_node(compType->children, "choice"); - if(content != NULL) - { - schema_choice(sdl, tsn, content, cur_type); - return TRUE; - } - - content = get_node(compType->children, "sequence"); - if(content != NULL) - schema_sequence(sdl, tsn, content, cur_type); - - return TRUE; -} -/* -<element - abstract = boolean : false - block = (#all | List of (extension | restriction | substitution)) - default = string - final = (#all | List of (extension | restriction)) - fixed = string - form = (qualified | unqualified) - id = ID - maxOccurs = (nonNegativeInteger | unbounded) : 1 - minOccurs = nonNegativeInteger : 1 - name = NCName - nillable = boolean : false - ref = QName - substitutionGroup = QName - type = QName - {any attributes with non-schema namespace . . .}> - Content: (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*)) -</element> -*/ -int schema_element(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTypePtr cur_type) -{ - xmlNodePtr content; - xmlAttrPtr attrs, curattr, name, ns; - TSRMLS_FETCH(); /* is this really needed - or the parameter */ - - attrs = element->properties; - ns = get_attribute(attrs, "targetNamespace"); - if(ns == NULL) - ns = tsn; - - name = get_attribute(attrs, "name"); - if(!name) - name = get_attribute(attrs, "ref"); - if(name) - { - HashTable *addHash; - sdlTypePtr newType, *tmp; - smart_str key = {0}; - - newType = malloc(sizeof(sdlType)); - - memset(newType, 0, sizeof(sdlType)); - newType->name = strdup(name->children->content); - newType->namens = strdup(tsn->children->content); - newType->nullable = FALSE; - newType->min_occurs = 1; - newType->max_occurs = 1; - - if(cur_type == NULL) - { - addHash = (*sdl)->types; - smart_str_appends(&key, newType->namens); - smart_str_appendc(&key, ':'); - smart_str_appends(&key, newType->name); - } - else - { - if(cur_type->elements == NULL) - { - cur_type->elements = malloc(sizeof(HashTable)); - zend_hash_init(cur_type->elements, 0, NULL, delete_type, 1); - } - addHash = cur_type->elements; - smart_str_appends(&key, newType->name); - } - - smart_str_0(&key); - zend_hash_add(addHash, key.c, key.len + 1, &newType, sizeof(sdlTypePtr), (void **)&tmp); - cur_type = (*tmp); - create_encoder((*sdl), cur_type, ns->children->content, name->children->content); - smart_str_free(&key); - } - - curattr = get_attribute(attrs, "maxOccurs"); - if(curattr) - { - if(!strcmp(curattr->children->content, "unbounded")) - cur_type->max_occurs = -1; - else - cur_type->max_occurs = atoi(curattr->children->content); - } - - curattr = get_attribute(attrs, "minOccurs"); - if(curattr) - cur_type->min_occurs = atoi(curattr->children->content); - - /* nillable = boolean : false */ - attrs = element->properties; - curattr = get_attribute(attrs, "nillable"); - if(curattr) - { - if(!stricmp(curattr->children->content, "true") || - !stricmp(curattr->children->content, "1")) - cur_type->nullable = TRUE; - else - cur_type->nullable = FALSE; - } - else - cur_type->nullable = FALSE; - - /* type = QName */ - curattr = get_attribute(attrs, "type"); - if(!curattr) - curattr = name; - if(curattr) - { - char *cptype, *str_ns; - xmlNsPtr nsptr; - - parse_namespace(curattr->children->content, &cptype, &str_ns); - if(str_ns) - nsptr = xmlSearchNs(element->doc, element, str_ns); - else - nsptr = xmlSearchNsByHref(element->doc, element, ns->children->content); - - cur_type->encode = get_create_encoder((*sdl), cur_type, (char *)nsptr->href, (char *)cptype); - if(str_ns) efree(str_ns); - if(cptype) efree(cptype); - } - - if(cur_type->max_occurs == -1 || cur_type->max_occurs > 1) - cur_type->encode = get_conversion(SOAP_ENC_ARRAY); - - content = get_node(element->children, "simpleType"); - if(content) - schema_simpleType(sdl, tsn, content, cur_type); - - content = get_node(element->children, "complexType"); - if(content) - schema_complexType(sdl, tsn, content, cur_type); - - return FALSE; -} - -/* -<attribute - default = string - fixed = string - form = (qualified | unqualified) - id = ID - name = NCName - ref = QName - type = QName - use = (optional | prohibited | required) : optional - {any attributes with non-schema namespace . . .}> - Content: (annotation?, (simpleType?)) -</attribute> -*/ -int schema_attribute(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdlTypePtr cur_type) -{ - xmlAttrPtr attr; - sdlAttributePtr newAttr; - xmlAttrPtr trav; - smart_str key = {0}; - - newAttr = malloc(sizeof(sdlAttribute)); - memset(newAttr, 0, sizeof(sdlAttribute)); - - if(cur_type->attributes == NULL) - { - cur_type->attributes = malloc(sizeof(HashTable)); - zend_hash_init(cur_type->attributes, 0, NULL, delete_attribute, 1); - } - - trav = attrType->properties; - FOREACHATTRNODE(trav, NULL, attr) - { - if(attr_is_equal_ex(trav, "default", SCHEMA_NAMESPACE)) - newAttr->def = strdup(attr->children->content); - else if(attr_is_equal_ex(trav, "fixed", SCHEMA_NAMESPACE)) - newAttr->fixed = strdup(attr->children->content); - else if(attr_is_equal_ex(trav, "form", SCHEMA_NAMESPACE)) - newAttr->form = strdup(attr->children->content); - else if(attr_is_equal_ex(trav, "id", SCHEMA_NAMESPACE)) - newAttr->id = strdup(attr->children->content); - else if(attr_is_equal_ex(trav, "name", SCHEMA_NAMESPACE)) - newAttr->name = strdup(attr->children->content); - else if(attr_is_equal_ex(trav, "ref", SCHEMA_NAMESPACE)) - newAttr->ref= strdup(attr->children->content); - else if(attr_is_equal_ex(trav, "type", SCHEMA_NAMESPACE)) - newAttr->type = strdup(attr->children->content); - else if(attr_is_equal_ex(trav, "use", SCHEMA_NAMESPACE)) - newAttr->use = strdup(attr->children->content); - else - { - xmlNsPtr nsPtr = attr_find_ns(trav); - - if(strcmp(nsPtr->href, SCHEMA_NAMESPACE)) - { - smart_str key2 = {0}; - - if(!newAttr->extraAttributes) - { - newAttr->extraAttributes = malloc(sizeof(HashTable)); - zend_hash_init(newAttr->extraAttributes, 0, NULL, NULL, 1); - } - - smart_str_appends(&key2, nsPtr->href); - smart_str_appendc(&key2, ':'); - smart_str_appends(&key2, trav->name); - smart_str_0(&key2); - zend_hash_add(newAttr->extraAttributes, key2.c, key2.len + 1, &trav, sizeof(xmlAttrPtr), NULL); - smart_str_free(&key2); - } - } - } - ENDFOREACH(trav); - - - if(newAttr->ref || newAttr->name) - { - xmlNsPtr ns; - - if(newAttr->ref) - { - char *value, *prefix = NULL; - - parse_namespace(newAttr->ref, &value, &prefix); - ns = xmlSearchNs(attrType->doc, attrType, prefix); - smart_str_appends(&key, ns->href); - smart_str_appendc(&key, ':'); - smart_str_appends(&key, value); - - if(value) - efree(value); - if(prefix) - efree(prefix); - } - else - { - ns = node_find_ns(attrType); - smart_str_appends(&key, ns->href); - smart_str_appendc(&key, ':'); - smart_str_appends(&key, newAttr->name); - } - - - if(ns) - { - smart_str_0(&key); - zend_hash_add(cur_type->attributes, key.c, key.len + 1, &newAttr, sizeof(sdlAttributePtr), NULL); - smart_str_free(&key); - return TRUE; - } - } - - zend_hash_next_index_insert(cur_type->attributes, &newAttr, sizeof(sdlAttributePtr), NULL); - return TRUE; -}
\ No newline at end of file diff --git a/ext/soap/php_schema.h b/ext/soap/php_schema.h deleted file mode 100644 index c43a221608..0000000000 --- a/ext/soap/php_schema.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef PHP_SCHEMA_H -#define PHP_SCHEMA_H - -int load_schema(sdlPtr *sdl,xmlNodePtr schema); -int schema_simpleType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr simpleType, sdlTypePtr cur_type); -int schema_complexType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr compType, sdlTypePtr cur_type); -int schema_sequence(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr seqType, sdlTypePtr cur_type); -int schema_list(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr listType, sdlTypePtr cur_type); -int schema_union(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr unionType, sdlTypePtr cur_type); -int schema_simpleContent(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr simpCompType, sdlTypePtr cur_type); -int schema_restriction_simpleType(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr restType, sdlTypePtr cur_type); -int schema_restriction_simpleContent(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr restType, sdlTypePtr cur_type); -int schema_restriction_complexContent(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr restType, sdlTypePtr cur_type); -int schema_extension(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr extType, sdlTypePtr cur_type); -int schema_all(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr extType, sdlTypePtr cur_type); -int schema_group(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr groupType, sdlTypePtr cur_type); -int schema_choice(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr choiceType, sdlTypePtr cur_type); -int schema_element(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr element, sdlTypePtr cur_type); -int schema_attribute(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr attrType, sdlTypePtr cur_type); -int schema_any(sdlPtr *sdl, xmlAttrPtr tsn, xmlNodePtr extType, sdlTypePtr cur_type); - -int schema_restriction_var_int(xmlNodePtr val, sdlRestrictionIntPtr *valptr); -void delete_restriction_var_int(void *rvi); - -int schema_restriction_var_char(xmlNodePtr val, sdlRestrictionCharPtr *valptr); -void delete_schema_restriction_var_char(void *srvc); - -#endif diff --git a/ext/soap/php_sdl.c b/ext/soap/php_sdl.c deleted file mode 100644 index c34f33b9e9..0000000000 --- a/ext/soap/php_sdl.c +++ /dev/null @@ -1,1139 +0,0 @@ -#include "php_soap.h" - -encodePtr get_encoder_from_prefix(sdlPtr sdl, xmlNodePtr data, char *type) -{ - encodePtr enc = NULL; - TSRMLS_FETCH(); - - enc = get_conversion_from_type(data, type); - if(enc == NULL && sdl) - enc = get_conversion_from_type_ex(sdl->encoders, data, type); - if(enc == NULL) - enc = get_conversion(UNKNOWN_TYPE); - - return enc; -} - -encodePtr get_encoder(sdlPtr sdl, char *ns, char *type) -{ - encodePtr enc = NULL; - char *nscat; - TSRMLS_FETCH(); - - nscat = emalloc(strlen(ns) + strlen(type) + 2); - sprintf(nscat, "%s:%s", ns, type); - - enc = get_encoder_ex(sdl, nscat); - - efree(nscat); - return enc; -} - -encodePtr get_encoder_ex(sdlPtr sdl, char *nscat) -{ - encodePtr enc = NULL; - TSRMLS_FETCH(); - - enc = get_conversion_from_href_type(nscat); - if(enc == NULL && sdl) - enc = get_conversion_from_href_type_ex(sdl->encoders, nscat, strlen(nscat)); - if(enc == NULL) - enc = get_conversion(UNKNOWN_TYPE); - return enc; -} - -encodePtr get_create_encoder(sdlPtr sdl, sdlTypePtr cur_type, char *ns, char *type) -{ - encodePtr enc = NULL; - smart_str nscat = {0}; - TSRMLS_FETCH(); - - smart_str_appends(&nscat, ns); - smart_str_appendc(&nscat, ':'); - smart_str_appends(&nscat, type); - smart_str_0(&nscat); - - enc = get_conversion_from_href_type(nscat.c); - if(enc == NULL) - enc = get_conversion_from_href_type_ex(sdl->encoders, nscat.c, nscat.len); - if(enc == NULL) - enc = create_encoder(sdl, cur_type, ns, type); - - smart_str_free(&nscat); - return enc; -} - -encodePtr create_encoder(sdlPtr sdl, sdlTypePtr cur_type, char *ns, char *type) -{ - smart_str nscat = {0}; - encodePtr enc; - - enc = malloc(sizeof(encode)); - memset(enc, 0, sizeof(encode)); - - smart_str_appends(&nscat, ns); - smart_str_appendc(&nscat, ':'); - smart_str_appends(&nscat, type); - smart_str_0(&nscat); - - enc->details.ns = strdup(ns); - enc->details.type_str = strdup(type); - enc->details.sdl_type = cur_type; - enc->to_xml = sdl_guess_convert_xml; - enc->to_zval = sdl_guess_convert_zval; - - if(sdl->encoders == NULL) - { - sdl->encoders = malloc(sizeof(HashTable)); - zend_hash_init(sdl->encoders, 0, NULL, delete_encoder, 1); - } - zend_hash_add(sdl->encoders, nscat.c, nscat.len + 1, &enc, sizeof(encodePtr), NULL); - smart_str_free(&nscat); - return enc; -} - -zval *sdl_guess_convert_zval(encodeType enc, xmlNodePtr data) -{ - sdlTypePtr type; - zval *ret; - - type = enc.sdl_type; - - if(type->encode) - { - if(type->encode->details.type == IS_ARRAY || - type->encode->details.type == SOAP_ENC_ARRAY) - ret = to_zval_array(enc, data); - else - ret = master_to_zval(type->encode, data); - } - else if(zend_hash_num_elements(type->elements) == 1) - { - sdlTypePtr *t; - zend_hash_internal_pointer_reset(type->elements); - if(zend_hash_get_current_data(type->elements, (void **)&t) != FAILURE && - (*t)->max_occurs != 1) - ret = to_zval_array(enc, data); - } - if(ret) - return ret; - else - return guess_zval_convert(enc, data); -} - -xmlNodePtr sdl_guess_convert_xml(encodeType enc, zval *data, int style) -{ - sdlTypePtr type; - xmlNodePtr ret = NULL; - - type = enc.sdl_type; - - if(type->encode) - { - if(type->encode->details.type == IS_ARRAY || - type->encode->details.type == SOAP_ENC_ARRAY) - ret = sdl_to_xml_array(type, data, style); - else - ret = master_to_xml(type->encode, data, style); - } - else if(type->elements) - { - sdlTypePtr *t; - if(zend_hash_num_elements(type->elements) == 1) - { - zend_hash_internal_pointer_reset(type->elements); - if(zend_hash_get_current_data(type->elements, (void **)&t) != FAILURE && - (*t)->max_occurs != 1) - ret = sdl_to_xml_array((*t), data, style); - } - if(!ret) - ret = sdl_to_xml_object(type, data, style); - } - else - ret = guess_xml_convert(enc, data, style); - - /* - set_ns_and_type(ret, enc); - */ - return ret; -} - -xmlNodePtr sdl_to_xml_object(sdlTypePtr type, zval *data, int style) -{ - xmlNodePtr ret; - sdlTypePtr *t, tmp; - - ret = xmlNewNode(NULL, "BOGUS"); - - zend_hash_internal_pointer_reset(type->elements); - while(zend_hash_get_current_data(type->elements, (void **)&t) != FAILURE) - { - zval **prop; - tmp = *t; - if(zend_hash_find(Z_OBJPROP_P(data), tmp->name, strlen(tmp->name) + 1, (void **)&prop) == FAILURE) - { - if(tmp->nullable == FALSE) - php_error(E_ERROR, "Error encoding object to xml missing property \"%s\"", tmp->name); - } - else - { - xmlNodePtr newNode; - - newNode = master_to_xml(tmp->encode, (*prop), style); - xmlNodeSetName(newNode, tmp->name); - xmlAddChild(ret, newNode); - } - zend_hash_move_forward(type->elements); - } - - return ret; -} - -xmlNodePtr sdl_to_xml_array(sdlTypePtr type, zval *data, int style) -{ - smart_str array_type_and_size = {0}, array_type = {0}; - int i; - xmlNodePtr xmlParam; - TSRMLS_FETCH(); - - xmlParam = xmlNewNode(NULL,"BOGUS"); - - FIND_ZVAL_NULL(data, xmlParam); - - if(Z_TYPE_P(data) == IS_ARRAY) - { - sdlAttributePtr *arrayType; - i = zend_hash_num_elements(Z_ARRVAL_P(data)); - - if(style == SOAP_ENCODED) - { - if(type->attributes && - zend_hash_find(type->attributes, SOAP_ENC_NAMESPACE":arrayType", - sizeof(SOAP_ENC_NAMESPACE":arrayType"), - (void **)&arrayType) == SUCCESS) - { - xmlAttrPtr *wsdl; - if(zend_hash_find((*arrayType)->extraAttributes, WSDL_NAMESPACE":arrayType", sizeof(WSDL_NAMESPACE":arrayType"), (void **)&wsdl) == SUCCESS) - { - char *ns = NULL, *value; - smart_str *prefix = encode_new_ns(); - smart_str smart_ns = {0}; - xmlNsPtr myNs; - - parse_namespace((*wsdl)->children->content, &value, &ns); - myNs = xmlSearchNs((*wsdl)->doc, (*wsdl)->parent, ns); - - smart_str_appendl(&smart_ns, "xmlns:", sizeof("xmlns:") - 1); - smart_str_appendl(&smart_ns, prefix->c, prefix->len); - smart_str_0(&smart_ns); - - xmlSetProp(xmlParam, smart_ns.c, myNs->href); - smart_str_appends(&array_type_and_size, prefix->c); - smart_str_appendc(&array_type_and_size, ':'); - smart_str_appends(&array_type_and_size, value); - smart_str_0(&array_type_and_size); - - smart_str_free(prefix); - efree(prefix); - } - } - else - { - smart_str_appends(&array_type_and_size, type->name); - smart_str_appendc(&array_type_and_size, '['); - smart_str_append_long(&array_type_and_size, i); - smart_str_appendc(&array_type_and_size, ']'); - smart_str_0(&array_type_and_size); - } - xmlSetProp(xmlParam, SOAP_ENC_NS_PREFIX":arrayType", array_type_and_size.c); - - smart_str_free(&array_type_and_size); - smart_str_free(&array_type); - } - - zend_hash_internal_pointer_reset(data->value.ht); - for(;i > 0;i--) - { - xmlNodePtr xparam; - zval **zdata; - encodePtr enc; - zend_hash_get_current_data(data->value.ht, (void **)&zdata); - - enc = get_conversion((*zdata)->type); - xparam = master_to_xml(enc, (*zdata), style); - - xmlNodeSetName(xparam, type->name); - xmlAddChild(xmlParam, xparam); - zend_hash_move_forward(data->value.ht); - } - } - - if(style == SOAP_ENCODED) - set_ns_and_type_ex(xmlParam, type->namens, type->name); - return xmlParam; -} - -zval *sdl_convert_zval(encodeType enc, xmlNodePtr data) -{ - zval *ret; - MAKE_STD_ZVAL(ret); - ZVAL_STRING(ret, "blah", 1); - - return ret; -} - -/* -zval *sdl_convert_zval(xmlNodePtr data, sdlTypePtr type) -{ - found = zend_hash_find(EG(class_table), class_name, class_name_len + 1, (void **)&ce); - if(found != FAILURE) - { - service->type = SOAP_CLASS; - service->soap_class.ce = ce; - } -} -// this function will take a zval and apply all attributes of sldTypePtr -zval *sdl_convert_zval_to_zval(zval *data, sdlTypePtr type) -{ -} -*/ - -sdlPtr get_sdl(char *uri) -{ - sdlPtr tmp, *hndl; - TSRMLS_FETCH(); - - tmp = NULL; - hndl = NULL; - if(zend_hash_find(SOAP_GLOBAL(sdls), uri, strlen(uri), (void **)&hndl) == FAILURE) - { - tmp = load_wsdl(uri, NULL); - zend_hash_add(SOAP_GLOBAL(sdls), uri, strlen(uri), &tmp, sizeof(sdlPtr), NULL); - } - else - tmp = *hndl; - - return tmp; -} - -sdlBindingPtr get_binding_from_type(sdlPtr sdl, int type) -{ - sdlBindingPtr *binding; - - if (sdl == NULL) { - return NULL; - } - - for(zend_hash_internal_pointer_reset(sdl->bindings); - zend_hash_get_current_data(sdl->bindings, (void **) &binding) == SUCCESS; - zend_hash_move_forward(sdl->bindings)) - { - if((*binding)->bindingType == type) - return *binding; - } - return NULL; -} - -sdlBindingPtr get_binding_from_name(sdlPtr sdl, char *name, char *ns) -{ - sdlBindingPtr binding = NULL; - smart_str key = {0}; - - smart_str_appends(&key, ns); - smart_str_appendc(&key, ':'); - smart_str_appends(&key, name); - - zend_hash_find(sdl->bindings, key.c, key.len, (void **)&binding); - - smart_str_free(&key); - return binding; -} - -int load_php_sdl() -{ -#ifdef BRAD_0 - xmlNodePtr rootElement; - xmlNodePtr services; - - SOAP_SERVER_GLOBAL_VARS(); - SOAP_SERVER_GLOBAL(availableServices) = xmlParseFile(servicesFile); - rootElement = SOAP_SERVER_GLOBAL(availableServices)->children; - services = rootElement->children; - - do - { - if(IS_ELEMENT_TYPE(services,PHP_SOAPSERVER_SERVICE)) - { - phpSoapServicePtr newService; - xmlNodePtr attrib, trav; - HashTable *fn = NULL; - HashTable *include = NULL; - HashTable *cl = NULL; - - /* Init New Service */ - newService = emalloc(sizeof(phpSoapService)); - newService->serviceNode = services; - newService->started = FALSE; - - fn = newService->functions = emalloc(sizeof(HashTable)); - include = newService->include_files = emalloc(sizeof(HashTable)); - zend_hash_init(fn, 0, NULL, free_function, 0); - zend_hash_init(include, 0, NULL, ZVAL_PTR_DTOR, 0); - - attrib = services->properties; - trav = attrib; - /* Get Attributes of Service */ - do - { - if(IS_ATTRIBUTE_TYPE(trav,PHP_SOAPSERVER_SERVICE_NAME)) - { - char* name = ATTRIBUTE_VALUE(trav); - - /* Assign Service Vals */ - ALLOC_INIT_ZVAL(newService->serviceName); - ZVAL_STRING(newService->serviceName,name,1); - } - - if(IS_ATTRIBUTE_TYPE(trav,PHP_SOAPSERVER_SERVICE_STARTED)) - { - char* started = ATTRIBUTE_VALUE(trav); - - /* Assign Service Vals */ - if(!stricmp(started,"true")) - newService->started = TRUE; - } - } - while(trav = trav->next); - - /* Get ChildNodes of Service */ - trav = services->children; - do - { - /* Include Files */ - if(IS_ELEMENT_TYPE(trav,PHP_SOAPSERVER_SERVICE_INCLUDE_FILE)) - { - xmlNodePtr trav1 = trav->properties; - do - { - if(IS_ATTRIBUTE_TYPE(trav1,PHP_SOAPSERVER_SERVICE_INCLUDE_FILE_NAME)) - { - char* name = ATTRIBUTE_VALUE(trav1); - zval* z_name; - ALLOC_INIT_ZVAL(z_name); - ZVAL_STRING(z_name,name,1); - zend_hash_next_index_insert(include,&z_name,sizeof(zval),NULL); - } - } - while(trav1 = trav1->next); - } - - /* Functions */ - if(IS_ELEMENT_TYPE(trav,PHP_SOAPSERVER_SERVICE_FUNCTION)) - { - phpSoapServiceFunctionPtr function; - xmlNodePtr trav1; - HashTable *par = NULL; - - function = emalloc(sizeof(phpSoapServiceFunction)); - function->functionNode = trav; - - par = function->functionParams = emalloc(sizeof(HashTable)); - zend_hash_init(par, 0, NULL, free_param, 0); - - trav1 = trav->properties; - - do - { - if(IS_ATTRIBUTE_TYPE(trav1,PHP_SOAPSERVER_SERVICE_FUNCTION_NAME)) - { - char* name = ATTRIBUTE_VALUE(trav1); - ALLOC_INIT_ZVAL(function->functionName); - ZVAL_STRING(function->functionName,name,1); - } - } - while(trav1 = trav1->next); - - trav1 = trav->children; - do - { - if(IS_ELEMENT_TYPE(trav1,PHP_SOAPSERVER_SERVICE_FUNCTION_PARAM)) - { - phpSoapServiceParamPtr param; - xmlNodePtr trav2; - - param = emalloc(sizeof(phpSoapServiceParam)); - param->paramNode = trav1; - - trav2 = trav1->properties; - - do - { - if(IS_ATTRIBUTE_TYPE(trav2,PHP_SOAPSERVER_SERVICE_FUNCTION_PARAM_NAME)) - { - char* name = ATTRIBUTE_VALUE(trav2); - ALLOC_INIT_ZVAL(param->paramName); - ZVAL_STRING(param->paramName,name,1); - } - else if(IS_ATTRIBUTE_TYPE(trav2,PHP_SOAPSERVER_SERVICE_FUNCTION_PARAM_TYPE)) - { - char* type = ATTRIBUTE_VALUE(trav2); - ALLOC_INIT_ZVAL(param->paramType); - ZVAL_STRING(param->paramType,type,1); - } - else if(IS_ATTRIBUTE_TYPE(trav2,PHP_SOAPSERVER_SERVICE_FUNCTION_PARAM_POSITION)) - { - char* val = ATTRIBUTE_VALUE(trav2); - ALLOC_INIT_ZVAL(param->paramName); - ZVAL_LONG(param->paramName,atoi(val)); - } - } - while(trav2 = trav2->next); - zend_hash_add(par,Z_STRVAL_P(param->paramName),Z_STRLEN_P(param->paramName),param,sizeof(phpSoapServiceParam),NULL); - } - } - while(trav1 = trav1->next); - zend_hash_add(fn,Z_STRVAL_P(function->functionName),Z_STRLEN_P(function->functionName),function,sizeof(phpSoapServiceFunction),NULL); - } - - /* Classes */ - if(IS_ELEMENT_TYPE(trav,PHP_SOAPSERVER_SERVICE_CLASS)) - { - xmlNodePtr att, func; - att = trav->properties; - - if(fn == NULL) - { - fn = newService->functions = emalloc(sizeof(HashTable)); - zend_hash_init(fn, 0, NULL, ZVAL_PTR_DTOR, 0); - } - - } - - }while(trav = trav->next); - - zend_hash_add(SOAP_SERVER_GLOBAL(services),Z_STRVAL_P(newService->serviceName),Z_STRLEN_P(newService->serviceName),newService,sizeof(phpSoapService),NULL); - } - } - while(services = services->next); -#endif - return TRUE; -} - -int write_php_sdl() -{ - return TRUE; -} - -sdlPtr load_wsdl(char *struri, sdlPtr parent) -{ - xmlDocPtr wsdl; - xmlNodePtr root, definitions, types, binding, schema, service, import; - xmlNodePtr trav, trav2, trav3; - xmlAttrPtr targetNamespace; - sdlPtr tmpsdl; - TSRMLS_FETCH(); - - if(!parent) - { - tmpsdl = malloc(sizeof(sdl)); - memset(tmpsdl, 0, sizeof(sdl)); - tmpsdl->source = strdup(struri); - } - else - tmpsdl = parent; - - wsdl = xmlParseFile(struri); - xmlCleanupParser(); - - if(!wsdl) - php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Couldn't load from %s", struri); - - tmpsdl->doc = wsdl; - root = wsdl->children; - definitions = get_node(root, "definitions"); - if(!definitions) - php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: Couldn't find definitions in %s", struri); - - targetNamespace = get_attribute(definitions->properties, "targetNamespace"); - if(targetNamespace) - tmpsdl->target_ns = strdup(targetNamespace->children->content); - - types = get_node(definitions->children, "types"); - if(types) - { - trav = types->children; - FOREACHNODE(trav, "schema", schema) - { - load_schema(&tmpsdl, schema); - } - ENDFOREACH(trav); - } - - trav = definitions->children; - FOREACHNODE(trav, "import", import) - { - xmlAttrPtr tmp = get_attribute(import->properties, "location"); - if(tmp) - load_wsdl(tmp->children->content, tmpsdl); - } - ENDFOREACH(trav); - - service = get_node(definitions->children, "service"); - if(service != NULL) - { - xmlAttrPtr name; - xmlNodePtr trav, port; - - name = get_attribute(service->properties, "name"); - if(!name) - php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No name associated with service"); - - trav = service->children; - FOREACHNODE(trav, "port", port) - { - xmlAttrPtr type, name, bindingAttr, location; - xmlNodePtr portType, operation; - xmlNodePtr address; - char *ns, *ctype; - sdlBindingPtr tmpbinding; - - tmpbinding = malloc(sizeof(sdlBinding)); - memset(tmpbinding, 0, sizeof(sdlBinding)); - - name = get_attribute(port->properties, "name"); - if(!name) - php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No name associated with port"); - - bindingAttr = get_attribute(port->properties, "binding"); - if(bindingAttr == NULL) - php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No binding associated with port"); - - /* find address and figure out binding type */ - address = get_node(port->children, "address"); - if(!address) - php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No address associated with port"); - - location = get_attribute(address->properties, "location"); - if(!location) - php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No location associated with port"); - - tmpbinding->location = strdup(location->children->content); - - if(address->ns && !strcmp(address->ns->href, WSDL_SOAP_NAMESPACE)) - tmpbinding->bindingType = BINDING_SOAP; - else if(address->ns && !strcmp(address->ns->href, WSDL_HTTP_NAMESPACE)) - tmpbinding->bindingType = BINDING_HTTP; - - parse_namespace(bindingAttr->children->content, &ctype, &ns); - binding = get_node_with_attribute(definitions->children, "binding", "name", ctype); - - if(!binding) - php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: No binding element with name \"%s\"", ctype); - - if(ns) efree(ns); if(ctype) efree(ctype); - - if(tmpbinding->bindingType == BINDING_SOAP) - { - sdlSoapBindingPtr soapBinding; - xmlNodePtr soapBindingNode; - xmlAttrPtr tmp; - - soapBinding = malloc(sizeof(sdlSoapBinding)); - memset(soapBinding, 0, sizeof(sdlSoapBinding)); - - soapBindingNode = get_node_ex(binding->children, "binding", WSDL_SOAP_NAMESPACE); - if(soapBindingNode) - { - tmp = get_attribute(soapBindingNode->properties, "style"); - if(tmp && !strcmp(tmp->children->content, "document")) - soapBinding->style = SOAP_DOCUMENT; - else - soapBinding->style = SOAP_RPC; - - tmp = get_attribute(soapBindingNode->properties, "transport"); - if(tmp) - { - if(strcmp(tmp->children->content, WSDL_HTTP_TRANSPORT)) - php_error(E_ERROR, "SOAP-ERROR: Parsing WSDL: PHP-SOAP doesn't support transport '%s'", tmp->children->content); - - soapBinding->transport = strdup(tmp->children->content); - } - tmpbinding->bindingAttributes = (void *)soapBinding; - } - } - - name = get_attribute(binding->properties, "name"); - if(name == NULL) - php_error(E_ERROR, "Error parsing wsdl (Missing \"name\" attribute for \"binding\")"); - - tmpbinding->name = strdup(name->children->content); - - type = get_attribute(binding->properties, "type"); - if(type == NULL) - php_error(E_ERROR, "Error parsing wsdl (Missing \"type\" attribute for \"binding\")"); - - parse_namespace(type->children->content, &ctype, &ns); - portType = get_node_with_attribute(definitions->children, "portType", "name", ctype); - if(portType == NULL) - php_error(E_ERROR, "Error parsing wsdl (Missing \"portType\" with name \"%s\")", name->children->content); - if(ctype) efree(ctype); if(ns) efree(ns); - - trav2 = binding->children; - FOREACHNODE(trav2, "operation", operation) - { - sdlFunctionPtr function; - xmlNodePtr input, output, fault, portTypeOperation, portTypeInput, msgInput, msgOutput; - xmlAttrPtr op_name, paramOrder; - - op_name = get_attribute(operation->properties, "name"); - if(op_name == NULL) - php_error(E_ERROR, "Error parsing wsdl (Missing \"name\" attribute for \"operation\")"); - - portTypeOperation = get_node_with_attribute(portType->children, "operation", "name", op_name->children->content); - if(portTypeOperation == NULL) - php_error(E_ERROR, "Error parsing wsdl (Missing \"portType/operation\" with name \"%s\")", op_name->children->content); - - function = malloc(sizeof(sdlFunction)); - function->functionName = strdup(op_name->children->content); - function->requestParameters = NULL; - function->responseParameters = NULL; - function->responseName = NULL; - function->bindingAttributes = NULL; - function->bindingType = tmpbinding->bindingType; - - if(tmpbinding->bindingType == BINDING_SOAP) - { - sdlSoapBindingFunctionPtr soapFunctionBinding; - sdlSoapBindingPtr soapBinding; - xmlNodePtr soapOperation; - xmlAttrPtr tmp; - - soapFunctionBinding = malloc(sizeof(sdlSoapBindingFunction)); - memset(soapFunctionBinding, 0, sizeof(sdlSoapBindingFunction)); - soapBinding = (sdlSoapBindingPtr)tmpbinding->bindingAttributes; - soapFunctionBinding->style = soapBinding->style; - - soapOperation = get_node_ex(operation->children, "operation", WSDL_SOAP_NAMESPACE); - if(soapOperation) - { - tmp = get_attribute(soapOperation->properties, "soapAction"); - if(tmp) - soapFunctionBinding->soapAction = strdup(tmp->children->content); - - tmp = get_attribute(soapOperation->properties, "style"); - if(tmp && !strcmp(tmp->children->content, "rpc")) - soapFunctionBinding->style = SOAP_RPC; - else if(!soapBinding->style) - soapFunctionBinding->style = SOAP_DOCUMENT; - } - - function->bindingAttributes = (void *)soapFunctionBinding; - } - - input = get_node(operation->children, "input"); - if(input != NULL) - { - xmlAttrPtr message; - xmlNodePtr part; - char *ns, *ctype; - - portTypeInput = get_node(portTypeOperation->children, "input"); - message = get_attribute(portTypeInput->properties, "message"); - if(message == NULL) - php_error(E_ERROR, "Error parsing wsdl (Missing name for \"input\" of \"%s\")", op_name->children->content); - - function->requestName = strdup(function->functionName); - function->requestParameters = malloc(sizeof(HashTable)); - zend_hash_init(function->requestParameters, 0, NULL, delete_paramater, 1); - - parse_namespace(message->children->content, &ctype, &ns); - msgInput = get_node_with_attribute(definitions->children, "message", "name", ctype); - if(msgInput == NULL) - php_error(E_ERROR, "Error parsing wsdl (Missing \"message\" with name \"%s\")", message->children->content); - if(ctype) efree(ctype); if(ns) efree(ns); - - if(tmpbinding->bindingType == BINDING_SOAP) - { - sdlSoapBindingFunctionPtr soapFunctionBinding = function->bindingAttributes; - xmlNodePtr body; - xmlAttrPtr tmp; - - body = get_node_ex(input->children, "body", WSDL_SOAP_NAMESPACE); - if(body) - { - tmp = get_attribute(body->properties, "use"); - if(tmp && !strcmp(tmp->children->content, "literal")) - soapFunctionBinding->input.use = SOAP_LITERAL; - else - soapFunctionBinding->input.use = SOAP_ENCODED; - - tmp = get_attribute(body->properties, "namespace"); - if(tmp) - soapFunctionBinding->input.ns = strdup(tmp->children->content); - - tmp = get_attribute(body->properties, "parts"); - if(tmp) - soapFunctionBinding->input.parts = strdup(tmp->children->content); - - tmp = get_attribute(body->properties, "encodingStyle"); - if(tmp) - soapFunctionBinding->input.encodingStyle = strdup(tmp->children->content); - } - } - - trav3 = msgInput->children; - FOREACHNODE(trav3, "part", part) - { - xmlAttrPtr element, type, name; - sdlParamPtr param; - - param = malloc(sizeof(sdlParam)); - param->order = 0; - - name = get_attribute(part->properties, "name"); - if(name == NULL) - php_error(E_ERROR, "Error parsing wsdl (No name associated with part \"%s\")", msgInput->name); - - param->paramName = strdup(name->children->content); - - element = get_attribute(part->properties, "element"); - if(element != NULL) - param->encode = get_encoder_from_prefix(tmpsdl, part, element->children->content); - - type = get_attribute(part->properties, "type"); - if(type != NULL) - param->encode = get_encoder_from_prefix(tmpsdl, part, type->children->content); - - zend_hash_next_index_insert(function->requestParameters, ¶m, sizeof(sdlParamPtr), NULL); - } - ENDFOREACH(trav3); - } - - paramOrder = get_attribute(portTypeOperation->properties, "parameterOrder"); - if(paramOrder) - { - - } - - output = get_node(portTypeOperation->children, "output"); - if(output != NULL) - { - xmlAttrPtr message; - xmlNodePtr part; - char *ns, *ctype; - - - function->responseName = malloc(strlen(function->functionName) + strlen("Response") + 1); - sprintf(function->responseName, "%sResponse\0", function->functionName); - function->responseParameters = malloc(sizeof(HashTable)); - zend_hash_init(function->responseParameters, 0, NULL, delete_paramater, 1); - - message = get_attribute(output->properties, "message"); - if(message == NULL) - php_error(E_ERROR, "Error parsing wsdl (Missing name for \"output\" of \"%s\")", op_name->children->content); - - parse_namespace(message->children->content, &ctype, &ns); - msgOutput = get_node_with_attribute(definitions->children, "message", "name", ctype); - if(msgOutput == NULL) - php_error(E_ERROR, "Error parsing wsdl (Missing \"message\" with name \"%s\")", message->children->content); - if(ctype) efree(ctype); if(ns) efree(ns); - - if(tmpbinding->bindingType == BINDING_SOAP) - { - sdlSoapBindingFunctionPtr soapFunctionBinding = function->bindingAttributes; - xmlNodePtr body; - xmlAttrPtr tmp; - - body = get_node_ex(output->children, "body", WSDL_SOAP_NAMESPACE); - if(body) - { - tmp = get_attribute(body->properties, "use"); - if(tmp && !strcmp(tmp->children->content, "literal")) - soapFunctionBinding->output.use = SOAP_LITERAL; - else - soapFunctionBinding->output.use = SOAP_ENCODED; - - tmp = get_attribute(body->properties, "namespace"); - if(tmp) - soapFunctionBinding->output.ns = strdup(tmp->children->content); - - tmp = get_attribute(body->properties, "parts"); - if(tmp) - soapFunctionBinding->output.parts = strdup(tmp->children->content); - - tmp = get_attribute(body->properties, "encodingStyle"); - if(tmp) - soapFunctionBinding->output.encodingStyle = strdup(tmp->children->content); - } - } - - trav3 = msgOutput->children; - FOREACHNODE(trav3, "part", part) - { - sdlParamPtr param; - xmlAttrPtr element, type, name; - - param = malloc(sizeof(sdlParam)); - param->order = 0; - - name = get_attribute(part->properties, "name"); - if(name == NULL) - php_error(E_ERROR, "Error parsing wsdl (No name associated with part \"%s\")", msgOutput->name); - - param->paramName = strdup(name->children->content); - - element = get_attribute(part->properties, "element"); - if(element) - param->encode = get_encoder_from_prefix(tmpsdl, part, element->children->content); - - type = get_attribute(part->properties, "type"); - if(type) - param->encode = get_encoder_from_prefix(tmpsdl, part, type->children->content); - - zend_hash_next_index_insert(function->responseParameters, ¶m, sizeof(sdlParamPtr), NULL); - } - ENDFOREACH(trav3); - } - - fault = get_node(operation->children, "fault"); - if(!fault) - { - } - - if(!tmpbinding->functions) - { - tmpbinding->functions = malloc(sizeof(HashTable)); - zend_hash_init(tmpbinding->functions, 0, NULL, delete_function, 1); - } - - zend_hash_add(tmpbinding->functions, php_strtolower(function->functionName, strlen(function->functionName)), strlen(function->functionName), &function, sizeof(sdlFunctionPtr), NULL); - } - ENDFOREACH(trav2); - - if(!tmpsdl->bindings) - { - tmpsdl->bindings = malloc(sizeof(HashTable)); - zend_hash_init(tmpsdl->bindings, 0, NULL, delete_binding, 1); - } - - zend_hash_add(tmpsdl->bindings, tmpbinding->name, strlen(tmpbinding->name), &tmpbinding, sizeof(sdlBindingPtr), NULL); - } - ENDFOREACH(trav); - - } - else - php_error(E_ERROR, "Error parsing wsdl (\"Couldn't bind to service\")"); - - return tmpsdl; -} - -int write_wsdl() -{ - return TRUE; -} - -int write_ms_sdl() -{ - return TRUE; -} - -int load_ms_sdl(char *struri,int force_load) -{ -/* Commenting this out. Does anyone need it? */ -#ifdef BRAD_0 - - if(get_sdl(struri) == NULL || force_load) - { - SOAP_TLS_VARS(); - xmlDocPtr sdl = xmlParseFile(struri); - xmlNodePtr schema,trav,trav2,req,res,paramOrd,reqRes,address,serviceAdd,service,soap,serviceDesc,root = sdl->children; - xmlAttrPtr tmpattr,uri; - char *add,*functionName,*soapAction,*request,*response,*parameterOrder,*value,*namespace; - SDLPtr sdlPtr; - SoapFunctionPtr tmpFunction; - zval *tempZval; - serviceDesc = get_node(root,"serviceDescription"); - soap = get_node(serviceDesc->children,"soap"); - trav = soap->children; - sdlPtr = emalloc(sizeof(SDL)); - - ALLOC_INIT_ZVAL(sdlPtr->sdlUri); - ZVAL_STRING(sdlPtr->sdlUri,struri,1); - - FOREACHNODE(trav,"service",service) - { - sdlPtr->soapFunctions = emalloc(sizeof(HashTable)); - sdlPtr->addresses = emalloc(sizeof(HashTable)); - zend_hash_init(sdlPtr->soapFunctions, 0, NULL, delete_function, 0); - zend_hash_init(sdlPtr->addresses, 0, NULL, ZVAL_PTR_DTOR, 0); - - serviceAdd = get_node(service->children,"addresses"); - trav2 = serviceAdd->children; - ALLOC_INIT_ZVAL(tempZval); - FOREACHNODE(trav2,"address",address) - { - uri = get_attribute(address->properties,"uri"); - add = uri->children->content; - ZVAL_STRING(tempZval,add,1); - zend_hash_next_index_insert(sdlPtr->addresses,tempZval,sizeof(zval),NULL); - } - ENDFOREACH(trav2); - trav2 = service->children; - FOREACHNODE(trav2,"requestResponse",reqRes) - { - tmpFunction = emalloc(sizeof(SoapFunction)); - - tmpattr = get_attribute(reqRes->properties,"name"); - functionName = tmpattr->children->content; - ALLOC_INIT_ZVAL(tmpFunction->functionName); - ZVAL_STRING(tmpFunction->functionName,functionName,1); - - tmpattr = get_attribute(reqRes->properties,"soapAction"); - soapAction = tmpattr->children->content; - ALLOC_INIT_ZVAL(tmpFunction->soapAction); - ZVAL_STRING(tmpFunction->soapAction,soapAction,1); - - /* Request */ - req = get_node(reqRes->children,"request"); - tmpattr = get_attribute(req->properties,"ref"); - if(tmpattr != NULL) - { - request = tmpattr->children->content; - parse_namespace(request,&value,&namespace); - ALLOC_INIT_ZVAL(tmpFunction->requestName); - ZVAL_STRING(tmpFunction->requestName,value,1); - tmpFunction->requestParameters = emalloc(sizeof(HashTable)); - zend_hash_init(tmpFunction->requestParameters, 0, NULL, delete_paramater, 0); - efree(value); - efree(namespace); - } - - /* Response */ - res = get_node(reqRes->children,"response"); - tmpattr = get_attribute(res->properties,"ref"); - if(tmpattr != NULL) - { - response = tmpattr->children->content; - parse_namespace(response,&value,&namespace); - ALLOC_INIT_ZVAL(tmpFunction->responseName); - ZVAL_STRING(tmpFunction->responseName,value,1); - tmpFunction->responseParameters = emalloc(sizeof(HashTable)); - zend_hash_init(tmpFunction->responseParameters, 0, NULL, delete_paramater, 0); - efree(value); - efree(namespace); - } - - /* Parameters */ - paramOrd = get_node(reqRes->children,"parameterorder"); - if(paramOrd != NULL) - { - zval *space,*array,**strval; - int count,i; - ALLOC_INIT_ZVAL(space); - ZVAL_STRING(space," ",0); - parameterOrder = paramOrd->children->content; - ZVAL_STRING(tempZval,parameterOrder,1); - ALLOC_INIT_ZVAL(array); - array_init(array); - - /* Split on space */ - php_explode(space, tempZval, array, -1); - zend_hash_internal_pointer_reset(array->value.ht); - count = zend_hash_num_elements(array->value.ht); - - for(i = 0;i < count;i++) - { - SoapParamPtr param; - param = emalloc(sizeof(SoapParam)); - param->order = i+1; - param->type = NULL; - zend_hash_get_current_data(array->value.ht,(void **)&strval); - ALLOC_INIT_ZVAL(param->paramName); - ZVAL_STRING(param->paramName,Z_STRVAL_PP(strval),1); - zend_hash_next_index_insert(tmpFunction->requestParameters,param,sizeof(SoapParam),NULL); - zend_hash_move_forward(array->value.ht); - } - } - zend_hash_add(sdlPtr->soapFunctions,(char *)php_strtolower(functionName,strlen(functionName)),strlen(functionName),tmpFunction,sizeof(SoapFunction),NULL); - } - ENDFOREACH(trav2); - } - ENDFOREACH(trav); - - trav = serviceDesc->children; - FOREACHNODE(trav,"schema",schema) - { - load_schema(&sdlPtr, schema); - } - ENDFOREACH(trav); - sdlPtr->have_sdl = 1; - map_types_to_functions(sdlPtr); - zend_hash_add(SOAP_GLOBAL(SDLs),struri,strlen(struri),sdlPtr,sizeof(SDL),NULL); - } -#endif - return FALSE; -} - -void delete_type(void *data) -{ - sdlTypePtr type = *((sdlTypePtr*)data); - if(type->name) - free(type->name); - if(type->namens) - free(type->namens); - if(type->elements) - { - zend_hash_destroy(type->elements); - free(type->elements); - } - if(type->attributes) - { - zend_hash_destroy(type->attributes); - free(type->attributes); - } - if(type->restrictions) - { - delete_restriction_var_int(&type->restrictions->minExclusive); - delete_restriction_var_int(&type->restrictions->minInclusive); - delete_restriction_var_int(&type->restrictions->maxExclusive); - delete_restriction_var_int(&type->restrictions->maxInclusive); - delete_restriction_var_int(&type->restrictions->totalDigits); - delete_restriction_var_int(&type->restrictions->fractionDigits); - delete_restriction_var_int(&type->restrictions->length); - delete_restriction_var_int(&type->restrictions->minLength); - delete_restriction_var_int(&type->restrictions->maxLength); - delete_schema_restriction_var_char(&type->restrictions->whiteSpace); - delete_schema_restriction_var_char(&type->restrictions->pattern); - zend_hash_destroy(type->restrictions->enumeration); - free(type->restrictions->enumeration); - free(type->restrictions); - } - free(type); -} - -void delete_attribute(void *attribute) -{ - sdlAttributePtr attr = *((sdlAttributePtr*)attribute); - - if(attr->def) - free(attr->def); - if(attr->fixed) - free(attr->fixed); - if(attr->form) - free(attr->form); - if(attr->id) - free(attr->id); - if(attr->name) - free(attr->name); - if(attr->ref) - free(attr->ref); - if(attr->type) - free(attr->type); - if(attr->use) - free(attr->use); - if(attr->extraAttributes) - { - zend_hash_destroy(attr->extraAttributes); - free(attr->extraAttributes); - } -} diff --git a/ext/soap/php_sdl.h b/ext/soap/php_sdl.h deleted file mode 100644 index 38c9001e84..0000000000 --- a/ext/soap/php_sdl.h +++ /dev/null @@ -1,167 +0,0 @@ -#ifndef PHP_SDL_H -#define PHP_SDL_H - -#define XSD_WHITESPACE_COLLAPSE 1 -#define XSD_WHITESPACE_PRESERVE 1 -#define XSD_WHITESPACE_REPLACE 1 - -#define BINDING_SOAP 1 -#define BINDING_HTTP 2 - -#define SOAP_RPC 1 -#define SOAP_DOCUMENT 2 - -#define SOAP_ENCODED 1 -#define SOAP_LITERAL 2 - -struct _sdl -{ - xmlDocPtr doc; /* pointer to the parsed xml file */ - HashTable *types; /* array of sdlTypesPtr */ - HashTable *encoders; /* array of encodePtr */ - HashTable *bindings; /* array of sdlBindings (key'd by name) */ - char *target_ns; - char *source; -}; - -struct _sdlBinding -{ - char *name; - HashTable *functions; - char *location; - int bindingType; - void *bindingAttributes; -}; - -/* Soap Binding Specfic stuff */ -struct _sdlSoapBinding -{ - char *transport; - int style; -}; - -struct _sdlSoapBindingFunctionBody -{ - char *ns; - int use; - char *parts; /* not implemented yet */ - char *encodingStyle; /* not implemented yet */ -}; - -struct _sdlSoapBindingFunction -{ - char *soapAction; - int style; - - sdlSoapBindingFunctionBody input; - sdlSoapBindingFunctionBody output; - sdlSoapBindingFunctionBody falut; -}; - -/* HTTP Binding Specfic stuff */ -/*********** not implemented yet ************ -struct _sdlHttpBinding -{ - int holder; -}; -*********************************************/ - -struct _sdlRestrictionInt -{ - int value; - char fixed; - char *id; -}; - -struct _sdlRestrictionChar -{ - char *value; - char fixed; - char *id; -}; - -struct _sdlRestrictions -{ - HashTable *enumeration; /* array of sdlRestrictionCharPtr */ - sdlRestrictionIntPtr minExclusive; - sdlRestrictionIntPtr minInclusive; - sdlRestrictionIntPtr maxExclusive; - sdlRestrictionIntPtr maxInclusive; - sdlRestrictionIntPtr totalDigits; - sdlRestrictionIntPtr fractionDigits; - sdlRestrictionIntPtr length; - sdlRestrictionIntPtr minLength; - sdlRestrictionIntPtr maxLength; - sdlRestrictionCharPtr whiteSpace; - sdlRestrictionCharPtr pattern; -}; - -struct _sdlType -{ - char *name; - char *namens; - int nullable; - int min_occurs; - int max_occurs; - HashTable *elements; /* array of sdlTypePtr */ - HashTable *attributes; /* array of sdlAttributePtr */ - sdlRestrictionsPtr restrictions; - encodePtr encode; -}; - -struct _sdlParam -{ - int order; - encodePtr encode; - char *paramName; -}; - -struct _sdlFunction -{ - char *functionName; - char *requestName; - char *responseName; - HashTable *requestParameters; /* array of sdlParamPtr */ - HashTable *responseParameters; /* array of sdlParamPtr (this should only be one) */ - int bindingType; - void *bindingAttributes; -}; - -struct _sdlAttribute -{ - char *def; - char *fixed; - char *form; - char *id; - char *name; - char *ref; - char *type; - char *use; - HashTable *extraAttributes; /* array of xmlNodePtr */ -}; - -sdlPtr get_sdl(char *uri); -sdlPtr load_wsdl(char *struri, sdlPtr parent); -int load_sdl(char *struri, int force_load); -int load_ms_sdl(char *struri, int force_load); - -encodePtr get_encoder_from_prefix(sdlPtr sdl, xmlNodePtr data, char *type); -encodePtr get_encoder(sdlPtr sdl, char *ns, char *type); -encodePtr get_encoder_ex(sdlPtr sdl, char *nscat); -encodePtr get_create_encoder(sdlPtr sdl, sdlTypePtr cur_type, char *ns, char *type); -encodePtr create_encoder(sdlPtr sdl, sdlTypePtr cur_type, char *ns, char *type); - -sdlBindingPtr get_binding_from_type(sdlPtr sdl, int type); -sdlBindingPtr get_binding_from_name(sdlPtr sdl, char *name, char *ns); - -xmlNodePtr sdl_guess_convert_xml(encodeType enc, zval* data, int style); -zval *sdl_guess_convert_zval(encodeType enc, xmlNodePtr data); - -xmlNodePtr sdl_to_xml_array(sdlTypePtr type, zval *data, int style); -xmlNodePtr sdl_to_xml_object(sdlTypePtr type, zval *data, int style); - -void delete_type(void *type); -void delete_attribute(void *attribute); -#endif - - diff --git a/ext/soap/php_soap.dsp b/ext/soap/php_soap.dsp deleted file mode 100644 index a80142d6c3..0000000000 --- a/ext/soap/php_soap.dsp +++ /dev/null @@ -1,148 +0,0 @@ -# Microsoft Developer Studio Project File - Name="php_soap" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=php_soap - Win32 Debug
-!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 "php_soap.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 "php_soap.mak" CFG="php_soap - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "php_soap - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "php_soap - Win32 Debug" (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)" == "php_soap - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP_SOAP_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /I "..\..\..\libxml2-2.4.12\include" /I "..\..\bind" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PHP_SOAP_EXPORTSWS" /D "PHP_SOAP_EXPORTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "ZTS" /D ZEND_DEBUG=0 /D "COMPILE_DL_SOAP" /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 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib libxml2.lib wsock32.lib resolv.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS\php_soap.dll" /libpath:"..\..\\" /libpath:"..\..\..\libxml2-2.4.12\lib" /libpath:"..\..\Release_TS"
-
-!ELSEIF "$(CFG)" == "php_soap - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# 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 "PHP_SOAP_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\main" /I "..\..\..\libxml2-2.4.12\include" /I "..\..\bind" /D "WS" /D "_MBCS" /D "_USRDLL" /D "PHP_SOAP_EXPORTS" /D "ZEND_WIN32" /D "PHP_WIN32" /D "ZTS" /D ZEND_DEBUG=1 /D "COMPILE_DL_SOAP" /FR"Release_TS/" /Fp"Release_TS/gd.pch" /YX /Fo"Release_TS/" /Fd"Release_TS/" /FD /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 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts_debug.lib libxml2.lib wsock32.lib resolv.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS\php_soap.dll" /implib:"Release_TS/php_gd.lib" /pdbtype:sept /libpath:"..\..\\" /libpath:"..\..\..\libxml2-2.4.12\lib" /libpath:"..\..\Debug_TS"
-# SUBTRACT LINK32 /pdb:none /incremental:no
-
-!ENDIF
-
-# Begin Target
-
-# Name "php_soap - Win32 Release"
-# Name "php_soap - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\php_encoding.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_http.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_schema.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_sdl.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_xml.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\soap.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\php_encoding.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_http.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_schema.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_sdl.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_soap.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\php_xml.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/ext/soap/php_soap.h b/ext/soap/php_soap.h deleted file mode 100644 index 9475e3207e..0000000000 --- a/ext/soap/php_soap.h +++ /dev/null @@ -1,416 +0,0 @@ -#ifndef PHP_SOAP_H -#define PHP_SOAP_H - -#include "php.h" -#include "php_globals.h" -#include "ext/standard/info.h" -#include "ext/standard/php_standard.h" -#include "ext/session/php_session.h" -#include "ext/standard/php_smart_str.h" -#include "php_ini.h" -#include "SAPI.h" -#include <libxml/parser.h> -#include <libxml/xpath.h> - -#ifdef HAVE_PHP_DOMXML -# include "ext/domxml/php_domxml.h" -#endif - -#ifndef PHP_HAVE_STREAMS -# error You lose - must be compiled against PHP 4.3.0 or later -#endif - -#ifndef PHP_WIN32 -# define TRUE 1 -# define FALSE 0 -# define stricmp strcasecmp -#endif - -typedef struct _encodeType encodeType, *encodeTypePtr; -typedef struct _encode encode, *encodePtr; - -typedef struct _sdl sdl, *sdlPtr; -typedef struct _sdlRestrictionInt sdlRestrictionInt, *sdlRestrictionIntPtr; -typedef struct _sdlRestrictionChar sdlRestrictionChar, *sdlRestrictionCharPtr; -typedef struct _sdlRestrictions sdlRestrictions, *sdlRestrictionsPtr; -typedef struct _sdlType sdlType, *sdlTypePtr; -typedef struct _sdlParam sdlParam, *sdlParamPtr; -typedef struct _sdlFunction sdlFunction, *sdlFunctionPtr; -typedef struct _sdlAttribute sdlAttribute, *sdlAttributePtr; -typedef struct _sdlBinding sdlBinding, *sdlBindingPtr; -typedef struct _sdlSoapBinding sdlSoapBinding, *sdlSoapBindingPtr; -typedef struct _sdlSoapBindingFunction sdlSoapBindingFunction, *sdlSoapBindingFunctionPtr; -typedef struct _sdlSoapBindingFunctionBody sdlSoapBindingFunctionBody, *sdlSoapBindingFunctionBodyPtr; - -typedef struct _soapMapping soapMapping, *soapMappingPtr; -typedef struct _soapService soapService, *soapServicePtr; - -#include "php_xml.h" -#include "php_encoding.h" -#include "php_sdl.h" -#include "php_schema.h" -#include "php_http.h" -#include "php_packet_soap.h" - -extern int le_sdl; -extern int le_http_socket; -extern int le_url; -extern int le_service; - - -struct _soapHeaderHandler -{ - char *ns; - int type; - - struct _function_handler - { - char *functionName; - char *type; - } function_handler; - - struct _class_handler - { - zend_class_entry *ce; - } class_handler; -}; - -struct _soapMapping -{ - char *ns; - char *ctype; - int type; - - struct _map_functions - { - zval *to_xml_before; - zval *to_xml; - zval *to_xml_after; - zval *to_zval_before; - zval *to_zval; - zval *to_zval_after; - } map_functions; - - struct _map_class - { - int type; - zend_class_entry *ce; - } map_class; -}; - -struct _soapService -{ - sdlPtr sdl; - - struct _soap_functions - { - HashTable *ft; - int functions_all; - } soap_functions; - - struct _soap_class - { - zend_class_entry *ce; - zval **argv; - int argc; - int persistance; - } soap_class; - - HashTable *mapping; - int type; - int enabled; - char *uri; -}; - -#define SOAP_CLASS 1 -#define SOAP_FUNCTIONS 2 -#define SOAP_FUNCTIONS_ALL 999 - -#define SOAP_MAP_FUNCTION 1 -#define SOAP_MAP_CLASS 2 - -#define SOAP_PERSISTENCE_SESSION 1 -#define SOAP_PERSISTENCE_REQUEST 2 - -ZEND_BEGIN_MODULE_GLOBALS(soap) - HashTable *defEncNs; - HashTable *defEncPrefix; - HashTable *defEnc; - HashTable *defEncIndex; - HashTable *sdls; - HashTable *services; - HashTable *overrides; - int cur_uniq_ns; -ZEND_END_MODULE_GLOBALS(soap) -#ifdef PHP_WIN32 -#define PHP_SOAP_API __declspec(dllexport) -#else -#define PHP_SOAP_API -#endif -#ifdef ZTS -#include "TSRM.h" -#endif - -ZEND_EXTERN_MODULE_GLOBALS(soap); - -#ifdef ZTS -# define SOAP_GLOBAL(v) TSRMG(soap_globals_id, zend_soap_globals *, v) -#else -# define SOAP_GLOBAL(v) (soap_globals.v) -#endif - -#define PHP_SOAP_SERVER_CLASSNAME "soapserver" -#define PHP_SOAP_CLASSNAME "soapobject" -#define PHP_SOAP_VAR_CLASSNAME "soapvar" -#define PHP_SOAP_FAULT_CLASSNAME "soapfault" -#define PHP_SOAP_PARAM_CLASSNAME "soapparam" - - -extern zend_module_entry soap_module_entry; -#define soap_module_ptr & soap_module_entry - -PHP_MINIT_FUNCTION(soap); -PHP_MSHUTDOWN_FUNCTION(soap); -PHP_MINFO_FUNCTION(soap); - -/* - Registry Functions - TODO: this! -*/ -PHP_FUNCTION(load_sdl); -PHP_FUNCTION(unload_sdl); -PHP_FUNCTION(unload_all_sdls); -PHP_FUNCTION(get_available_sdls); -PHP_FUNCTION(get_available_functions); -PHP_FUNCTION(get_function_parameters); -PHP_FUNCTION(soap_encode_to_xml); -PHP_FUNCTION(soap_encode_to_zval); - - -/* Server Functions */ -PHP_FUNCTION(soapserver); -PHP_FUNCTION(setclass); -PHP_FUNCTION(addfunction); -PHP_FUNCTION(getfunctions); -PHP_FUNCTION(handle); -PHP_FUNCTION(setpersistence); -PHP_FUNCTION(bind); -#ifdef HAVE_PHP_DOMXML -PHP_FUNCTION(map); -#endif - -/* Client Functions */ -PHP_FUNCTION(soapobject); -PHP_FUNCTION(__use); -PHP_FUNCTION(__style); -PHP_FUNCTION(__isfault); -PHP_FUNCTION(__getfault); -PHP_FUNCTION(__call); -PHP_FUNCTION(__parse); -PHP_FUNCTION(__generate); -PHP_FUNCTION(__trace); -PHP_FUNCTION(__getfunctions); -PHP_FUNCTION(__gettypes); -PHP_FUNCTION(__getlastresponse); -PHP_FUNCTION(__getlastrequest); -PHP_FUNCTION(__headerclass); -PHP_FUNCTION(__headerfunction); - -/* SoapVar Functions */ -PHP_FUNCTION(soapvar); - -/* SoapFault Functions */ -PHP_FUNCTION(soapfault); - -/* SoapParam Functions */ -PHP_FUNCTION(soapparam); - - -#define DECLARE_TRACE(file) \ - FILE *trace_fp; \ - char *trace_file = file; - -#define TRACE(place) \ - trace_fp = fopen(trace_file, "a+"); \ - fwrite(place, strlen(place), 1, trace_fp); \ - fclose(trace_fp); - -extern zend_class_entry soap_var_class_entry; - -PS_SERIALIZER_FUNCS(soap); - -void clear_soap_fault(zval *obj); -void set_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail TSRMLS_DC); -void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail TSRMLS_DC); - -sdlParamPtr get_param(sdlFunctionPtr function, char *param_name, int index, int); -sdlFunctionPtr get_function(sdlBindingPtr sdl, char *function_name); - -void delete_sdl(void *handle); -void delete_binding(void *binding); -void delete_sdl_soap_binding_function_body(sdlSoapBindingFunctionBody body); -void delete_function(void *function); -void delete_paramater(void *paramater); -void delete_service(void *service); -void delete_http_socket(void *handle); -void delete_url(void *handle); -void delete_mapping(void *data); - -void soap_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference); -zval soap_get_property_handler(zend_property_reference *property_reference); -int soap_set_property_handler(zend_property_reference *property_reference, zval *value); -void soap_destructor(void *jobject); - -void deseralize_function_call(sdlPtr sdl, xmlDocPtr request, zval *function_name, int *num_params, zval **parameters[] TSRMLS_DC); -xmlDocPtr seralize_response_call(sdlFunctionPtr function, char *function_name,char *uri,zval *ret TSRMLS_DC); -xmlDocPtr seralize_function_call(zval *this_ptr, sdlFunctionPtr function, char *function_name, char *uri, zval **arguments, int arg_count TSRMLS_DC); -xmlNodePtr seralize_parameter(sdlParamPtr param,zval *param_val,int index,char *name, int style TSRMLS_DC); -xmlNodePtr seralize_zval(zval *val, sdlParamPtr param, char *paramName, int style TSRMLS_DC); -zval *desearlize_zval(sdlPtr sdl, xmlNodePtr data, sdlParamPtr param TSRMLS_DC); - -void soap_error_handler(int error_num, const char *error_filename, const uint error_lineno, const char *format, va_list args); -#ifndef ZEND_ENGINE_2 -int my_call_user_function(HashTable *function_table, zval **object_pp, zval *function_name, zval *retval_ptr, int param_count, zval *params[] TSRMLS_DC); -#endif - -#define phpext_soap_ptr soap_module_ptr - -#define HTTP_RAW_POST_DATA "HTTP_RAW_POST_DATA" - -#define SOAP_SERVER_BEGIN_CODE() \ - zend_error_cb = soap_error_handler - -#define SOAP_SERVER_END_CODE() \ - zend_error_cb = old_handler - - -#define FOREACHATTRNODE(n,c,i) \ - do \ - { \ - if(n == NULL) \ - break; \ - if(c) \ - i = get_attribute(n,c); \ - else \ - i = n; \ - if(i != NULL) \ - { \ - n = i; - -#define FOREACHNODE(n,c,i) \ - do \ - { \ - if(n == NULL) \ - break; \ - if(c) \ - i = get_node(n,c); \ - else \ - i = n; \ - if(i != NULL) \ - { \ - n = i; - -#define ENDFOREACH(n) \ - } \ - } while ((n = n->next)); - -#define ZERO_PARAM() \ - if(ZEND_NUM_ARGS() != 0) \ - WRONG_PARAM_COUNT; - -#define ONE_PARAM(p) \ - if(ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &p) == FAILURE) \ - WRONG_PARAM_COUNT; - -#define TWO_PARAM(p,p1) \ - if(ZEND_NUM_ARGS() != 1 || getParameters(ht, 2, &p, &p1) == FAILURE) \ - WRONG_PARAM_COUNT; - -#define THREE_PARAM(p,p1,p2) \ - if(ZEND_NUM_ARGS() != 1 || getParameters(ht, 3, &p, &p1, &p2) == FAILURE) \ - WRONG_PARAM_COUNT; - -#define FETCH_THIS_PORT(ss) \ - { \ - zval *__thisObj; zval *__port; sdlBindingPtr *__tmp; \ - GET_THIS_OBJECT(__thisObj) \ - if(FIND_PORT_PROPERTY(__thisObj, __port) == FAILURE) { \ - ss = NULL; \ - php_error(E_ERROR, "Error could find current port"); \ - } \ - __tmp = (sdlBindingPtr*)Z_LVAL_P(__port); \ - ss = *__tmp; \ - } - -#define FIND_PORT_PROPERTY(ss,tmp) zend_hash_find(Z_OBJPROP_P(ss), "port", sizeof("port"), (void **)&tmp) - -#define FETCH_THIS_SDL(ss) \ - { \ - zval *__thisObj,**__tmp; \ - GET_THIS_OBJECT(__thisObj) \ - if(FIND_SDL_PROPERTY(__thisObj,__tmp) != FAILURE) \ - { \ - FETCH_SDL_RES(ss,__tmp); \ - } \ - else \ - ss = NULL; \ - } - -#define FIND_SDL_PROPERTY(ss,tmp) zend_hash_find(Z_OBJPROP_P(ss), "sdl", sizeof("sdl"), (void **)&tmp) -#define FETCH_SDL_RES(ss,tmp) ss = (sdlPtr) zend_fetch_resource(tmp TSRMLS_CC, -1, "sdl", NULL, 1, le_sdl) - -#define FETCH_THIS_SERVICE(ss) \ - { \ - zval *__thisObj,**__tmp; \ - GET_THIS_OBJECT(__thisObj) \ - if(FIND_SERVICE_PROPERTY(__thisObj,__tmp) != FAILURE) \ - { \ - FETCH_SERVICE_RES(ss,__tmp); \ - } \ - else \ - ss = NULL; \ - } - -#define FIND_SERVICE_PROPERTY(ss,tmp) zend_hash_find(Z_OBJPROP_P(ss), "service", sizeof("service"), (void **)&tmp) -#define FETCH_SERVICE_RES(ss,tmp) ss = (soapServicePtr) zend_fetch_resource(tmp TSRMLS_CC, -1, "service", NULL, 1, le_service) - -#define FETCH_THIS_URL(ss) \ - { \ - zval *__thisObj,**__tmp; \ - GET_THIS_OBJECT(__thisObj) \ - if(FIND_URL_PROPERTY(__thisObj,__tmp) != FAILURE) \ - { \ - FETCH_URL_RES(ss,__tmp); \ - } \ - else \ - ss = NULL; \ - } - -#define FIND_URL_PROPERTY(ss,tmp) zend_hash_find(Z_OBJPROP_P(ss), "httpurl", sizeof("httpurl"), (void **)&tmp) -#define FETCH_URL_RES(ss,tmp) ss = (php_url *) zend_fetch_resource(tmp TSRMLS_CC, -1, "httpurl", NULL, 1, le_url) - -#define FETCH_THIS_SOCKET(ss) \ - { \ - zval *__thisObj,**__tmp; \ - GET_THIS_OBJECT(__thisObj) \ - if(FIND_SOCKET_PROPERTY(__thisObj,__tmp) != FAILURE) \ - { \ - FETCH_SOCKET_RES(ss,__tmp); \ - } \ - else \ - ss = NULL; \ - } - -#define FIND_SOCKET_PROPERTY(ss,tmp) zend_hash_find(Z_OBJPROP_P(ss), "httpsocket", sizeof("httpsocket"), (void **)&tmp) -#define FETCH_SOCKET_RES(ss,tmp) php_stream_from_zval_no_verify(ss,tmp) - -#define GET_THIS_OBJECT(o) \ - o = getThis(); \ - if (!o) \ - { \ - php_error(E_WARNING, "Cannot Get Class Info"); \ - return; \ - } - - -#endif diff --git a/ext/soap/php_xml.c b/ext/soap/php_xml.c deleted file mode 100644 index 786ebc97a5..0000000000 --- a/ext/soap/php_xml.c +++ /dev/null @@ -1,242 +0,0 @@ -#include "php_soap.h" - -/* Channel libxml file io layer through the PHP streams subsystem. - * This allows use of ftps:// and https:// urls */ - -int php_stream_xmlIO_match_wrapper(const char *filename) -{ - TSRMLS_FETCH(); - return php_stream_locate_url_wrapper(filename, NULL, STREAM_LOCATE_WRAPPERS_ONLY TSRMLS_CC) ? 1 : 0; - -} - -void *php_stream_xmlIO_open_wrapper(const char *filename) -{ - TSRMLS_FETCH(); - return php_stream_open_wrapper(filename, "rb", ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL); -} - -int php_stream_xmlIO_read(void *context, char *buffer, int len) -{ - TSRMLS_FETCH(); - return php_stream_read((php_stream*)context, buffer, len); -} - -int php_stream_xmlIO_close(void *context) -{ - TSRMLS_FETCH(); - return php_stream_close((php_stream*)context); -} - -xmlNsPtr attr_find_ns(xmlAttrPtr node) -{ - if(node->ns) - return node->ns; - else if(node->parent->ns) - return node->parent->ns; - else - return xmlSearchNs(node->doc, node->parent, NULL); -} - -xmlNsPtr node_find_ns(xmlNodePtr node) -{ - if(node->ns) - return node->ns; - else - return xmlSearchNs(node->doc, node, NULL); -} - -int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns) -{ - if(!strcmp(node->name, name)) - { - if(ns) - { - xmlNsPtr nsPtr; - if(node->ns) - nsPtr = node->ns; - else if(node->parent->ns) - nsPtr = node->parent->ns; - else - nsPtr = xmlSearchNs(node->doc, node->parent, NULL); - if(!strcmp(nsPtr->href, ns)) - return TRUE; - return FALSE; - } - return TRUE; - } - return FALSE; -} - -int node_is_equal_ex(xmlNodePtr node, char *name, char *ns) -{ - if(!strcmp(node->name, name)) - { - if(ns) - { - xmlNsPtr nsPtr; - if(node->ns) - nsPtr = node->ns; - else - nsPtr = xmlSearchNs(node->doc, node, NULL); - if(!strcmp(nsPtr->href, ns)) - return TRUE; - return FALSE; - } - return TRUE; - } - return FALSE; -} - -xmlAttrPtr get_attribute_ex(xmlAttrPtr node, char *name, char *ns) -{ - xmlAttrPtr trav = node; - if(node == NULL) return NULL; - do { - if(attr_is_equal_ex(trav, name, ns)) - return trav; - } while(trav = trav->next); - return NULL; -} - -xmlNodePtr get_node_ex(xmlNodePtr node, char *name, char *ns) -{ - xmlNodePtr trav = node; - if(node == NULL) return NULL; - do { - if(node_is_equal_ex(trav, name, ns)) - return trav; - } while(trav = trav->next); - return NULL; -} - -xmlNodePtr get_node_recurisve_ex(xmlNodePtr node, char *name, char *ns) -{ - xmlNodePtr trav = node; - if(node == NULL) return NULL; - do - { - if(node_is_equal_ex(trav, name, ns)) - return trav; - else - { - if(node->children != NULL) - { - xmlNodePtr tmp; - tmp = get_node_recurisve_ex(node->children, name, ns); - if(tmp) - return tmp; - } - } - } while(trav = trav->next); - return NULL; -} - -xmlNodePtr get_node_with_attribute_ex(xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns) -{ - xmlNodePtr trav = node, cur = NULL; - xmlAttrPtr attr; - - if(node == NULL) return NULL; - do - { - if(name != NULL) - { - cur = get_node_ex(trav, name, name_ns); - if(!cur) - return cur; - } - else - cur = trav; - - attr = get_attribute_ex(cur->properties, attribute, attr_ns); - if(attr != NULL && strcmp(attr->children->content, value) == 0) - return cur; - else - { - if(cur->children != NULL) - { - xmlNodePtr tmp; - tmp = get_node_with_attribute_ex(cur->children, name, name_ns, attribute, value, attr_ns); - if(tmp) - return tmp; - } - } - }while(trav = trav->next); - return NULL; -} - -xmlNodePtr get_node_with_attribute_recursive_ex(xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns) -{ - xmlNodePtr trav = node, cur; - xmlAttrPtr attr; - - if(node == NULL) return NULL; - do - { - if(name != NULL) - { - cur = get_node_recurisve_ex(trav, name, name_ns); - if(!cur) - return cur; - } - else - cur = trav; - - attr = get_attribute_ex(cur->properties, attribute, attr_ns); - if(attr != NULL && strcmp(attr->children->content, value) == 0) - return cur; - else - { - if(cur->children != NULL) - { - xmlNodePtr tmp; - tmp = get_node_with_attribute_recursive_ex(cur->children, name, name_ns, attribute, value, attr_ns); - if(tmp) - return tmp; - } - } - }while(trav = trav->next); - return NULL; -} - -xmlNodePtr check_and_resolve_href(xmlNodePtr data) -{ - xmlAttrPtr href; - xmlNodePtr ret = data; - - if(!data || !data->properties) - return ret; - - href = get_attribute(data->properties, "href"); - if(href) - { - /* Internal href try and find node */ - if(href->children->content[0] == '#') - { - ret = get_node_with_attribute_recursive(data->doc->children, NULL, "id", &href->children->content[1]); - } - /* External href....? */ - } - - return ret; -} - -int parse_namespace(char *inval, char **value, char **namespace) -{ - char *found = strchr(inval, ':'); - - if(found != NULL) - { - (*namespace) = estrndup(inval, found - inval); - (*value) = estrdup(++found); - } - else - { - (*value) = estrdup(inval); - (*namespace) = NULL; - } - - return FALSE; -} - diff --git a/ext/soap/php_xml.h b/ext/soap/php_xml.h deleted file mode 100644 index 461bf9dd97..0000000000 --- a/ext/soap/php_xml.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef PHP_SOAP_XML_H -#define PHP_SOAP_XML_H - -#define get_attribute(node, name) get_attribute_ex(node, name, NULL) -#define get_node(node, name) get_node_ex(node, name, NULL) -#define get_node_recursive(node, name) get_node_recursive_ex(node, name, NULL) -#define get_node_with_attribute(node, name, attr, val) get_node_with_attribute_ex(node, name, NULL, attr, val, NULL) -#define get_node_with_attribute_recursive(node, name, attr, val) get_node_with_attribute_recursive_ex(node, name, NULL, attr, val, NULL) -#define attr_is_equal(node, name) attr_is_equal_ex(node, name, NULL) - -xmlNsPtr attr_find_ns(xmlAttrPtr node); -xmlNsPtr node_find_ns(xmlNodePtr node); -int attr_is_equal_ex(xmlAttrPtr node, char *name, char *ns); -int node_is_equal_ex(xmlNodePtr node, char *name, char *ns); -xmlAttrPtr get_attribute_ex(xmlAttrPtr node,char *name, char *ns); -xmlNodePtr get_node_ex(xmlNodePtr node,char *name, char *ns); -xmlNodePtr get_node_recurisve_ex(xmlNodePtr node,char *name, char *ns); -xmlNodePtr get_node_with_attribute_ex(xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns); -xmlNodePtr get_node_with_attribute_recursive_ex(xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns); -int parse_namespace(char *inval,char **value,char **namespace); -xmlNodePtr check_and_resolve_href(xmlNodePtr data); - -int php_stream_xmlIO_match_wrapper(const char *filename); -void *php_stream_xmlIO_open_wrapper(const char *filename); -int php_stream_xmlIO_read(void *context, char *buffer, int len); -int php_stream_xmlIO_close(void *context); - -#endif diff --git a/ext/soap/soap.c b/ext/soap/soap.c deleted file mode 100644 index a349503d86..0000000000 --- a/ext/soap/soap.c +++ /dev/null @@ -1,2309 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include "php_soap.h" - -int le_sdl = 0; -int le_url = 0; -int le_service = 0; - -/* Local functions */ -static void function_to_string(sdlFunctionPtr function, smart_str *buf); -static void type_to_string(sdlTypePtr type, smart_str *buf, int level); - -static zend_class_entry soap_class_entry; -static zend_class_entry soap_server_class_entry; -static zend_class_entry soap_fault_class_entry; -zend_class_entry soap_var_class_entry; -zend_class_entry soap_param_class_entry; - -ZEND_DECLARE_MODULE_GLOBALS(soap); - -static void (*old_handler)(int, const char *, const uint, const char*, va_list); - -static zend_function_entry soap_functions[] = { -#ifdef HAVE_PHP_DOMXML - PHP_FE(soap_encode_to_xml, NULL) - PHP_FE(soap_encode_to_zval, NULL) -#endif - {NULL, NULL, NULL} -}; - -static zend_function_entry soap_fault_functions[] = { - PHP_FE(soapfault, NULL) - {NULL, NULL, NULL} -}; - -static zend_function_entry soap_server_functions[] = { - PHP_FE(soapserver,NULL) - PHP_FE(setpersistence,NULL) - PHP_FE(setclass,NULL) - PHP_FE(addfunction,NULL) - PHP_FE(getfunctions,NULL) - PHP_FE(handle,NULL) - PHP_FE(bind,NULL) -#ifdef HAVE_PHP_DOMXML - PHP_FE(map, NULL) -#endif - {NULL, NULL, NULL} -}; - -static zend_function_entry soap_client_functions[] = { - PHP_FE(soapobject, NULL) - PHP_FE(__isfault, NULL) - PHP_FE(__getfault, NULL) - PHP_FE(__use, NULL) - PHP_FE(__style, NULL) - PHP_FE(__call, NULL) - PHP_FE(__parse, NULL) - PHP_FE(__generate, NULL) - PHP_FE(__trace, NULL) - PHP_FE(__headerclass, NULL) - PHP_FE(__headerfunction, NULL) - PHP_FE(__getlastrequest, NULL) - PHP_FE(__getlastresponse, NULL) - PHP_FE(__getfunctions, NULL) - PHP_FE(__gettypes, NULL) - {NULL, NULL, NULL} -}; - -static zend_function_entry soap_var_functions[] = { - PHP_FE(soapvar, NULL) - {NULL, NULL, NULL} -}; - -static zend_function_entry soap_param_functions[] = { - PHP_FE(soapparam, NULL) - {NULL, NULL, NULL} -}; - -zend_module_entry soap_module_entry = { -#ifdef STANDARD_MODULE_HEADER - STANDARD_MODULE_HEADER, -#endif - "soap", - soap_functions, - PHP_MINIT(soap), - PHP_MSHUTDOWN(soap), - NULL, - NULL, - PHP_MINFO(soap), -#ifdef STANDARD_MODULE_HEADER - NO_VERSION_YET, -#endif - STANDARD_MODULE_PROPERTIES, -}; - -#ifdef COMPILE_DL_SOAP -ZEND_GET_MODULE(soap) -#endif - -static void php_soap_init_globals(zend_soap_globals *soap_globals) -{ - int i; - long enc; - - soap_globals->sdls = malloc(sizeof(HashTable)); - zend_hash_init(soap_globals->sdls, 0, NULL, delete_sdl, 1); - - soap_globals->services = malloc(sizeof(HashTable)); - zend_hash_init(soap_globals->services, 0, NULL, delete_service, 1); - - soap_globals->defEnc = malloc(sizeof(HashTable)); - zend_hash_init(soap_globals->defEnc, 0, NULL, NULL, 1); - - soap_globals->defEncIndex = malloc(sizeof(HashTable)); - zend_hash_init(soap_globals->defEncIndex, 0, NULL, NULL, 1); - - soap_globals->defEncNs = malloc(sizeof(HashTable)); - zend_hash_init(soap_globals->defEncNs, 0, NULL, NULL, 1); - - soap_globals->defEncPrefix = malloc(sizeof(HashTable)); - zend_hash_init(soap_globals->defEncPrefix, 0, NULL, NULL, 1); - - soap_globals->overrides = NULL; - - i = 0; - do - { - enc = (long)&defaultEncoding[i]; - - /* If has a ns and a str_type then index it */ - if(defaultEncoding[i].details.type_str) - { - if(defaultEncoding[i].details.ns != NULL) - { - char *ns_type; - ns_type = emalloc(strlen(defaultEncoding[i].details.ns) + strlen(defaultEncoding[i].details.type_str) + 2); - sprintf(ns_type, "%s:%s", defaultEncoding[i].details.ns, defaultEncoding[i].details.type_str); - zend_hash_add(soap_globals->defEnc, ns_type, strlen(ns_type) + 1, &enc, sizeof(encodePtr), NULL); - efree(ns_type); - } - else - { - zend_hash_add(soap_globals->defEnc, defaultEncoding[i].details.type_str, strlen(defaultEncoding[i].details.type_str) + 1, &enc, sizeof(encodePtr), NULL); - } - } - /* Index everything by number */ - zend_hash_index_update(soap_globals->defEncIndex, defaultEncoding[i].details.type, &enc, sizeof(encodePtr), NULL); - i++; - } - while(defaultEncoding[i].details.type != END_KNOWN_TYPES); - - /* hash by namespace */ - zend_hash_add(soap_globals->defEncNs, XSD_1999_NAMESPACE, sizeof(XSD_1999_NAMESPACE), XSD_NS_PREFIX, sizeof(XSD_NS_PREFIX), NULL); - zend_hash_add(soap_globals->defEncNs, XSD_NAMESPACE, sizeof(XSD_NAMESPACE), XSD_NS_PREFIX, sizeof(XSD_NS_PREFIX), NULL); - zend_hash_add(soap_globals->defEncNs, APACHE_NAMESPACE, sizeof(APACHE_NAMESPACE), APACHE_NS_PREFIX, sizeof(APACHE_NS_PREFIX), NULL); - zend_hash_add(soap_globals->defEncNs, SOAP_ENC_NAMESPACE, sizeof(SOAP_ENC_NAMESPACE), SOAP_ENC_NS_PREFIX, sizeof(SOAP_ENC_NS_PREFIX), NULL); - /* and by prefix */ - zend_hash_add(soap_globals->defEncPrefix, XSD_NS_PREFIX, sizeof(XSD_NS_PREFIX), XSD_NAMESPACE, sizeof(XSD_NAMESPACE), NULL); - zend_hash_add(soap_globals->defEncPrefix, APACHE_NS_PREFIX, sizeof(APACHE_NS_PREFIX), APACHE_NAMESPACE, sizeof(APACHE_NAMESPACE), NULL); - zend_hash_add(soap_globals->defEncPrefix, SOAP_ENC_NS_PREFIX, sizeof(SOAP_ENC_NS_PREFIX), SOAP_ENC_NAMESPACE, sizeof(SOAP_ENC_NAMESPACE), NULL); - -} - -static void php_soap_del_globals(zend_soap_globals *soap_globals) -{ -/* zend_hash_destroy(soap_globals->sdls); - zend_hash_destroy(soap_globals->services); - zend_hash_destroy(soap_globals->defEnc); - zend_hash_destroy(soap_globals->defEncIndex); - zend_hash_destroy(soap_globals->defEncNs);*/ -} - -PHP_MSHUTDOWN_FUNCTION(soap) -{ - zend_hash_destroy(SOAP_GLOBAL(sdls)); - zend_hash_destroy(SOAP_GLOBAL(services)); - zend_hash_destroy(SOAP_GLOBAL(defEnc)); - zend_hash_destroy(SOAP_GLOBAL(defEncIndex)); - zend_hash_destroy(SOAP_GLOBAL(defEncNs)); - zend_hash_destroy(SOAP_GLOBAL(defEncPrefix)); - return SUCCESS; -} - -PHP_MINIT_FUNCTION(soap) -{ - /* TODO: add ini entry for always use soap errors */ - ZEND_INIT_MODULE_GLOBALS(soap, php_soap_init_globals, php_soap_del_globals); - - /* Enable php stream/wrapper support for libxml */ - xmlRegisterDefaultInputCallbacks(); - xmlRegisterInputCallbacks(php_stream_xmlIO_match_wrapper, php_stream_xmlIO_open_wrapper, - php_stream_xmlIO_read, php_stream_xmlIO_close); - - /* Register SoapObject class */ - /* BIG NOTE : THIS EMITS AN COMPILATION WARNING UNDER ZE2 - handle_function_call deprecated. - soap_call_function_handler should be of type struct _zend_function, not (*handle_function_call). - */ - INIT_OVERLOADED_CLASS_ENTRY(soap_class_entry, PHP_SOAP_CLASSNAME, soap_client_functions, soap_call_function_handler, NULL, NULL); - zend_register_internal_class(&soap_class_entry TSRMLS_CC); - - /* Register SoapVar class */ - INIT_CLASS_ENTRY(soap_var_class_entry, PHP_SOAP_VAR_CLASSNAME, soap_var_functions); - zend_register_internal_class(&soap_var_class_entry TSRMLS_CC); - - /* Register SoapServer class */ - INIT_CLASS_ENTRY(soap_server_class_entry, PHP_SOAP_SERVER_CLASSNAME, soap_server_functions); - zend_register_internal_class(&soap_server_class_entry TSRMLS_CC); - - /* Register SoapFault class */ - INIT_CLASS_ENTRY(soap_fault_class_entry, PHP_SOAP_FAULT_CLASSNAME, soap_fault_functions); - zend_register_internal_class(&soap_fault_class_entry TSRMLS_CC); - - /* Register SoapParam class */ - INIT_CLASS_ENTRY(soap_param_class_entry, PHP_SOAP_PARAM_CLASSNAME, soap_param_functions); - zend_register_internal_class(&soap_param_class_entry TSRMLS_CC); - - le_sdl = register_list_destructors(NULL, NULL); - le_url = register_list_destructors(delete_url, NULL); - le_service = register_list_destructors(delete_service, NULL); - - REGISTER_LONG_CONSTANT("SOAP_PERSISTENCE_SESSION", SOAP_PERSISTENCE_SESSION, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SOAP_PERSISTENCE_REQUEST", SOAP_PERSISTENCE_REQUEST, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SOAP_FUNCTIONS_ALL", SOAP_FUNCTIONS_ALL, CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("SOAP_ENCODED", SOAP_ENCODED, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SOAP_LITERAL", SOAP_LITERAL, CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("SOAP_RPC", SOAP_RPC, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SOAP_DOCUMENT", SOAP_DOCUMENT, CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("XSD_1999_TIMEINSTANT", XSD_1999_TIMEINSTANT, CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("UNKNOWN_TYPE", UNKNOWN_TYPE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SOAP_ENC_OBJECT", SOAP_ENC_OBJECT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SOAP_ENC_ARRAY", SOAP_ENC_ARRAY, CONST_CS | CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("XSD_STRING", XSD_STRING, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_BOOLEAN", XSD_BOOLEAN, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_DECIMAL", XSD_DECIMAL, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_FLOAT", XSD_FLOAT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_DOUBLE", XSD_DOUBLE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_DURATION", XSD_DURATION, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_DATETIME", XSD_DATETIME, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_TIME", XSD_TIME, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_DATE", XSD_DATE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_GYEARMONTH", XSD_GYEARMONTH, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_GYEAR", XSD_GYEAR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_GMONTHDAY", XSD_GMONTHDAY, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_GDAY", XSD_GDAY, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_GMONTH", XSD_GMONTH, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_HEXBINARY", XSD_HEXBINARY, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_BASE64BINARY", XSD_BASE64BINARY, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_ANYURI", XSD_ANYURI, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_QNAME", XSD_QNAME, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_NOTATION", XSD_NOTATION, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_NORMALIZEDSTRING", XSD_NORMALIZEDSTRING, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_TOKEN", XSD_TOKEN, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_LANGUAGE", XSD_LANGUAGE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_NMTOKEN", XSD_NMTOKEN, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_NAME", XSD_NAME, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_NCNAME", XSD_NCNAME, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_ID", XSD_ID, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_IDREF", XSD_IDREF, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_IDREFS", XSD_IDREFS, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_ENTITY", XSD_ENTITY, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_ENTITYS", XSD_ENTITYS, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_INTEGER", XSD_INTEGER, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_NONPOSITIVEINTEGER", XSD_NONPOSITIVEINTEGER, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_NEGATIVEINTEGER", XSD_NEGATIVEINTEGER, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_LONG", XSD_LONG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_INT", XSD_INT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_SHORT", XSD_SHORT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_BYTE", XSD_BYTE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_NONNEGATIVEINTEGER", XSD_NONNEGATIVEINTEGER, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_UNSIGNEDLONG", XSD_UNSIGNEDLONG, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_UNSIGNEDINT", XSD_UNSIGNEDINT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_UNSIGNEDSHORT", XSD_UNSIGNEDSHORT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_UNSIGNEDBYTE", XSD_UNSIGNEDBYTE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSD_POSITIVEINTEGER", XSD_POSITIVEINTEGER, CONST_CS | CONST_PERSISTENT); - - old_handler = zend_error_cb; - -#if HAVE_PHP_SESSION - php_session_register_serializer("soap", PS_SERIALIZER_ENCODE_NAME(soap), PS_SERIALIZER_DECODE_NAME(soap)); -#endif - - return SUCCESS; -} - -#if HAVE_PHP_SESSION -PS_SERIALIZER_ENCODE_FUNC(soap) -{ -/* - char *key; \ - uint key_length; \ - ulong num_key; \ - zval **struc; - - wddx_packet *packet; - PS_ENCODE_VARS; - - packet = php_wddx_constructor(); - if (!packet) - return FAILURE; - - php_wddx_packet_start(packet, NULL, 0); - php_wddx_add_chunk_static(packet, WDDX_STRUCT_S); - - PS_ENCODE_LOOP( - - php_wddx_serialize_var(packet, *struc, key, key_length); - ); - - php_wddx_add_chunk_static(packet, WDDX_STRUCT_E); - php_wddx_packet_end(packet); - *newstr = php_wddx_gather(packet); - php_wddx_destructor(packet); - - if (newlen) - *newlen = strlen(*newstr); -*/ - return SUCCESS; -} - -PS_SERIALIZER_DECODE_FUNC(soap) -{ -/* zval *retval; - zval **ent; - char *key; - uint key_length; - char tmp[128]; - ulong idx; - int hash_type; - int ret; - HashPosition pos; - - if (vallen == 0) - return SUCCESS; - - MAKE_STD_ZVAL(retval); - - if ((ret = php_wddx_deserialize_ex((char *)val, vallen, retval)) == SUCCESS) { - - for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(retval), &pos); - zend_hash_get_current_data_ex(Z_ARRVAL_P(retval), (void **) &ent, &pos) == SUCCESS; - zend_hash_move_forward(Z_ARRVAL_P(retval), &pos)) { - hash_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(retval), &key, &key_length, &idx, 0, &pos); - - switch (hash_type) { - case HASH_KEY_IS_LONG: - sprintf(tmp, "%ld", idx); - key = tmp; - case HASH_KEY_IS_STRING: - php_set_session_var(key, key_length-1, *ent, NULL TSRMLS_CC); - PS_ADD_VAR(key); - } - } - } - - zval_ptr_dtor(&retval); -*/ - return TRUE; -} -#endif - - -PHP_MINFO_FUNCTION(soap) -{ - php_info_print_table_start(); - php_info_print_table_row(2, "Soap Client", "enabled"); - php_info_print_table_row(2, "Soap Server", "enabled"); -#if HAVE_PHP_SESSION - php_info_print_table_row(2, "Soap Serializer", "enabled"); -#endif - php_info_print_table_end(); -} - -#ifdef HAVE_PHP_DOMXML -PHP_FUNCTION(soap_encode_to_xml) -{ - zval *pzval, *ret; - encodePtr enc; - char *name; - int found, name_len; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &name, &name_len, &pzval) == FAILURE) - php_error(E_ERROR, "wrong number of parameters to soap_encode_to_xml"); - - enc = get_conversion(Z_TYPE_P(pzval)); - ret = php_domobject_new(seralize_zval(pzval, NULL, name, SOAP_ENCODED), &found, NULL TSRMLS_CC); - *return_value = *ret; - zval_copy_ctor(return_value); - zval_ptr_dtor(&ret); -} - -PHP_FUNCTION(soap_encode_to_zval) -{ - zval *dom, **addr, *ret; - xmlNodePtr node; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &dom) == FAILURE) - php_error(E_ERROR, "wrong number of parameters to soap_encode_to_zval"); - - if(zend_hash_index_find(Z_OBJPROP_P(dom), 1, (void **)&addr) == FAILURE) - php_error(E_ERROR, "Cannot find domaddress to parameter passed to soap_encode_to_zval"); - - node = (xmlNodePtr)Z_LVAL_PP(addr); - ret = master_to_zval(get_conversion(UNKNOWN_TYPE), node); - *return_value = *ret; -} -#endif - -/* SoapParam functions */ -PHP_FUNCTION(soapparam) -{ - zval *thisObj, *data; - char *name; - int name_length; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs", &data, &name, &name_length) == FAILURE) - php_error(E_ERROR, "Invalid arguments to SoapParam constructor"); - - GET_THIS_OBJECT(thisObj); - - zval_add_ref(&data); - add_property_stringl(thisObj, "param_name", name, name_length, 1); - add_property_zval(thisObj, "param_data", data); -} - -/* SoapFault functions */ -PHP_FUNCTION(soapfault) -{ - char *fault_string = NULL, *fault_code = NULL, *fault_actor = NULL; - int fault_string_len, fault_code_len, fault_actor_len; - zval *thisObj, *details = NULL; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|zs", &fault_string, &fault_string_len, - &fault_code, &fault_code_len, &details, &fault_actor, &fault_actor_len) == FAILURE) - php_error(E_ERROR, "Invalid arguments to SoapFault constructor"); - - GET_THIS_OBJECT(thisObj); - - if(details) - zval_add_ref(&details); - set_soap_fault(thisObj, fault_code, fault_string, fault_actor, details TSRMLS_CC); -} - -/* SoapVar functions */ -PHP_FUNCTION(soapvar) -{ - zval *data, *thisObj, *type; - char *stype = NULL, *ns = NULL, *name = NULL, *namens = NULL; - int stype_len, ns_len, name_len, namens_len; - - GET_THIS_OBJECT(thisObj); - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z!z|ssss", &data, &type, &stype, &stype_len, &ns, &ns_len, &name, &name_len, &namens, &namens_len) == FAILURE) - php_error(E_ERROR, "Invalid arguments to SoapVal constructor"); - - zval_add_ref(&data); - if(Z_TYPE_P(type) == IS_NULL) - add_property_long(thisObj, "enc_type", UNKNOWN_TYPE); - else - { - if(zend_hash_index_exists(SOAP_GLOBAL(defEncIndex), Z_LVAL_P(type))) - add_property_long(thisObj, "enc_type", Z_LVAL_P(type)); - else - php_error(E_ERROR, "Cannot find encoding for SoapVar"); - } - - add_property_zval(thisObj, "enc_value", data); - - if(stype && strlen(stype) > 0) - add_property_stringl(thisObj, "enc_stype", stype, stype_len, 1); - if(ns && strlen(ns) > 0) - add_property_stringl(thisObj, "enc_ns", ns, ns_len, 1); - if(name && strlen(name) > 0) - add_property_stringl(thisObj, "enc_name", name, name_len, 1); - if(namens && strlen(namens) > 0) - add_property_stringl(thisObj, "enc_namens", namens, namens_len, 1); -} - -/* SoapServer functions */ -PHP_FUNCTION(soapserver) -{ - zval *thisObj; - soapServicePtr service; - char *uri; - int ret, uri_len; - - SOAP_SERVER_BEGIN_CODE(); - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &uri, &uri_len) == FAILURE) - php_error(E_ERROR, "Wrong number of parameters to SoapServer constructor"); - - GET_THIS_OBJECT(thisObj); - - service = emalloc(sizeof(soapService)); - memset(service, 0, sizeof(soapService)); - - service->uri = estrndup(uri, uri_len); - service->type = SOAP_FUNCTIONS; - service->soap_functions.functions_all = FALSE; - service->soap_functions.ft = emalloc(sizeof(HashTable)); - zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0); - - ret = zend_list_insert(service, le_service); - add_property_resource(thisObj, "service", ret); - zend_list_addref(ret); - - SOAP_SERVER_END_CODE(); -} - -#define NULL_OR_STRING(zval) \ - (!zval || Z_TYPE_P(zval) == IS_NULL || Z_TYPE_P(zval) == IS_STRING) - -#define IS_VALID_FUNCTION(zval) \ - (zval && Z_TYPE_P(zval) != IS_NULL) - -#ifdef HAVE_PHP_DOMXML -PHP_FUNCTION(map) -{ - char *type, *class_name; - zval *to_xml_before = NULL, *to_xml = NULL, *to_xml_after = NULL, - *to_zval_before = NULL, *to_zval = NULL, *to_zval_after = NULL; - int type_len, class_name_len; - char *ns, *ctype; - soapServicePtr service; - - SOAP_SERVER_BEGIN_CODE(); - - if(zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "sz|zzzzz", - &type, &type_len, &to_xml_before, &to_xml, &to_xml_after, &to_zval_before, &to_zval, - &to_zval_after) == SUCCESS && NULL_OR_STRING(to_xml_before) && NULL_OR_STRING(to_xml) && - NULL_OR_STRING(to_xml_after) && NULL_OR_STRING(to_zval_before) && NULL_OR_STRING(to_zval) && - NULL_OR_STRING(to_zval_after)) - { - soapMappingPtr map; - encodePtr enc, new_enc; - smart_str resloved_ns = {0}; - - FETCH_THIS_SERVICE(service); - - new_enc = malloc(sizeof(encode)); - memset(new_enc, 0, sizeof(encode)); - - ctype = strrchr(type, ':'); - if(ctype) { - smart_str_appendl(&resloved_ns, type, ctype - type); - smart_str_0(&resloved_ns); - ctype++; - } else { - ns = NULL; - } - - if(ns) - { - if(zend_hash_find(SOAP_GLOBAL(defEncPrefix), resloved_ns.c, resloved_ns.len + 1, &ns) == SUCCESS) - { - enc = get_encoder(service->sdl, ns, ctype); - smart_str_free(&resloved_ns); - smart_str_appendl(&resloved_ns, ns, strlen(ns)); - smart_str_appendc(&resloved_ns, ':'); - smart_str_appendl(&resloved_ns, ctype, strlen(ctype)); - smart_str_0(&resloved_ns); - type = resloved_ns.c; - type_len = resloved_ns.len; - } - else - enc = get_encoder_ex(service->sdl, type); - } - else - enc = get_encoder_ex(service->sdl, type); - - new_enc->details.type = enc->details.type; - new_enc->details.ns = strdup(enc->details.ns); - new_enc->details.type_str = strdup(enc->details.type_str); - new_enc->details.sdl_type = enc->details.sdl_type; - new_enc->to_xml = enc->to_xml; - new_enc->to_zval = enc->to_zval; - new_enc->to_xml_before = enc->to_xml_before; - new_enc->to_zval_before = enc->to_zval_before; - new_enc->to_xml_after = enc->to_xml_after; - new_enc->to_zval_after = enc->to_zval_after; - - map = emalloc(sizeof(soapMapping)); - memset(map, 0, sizeof(soapMapping)); - - map->type = SOAP_MAP_FUNCTION; - if(IS_VALID_FUNCTION(to_xml_before)) - { - zval_add_ref(&to_xml_before); - map->map_functions.to_xml_before = to_xml_before; - new_enc->to_xml_before = to_xml_before_user; - } - if(IS_VALID_FUNCTION(to_xml)) - { - zval_add_ref(&to_xml); - map->map_functions.to_xml = to_xml; - new_enc->to_xml = to_xml_user; - } - if(IS_VALID_FUNCTION(to_xml_after)) - { - zval_add_ref(&to_xml_after); - map->map_functions.to_xml_after = to_xml_after; - new_enc->to_xml_after = to_xml_after_user; - } - if(IS_VALID_FUNCTION(to_zval_before)) - { - zval_add_ref(&to_zval_before); - map->map_functions.to_zval_before = to_zval_before; - new_enc->to_zval_before = to_zval_before_user; - } - if(IS_VALID_FUNCTION(to_zval)) - { - zval_add_ref(&to_zval); - map->map_functions.to_zval = to_zval; - new_enc->to_zval = to_zval_user; - } - if(IS_VALID_FUNCTION(to_zval_after)) - { - zval_add_ref(&to_zval_after); - map->map_functions.to_zval_after = to_zval_after; - new_enc->to_zval_after = to_zval_after_user; - } - - new_enc->details.map = map; - - if(!service->mapping) - { - service->mapping = emalloc(sizeof(HashTable)); - zend_hash_init(service->mapping, 0, NULL, delete_encoder, 0); - } - zend_hash_update(service->mapping, type, type_len + 1, &new_enc, sizeof(encodePtr), NULL); - smart_str_free(&resloved_ns); - } - else if(zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &type, &type_len, &class_name, &class_name_len, &type) == SUCCESS) - { - } - else - php_error(E_ERROR, "Wrong number of parameters to SoapServer->map"); -} -#endif - -PHP_FUNCTION(bind) -{ - char *wsdl; - int wsdl_len; - soapServicePtr service; - - SOAP_SERVER_BEGIN_CODE(); - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &wsdl, &wsdl_len) == FAILURE) - php_error(E_ERROR, "Wrong number of parameters to SoapServer->bind"); - - FETCH_THIS_SERVICE(service); - service->sdl = get_sdl(wsdl); - - SOAP_SERVER_END_CODE(); -} - -PHP_FUNCTION(setpersistence) -{ - soapServicePtr service; - int value; - - SOAP_SERVER_BEGIN_CODE(); - FETCH_THIS_SERVICE(service); - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &value) != FAILURE) - { - if(service->type == SOAP_CLASS) - { - if(value == SOAP_PERSISTENCE_SESSION || - value == SOAP_PERSISTENCE_REQUEST) - service->soap_class.persistance = value; - else - php_error(E_ERROR, "Tried to set persistence with bogus value (%ld)", value); - } - else - php_error(E_ERROR, "Tried to set persistence when you are using you SOAP SERVER in function mode, no persistence needed"); - } - - SOAP_SERVER_END_CODE(); -} - -PHP_FUNCTION(setclass) -{ - soapServicePtr service; - zend_class_entry *ce; - char *class_name = NULL; - int found, argc; - zval ***argv; - - SOAP_SERVER_BEGIN_CODE(); - - FETCH_THIS_SERVICE(service); - - argc = ZEND_NUM_ARGS(); - argv = emalloc(argc * sizeof(zval **)); - - if (argc < 1 || zend_get_parameters_array_ex(argc, argv) == FAILURE) - { - efree(argv); - WRONG_PARAM_COUNT; - } - - if(Z_TYPE_PP(argv[0]) == IS_STRING) - { - class_name = estrdup(Z_STRVAL_PP(argv[0])); - - found = zend_hash_find(EG(class_table), php_strtolower(class_name, Z_STRLEN_PP(argv[0])), Z_STRLEN_PP(argv[0]) + 1, (void **)&ce); - efree(class_name); - if(found != FAILURE) - { - service->type = SOAP_CLASS; - service->soap_class.ce = ce; - service->soap_class.persistance = SOAP_PERSISTENCE_REQUEST; - service->soap_class.argc = argc - 1; - if(service->soap_class.argc > 0) - { - int i; - service->soap_class.argv = emalloc(sizeof(zval) * service->soap_class.argc); - for(i = 0;i < service->soap_class.argc;i++) - { - service->soap_class.argv[i] = *(argv[i + 1]); - zval_add_ref(&service->soap_class.argv[i]); - } - } - } - else - php_error(E_ERROR, "Tried to set a non existant class (%s)", Z_STRVAL_PP(argv[0])); - } - else - php_error(E_ERROR, "You must pass in a string to setclass"); - - efree(argv); - SOAP_SERVER_END_CODE(); -} - -PHP_FUNCTION(getfunctions) -{ - soapServicePtr service; - HashPosition pos; - - SOAP_SERVER_BEGIN_CODE(); - - FETCH_THIS_SERVICE(service); - - array_init(return_value); - if(service->type == SOAP_CLASS) - { - zend_function *f; - zend_hash_internal_pointer_reset_ex(&service->soap_class.ce->function_table, &pos); - while(zend_hash_get_current_data_ex(&service->soap_class.ce->function_table, (void **)&f, &pos) != FAILURE) - { - add_next_index_string(return_value, f->common.function_name, 1); - zend_hash_move_forward_ex(&service->soap_class.ce->function_table, &pos); - } - } - else if(service->soap_functions.functions_all == TRUE) - { - zend_function *f; - zend_hash_internal_pointer_reset_ex(EG(function_table), &pos); - while(zend_hash_get_current_data_ex(EG(function_table), (void **)&f, &pos) != FAILURE) - { - add_next_index_string(return_value, f->common.function_name, 1); - zend_hash_move_forward_ex(EG(function_table), &pos); - } - } - else if(service->soap_functions.ft != NULL) - zend_hash_copy(Z_ARRVAL_P(return_value), service->soap_functions.ft, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); - - SOAP_SERVER_END_CODE(); -} - -PHP_FUNCTION(addfunction) -{ - soapServicePtr service; - zval *function_name, *function_copy; - HashPosition pos; - - SOAP_SERVER_BEGIN_CODE(); - - FETCH_THIS_SERVICE(service); - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &function_name) == FAILURE) - php_error(E_ERROR, "Invalid parameters passed to addfunction"); - - /* TODO: could use zend_is_callable here */ - - if(function_name->type == IS_ARRAY) - { - if(service->type == SOAP_FUNCTIONS) - { - zval **tmp_function, *function_copy; - - if(service->soap_functions.ft == NULL) - { - service->soap_functions.ft = emalloc(sizeof(HashTable)); - zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0); - } - - zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(function_name), &pos); - while(zend_hash_get_current_data_ex(Z_ARRVAL_P(function_name), (void **)&tmp_function, &pos) != FAILURE) - { - if(Z_TYPE_PP(tmp_function) != IS_STRING) - php_error(E_ERROR, "Tried to add a function that isn't a string"); - - MAKE_STD_ZVAL(function_copy); - *function_copy = *(*tmp_function); - zval_copy_ctor(function_copy); - - php_strtolower(Z_STRVAL_P(function_copy), Z_STRLEN_P(function_copy)); - - if(zend_hash_exists(EG(function_table), Z_STRVAL_P(function_copy), Z_STRLEN_P(function_copy) + 1) == FALSE) - php_error(E_ERROR, "Tried to add a non existant function (\"%s\")", Z_STRVAL_PP(tmp_function)); - - zend_hash_update(service->soap_functions.ft, Z_STRVAL_P(function_copy), Z_STRLEN_P(function_copy) + 1, &function_copy, sizeof(zval *), NULL); - zend_hash_move_forward_ex(Z_ARRVAL_P(function_name), &pos); - } - } - } - else if(function_name->type == IS_STRING) - { - MAKE_STD_ZVAL(function_copy); - *function_copy = *function_name; - zval_copy_ctor(function_copy); - - php_strtolower(Z_STRVAL_P(function_copy), Z_STRLEN_P(function_copy)); - - if(zend_hash_exists(EG(function_table), Z_STRVAL_P(function_copy), Z_STRLEN_P(function_copy) + 1) == FALSE) - php_error(E_ERROR, "Tried to add a non existant function (\"%s\")", Z_STRVAL_P(function_name)); - if(service->soap_functions.ft == NULL) - { - service->soap_functions.functions_all = FALSE; - service->soap_functions.ft = emalloc(sizeof(HashTable)); - zend_hash_init(service->soap_functions.ft, 0, NULL, ZVAL_PTR_DTOR, 0); - } - - zend_hash_update(service->soap_functions.ft, Z_STRVAL_P(function_copy), Z_STRLEN_P(function_copy) + 1, &function_copy, sizeof(zval *), NULL); - } - else if(function_name->type == IS_LONG) - { - if(Z_LVAL_P(function_name) == SOAP_FUNCTIONS_ALL) - { - if(service->soap_functions.ft != NULL) - { - zend_hash_destroy(service->soap_functions.ft); - efree(service->soap_functions.ft); - service->soap_functions.ft = NULL; - } - service->soap_functions.functions_all = TRUE; - } - else - php_error(E_ERROR, "Invalid value passed to addfunction (%ld)", Z_LVAL_P(function_name)); - } - - SOAP_SERVER_END_CODE(); -} - -PHP_FUNCTION(handle) -{ - soapServicePtr service; - xmlDocPtr doc_request, doc_return; - zval function_name, **params, **raw_post, *soap_obj, retval, **server_vars; - char *fn_name, cont_len[30], *response_name; - int num_params = 0, size, i, call_status; - xmlChar *buf; - HashTable *function_table; - - FETCH_THIS_SERVICE(service); - - SOAP_SERVER_BEGIN_CODE(); - ZERO_PARAM(); - - INIT_ZVAL(retval); - - if(zend_hash_find(&EG(symbol_table), "_SERVER", sizeof("_SERVER"), (void **)&server_vars) == SUCCESS) - { - zval **req_method, **query_string; - if(zend_hash_find(Z_ARRVAL_PP(server_vars), "REQUEST_METHOD", sizeof("REQUEST_METHOD"), (void **)&req_method) == SUCCESS) - { - if(!strcmp(Z_STRVAL_PP(req_method), "GET") && zend_hash_find(Z_ARRVAL_PP(server_vars), "QUERY_STRING", sizeof("QUERY_STRING"), (void **)&query_string) == SUCCESS) - { - if(!strcmp(Z_STRVAL_PP(query_string), "WSDL")) - { - if(service->sdl) - { - zval readfile, readfile_ret, *param; - - INIT_ZVAL(readfile); - INIT_ZVAL(readfile_ret); - MAKE_STD_ZVAL(param); - - sapi_add_header("Content-Type: text/xml", sizeof("Content-Type: text/xml"), 1); - ZVAL_STRING(param, service->sdl->source, 1); - ZVAL_STRING(&readfile, "readfile", 1); - if(call_user_function(EG(function_table), NULL, &readfile, &readfile_ret, 1, ¶m TSRMLS_CC) == FAILURE) - php_error(E_ERROR, "Couldn't find WSDL"); - - zval_ptr_dtor(¶m); - zval_dtor(&readfile); - zval_dtor(&readfile_ret); - SOAP_SERVER_END_CODE(); - return; - } - } - } - } - } - -/* Turn on output buffering... we don't want people print in their methods - #if PHP_API_VERSION <= 20010901 - if(php_start_ob_buffer(NULL, 0 TSRMLS_CC) != SUCCESS) - #else -*/ - if(php_start_ob_buffer(NULL, 0, 0 TSRMLS_CC) != SUCCESS) -/* #endif */ - php_error(E_ERROR,"ob_start failed"); - - if (zend_hash_find(&EG(symbol_table), HTTP_RAW_POST_DATA, sizeof(HTTP_RAW_POST_DATA), (void **) &raw_post)!=FAILURE - && ((*raw_post)->type==IS_STRING)) - { - doc_request = xmlParseMemory(Z_STRVAL_PP(raw_post),Z_STRLEN_PP(raw_post)); - xmlCleanupParser(); - - deseralize_function_call(service->sdl, doc_request, &function_name, &num_params, ¶ms TSRMLS_CC); - xmlFreeDoc(doc_request); - - fn_name = estrndup(Z_STRVAL(function_name),Z_STRLEN(function_name)); - response_name = emalloc(Z_STRLEN(function_name) + strlen("Response") + 1); - sprintf(response_name,"%sResponse",fn_name); - - if(service->type == SOAP_CLASS) - { - soap_obj = NULL; - /* If persistent then set soap_obj from from the previous created session (if available) */ - if(service->soap_class.persistance == SOAP_PERSISTENCE_SESSION) - { - zval **tmp_soap; - - /* - Try and call session regiser for our dummy session object - The only reason that i use call_user_function is that - their isn't a way to start the session from an extension - so calling session_register will both register the var - and start the session - */ - { - zval *bogus_session_name, session_register, sess_retval; - - INIT_ZVAL(session_register); - INIT_ZVAL(sess_retval); - - if(!zend_ini_long("register_globals", sizeof("register_globals"), 0)) - php_error(E_ERROR, "PHP-SOAP requires 'register_globals' to be on when using persistent objects please check your php.ini file"); - - MAKE_STD_ZVAL(bogus_session_name); - - ZVAL_STRING(bogus_session_name, "_bogus_session_name", 1); - ZVAL_STRING(&session_register, "session_register", 1); - - if(call_user_function(EG(function_table), NULL, &session_register, &sess_retval, 1, &bogus_session_name TSRMLS_CC) == FAILURE) - php_error(E_ERROR,"session_register failed"); - - zval_ptr_dtor(&bogus_session_name); - zval_dtor(&session_register); - zval_dtor(&sess_retval); - } - - /* Find the soap object and assign */ - if(zend_hash_find(&EG(symbol_table), "_bogus_session_name", sizeof("_bogus_session_name"), (void **) &tmp_soap) == SUCCESS) - soap_obj = *tmp_soap; - } - - /* If new session or something wierd happned */ - if(soap_obj == NULL) - { - zval *tmp_soap; - MAKE_STD_ZVAL(tmp_soap); - object_init_ex(tmp_soap, service->soap_class.ce); - - /* Call constructor */ - if(zend_hash_exists(&Z_OBJCE_P(tmp_soap)->function_table, service->soap_class.ce->name, strlen(service->soap_class.ce->name) + 1)) - { - zval c_ret, constructor; - - INIT_ZVAL(c_ret); - INIT_ZVAL(constructor); - - ZVAL_STRING(&constructor, service->soap_class.ce->name, 1); - if(call_user_function(NULL, &tmp_soap, &constructor, &c_ret, service->soap_class.argc, service->soap_class.argv TSRMLS_CC) == FAILURE) - php_error(E_ERROR, "Error calling constructor"); - zval_dtor(&constructor); - zval_dtor(&c_ret); - } - - /* If session then update session hash with new object */ - if(service->soap_class.persistance == SOAP_PERSISTENCE_SESSION) - { - zval **tmp_soap_pp; - if(zend_hash_update(&EG(symbol_table), "_bogus_session_name", sizeof("_bogus_session_name"), &tmp_soap, sizeof(zval *), (void **)&tmp_soap_pp) == SUCCESS) - soap_obj = *tmp_soap_pp; - } - else - soap_obj = tmp_soap; - } -/* function_table = &(soap_obj->value.obj.ce->function_table);*/ - function_table = &((Z_OBJCE_P(soap_obj))->function_table); - } - else - { - if(service->soap_functions.functions_all == TRUE) - function_table = EG(function_table); - else - function_table = service->soap_functions.ft; - } - - doc_return = NULL; - if(zend_hash_exists(function_table, php_strtolower(Z_STRVAL(function_name), Z_STRLEN(function_name)), Z_STRLEN(function_name) + 1)) - { - if(service->type == SOAP_CLASS) - { - call_status = call_user_function(NULL, &soap_obj, &function_name, &retval, num_params, params TSRMLS_CC); - if(service->soap_class.persistance != SOAP_PERSISTENCE_SESSION) - zval_ptr_dtor(&soap_obj); - } - else - call_status = call_user_function(EG(function_table), NULL, &function_name, &retval, num_params, params TSRMLS_CC); - } - else - php_error(E_ERROR, "Function (%s) doesn't exist", Z_STRVAL(function_name)); - - if(call_status == SUCCESS) - { - sdlFunctionPtr function; - function = get_function(get_binding_from_type(service->sdl, BINDING_SOAP), Z_STRVAL(function_name)); - SOAP_GLOBAL(overrides) = service->mapping; - doc_return = seralize_response_call(function, response_name, service->uri, &retval TSRMLS_CC); - SOAP_GLOBAL(overrides) = NULL; - } - else - php_error(E_ERROR, "Function (%s) call failed", Z_STRVAL(function_name)); - - /* Flush buffer */ - php_end_ob_buffer(0, 0 TSRMLS_CC); - - /* xmlDocDumpMemoryEnc(doc_return, &buf, &size, XML_CHAR_ENCODING_UTF8); */ - xmlDocDumpMemory(doc_return, &buf, &size); - - if(size == 0) - php_error(E_ERROR, "Dump memory failed"); - - sprintf(cont_len, "Content-Length: %d", size); - sapi_add_header("Content-Type: text/xml", sizeof("Content-Type: text/xml"), 1); - sapi_add_header(cont_len, strlen(cont_len) + 1, 1); - - /* Free Memory */ - if(num_params > 0) - { - for(i = 0; i < num_params;i++) - zval_ptr_dtor(¶ms[i]); - efree(params); - } - - zval_dtor(&function_name); - xmlFreeDoc(doc_return); - efree(response_name); - efree(fn_name); - - php_write(buf, size TSRMLS_CC); - xmlFree(buf); - } - else - { - if(!zend_ini_long("always_populate_raw_post_data", sizeof("always_populate_raw_post_data"), 0)) - php_error(E_ERROR, "PHP-SOAP requires 'always_populate_raw_post_data' to be on please check your php.ini file"); - - php_error(E_ERROR, "Couln't find HTTP_RAW_POST_DATA"); - } - - zval_dtor(&retval); - SOAP_SERVER_END_CODE(); -} - -void soap_error_handler(int error_num, const char *error_filename, const uint error_lineno, const char *format, va_list args) -{ - char buffer[1024]; - int buffer_len; - TSRMLS_FETCH(); - - buffer_len = vsnprintf(buffer, sizeof(buffer)-1, format, args); - buffer[sizeof(buffer)-1]=0; - if(buffer_len > sizeof(buffer) - 1 || buffer_len < 0) { - buffer_len = sizeof(buffer) - 1; - } - - /* - Trap all errors - What do do with these warnings - E_WARNING, E_NOTICE, E_CORE_WARNING, E_COMPILE_WARNING, E_USER_WARNING, E_USER_NOTICE - */ - if(error_num == E_USER_ERROR || error_num == E_COMPILE_ERROR || error_num == E_CORE_ERROR || - error_num == E_ERROR || error_num == E_PARSE) - { - zval outbuf, outbuflen, ret; - xmlChar *buf, cont_len[30]; - int size; - xmlDocPtr doc_return; - - INIT_ZVAL(outbuf); - INIT_ZVAL(outbuflen); - INIT_ZVAL(ret); - - /* Get output buffer and send as fault detials */ - if(php_ob_get_length(&outbuflen TSRMLS_CC) != FAILURE && Z_LVAL(outbuflen) != 0) - php_ob_get_buffer(&outbuf TSRMLS_CC); - php_end_ob_buffer(0, 0 TSRMLS_CC); - - set_soap_fault(&ret, "SOAP-ENV:Server", buffer, NULL, &outbuf TSRMLS_CC); - doc_return = seralize_response_call(NULL, NULL, NULL, &ret TSRMLS_CC); - - /* Build and send our headers + http 500 status */ - /* - xmlDocDumpMemoryEnc(doc_return, &buf, &size, XML_CHAR_ENCODING_UTF8); - */ - xmlDocDumpMemory(doc_return, &buf, &size); - sprintf(cont_len,"Content-Length: %d", size); - sapi_add_header(cont_len, strlen(cont_len) + 1, 1); - sapi_add_header("Content-Type: text/xml", sizeof("Content-Type: text/xml"), 1); - - /* - Want to return HTTP 500 but apache wants to over write - our fault code with their own handling... Figure this out later - sapi_add_header("HTTP/1.1 500 Internal Service Error", sizeof("HTTP/1.1 500 Internal Service Error"), 1); - */ - php_write(buf, size TSRMLS_CC); - - xmlFreeDoc(doc_return); - xmlFree(buf); - - zval_dtor(&outbuf); - zval_dtor(&outbuflen); - zval_dtor(&ret); - - zend_bailout(); - } -} - -/* SoapObject functions */ -PHP_FUNCTION(soapobject) -{ - char *location, *uri = NULL; - int location_len, uri_len = 0; - zval *thisObj; - - GET_THIS_OBJECT(thisObj); - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &location, &location_len, &uri, &uri_len) == SUCCESS) - { - if(uri) - { - /* if two parameters assume 'proxy' and 'uri' */ - add_property_stringl(thisObj, "location", location, location_len, 1); - add_property_stringl(thisObj, "uri", uri, uri_len, 1); - } - else - { - /* if one parameter assume 'wsdl' */ - sdlPtr sdl; - int ret; - - sdl = get_sdl(location); - ret = zend_list_insert(sdl, le_sdl); - - add_property_resource(thisObj, "sdl", ret); - /* FIXME: this is extremely bad practice */ - add_property_resource(thisObj, "port", (long)get_binding_from_type(sdl, BINDING_SOAP)); - zend_list_addref(ret); - } - } -} - -PHP_FUNCTION(__headerclass) -{ - char *classname, *ns; - int classname_len, ns_len; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &classname, &classname_len, &ns, &ns_len) == FAILURE) - php_error(E_ERROR, "Invalid arguments to SoapObject->__headerclass"); -} - -PHP_FUNCTION(__headerfunction) -{ - char *functionname, *headername, *ns; - int functionname_len, *headername_len, ns_len; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &functionname, &functionname_len, &headername, - &headername_len, &ns, &ns_len) == FAILURE) - php_error(E_ERROR, "Invalid arguments to SoapObject->__headerfunction"); -} - -PHP_FUNCTION(__use) -{ - int use; - zval *thisObj; - - GET_THIS_OBJECT(thisObj); - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &use) == FAILURE) - php_error(E_ERROR, "Invalid arguments to SoapObject->__use"); - - if(use == SOAP_DOCUMENT || use == SOAP_LITERAL) - { - add_property_long(thisObj, "use", use); - RETURN_TRUE; - } - RETURN_FALSE; -} - -PHP_FUNCTION(__style) -{ - int style; - zval *thisObj; - - GET_THIS_OBJECT(thisObj); - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &style)) - php_error(E_ERROR, "Invalid arguments to SoapObject->__style"); - - if(style == SOAP_RPC || style == SOAP_DOCUMENT) - { - add_property_long(thisObj, "style", style); - RETURN_TRUE; - } - RETURN_FALSE; -} - -PHP_FUNCTION(__trace) -{ - int level; - zval *thisObj; - - GET_THIS_OBJECT(thisObj); - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &level)) - php_error(E_ERROR, "Invalid arguments to SoapObject->__trace"); - - add_property_long(thisObj, "trace", level); - RETURN_TRUE; -} - -PHP_FUNCTION(__generate) -{ - char *function, *soap_action, *uri; - int function_len, soap_action_len, uri_len, i = 0; - zval *args; - zval **real_args; - zval **param; - xmlDocPtr request = NULL; - int arg_count; - xmlChar *buf; - int size; - sdlPtr sdl; - - HashPosition pos; - - FETCH_THIS_SDL(sdl); - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa|ss", - &function, &function_len, &args, &soap_action, &soap_action_len, &uri, &uri_len) == FAILURE) - php_error(E_ERROR, "Invalid arguments to SoapObject->__generate"); - - arg_count = zend_hash_num_elements(Z_ARRVAL_P(args)); - - real_args = emalloc(sizeof(zval *) * arg_count); - for(zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &pos); - zend_hash_get_current_data_ex(Z_ARRVAL_P(args), (void **) ¶m, &pos) == SUCCESS; - zend_hash_move_forward_ex(Z_ARRVAL_P(args), &pos)) - { - zval_add_ref(param); - real_args[i++] = *param; - } - - - if(sdl) - { - sdlBindingPtr binding; - sdlFunctionPtr sdlFunction; - FETCH_THIS_PORT(binding); - - php_strtolower(function, function_len); - sdlFunction = get_function(binding, function); - request = seralize_function_call(this_ptr, sdlFunction, NULL, uri, real_args, arg_count TSRMLS_CC); - } - else - { - request = seralize_function_call(this_ptr, NULL, function, uri, real_args, arg_count TSRMLS_CC); - } - - xmlDocDumpMemory(request, &buf, &size); - ZVAL_STRINGL(return_value, buf, size, 1); - xmlFree(buf); -} - -PHP_FUNCTION(__parse) -{ - char *message, *function; - int message_len, function_len; - int num_params; - zval **ret_params = NULL; - sdlPtr sdl; - sdlFunctionPtr fn; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s", &message, &message_len, &function, &function_len) == FAILURE) { - php_error(E_ERROR, "Invalid arguments to SoapObject->__parse"); - } - - FETCH_THIS_SDL(sdl); - - if (sdl != NULL) { - sdlBindingPtr binding; - - FETCH_THIS_PORT(binding); - fn = get_function(binding, function); - - if (fn != NULL) { - parse_packet_soap(getThis(), message, message_len, fn, NULL, &ret_params, &num_params TSRMLS_CC); - } - } else { - parse_packet_soap(getThis(), message, message_len, NULL, function, &ret_params, &num_params TSRMLS_CC); - } - - if (num_params > 0) { - *return_value = *ret_params[0]; - /* zval_add_ref(&return_value); */ - } else { - ZVAL_NULL(return_value); - } - - if (ret_params) { - FREE_ZVAL(ret_params[0]); - efree(ret_params); - } -} - -PHP_FUNCTION(__call) -{ - char *function, *soap_action, *uri; - int function_len, soap_action_len, uri_len, i = 0; - zval *args; - zval **real_args; - zval **param; - xmlDocPtr request = NULL; - int num_params, arg_count; - zval **ret_params = NULL; - char *buffer; - int len; - - HashPosition pos; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sa|ss", - &function, &function_len, &args, &soap_action, &soap_action_len, &uri, &uri_len) == FAILURE) - php_error(E_ERROR, "Invalid arguments to SoapObject->__call"); - - arg_count = zend_hash_num_elements(Z_ARRVAL_P(args)); - - real_args = emalloc(sizeof(zval *) * arg_count); - for(zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &pos); - zend_hash_get_current_data_ex(Z_ARRVAL_P(args), (void **) ¶m, &pos) == SUCCESS; - zend_hash_move_forward_ex(Z_ARRVAL_P(args), &pos)) - { - zval_add_ref(param); - real_args[i++] = *param; - } - - request = seralize_function_call(this_ptr, NULL, function, uri, real_args, arg_count TSRMLS_CC); - send_http_soap_request(getThis(), request, function, soap_action TSRMLS_CC); - xmlFreeDoc(request); - - get_http_soap_response(getThis(), &buffer, &len TSRMLS_CC); - parse_packet_soap(getThis(), buffer, len, NULL, function, &ret_params, &num_params TSRMLS_CC); - efree(buffer); - - if(num_params > 0) { - *return_value = *ret_params[0]; - /* zval_add_ref(&return_value); */ - } else { - ZVAL_NULL(return_value); - } - - if (ret_params) { - FREE_ZVAL(ret_params[0]); - efree(ret_params); - } -} - -PHP_FUNCTION(__isfault) -{ - zval *thisObj; - - GET_THIS_OBJECT(thisObj); - - if(zend_hash_exists(Z_OBJPROP_P(thisObj), "__soap_fault", sizeof("__soap_fault"))) - RETURN_TRUE - else - RETURN_FALSE -} - -PHP_FUNCTION(__getfault) -{ - zval *thisObj; - zval **tmp; - - GET_THIS_OBJECT(thisObj); - - if(zend_hash_find(Z_OBJPROP_P(thisObj), "__soap_fault", sizeof("__soap_fault"), (void **)&tmp) == SUCCESS) - { - *return_value = *(*tmp); - zval_copy_ctor(return_value); - return; - } - RETURN_NULL(); -} - -PHP_FUNCTION(__getfunctions) -{ - sdlPtr sdl; - zval *thisObj; - HashPosition pos; - - GET_THIS_OBJECT(thisObj); - - FETCH_THIS_SDL(sdl); - - if(sdl) - { - smart_str buf = {0}; - sdlFunctionPtr *function; - sdlBindingPtr binding; - - FETCH_THIS_PORT(binding); - - array_init(return_value); - zend_hash_internal_pointer_reset_ex(binding->functions, &pos); - while(zend_hash_get_current_data_ex(binding->functions, (void **)&function, &pos) != FAILURE) - { - function_to_string((*function), &buf); - add_next_index_stringl(return_value, buf.c, buf.len, 1); - zend_hash_move_forward_ex(binding->functions, &pos); - smart_str_free(&buf); - } - } -} - -PHP_FUNCTION(__gettypes) -{ - sdlPtr sdl; - zval *thisObj; - HashPosition pos; - - GET_THIS_OBJECT(thisObj); - - FETCH_THIS_SDL(sdl); - - if(sdl) - { - sdlTypePtr *type; - smart_str buf = {0}; - - array_init(return_value); - if(sdl->types) - { - zend_hash_internal_pointer_reset_ex(sdl->types, &pos); - while(zend_hash_get_current_data_ex(sdl->types, (void **)&type, &pos) != FAILURE) - { - type_to_string((*type), &buf, 0); - add_next_index_stringl(return_value, buf.c, buf.len, 1); - zend_hash_move_forward_ex(sdl->types, &pos); - smart_str_free(&buf); - } - } - } -} - -PHP_FUNCTION(__getlastrequest) -{ - zval *thisObj; - zval **tmp; - - GET_THIS_OBJECT(thisObj); - - if(zend_hash_find(Z_OBJPROP_P(thisObj), "__last_request", sizeof("__last_request"), (void **)&tmp) == SUCCESS) - { - RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1); - } - RETURN_NULL(); -} - -PHP_FUNCTION(__getlastresponse) -{ - zval *thisObj; - zval **tmp; - - GET_THIS_OBJECT(thisObj); - - if(zend_hash_find(Z_OBJPROP_P(thisObj), "__last_response", sizeof("__last_response"), (void **)&tmp) == SUCCESS) - { - RETURN_STRINGL(Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp), 1); - } - RETURN_NULL(); -} - -void soap_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_property_reference *property_reference) -{ - pval *object = property_reference->object; - zend_overloaded_element *function_name = (zend_overloaded_element *)property_reference->elements_list->tail->data; - zval *thisObj; - char *function = Z_STRVAL(function_name->element); - zend_function *builtin_function; - - GET_THIS_OBJECT(thisObj); - - /* - Find if the function being called is already defined... - ( IMHO: zend should handle this functionality ) - */ - if(zend_hash_find(&Z_OBJCE_P(thisObj)->function_table, function, Z_STRLEN(function_name->element) + 1, (void **) &builtin_function) == SUCCESS) - { - builtin_function->internal_function.handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); - } - else - { - zval **arguments = (zval **) emalloc(sizeof(zval *) * ZEND_NUM_ARGS()); - int arg_count = ZEND_NUM_ARGS(); - xmlDocPtr request = NULL; - sdlPtr sdl; - sdlFunctionPtr fn; - - zend_get_parameters_array(ht, arg_count, arguments); - - FETCH_THIS_SDL(sdl); - - clear_soap_fault(thisObj); - - if (sdl != NULL) { - sdlBindingPtr binding; - - FETCH_THIS_PORT(binding); - fn = get_function(binding, function); - if(fn != NULL) - { - int num_params; - zval **ret_params = NULL; - char *buffer; - char *ns; - int len; - - if(binding->bindingType == BINDING_SOAP) - { - sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)fn->bindingAttributes; - request = seralize_function_call(this_ptr, fn, NULL, fnb->input.ns, arguments, arg_count TSRMLS_CC); - send_http_soap_request(getThis(), request, fn->functionName, fnb->soapAction TSRMLS_CC); - } - else - { - request = seralize_function_call(this_ptr, fn, NULL, sdl->target_ns, arguments, arg_count TSRMLS_CC); - send_http_soap_request(getThis(), request, fn->functionName, NULL TSRMLS_CC); - } - - xmlFreeDoc(request); - - get_http_soap_response(getThis(), &buffer, &len TSRMLS_CC); - parse_packet_soap(getThis(), buffer, len, fn, NULL, &ret_params, &num_params TSRMLS_CC); - efree(buffer); - - if(num_params > 0) { - *return_value = *ret_params[0]; - /* zval_add_ref(&return_value); */ - } else { - ZVAL_NULL(return_value); - } - - if (ret_params) { - FREE_ZVAL(ret_params[0]); - efree(ret_params); - } - } - else - { - php_error(E_WARNING,"Function (\"%s\") not is not a valid method for this service", function); - } - } - else - { - int num_params; - zval **ret_params = NULL; - zval **uri; - smart_str *action; - char *buffer; - int len; - - if(zend_hash_find(Z_OBJPROP_P(thisObj), "uri", sizeof("uri"), (void *)&uri) == FAILURE) - php_error(E_ERROR, "Error finding uri in soap_call_function_handler"); - - request = seralize_function_call(this_ptr, NULL, function, Z_STRVAL_PP(uri), arguments, arg_count TSRMLS_CC); - action = build_soap_action(thisObj, function); - send_http_soap_request(getThis(), request, function, action->c TSRMLS_CC); - - smart_str_free(action); - efree(action); - xmlFreeDoc(request); - - get_http_soap_response(getThis(), &buffer, &len TSRMLS_CC); - parse_packet_soap(getThis(), buffer, len, NULL, function, &ret_params, &num_params TSRMLS_CC); - efree(buffer); - - if(num_params > 0) { - *return_value = *ret_params[0]; - /* zval_add_ref(&return_value); */ - } else { - ZVAL_NULL(return_value); - } - - if (ret_params) { - FREE_ZVAL(ret_params[0]); - efree(ret_params); - } - } - efree(arguments); - } - - zval_dtor(&function_name->element); -} - -void clear_soap_fault(zval *obj) -{ - if(obj != NULL && obj->type == IS_OBJECT) { -/* zend_hash_del(obj->value.obj.properties, "__soap_fault", sizeof("__soap_fault"));*/ - zend_hash_del(Z_OBJPROP_P(obj), "__soap_fault", sizeof("__soap_fault")); - } -} - -void add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail TSRMLS_DC) -{ - zval *fault; - MAKE_STD_ZVAL(fault); - set_soap_fault(fault, fault_string, fault_code, fault_actor, fault_detail TSRMLS_CC); - add_property_zval(obj, "__soap_fault", fault); -} - -void set_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail TSRMLS_DC) -{ - if(Z_TYPE_P(obj) != IS_OBJECT) - object_init_ex(obj, &soap_fault_class_entry); - - if(fault_string != NULL) - add_property_string(obj, "faultstring", fault_string, 1); - - if(fault_code != NULL) - add_property_string(obj, "faultcode", fault_code, 1); - - if(fault_actor != NULL) - add_property_string(obj, "faultactor", fault_actor, 1); - - if(fault_detail != NULL) - { - zval_add_ref(&fault_detail); - add_property_zval(obj, "detail", fault_detail); - } -} - -void deseralize_function_call(sdlPtr sdl, xmlDocPtr request, zval *function_name, int *num_params, zval ***parameters TSRMLS_DC) -{ - xmlNodePtr trav,trav2,trav3,trav4,env,body; - int cur_param = 0,num_of_params = 0; - - trav = request->children; - FOREACHNODE(trav,"Envelope",env) - { - trav2 = env->children; - FOREACHNODE(trav2,"Body",body) - { - trav3 = body->children; - do - { - /* TODO: make 'strict' (use the sdl defnintions) */ - if(trav3->type == XML_ELEMENT_NODE) - { - zval tmp_function_name, **tmp_parameters; - sdlFunctionPtr function; - sdlBindingPtr binding = get_binding_from_type(sdl, BINDING_SOAP); - - INIT_ZVAL(tmp_function_name); - ZVAL_STRING(&tmp_function_name, (char *)trav3->name, 1); - - (*function_name) = tmp_function_name; - - function = get_function(binding, php_strtolower((char *)trav3->name, strlen(trav3->name))); - if(sdl != NULL && function == NULL) - php_error(E_ERROR, "Error function \"%s\" doesn't exists for this service \"%s\"", trav3->name, binding->location); - - if(trav3->children) - { - trav4 = trav3->children; - if(function == NULL) - { - do - { - if(trav4->type == XML_ELEMENT_NODE) - num_of_params++; - - } while ((trav4 = trav4->next)); - } - else - num_of_params = zend_hash_num_elements(function->requestParameters); - - tmp_parameters = emalloc(num_of_params * sizeof(zval *)); - trav4 = trav3->children; - do - { - if(trav4->type == XML_ELEMENT_NODE) - { - encodePtr enc; - sdlParamPtr *param = NULL; - - if(function != NULL && zend_hash_index_find(function->requestParameters, cur_param, (void **)¶m) == FAILURE) - php_error(E_ERROR, "Error cannot find parameter"); - if(param == NULL) - enc = get_conversion(UNKNOWN_TYPE); - else - enc = (*param)->encode; - - tmp_parameters[cur_param] = master_to_zval(enc, trav4); - cur_param++; - } - - } while ((trav4 = trav4->next)); - } - (*parameters) = tmp_parameters; - (*num_params) = num_of_params; - break; - } - } while ((trav3 = trav3->next)); - - } - ENDFOREACH(trav2); - } - ENDFOREACH(trav); -} - -xmlDocPtr seralize_response_call(sdlFunctionPtr function, char *function_name, char *uri, zval *ret TSRMLS_DC) -{ - xmlDoc *doc; - xmlNode *envelope,*body,*method, *param; - xmlNs *ns; - sdlParamPtr parameter = NULL; - smart_str *gen_ns = NULL; - - encode_reset_ns(); - - doc = xmlNewDoc("1.0"); - doc->charset = XML_CHAR_ENCODING_UTF8; - doc->encoding = xmlStrdup((xmlChar*)"UTF-8"); - doc->children = xmlNewDocNode(doc, NULL, "SOAP-ENV:Envelope", NULL); - envelope = doc->children; - - xmlSetProp(envelope, "SOAP-ENV:encodingStyle", "http://schemas.xmlsoap.org/soap/encoding/"); - xmlSetProp(envelope, "xmlns:SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/"); - xmlSetProp(envelope, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); - xmlSetProp(envelope, "xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); - xmlSetProp(envelope, "xmlns:" APACHE_NS_PREFIX , APACHE_NAMESPACE); - - ns = xmlNewNs(envelope,"http://schemas.xmlsoap.org/soap/envelope/","SOAP-ENV"); - body = xmlNewChild(envelope, ns, "Body", NULL); - - if(Z_TYPE_P(ret) == IS_OBJECT && - Z_OBJCE_P(ret)->refcount == soap_fault_class_entry.refcount) - { - param = seralize_zval(ret, NULL, "SOAP-ENV:Fault", SOAP_ENCODED TSRMLS_CC); - xmlAddChild(body, param); - } - else - { - gen_ns = encode_new_ns(); - ns = xmlNewNs(envelope, uri, gen_ns->c); - - if(function != NULL) - method = xmlNewChild(body, ns, function->responseName , NULL); - else - method = xmlNewChild(body, ns, function_name, NULL); - - if(uri) - ns = xmlNewNs(method, uri, NULL); - - parameter = get_param(function, NULL, 0, TRUE); - - if(Z_TYPE_P(ret) == IS_OBJECT && - Z_OBJCE_P(ret)->refcount == soap_param_class_entry.refcount) - { - zval **ret_name; - zval **ret_data; - - if(zend_hash_find(Z_OBJPROP_P(ret), "param_name", sizeof("param_name"), (void **)&ret_name) == SUCCESS && - zend_hash_find(Z_OBJPROP_P(ret), "param_data", sizeof("param_data"), (void **)&ret_data) == SUCCESS) - param = seralize_parameter(parameter, *ret_data, 0, Z_STRVAL_PP(ret_name), SOAP_ENCODED TSRMLS_CC); - else - param = seralize_parameter(parameter, ret, 0, "return", SOAP_ENCODED TSRMLS_CC); - } - else - param = seralize_parameter(parameter, ret, 0, "return", SOAP_ENCODED TSRMLS_CC); - - xmlAddChild(method,param); - } - - if (gen_ns) { - smart_str_free(gen_ns); - efree(gen_ns); - } - - return doc; -} - -xmlDocPtr seralize_function_call(zval *this_ptr, sdlFunctionPtr function, char *function_name, char *uri, zval **arguments, int arg_count TSRMLS_DC) -{ - xmlDoc *doc; - xmlNode *envelope, *body, *method; - xmlNs *ns, *tmpns; - zval **zstyle, **zuse; - int i, style, use; - smart_str *gen_ns; - - encode_reset_ns(); - - doc = xmlNewDoc("1.0"); - doc->encoding = xmlStrdup((xmlChar*)"UTF-8"); - doc->charset = XML_CHAR_ENCODING_UTF8; - envelope = xmlNewDocNode(doc, NULL, "SOAP-ENV:Envelope", NULL); - xmlDocSetRootElement(doc, envelope); - xmlSetProp(envelope, "SOAP-ENV:encodingStyle", "http://schemas.xmlsoap.org/soap/encoding/"); - xmlSetProp(envelope, "xmlns:SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/"); - xmlSetProp(envelope, "xmlns:xsd", "http://www.w3.org/2001/XMLSchema"); - xmlSetProp(envelope, "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); - - ns = xmlNewNs(envelope, "http://schemas.xmlsoap.org/soap/envelope/", "SOAP-ENV"); - body = xmlNewChild(envelope, ns, "Body", NULL); - - gen_ns = encode_new_ns(); - - if(function) - { - if(function->bindingType == BINDING_SOAP) - { - sdlSoapBindingFunctionPtr fnb = (sdlSoapBindingFunctionPtr)function->bindingAttributes; - - style = fnb->style; - use = fnb->input.use; - if(style == SOAP_RPC) - { - ns = xmlNewNs(body, fnb->input.ns, gen_ns->c); - method = xmlNewChild(body, ns, function->requestName , NULL); - } - } - } - else - { - if(zend_hash_find(Z_OBJPROP_P(this_ptr), "style", sizeof("style"), (void **)&zstyle) == SUCCESS) - style = Z_LVAL_PP(zstyle); - else - style = SOAP_RPC; - - if(style == SOAP_RPC) - { - ns = xmlNewNs(body, uri, gen_ns->c); - method = xmlNewChild(body, ns, function_name, NULL); - } - - if(zend_hash_find(Z_OBJPROP_P(this_ptr), "use", sizeof("use"), (void **)&zuse) == SUCCESS) - use = Z_LVAL_PP(zuse); - else - use = SOAP_ENCODED; - } - - for(i = 0;i < arg_count;i++) - { - xmlNodePtr param; - sdlParamPtr parameter = get_param(function, NULL, i, FALSE); - - if(Z_TYPE_P(arguments[i]) == IS_OBJECT && - Z_OBJCE_P(arguments[i])->refcount == soap_param_class_entry.refcount) - { - zval **ret_name; - zval **ret_data; - - if(zend_hash_find(Z_OBJPROP_P(arguments[i]), "param_name", sizeof("param_name"), (void **)&ret_name) == SUCCESS && - zend_hash_find(Z_OBJPROP_P(arguments[i]), "param_data", sizeof("param_data"), (void **)&ret_data) == SUCCESS) - param = seralize_parameter(parameter, *ret_data, i, Z_STRVAL_PP(ret_name), use TSRMLS_CC); - else - param = seralize_parameter(parameter, arguments[i], i, NULL, use TSRMLS_CC); - } - else - param = seralize_parameter(parameter, arguments[i], i, NULL, use TSRMLS_CC); - - if(style == SOAP_RPC) - xmlAddChild(method, param); - else if(style == SOAP_DOCUMENT) - { - if(function && function->bindingType == BINDING_SOAP) - { - sdlParamPtr *sparam; - - if(zend_hash_index_find(function->requestParameters, 0, (void **)&sparam) == SUCCESS) - { - ns = xmlNewNs(param, (*sparam)->encode->details.ns, gen_ns->c); - xmlNodeSetName(param, (*sparam)->encode->details.type_str); - xmlSetNs(param, ns); - } - } - xmlAddChild(body, param); - } - } - smart_str_free(gen_ns); - efree(gen_ns); - - return doc; -} - -xmlNodePtr seralize_parameter(sdlParamPtr param, zval *param_val, int index, char *name, int style TSRMLS_DC) -{ - int type = 0; - char *paramName; - xmlNodePtr xmlParam; - - if(param != NULL && param->paramName != NULL) - paramName = estrdup(param->paramName); - else - { - if(name == NULL) - { - paramName = emalloc(10); - sprintf(paramName,"param%d",index); - } - else - paramName = estrdup(name); - } - - xmlParam = seralize_zval(param_val, param, paramName, style TSRMLS_CC); - - efree(paramName); - - return xmlParam; -} - -zval *desearlize_zval(sdlPtr sdl, xmlNodePtr data, sdlParamPtr param TSRMLS_DC) -{ - encodePtr enc; - - if(param != NULL) - enc = param->encode; - else - enc = get_conversion(UNKNOWN_TYPE); - - return enc->to_zval(enc->details, data); -} - -xmlNodePtr seralize_zval(zval *val, sdlParamPtr param, char *paramName, int style TSRMLS_DC) -{ - xmlNodePtr xmlParam; - encodePtr enc; - - if(param != NULL) - enc = param->encode; - else - enc = get_conversion(val->type); - - xmlParam = master_to_xml(enc, val, style); - if(!strcmp(xmlParam->name, "BOGUS")) - xmlNodeSetName(xmlParam, paramName); - - return xmlParam; -} - -sdlParamPtr get_param(sdlFunctionPtr function, char *param_name, int index, int response) -{ - sdlParamPtr *tmp = NULL; - HashTable *h; - - if(function == NULL) - return NULL; - - if(response == FALSE) - h = function->requestParameters; - else - h = function->responseParameters; - - if (function != NULL && (param_name == NULL || zend_hash_find(h, param_name, strlen(param_name), (void **)&tmp) == FAILURE)) - { - if(index != -1) - if(zend_hash_index_find(h, index, (void **)&tmp) != FAILURE) - return (*tmp); - } - else - return (*tmp); - - return NULL; -} - -sdlFunctionPtr get_function(sdlBindingPtr sdl, char *function_name) -{ - sdlFunctionPtr *tmp; - if(sdl != NULL) - if(zend_hash_find(sdl->functions, function_name, strlen(function_name), (void **)&tmp) != FAILURE) - return (*tmp); - return NULL; -} - -static void function_to_string(sdlFunctionPtr function, smart_str *buf) -{ - int i = 0; - HashPosition pos; - - if(function->responseParameters) - { - sdlParamPtr *param; - param = function->responseParameters->pListHead->pData; - smart_str_appendl(buf, (*param)->encode->details.type_str, strlen((*param)->encode->details.type_str)); - smart_str_appendc(buf, ' '); - } - else - smart_str_appendl(buf, "void ", 5); - - smart_str_appendl(buf, function->functionName, strlen(function->functionName)); - - smart_str_appendc(buf, '('); - if(function->requestParameters) - { - sdlParamPtr *param; - - i = 0; - zend_hash_internal_pointer_reset_ex(function->requestParameters, &pos); - while(zend_hash_get_current_data_ex(function->requestParameters, (void **)¶m, &pos) != FAILURE) - { - smart_str_appendl(buf, (*param)->encode->details.type_str, strlen((*param)->encode->details.type_str)); - smart_str_appendc(buf, ' '); - smart_str_appendc(buf, '$'); - smart_str_appendl(buf, (*param)->paramName, strlen((*param)->paramName)); - if(zend_hash_num_elements(function->requestParameters) > i + 1) - smart_str_appendl(buf, ", ", 2); - zend_hash_move_forward_ex(function->requestParameters, &pos); - i++; - } - } - smart_str_appendc(buf, ')'); -} - -static void type_to_string(sdlTypePtr type, smart_str *buf, int level) -{ - int i; - smart_str spaces = {0}; - HashPosition pos; - - for(i = 0;i < level;i++) - smart_str_appendc(&spaces, ' '); - - smart_str_appendl(buf, spaces.c, spaces.len); - if(type->elements) - { - sdlTypePtr *t_type; - - smart_str_appendl(buf, "struct ", 7); - smart_str_appendl(buf, type->name, strlen(type->name)); - smart_str_appendc(buf, '\n'); - smart_str_appendl(buf, spaces.c, spaces.len); - smart_str_appendl(buf, "{\n", 2); - - zend_hash_internal_pointer_reset_ex(type->elements, &pos); - level++; - while(zend_hash_get_current_data_ex(type->elements, (void **)&t_type, &pos) != FAILURE) - { - type_to_string((*t_type), buf, level); - zend_hash_move_forward_ex(type->elements, &pos); - } - - smart_str_appendl(buf, spaces.c, spaces.len); - smart_str_appendl(buf, "}\n", 2); - } - else - { - smart_str_appendl(buf, type->encode->details.type_str, strlen(type->encode->details.type_str)); - smart_str_appendc(buf, ' '); - smart_str_appendl(buf, type->name, strlen(type->name)); - smart_str_appendl(buf, ";\n", 2); - } -} - -/* Deletes */ -void delete_sdl(void *handle) -{ - sdlPtr tmp = *((sdlPtr*)handle); - - xmlFreeDoc(tmp->doc); - if(tmp->source) - free(tmp->source); - if(tmp->target_ns) - free(tmp->target_ns); - if(tmp->encoders) - { - zend_hash_destroy(tmp->encoders); - free(tmp->encoders); - } - if(tmp->types) - { - zend_hash_destroy(tmp->types); - free(tmp->types); - } - if(tmp->bindings) - { - zend_hash_destroy(tmp->bindings); - free(tmp->bindings); - } - free(tmp); -} - -void delete_url(void *handle) -{ - php_url_free((php_url*)handle); -} - -void delete_service(void *data) -{ - soapServicePtr service = (soapServicePtr)data; - - if(service->soap_functions.ft) - { - zend_hash_destroy(service->soap_functions.ft); - efree(service->soap_functions.ft); - } - - if(service->mapping) - { - zend_hash_destroy(service->mapping); - efree(service->mapping); - } - - if(service->soap_class.argc) - { - int i; - for(i = 0; i < service->soap_class.argc;i++) - zval_ptr_dtor(&service->soap_class.argv[i]); - efree(service->soap_class.argv); - } - - efree(service->uri); - efree(service); -} - -void delete_binding(void *data) -{ - sdlBindingPtr binding = *((sdlBindingPtr*)data); - - if(binding->functions) - { - zend_hash_destroy(binding->functions); - free(binding->functions); - } - - if(binding->location) - free(binding->location); - if(binding->name) - free(binding->name); - - if(binding->bindingType == BINDING_SOAP) - { - sdlSoapBindingPtr soapBind = binding->bindingAttributes; - free(soapBind->transport); - } -} - -void delete_function(void *data) -{ - sdlFunctionPtr function = *((sdlFunctionPtr*)data); - - if(function->functionName) - free(function->functionName); - if(function->requestName) - free(function->requestName); - if(function->responseName) - free(function->responseName); - - if(function->requestParameters) - { - zend_hash_destroy(function->requestParameters); - free(function->requestParameters); - } - if(function->responseParameters) - { - zend_hash_destroy(function->responseParameters); - free(function->responseParameters); - } - - if(function->bindingType == BINDING_SOAP) - { - sdlSoapBindingFunctionPtr soapFunction = function->bindingAttributes; - if(soapFunction->soapAction) - free(soapFunction->soapAction); - delete_sdl_soap_binding_function_body(soapFunction->input); - delete_sdl_soap_binding_function_body(soapFunction->output); - delete_sdl_soap_binding_function_body(soapFunction->falut); - } -} - -void delete_sdl_soap_binding_function_body(sdlSoapBindingFunctionBody body) -{ - if(body.ns) - free(body.ns); - if(body.parts) - free(body.parts); - if(body.encodingStyle) - free(body.encodingStyle); -} - -void delete_paramater(void *data) -{ - sdlParamPtr param = *((sdlParamPtr*)data); - if(param->paramName) - free(param->paramName); - free(param); -} - -void delete_mapping(void *data) -{ - soapMappingPtr map = (soapMappingPtr)data; - - if(map->ns) - efree(map->ns); - if(map->ctype) - efree(map->ctype); - - if(map->type == SOAP_MAP_FUNCTION) - { - if(map->map_functions.to_xml_before) - zval_ptr_dtor(&map->map_functions.to_xml_before); - if(map->map_functions.to_xml) - zval_ptr_dtor(&map->map_functions.to_xml); - if(map->map_functions.to_xml_after) - zval_ptr_dtor(&map->map_functions.to_xml_after); - - if(map->map_functions.to_zval_before) - zval_ptr_dtor(&map->map_functions.to_zval_before); - if(map->map_functions.to_zval) - zval_ptr_dtor(&map->map_functions.to_zval); - if(map->map_functions.to_zval_after) - zval_ptr_dtor(&map->map_functions.to_zval_after); - } - efree(map); -} - -/* Should not need */ -#ifndef ZEND_ENGINE_2 -int my_call_user_function(HashTable *function_table, zval **object_pp, zval *function_name, zval *retval_ptr, int param_count, zval *params[] TSRMLS_DC) -{ - if(call_user_function(function_table, object_pp, function_name, retval_ptr, param_count, params TSRMLS_CC) == FAILURE) - { - if(Z_OBJCE_PP(object_pp)->handle_function_call != NULL) - { - zend_overloaded_element overloaded_element; - zend_property_reference property_reference; - zend_function_state function_state; - zend_function_state *original_function_state_ptr; - int i; - - overloaded_element.element = *function_name; - overloaded_element.type = OE_IS_METHOD; - - function_state.function = (zend_function *) emalloc(sizeof(zend_function)); - function_state.function->type = ZEND_OVERLOADED_FUNCTION; - function_state.function->common.arg_types = NULL; - function_state.function->overloaded_function.function_name = Z_STRVAL_P(function_name); - - property_reference.object = *object_pp; - property_reference.type = BP_VAR_NA; - property_reference.elements_list = (zend_llist *)emalloc(sizeof(zend_llist)); - zend_llist_init(property_reference.elements_list, sizeof(zend_overloaded_element), NULL, 0); - zend_llist_add_element(property_reference.elements_list, &overloaded_element); - - /* Build argument stack */ - for(i = 0;i < param_count;i++) - zend_ptr_stack_push(&EG(argument_stack), params[i]); - zend_ptr_stack_n_push(&EG(argument_stack), 2, (void *)param_count, NULL); - - original_function_state_ptr = EG(function_state_ptr); - EG(function_state_ptr) = &function_state; - Z_OBJCE_PP(object_pp)->handle_function_call(param_count, retval_ptr, *object_pp, 1 TSRMLS_CC, &property_reference); - EG(function_state_ptr) = original_function_state_ptr; - - zend_llist_destroy(property_reference.elements_list); - efree(property_reference.elements_list); - efree(function_state.function); - - zend_ptr_stack_clear_multiple(TSRMLS_C); - return SUCCESS; - } - } - return FAILURE; -} -#endif - - diff --git a/ext/spl/CREDITS b/ext/spl/CREDITS deleted file mode 100755 index 8710aac550..0000000000 --- a/ext/spl/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -SPL -Marcus Boerger diff --git a/ext/spl/EXPERIMENTAL b/ext/spl/EXPERIMENTAL deleted file mode 100755 index e69de29bb2..0000000000 --- a/ext/spl/EXPERIMENTAL +++ /dev/null diff --git a/ext/spl/README b/ext/spl/README deleted file mode 100755 index 60c6d97425..0000000000 --- a/ext/spl/README +++ /dev/null @@ -1,88 +0,0 @@ -This is an extension that aims to implement some efficient data access -interfaces and classes. You'll find the classes documented using php -code in the file spl.php. - -There are special SPL interfaces that provides the ability to hook into -foreach and array reading/writng. By inheriting these interfaces, instances -of the resulting classes can be iterated using the foreach construct or -use array read write notation. - -Look into the examples subdirectory for some basic examples which will -demonstracte this. - -Also some classes of extensions like SQLite inherit SPL interfaces so that -they take advantage of the foreach or array overloading. - -1) Iterators - -Iterator is design pattern that allows to enumerate and list all elements of -a collection whatsoever using an oo protocol. The minimalistic Iterator needs -a method that returns the current value, a method that moves to the next value -and a method that checks whether or not the Iterator can provide more elements. - -In SPL this basich Iterator is defined by the interface spl_forward: - -interface spl_forward { - function current(); - function next(); - function has_more(); -} - -This basic Iterator does not allow to rewind itself nor does it in anyway -support to name the values by some kind association as key/value mappings -provided by the standard PHP arrays. All these additions to the basic Iterator -are done in specialized interfaces as described in detail in the file spl.php. - -SPL allows to hook into the engine opcodes that realize the foreach construct. -This construct normally works on arrays the following way. First it rewinds -the current array position to the beginning. Then it loops through the whole -array by first checking whether or not the end of the array is reached and -if not returning the current array value and or key. After that it move the -current array pointer forward and does starts the loop process again. As you -can see this perfectly maps to the interface spl_forward. So the foreach -hooking simply checks whether or not the variable passed to foreach is an -object of a class implementing the interface spl_forward. The foreach hook -can be activated by --enable-spl-foreach which is on by default. - -class it implements spl_forward... -$obj = new it(); -foreach($obj as $value) ... - -2) Arrays - -Arrays in general, not specifically PHP arrays, provide a collection of pairs -normally referred to as key and value. A PHP object consists of properties and -a class type specifing the methods available for the object. SPL now allows -this to be combined using the spl_array_<xy> interfaces. - -The minimalistic array interface is spl_array_read which only support reading: - -interface spl_array_read { - function exists($key); - function get($key); -} - -Any instance of a class that implements spl_array_read can be used with array -read notation when the corresponding hook is activated --enable-spl-array-read. - -class ar implements spl_array_read... -$obj = new ar(); -$value = $obj[$key]; - -SPL also supports the write notation by the interface spl_array_access: - -interface spl_array_access extends spl_array_read { - function set($value, $index); -} - -When the array write hook is activated by --enable-spl-array-write the -following can be done: - -class ar implements spl_array_access... -$obj = new ar(); -$value = $obj[$key]; -$obj[$key] = $value; - -However this hook should only be activated when it is made use of, since it -slows down noticeable. That is the case because first there is some not used -overhead and second the overhead is in one the most often used opcodes.
\ No newline at end of file diff --git a/ext/spl/README.PROFILING b/ext/spl/README.PROFILING deleted file mode 100755 index 67e55b3717..0000000000 --- a/ext/spl/README.PROFILING +++ /dev/null @@ -1,98 +0,0 @@ -SQLite is the first extension that makes use of SPL automatically by simply -enabling both. - -SQLite offers four access strategies: -1) sqlite_query + sqlite_fetch_array -2) sqlite_unbuffered_query + sqlite_fetch_array -3) sqlite_query + iterators (sqlite_current) -4) sqlite_unbuffered_query + iterators (sqlite_current) -5) sqlite_array_query - -1) and 3) do "over eager evaluating" since they fetch all rows directly. - -2) does "eager evaluating". It always fetches the next row but doesn't -keep the current row, so that it must be stored elsewhere if it must be -accessed more then once. For instance this happens when you need to access -columns separately. - -4) does "eager evaluating". But in contrast to 2) it keeps the current row -hence its name. - -There is no efficient way for "lazy or just in time evaluating" so 4) should -be the best case. And 4) also enables the foreach trick. - -5) does a full buffered fetch and returns the complete result into an array. -As long as you only have a few rows in your result this is very fast and of -course it is very flexible since you can access any column/row as often you -like and in any order you like. But it needs to store the full result what -is called "eager evaluating". - -Speedwise analysis: - -I compared a database using a table of round about 200 rows with 3 columns. -I measured the case where 10 rows are returned, since i guess this is a -value often taken as default list size in web applications. However i did -that 10 times because the loop initialization is the slowest part of foreach -overloading. Since we are only interested in the relative effect foreach -overloading has i stiped the setup part and used a query result iteration -that does nothing. That means i run 'php -h' in the profiler first and then -profiled every single case. For completeness i also computed the values -including the setup process. - -Method, without setup, with setup -1) 100.00% 100.00% -2) 89.32% 97.16% -3) 88.35% 96.90% - -Furthermore i did some more checks and found out that the loop process using -foreach overloading (2) takes a constant time while it seems that the time -needed to add more rows to the array increases with the number of rows being -already in the array. As a result (2) is faster than (3) after round about 45 -rows. - -The loop codes used: - -1) Unbuffered query - -<?php -$dbname = dirname(__FILE__).'/profile.sqlite'; -$db = sqlite_factory($dbname); - -for ($i = 0; $i < 10; $i++) { - $res = $db->unbuffered_query("SELECT idx, name, size from files LIMIT 10", SQLITE_NUM); - while ($res->has_more()) { -// var_dump($res->current()); - $res->current(); - $res->next(); - } -} -echo "DONE!\n"; -?> - -2) Unbuffered query using foreach overloading - -<?php -$dbname = dirname(__FILE__).'/profile.sqlite'; -$db = sqlite_factory($dbname); - -for ($i = 0; $i < 10; $i++) { - foreach($db->unbuffered_query("SELECT idx, name, size from files LIMIT 10", SQLITE_NUM) as $row) { -// var_dump($row); - } -} -echo "DONE!\n"; -?> - -3) Array query method - -<?php -$dbname = dirname(__FILE__).'/profile.sqlite'; -$db = sqlite_factory($dbname); - -for ($i = 0; $i < 10; $i++) { - foreach($db->array_query("SELECT idx, name, size from files LIMIT 10", SQLITE_NUM) as $row) { -// var_dump($row); - } -} -echo "DONE!\n"; -?>
\ No newline at end of file diff --git a/ext/spl/TODO b/ext/spl/TODO deleted file mode 100755 index 5311ef6c11..0000000000 --- a/ext/spl/TODO +++ /dev/null @@ -1,13 +0,0 @@ -This is the ToDo of ext/spl: - -- spl::array_access cals set() which is supposed to return a value. - Currently you *must* return a value even when it is not used. - $obj[$idx] = $val; // doesn't use the return value - $x = $obj[$idx] = $val; // here it is used - Since array_access.phpt is a test with a return value there - should be a test without a return value. Maybe an error message - is required in case there is no return value. - -- spl::array_access_ex is not completely done and not tested. - -If you have further questions: mailto:helly@php.net diff --git a/ext/spl/config.m4 b/ext/spl/config.m4 deleted file mode 100755 index bce2b4f43a..0000000000 --- a/ext/spl/config.m4 +++ /dev/null @@ -1,43 +0,0 @@ -dnl $Id$ -dnl config.m4 for extension SPL - -PHP_ARG_ENABLE(spl, enable SPL suppport, -[ --disable-spl Enable Standard PHP Library], yes) - -dnl first enable/disable all hooks - -PHP_ARG_ENABLE(spl-hook-all, enable all hooks, -[ --enable-spl-hook-all SPL: Enable all hooks]) - -dnl now all single enable/disable for hooks - -PHP_ARG_ENABLE(spl-foreach, enable hook on foreach, -[ --disable-spl-foreach SPL: Disable hook on forach], yes) - -PHP_ARG_ENABLE(spl-array-read, enable hook on array read, -[ --enable-spl-array-read SPL: Enable hook on array read]) - -PHP_ARG_ENABLE(spl-array-write, enable hook on array write, -[ --enable-spl-array-write SPL: Enable hook on array write (+read)]) - -dnl last do checks on hooks - -if test "$PHP_SPL" != "no"; then - if test "$PHP_SPL_HOOK_ALL" != "no" -o "$PHP_SPL_FOREACH" != "no"; then - AC_DEFINE(SPL_FOREACH, 1, [Activate opcode hook on foreach]) - PHP_SPL="yes" - fi - if test "$PHP_SPL_HOOK_ALL" != "no" -o "$PHP_SPL_ARRAY_READ" != "no" -o "$PHP_SPL_ARRAY_WRITE" != "no"; then - AC_DEFINE(SPL_ARRAY_READ, 1, [Activate opcode hook on array read]) - PHP_SPL="yes" - fi - if test "$PHP_SPL_HOOK_ALL" != "no" -o "$PHP_SPL_ARRAY_WRITE" != "no"; then - AC_DEFINE(SPL_ARRAY_WRITE, 1, [Activate opcode hook on array write]) - PHP_SPL="yes" - fi -fi - -if test "$PHP_SPL" != "no"; then - AC_DEFINE(HAVE_SPL, 1, [Whether you want SPL (Standard Php Library) support]) - PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_foreach.c spl_array.c spl_directory.c, $ext_shared) -fi diff --git a/ext/spl/examples/dba_array.php b/ext/spl/examples/dba_array.php deleted file mode 100755 index ebbe5a7bac..0000000000 --- a/ext/spl/examples/dba_array.php +++ /dev/null @@ -1,79 +0,0 @@ -<?php - -/* dba array utility - * - * Usage php dba_dump <file> <handler> <key> [<value>] - * - * If <value> is specified then <key> is set to <value> in <file>. - * Else the value of <key> is printed only. - * - * Note: configure with --enable-dba - * - * (c) Marcus Boerger - */ - -class dba_array implements spl_array_access { - private $db; - - function __construct($file, $handler) - { - $this->db = dba_popen($file, "c", $handler); - if (!$this->db) { - throw new exception("Databse could not be opened"); - } - } - - function __destruct() - { - dba_close($this->db); - } - - function get($name) - { - $data = dba_fetch($name, $this->db); - if($data) { - if (ini_get('magic_quotes_runtime')) { - $data = stripslashes($data); - } - return unserialize($data); - } - else - { - return NULL; - } - } - - function set($name, $value) - { - dba_replace($name, serialize($value), $this->db); - return $value; - } - - function exists($name) - { - return dba_exists($name, $this->db); - } -} - -try { - if ($argc > 2) { - $dba = new dba_array($argv[1], $argv[2]); - if ($dba && $argc > 3) { - if ($argc > 4) { - $dba[$argv[3]] = $argv[4]; - } - var_dump(array('Index' => $argv[3], 'Value' => $dba[$argv[3]])); - } - $dba = NULL; - } - else - { - echo "Not enough parameters\n"; - exit(1); - } -} -catch (exception $err) { - var_dump($err); - exit(1); -} -?>
\ No newline at end of file diff --git a/ext/spl/examples/dba_dump.php b/ext/spl/examples/dba_dump.php deleted file mode 100755 index 77ea2008bd..0000000000 --- a/ext/spl/examples/dba_dump.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -/* dba dump utility - * - * Usage: php dba_dump <file> <handler> [<regex>] - * - * Show all groups in the ini file specified by <file>. - * The regular expression <regex> is used to filter the by setting name. - * - * Note: configure with --enable-dba - * - * (c) Marcus Boerger - */ - -require_once("dba_reader.inc"); -require_once("key_filter.inc"); - -$db = new dba_reader($argv[1], $argv[2]); - -if ($argc>3) { - $db = new key_filter($db, $argv[3]); -} - -foreach($db as $key => $val) { - echo "'$key' => '$val'\n"; -} - -?>
\ No newline at end of file diff --git a/ext/spl/examples/dba_reader.inc b/ext/spl/examples/dba_reader.inc deleted file mode 100755 index b8c7365f97..0000000000 --- a/ext/spl/examples/dba_reader.inc +++ /dev/null @@ -1,83 +0,0 @@ -<?php - -/** - * @brief This implements an dba iterator. - * @author Marcus Boerger - * @version 1.0 - */ -class dba_reader implements spl_sequence_assoc -{ - - private $db = NULL; - private $key = false; - private $val = false; - - /** - * Open database $file with $handler in read only mode. - * - * @param file Database file to open. - * @param handler Handler to use for database access. - */ - function __construct($file, $handler) { - $this->db = dba_open($file, 'r', $handler); - } - - /** - * Close database. - */ - function __destruct() { - if ($this->db) { - dba_close($this->db); - } - } - - /** - * Rewind to first element. - */ - function rewind() { - if ($this->db) { - $this->key = dba_firstkey($this->db); - } - } - - /** - * @return Current data. - */ - function current() { - return $this->val; - } - - /** - * Move to next element. - * - * @return void - */ - function next() { - if ($this->db) { - $this->key = dba_nextkey($this->db); - if ($this->key !== false) { - $this->val = dba_fetch($this->key, $this->db); - } - } - } - - /** - * @return Whether more elements are available. - */ - function hasMore() { - if ($this->db && $this->key !== false) { - return true; - } else { - return false; - } - } - - /** - * @return Current key. - */ - function key() { - return $this->key; - } -} - -?>
\ No newline at end of file diff --git a/ext/spl/examples/filter.inc b/ext/spl/examples/filter.inc deleted file mode 100755 index 1cab580edd..0000000000 --- a/ext/spl/examples/filter.inc +++ /dev/null @@ -1,96 +0,0 @@ -<?php - -/** - * @brief Regular expression filter for string iterators - * @author Marcus Boerger - * @version 1.0 - * - * Instances of this class act as a filter around iterators whose elements - * are strings. In other words you can put an iterator into the constructor - * and the instance will only return elements which match the given regular - * expression. - */ -class filter implements spl_forward -{ - protected $it; - protected $regex; - protected $curr; - - /** - * Constructs a filter around an iterator whose elemnts are strings. - * If the given iterator is of type spl_sequence then its rewind() - * method is called. - * - * @param it Object that implements at least spl_forward - * @patam regex Regular expression used as a filter. - */ - function __construct(spl_forward $it, $regex) { - if ($it instanceof spl_sequence) { - $it->rewind(); - } - $this->it = $it; - $this->regex = $regex; - $this->fetch(); - } - - /** - * Destruct the iterator. - */ - function __destruct() { - unset($this->it); - } - - protected function accept($curr) { - return ereg($this->regex, $curr); - } - - /** - * Fetch next element and store it. - * - * @return void - */ - protected function fetch() { - $this->curr = false; - while ($this->it->hasMore()) { - $curr = $this->it->current(); - if ($this->accept($curr)) { - $this->curr = $curr; - return; - } - $this->it->next(); - }; - } - - /** - * Move to next element - * - * @return void - */ - function next() { - $this->it->next(); - $this->fetch(); - } - - /** - * @return Whether more elements are available - */ - function hasMore() { - return $this->curr !== false; - } - - /** - * @return The current value - */ - function current() { - return $this->curr; - } - - /** - * hidden __clone - */ - protected function __clone() { - // disallow clone - } -} - -?>
\ No newline at end of file diff --git a/ext/spl/examples/filter_tree.php b/ext/spl/examples/filter_tree.php deleted file mode 100755 index 8ee4cef556..0000000000 --- a/ext/spl/examples/filter_tree.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php - -/* tree view example - * - * Usage: php filter_tree.php <path> <regex> - * - * Simply specify the path to tree with parameter <path>. - * The regular expression <regex> is used to filter the tree. - * - * (c) Marcus Boerger - */ - -require_once("sub_dir.inc"); -require_once("filter.inc"); - -foreach(new filter(new sub_dir($argv[1]), $argv[2]) as $f) { - echo "$f\n"; -} - -?>
\ No newline at end of file diff --git a/ext/spl/examples/ini_groups.php b/ext/spl/examples/ini_groups.php deleted file mode 100755 index 1909e87c2d..0000000000 --- a/ext/spl/examples/ini_groups.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - -/* List groups within an ini file - * - * Usage: php dba_dump <file> [<regex>] - * - * Show all groups in the ini file specified by <file>. - * The regular expression <regex> is used to filter the result. - * - * Note: configure with --enable-dba - * - * (c) Marcus Boerger - */ - -require_once("dba_reader.inc"); -require_once("key_filter.inc"); - -/** - * @brief Class to iterate all groups within an ini file. - * @author Marcus Boerger - * @version 1.0 - * - * Using this class you can iterator over all groups of a ini file. - * - * This class uses a 'is-a' relation to key_filter in contrast to a 'has-a' - * relation. Doing so both current() and key() methods must be overwritten. - * If it would use a 'has-a' relation there would be much more to type... - * but for puritists that would allow correctness in so far as then no - * key() would be needed. - */ -class ini_groups extends key_filter -{ - /** - * Construct an ini file group iterator from a filename. - * - * @param file Ini file to open. - */ - function __construct($file) { - parent::__construct(new dba_reader($file, 'inifile'), '^\[.*\]$'); - } - - /** - * @return The current group. - */ - function current() { - return substr(parent::key(),1,-1); - } - - /** - * @return The current group. - */ - function key() { - return substr(parent::key(),1,-1); - } -} - -$it = new ini_groups($argv[1]); -if ($argc>2) { - $it = new key_filter($it, $argv[2]); -} -foreach($it as $group) { - echo "$group\n"; -} - -?>
\ No newline at end of file diff --git a/ext/spl/examples/key_filter.inc b/ext/spl/examples/key_filter.inc deleted file mode 100755 index 47ceed2246..0000000000 --- a/ext/spl/examples/key_filter.inc +++ /dev/null @@ -1,102 +0,0 @@ -<?php - -/** - * @brief Regular expression filter for string iterators - * @author Marcus Boerger - * @version 1.0 - * - * Instances of this class act as a filter around iterators whose elements - * are strings. In other words you can put an iterator into the constructor - * and the instance will only return elements which match the given regular - * expression. - */ -class key_filter implements spl_forward_assoc -{ - protected $it; - protected $regex; - protected $key; - protected $curr; - - /** - * Constructs a filter around an iterator whose elemnts are strings. - * If the given iterator is of type spl_sequence then its rewind() - * method is called. - * - * @param it Object that implements at least spl_forward - * @patam regex Regular expression used as a filter. - */ - function __construct(spl_forward $it, $regex) { - if ($it instanceof spl_sequence) { - $it->rewind(); - } - $this->it = $it; - $this->regex = $regex; - $this->fetch(); - } - - /** - * Destruct the iterator. - */ - function __destruct() { - unset($this->it); - } - - /** - * Fetch next element and store it. - * - * @return void - */ - protected function fetch() { - $this->key = false; - $this->curr = false; - while ($this->it->hasMore()) { - $key = $this->it->key(); - if (ereg($this->regex, $key)) { - $this->key = $key; - $this->curr = $this->it->current(); - return; - } - $this->it->next(); - }; - } - - /** - * Move to next element - * - * @return void - */ - function next() { - $this->it->next(); - $this->fetch(); - } - - /** - * @return Whether more elements are available - */ - function hasMore() { - return $this->key !== false; - } - - /** - * @return The current key - */ - function key() { - return $this->key; - } - - /** - * @return The current value - */ - function current() { - return $this->curr; - } - - /** - * hidden __clone - */ - protected function __clone() { - // disallow clone - } -} - -?>
\ No newline at end of file diff --git a/ext/spl/examples/sub_dir.inc b/ext/spl/examples/sub_dir.inc deleted file mode 100755 index 2e869e78d4..0000000000 --- a/ext/spl/examples/sub_dir.inc +++ /dev/null @@ -1,134 +0,0 @@ -<?php - -/** - * @brief Subdirectory aware directory iterator. - * @author Marcus Boerger - * @version 1.0 - * - * This directory iterator recursively returns all files and directories - * within a given path. - */ -class sub_dir implements spl_sequence -{ - protected $adir = array(); - protected $cnt = 0; - protected $path = ''; - protected $curr = ''; - protected $nodots = true; - - /** - * Construct a directory from a path. - * - * @param path The path to iterate. - * @param nodots Whether or not to display the entries '.' and '..'. - */ - function __construct($path, $nodots = true, $graph = false) { - $this->cnt = 0; - $this->path = $path; - $this->nodots = $nodots; - $this->graph = $graph; - } - - /** - * Rewind the directory. - * - * @return void - */ - function rewind() { - while($this->cnt) { - unset($this->adir[$this->cnt--]); - } - $dir = new spl_dir($this->path); - $dir->path = ""; - $this->adir[1] = $dir; - $this->cnt = 1; - if ($this->nodots) { - while ($dir->hasMore()) { - $ent = $dir->current(); - if ($ent != '.' && $ent != '..') { - break; - } - $dir->next(); - } - } - } - - /** - * Move to net dir or file entry. - * - * @return void - */ - function next() { - if ($this->cnt) { - $dir = $this->adir[$this->cnt]; - $ent = $dir->current(); - $path = $dir->getPath().'/'.$ent; - if ($ent != '.' && $ent != '..' && is_dir($path)) { - $new = new spl_dir($path); - $new->path = $dir->path.$ent.'/'; - $new->cnt = $this->cnt++; - $this->adir[$this->cnt] = $new; - if ($this->nodots) { - $dir->has_more = false; - while ($new->hasMore()) { - $ent = $new->current(); - if ($ent != '.' && $ent != '..') { - $dir->has_more = true; - break; - } - $new->next(); - } - } else { - $dir->has_more = $dir->hasMore(); - } - } - $dir->next(); - } - } - - /** - * @return Whether more dirs or files entries are available. - */ - function hasMore() { - while ($this->cnt) { - $dir = $this->adir[$this->cnt]; - if ($dir->hasMore()) { - return true; - } - unset($this->adir[$this->cnt--]); - } - return false; - } - - /** - * @return The current dir or file entry. - */ - function current() { - if ($this->cnt) { - if ($this->graph) { - $prefix = ''; - for ($i = 1; $i < $this->cnt; $i++) { - $dir = $this->adir[$i]; - $prefix .= $dir->hasMore() ? '| ' : ' '; - } - $dir = $this->adir[$this->cnt]; - $ent = $dir->current(); - $prefix .= $dir->hasMore() ? '+-' : '\-'; - return $prefix . $ent; - } else { - $dir = $this->adir[$this->cnt]; - return $dir->path . $dir->current(); - } - } - throw new exception("No more elements available"); - } - - /** - * Hidden __clone - */ - protected function __clone() { - // disallow clone - } -} - -?>
\ No newline at end of file diff --git a/ext/spl/examples/tree.php b/ext/spl/examples/tree.php deleted file mode 100755 index 176c286076..0000000000 --- a/ext/spl/examples/tree.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/* tree view example - * - * Usage: php tree.php <path> - * - * Simply specify the path to tree with parameter <path>. - * - * (c) Marcus Boerger - */ - -require_once("sub_dir.inc"); - -foreach(new sub_dir($argv[1], true, isset($argv[2]) ? $argv[2] : false) as $f) { - echo "$f\n"; -} - -?>
\ No newline at end of file diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c deleted file mode 100755 index 7617f3fa9e..0000000000 --- a/ext/spl/php_spl.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.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. | - +----------------------------------------------------------------------+ - | Authors: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_spl.h" -#include "spl_functions.h" -#include "spl_engine.h" -#include "spl_foreach.h" -#include "spl_array.h" - -#ifdef COMPILE_DL_SPL -ZEND_GET_MODULE(spl) -#endif - -ZEND_DECLARE_MODULE_GLOBALS(spl) - -/* {{{ spl_functions - */ -function_entry spl_functions[] = { - PHP_FE(spl_classes, NULL) - PHP_FE(class_parents, NULL) - PHP_FE(class_implements, NULL) - {NULL, NULL, NULL} -}; -/* }}} */ - -/* {{{ spl_module_entry - */ -zend_module_entry spl_module_entry = { - STANDARD_MODULE_HEADER, - "spl", - spl_functions, - PHP_MINIT(spl), - PHP_MSHUTDOWN(spl), - PHP_RINIT(spl), - PHP_RSHUTDOWN(spl), - PHP_MINFO(spl), - "0.2", - STANDARD_MODULE_PROPERTIES -}; -/* }}} */ - -zend_class_entry *spl_ce_iterator; -zend_class_entry *spl_ce_forward; -zend_class_entry *spl_ce_assoc; -zend_class_entry *spl_ce_sequence; -zend_class_entry *spl_ce_forward_assoc; -zend_class_entry *spl_ce_sequence_assoc; -zend_class_entry *spl_ce_array_read; -zend_class_entry *spl_ce_array_access; - -/* {{{ spl_functions_none - */ -function_entry spl_functions_none[] = { - {NULL, NULL, NULL} -}; -/* }}} */ - -/* {{{ spl_init_globals - */ -static void spl_init_globals(zend_spl_globals *spl_globals) -{ -#ifdef SPL_FOREACH - ZEND_EXECUTE_HOOK(ZEND_FE_RESET); - ZEND_EXECUTE_HOOK(ZEND_FE_FETCH); - ZEND_EXECUTE_HOOK(ZEND_SWITCH_FREE); -#endif - -#if defined(SPL_ARRAY_READ) | defined(SPL_ARRAY_WRITE) - ZEND_EXECUTE_HOOK(ZEND_FETCH_DIM_R); - ZEND_EXECUTE_HOOK(ZEND_FETCH_DIM_W); - ZEND_EXECUTE_HOOK(ZEND_FETCH_DIM_RW); -#endif - -#ifdef SPL_ARRAY_WRITE - ZEND_EXECUTE_HOOK(ZEND_ASSIGN_DIM); - ZEND_EXECUTE_HOOK(ZEND_UNSET_DIM_OBJ); -#endif /* SPL_ARRAY_WRITE */ -} -/* }}} */ - -PHP_FUNCTION(spl_abstract) {} - -#define SPL_ABSTRACT_FE(class, name, arg_info) \ - { #name, ZEND_FN(spl_abstract), arg_info, sizeof(arg_info)/sizeof(struct _zend_arg_info)-1, ZEND_ACC_ABSTRACT|ZEND_ACC_PUBLIC }, - -static -ZEND_BEGIN_ARG_INFO(arginfo_one_param, 0) - ZEND_ARG_INFO(0, index) -ZEND_END_ARG_INFO(); - -static -ZEND_BEGIN_ARG_INFO(arginfo_two_params, 0) - ZEND_ARG_INFO(0, index) - ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO(); - -function_entry spl_funcs_iterator[] = { - SPL_ABSTRACT_FE(iterator, newIterator, NULL) - {NULL, NULL, NULL} -}; - -function_entry spl_funcs_forward[] = { - SPL_ABSTRACT_FE(forward, current, NULL) - SPL_ABSTRACT_FE(forward, next, NULL) - SPL_ABSTRACT_FE(forward, hasMore, NULL) - {NULL, NULL, NULL} -}; - -function_entry spl_funcs_sequence[] = { - SPL_ABSTRACT_FE(sequence, rewind, NULL) - {NULL, NULL, NULL} -}; - -function_entry spl_funcs_assoc[] = { - SPL_ABSTRACT_FE(assoc, key, NULL) - {NULL, NULL, NULL} -}; - -function_entry *spl_funcs_forward_assoc = NULL; -function_entry *spl_funcs_sequence_assoc = NULL; - -function_entry spl_funcs_array_read[] = { - SPL_ABSTRACT_FE(array_read, get, arginfo_one_param) - SPL_ABSTRACT_FE(array_read, exists, arginfo_one_param) - {NULL, NULL, NULL} -}; - -function_entry spl_funcs_array_access[] = { - SPL_ABSTRACT_FE(array_access, set, arginfo_two_params) - SPL_ABSTRACT_FE(array_access, del, arginfo_one_param) - {NULL, NULL, NULL} -}; - -/* {{{ PHP_MINIT_FUNCTION(spl) - */ -PHP_MINIT_FUNCTION(spl) -{ - ZEND_INIT_MODULE_GLOBALS(spl, spl_init_globals, NULL); - - REGISTER_SPL_INTERFACE(iterator); - - REGISTER_SPL_INTERFACE(forward); - - REGISTER_SPL_INTERFACE(sequence); - REGISTER_SPL_IMPLEMENT(sequence, forward); - - REGISTER_SPL_INTERFACE(assoc); - - REGISTER_SPL_INTERFACE(forward_assoc); - REGISTER_SPL_IMPLEMENT(forward_assoc, assoc); - REGISTER_SPL_IMPLEMENT(forward_assoc, forward); - - REGISTER_SPL_INTERFACE(sequence_assoc); - REGISTER_SPL_IMPLEMENT(sequence_assoc, forward_assoc); - REGISTER_SPL_IMPLEMENT(sequence_assoc, sequence); - - REGISTER_SPL_INTERFACE(array_read); - - REGISTER_SPL_INTERFACE(array_access); - REGISTER_SPL_IMPLEMENT(array_access, array_read); - - PHP_MINIT(spl_array)(INIT_FUNC_ARGS_PASSTHRU); - PHP_MINIT(spl_directory)(INIT_FUNC_ARGS_PASSTHRU); - - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_RINIT_FUNCTION(spl) - */ -PHP_RINIT_FUNCTION(spl) -{ - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_RSHUTDOWN_FUNCTION(spl) - */ -PHP_RSHUTDOWN_FUNCTION(spl) -{ - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_MSHUTDOWN_FUNCTION(spl) - */ -PHP_MSHUTDOWN_FUNCTION(spl) -{ - SPL_DEBUG(fprintf(stderr, "%s\n", "Shutting down SPL");) - -#ifdef SPL_FOREACH - ZEND_EXECUTE_HOOK_RESTORE(ZEND_FE_RESET); - ZEND_EXECUTE_HOOK_RESTORE(ZEND_FE_FETCH); - ZEND_EXECUTE_HOOK_RESTORE(ZEND_SWITCH_FREE); -#endif - -#if defined(SPL_ARRAY_READ) | defined(SPL_ARRAY_WRITE) - ZEND_EXECUTE_HOOK_RESTORE(ZEND_FETCH_DIM_R); - ZEND_EXECUTE_HOOK_RESTORE(ZEND_FETCH_DIM_W); - ZEND_EXECUTE_HOOK_RESTORE(ZEND_FETCH_DIM_RW); -#endif - -#ifdef SPL_ARRAY_WRITE - ZEND_EXECUTE_HOOK_RESTORE(ZEND_ASSIGN_DIM); -#endif /* SPL_ARRAY_WRITE */ - - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_MINFO(spl) - */ -PHP_MINFO_FUNCTION(spl) -{ -#ifdef SPL_FOREACH - char *foreach = "beta"; -#else /* SPL_ARRAY_WRITE */ - char *foreach = "beta, not hooked"; -#endif -#ifdef SPL_ARRAY_READ - char *array_read = "beta"; -#else /* SPL_ARRAY_WRITE */ - char *array_read = "beta, not hooked"; -#endif -#ifdef SPL_ARRAY_WRITE - char *array_write = "beta"; -#else /* SPL_ARRAY_WRITE */ - char *array_write = "beta, not hooked"; -#endif /* SPL_ARRAY_WRITE */ - - php_info_print_table_start(); - php_info_print_table_header(2, "SPL support", "enabled"); - php_info_print_table_row(2, "iterator", foreach); - php_info_print_table_row(2, "forward", foreach); - php_info_print_table_row(2, "sequence", foreach); - php_info_print_table_row(2, "assoc", foreach); - php_info_print_table_row(2, "forward_assoc", foreach); - php_info_print_table_row(2, "sequence_assoc", foreach); - php_info_print_table_row(2, "array_read", array_read); - php_info_print_table_row(2, "array_access", array_write); - php_info_print_table_end(); -} -/* }}} */ - -/* {{{ class_parents - */ -PHP_FUNCTION(class_parents) -{ - zval *obj; - zend_class_entry *parent_class; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) { - RETURN_FALSE; - } - array_init(return_value); - parent_class = Z_OBJCE_P(obj)->parent; - while (parent_class) { - spl_add_class_name(return_value, parent_class TSRMLS_CC); - parent_class = parent_class->parent; - } -} -/* }}} */ - -/* {{{ class_implements - */ -PHP_FUNCTION(class_implements) -{ - zval *obj; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) { - RETURN_FALSE; - } - array_init(return_value); - spl_add_interfaces(return_value, Z_OBJCE_P(obj) TSRMLS_CC); -} -/* }}} */ - -#define SPL_ADD_CLASS(class_name) \ - spl_add_classes(&spl_ce_ ## class_name, return_value TSRMLS_CC) - -/* {{{ spl_classes */ -PHP_FUNCTION(spl_classes) -{ - array_init(return_value); - - SPL_ADD_CLASS(iterator); - SPL_ADD_CLASS(forward); - SPL_ADD_CLASS(sequence); - SPL_ADD_CLASS(assoc); - SPL_ADD_CLASS(forward_assoc); - SPL_ADD_CLASS(sequence_assoc); - SPL_ADD_CLASS(array_read); - SPL_ADD_CLASS(array_access); -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/spl/php_spl.h b/ext/spl/php_spl.h deleted file mode 100755 index b8de833022..0000000000 --- a/ext/spl/php_spl.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.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. | - +----------------------------------------------------------------------+ - | Authors: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -#ifndef PHP_SPL_H -#define PHP_SPL_H - -#include "php.h" -#include <stdarg.h> - -#if 0 -#define SPL_DEBUG(x) x -#else -#define SPL_DEBUG(x) -#endif - -extern zend_module_entry spl_module_entry; -#define phpext_spl_ptr &spl_module_entry - -#if defined(PHP_WIN32) && !defined(COMPILE_DL_SPL) -#undef phpext_spl -#define phpext_spl NULL -#endif - -PHP_MINIT_FUNCTION(spl); -PHP_MSHUTDOWN_FUNCTION(spl); -PHP_RINIT_FUNCTION(spl); -PHP_RSHUTDOWN_FUNCTION(spl); -PHP_MINFO_FUNCTION(spl); - -#define ZEND_EXECUTE_HOOK_PTR(name) \ - opcode_handler_t handler_ ## name - -#define ZEND_EXECUTE_HOOK(name) \ - spl_globals->handler_ ## name = zend_opcode_handlers[name]; \ - zend_opcode_handlers[name] = spl_handler_ ## name - -#define ZEND_EXECUTE_HOOK_RESTORE(name) \ - zend_opcode_handlers[name] = SPL_G(handler_ ## name) - -#define ZEND_EXECUTE_HOOK_ORIGINAL(name) \ - return SPL_G(handler_ ## name)(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) - -#define ZEND_EXECUTE_HOOK_FUNCTION(name) \ - int spl_handler_ ## name(ZEND_OPCODE_HANDLER_ARGS) - -ZEND_BEGIN_MODULE_GLOBALS(spl) -#ifdef SPL_FOREACH - ZEND_EXECUTE_HOOK_PTR(ZEND_FE_RESET); - ZEND_EXECUTE_HOOK_PTR(ZEND_FE_FETCH); - ZEND_EXECUTE_HOOK_PTR(ZEND_SWITCH_FREE); -#endif -#if defined(SPL_ARRAY_READ) | defined(SPL_ARRAY_WRITE) - ZEND_EXECUTE_HOOK_PTR(ZEND_FETCH_DIM_R); - ZEND_EXECUTE_HOOK_PTR(ZEND_FETCH_DIM_W); - ZEND_EXECUTE_HOOK_PTR(ZEND_FETCH_DIM_RW); -#endif -#ifdef SPL_ARRAY_WRITE - ZEND_EXECUTE_HOOK_PTR(ZEND_ASSIGN_DIM); - ZEND_EXECUTE_HOOK_PTR(ZEND_UNSET_DIM_OBJ); -#endif -ZEND_END_MODULE_GLOBALS(spl) - -#ifdef ZTS -# define SPL_G(v) TSRMG(spl_globals_id, zend_spl_globals *, v) -extern int spl_globals_id; -#else -# define SPL_G(v) (spl_globals.v) -extern zend_spl_globals spl_globals; -#endif - -extern zend_class_entry *spl_ce_iterator; -extern zend_class_entry *spl_ce_forward; -extern zend_class_entry *spl_ce_sequence; -extern zend_class_entry *spl_ce_assoc; -extern zend_class_entry *spl_ce_forward_assoc; -extern zend_class_entry *spl_ce_sequence_assoc; -extern zend_class_entry *spl_ce_array_read; -extern zend_class_entry *spl_ce_array_access; - -PHP_FUNCTION(spl_classes); -PHP_FUNCTION(class_parents); -PHP_FUNCTION(class_implements); - -PHP_MINIT_FUNCTION(spl_array); -PHP_MINIT_FUNCTION(spl_directory); - -#endif /* PHP_SPL_H */ - -/* - * Local Variables: - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/spl/spl.php b/ext/spl/spl.php deleted file mode 100755 index 2edde96154..0000000000 --- a/ext/spl/spl.php +++ /dev/null @@ -1,340 +0,0 @@ -<?php - -/* Standard PHP Library - * - * (c) M.Boerger 2003 - */ - -/*! \brief Interface to foreach() construct - * - * Any class that implements this interface can for example be used as - * the input parameter to foreach() calls which would normally be an - * array. - * - * The class must implement the function new_iterator which must return - * an object which implements the interface spl_forward. - * - * \see spl_forward, spl_sequence, spl_forward_assoc, spl_sequence_assoc - */ -interface spl_iterator { - - /*! \brief Create a new iterator - * - * \return an object that implements the interface spl_forward. - */ - function new_iterator(); -} - -/*! \brief Simple forward iterator - * - * Any class that implements this interface can be used as the - * return of a foreach interface. And hence the class itself - * can be used as a parameter to be iterated (normally an array). - * - * \code - class c implements spl_iterator, spl_forward { - private $num = 0; - function new_iterator() { - $this->num = 0; - return $this; - } - function current() { - return $this->num; - } - function next() { - $this->num++; - } - function has_more() { - return $this->num < 5; - } - } - - $t = new c(); - - foreach($t as $num) { - echo "$num\n"; - } - \endcode - * - * A very interesting usage scenario are for example database queries. - * Without this interface you need to do it without foreach or fetch the - * whole rowset into an array. - * - * In the above code the class implements both the foreach and the - * forward interface. Doing this you cannot have nested foreach calls. - * If you need this you must split the two parts. - * - * \code - class c implements spl_iterator { - public $max = 3; - function new_iterator() { - return new c_iter($this); - } - } - class c_iter implements spl_forward { - private $obj; - private $num = 0; - function __construct($obj) { - $this->obj = $obj; - } - function current() { - return $this->num; - } - function next() { - $this->num++; - } - function has_more() { - return $this->num < $this->obj->max; - } - } - - $t = new c(); - - foreach($t as $outer) { - foreach($t as $inner) { - echo "$outer,$inner\n"; - } - } - \endcode - * - * You can also use this interface with the for() construct. - * - * \code - class c implements spl_iterator { - public $max = 3; - function new_iterator() { - return new c_iter($this); - } - } - class c_iter implements spl_forward { - private $obj; - private $num = 0; - function __construct($obj) { - $this->obj = $obj; - } - function current() { - return $this->num; - } - function next() { - $this->num++; - } - function has_more() { - return $this->num < $this->obj->max; - } - } - - $t = new c(); - - for ($iter = $t->new_iterator(); $iter->has_more(); $iter->next()) { - echo $iter->current() . "\n"; - } - \endcode - */ -interface spl_forward { - - /*! \brief Retrieve the current currentent - * - * \return \c mixed current element or \c false if no more elements - */ - function current(); - - /*! \brief Forward to next element. - */ - function next(); - - /*! \brief Check if more elements are available. - * - * This method is meant to be called right after calls to rewind() or - * next(). When you use foreach hooking then this is done automatically - * but you can use it inside a for loop yourself: - * \code - for(; $it->has_more(); $it->next()) { ... } - \endcode - * - * \return \c bool whether or not more elements are available - */ - function has_more(); -} - -/*! \brief A restartable iterator. - * - * This iterator allows you to implement a restartable iterator. That - * means the iterator can be rewind to the first element after accessing - * any number of elements. - * - * \note If you use sequence in foreach then rewind() will be called - * first. - */ -interface spl_sequence extends spl_forward { - - /*! Restart the sequence by positioning it to the first element. - */ - function rewind(); -} - -/*! \brief associative interface - * - * This interface allows to implement associative iterators - * and containers. - */ -interface spl_assoc { - - /*! \brief Retrieve the current elements key - * - * \return \c mixed current key or \c false if no more elements - */ - function key(); -} - -/*! \brief associative foreach() interface - * - * This interface extends the forward interface to support keys. - * With this interface you can do: - * \code - $t = new c(); - foreach($t as $key => $elem). - \endcode - */ -interface spl_assoc_forward implements spl_forward, spl_assoc { -} - -/*! \brief associative sequence - */ -interface spl_assoc_sequence implements spl_sequence, spl_assoc { -} - -/*! \brief array read only access for objects - */ -interface spl_array_read { - - /*! Check whether or not the given index exists. - * The returned value is interpreted as converted to bool. - */ - function exists($index); - - /*! Read the value at position $index. - * This function is only beeing called if exists() returns true. - */ - function get($index); -} - -/*! \brief array read/write access for objects. - * - * The following example shows how to use interface array_access: - * \code - class array_emulation implemets spl_array_access { - private $ar = array(); - function exists($index) { - return array_key_exists($index, $this->ar); - } - function get($index) { - return $this->ar[$index]; - } - function set($index, $value) { - $this->ar[$index] = $value; - } - function del($index) { - unset($this->ar[$index]); - } - } - \endcode - */ -interface spl_array_access implements spl_array_read { - - /*! Set the value identified by $index to $value. - */ - function set($index, $value); - - /*! Delete (unset) the value identified by $index. - */ - function del($index); -} - -/*! \brief An array wrapper - * - * This array wrapper allows to recursively iterate over Arrays and Objects. - * - * \see spl_array_it - */ -class spl_array implements spl_iterator { - - /*! Construct a new array iterator from anything that has a hash table. - * That is any Array or Object. - * - * \param $array the array to use. - */ - function __construct($array); - - /*! \copydoc spl_iterator::new_iterator - */ - function new_iterator(); -} - -/*! \brief An array iterator - * - * This iterator allows to unset and modify values and keys while iterating - * over Arrays and Objects. - * - * To use this class you must instanciate spl_array. - */ -class spl_array_it implements spl_sequence_assoc { - - /*! Construct a new array iterator from anything that has a hash table. - * That is any Array or Object. - * - * \param $array the array to use. - */ - private function __construct($array); - - /*! \copydoc spl_sequence::rewind - */ - function rewind(); - - /*! \copydoc spl_forward::current - */ - function current(); - - /*! \copydoc spl_assoc::key - */ - function key(); - - /*! \copydoc spl_forward::next - */ - function next(); - - /*! \copydoc spl_forward::has_more - */ - function has_more(); -} - -/*! \brief Directory iterator - */ -class spl_dir implements spl_sequence { - - /*! Construct a directory iterator from a path-string. - * - * \param $path directory to iterate. - */ - function __construct($path); - - /*! \copydoc spl_sequence::rewind - */ - function rewind(); - - /*! \copydoc spl_forward::current - */ - function current(); - - /*! \copydoc spl_forward::next - */ - function next(); - - /*! \copydoc spl_forward::has_more - */ - function has_more(); - - /*! \return The opened path. - */ - function get_path(); -} -?>
\ No newline at end of file diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c deleted file mode 100755 index 95132cb6c2..0000000000 --- a/ext/spl/spl_array.c +++ /dev/null @@ -1,772 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.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. | - +----------------------------------------------------------------------+ - | Authors: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "zend_compile.h" - -#include "php_spl.h" -#include "spl_functions.h" -#include "spl_engine.h" -#include "spl_array.h" - -#define DELETE_ZVAL(z) \ - if ((z)->refcount < 2) { \ - zval_dtor(z); \ - FREE_ZVAL(z); /* maybe safe_free_zval_ptr is needed for the uninitialised things */ \ - } - -#define DELETE_RET_ZVAL(z) \ - if ((z)->refcount < 3) { \ - zval_dtor(z); \ - FREE_ZVAL(z); /* maybe safe_free_zval_ptr is needed for the uninitialised things */ \ - } - -#define AI_PTR_2_PTR_PTR(ai) \ - (ai).ptr_ptr = &((ai).ptr) - -/* {{{ spl_fetch_dimension_address */ -int spl_fetch_dimension_address(znode *result, znode *op1, znode *op2, temp_variable *Ts, int type TSRMLS_DC) -{ - zval **obj; - zend_class_entry *obj_ce; - spl_is_a is_a; - - obj = spl_get_zval_ptr_ptr(op1, Ts TSRMLS_CC); - - if (!obj || (obj_ce = spl_get_class_entry(*obj TSRMLS_CC)) == NULL) { - return 1; - } - - is_a = spl_implements(obj_ce); - - if (is_a & SPL_IS_A_ARRAY_READ) { - zval **retval = &(T(result->u.var).var.ptr); - zval *dim = spl_get_zval_ptr(op2, Ts, &EG(free_op2) TSRMLS_CC); - zval *exists; - - spl_call_method_1(obj, obj_ce, NULL, "exists", sizeof("exists")-1, &exists, dim); - if (!i_zend_is_true(exists)) { - if (type == BP_VAR_R || type == BP_VAR_RW) { - SEPARATE_ZVAL(&dim); - convert_to_string_ex(&dim); - zend_error(E_NOTICE, "Undefined index: %s", Z_STRVAL_P(dim)); - DELETE_ZVAL(dim); - } - if (type == BP_VAR_R || type == BP_VAR_IS) { - DELETE_RET_ZVAL(exists); - *retval = &EG(error_zval); - (*retval)->refcount++; - FREE_OP(Ts, op2, EG(free_op2)); - SELECTIVE_PZVAL_LOCK(*retval, result); - return 0; - } - } - DELETE_RET_ZVAL(exists); - if (type == BP_VAR_R || type == BP_VAR_IS) { - spl_call_method_1(obj, obj_ce, NULL, "get", sizeof("get")-1, retval, dim); - } - FREE_OP(Ts, op2, EG(free_op2)); - return 0; - } - return 1; -} -/* }}} */ - -/* {{{ ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FETCH_DIM_R) */ -#ifdef SPL_ARRAY_READ -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FETCH_DIM_R) -{ - if (!spl_fetch_dimension_address(&EX(opline)->result, &EX(opline)->op1, &EX(opline)->op2, EX(Ts), BP_VAR_R TSRMLS_CC)) - { - if (EX(opline)->extended_value == ZEND_FETCH_ADD_LOCK) { - spl_pzval_lock_func(*EX_T(EX(opline)->op1.u.var).var.ptr_ptr); - } - spl_unlock_zval_ptr_ptr(&EX(opline)->op1, EX(Ts) TSRMLS_CC); - - AI_PTR_2_PTR_PTR(EX_T(EX(opline)->result.u.var).var); - NEXT_OPCODE(); - } - ZEND_EXECUTE_HOOK_ORIGINAL(ZEND_FETCH_DIM_R); -} -#endif -/* }}} */ - -/* {{{ ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FETCH_DIM_W) */ -#ifdef SPL_ARRAY_READ -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FETCH_DIM_W) -{ - if (!spl_fetch_dimension_address(&EX(opline)->result, &EX(opline)->op1, &EX(opline)->op2, EX(Ts), BP_VAR_W TSRMLS_CC)) - { - spl_unlock_zval_ptr_ptr(&EX(opline)->op1, EX(Ts) TSRMLS_CC); - - NEXT_OPCODE(); - } - ZEND_EXECUTE_HOOK_ORIGINAL(ZEND_FETCH_DIM_W); -} -#endif -/* }}} */ - -/* {{{ ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FETCH_DIM_RW) */ -#ifdef SPL_ARRAY_READ -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FETCH_DIM_RW) -{ - if (!spl_fetch_dimension_address(&EX(opline)->result, &EX(opline)->op1, &EX(opline)->op2, EX(Ts), BP_VAR_RW TSRMLS_CC)) - { - spl_unlock_zval_ptr_ptr(&EX(opline)->op1, EX(Ts) TSRMLS_CC); - - NEXT_OPCODE(); - } - ZEND_EXECUTE_HOOK_ORIGINAL(ZEND_FETCH_DIM_RW); -} -#endif -/* }}} */ - -static inline zval **spl_get_obj_zval_ptr_ptr(znode *op, temp_variable *Ts, int type TSRMLS_DC) -{ - if (op->op_type == IS_UNUSED) { - if (EG(This)) { - /* this should actually never be modified, _ptr_ptr is modified only when - the object is empty */ - return &EG(This); - } else { - zend_error(E_ERROR, "Using $this when not in object context"); - } - } - return spl_get_zval_ptr_ptr(op, Ts TSRMLS_CC); -} - -/* {{{ ZEND_EXECUTE_HOOK_FUNCTION(ZEND_ASSIGN_DIM) */ -#ifdef SPL_ARRAY_WRITE -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_ASSIGN_DIM) -{ - zval **obj; - zend_class_entry *obj_ce; - spl_is_a is_a; - - obj = spl_get_obj_zval_ptr_ptr(&EX(opline)->op1, EX(Ts), 0 TSRMLS_CC); - - if (!obj || (obj_ce = spl_get_class_entry(*obj TSRMLS_CC)) == NULL) { - ZEND_EXECUTE_HOOK_ORIGINAL(ZEND_ASSIGN_DIM); - } - - is_a = spl_implements(obj_ce); - - if (is_a & SPL_IS_A_ARRAY_ACCESS) { - znode *op2 = &EX(opline)->op2; - zval *index = spl_get_zval_ptr(op2, EX(Ts), &EG(free_op2), BP_VAR_R); - zval *free_value; - zend_op *value_op = EX(opline)+1; - zval *value = spl_get_zval_ptr(&value_op->op1, EX(Ts), &free_value, BP_VAR_R); - zval tmp; - zval *retval; - - spl_unlock_zval_ptr_ptr(&EX(opline)->op1, EX(Ts) TSRMLS_CC); - - /* here we are sure we are dealing with an object */ - switch (op2->op_type) { - case IS_CONST: - /* already a constant string */ - break; - case IS_VAR: - tmp = *index; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - index = &tmp; - break; - case IS_TMP_VAR: - convert_to_string(index); - break; - } - - /* separate our value if necessary */ - if (value_op->op1.op_type == IS_TMP_VAR) { - zval *orig_value = value; - - ALLOC_ZVAL(value); - *value = *orig_value; - value->is_ref = 0; - value->refcount = 0; - } - - spl_call_method_2(obj, obj_ce, NULL, "set", sizeof("set")-1, &retval, index, value); - - if (index == &tmp) { - zval_dtor(index); - } - - FREE_OP(Ts, op2, EG(free_op2)); - if (&EX(opline)->result) { - if (retval->refcount < 2) { - zend_error(E_WARNING, "Method %s::set() did not return a value, using input value", obj_ce->name); - EX_T(EX(opline)->result.u.var).var.ptr = value; - SELECTIVE_PZVAL_LOCK(value, &EX(opline)->result); - DELETE_RET_ZVAL(retval); - } else { - SELECTIVE_PZVAL_LOCK(retval, &EX(opline)->result); - EX_T(EX(opline)->result.u.var).var.ptr = retval; - retval->refcount--; - } - EX_T(EX(opline)->result.u.var).var.ptr_ptr = NULL; - } else { - DELETE_RET_ZVAL(retval); - } - - EX(opline)++; - NEXT_OPCODE(); - } - ZEND_EXECUTE_HOOK_ORIGINAL(ZEND_ASSIGN_DIM); -} -#endif -/* }}} */ - -/* {{{ ZEND_EXECUTE_HOOK_FUNCTION(ZEND_UNSET_DIM_OBJ) */ -#ifdef SPL_ARRAY_WRITE -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_UNSET_DIM_OBJ) -{ - zval **obj; - zend_class_entry *obj_ce; - spl_is_a is_a; - - if (EX(opline)->extended_value != ZEND_UNSET_DIM) { - ZEND_EXECUTE_HOOK_ORIGINAL(ZEND_UNSET_DIM_OBJ); - } - - obj = spl_get_obj_zval_ptr_ptr(&EX(opline)->op1, EX(Ts), 0 TSRMLS_CC); - - if (!obj || (obj_ce = spl_get_class_entry(*obj TSRMLS_CC)) == NULL) { - ZEND_EXECUTE_HOOK_ORIGINAL(ZEND_UNSET_DIM_OBJ); - } - - is_a = spl_implements(obj_ce); - - if (is_a & SPL_IS_A_ARRAY_ACCESS) { - znode *op2 = &EX(opline)->op2; - zval *index = spl_get_zval_ptr(op2, EX(Ts), &EG(free_op2), BP_VAR_R); - zval tmp; - zval *retval; - - spl_unlock_zval_ptr_ptr(&EX(opline)->op1, EX(Ts) TSRMLS_CC); - - /* here we are sure we are dealing with an object */ - switch (op2->op_type) { - case IS_CONST: - /* already a constant string */ - break; - case IS_VAR: - tmp = *index; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - index = &tmp; - break; - case IS_TMP_VAR: - convert_to_string(index); - break; - } - - spl_call_method_1(obj, obj_ce, NULL, "del", sizeof("del")-1, &retval, index); - - if (index == &tmp) { - zval_dtor(index); - } - - FREE_OP(Ts, op2, EG(free_op2)); - DELETE_RET_ZVAL(retval); - - NEXT_OPCODE(); - } - ZEND_EXECUTE_HOOK_ORIGINAL(ZEND_UNSET_DIM_OBJ); -} -#endif -/* }}} */ - -SPL_CLASS_FUNCTION(array, __construct); -SPL_CLASS_FUNCTION(array, newIterator); -SPL_CLASS_FUNCTION(array, rewind); -SPL_CLASS_FUNCTION(array, current); -SPL_CLASS_FUNCTION(array, key); -SPL_CLASS_FUNCTION(array, next); -SPL_CLASS_FUNCTION(array, hasMore); - -static -ZEND_BEGIN_ARG_INFO(arginfo_array___construct, 0) - ZEND_ARG_INFO(0, array) -ZEND_END_ARG_INFO(); - -static zend_function_entry spl_array_class_functions[] = { - SPL_CLASS_FE(array, __construct, arginfo_array___construct, ZEND_ACC_PUBLIC) - SPL_CLASS_FE(array, newIterator, NULL, ZEND_ACC_PUBLIC) - {NULL, NULL, NULL} -}; - -static zend_function_entry spl_array_it_class_functions[] = { - SPL_CLASS_FE(array, __construct, arginfo_array___construct, ZEND_ACC_PRIVATE) - SPL_CLASS_FE(array, rewind, NULL, ZEND_ACC_PUBLIC) - SPL_CLASS_FE(array, current, NULL, ZEND_ACC_PUBLIC) - SPL_CLASS_FE(array, key, NULL, ZEND_ACC_PUBLIC) - SPL_CLASS_FE(array, next, NULL, ZEND_ACC_PUBLIC) - SPL_CLASS_FE(array, hasMore, NULL, ZEND_ACC_PUBLIC) - {NULL, NULL, NULL} -}; - -static zend_object_handlers spl_array_handlers; -static zend_class_entry * spl_ce_array; - -static zend_object_handlers spl_array_it_handlers; -static zend_class_entry * spl_ce_array_it; - -typedef struct _spl_array_object { - zend_object std; - zval *array; - HashPosition pos; -} spl_array_object; - -/* {{{ spl_array_object_dtor */ -static void spl_array_object_dtor(void *object, zend_object_handle handle TSRMLS_DC) -{ - spl_array_object *intern = (spl_array_object *)object; - - zend_hash_destroy(intern->std.properties); - FREE_HASHTABLE(intern->std.properties); - - if (!ZVAL_DELREF(intern->array)) { - zval_dtor(intern->array); - FREE_ZVAL(intern->array); - } - - efree(object); -} -/* }}} */ - -/* {{{ spl_array_object_new */ -static zend_object_value spl_array_object_new_ex(zend_class_entry *class_type, spl_array_object **obj, spl_array_object *orig TSRMLS_DC) -{ - zend_object_value retval; - spl_array_object *intern; - zval *tmp; - - intern = emalloc(sizeof(spl_array_object)); - memset(intern, 0, sizeof(spl_array_object)); - intern->std.ce = class_type; - *obj = intern; - - ALLOC_HASHTABLE(intern->std.properties); - zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0); - zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); - - if (orig) { - intern->array = orig->array; - ZVAL_ADDREF(intern->array); - } else { - MAKE_STD_ZVAL(intern->array); - array_init(intern->array); - } - zend_hash_internal_pointer_reset_ex(HASH_OF(intern->array), &intern->pos); - - retval.handle = zend_objects_store_put(intern, spl_array_object_dtor, NULL TSRMLS_CC); - if (class_type == spl_ce_array_it) { - retval.handlers = &spl_array_it_handlers; - } else { - retval.handlers = &spl_array_handlers; - } - return retval; -} -/* }}} */ - -/* {{{ spl_array_object_new */ -static zend_object_value spl_array_object_new(zend_class_entry *class_type TSRMLS_DC) -{ - spl_array_object *tmp; - return spl_array_object_new_ex(class_type, &tmp, NULL TSRMLS_CC); -} -/* }}} */ - -/* {{{ spl_array_object_clone */ -static zend_object_value spl_array_object_clone(zval *zobject TSRMLS_DC) -{ - zend_object_value new_obj_val; - zend_object *old_object; - zend_object *new_object; - zend_object_handle handle = Z_OBJ_HANDLE_P(zobject); - spl_array_object *intern; - - old_object = zend_objects_get_address(zobject TSRMLS_CC); - new_obj_val = spl_array_object_new_ex(old_object->ce, &intern, (spl_array_object*)old_object TSRMLS_CC); - new_object = &intern->std; - - zend_objects_clone_members(new_object, new_obj_val, old_object, handle TSRMLS_CC); - - return new_obj_val; -} -/* }}} */ - -/* {{{ spl_array_get_ce */ -static zend_class_entry *spl_array_get_ce(zval *object TSRMLS_DC) -{ - return spl_ce_array; -} -/* }}} */ - -/* {{{ spl_array_it_get_ce */ -static zend_class_entry *spl_array_it_get_ce(zval *object TSRMLS_DC) -{ - return spl_ce_array_it; -} -/* }}} */ - -/* {{{ spl_array_read_dimension */ -static zval *spl_array_read_dimension(zval *object, zval *offset TSRMLS_DC) -{ - spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); - zval **retval; - long index; - - switch(Z_TYPE_P(offset)) { - case IS_STRING: - if (zend_symtable_find(HASH_OF(intern->array), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &retval) == FAILURE) { - zend_error(E_NOTICE,"Undefined index: %s", Z_STRVAL_P(offset)); - return EG(uninitialized_zval_ptr); - } else { - return *retval; - } - case IS_DOUBLE: - case IS_RESOURCE: - case IS_BOOL: - case IS_LONG: - if (offset->type == IS_DOUBLE) { - index = (long)Z_DVAL_P(offset); - } else { - index = Z_LVAL_P(offset); - } - if (zend_hash_index_find(HASH_OF(intern->array), index, (void **) &retval) == FAILURE) { - zend_error(E_NOTICE,"Undefined offset: %ld", Z_LVAL_P(offset)); - return EG(uninitialized_zval_ptr); - } else { - return *retval; - } - break; - default: - zend_error(E_WARNING, "Illegal offset type"); - return EG(uninitialized_zval_ptr); - } -} -/* }}} */ - -/* {{{ spl_array_write_dimension */ -static void spl_array_write_dimension(zval *object, zval *offset, zval *value TSRMLS_DC) -{ - spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); - long index; - - switch(Z_TYPE_P(offset)) { - case IS_STRING: - zend_symtable_update(HASH_OF(intern->array), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void**)&value, sizeof(void*), NULL); - return; - case IS_DOUBLE: - case IS_RESOURCE: - case IS_BOOL: - case IS_LONG: - if (offset->type == IS_DOUBLE) { - index = (long)Z_DVAL_P(offset); - } else { - index = Z_LVAL_P(offset); - } - add_index_zval(intern->array, index, value); - return; - default: - zend_error(E_WARNING, "Illegal offset type"); - return; - } -} -/* }}} */ - -/* {{{ spl_array_unset_dimension */ -static void spl_array_unset_dimension(zval *object, zval *offset TSRMLS_DC) -{ - spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); - long index; - - switch(Z_TYPE_P(offset)) { - case IS_STRING: - if (zend_symtable_del(HASH_OF(intern->array), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1) == FAILURE) { - zend_error(E_NOTICE,"Undefined index: %s", Z_STRVAL_P(offset)); - } - return; - case IS_DOUBLE: - case IS_RESOURCE: - case IS_BOOL: - case IS_LONG: - if (offset->type == IS_DOUBLE) { - index = (long)Z_DVAL_P(offset); - } else { - index = Z_LVAL_P(offset); - } - if (zend_hash_index_del(HASH_OF(intern->array), index) == FAILURE) { - zend_error(E_NOTICE,"Undefined offset: %ld", Z_LVAL_P(offset)); - } - return; - default: - zend_error(E_WARNING, "Illegal offset type"); - return; - } -} -/* }}} */ - -/* {{{ spl_array_get_properties */ -static HashTable *spl_array_get_properties(zval *object TSRMLS_DC) -{ - spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); - - return HASH_OF(intern->array); -} -/* }}} */ - -/* {{{ PHP_MINIT_FUNCTION(spl_array) */ -PHP_MINIT_FUNCTION(spl_array) -{ - REGISTER_SPL_STD_CLASS_EX(array, spl_array_object_new, spl_array_class_functions); - REGISTER_SPL_IMPLEMENT(array, iterator); - memcpy(&spl_array_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - spl_array_handlers.clone_obj = spl_array_object_clone; - spl_array_handlers.get_class_entry = spl_array_get_ce; - spl_array_handlers.read_dimension = spl_array_read_dimension; - spl_array_handlers.write_dimension = spl_array_write_dimension; - spl_array_handlers.unset_dimension = spl_array_unset_dimension; - spl_array_handlers.get_properties = spl_array_get_properties; - - REGISTER_SPL_STD_CLASS_EX(array_it, spl_array_object_new, spl_array_it_class_functions); - REGISTER_SPL_IMPLEMENT(array_it, sequence_assoc); - memcpy(&spl_array_it_handlers, &spl_array_handlers, sizeof(zend_object_handlers)); - spl_array_it_handlers.get_class_entry = spl_array_it_get_ce; - - return SUCCESS; -} -/* }}} */ - -/* {{{ proto void spl_array::__construct(array|object ar = array()) - proto void spl_array_it::__construct(array|object ar = array()) - Cronstructs a new array iterator from a path. */ -SPL_CLASS_FUNCTION(array, __construct) -{ - zval *object = getThis(); - spl_array_object *intern; - zval **array; - - if (ZEND_NUM_ARGS() == 0) { - return; /* nothing to do */ - } -/* exceptions do not work yet - php_set_error_handling(EH_THROW, zend_exception_get_default() TSRMLS_CC);*/ - - if (ZEND_NUM_ARGS() > 1 || zend_get_parameters_ex(1, &array) == FAILURE) { - WRONG_PARAM_COUNT; - } - if (!HASH_OF(*array)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Passed variable is not an array or object, using empty array instead"); - php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); - return; - } - intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); - zval_dtor(intern->array); - FREE_ZVAL(intern->array); - intern->array = *array; - ZVAL_ADDREF(intern->array); - - zend_hash_internal_pointer_reset_ex(HASH_OF(intern->array), &intern->pos); - - php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto spl_array_it|NULL spl_array::newIterator() - Create a new iterator from a spl_array instance */ -SPL_CLASS_FUNCTION(array, newIterator) -{ - zval *object = getThis(); - spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); - spl_array_object *iterator; - HashTable *aht = HASH_OF(intern->array); - - if (!aht) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array"); - return; - } - - return_value->type = IS_OBJECT; - return_value->value.obj = spl_array_object_new_ex(spl_ce_array_it, &iterator, intern TSRMLS_CC); - return_value->refcount = 1; - return_value->is_ref = 1; -} -/* }}} */ - -/* {{{ spl_hash_pos_exists */ -ZEND_API int spl_hash_pos_exists(spl_array_object * intern TSRMLS_DC) -{ - HashTable *ht = HASH_OF(intern->array); - Bucket *p; - -/* IS_CONSISTENT(ht);*/ - -/* HASH_PROTECT_RECURSION(ht);*/ - p = ht->pListHead; - while (p != NULL) { - if (p == intern->pos) { - return SUCCESS; - } - p = p->pListNext; - } -/* HASH_UNPROTECT_RECURSION(ht); */ - zend_hash_internal_pointer_reset_ex(HASH_OF(intern->array), &intern->pos); - return FAILURE; -} -/* }}} */ - -/* {{{ proto void spl_array_it::rewind() - Rewind array back to the start */ -SPL_CLASS_FUNCTION(array, rewind) -{ - zval *object = getThis(); - spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); - HashTable *aht = HASH_OF(intern->array); - - if (!aht) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array"); - return; - } - - zend_hash_internal_pointer_reset_ex(aht, &intern->pos); -} -/* }}} */ - -/* {{{ proto mixed|false spl_array_it::current() - Return current array entry */ -SPL_CLASS_FUNCTION(array, current) -{ - zval *object = getThis(); - spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); - zval **entry; - HashTable *aht = HASH_OF(intern->array); - - if (!aht) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array"); - return; - } - - if (intern->array->is_ref && spl_hash_pos_exists(intern TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid"); - RETURN_FALSE; - } - - if (zend_hash_get_current_data_ex(aht, (void **) &entry, &intern->pos) == FAILURE) { - RETURN_FALSE; - } - *return_value = **entry; - zval_copy_ctor(return_value); -} -/* }}} */ - -/* {{{ proto mixed|false spl_array_it::key() - Return current array key */ -SPL_CLASS_FUNCTION(array, key) -{ - zval *object = getThis(); - spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); - char *string_key; - uint string_length; - ulong num_key; - HashTable *aht = HASH_OF(intern->array); - - if (!aht) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array"); - return; - } - - if (intern->array->is_ref && spl_hash_pos_exists(intern TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid"); - RETURN_FALSE; - } - - switch (zend_hash_get_current_key_ex(aht, &string_key, &string_length, &num_key, 0, &intern->pos)) { - case HASH_KEY_IS_STRING: - RETVAL_STRINGL(string_key, string_length - 1, 1); - break; - case HASH_KEY_IS_LONG: - RETVAL_LONG(num_key); - break; - case HASH_KEY_NON_EXISTANT: - return; - } -} -/* }}} */ - -/* {{{ proto void spl_array_it::next() - Move to next entry */ -SPL_CLASS_FUNCTION(array, next) -{ - zval *object = getThis(); - spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); - HashTable *aht = HASH_OF(intern->array); - - if (!aht) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array"); - return; - } - - if (intern->array->is_ref && spl_hash_pos_exists(intern TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid"); - } else { - zend_hash_move_forward_ex(aht, &intern->pos); - } -} -/* }}} */ - -/* {{{ proto bool spl_array_it::hasMore() - Check whether array contains more entries */ -SPL_CLASS_FUNCTION(array, hasMore) -{ - zval *object = getThis(); - spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); - HashTable *aht = HASH_OF(intern->array); - - if (!aht) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array"); - return; - } - - if (intern->pos && intern->array->is_ref && spl_hash_pos_exists(intern TSRMLS_CC) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid"); - RETURN_FALSE; - } else { - RETURN_BOOL(zend_hash_has_more_elements_ex(aht, &intern->pos) == SUCCESS); - } -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/spl/spl_array.h b/ext/spl/spl_array.h deleted file mode 100755 index 840a9627eb..0000000000 --- a/ext/spl/spl_array.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.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. | - +----------------------------------------------------------------------+ - | Authors: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -#ifndef SPL_ARRAY_H -#define SPL_ARRAY_H - -#include "php.h" -#include "php_spl.h" - -#ifdef SPL_ARRAY_READ -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FETCH_DIM_R); -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FETCH_DIM_W); -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FETCH_DIM_RW); -#endif - -#ifdef SPL_ARRAY_WRITE -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_ASSIGN_DIM); -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_UNSET_DIM_OBJ); -#endif - -#endif /* SPL_ARRAY_H */ - -/* - * Local Variables: - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c deleted file mode 100755 index 045e5d4368..0000000000 --- a/ext/spl/spl_directory.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.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: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "zend_compile.h" -#include "zend_default_classes.h" - -#include "php_spl.h" -#include "spl_functions.h" -#include "spl_engine.h" -#include "spl_foreach.h" - -#include "php.h" -#include "fopen_wrappers.h" - -SPL_CLASS_FUNCTION(dir, __construct); -SPL_CLASS_FUNCTION(dir, rewind); -SPL_CLASS_FUNCTION(dir, current); -SPL_CLASS_FUNCTION(dir, next); -SPL_CLASS_FUNCTION(dir, hasMore); -SPL_CLASS_FUNCTION(dir, getPath); - -static -ZEND_BEGIN_ARG_INFO(arginfo_dir___construct, 0) - ZEND_ARG_INFO(0, path) -ZEND_END_ARG_INFO(); - -static zend_function_entry spl_dir_class_functions[] = { - SPL_CLASS_FE(dir, __construct, arginfo_dir___construct, ZEND_ACC_PUBLIC) - SPL_CLASS_FE(dir, rewind, NULL, ZEND_ACC_PUBLIC) - SPL_CLASS_FE(dir, current, NULL, ZEND_ACC_PUBLIC) - SPL_CLASS_FE(dir, next, NULL, ZEND_ACC_PUBLIC) - SPL_CLASS_FE(dir, hasMore, NULL, ZEND_ACC_PUBLIC) - SPL_CLASS_FE(dir, getPath, NULL, ZEND_ACC_PUBLIC) - {NULL, NULL, NULL} -}; - -static zend_object_handlers spl_dir_handlers; -static zend_class_entry *spl_ce_dir; - -typedef struct _spl_dir_object { - zend_object std; - php_stream *dirp; - php_stream_dirent entry; - char *path; -} spl_dir_object; - -/* {{{ spl_dir_object_dtor */ -static void spl_dir_object_dtor(void *object, zend_object_handle handle TSRMLS_DC) -{ - spl_dir_object *intern = (spl_dir_object *)object; - - zend_hash_destroy(intern->std.properties); - FREE_HASHTABLE(intern->std.properties); - - if (intern->path) { - efree(intern->path); - } - if (intern->dirp) { - php_stream_close(intern->dirp); - } - efree(object); -} -/* }}} */ - -/* {{{ spl_dir_object_new */ -static zend_object_value spl_dir_object_new_ex(zend_class_entry *class_type, spl_dir_object **obj TSRMLS_DC) -{ - zend_object_value retval; - spl_dir_object *intern; - zval *tmp; - - intern = emalloc(sizeof(spl_dir_object)); - memset(intern, 0, sizeof(spl_dir_object)); - intern->std.ce = class_type; - *obj = intern; - - ALLOC_HASHTABLE(intern->std.properties); - zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0); - zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); - - retval.handle = zend_objects_store_put(intern, spl_dir_object_dtor, NULL TSRMLS_CC); - retval.handlers = &spl_dir_handlers; - return retval; -} -/* }}} */ - -/* {{{ spl_dir_object_new */ -static zend_object_value spl_dir_object_new(zend_class_entry *class_type TSRMLS_DC) -{ - spl_dir_object *tmp; - return spl_dir_object_new_ex(class_type, &tmp TSRMLS_CC); -} -/* }}} */ - -/* {{{ spl_dir_open */ -static void spl_dir_open(spl_dir_object* intern, char *path TSRMLS_DC) -{ - /* we are using EH_THORW so REPORT_ERRORS results in exceptions */ - intern->dirp = php_stream_opendir(path, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL); - - intern->path = estrdup(path); - - if (intern->dirp == NULL) { - /* throw exception: should've been already happened */ - intern->entry.d_name[0] = '\0'; - } else { - if (!php_stream_readdir(intern->dirp, &intern->entry)) { - intern->entry.d_name[0] = '\0'; - } - } -} -/* }}} */ - -/* {{{ spl_dir_object_clone */ -static zend_object_value spl_dir_object_clone(zval *zobject TSRMLS_DC) -{ - zend_object_value new_obj_val; - zend_object *old_object; - zend_object *new_object; - zend_object_handle handle = Z_OBJ_HANDLE_P(zobject); - spl_dir_object *intern; - - old_object = zend_objects_get_address(zobject TSRMLS_CC); - new_obj_val = spl_dir_object_new_ex(old_object->ce, &intern TSRMLS_CC); - new_object = &intern->std; - - spl_dir_open(intern, ((spl_dir_object*)old_object)->path TSRMLS_CC); - - zend_objects_clone_members(new_object, new_obj_val, old_object, handle TSRMLS_CC); - - return new_obj_val; -} -/* }}} */ - -/* {{{ spl_dir_get_ce */ -static zend_class_entry *spl_dir_get_ce(zval *object TSRMLS_DC) -{ - return spl_ce_dir; -} -/* }}} */ - -/* {{{ PHP_MINIT_FUNCTION(spl_directory) */ -PHP_MINIT_FUNCTION(spl_directory) -{ - REGISTER_SPL_STD_CLASS_EX(dir, spl_dir_object_new, spl_dir_class_functions); - REGISTER_SPL_IMPLEMENT(dir, sequence); - memcpy(&spl_dir_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - spl_dir_handlers.clone_obj = spl_dir_object_clone; - spl_dir_handlers.get_class_entry = spl_dir_get_ce; - - return SUCCESS; -} -/* }}} */ - -/* {{{ proto void __construct(string path) - Cronstructs a new dir iterator from a path. */ -SPL_CLASS_FUNCTION(dir, __construct) -{ - zval *object = getThis(); - spl_dir_object *intern; - char *path; - long len; - - php_set_error_handling(EH_THROW, zend_exception_get_default() TSRMLS_CC); - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &len) == FAILURE) { - php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); - return; - } - - intern = (spl_dir_object*)zend_object_store_get_object(object TSRMLS_CC); - spl_dir_open(intern, path TSRMLS_CC); - - php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto void rewind() - Rewind dir back to the start */ -SPL_CLASS_FUNCTION(dir, rewind) -{ - zval *object = getThis(); - spl_dir_object *intern = (spl_dir_object*)zend_object_store_get_object(object TSRMLS_CC); - - if (intern->dirp) { - php_stream_rewinddir(intern->dirp); - } - if (!intern->dirp || !php_stream_readdir(intern->dirp, &intern->entry)) { - intern->entry.d_name[0] = '\0'; - } -} -/* }}} */ - -/* {{{ proto string current() - Return current dir entry */ -SPL_CLASS_FUNCTION(dir, current) -{ - zval *object = getThis(); - spl_dir_object *intern = (spl_dir_object*)zend_object_store_get_object(object TSRMLS_CC); - - if (intern->dirp) { - RETURN_STRING(intern->entry.d_name, 1); - } else { - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto void next() - Move to next entry */ -SPL_CLASS_FUNCTION(dir, next) -{ - zval *object = getThis(); - spl_dir_object *intern = (spl_dir_object*)zend_object_store_get_object(object TSRMLS_CC); - - if (!intern->dirp || !php_stream_readdir(intern->dirp, &intern->entry)) { - intern->entry.d_name[0] = '\0'; - } -} -/* }}} */ - -/* {{{ proto string hasMore() - Check whether dir contains more entries */ -SPL_CLASS_FUNCTION(dir, hasMore) -{ - zval *object = getThis(); - spl_dir_object *intern = (spl_dir_object*)zend_object_store_get_object(object TSRMLS_CC); - - RETURN_BOOL(intern->entry.d_name[0] != '\0'); -} -/* }}} */ - -/* {{{ proto string getPath() - Return directory path */ -SPL_CLASS_FUNCTION(dir, getPath) -{ - zval *object = getThis(); - spl_dir_object *intern = (spl_dir_object*)zend_object_store_get_object(object TSRMLS_CC); - - RETURN_STRING(intern->path, 1); -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/spl/spl_engine.c b/ext/spl/spl_engine.c deleted file mode 100755 index 349a599784..0000000000 --- a/ext/spl/spl_engine.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.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. | - +----------------------------------------------------------------------+ - | Authors: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "zend_compile.h" - -#include "php_spl.h" -#include "spl_functions.h" -#include "spl_engine.h" - -/* {{{ spl_instanciate */ -void spl_instanciate(zend_class_entry *pce, zval **object TSRMLS_DC) -{ - ALLOC_ZVAL(*object); - object_init_ex(*object, pce); - (*object)->refcount = 1; - (*object)->is_ref = 1; /* check if this can be hold always */ -} -/* }}} */ - -/* {{{ spl_instanciate_arg_ex2 */ -int spl_instanciate_arg_ex2(zend_class_entry *pce, zval **retval, zval *arg1, zval *arg2 TSRMLS_DC) -{ - zval *object; - - spl_instanciate(pce, &object TSRMLS_CC); - - retval = &EG(uninitialized_zval_ptr); - - spl_call_method(&object, pce, &pce->constructor, pce->constructor->common.function_name, strlen(pce->constructor->common.function_name), retval, 2, arg1, arg2 TSRMLS_CC); - *retval = object; - return 0; -} -/* }}} */ - -/* {{{ spl_get_zval_ptr_ptr - Remember to call spl_unlock_ptr_ptr when needed */ -zval ** spl_get_zval_ptr_ptr(znode *node, temp_variable *Ts TSRMLS_DC) -{ - if (node->op_type==IS_VAR) { - return T(node->u.var).var.ptr_ptr; - } else { - return NULL; - } -} -/* }}} */ - -/* {{{ spl_unlock_zval_ptr_ptr */ -void spl_unlock_zval_ptr_ptr(znode *node, temp_variable *Ts TSRMLS_DC) -{ - if (node->op_type==IS_VAR) { - if (T(node->u.var).var.ptr_ptr) { - spl_pzval_unlock_func(*T(node->u.var).var.ptr_ptr TSRMLS_CC); - } else if (T(node->u.var).EA.type==IS_STRING_OFFSET) { - spl_pzval_unlock_func(T(node->u.var).EA.data.str_offset.str TSRMLS_CC); - } - } -} -/* }}} */ - -/* {{{ spl_get_zval_ptr */ -zval * spl_get_zval_ptr(znode *node, temp_variable *Ts, zval **should_free TSRMLS_DC) -{ - switch (node->op_type) { - case IS_CONST: - *should_free = 0; - return &node->u.constant; - break; - case IS_TMP_VAR: - return *should_free = &T(node->u.var).tmp_var; - break; - case IS_VAR: - if (T(node->u.var).var.ptr) { - spl_pzval_unlock_func(T(node->u.var).var.ptr TSRMLS_CC); - *should_free = 0; - return T(node->u.var).var.ptr; - } else { - *should_free = &T(node->u.var).tmp_var; - - switch (T(node->u.var).EA.type) { - case IS_STRING_OFFSET: { - temp_variable *T = &T(node->u.var); - zval *str = T->EA.data.str_offset.str; - - if (T->EA.data.str_offset.str->type != IS_STRING - || (T->EA.data.str_offset.offset<0) - || (T->EA.data.str_offset.str->value.str.len <= T->EA.data.str_offset.offset)) { - zend_error(E_NOTICE, "Uninitialized string offset: %d", T->EA.data.str_offset.offset); - T->tmp_var.value.str.val = empty_string; - T->tmp_var.value.str.len = 0; - } else { - char c = str->value.str.val[T->EA.data.str_offset.offset]; - - T->tmp_var.value.str.val = estrndup(&c, 1); - T->tmp_var.value.str.len = 1; - } - spl_pzval_unlock_func(str TSRMLS_CC); - T->tmp_var.refcount=1; - T->tmp_var.is_ref=1; - T->tmp_var.type = IS_STRING; - return &T->tmp_var; - } - break; - } - } - break; - case IS_UNUSED: - *should_free = 0; - return NULL; - break; - EMPTY_SWITCH_DEFAULT_CASE() - } - return NULL; -} -/* }}} */ - -/* {{{ spl_is_instance_of */ -int spl_is_instance_of(zval **obj, zend_class_entry *ce TSRMLS_DC) -{ - /* Ensure everything needed is available before checking for the type. - */ - zend_class_entry *instance_ce; - - if (obj && (instance_ce = spl_get_class_entry(*obj TSRMLS_CC)) != NULL) { - return instanceof_function(instance_ce, ce TSRMLS_CC); - } - return 0; -} -/* }}} */ - -/* {{{ spl_implements */ -spl_is_a spl_implements(zend_class_entry *ce) -{ - register spl_is_a is_a = 0; - register int i = ce->num_interfaces; - register zend_class_entry **pce = ce->interfaces; - - while (i--) { - if (*pce == spl_ce_iterator) is_a |= SPL_IS_A_ITERATOR; - else if (*pce == spl_ce_forward) is_a |= SPL_IS_A_FORWARD; - else if (*pce == spl_ce_assoc) is_a |= SPL_IS_A_ASSOC; - else if (*pce == spl_ce_sequence) is_a |= SPL_IS_A_SEQUENCE; - else if (*pce == spl_ce_array_read) is_a |= SPL_IS_A_ARRAY_READ; - else if (*pce == spl_ce_array_access) is_a |= SPL_IS_A_ARRAY_ACCESS; - pce++; - } - return is_a; -} -/* }}} */ - -/* {{{ spl_call_method */ -zval * spl_call_method(zval **object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, char *function_name, int function_name_len, zval **retval_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC) -{ - int result; - zend_fcall_info fci; - zval z_fname; - zval *retval; - - zval **params[2]; - - params[0] = &arg1; - params[1] = &arg2; - - fci.size = sizeof(fci); - /*fci.function_table = NULL; will be read form zend_class_entry of object if needed */ - fci.object_pp = object_pp; - fci.function_name = &z_fname; - fci.retval_ptr_ptr = retval_ptr ? retval_ptr : &retval; - fci.param_count = param_count; - fci.params = params; - fci.no_separation = 1; - fci.symbol_table = NULL; - - if (!fn_proxy && !obj_ce) { - /* no interest in caching and no information already present that is - * needed later inside zend_call_function. */ - ZVAL_STRINGL(&z_fname, function_name, function_name_len, 0); - result = zend_call_function(&fci, NULL TSRMLS_CC); - } else { - zend_fcall_info_cache fcic; - - fcic.initialized = 1; - if (!obj_ce) { - obj_ce = Z_OBJCE_PP(object_pp); - } - if (!fn_proxy || !*fn_proxy) { - if (zend_hash_find(&obj_ce->function_table, function_name, function_name_len+1, (void **) &fcic.function_handler) == FAILURE) { - /* error at c-level */ - zend_error(E_CORE_ERROR, "Couldn't find implementation for method %s::%s\n", obj_ce->name, function_name); - } - if (fn_proxy) { - *fn_proxy = fcic.function_handler; - } - } else { - fcic.function_handler = *fn_proxy; - } - fcic.calling_scope = obj_ce; - fcic.object_pp = object_pp; - result = zend_call_function(&fci, &fcic TSRMLS_CC); - } - if (result == FAILURE) { - /* error at c-level */ - if (!obj_ce) { - obj_ce = Z_OBJCE_PP(object_pp); - } - zend_error(E_CORE_ERROR, "Couldn't execute method %s::%s\n", obj_ce->name, function_name); - } - if (!retval_ptr && retval) { - zval_dtor(retval); - FREE_ZVAL(retval); - return NULL; - } - return *retval_ptr; -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/spl/spl_engine.h b/ext/spl/spl_engine.h deleted file mode 100755 index 19f4ccc83b..0000000000 --- a/ext/spl/spl_engine.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.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. | - +----------------------------------------------------------------------+ - | Authors: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -#ifndef SPL_ENGINE_H -#define SPL_ENGINE_H - -#include "php.h" -#include "php_spl.h" - -#include "zend_compile.h" - -#undef EX -#define EX(element) execute_data->element -#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset)) -#define T(offset) (*(temp_variable *)((char *) Ts + offset)) - -#define NEXT_OPCODE() \ - EX(opline)++; \ - return 0; - -zval * spl_call_method(zval **object_pp, zend_class_entry *obj_ce, zend_function **fn_proxy, char *function_name, int function_name_len, zval **retval_ptr, int param_count, zval* arg1, zval* arg2 TSRMLS_DC); - -/* {{{ zend_class_entry */ -static inline zend_class_entry *spl_get_class_entry(zval *obj TSRMLS_DC) -{ - if (obj && Z_TYPE_P(obj) == IS_OBJECT && Z_OBJ_HT_P(obj)->get_class_entry) { - return Z_OBJ_HT_P(obj)->get_class_entry(obj TSRMLS_CC); - } else { - return NULL; - } -} -/* }}} */ - -#define spl_call_method_0(obj, obj_ce, fn_proxy, function_name, fname_len, retval) \ - spl_call_method(obj, obj_ce, fn_proxy, function_name, fname_len, retval, 0, NULL, NULL TSRMLS_CC) - -#define spl_call_method_1(obj, obj_ce, fn_proxy, function_name, fname_len, retval, arg1) \ - spl_call_method(obj, obj_ce, fn_proxy, function_name, fname_len, retval, 1, arg1, NULL TSRMLS_CC) - -#define spl_call_method_2(obj, obj_ce, fn_proxy, function_name, fname_len, retval, arg1, arg2) \ - spl_call_method(obj, obj_ce, fn_proxy, function_name, fname_len, retval, 2, arg1, arg2 TSRMLS_CC) - -void spl_instanciate(zend_class_entry *pce, zval **object TSRMLS_DC); -int spl_instanciate_arg_ex2(zend_class_entry *pce, zval **retval, zval *arg1, zval *arg2 TSRMLS_DC); - -zval ** spl_get_zval_ptr_ptr(znode *node, temp_variable *Ts TSRMLS_DC); -void spl_unlock_zval_ptr_ptr(znode *node, temp_variable *Ts TSRMLS_DC); -zval * spl_get_zval_ptr(znode *node, temp_variable *Ts, zval **should_free TSRMLS_DC); - -int spl_is_instance_of(zval **obj, zend_class_entry *ce TSRMLS_DC); - -typedef enum { - SPL_IS_A_ITERATOR = 0x01, - SPL_IS_A_FORWARD = 0x02, - SPL_IS_A_ASSOC = 0x04, - SPL_IS_A_SEQUENCE = 0x08, - SPL_IS_A_ARRAY_READ = 0x10, - SPL_IS_A_ARRAY_ACCESS = 0x20 -} spl_is_a; - -spl_is_a spl_implements(zend_class_entry *ce); - -/* Use this only insode OPCODE-Hooks */ -static inline void spl_pzval_unlock_func(zval *z TSRMLS_DC) -{ - z->refcount--; - if (!z->refcount) { - z->refcount = 1; - z->is_ref = 0; - EG(garbage)[EG(garbage_ptr)++] = z; - } -} - -/* Use this only insode OPCODE-Hooks */ -static inline void spl_pzval_lock_func(zval *z) -{ - z->refcount++; -} - -/* Use this only insode OPCODE-Hooks */ -#define SELECTIVE_PZVAL_LOCK(pzv, pzn) if (!((pzn)->u.EA.type & EXT_TYPE_UNUSED)) { spl_pzval_lock_func(pzv); } - -#endif /* SPL_ENGINE_H */ - -/* - * Local Variables: - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/spl/spl_foreach.c b/ext/spl/spl_foreach.c deleted file mode 100755 index 90441415d8..0000000000 --- a/ext/spl/spl_foreach.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.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. | - +----------------------------------------------------------------------+ - | Authors: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "zend_compile.h" - -#include "php_spl.h" -#include "spl_functions.h" -#include "spl_engine.h" -#include "spl_foreach.h" - -#define OPTIMIZED_ARRAY_CONSTRUCT - -typedef struct { - zend_function *next; - zend_function *rewind; - zend_function *more; - zend_function *current; - zend_function *key; -} spl_foreach_funcs; - -typedef struct { - zval *obj; - zend_class_entry *obj_ce; - zend_uint index; - spl_is_a is_a; - spl_foreach_funcs funcs; - char dummy; /* needed for '\0' but we can't set it due to compiler optimizations */ -} spl_foreach_proxy; - -/* {{{ ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FE_RESET) */ -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FE_RESET) -{ - zval **obj, *retval; - spl_foreach_proxy *proxy; - zend_class_entry *instance_ce, *obj_ce; - spl_is_a is_a; - temp_variable *tmp; - - obj = spl_get_zval_ptr_ptr(&EX(opline)->op1, EX(Ts) TSRMLS_CC); - - if (!obj || (instance_ce = spl_get_class_entry(*obj TSRMLS_CC)) == NULL) { - ZEND_EXECUTE_HOOK_ORIGINAL(ZEND_FE_RESET); - } - - is_a = spl_implements(instance_ce); - - if (is_a & SPL_IS_A_ITERATOR) { - spl_unlock_zval_ptr_ptr(&EX(opline)->op1, EX(Ts) TSRMLS_CC); - obj_ce = instance_ce; - spl_call_method_0(obj, obj_ce, NULL, "newiterator", sizeof("newiterator")-1, &retval); - instance_ce = spl_get_class_entry(retval TSRMLS_CC); - is_a = spl_implements(instance_ce); - if (!(is_a & SPL_IS_A_FORWARD)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Objects created by %s::newIterator() must implement spl_forward", obj_ce->name); - ZEND_EXECUTE_HOOK_ORIGINAL(ZEND_FE_RESET); - } - spl_pzval_lock_func(retval); - } else if (is_a & SPL_IS_A_FORWARD) { - spl_unlock_zval_ptr_ptr(&EX(opline)->op1, EX(Ts) TSRMLS_CC); - retval = *obj; - retval->refcount += 2; /* lock two times */ - } else { - ZEND_EXECUTE_HOOK_ORIGINAL(ZEND_FE_RESET); - } - - /* create the proxy */ - proxy = emalloc(sizeof(spl_foreach_proxy)); - proxy->obj = retval; - proxy->obj_ce = instance_ce; - proxy->index = 0; - proxy->is_a = is_a; - memset(&proxy->funcs, 0, sizeof(spl_foreach_funcs)); - ((char*)proxy)[sizeof(spl_foreach_proxy)-1] = '\0'; - /* And pack it into a zval. Since it is nowhere accessible using a - * zval of type STRING is the fastest approach of storing the proxy. - */ - ALLOC_ZVAL(retval); - ZVAL_STRINGL(retval, (char*)proxy, sizeof(spl_foreach_proxy)-1, 0); - retval->is_ref = 0; - retval->refcount = 2; /* lock two times */ - /* return the created proxy container */ - tmp = &EX_T(EX(opline)->result.u.var); - tmp->var.ptr = retval; - tmp->var.ptr_ptr = &tmp->var.ptr; - - NEXT_OPCODE(); -} -/* }}} */ - -/* {{{ OPTIMIZED_ARRAY_CONSTRUCT macros */ -#ifdef OPTIMIZED_ARRAY_CONSTRUCT -#define CONNECT_TO_BUCKET_DLLIST(element, list_head) \ - (element)->pNext = (list_head); \ - (element)->pLast = NULL; - -#define CONNECT_TO_GLOBAL_DLLIST(element, ht) \ - (element)->pListLast = (ht)->pListTail; \ - (ht)->pListTail = (element); \ - (element)->pListNext = NULL; \ - if ((element)->pListLast != NULL) { \ - (element)->pListLast->pListNext = (element); \ - } \ - if (!(ht)->pListHead) { \ - (ht)->pListHead = (element); \ - } \ - if ((ht)->pInternalPointer == NULL) { \ - (ht)->pInternalPointer = (element); \ - } -#endif -/* }}} */ - -/* {{{ ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FE_FETCH) */ -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FE_FETCH) -{ - znode *op1 = &EX(opline)->op1; - zval **obj = spl_get_zval_ptr_ptr(op1, EX(Ts) TSRMLS_CC); - zval *more, *value, *key, *result; - spl_foreach_proxy *proxy; - - if (Z_TYPE_PP(obj) == IS_STRING) { - int has_more; - - proxy = (spl_foreach_proxy*)Z_STRVAL_PP(obj); - obj = &proxy->obj; /* will be optimized out */ - - if (proxy->index++) { - spl_call_method_0(obj, proxy->obj_ce, &proxy->funcs.next, "next", sizeof("next")-1, NULL); - } else { - if (proxy->is_a & SPL_IS_A_SEQUENCE) { - spl_call_method_0(obj, proxy->obj_ce, &proxy->funcs.rewind, "rewind", sizeof("rewind")-1, NULL); - } - /* now this is an optimization trick: - ZEND_SWITCH_FREE receives the array copy or the spl object in op1 and has an unused op2 - We have to check for op1 being an object that implements spl_forwar... Or we simply set - op2 and know we can safely free the object as needed, which is waht we do. */ - op_array->opcodes[EX(opline)->op2.u.opline_num].op2 = *op1; - } - - spl_call_method_0(obj, proxy->obj_ce, &proxy->funcs.more, "hasmore", sizeof("hasmore")-1, &more); - has_more = i_zend_is_true(more); - zval_dtor(more); - FREE_ZVAL(more); - if (has_more) { - result = &EX_T(EX(opline)->result.u.var).tmp_var; - - spl_call_method_0(obj, proxy->obj_ce, &proxy->funcs.current, "current", sizeof("current")-1, &value); - - if (proxy->is_a & SPL_IS_A_ASSOC) { - spl_call_method_0(obj, proxy->obj_ce, &proxy->funcs.key, "key", sizeof("key")-1, &key); - } else { - MAKE_STD_ZVAL(key); - key->value.lval = proxy->index; - key->type = IS_LONG; - } -#ifndef OPTIMIZED_ARRAY_CONSTRUCT - array_init(result); - add_next_index_zval(result, value); - add_next_index_zval(result, key); -#else - { - Bucket *p; - HashTable *ht; - - ht = emalloc(sizeof(HashTable)); - result->value.ht = ht; - ht->nTableSize = 1 << 1; - ht->nTableMask = ht->nTableSize - 1; -#if ZEND_DEBUG - ht->inconsistent = 0; /*HT_OK;*/ -#endif - - ht->arBuckets = (Bucket **)emalloc(ht->nTableSize * sizeof(Bucket *)); - - ht->pDestructor = ZVAL_PTR_DTOR; - ht->pListHead = NULL; - ht->pListTail = NULL; - ht->nNumOfElements = 0; - ht->nNextFreeElement = 0; - ht->pInternalPointer = NULL; - ht->persistent = 0; - ht->nApplyCount = 0; - ht->bApplyProtection = 1; - result->type = IS_ARRAY; - - p = (Bucket*)emalloc(sizeof(Bucket)-1); - p->pDataPtr = value; - p->pData = &p->pDataPtr; - p->nKeyLength = 0; - p->h = 0; - result->value.ht->arBuckets[0] = p; - CONNECT_TO_BUCKET_DLLIST(p, ht->arBuckets[0]); - CONNECT_TO_GLOBAL_DLLIST(p, ht); - - p = (Bucket*)emalloc(sizeof(Bucket)-1); - p->pDataPtr = key; - p->pData = &p->pDataPtr; - p->nKeyLength = 0; - p->h = 1; - result->value.ht->arBuckets[1] = p; - CONNECT_TO_BUCKET_DLLIST(p, ht->arBuckets[1]); - CONNECT_TO_GLOBAL_DLLIST(p, ht); - - ht->nNumOfElements = 2; - } -#endif - NEXT_OPCODE(); - } - EX(opline) = op_array->opcodes+EX(opline)->op2.u.opline_num; - return 0; - } - ZEND_EXECUTE_HOOK_ORIGINAL(ZEND_FE_FETCH); -} -/* }}} */ - -/* {{{ ZEND_EXECUTE_HOOK_FUNCTION(ZEND_SWITCH_FREE) */ -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_SWITCH_FREE) -{ - /* See not in ZEND_FE_FETCH on setting op2 */ - znode *op2 = &EX(opline)->op2; - zval *tmp, **obj = spl_get_zval_ptr_ptr(op2, EX(Ts) TSRMLS_CC); - spl_foreach_proxy *proxy; - - if (obj) { - proxy = (spl_foreach_proxy*)Z_STRVAL_PP(obj); - tmp = *obj; - *obj = proxy->obj; /* restore */ - - efree(tmp->value.str.val); - FREE_ZVAL(tmp); - - spl_unlock_zval_ptr_ptr(&EX(opline)->op1, EX(Ts) TSRMLS_CC); - spl_pzval_lock_func(*obj); - - SET_UNUSED(*op2); - } - ZEND_EXECUTE_HOOK_ORIGINAL(ZEND_SWITCH_FREE); -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/spl/spl_foreach.h b/ext/spl/spl_foreach.h deleted file mode 100755 index e27f9e77de..0000000000 --- a/ext/spl/spl_foreach.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.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. | - +----------------------------------------------------------------------+ - | Authors: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -#ifndef SPL_FOREACH_H -#define SPL_FOREACH_H - -#include "php.h" -#include "php_spl.h" - -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FE_RESET); -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_FE_FETCH); -ZEND_EXECUTE_HOOK_FUNCTION(ZEND_SWITCH_FREE); - -#endif /* SPL_FOREACH_H */ - -/* - * Local Variables: - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/spl/spl_functions.c b/ext/spl/spl_functions.c deleted file mode 100755 index 126a6f15e3..0000000000 --- a/ext/spl/spl_functions.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.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. | - +----------------------------------------------------------------------+ - | Authors: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_spl.h" -#include "spl_foreach.h" - -/* {{{ spl_destroy_class */ -void spl_destroy_class(zend_class_entry ** ppce) -{ - SPL_DEBUG(fprintf(stderr, "Destroy(%s): %s\n", (*ppce)->type == ZEND_USER_CLASS ? "user" : "other", (*ppce)->name);) - destroy_zend_class(ppce); -} -/* }}} */ - -/* {{{ spl_register_interface */ -void spl_register_interface(zend_class_entry ** ppce, char * class_name, zend_function_entry *functions TSRMLS_DC) -{ - zend_class_entry ce; - - INIT_CLASS_ENTRY(ce, class_name, functions); - ce.name_length = strlen(class_name); - *ppce = zend_register_internal_class(&ce TSRMLS_CC); - - /* entries changed by initialize */ - (*ppce)->ce_flags = ZEND_ACC_ABSTRACT | ZEND_ACC_INTERFACE; -} -/* }}} */ - -/* {{{ spl_register_std_class */ -void spl_register_std_class(zend_class_entry ** ppce, char * class_name, void * obj_ctor, function_entry * function_list TSRMLS_DC) -{ - zend_class_entry ce; - - INIT_CLASS_ENTRY(ce, class_name, function_list); - ce.name_length = strlen(class_name); - *ppce = zend_register_internal_class(&ce TSRMLS_CC); - - /* entries changed by initialize */ - (*ppce)->create_object = obj_ctor; -} -/* }}} */ - -/* {{{ spl_register_parent_ce */ -void spl_register_parent_ce(zend_class_entry * class_entry, zend_class_entry * parent_class TSRMLS_DC) -{ - class_entry->parent = parent_class; -} -/* }}} */ - -/* {{{ spl_register_implement */ -void spl_register_implement(zend_class_entry * class_entry, zend_class_entry * interface_entry TSRMLS_DC) -{ - zend_class_implements(class_entry TSRMLS_CC, 1, interface_entry); -} -/* }}} */ - -/* {{{ spl_register_functions */ -void spl_register_functions(zend_class_entry * class_entry, function_entry * function_list TSRMLS_DC) -{ - zend_register_functions(class_entry, function_list, &class_entry->function_table, MODULE_PERSISTENT TSRMLS_CC); -} -/* }}} */ - -/* {{{ spl_register_property */ -void spl_register_property( zend_class_entry * class_entry, char *prop_name, zval *prop_val, int prop_flags TSRMLS_DC) -{ - if (!prop_val) { - INIT_PZVAL(prop_val); - prop_val->type = IS_NULL; - } - - zend_declare_property(class_entry, prop_name, strlen(prop_name), prop_val, prop_flags TSRMLS_CC); -} -/* }}} */ - -/* {{{ spl_add_class_name */ -void spl_add_class_name(zval * list, zend_class_entry * pce TSRMLS_DC) -{ - size_t len = strlen(pce->name); - zval *tmp; - - if (zend_hash_find(Z_ARRVAL_P(list), pce->name, len+1, (void*)&tmp) == FAILURE) { - MAKE_STD_ZVAL(tmp); - ZVAL_STRING(tmp, pce->name, 1); - zend_hash_add(Z_ARRVAL_P(list), pce->name, len+1, &tmp, sizeof(zval *), NULL); - } -} -/* }}} */ - -/* {{{ spl_add_interfaces */ -void spl_add_interfaces(zval *list, zend_class_entry * pce TSRMLS_DC) -{ - zend_uint num_interfaces; - - for (num_interfaces = 0; num_interfaces < pce->num_interfaces; num_interfaces++) { - spl_add_class_name(list, pce->interfaces[num_interfaces] TSRMLS_CC); - } -} -/* }}} */ - -/* {{{ spl_add_classes */ -int spl_add_classes(zend_class_entry ** ppce, zval *list TSRMLS_DC) -{ - zend_class_entry *pce = *ppce; - spl_add_class_name(list, pce TSRMLS_CC); - spl_add_interfaces(list, pce TSRMLS_CC); - while (pce->parent) { - pce = pce->parent; - spl_add_classes(&pce, list TSRMLS_CC); - } - return 0; -} -/* }}} */ - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/spl/spl_functions.h b/ext/spl/spl_functions.h deleted file mode 100755 index 1a2aa15037..0000000000 --- a/ext/spl/spl_functions.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.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. | - +----------------------------------------------------------------------+ - | Authors: Marcus Boerger <helly@php.net> | - +----------------------------------------------------------------------+ - */ - -#ifndef PHP_FUNCTIONS_H -#define PHP_FUNCTIONS_H - -#include "php.h" - -typedef zend_object_value (*create_object_func_t)(zend_class_entry *class_type TSRMLS_DC); - -#define REGISTER_SPL_STD_CLASS(class_name, obj_ctor) \ - spl_register_std_class(&spl_ce_ ## class_name, "spl_" # class_name, obj_ctor, NULL TSRMLS_CC); - -#define REGISTER_SPL_STD_CLASS_EX(class_name, obj_ctor, funcs) \ - spl_register_std_class(&spl_ce_ ## class_name, "spl_" # class_name, obj_ctor, funcs TSRMLS_CC); - -#define REGISTER_SPL_INTERFACE(class_name) \ - spl_register_interface(&spl_ce_ ## class_name, "spl_" # class_name, spl_funcs_ ## class_name TSRMLS_CC); - -#define REGISTER_SPL_PARENT_CE(class_name, parent_class) \ - spl_register_parent_ce(spl_ce_ ## class_name, spl_ce_ ## parent_class TSRMLS_CC); - -#define REGISTER_SPL_IMPLEMENT(class_name, interface_name) \ - spl_register_implement(spl_ce_ ## class_name, spl_ce_ ## interface_name TSRMLS_CC); - -#define REGISTER_SPL_FUNCTIONS(class_name, function_list) \ - spl_register_functions(spl_ce_ ## class_name, function_list TSRMLS_CC); - -#define REGISTER_SPL_PROPERTY(class_name, prop_name) \ - spl_register_property(spl_ce_ ## class_name, prop_name, prop_val, prop_flags TSRMLS_CC); - -void spl_destroy_class(zend_class_entry ** ppce); - -void spl_register_std_class(zend_class_entry ** ppce, char * class_name, create_object_func_t ctor, function_entry * function_list TSRMLS_DC); - -void spl_register_interface(zend_class_entry ** ppce, char * class_name, zend_function_entry *functions TSRMLS_DC); - -void spl_register_parent_ce(zend_class_entry * class_entry, zend_class_entry * parent_class TSRMLS_DC); -void spl_register_implement(zend_class_entry * class_entry, zend_class_entry * interface_entry TSRMLS_DC); -void spl_register_functions(zend_class_entry * class_entry, function_entry * function_list TSRMLS_DC); -void spl_register_property( zend_class_entry * class_entry, char *prop_name, zval *prop_val, int prop_flags TSRMLS_DC); - -void spl_add_class_name(zval * list, zend_class_entry * pce TSRMLS_DC); -void spl_add_interfaces(zval * list, zend_class_entry * pce TSRMLS_DC); -int spl_add_classes(zend_class_entry ** ppce, zval *list TSRMLS_DC); - -#define SPL_CLASS_FE(class_name, function_name, arg_info, flags) \ - PHP_ME( spl_ ## class_name, function_name, arg_info, flags) - -#define SPL_CLASS_FUNCTION(class_name, function_name) \ - PHP_METHOD(spl_ ## class_name, function_name) - -#endif /* PHP_FUNCTIONS_H */ - -/* - * Local Variables: - * c-basic-offset: 4 - * tab-width: 4 - * End: - * vim600: fdm=marker - * vim: noet sw=4 ts=4 - */ diff --git a/ext/spl/tests/.htaccess b/ext/spl/tests/.htaccess deleted file mode 100755 index 5a01a1c16e..0000000000 --- a/ext/spl/tests/.htaccess +++ /dev/null @@ -1,3 +0,0 @@ -<IfModule mod_autoindex.c> - IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t *.php -</IfModule> diff --git a/ext/spl/tests/array.phpt b/ext/spl/tests/array.phpt deleted file mode 100755 index 1474564dc0..0000000000 --- a/ext/spl/tests/array.phpt +++ /dev/null @@ -1,88 +0,0 @@ ---TEST-- -SPL: array ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -$ar = array(0=>0, 1=>1); -$ar = new spl_array($ar); - -var_dump($ar); - -$ar[2] = 2; -var_dump($ar[2]); -var_dump($ar["3"] = 3); - -var_dump(array_merge((array)$ar, array(4=>4, 5=>5))); - -var_dump($ar["a"] = "a"); - -var_dump($ar); -var_dump($ar[0]); -var_dump($ar[6]); -var_dump($ar["b"]); - -unset($ar[1]); -unset($ar["3"]); -unset($ar["a"]); -unset($ar[7]); -unset($ar["c"]); -var_dump($ar); - -echo "Done\n"; -?> ---EXPECTF-- -object(spl_array)#1 (2) { - [0]=> - int(0) - [1]=> - int(1) -} -int(2) -int(3) -array(6) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - &int(2) - [3]=> - &int(3) - [4]=> - int(4) - [5]=> - int(5) -} -string(1) "a" -object(spl_array)#1 (5) { - [0]=> - int(0) - [1]=> - int(1) - [2]=> - &int(2) - [3]=> - &int(3) - ["a"]=> - &string(1) "a" -} -int(0) - -Notice: Undefined offset: 6 in %sarray.php on line %d -NULL - -Notice: Undefined index: b in %sarray.php on line %d -NULL - -Notice: Undefined offset: 7 in %sarray.php on line %d - -Notice: Undefined index: c in %sarray.php on line %d -object(spl_array)#1 (2) { - [0]=> - int(0) - [2]=> - &int(2) -} -Done diff --git a/ext/spl/tests/array_access_001.phpt b/ext/spl/tests/array_access_001.phpt deleted file mode 100755 index 2292749db2..0000000000 --- a/ext/spl/tests/array_access_001.phpt +++ /dev/null @@ -1,163 +0,0 @@ ---TEST-- -SPL: array_access ---SKIPIF-- -<?php - if (!extension_loaded("spl")) die("skip"); - if (!in_array("spl_array_access", spl_classes())) die("skip spl_array_access not present"); -?> ---FILE-- -<?php -class c implements spl_array_access { - - public $a = array('1st', 1, 2=>'3rd', '4th'=>4); - function exists($index) { - echo __METHOD__ . "($index)\n"; - return array_key_exists($index, $this->a); - } - function get($index) { - echo __METHOD__ . "($index)\n"; - return $this->a[$index]; - } - function set($index, $newval) { - echo __METHOD__ . "($index,$newval)\n"; - return $this->a[$index] = $newval; - } - function del($index) { - echo __METHOD__ . "($index)\n"; - unset($this->a[$index]); - } -} - -$obj = new c(); - -var_dump($obj->a); - -var_dump($obj[0]); -var_dump($obj[1]); -var_dump($obj[2]); -var_dump($obj['4th']); -var_dump($obj['5th']); -var_dump($obj[6]); - -echo "WRITE 1\n"; -$obj[1] = 'Changed 1'; -var_dump($obj[1]); -echo "WRITE 2\n"; -$obj['4th'] = 'Changed 4th'; -var_dump($obj['4th']); -echo "WRITE 3\n"; -$obj['5th'] = 'Added 5th'; -var_dump($obj['5th']); -echo "WRITE 4\n"; -$obj[6] = 'Added 6'; -var_dump($obj[6]); - -var_dump($obj[0]); -var_dump($obj[2]); - -$x = $obj[6] = 'changed 6'; -var_dump($obj[6]); -var_dump($x); - -echo "===unset===\n"; -var_dump($obj->a); -unset($obj[2]); -unset($obj['4th']); -unset($obj[7]); -unset($obj['8th']); -var_dump($obj->a); - -print "Done\n"; -?> ---EXPECTF-- -array(4) { - [0]=> - string(3) "1st" - [1]=> - int(1) - [2]=> - string(3) "3rd" - ["4th"]=> - int(4) -} -c::exists(0) -c::get(0) -string(3) "1st" -c::exists(1) -c::get(1) -int(1) -c::exists(2) -c::get(2) -string(3) "3rd" -c::exists(4th) -c::get(4th) -int(4) -c::exists(5th) - -Notice: Undefined index: 5th in %sarray_access_001.php on line %d -NULL -c::exists(6) - -Notice: Undefined index: 6 in %sarray_access_001.php on line %d -NULL -WRITE 1 -c::set(1,Changed 1) -c::exists(1) -c::get(1) -string(9) "Changed 1" -WRITE 2 -c::set(4th,Changed 4th) -c::exists(4th) -c::get(4th) -string(11) "Changed 4th" -WRITE 3 -c::set(5th,Added 5th) -c::exists(5th) -c::get(5th) -string(9) "Added 5th" -WRITE 4 -c::set(6,Added 6) -c::exists(6) -c::get(6) -string(7) "Added 6" -c::exists(0) -c::get(0) -string(3) "1st" -c::exists(2) -c::get(2) -string(3) "3rd" -c::set(6,changed 6) -c::exists(6) -c::get(6) -string(9) "changed 6" -string(9) "changed 6" -===unset=== -array(6) { - [0]=> - string(3) "1st" - [1]=> - string(9) "Changed 1" - [2]=> - string(3) "3rd" - ["4th"]=> - string(11) "Changed 4th" - ["5th"]=> - string(9) "Added 5th" - [6]=> - string(9) "changed 6" -} -c::del(2) -c::del(4th) -c::del(7) -c::del(8th) -array(4) { - [0]=> - string(3) "1st" - [1]=> - string(9) "Changed 1" - ["5th"]=> - string(9) "Added 5th" - [6]=> - string(9) "changed 6" -} -Done diff --git a/ext/spl/tests/array_access_002.phpt b/ext/spl/tests/array_access_002.phpt deleted file mode 100755 index 133e6f3f4a..0000000000 --- a/ext/spl/tests/array_access_002.phpt +++ /dev/null @@ -1,137 +0,0 @@ ---TEST-- -SPL: array_access without return in set() ---SKIPIF-- -<?php - if (!extension_loaded("spl")) die("skip"); - if (!in_array("spl_array_access", spl_classes())) die("skip spl_array_access not present"); -?> ---FILE-- -<?php -class c implements spl_array_access { - - public $a = array('1st', 1, 2=>'3rd', '4th'=>4); - - function exists($index) { - echo __METHOD__ . "($index)\n"; - return array_key_exists($index, $this->a); - } - function get($index) { - echo __METHOD__ . "($index)\n"; - return $this->a[$index]; - } - function set($index, $newval) { - echo __METHOD__ . "($index,$newval)\n"; - /* return */ $this->a[$index] = $newval; - } - function del($index) { - echo __METHOD__ . "($index)\n"; - unset($this->a[$index]); - } -} - -$obj = new c(); - -var_dump($obj->a); - -var_dump($obj[0]); -var_dump($obj[1]); -var_dump($obj[2]); -var_dump($obj['4th']); -var_dump($obj['5th']); -var_dump($obj[6]); - -echo "WRITE 1\n"; -$obj[1] = 'Changed 1'; -var_dump($obj[1]); -echo "WRITE 2\n"; -$obj['4th'] = 'Changed 4th'; -var_dump($obj['4th']); -echo "WRITE 3\n"; -$obj['5th'] = 'Added 5th'; -var_dump($obj['5th']); -echo "WRITE 4\n"; -$obj[6] = 'Added 6'; -var_dump($obj[6]); - -var_dump($obj[0]); -var_dump($obj[2]); - -$x = $obj[6] = 'changed 6'; -var_dump($obj[6]); -var_dump($x); - -print "Done\n"; -?> ---EXPECTF-- -array(4) { - [0]=> - string(3) "1st" - [1]=> - int(1) - [2]=> - string(3) "3rd" - ["4th"]=> - int(4) -} -c::exists(0) -c::get(0) -string(3) "1st" -c::exists(1) -c::get(1) -int(1) -c::exists(2) -c::get(2) -string(3) "3rd" -c::exists(4th) -c::get(4th) -int(4) -c::exists(5th) - -Notice: Undefined index: 5th in %sarray_access_002.php on line %d -NULL -c::exists(6) - -Notice: Undefined index: 6 in %sarray_access_002.php on line %d -NULL -WRITE 1 -c::set(1,Changed 1) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(1) -c::get(1) -string(9) "Changed 1" -WRITE 2 -c::set(4th,Changed 4th) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(4th) -c::get(4th) -string(11) "Changed 4th" -WRITE 3 -c::set(5th,Added 5th) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(5th) -c::get(5th) -string(9) "Added 5th" -WRITE 4 -c::set(6,Added 6) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(6) -c::get(6) -string(7) "Added 6" -c::exists(0) -c::get(0) -string(3) "1st" -c::exists(2) -c::get(2) -string(3) "3rd" -c::set(6,changed 6) - -Warning: Method c::set() did not return a value, using input value in %sarray_access_002.php on line %d -c::exists(6) -c::get(6) -string(9) "changed 6" -string(9) "changed 6" -Done diff --git a/ext/spl/tests/array_iterator.phpt b/ext/spl/tests/array_iterator.phpt deleted file mode 100755 index 751e623d1c..0000000000 --- a/ext/spl/tests/array_iterator.phpt +++ /dev/null @@ -1,138 +0,0 @@ ---TEST-- -SPL: spl_array_iterator ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -echo "==Normal==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array($arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==0 && $bk==0) { - $arr[0] = "modify"; - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "==UseRef==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array(&$arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "==Modify==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array(&$arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==0 && $bk==0) { - $arr[0] = "modify"; - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "==Delete==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array(&$arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==1 && $bk==1) { - unset($arr[1]); - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "==Change==\n"; - -$arr = array(0=>0, 1=>1, 2=>2); -$obj = new spl_array(&$arr); - -foreach($obj as $ak=>$av) { - foreach($obj as $bk=>$bv) { - if ($ak==1 && $bk==1) { - $arr = NULL; - } - echo "$ak=>$av - $bk=>$bv\n"; - } -} - -echo "Done\n"; -?> ---EXPECTF-- -==Normal== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>0 -1=>1 - 1=>1 -1=>1 - 2=>2 -2=>2 - 0=>0 -2=>2 - 1=>1 -2=>2 - 2=>2 -==UseRef== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>0 -1=>1 - 1=>1 -1=>1 - 2=>2 -2=>2 - 0=>0 -2=>2 - 1=>1 -2=>2 - 2=>2 -==Modify== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>modify -1=>1 - 1=>1 -1=>1 - 2=>2 -2=>2 - 0=>modify -2=>2 - 1=>1 -2=>2 - 2=>2 -==Delete== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>0 -1=>1 - 1=>1 - -Notice: spl_array_it::next(): Array was modified outside object and internal position is no longer valid in %sarray_iterator.php on line %d -1=>1 - 0=>0 -1=>1 - 2=>2 - -Notice: spl_array_it::next(): Array was modified outside object and internal position is no longer valid in %sarray_iterator.php on line %d -0=>0 - 0=>0 -0=>0 - 2=>2 -2=>2 - 0=>0 -2=>2 - 2=>2 -==Change== -0=>0 - 0=>0 -0=>0 - 1=>1 -0=>0 - 2=>2 -1=>1 - 0=>0 -1=>1 - 1=>1 - -Notice: spl_array_it::next(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d - -Notice: spl_array_it::hasMore(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d - -Notice: spl_array_it::next(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d - -Notice: spl_array_it::hasMore(): Array was modified outside object and is no longer an array in %sarray_iterator.php on line %d -Done diff --git a/ext/spl/tests/array_read.phpt b/ext/spl/tests/array_read.phpt deleted file mode 100755 index 032373d52d..0000000000 --- a/ext/spl/tests/array_read.phpt +++ /dev/null @@ -1,208 +0,0 @@ ---TEST-- -SPL: array_read ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -echo "EXTERNAL\n"; - -$a = array('1st', 1, 2=>'3rd', '4th'=>4); -var_dump($a); - -class external implements spl_array_read { - - function exists($index) { - echo __METHOD__ . "($index)\n"; - return array_key_exists($index, $GLOBALS['a']); - } - - function get($index) { - echo __METHOD__ . "($index)\n"; - return $GLOBALS['a'][$index]; - } -} - -$obj = new external(); - -var_dump($obj->get(0)); -var_dump($obj->get(1)); -var_dump($obj->get(2)); -var_dump($obj->get('4th')); -var_dump($obj->get('5th')); -var_dump($obj->get(6)); - -var_dump($obj[0]); -var_dump($obj[1]); -var_dump($obj[2]); -var_dump($obj['4th']); -var_dump($obj['5th']); -var_dump($obj[6]); - -$out = $obj[0]; echo "$out\n"; -$out = $obj[1]; echo "$out\n"; -$out = $obj[2]; echo "$out\n"; -$out = $obj['4th']; echo "$out\n"; - -echo "INTERNAL\n"; - -class internal implements spl_array_read { - - public $a = array('1st', 1, 2=>'3rd', '4th'=>4); - - function exists($index) { - echo __METHOD__ . "($index)\n"; - return array_key_exists($index, $GLOBALS['a']); - } - - function get($index) { - echo __METHOD__ . "($index)\n"; - return $GLOBALS['a'][$index]; - } -} - -$obj = new internal(); - -var_dump($obj->a); - -var_dump($obj->get(0)); -var_dump($obj->get(1)); -var_dump($obj->get(2)); -var_dump($obj->get('4th')); -var_dump($obj->get('5th')); -var_dump($obj->get(6)); - -var_dump($obj[0]); -var_dump($obj[1]); -var_dump($obj[2]); -var_dump($obj['4th']); -var_dump($obj['5th']); -var_dump($obj[6]); - -$out = $obj[0]; echo "$out\n"; -$out = $obj[1]; echo "$out\n"; -$out = $obj[2]; echo "$out\n"; -$out = $obj['4th']; echo "$out\n"; - -print "Done\n"; -?> ---EXPECTF-- -EXTERNAL -array(4) { - [0]=> - string(3) "1st" - [1]=> - int(1) - [2]=> - string(3) "3rd" - ["4th"]=> - int(4) -} -external::get(0) -string(3) "1st" -external::get(1) -int(1) -external::get(2) -string(3) "3rd" -external::get(4th) -int(4) -external::get(5th) - -Notice: Undefined index: 5th in %s on line %d -NULL -external::get(6) - -Notice: Undefined offset: 6 in %s on line %d -NULL -external::exists(0) -external::get(0) -string(3) "1st" -external::exists(1) -external::get(1) -int(1) -external::exists(2) -external::get(2) -string(3) "3rd" -external::exists(4th) -external::get(4th) -int(4) -external::exists(5th) - -Notice: Undefined index: 5th in %s on line %d -NULL -external::exists(6) - -Notice: Undefined index: 6 in %s on line %d -NULL -external::exists(0) -external::get(0) -1st -external::exists(1) -external::get(1) -1 -external::exists(2) -external::get(2) -3rd -external::exists(4th) -external::get(4th) -4 -INTERNAL -array(4) { - [0]=> - string(3) "1st" - [1]=> - int(1) - [2]=> - string(3) "3rd" - ["4th"]=> - int(4) -} -internal::get(0) -string(3) "1st" -internal::get(1) -int(1) -internal::get(2) -string(3) "3rd" -internal::get(4th) -int(4) -internal::get(5th) - -Notice: Undefined index: 5th in %s on line %d -NULL -internal::get(6) - -Notice: Undefined offset: 6 in %s on line %d -NULL -internal::exists(0) -internal::get(0) -string(3) "1st" -internal::exists(1) -internal::get(1) -int(1) -internal::exists(2) -internal::get(2) -string(3) "3rd" -internal::exists(4th) -internal::get(4th) -int(4) -internal::exists(5th) - -Notice: Undefined index: 5th in %s on line %d -NULL -internal::exists(6) - -Notice: Undefined index: 6 in %s on line %d -NULL -internal::exists(0) -internal::get(0) -1st -internal::exists(1) -internal::get(1) -1 -internal::exists(2) -internal::get(2) -3rd -internal::exists(4th) -internal::get(4th) -4 -Done diff --git a/ext/spl/tests/foreach.phpt b/ext/spl/tests/foreach.phpt deleted file mode 100755 index 0a4cd91fb7..0000000000 --- a/ext/spl/tests/foreach.phpt +++ /dev/null @@ -1,202 +0,0 @@ ---TEST-- -SPL: foreach and iterator ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php -class c_iter implements spl_forward_assoc { - - private $obj; - private $num = 0; - - function __construct($obj) { - echo __METHOD__ . "\n"; - $this->num = 0; - $this->obj = $obj; - } - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - $more = $this->num < $this->obj->max; - echo __METHOD__ . ' = ' .($more ? 'true' : 'false') . "\n"; - return $more; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -class c implements spl_iterator { - - public $max = 3; - - function newIterator() { - echo __METHOD__ . "\n"; - return new c_iter($this); - } -} - -$t = new c(); - -for ($iter = $t->newIterator(); $iter->hasMore(); $iter->next()) { - echo $iter->current() . "\n"; -} - -$a = array(0,1,2); -foreach($a as $v) { - echo "array:$v\n"; -} - -foreach($t as $v) { - echo "object:$v\n"; -} - -foreach($t as $v) { - foreach($t as $w) { - echo "double:$v:$w\n"; - } -} - -foreach($t as $i => $v) { - echo "object:$i=>$v\n"; -} - -print "Done\n"; -?> ---EXPECT-- -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -0 -c_iter::next -c_iter::hasMore = true -c_iter::current -1 -c_iter::next -c_iter::hasMore = true -c_iter::current -2 -c_iter::next -c_iter::hasMore = false -array:0 -array:1 -array:2 -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -object:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -object:1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -object:2 -c_iter::next -c_iter::hasMore = false -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -double:0:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:0:1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:0:2 -c_iter::next -c_iter::hasMore = false -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -double:1:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:1:1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:1:2 -c_iter::next -c_iter::hasMore = false -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -double:2:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:2:1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -double:2:2 -c_iter::next -c_iter::hasMore = false -c_iter::next -c_iter::hasMore = false -c::newIterator -c_iter::__construct -c_iter::hasMore = true -c_iter::current -c_iter::key -object:1st=>0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -object:2nd=>1 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -object:3rd=>2 -c_iter::next -c_iter::hasMore = false -Done diff --git a/ext/spl/tests/foreach_break.phpt b/ext/spl/tests/foreach_break.phpt deleted file mode 100755 index 184b762b84..0000000000 --- a/ext/spl/tests/foreach_break.phpt +++ /dev/null @@ -1,90 +0,0 @@ ---TEST-- -SPL: foreach and break ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php -class c_iter implements spl_forward_assoc { - - private $obj; - private $num = 0; - - function __construct($obj) { - $this->obj = $obj; - } - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - $more = $this->num < $this->obj->max; - echo __METHOD__ . ' = ' .($more ? 'true' : 'false') . "\n"; - return $more; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -class c implements spl_iterator { - - public $max = 3; - - function newIterator() { - echo __METHOD__ . "\n"; - return new c_iter($this); - } -} - -$t = new c(); - -foreach($t as $v) { - foreach($t as $w) { - echo "double:$v:$w\n"; - break; - } -} - -print "Done\n"; -?> ---EXPECT-- -c::newIterator -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::hasMore = true -c_iter::current -c_iter::key -double:0:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::hasMore = true -c_iter::current -c_iter::key -double:1:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -c_iter::key -c::newIterator -c_iter::hasMore = true -c_iter::current -c_iter::key -double:2:0 -c_iter::next -c_iter::hasMore = false -Done diff --git a/ext/spl/tests/foreach_continue.phpt b/ext/spl/tests/foreach_continue.phpt deleted file mode 100755 index 289f67e0a6..0000000000 --- a/ext/spl/tests/foreach_continue.phpt +++ /dev/null @@ -1,102 +0,0 @@ ---TEST-- -SPL: foreach and break ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php -class c_iter implements spl_forward { - - private $obj; - private $num = 0; - - function __construct($obj) { - $this->obj = $obj; - } - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - $more = $this->num < $this->obj->max; - echo __METHOD__ . ' = ' .($more ? 'true' : 'false') . "\n"; - return $more; - } -} - -class c implements spl_iterator { - - public $max = 4; - - function newIterator() { - echo __METHOD__ . "\n"; - return new c_iter($this); - } -} - -$t = new c(); - -foreach($t as $v) { - if ($v == 0) { - echo "continue outer\n"; - continue; - } - foreach($t as $w) { - if ($w == 1) { - echo "continue inner\n"; - continue; - } - if ($w == 2) { - echo "break inner\n"; - break; - } - echo "double:$v:$w\n"; - } - if ($v == 2) { - echo "break outer\n"; - break; - } -} - -print "Done\n"; -?> ---EXPECT-- -c::newIterator -c_iter::hasMore = true -c_iter::current -continue outer -c_iter::next -c_iter::hasMore = true -c_iter::current -c::newIterator -c_iter::hasMore = true -c_iter::current -double:1:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -continue inner -c_iter::next -c_iter::hasMore = true -c_iter::current -break inner -c_iter::next -c_iter::hasMore = true -c_iter::current -c::newIterator -c_iter::hasMore = true -c_iter::current -double:2:0 -c_iter::next -c_iter::hasMore = true -c_iter::current -continue inner -c_iter::next -c_iter::hasMore = true -c_iter::current -break inner -break outer -Done diff --git a/ext/spl/tests/foreach_non_spl.phpt b/ext/spl/tests/foreach_non_spl.phpt deleted file mode 100755 index 71a7cb7f4d..0000000000 --- a/ext/spl/tests/foreach_non_spl.phpt +++ /dev/null @@ -1,61 +0,0 @@ ---TEST-- -SPL: foreach non spl classes ---SKIPIF-- -<?php if (0 && !extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php - -echo "1st try\n"; - -class c1 {} - -$obj = new c1(); - -foreach($obj as $w) { - echo "object:$w\n"; -} - -echo "2nd try\n"; - -class c2 { - - public $max = 3; - public $num = 0; - - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - echo __METHOD__ . "\n"; - return $this->num < $this->max; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -$obj = new c2(); - -foreach($obj as $v => $w) { - echo "object:$v=>$w\n"; -} - -print "Done\n"; -?> ---EXPECTF-- -1st try -2nd try -object:max=>3 -object:num=>0 -Done diff --git a/ext/spl/tests/forward.phpt b/ext/spl/tests/forward.phpt deleted file mode 100755 index 8a14a52fe8..0000000000 --- a/ext/spl/tests/forward.phpt +++ /dev/null @@ -1,138 +0,0 @@ ---TEST-- -SPL: forward ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php -class c implements spl_forward_assoc { - - public $max = 3; - public $num = 0; - - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - echo __METHOD__ . "\n"; - return $this->num < $this->max; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -$i = new c(); - -$implements = class_implements($i); -asort($implements); -$c_info = array(get_class($i) => array('inheits' => class_parents($i), 'implements' => $implements)); -print_r($c_info); -$methods = get_class_methods("spl_forward_assoc"); -sort($methods); -print_r($methods); -$methods = get_class_methods($i); -sort($methods); -print_r($methods); - - -echo "1st try\n"; -foreach($i as $w) { - echo "object:$w\n"; -} - -echo "2nd try\n"; - -foreach($i as $v => $w) { - echo "object:$v=>$w\n"; -} - -echo "3rd try\n"; -$i->num = 0; - -foreach($i as $v => $w) { - echo "object:$v=>$w\n"; -} - -print "Done\n"; -?> ---EXPECT-- -Array -( - [c] => Array - ( - [inheits] => Array - ( - ) - - [implements] => Array - ( - [spl_assoc] => spl_assoc - [spl_forward] => spl_forward - [spl_forward_assoc] => spl_forward_assoc - ) - - ) - -) -Array -( - [0] => current - [1] => hasMore - [2] => key - [3] => next -) -Array -( - [0] => current - [1] => hasMore - [2] => key - [3] => next -) -1st try -c::hasMore -c::current -c::key -object:0 -c::next -c::hasMore -c::current -c::key -object:1 -c::next -c::hasMore -c::current -c::key -object:2 -c::next -c::hasMore -2nd try -c::hasMore -3rd try -c::hasMore -c::current -c::key -object:1st=>0 -c::next -c::hasMore -c::current -c::key -object:2nd=>1 -c::next -c::hasMore -c::current -c::key -object:3rd=>2 -c::next -c::hasMore -Done diff --git a/ext/spl/tests/sequence.phpt b/ext/spl/tests/sequence.phpt deleted file mode 100755 index 34ea7fd8d5..0000000000 --- a/ext/spl/tests/sequence.phpt +++ /dev/null @@ -1,143 +0,0 @@ ---TEST-- -SPL: sequence ---SKIPIF-- -<?php if (!extension_loaded("spl")) print "skip"; ?> ---FILE-- -<?php -class c implements spl_iterator { - - public $max = 3; - - function newIterator() { - echo __METHOD__ . "\n"; - return new c_iter($this); - } -} - -class c_iter implements spl_sequence_assoc { - - private $obj; - private $num = 0; - - function __construct($obj) { - $this->obj = $obj; - } - function rewind() { - echo __METHOD__ . "\n"; - $this->num = 0; - } - function current() { - echo __METHOD__ . "\n"; - return $this->num; - } - function next() { - echo __METHOD__ . "\n"; - $this->num++; - } - function hasMore() { - echo __METHOD__ . "\n"; - return $this->num < $this->obj->max; - } - function key() { - echo __METHOD__ . "\n"; - switch($this->num) { - case 0: return "1st"; - case 1: return "2nd"; - case 2: return "3rd"; - default: return "???"; - } - } -} - -$t = new c(); -$i = $t->newIterator(); - -$implements_t = class_implements($t); -asort($implements_t); -$implements_i = class_implements($i); -asort($implements_i); - -$c_info = array(get_class($t) => array('inheits' => class_parents($t), 'implements' => $implements_t), - get_class($i) => array('inheits' => class_parents($i), 'implements' => $implements_i)); -print_r($c_info); - -foreach($i as $w) { - echo "object:$w\n"; -} - -foreach($i as $v => $w) { - echo "object:$v=>$w\n"; -} - -print "Done\n"; -?> ---EXPECT-- -c::newIterator -Array -( - [c] => Array - ( - [inheits] => Array - ( - ) - - [implements] => Array - ( - [spl_iterator] => spl_iterator - ) - - ) - - [c_iter] => Array - ( - [inheits] => Array - ( - ) - - [implements] => Array - ( - [spl_assoc] => spl_assoc - [spl_forward] => spl_forward - [spl_forward_assoc] => spl_forward_assoc - [spl_sequence] => spl_sequence - [spl_sequence_assoc] => spl_sequence_assoc - ) - - ) - -) -c_iter::rewind -c_iter::hasMore -c_iter::current -c_iter::key -object:0 -c_iter::next -c_iter::hasMore -c_iter::current -c_iter::key -object:1 -c_iter::next -c_iter::hasMore -c_iter::current -c_iter::key -object:2 -c_iter::next -c_iter::hasMore -c_iter::rewind -c_iter::hasMore -c_iter::current -c_iter::key -object:1st=>0 -c_iter::next -c_iter::hasMore -c_iter::current -c_iter::key -object:2nd=>1 -c_iter::next -c_iter::hasMore -c_iter::current -c_iter::key -object:3rd=>2 -c_iter::next -c_iter::hasMore -Done
\ No newline at end of file diff --git a/ext/tidy/CREDITS b/ext/tidy/CREDITS deleted file mode 100644 index 1c77b2ff3b..0000000000 --- a/ext/tidy/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -tidy -John Coggeshall, Ilia Alshanetsky diff --git a/ext/tidy/README b/ext/tidy/README deleted file mode 100644 index 2d4e015176..0000000000 --- a/ext/tidy/README +++ /dev/null @@ -1,122 +0,0 @@ - -README FOR ext/tidy by John Coggeshall <john@php.net> - -Tidy Version: 0.7b - -Tidy is an extension based on Libtidy (http://tidy.sf.net/) and allows a PHP developer -to clean, repair, and traverse HTML, XHTML, and XML documents -- including ones with -embedded scripting languages such as PHP or ASP within them using OO constructs. - ---------------------------------------------------------------------------------------- -!! Important Note !! ---------------------------------------------------------------------------------------- -At this time libtidy has a small memory leak inside the ParseConfigFileEnc() function -used to load configuration from a file. If you intend to use this functionality apply -the "libtidy.txt" patch (cd tidy/src/; patch -p0 < libtidy.txt) to libtidy sources and -then recompile libtidy. ---------------------------------------------------------------------------------------- - -The Tidy extension has two separate APIs, one for general parsing, cleaning, and -repairing and another for document traversal. The general API is provided below: - - tidy_create() Reinitialize the tidy engine - tidy_parse_file($file) Parse the document stored in $file - tidy_parse_string($str) Parse the string stored in $str - - tidy_clean_repair() Clean and repair the document - tidy_diagnose() Diagnose a parsed document - - tidy_setopt($opt, $val) Set a configuration option $opt to $val - tidy_getopt($opt) Retrieve a configuration option - - ** note: $opt is a string representing the option. Although no formal - documentation yet exists for PHP, you can find a description of many - of them at http://www.w3.org/People/Raggett/tidy/ and a list of supported - options in the phpinfo(); output** - - tidy_get_output() Return the cleaned tidy HTML as a string - tidy_get_error_buffer() Return a log of the errors and warnings - returned by tidy - - tidy_get_release() Return the Libtidy release date - tidy_get_status() Return the status of the document - tidy_get_html_ver() Return the major HTML version detected for - the document; - - tidy_is_xhtml() Determines if the document is XHTML - tidy_is_xml() Determines if the document is a generic XML - - tidy_error_count() Returns the number of errors in the document - tidy_warning_count() Returns the number of warnings in the document - tidy_access_count() Returns the number of accessibility-related - warnings in the document. - tidy_config_count() Returns the number of configuration errors found - - tidy_load_config($file) Loads the specified configuration file - tidY_load_config_enc($file, - $enc) Loads the specified config file using the specified - character encoding - tidy_set_encoding($enc) Sets the current character encoding for the document - tidy_save_config($file) Saves the current config to $file - - -Beyond these general-purpose API functions, Tidy also supports the following -functions which are used to retrieve an object for document traversal: - - tidy_get_root() Returns an object starting at the root of the - document - tidy_get_head() Returns an object starting at the <HEAD> tag - tidy_get_html() Returns an object starting at the <HTML> tag - tidy_get_body() Returns an object starting at the <BODY> tag - -All Navigation of the specified document is done via the PHP5 object constructs. -There are two types of objects which Tidy can create. The first is TidyNode, which -represents HTML Tags, Text, and more (see the TidyNode_Type Constants). The second -is TidyAttr, which represents an attribute within an HTML tag (TidyNode). The -functionality of these objects is represented by the following schema: - -class TidyNode { - - public $name; // name of node (i.e. HEAD) - public $value; // value of node (everything between tags) - public $type; // type of node (text, php, asp, etc.) - public $id; // id of node (i.e. TIDY_TAG_HEAD) - - public function attributes(); // an array of attributes (see TidyAttr) - public function children(); // an array of child nodes - - function has_siblings(); // any sibling nodes? - function has_children(); // any child nodes? - - function is_comment(); // is node a comment? - function is_xhtml(); // is document XHTML? - function is_xml(); // is document generic XML (not HTML/XHTML) - function is_text(); // is node text? - function is_html(); // is node an HTML tag? - - function is_jste(); // is jste block? - function is_asp(); // is Microsoft ASP block? - function is_php(); // is PHP block? - - function next(); // returns next node - function prev(); // returns prev node - - /* Searches for a particular attribute in the current node based - on node ID. If found returns a TidyAttr object for it */ - function get_attr($attr_id); - - /* -} - -class TidyAttr { - - public $name; // attribute name i.e. HREF - public $value; // attribute value - public $id; // attribute id i.e. TIDY_ATTR_HREF - -} - -Examples of using these objects to navigate the tree can be found in the examples/ -directory (I suggest looking at urlgrab.php and dumpit.php) - -E-mail thoughts, suggestions, patches, etc. to <john@php.net> diff --git a/ext/tidy/TODO b/ext/tidy/TODO deleted file mode 100644 index 699c207dcb..0000000000 --- a/ext/tidy/TODO +++ /dev/null @@ -1,3 +0,0 @@ -TODO - - - Implement get_nodes() method diff --git a/ext/tidy/config.m4 b/ext/tidy/config.m4 deleted file mode 100644 index 069b3ee6b4..0000000000 --- a/ext/tidy/config.m4 +++ /dev/null @@ -1,35 +0,0 @@ -dnl -dnl $Id$ -dnl - -PHP_ARG_WITH(tidy,for TIDY support, -[ --with-tidy[=DIR] Include TIDY support]) - -if test "$PHP_TIDY" != "no"; then - PHP_NEW_EXTENSION(tidy, tidy.c, $ext_shared) - if test "$PHP_TIDY" != "yes"; then - TIDY_SEARCH_DIRS=$PHP_TIDY - else - TIDY_SEARCH_DIRS="/usr/local /usr" - fi - for i in $TIDY_SEARCH_DIRS; do - if test -f $i/include/tidy/tidy.h; then - TIDY_DIR=$i - TIDY_INCDIR=$i/include/tidy - elif test -f $i/include/tidy.h; then - TIDY_DIR=$i - TIDY_INCDIR=$i/include - fi - done - - if test -z "$TIDY_DIR"; then - AC_MSG_ERROR(Cannot find libtidy) - fi - - TIDY_LIBDIR=$TIDY_DIR/lib - - AC_DEFINE(HAVE_TIDY,1,[ ]) - PHP_SUBST(TIDY_SHARED_LIBADD) - PHP_ADD_LIBRARY_WITH_PATH(tidy, $TIDY_LIBDIR, TIDY_SHARED_LIBADD) - PHP_ADD_INCLUDE($TIDY_INCDIR) -fi diff --git a/ext/tidy/examples/cleanhtml.php b/ext/tidy/examples/cleanhtml.php deleted file mode 100644 index 9d054cda4f..0000000000 --- a/ext/tidy/examples/cleanhtml.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - - /* - * cleanhtml.php - * - * A simple script to clean and repair HTML,XHTML,PHP,ASP,etc. documents - * if no file is provided, it reads from standard input. - * - * By: John Coggeshall <john@php.net> - * - * Usage: php cleanhtml.php [filename] - * - */ - - if(!isset($_SERVER['argv'][1])) { - $data = file_get_contents("php://stdin"); - tidy_parse_string($data); - } else { - tidy_parse_file($_SERVER['argv'][1]); - } - - tidy_clean_repair(); - - if(tidy_warning_count() || - tidy_error_count()) { - - echo "\n\nThe following errors or warnings occured:\n"; - echo tidy_get_error_buffer(); - echo "\n"; - } - - echo tidy_get_output(); - -?> - - - -
\ No newline at end of file diff --git a/ext/tidy/examples/dumpit.php b/ext/tidy/examples/dumpit.php deleted file mode 100644 index e77b7b9323..0000000000 --- a/ext/tidy/examples/dumpit.php +++ /dev/null @@ -1,93 +0,0 @@ -<?php - /* - * dumpit.php - * - * a command-line script which dumps the given HTML, PHP, ASP, XHTML, etc. - * file as it is represented in the document model. - * - * By: John Coggeshall <john@php.net> - * - * Usage; php dumpit.php <filename> - */ - - tidy_parse_file($_SERVER['argv'][1]); - - /* Optionally you can do this here if you want to fix up the document */ - - /* tidy_clean_repair(); */ - - $tree = tidy_get_root(); - dump_tree($tree); - echo "\n"; - - function node_type($type) { - - switch($type) { - - case TIDY_NODETYPE_ROOT: return "Root Node"; - case TIDY_NODETYPE_DOCTYPE: return "DocType Node"; - case TIDY_NODETYPE_COMMENT: return "Comment Node"; - case TIDY_NODETYPE_PROCINS: return "ProcIns Node"; - case TIDY_NODETYPE_TEXT: return "Text Node"; - case TIDY_NODETYPE_START: return "Start Node"; - case TIDY_NODETYPE_END: return "End Node"; - case TIDY_NODETYPE_STARTEND: return "Start/End Node"; - case TIDY_NODETYPE_CDATA: return "CDATA Node"; - case TIDY_NODETYPE_SECTION: return "Section Node"; - case TIDY_NODETYPE_ASP: return "ASP Source Code Node"; - case TIDY_NODETYPE_PHP: return "PHP Source Code Node"; - case TIDY_NODETYPE_JSTE: return "JSTE Source Code"; - case TIDY_NODETYPE_XMLDECL: return "XML Declaration Node"; - default: return "Unknown Node"; - } - } - - function do_leaf($string, $indent) { - for($i = 0; $i < $indent; $i++) { - echo " "; - } - echo $string; - } - - function dump_tree($node, $indent = 0) { - if($node) { - /* Put something there if the node name is empty */ - $nodename = trim(strtoupper($node->name)); - $nodename = (empty($nodename)) ? "[EMPTY]" : $nodename; - - /* Generate the Node, and a pretty name for it */ - do_leaf(" + $nodename (".node_type($node->type).")\n", $indent); - - /* Check to see if this node is a text node. Text nodes are - generated by start/end tags and contain the text in between. - i.e. <B>foo</B> will create a text node with $node->value - equal to 'foo' */ - if($node->type == TIDY_NODETYPE_TEXT) { - do_leaf(" |\n", $indent); - do_leaf(" +---- Value: '{$node->value}'\n", $indent); - } - - /* Any attributes on this node? */ - if(count($node->attributes())) { - do_leaf(" |\n", $indent); - do_leaf(" +---- Attributes\n", $indent); - - /* Cycle through the attributes and display them and their values. */ - foreach($node->attributes() as $attrib) { - do_leaf(" +--{$attrib->name}\n", $indent); - do_leaf(" | +-- Value: {$attrib->value}\n", $indent); - } - } - - /* Recurse along the children to generate the remaining nodes */ - if($node->has_children()) { - foreach($node->children() as $child) { - dump_tree($child, $indent + 3); - } - } - } - } - - echo tidy_get_output(); - -?>
\ No newline at end of file diff --git a/ext/tidy/examples/urlgrab.php b/ext/tidy/examples/urlgrab.php deleted file mode 100644 index 7896792ea5..0000000000 --- a/ext/tidy/examples/urlgrab.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php - - /* - * urlgrab.php - * - * A simple command-line utility to extract all of the URLS contained - * within <A HREF> tags from a document. - * - * By: John Coggeshall <john@php.net> - * - * Usage: php urlgrab.php <file> - * - */ - - /* Parse the document */ - tidy_parse_file($_SERVER['argv'][1]); - - /* Fix up the document */ - tidy_clean_repair(); - - /* Get an object representing everything from the <HTML> tag in */ - $html = tidy_get_html(); - - /* Traverse the document tree */ - print_r(get_links($html)); - - function get_links($node) { - $urls = array(); - - /* Check to see if we are on an <A> tag or not */ - if($node->id == TIDY_TAG_A) { - /* If we are, find the HREF attribute */ - $attrib = $node->get_attr(TIDY_ATTR_HREF); - if($attrib) { - /* Add the value of the HREF attrib to $urls */ - $urls[] = $attrib->value; - } - - } - - /* Are there any children? */ - if($node->has_children()) { - - /* Traverse down each child recursively */ - foreach($node->children() as $child) { - - /* Append the results from recursion to $urls */ - foreach(get_links($child) as $url) { - - $urls[] = $url; - - } - - } - } - - return $urls; - } - -?>
\ No newline at end of file diff --git a/ext/tidy/libtidy.txt b/ext/tidy/libtidy.txt deleted file mode 100644 index 53185d9fc2..0000000000 --- a/ext/tidy/libtidy.txt +++ /dev/null @@ -1,12 +0,0 @@ ---- config.c Mon Jun 9 04:07:55 2003 -+++ config.c Sun Sep 21 16:13:04 2003 -@@ -719,7 +719,8 @@ - } - - fclose( fin ); -- MemFree( cfg->cfgIn ); -+ MemFree( cfg->cfgIn->source.sourceData ); -+ MemFree( cfg->cfgIn ); - cfg->cfgIn = NULL; - } - diff --git a/ext/tidy/package.xml b/ext/tidy/package.xml deleted file mode 100644 index b7f6e26d9b..0000000000 --- a/ext/tidy/package.xml +++ /dev/null @@ -1,74 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!DOCTYPE package SYSTEM "../pear/package.dtd"> -<package> - <name>tidy</name> - <summary>Tidy HTML Repairing and Parsing</summary> - <maintainers> - <maintainer> - <user>john</user> - <name>John Coggeshall</name> - <email>john@php.net</email> - <role>lead</role> - </maintainer> - <maintainer> - <user>iliaa</user> - <name>Ilia Alshanetsky</name> - <email>ilia@php.net</email> - <role>lead</role> - </maintainer> - </maintainers> - <description> -Tidy is a binding for the Tidy HTML clean and repair utility which -allows you to not only clean and otherwise manipluate HTML documents, -but also traverse the document tree using the Zend Engine 2 OO semantics. - </description> - <license>PHP</license> - <release> - <state>beta</state> - <version>0.7</version> - <date>2003-05-07</date> - <notes> - The tidy extension now works in PHP4 for most tasks, only the parsing - abilities of the extension are not available (ZE2 only). The OO portions - of the extension have been completely re-written and are now stable and - work quite well. - - The way all tidy functions work has also changed slightly. Instead of - calling tidy_create() to create a tidy resource, the tidy resource is - stored internally and used as needed. Thus, all tidy functions no longer - need the initial $tidy parameter to function. If you'd like to reset - tidy to an initial state, you can still call tidy_create(). This change - was done to make tidy faster per-request. - </notes> - <configureoptions> - <configureoption name="with-tidy" default="autodetect" prompt="Tidy library installation dir?"/> - </configureoptions> - <filelist> - <file role="src" name="config.m4"/> - <file role="src" name="tidy.c"/> - <file role="src" name="php_tidy.h"/> - - <file role="doc" name="CREDITS"/> - <file role="doc" name="README"/> - <file role="doc" name="TODO"/> - <file role="doc" name="examples/cleanhtml.php"/> - <file role="doc" name="examples/dumpit.php"/> - <file role="doc" name="examples/urlgrab.php"/> - - <file role="test" name="tests/001.phpt"/> - <file role="test" name="tests/002.phpt"/> - <file role="test" name="tests/003.phpt"/> - <file role="test" name="tests/004.phpt"/> - <file role="test" name="tests/005.phpt"/> - <file role="test" name="tests/005.html"/> - <file role="test" name="tests/006.phpt"/> - <file role="test" name="tests/007.phpt"/> - </filelist> - <deps> - <dep type="php" rel="ge">5.0.0</dep> - </deps> - </release> -</package> -<!-- -vim:et:ts=1:sw=1 ---> diff --git a/ext/tidy/php_tidy.h b/ext/tidy/php_tidy.h deleted file mode 100644 index e170d37086..0000000000 --- a/ext/tidy/php_tidy.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.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: John Coggeshall <john@php.net> | - | Ilia Alshanetsky <ilia@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifndef PHP_TIDY_H -#define PHP_TIDY_H - -extern zend_module_entry tidy_module_entry; -#define phpext_tidy_ptr &tidy_module_entry - -#ifdef PHP_WIN32 -#define PHP_TIDY_API __declspec(dllexport) -#else -#define PHP_TIDY_API -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -#include "tidyenum.h" -#include "tidy.h" -#include "buffio.h" - -#ifdef ZTS -#define TG(v) TSRMG(tidy_globals_id, zend_tidy_globals *, v) -#else -#define TG(v) (tidy_globals.v) -#endif - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -#define TIDY_RV_FALSE(__t) __t->type = IS_BOOL; __t->value.lval = FALSE -#define TIDY_RV_TRUE(__t) __t->type = IS_BOOL; __t->value.lval = TRUE - -#define REMOVE_NEWLINE(_z) _z->value.str.val[_z->value.str.len-1] = '\0'; _z->value.str.len--; - -#define TIDY_TAG_CONST(tag) REGISTER_LONG_CONSTANT("TIDY_TAG_" #tag, TidyTag_##tag, CONST_CS | CONST_PERSISTENT) -#define TIDY_ATTR_CONST(attr) REGISTER_LONG_CONSTANT("TIDY_ATTR_" #attr, TidyAttr_##attr, CONST_CS | CONST_PERSISTENT) -#define TIDY_NODE_CONST(name, type) REGISTER_LONG_CONSTANT("TIDY_NODETYPE_" #name, TidyNode_##type, CONST_CS | CONST_PERSISTENT) - -#define PHP_ME_MAPPING(name, func_name, arg_types) \ - ZEND_NAMED_FE(name, ZEND_FN(func_name), arg_types) - -#define PHP_NODE_METHOD(name) PHP_FUNCTION(tnm_ ##name) -#define PHP_ATTR_METHOD(name) PHP_FUNCTION(tam_ ##name) -#define PHP_NODE_ME(name, param) PHP_ME_MAPPING(name, tnm_ ##name, param) -#define PHP_ATTR_ME(name, param) PHP_ME_MAPPING(name, tam_ ##name, param) - - - -#define TIDY_REGISTER_OBJECT(_type, _object, _ptr) \ - { \ - tidy_object *obj; \ - obj = (tidy_object*)zend_object_store_get_object(_object TSRMLS_CC); \ - obj->type = is_ ## _type; \ - obj->u._type = _ptr; \ - } - -#define REGISTER_TIDY_CLASS(name, parent) \ - { \ - zend_class_entry ce; \ - INIT_CLASS_ENTRY(ce, "tidy_" # name, tidy_funcs_ ## name); \ - ce.create_object = tidy_object_new_ ## name; \ - tidy_ce_ ## name = zend_register_internal_class_ex(&ce, parent, NULL TSRMLS_CC); \ - tidy_ce_ ## name->ce_flags |= ZEND_ACC_FINAL_CLASS; \ - memcpy(&tidy_object_handlers_ ## name, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); \ - tidy_object_handlers_ ## name.clone_obj = NULL; \ - } - -#define GET_THIS_CONTAINER() \ - PHPTidyObj *obj; \ - { \ - zval *object = getThis(); \ - obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC); \ - } - -#define INSTANCIATE_NODE(_zval, _container, _node) \ - tidy_instanciate(tidy_ce_node, _zval TSRMLS_CC); \ - _container = (PHPTidyObj *) zend_object_store_get_object(_zval TSRMLS_CC); \ - _container->node = _node; \ - _container->attr = NULL; \ - _container->type = is_node; \ - tidy_add_default_properities(_container, is_node TSRMLS_CC); - -#define INSTANCIATE_ATTR(_zval, _container, _attr) \ - tidy_instanciate(tidy_ce_attr, _zval TSRMLS_CC); \ - _container = (PHPTidyObj *) zend_object_store_get_object(_zval TSRMLS_CC); \ - _container->node = NULL; \ - _container->attr = _attr; \ - _container->type = is_attr; \ - tidy_add_default_properities(_container, is_attr TSRMLS_CC); - -#define PHP_NODE_METHOD_IS_TYPE(_type, _const) \ -PHP_NODE_METHOD(is_ ##_type) \ -{ \ - GET_THIS_CONTAINER(); \ - if(tidyNodeGetType(obj->node) == _const) {\ - RETURN_TRUE; \ - } else { \ - RETURN_FALSE; \ - } \ -} - -typedef enum { - is_node, - is_attr -} tidy_obj_type; - -struct _PHPTidyDoc { - - TidyDoc doc; - TidyBuffer *errbuf; - zend_bool parsed; -}; - -typedef struct _PHPTidyDoc PHPTidyDoc; -typedef struct _PHPTidyObj PHPTidyObj; - -struct _PHPTidyObj { - zend_object std; - TidyNode node; - TidyAttr attr; - tidy_obj_type type; -}; - - -PHP_MINIT_FUNCTION(tidy); -PHP_MSHUTDOWN_FUNCTION(tidy); -PHP_RINIT_FUNCTION(tidy); -PHP_RSHUTDOWN_FUNCTION(tidy); -PHP_MINFO_FUNCTION(tidy); - -PHP_FUNCTION(tidy_setopt); -PHP_FUNCTION(tidy_getopt); -PHP_FUNCTION(tidy_parse_string); -PHP_FUNCTION(tidy_parse_file); -PHP_FUNCTION(tidy_clean_repair); -PHP_FUNCTION(tidy_repair_string); -PHP_FUNCTION(tidy_repair_file); -PHP_FUNCTION(tidy_diagnose); -PHP_FUNCTION(tidy_get_output); -PHP_FUNCTION(tidy_get_error_buffer); -PHP_FUNCTION(tidy_get_release); -PHP_FUNCTION(tidy_reset_config); -PHP_FUNCTION(tidy_get_config); -PHP_FUNCTION(tidy_get_status); -PHP_FUNCTION(tidy_get_html_ver); -PHP_FUNCTION(tidy_is_xhtml); -PHP_FUNCTION(tidy_is_xml); -PHP_FUNCTION(tidy_error_count); -PHP_FUNCTION(tidy_warning_count); -PHP_FUNCTION(tidy_access_count); -PHP_FUNCTION(tidy_config_count); -PHP_FUNCTION(tidy_load_config); -PHP_FUNCTION(tidy_load_config_enc); -PHP_FUNCTION(tidy_set_encoding); -PHP_FUNCTION(tidy_save_config); - -PHP_FUNCTION(tidy_get_root); -PHP_FUNCTION(tidy_get_html); -PHP_FUNCTION(tidy_get_head); -PHP_FUNCTION(tidy_get_body); - -PHP_NODE_METHOD(__construct); -PHP_NODE_METHOD(attributes); -PHP_NODE_METHOD(children); - -PHP_NODE_METHOD(has_children); -PHP_NODE_METHOD(has_siblings); -PHP_NODE_METHOD(is_comment); -PHP_NODE_METHOD(is_html); -PHP_NODE_METHOD(is_xhtml); -PHP_NODE_METHOD(is_xml); -PHP_NODE_METHOD(is_text); -PHP_NODE_METHOD(is_jste); -PHP_NODE_METHOD(is_asp); -PHP_NODE_METHOD(is_php); - -PHP_NODE_METHOD(next); -PHP_NODE_METHOD(prev); -PHP_NODE_METHOD(get_attr); -PHP_NODE_METHOD(get_nodes); - -/* resource dtor */ -void dtor_TidyDoc(zend_rsrc_list_entry * TSRMLS_DC); - -/* constant register helpers */ -void _php_tidy_register_nodetypes(INIT_FUNC_ARGS); -void _php_tidy_register_tags(INIT_FUNC_ARGS); -void _php_tidy_register_attributes(INIT_FUNC_ARGS); - -ZEND_BEGIN_MODULE_GLOBALS(tidy) - PHPTidyDoc *tdoc; - zend_bool used; - char *default_config; -ZEND_END_MODULE_GLOBALS(tidy) - -#ifdef ZTS -#define TG(v) TSRMG(tidy_globals_id, zend_tidy_globals *, v) -#else -#define TG(v) (tidy_globals.v) -#endif - - - - -#endif - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/ext/tidy/tests/001.phpt b/ext/tidy/tests/001.phpt deleted file mode 100644 index 17da6f9874..0000000000 --- a/ext/tidy/tests/001.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -Check for tidy presence ---SKIPIF-- -<?php if (!extension_loaded("tidy")) print "skip"; ?> ---POST-- ---GET-- ---INI-- ---FILE-- -<?php -echo "tidy 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-- -tidy extension is available diff --git a/ext/tidy/tests/002.phpt b/ext/tidy/tests/002.phpt deleted file mode 100644 index 83456091f7..0000000000 --- a/ext/tidy/tests/002.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -tidy_parse_string() ---SKIPIF-- -<?php if (!extension_loaded("tidy")) print "skip"; ?> ---POST-- ---GET-- ---INI-- ---FILE-- -<?php - tidy_parse_string("<HTML></HTML>"); - - echo tidy_get_output(); - -?> ---EXPECT-- -<html> -<head> -<title></title> -</head> -<body> -</body> -</html>
\ No newline at end of file diff --git a/ext/tidy/tests/003.phpt b/ext/tidy/tests/003.phpt deleted file mode 100644 index b008acecdb..0000000000 --- a/ext/tidy/tests/003.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -tidy_clean_repair() ---SKIPIF-- -<?php if (!extension_loaded("tidy")) print "skip"; ?> ---POST-- ---GET-- ---INI-- ---FILE-- -<?php - - tidy_parse_string("<HTML></HTML>"); - tidy_clean_repair(); - - echo tidy_get_output(); - -?> ---EXPECT-- -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> -<html> -<head> -<title></title> -</head> -<body> -</body> -</html> diff --git a/ext/tidy/tests/004.phpt b/ext/tidy/tests/004.phpt deleted file mode 100644 index ed60a39b27..0000000000 --- a/ext/tidy/tests/004.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -tidy_diagnose() ---SKIPIF-- -<?php if (!extension_loaded("tidy")) print "skip"; ?> ---POST-- ---GET-- ---INI-- ---FILE-- -<?php - tidy_parse_string("<HTML></HTML>"); - tidy_diagnose(); - echo tidy_get_error_buffer(); - -?> ---EXPECT-- - -line 1 column 1 - Warning: missing <!DOCTYPE> declaration -line 1 column 7 - Warning: discarding unexpected </html> -line 1 column 14 - Warning: inserting missing 'title' element -Info: Document content looks like HTML 3.2 -3 warnings, 0 errors were found!
\ No newline at end of file diff --git a/ext/tidy/tests/005.html b/ext/tidy/tests/005.html deleted file mode 100644 index 8c17451f91..0000000000 --- a/ext/tidy/tests/005.html +++ /dev/null @@ -1 +0,0 @@ -<HTML></HTML> diff --git a/ext/tidy/tests/005.phpt b/ext/tidy/tests/005.phpt deleted file mode 100644 index d69a726c8f..0000000000 --- a/ext/tidy/tests/005.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -tidy_parse_file() ---SKIPIF-- -<?php if (!extension_loaded("tidy")) print "skip"; ?> ---POST-- ---GET-- ---INI-- ---FILE-- -<?php - - tidy_parse_file("ext/tidy/tests/005.html"); - - echo tidy_get_output(); - -?> ---EXPECT-- -<html> -<head> -<title></title> -</head> -<body> -</body> -</html>
\ No newline at end of file diff --git a/ext/tidy/tests/006.phpt b/ext/tidy/tests/006.phpt deleted file mode 100644 index 7ea28e79c5..0000000000 --- a/ext/tidy/tests/006.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Verbose tidy_get_error_buffer() ---SKIPIF-- -<?php if (!extension_loaded("tidy")) print "skip"; ?> ---POST-- ---GET-- ---INI-- ---FILE-- -<?php - - tidy_parse_string("<HTML><asd asdf></HTML>"); - - echo tidy_get_error_buffer(true); - -?> ---EXPECT-- -line 1 column 1 - Warning: missing <!DOCTYPE> declaration -line 1 column 7 - Error: <asd> is not recognized! -line 1 column 7 - Warning: discarding unexpected <asd> -line 1 column 17 - Warning: discarding unexpected </html> -line 1 column 7 - Warning: inserting missing 'title' element
\ No newline at end of file diff --git a/ext/tidy/tests/007.phpt b/ext/tidy/tests/007.phpt deleted file mode 100644 index 9987677df6..0000000000 --- a/ext/tidy/tests/007.phpt +++ /dev/null @@ -1,36 +0,0 @@ ---TEST-- -Verbose tidy_setopt() / tidy_getopt() ---SKIPIF-- -<?php if (!extension_loaded("tidy")) print "skip"; ?> ---POST-- ---GET-- ---INI-- ---FILE-- -<?php - - echo "Current Value of 'tidy-mark': "; - var_dump(tidy_getopt("tidy-mark")); - tidy_setopt($tidy, "tidy-mark", true); - echo "\nNew Value of 'tidy-mark': "; - var_dump(tidy_getopt("tidy-mark")); - echo "Current Value of 'error-file': "; - var_dump(tidy_getopt("error-file")); - tidy_setopt($tidy, "error-file", "foobar"); - echo "\nNew Value of 'error-file': "; - var_dump(tidy_getopt("error-file")); - echo "Current Value of 'tab-size': "; - var_dump(tidy_getopt("tab-size")); - tidy_setopt($tidy, "tab-size", 10); - echo "\nNew Value of 'tab-size': "; - var_dump(tidy_getopt("tab-size")); -?> ---EXPECT-- -Current Value of 'tidy-mark': bool(false) - -New Value of 'tidy-mark': bool(true) -Current Value of 'error-file': string(0) "" - -New Value of 'error-file': string(6) "foobar" -Current Value of 'tab-size': int(8) - -New Value of 'tab-size': int(10)
\ No newline at end of file diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c deleted file mode 100644 index 0714346223..0000000000 --- a/ext/tidy/tidy.c +++ /dev/null @@ -1,1679 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2003 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 | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_0.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: John Coggeshall <john@php.net> | - | Ilia Alshanetsky <ilia@php.net> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_tidy.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "Zend/zend_API.h" -#include "Zend/zend_hash.h" -#include "safe_mode.h" - -ZEND_DECLARE_MODULE_GLOBALS(tidy); - -#define TIDY_PARSED_CHECK() \ -if(!TG(tdoc)->parsed) { \ - php_error_docref(NULL TSRMLS_CC, E_WARNING, "A document must be parsed before executing this function."); \ - RETURN_FALSE; \ -} \ - -#define TIDY_SAFE_MODE_CHECK(filename) \ -if ((PG(safe_mode) && (!php_checkuid(filename, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(filename TSRMLS_CC)) { \ - RETURN_FALSE; \ -} \ - -function_entry tidy_functions[] = { - PHP_FE(tidy_setopt, NULL) - PHP_FE(tidy_getopt, NULL) - PHP_FE(tidy_parse_string, NULL) - PHP_FE(tidy_parse_file, NULL) - PHP_FE(tidy_get_output, NULL) - PHP_FE(tidy_get_error_buffer, NULL) - PHP_FE(tidy_clean_repair, NULL) - PHP_FE(tidy_repair_string, NULL) - PHP_FE(tidy_repair_file, NULL) - PHP_FE(tidy_diagnose, NULL) - PHP_FE(tidy_get_release, NULL) - PHP_FE(tidy_get_config, NULL) - PHP_FE(tidy_get_status, NULL) - PHP_FE(tidy_get_html_ver, NULL) - PHP_FE(tidy_is_xhtml, NULL) - PHP_FE(tidy_is_xml, NULL) - PHP_FE(tidy_error_count, NULL) - PHP_FE(tidy_warning_count, NULL) - PHP_FE(tidy_access_count, NULL) - PHP_FE(tidy_config_count, NULL) - PHP_FE(tidy_load_config, NULL) - PHP_FE(tidy_load_config_enc, NULL) - PHP_FE(tidy_set_encoding, NULL) - PHP_FE(tidy_save_config, NULL) - -#ifdef ZEND_ENGINE_2 - PHP_FE(tidy_get_root, NULL) - PHP_FE(tidy_get_head, NULL) - PHP_FE(tidy_get_html, NULL) - PHP_FE(tidy_get_body, NULL) -#endif - - {NULL, NULL, NULL} -}; - -#ifdef ZEND_ENGINE_2 -#include "zend_default_classes.h" - -static void tidy_object_dtor(void *object, zend_object_handle handle TSRMLS_DC); -static void tidy_object_new(zend_class_entry *class_type, zend_object_handlers *handlers, zend_object_value *retval TSRMLS_DC); - -static zend_object_value tidy_object_new_node(zend_class_entry *class_type TSRMLS_DC); -static zend_object_value tidy_object_new_attr(zend_class_entry *class_type TSRMLS_DC); -static zend_object_value tidy_object_new_exception(zend_class_entry *class_type TSRMLS_DC); - -static zend_class_entry *tidy_get_ce_node(zval *object TSRMLS_DC); -static zend_class_entry *tidy_get_ce_attr(zval *object TSRMLS_DC); - -static zval * tidy_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC); - -zend_class_entry *tidy_ce_node, *tidy_ce_attr, - *tidy_ce_exception; - -static zend_object_handlers tidy_object_handlers_node; -static zend_object_handlers tidy_object_handlers_attr; -static zend_object_handlers tidy_object_handlers_exception; - -function_entry tidy_funcs_node[] = { - - PHP_NODE_ME(__construct, NULL) - PHP_NODE_ME(attributes, NULL) - PHP_NODE_ME(children, NULL) - - PHP_NODE_ME(has_children, NULL) - PHP_NODE_ME(has_siblings, NULL) - PHP_NODE_ME(is_comment, NULL) - PHP_NODE_ME(is_html, NULL) - PHP_NODE_ME(is_text, NULL) - PHP_NODE_ME(is_jste, NULL) - PHP_NODE_ME(is_asp, NULL) - PHP_NODE_ME(is_php, NULL) - - PHP_NODE_ME(next, NULL) - PHP_NODE_ME(prev, NULL) - PHP_NODE_ME(get_attr, NULL) - /*PHP_NODE_ME(get_nodes, NULL) TODO */ - {NULL, NULL, NULL} -}; - -function_entry tidy_funcs_attr[] = { - {NULL, NULL, NULL} -}; - -function_entry tidy_funcs_exception[] = { - {NULL, NULL, NULL} -}; - -#endif - -zend_module_entry tidy_module_entry = { -#if ZEND_MODULE_API_NO >= 20010901 - STANDARD_MODULE_HEADER, -#endif - "tidy", - tidy_functions, - PHP_MINIT(tidy), - PHP_MSHUTDOWN(tidy), - PHP_RINIT(tidy), - NULL, - PHP_MINFO(tidy), -#if ZEND_MODULE_API_NO >= 20010901 - "0.7b", -#endif - STANDARD_MODULE_PROPERTIES -}; - -#ifdef COMPILE_DL_TIDY -ZEND_GET_MODULE(tidy) -#endif - -/* {{{ PHP_INI - */ -PHP_INI_BEGIN() -STD_PHP_INI_ENTRY("tidy.default_config", "", PHP_INI_SYSTEM, OnUpdateString, default_config, zend_tidy_globals, tidy_globals) -PHP_INI_END() -/* }}} */ - -static void tidy_globals_ctor(zend_tidy_globals *g TSRMLS_DC) -{ - g->used = 0; - g->tdoc = pemalloc(sizeof(PHPTidyDoc), 1); - g->tdoc->doc = tidyCreate(); - g->tdoc->parsed = 0; - g->tdoc->errbuf = pemalloc(sizeof(TidyBuffer), 1); - tidyBufInit(g->tdoc->errbuf); - - if(tidySetErrorBuffer(g->tdoc->doc, g->tdoc->errbuf) != 0) { - zend_error(E_ERROR, "Could not set Tidy error buffer"); - } - - tidyOptSetBool(g->tdoc->doc, TidyForceOutput, yes); - tidyOptSetBool(g->tdoc->doc, TidyMark, no); - - /* remember settings so that we can restore them */ - tidyOptSnapshot(g->tdoc->doc); -} - -static void tidy_globals_dtor(zend_tidy_globals *g TSRMLS_DC) -{ - tidyBufFree(g->tdoc->errbuf); - pefree(g->tdoc->errbuf, 1); - tidyRelease(g->tdoc->doc); - pefree(g->tdoc, 1); - g->used = 0; -} - -static void *php_tidy_get_opt_val(TidyOption opt, TidyOptionType *type TSRMLS_DC) -{ - *type = tidyOptGetType(opt); - - switch (*type) { - case TidyString: { - char *val = (char *) tidyOptGetValue(TG(tdoc)->doc, tidyOptGetId(opt)); - if (val) { - return (void *) estrdup(val); - } else { - return (void *) estrdup(""); - } - } - break; - - case TidyInteger: - return (void *) tidyOptGetInt(TG(tdoc)->doc, tidyOptGetId(opt)); - break; - - case TidyBoolean: - return (void *) tidyOptGetBool(TG(tdoc)->doc, tidyOptGetId(opt)); - break; - } - - /* should not happen */ - return NULL; -} - -static char *php_tidy_file_to_mem(char *filename, zend_bool use_include_path TSRMLS_DC) -{ - php_stream *stream; - int len; - char *data = NULL; - - if (!(stream = php_stream_open_wrapper(filename, "rb", (use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) { - return NULL; - } - if ((len = php_stream_copy_to_mem(stream, &data, PHP_STREAM_COPY_ALL, 0)) > 0) { - /* noop */ - } else if (len == 0) { - data = estrdup(""); - } - php_stream_close(stream); - - return data; -} - -static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_file) -{ - char *data=NULL, *cfg_file=NULL, *arg1; - int cfg_file_len, arg1_len; - zend_bool use_include_path = 0; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sb", &arg1, &arg1_len, &cfg_file, &cfg_file_len, &use_include_path) == FAILURE) { - RETURN_FALSE; - } - - if (is_file) { - if (!(data = php_tidy_file_to_mem(arg1, use_include_path TSRMLS_CC))) { - RETURN_FALSE; - } - } else { - data = arg1; - } - - if (cfg_file && cfg_file[0]) { - TIDY_SAFE_MODE_CHECK(cfg_file); - if(tidyLoadConfig(TG(tdoc)->doc, cfg_file) < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not load configuration file '%s'", cfg_file); - RETVAL_FALSE; - } - TG(used) = 1; - } - - if (data) { - if(tidyParseString(TG(tdoc)->doc, data) < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "[Tidy error] %s", TG(tdoc)->errbuf->bp); - RETVAL_FALSE; - } else { - TG(tdoc)->parsed = TRUE; - if (tidyCleanAndRepair(TG(tdoc)->doc) >= 0) { - TidyBuffer output = {0}; - - tidySaveBuffer (TG(tdoc)->doc, &output); - RETVAL_STRING(output.bp, 1); - tidyBufFree(&output); - } else { - RETVAL_FALSE; - } - } - } - - if (is_file) { - efree(data); - } -} - -PHP_MINIT_FUNCTION(tidy) -{ - REGISTER_INI_ENTRIES(); - -#ifdef ZEND_ENGINE_2 - REGISTER_TIDY_CLASS(node, NULL); - REGISTER_TIDY_CLASS(attr, NULL); - REGISTER_TIDY_CLASS(exception, zend_exception_get_default()); - - tidy_object_handlers_node.get_class_entry = tidy_get_ce_node; - tidy_object_handlers_attr.get_class_entry = tidy_get_ce_attr; -#endif - - _php_tidy_register_tags(INIT_FUNC_ARGS_PASSTHRU); - _php_tidy_register_attributes(INIT_FUNC_ARGS_PASSTHRU); - _php_tidy_register_nodetypes(INIT_FUNC_ARGS_PASSTHRU); - - ZEND_INIT_MODULE_GLOBALS(tidy, tidy_globals_ctor, tidy_globals_dtor); - - return SUCCESS; -} - -PHP_MSHUTDOWN_FUNCTION(tidy) -{ -#ifndef ZTS - tidy_globals_dtor(&tidy_globals TSRMLS_CC); -#endif - return SUCCESS; -} - -PHP_RINIT_FUNCTION(tidy) -{ - if (TG(used) && tidyOptDiffThanSnapshot((TG(tdoc))->doc)) { - tidyOptResetToSnapshot((TG(tdoc))->doc); - TG(used) = 0; - } - /* if a user provided a default configuration file, use it */ - if (TG(default_config) && TG(default_config)[0]) { - if (tidyLoadConfig((TG(tdoc))->doc, TG(default_config)) < 0) { - zend_error(E_ERROR, "Unable to load Tidy configuration file at '%s'.", TG(default_config)); - } - TG(used) = 1; - } - return SUCCESS; -} - -PHP_MINFO_FUNCTION(tidy) -{ - TidyIterator itOpt = tidyGetOptionList(TG(tdoc)->doc); - void *opt_value; - TidyOptionType optt; - char buf[255]; - - php_info_print_table_start(); - php_info_print_table_header(2, "Tidy support", "enabled"); - php_info_print_table_row(2, "libTidy Build Date", (char *)tidyReleaseDate()); - php_info_print_table_end(); - - DISPLAY_INI_ENTRIES(); - - php_info_print_table_start(); - php_info_print_table_header(2, "Tidy Configuration Directive", "Value"); - while (itOpt) { - TidyOption opt = tidyGetNextOption(TG(tdoc)->doc, &itOpt); - - opt_value = php_tidy_get_opt_val(opt, &optt TSRMLS_CC); - switch (optt) { - case TidyString: - php_info_print_table_row(2, (char *)tidyOptGetName(opt), (char*)opt_value); - efree(opt_value); - break; - - case TidyInteger: - sprintf(buf, "%d", (int)opt_value); - php_info_print_table_row(2, (char *)tidyOptGetName(opt), (char*)buf); - break; - - case TidyBoolean: - php_info_print_table_row(2, (char *)tidyOptGetName(opt), (opt_value ? "TRUE" : "FALSE")); - break; - } - } - php_info_print_table_end(); -} - -/* {{{ proto bool tidy_parse_string(string input) - Parse a document stored in a string */ -PHP_FUNCTION(tidy_parse_string) -{ - char *input; - int input_len; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &input, &input_len) == FAILURE) { - RETURN_FALSE; - } - - if(tidyParseString(TG(tdoc)->doc, input) < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "[Tidy error] %s", TG(tdoc)->errbuf->bp); - RETURN_FALSE; - } - - TG(tdoc)->parsed = TRUE; - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto string tidy_get_error_buffer([boolean detailed]) - Return warnings and errors which occured parsing the specified document*/ -PHP_FUNCTION(tidy_get_error_buffer) -{ - zend_bool detailed = 0; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &detailed) == FAILURE) { - RETURN_FALSE; - } - - TIDY_PARSED_CHECK(); - - if (detailed) { - tidyErrorSummary(TG(tdoc)->doc); - } - - RETVAL_STRING(TG(tdoc)->errbuf->bp, 1); - tidyBufClear(TG(tdoc)->errbuf); -} -/* }}} */ - -/* {{{ proto string tidy_get_output() - Return a string representing the parsed tidy markup */ -PHP_FUNCTION(tidy_get_output) -{ - TidyBuffer output = {0}; - - if (ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - tidySaveBuffer (TG(tdoc)->doc, &output); - - RETVAL_STRING(output.bp, 1); - - tidyBufFree(&output); -} -/* }}} */ - -/* {{{ proto boolean tidy_parse_file(string file [, bool use_include_path]) - Parse markup in file or URI */ -PHP_FUNCTION(tidy_parse_file) -{ - char *inputfile; - int input_len; - zend_bool use_include_path = 0; - char *contents; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &inputfile, &input_len) == FAILURE) { - RETURN_FALSE; - } - - if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path TSRMLS_CC))) { - RETURN_FALSE; - } - - if(tidyParseString(TG(tdoc)->doc, contents) < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "[Tidy error] %s", TG(tdoc)->errbuf->bp); - RETVAL_FALSE; - } else { - TG(tdoc)->parsed = TRUE; - RETVAL_TRUE; - } - - efree(contents); -} -/* }}} */ - -/* {{{ proto boolean tidy_clean_repair() - Execute configured cleanup and repair operations on parsed markup */ -PHP_FUNCTION(tidy_clean_repair) -{ - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - if (tidyCleanAndRepair(TG(tdoc)->doc) >= 0) { - RETURN_TRUE; - } - - RETURN_FALSE; -} -/* }}} */ - -/* {{{ proto boolean tidy_repair_string(string data [, string config_file]) - Repair a string using an optionally provided configuration file */ -PHP_FUNCTION(tidy_repair_string) -{ - php_tidy_quick_repair(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0); -} -/* }}} */ - -/* {{{ proto boolean tidy_repair_file(string filename [, string config_file [, bool use_include_path]]) - Repair a file using an optionally provided configuration file */ -PHP_FUNCTION(tidy_repair_file) -{ - php_tidy_quick_repair(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1); -} -/* }}} */ - -/* {{{ proto boolean tidy_diagnose() - Run configured diagnostics on parsed and repaired markup. */ -PHP_FUNCTION(tidy_diagnose) -{ - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - if (tidyRunDiagnostics(TG(tdoc)->doc) >= 0) { - RETURN_TRUE; - } - - RETURN_FALSE; -} -/* }}} */ - -/* {{{ proto string tidy_get_release() - Get release date (version) for Tidy library */ -PHP_FUNCTION(tidy_get_release) -{ - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - RETURN_STRING((char *)tidyReleaseDate(), 1); -} -/* }}} */ - -/* {{{ proto string tidy_reset_config() - Restore Tidy configuration to default values */ -PHP_FUNCTION(tidy_reset_config) -{ - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - RETURN_BOOL(tidyOptResetToSnapshot(TG(tdoc)->doc)); -} -/* }}} */ - -/* {{{ proto array tidy_get_config() - Get current Tidy configuarion */ -PHP_FUNCTION(tidy_get_config) -{ - TidyIterator itOpt = tidyGetOptionList(TG(tdoc)->doc); - char *opt_name; - void *opt_value; - TidyOptionType optt; - - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - array_init(return_value); - - while (itOpt) { - TidyOption opt = tidyGetNextOption(TG(tdoc)->doc, &itOpt); - - opt_name = (char *)tidyOptGetName(opt); - opt_value = php_tidy_get_opt_val(opt, &optt TSRMLS_CC); - switch (optt) { - case TidyString: - add_assoc_string(return_value, opt_name, (char*)opt_value, 0); - break; - - case TidyInteger: - add_assoc_long(return_value, opt_name, (long)opt_value); - break; - - case TidyBoolean: - add_assoc_bool(return_value, opt_name, (long)opt_value); - break; - } - } - - return; -} -/* }}} */ - - -/* {{{ proto int tidy_get_status() - Get status of specfied document. */ -PHP_FUNCTION(tidy_get_status) -{ - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - RETURN_LONG(tidyStatus(TG(tdoc)->doc)); -} -/* }}} */ - -/* {{{ proto int tidy_get_html_ver() - Get the Detected HTML version for the specified document. */ -PHP_FUNCTION(tidy_get_html_ver) -{ - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - RETURN_LONG(tidyDetectedHtmlVersion(TG(tdoc)->doc)); -} -/* }}} */ - -/* {{{ proto boolean tidy_is_xhtml() - Indicates if the document is a XHTML document. */ -PHP_FUNCTION(tidy_is_xhtml) -{ - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - RETURN_BOOL(tidyDetectedXhtml(TG(tdoc)->doc)); -} -/* }}} */ - -/* {{{ proto boolean tidy_is_xhtml() - Indicates if the document is a generic (non HTML/XHTML) XML document. */ -PHP_FUNCTION(tidy_is_xml) -{ - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - RETURN_BOOL(tidyDetectedGenericXml(TG(tdoc)->doc)); -} -/* }}} */ - -/* {{{ proto int tidy_error_count() - Returns the Number of Tidy errors encountered for specified document. */ -PHP_FUNCTION(tidy_error_count) -{ - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - RETURN_LONG(tidyErrorCount(TG(tdoc)->doc)); -} -/* }}} */ - -/* {{{ proto int tidy_warning_count() - Returns the Number of Tidy warnings encountered for specified document. */ -PHP_FUNCTION(tidy_warning_count) -{ - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - RETURN_LONG(tidyWarningCount(TG(tdoc)->doc)); -} -/* }}} */ - -/* {{{ proto int tidy_access_count() - Returns the Number of Tidy accessibility warnings encountered for specified document. */ -PHP_FUNCTION(tidy_access_count) -{ - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - RETURN_LONG(tidyAccessWarningCount(TG(tdoc)->doc)); -} -/* }}} */ - -/* {{{ proto int tidy_config_count() - Returns the Number of Tidy configuration errors encountered for specified document. */ -PHP_FUNCTION(tidy_config_count) -{ - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - RETURN_LONG(tidyConfigErrorCount(TG(tdoc)->doc)); -} -/* }}} */ - -/* {{{ proto void tidy_load_config(string filename) - Load an ASCII Tidy configuration file */ -PHP_FUNCTION(tidy_load_config) -{ - char *filename; - int filename_len; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { - RETURN_FALSE; - } - - TIDY_SAFE_MODE_CHECK(filename); - - if(tidyLoadConfig(TG(tdoc)->doc, filename) < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not load configuration file '%s'", filename); - RETURN_FALSE; - } - - TG(used) = 1; - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto void tidy_load_config(string filename, string encoding) - Load an ASCII Tidy configuration file with the specified encoding */ -PHP_FUNCTION(tidy_load_config_enc) -{ - char *filename, *encoding; - int enc_len, file_len; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &filename, &file_len, &encoding, &enc_len) == FAILURE) { - RETURN_FALSE; - } - - TIDY_SAFE_MODE_CHECK(filename); - - if(tidyLoadConfigEnc(TG(tdoc)->doc, filename, encoding) < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not load configuration file '%s' using encoding '%s'", filename, encoding); - RETURN_FALSE; - } - - TG(used) = 1; - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto boolean tidy_set_encoding(string encoding) - Set the input/output character encoding for parsing markup. - Values include: ascii, latin1, raw, utf8, iso2022, mac, win1252, utf16le, - utf16be, utf16, big5 and shiftjis. */ -PHP_FUNCTION(tidy_set_encoding) -{ - char *encoding; - int enc_len; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &encoding, &enc_len) == FAILURE) { - RETURN_FALSE; - } - - if(tidySetCharEncoding(TG(tdoc)->doc, encoding) < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not set encoding '%s'", encoding); - RETURN_FALSE; - } - - TG(used) = 1; - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto boolean tidy_save_config(string filename) - Save current settings to named file. Only non-default values are written. */ -PHP_FUNCTION(tidy_save_config) -{ - char *filename; - int file_len; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &file_len) == FAILURE) { - RETURN_FALSE; - } - - TIDY_SAFE_MODE_CHECK(filename); - - if(tidyOptSaveFile(TG(tdoc)->doc, filename) < 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not write tidy configuration file '%s'", filename); - RETURN_FALSE; - } - - RETURN_TRUE; -} -/* }}} */ - -/* {{{ proto boolean tidy_setopt(string option, mixed newvalue) - Updates the configuration settings for the specified tidy document. */ -PHP_FUNCTION(tidy_setopt) -{ - zval *value; - char *optname; - int optname_len; - TidyOption opt; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &optname, &optname_len, &value) == FAILURE) { - RETURN_FALSE; - } - - opt = tidyGetOptionByName(TG(tdoc)->doc, optname); - if (!opt) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown Tidy Configuration Option '%s'", optname); - RETURN_FALSE; - } - - switch(tidyOptGetType(opt)) { - case TidyString: - convert_to_string_ex(&value); - if(tidyOptSetValue(TG(tdoc)->doc, tidyOptGetId(opt), Z_STRVAL_P(value))) { - TG(used) = 1; - RETURN_TRUE; - } - break; - - case TidyInteger: - convert_to_long_ex(&value); - if(tidyOptSetInt(TG(tdoc)->doc, tidyOptGetId(opt), Z_LVAL_P(value))) { - TG(used) = 1; - RETURN_TRUE; - } - break; - - case TidyBoolean: - convert_to_long_ex(&value); - if(tidyOptSetBool(TG(tdoc)->doc, tidyOptGetId(opt), Z_LVAL_P(value))) { - TG(used) = 1; - RETURN_TRUE; - } - break; - - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to determine type of Tidy configuration constant to set"); - break; - } - RETURN_FALSE; -} -/* }}} */ - -/* {{{ proto mixed tidy_getopt(string option) - Returns the value of the specified configuration option for the tidy document. */ -PHP_FUNCTION(tidy_getopt) -{ - char *optname; - void *optval; - int optname_len; - TidyOption opt; - TidyOptionType optt; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &optname, &optname_len) == FAILURE) { - RETURN_FALSE; - } - - opt = tidyGetOptionByName(TG(tdoc)->doc, optname); - if (!opt) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown Tidy Configuration Option '%s'", optname); - RETURN_FALSE; - } - - optval = php_tidy_get_opt_val(opt, &optt TSRMLS_CC); - switch (optt) { - case TidyString: - RETVAL_STRING((char *)optval, 0); - break; - - case TidyInteger: - RETURN_LONG((long)optval); - break; - - case TidyBoolean: - if (optval) { - RETURN_TRUE; - } else { - RETURN_NULL(); - } - break; - - default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to determine type of Tidy configuration constant to get"); - break; - } - - RETURN_FALSE; -} -/* }}} */ - -#ifdef ZEND_ENGINE_2 -static void tidy_object_dtor(void *object, zend_object_handle handle TSRMLS_DC) -{ - PHPTidyObj *intern = (PHPTidyObj *)object; - - zend_hash_destroy(intern->std.properties); - FREE_HASHTABLE(intern->std.properties); - - efree(object); -} - -static void tidy_object_new(zend_class_entry *class_type, zend_object_handlers *handlers, zend_object_value *retval TSRMLS_DC) -{ - PHPTidyObj *intern; - zval *tmp; - - intern = emalloc(sizeof(PHPTidyObj)); - memset(intern, 0, sizeof(PHPTidyObj)); - intern->std.ce = class_type; - - ALLOC_HASHTABLE(intern->std.properties); - zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0); - zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); - - retval->handle = zend_objects_store_put(intern, tidy_object_dtor, NULL TSRMLS_CC); - retval->handlers = handlers; -} - -static zend_object_value tidy_object_new_node(zend_class_entry *class_type TSRMLS_DC) -{ - zend_object_value retval; - tidy_object_new(class_type, &tidy_object_handlers_node, &retval TSRMLS_CC); - return retval; -} - -static zend_object_value tidy_object_new_attr(zend_class_entry *class_type TSRMLS_DC) -{ - zend_object_value retval; - tidy_object_new(class_type, &tidy_object_handlers_attr, &retval TSRMLS_CC); - return retval; - -} - -static zend_object_value tidy_object_new_exception(zend_class_entry *class_type TSRMLS_DC) -{ - zend_object_value retval; - tidy_object_new(class_type, &tidy_object_handlers_exception, &retval TSRMLS_CC); - return retval; - -} - -static zend_class_entry *tidy_get_ce_node(zval *object TSRMLS_DC) -{ - return tidy_ce_node; -} - -static zend_class_entry *tidy_get_ce_attr(zval *object TSRMLS_DC) -{ - return tidy_ce_attr; -} - -static zval * tidy_instanciate(zend_class_entry *pce, zval *object TSRMLS_DC) -{ - if (!object) { - ALLOC_ZVAL(object); - } - Z_TYPE_P(object) = IS_OBJECT; - object_init_ex(object, pce); - object->refcount = 1; - object->is_ref = 1; - return object; -} - -#define ADD_PROPERITY_STRING(_table, _key, _string) \ - { \ - zval *tmp; \ - MAKE_STD_ZVAL(tmp); \ - if(_string) { \ - ZVAL_STRING(tmp, (char *)_string, 1); \ - } else { \ - ZVAL_EMPTY_STRING(tmp); \ - } \ - zend_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \ - } - -#define ADD_PROPERITY_LONG(_table, _key, _long) \ - { \ - zval *tmp; \ - MAKE_STD_ZVAL(tmp); \ - ZVAL_LONG(tmp, _long); \ - zend_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \ - } - -static void tidy_add_default_properities(PHPTidyObj *obj, tidy_obj_type type TSRMLS_DC) { - - TidyBuffer buf; - - switch(type) { - - case is_node: - memset(&buf, 0, sizeof(buf)); - tidyNodeGetText(TG(tdoc)->doc, obj->node, &buf); - ADD_PROPERITY_STRING(obj->std.properties, value, buf.bp); - tidyBufFree(&buf); - - ADD_PROPERITY_STRING(obj->std.properties, name, tidyNodeGetName(obj->node)); - ADD_PROPERITY_LONG(obj->std.properties, type, tidyNodeGetType(obj->node)); - ADD_PROPERITY_LONG(obj->std.properties, id, tidyNodeGetId(obj->node)); - - break; - case is_attr: - ADD_PROPERITY_STRING(obj->std.properties, name, tidyAttrName(obj->attr)); - ADD_PROPERITY_STRING(obj->std.properties, value, tidyAttrValue(obj->attr)); - ADD_PROPERITY_LONG(obj->std.properties, id, tidyAttrGetId(obj->attr)); - break; - } - -} -/* {{{ proto TidyNode tidy_get_root() - Returns a TidyNode Object representing the root of the tidy parse tree */ -PHP_FUNCTION(tidy_get_root) -{ - PHPTidyObj *obj; - - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - tidy_instanciate(tidy_ce_node, return_value TSRMLS_CC); - obj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC); - obj->node = tidyGetRoot(TG(tdoc)->doc); - obj->attr = NULL; - obj->type = is_node; - - tidy_add_default_properities(obj, is_node TSRMLS_CC); - -} -/* }}} */ - -/* {{{ proto TidyNode tidy_get_html() - Returns a TidyNode Object starting from the <HTML> tag of the tidy parse tree */ -PHP_FUNCTION(tidy_get_html) -{ - PHPTidyObj *obj; - - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - tidy_instanciate(tidy_ce_node, return_value TSRMLS_CC); - obj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC); - obj->node = tidyGetHtml(TG(tdoc)->doc); - obj->attr = NULL; - obj->type = is_node; - - tidy_add_default_properities(obj, is_node TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto TidyNode tidy_get_head() - Returns a TidyNode Object starting from the <HEAD> tag of the tidy parse tree */ -PHP_FUNCTION(tidy_get_head) -{ - PHPTidyObj *obj; - - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - tidy_instanciate(tidy_ce_node, return_value TSRMLS_CC); - obj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC); - obj->node = tidyGetHead(TG(tdoc)->doc); - obj->attr = NULL; - obj->type = is_node; - - tidy_add_default_properities(obj, is_node TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto TidyNode tidy_get_body(resource tidy) - Returns a TidyNode Object starting from the <BODY> tag of the tidy parse tree */ -PHP_FUNCTION(tidy_get_body) -{ - PHPTidyObj *obj; - - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - tidy_instanciate(tidy_ce_node, return_value TSRMLS_CC); - obj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC); - obj->node = tidyGetBody(TG(tdoc)->doc); - obj->attr = NULL; - obj->type = is_node; - - tidy_add_default_properities(obj, is_node TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto void tidy_node::tidy_node() - Constructor. */ -PHP_NODE_METHOD(__construct) -{ -} -/* }}} */ - -/* {{{ proto tidy_attr tidy_node::attributes() - Returns an array of attribute objects for node */ -PHP_NODE_METHOD(attributes) -{ - TidyAttr tempattr; - zval *object; - PHPTidyObj *objtemp; - GET_THIS_CONTAINER(); - - tempattr = tidyAttrFirst(obj->node); - - if(tempattr) { - array_init(return_value); - - do { - - MAKE_STD_ZVAL(object); - INSTANCIATE_ATTR(object, objtemp, tempattr); - add_next_index_zval(return_value, object); - - } while((tempattr = tidyAttrNext(tempattr))); - } -} -/* }}} */ - - - -/* {{{ proto tidy_node tidy_node::children() - Returns an array of child nodes */ -PHP_NODE_METHOD(children) -{ - TidyNode tempnode; - zval *object; - PHPTidyObj *objtemp; - GET_THIS_CONTAINER(); - - tempnode = tidyGetChild(obj->node); - - if(tempnode) { - array_init(return_value); - do { - - MAKE_STD_ZVAL(object); - INSTANCIATE_NODE(object, objtemp, tempnode); - add_next_index_zval(return_value, object); - - } while((tempnode = tidyGetNext(tempnode))); - } -} -/* }}} */ - -/* {{{ proto boolean tidy_node::has_children() - Returns true if this node has children */ -PHP_NODE_METHOD(has_children) -{ - GET_THIS_CONTAINER(); - - if(tidyGetChild(obj->node)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } - -} -/* }}} */ - -/* {{{ proto boolean tidy_node::has_siblings() - Returns true if this node has siblings */ -PHP_NODE_METHOD(has_siblings) -{ - GET_THIS_CONTAINER(); - - if(tidyGetNext(obj->node)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } - -} -/* }}} */ - -/* {{{ proto boolean tidy_node::is_comment() - Returns true if this node represents a comment */ -PHP_NODE_METHOD(is_comment) -{ - GET_THIS_CONTAINER(); - if(tidyNodeGetType(obj->node) == TidyNode_Comment) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } - -} -/* }}} */ - -/* {{{ proto boolean tidy_node::is_html() - Returns true if this node is part of a HTML document */ -PHP_NODE_METHOD(is_html) -{ - GET_THIS_CONTAINER(); - - if(tidyNodeGetType(obj->node) & (TidyNode_Start | TidyNode_End | TidyNode_StartEnd)) { - RETURN_TRUE; - } - RETURN_FALSE; - -} -/* }}} */ - -/* {{{ proto boolean tidy_node::is_xhtml() - Returns true if this node is part of a XHTML document */ -PHP_NODE_METHOD(is_xhtml) -{ - GET_THIS_CONTAINER(); - if(tidyDetectedXhtml(TG(tdoc)->doc)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto boolean tidy_node::is_xml() - Returns true if this node is part of a XML document */ -PHP_NODE_METHOD(is_xml) -{ - GET_THIS_CONTAINER(); - if(tidyDetectedGenericXml(TG(tdoc)->doc)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto boolean tidy_node::is_text() - Returns true if this node represents text (no markup) */ -PHP_NODE_METHOD(is_text) -{ - GET_THIS_CONTAINER(); - if(tidyNodeGetType(obj->node) == TidyNode_Text) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } - -} -/* }}} */ - -/* {{{ proto boolean tidy_node::is_jste() - Returns true if this node is JSTE */ -PHP_NODE_METHOD(is_jste) -{ - GET_THIS_CONTAINER(); - if(tidyNodeGetType(obj->node) == TidyNode_Jste) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto boolean tidy_node::is_asp() - Returns true if this node is ASP */ -PHP_NODE_METHOD(is_asp) -{ - GET_THIS_CONTAINER(); - if(tidyNodeGetType(obj->node) == TidyNode_Asp) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto boolean tidy_node::is_jsp() - Returns true if this node is JSP */ -PHP_NODE_METHOD(is_php) -{ - GET_THIS_CONTAINER(); - if(tidyNodeGetType(obj->node) == TidyNode_Php) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto tidy_node tidy_node::next() - Returns the next sibling to this node */ -PHP_NODE_METHOD(next) -{ - PHPTidyObj *obj; - - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - tidy_instanciate(tidy_ce_node, return_value TSRMLS_CC); - obj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC); - obj->node = tidyGetNext(obj->node); - obj->attr = NULL; - obj->type = is_node; - - tidy_add_default_properities(obj, is_node TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto tidy_node tidy_node::prev() - Returns the previous sibiling to this node */ -PHP_NODE_METHOD(prev) -{ - PHPTidyObj *obj; - - if(ZEND_NUM_ARGS()) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - tidy_instanciate(tidy_ce_node, return_value TSRMLS_CC); - obj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC); - obj->node = tidyGetPrev(obj->node); - obj->attr = NULL; - obj->type = is_node; - - tidy_add_default_properities(obj, is_node TSRMLS_CC); -} -/* }}} */ - -/* {{{ proto tidy_attr tidy_node::get_attr(int attrib_id) - Return the attribute with the provided attribute id */ -PHP_NODE_METHOD(get_attr) -{ - TidyAttr tempattr; - long param; - GET_THIS_CONTAINER(); - - if(ZEND_NUM_ARGS() != 1) { - WRONG_PARAM_COUNT; - } - - TIDY_PARSED_CHECK(); - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", ¶m) == FAILURE) { - RETURN_FALSE; - } - - for(tempattr = tidyAttrFirst(obj->node); tempattr; tempattr = tidyAttrNext(tempattr)) { - - if(tidyAttrGetId(tempattr) == param) { - - tidy_instanciate(tidy_ce_node, return_value TSRMLS_CC); - - obj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC); - obj->node = NULL; - obj->attr = tempattr; - obj->type = is_attr; - - tidy_add_default_properities(obj, is_attr TSRMLS_CC); - } - } - -} -/* }}} */ - -/* {{{ proto tidy_node tidy_node::get_nodes(int node_id) - Return an array of nodes under this node with the specified id */ -PHP_NODE_METHOD(get_nodes) -{ - /* TODO */ -} -/* }}} */ - -#endif /* ZEND_ENGINE_2 */ - -void _php_tidy_register_nodetypes(INIT_FUNC_ARGS) -{ - - TIDY_NODE_CONST(ROOT, Root); - TIDY_NODE_CONST(DOCTYPE, DocType); - TIDY_NODE_CONST(COMMENT, Comment); - TIDY_NODE_CONST(PROCINS, ProcIns); - TIDY_NODE_CONST(TEXT, Text); - TIDY_NODE_CONST(START, Start); - TIDY_NODE_CONST(END, End); - TIDY_NODE_CONST(STARTEND, StartEnd); - TIDY_NODE_CONST(CDATA, CDATA); - TIDY_NODE_CONST(SECTION, Section); - TIDY_NODE_CONST(ASP, Asp); - TIDY_NODE_CONST(JSTE, Jste); - TIDY_NODE_CONST(PHP, Php); - TIDY_NODE_CONST(XMLDECL, XmlDecl); - -} - -void _php_tidy_register_tags(INIT_FUNC_ARGS) -{ - - TIDY_TAG_CONST(UNKNOWN); - TIDY_TAG_CONST(A); - TIDY_TAG_CONST(ABBR); - TIDY_TAG_CONST(ACRONYM); - TIDY_TAG_CONST(ADDRESS); - TIDY_TAG_CONST(ALIGN); - TIDY_TAG_CONST(APPLET); - TIDY_TAG_CONST(AREA); - TIDY_TAG_CONST(B); - TIDY_TAG_CONST(BASE); - TIDY_TAG_CONST(BASEFONT); - TIDY_TAG_CONST(BDO); - TIDY_TAG_CONST(BGSOUND); - TIDY_TAG_CONST(BIG); - TIDY_TAG_CONST(BLINK); - TIDY_TAG_CONST(BLOCKQUOTE); - TIDY_TAG_CONST(BODY); - TIDY_TAG_CONST(BR); - TIDY_TAG_CONST(BUTTON); - TIDY_TAG_CONST(CAPTION); - TIDY_TAG_CONST(CENTER); - TIDY_TAG_CONST(CITE); - TIDY_TAG_CONST(CODE); - TIDY_TAG_CONST(COL); - TIDY_TAG_CONST(COLGROUP); - TIDY_TAG_CONST(COMMENT); - TIDY_TAG_CONST(DD); - TIDY_TAG_CONST(DEL); - TIDY_TAG_CONST(DFN); - TIDY_TAG_CONST(DIR); - TIDY_TAG_CONST(DIV); - TIDY_TAG_CONST(DL); - TIDY_TAG_CONST(DT); - TIDY_TAG_CONST(EM); - TIDY_TAG_CONST(EMBED); - TIDY_TAG_CONST(FIELDSET); - TIDY_TAG_CONST(FONT); - TIDY_TAG_CONST(FORM); - TIDY_TAG_CONST(FRAME); - TIDY_TAG_CONST(FRAMESET); - TIDY_TAG_CONST(H1); - TIDY_TAG_CONST(H2); - TIDY_TAG_CONST(H3); - TIDY_TAG_CONST(H4); - TIDY_TAG_CONST(H5); - TIDY_TAG_CONST(H6); - TIDY_TAG_CONST(HEAD); - TIDY_TAG_CONST(HR); - TIDY_TAG_CONST(HTML); - TIDY_TAG_CONST(I); - TIDY_TAG_CONST(IFRAME); - TIDY_TAG_CONST(ILAYER); - TIDY_TAG_CONST(IMG); - TIDY_TAG_CONST(INPUT); - TIDY_TAG_CONST(INS); - TIDY_TAG_CONST(ISINDEX); - TIDY_TAG_CONST(KBD); - TIDY_TAG_CONST(KEYGEN); - TIDY_TAG_CONST(LABEL); - TIDY_TAG_CONST(LAYER); - TIDY_TAG_CONST(LEGEND); - TIDY_TAG_CONST(LI); - TIDY_TAG_CONST(LINK); - TIDY_TAG_CONST(LISTING); - TIDY_TAG_CONST(MAP); - TIDY_TAG_CONST(MARQUEE); - TIDY_TAG_CONST(MENU); - TIDY_TAG_CONST(META); - TIDY_TAG_CONST(MULTICOL); - TIDY_TAG_CONST(NOBR); - TIDY_TAG_CONST(NOEMBED); - TIDY_TAG_CONST(NOFRAMES); - TIDY_TAG_CONST(NOLAYER); - TIDY_TAG_CONST(NOSAVE); - TIDY_TAG_CONST(NOSCRIPT); - TIDY_TAG_CONST(OBJECT); - TIDY_TAG_CONST(OL); - TIDY_TAG_CONST(OPTGROUP); - TIDY_TAG_CONST(OPTION); - TIDY_TAG_CONST(P); - TIDY_TAG_CONST(PARAM); - TIDY_TAG_CONST(PLAINTEXT); - TIDY_TAG_CONST(PRE); - TIDY_TAG_CONST(Q); - TIDY_TAG_CONST(RB); - TIDY_TAG_CONST(RBC); - TIDY_TAG_CONST(RP); - TIDY_TAG_CONST(RT); - TIDY_TAG_CONST(RTC); - TIDY_TAG_CONST(RUBY); - TIDY_TAG_CONST(S); - TIDY_TAG_CONST(SAMP); - TIDY_TAG_CONST(SCRIPT); - TIDY_TAG_CONST(SELECT); - TIDY_TAG_CONST(SERVER); - TIDY_TAG_CONST(SERVLET); - TIDY_TAG_CONST(SMALL); - TIDY_TAG_CONST(SPACER); - TIDY_TAG_CONST(SPAN); - TIDY_TAG_CONST(STRIKE); - TIDY_TAG_CONST(STRONG); - TIDY_TAG_CONST(STYLE); - TIDY_TAG_CONST(SUB); - TIDY_TAG_CONST(SUP); - TIDY_TAG_CONST(TABLE); - TIDY_TAG_CONST(TBODY); - TIDY_TAG_CONST(TD); - TIDY_TAG_CONST(TEXTAREA); - TIDY_TAG_CONST(TFOOT); - TIDY_TAG_CONST(TH); - TIDY_TAG_CONST(THEAD); - TIDY_TAG_CONST(TITLE); - TIDY_TAG_CONST(TR); - TIDY_TAG_CONST(TT); - TIDY_TAG_CONST(U); - TIDY_TAG_CONST(UL); - TIDY_TAG_CONST(VAR); - TIDY_TAG_CONST(WBR); - TIDY_TAG_CONST(XMP); - -} - -void _php_tidy_register_attributes(INIT_FUNC_ARGS) -{ - - TIDY_ATTR_CONST(UNKNOWN); - TIDY_ATTR_CONST(ABBR); - TIDY_ATTR_CONST(ACCEPT); - TIDY_ATTR_CONST(ACCEPT_CHARSET); - TIDY_ATTR_CONST(ACCESSKEY); - TIDY_ATTR_CONST(ACTION); - TIDY_ATTR_CONST(ADD_DATE); - TIDY_ATTR_CONST(ALIGN); - TIDY_ATTR_CONST(ALINK); - TIDY_ATTR_CONST(ALT); - TIDY_ATTR_CONST(ARCHIVE); - TIDY_ATTR_CONST(AXIS); - TIDY_ATTR_CONST(BACKGROUND); - TIDY_ATTR_CONST(BGCOLOR); - TIDY_ATTR_CONST(BGPROPERTIES); - TIDY_ATTR_CONST(BORDER); - TIDY_ATTR_CONST(BORDERCOLOR); - TIDY_ATTR_CONST(BOTTOMMARGIN); - TIDY_ATTR_CONST(CELLPADDING); - TIDY_ATTR_CONST(CELLSPACING); - TIDY_ATTR_CONST(CHAR); - TIDY_ATTR_CONST(CHAROFF); - TIDY_ATTR_CONST(CHARSET); - TIDY_ATTR_CONST(CHECKED); - TIDY_ATTR_CONST(CITE); - TIDY_ATTR_CONST(CLASS); - TIDY_ATTR_CONST(CLASSID); - TIDY_ATTR_CONST(CLEAR); - TIDY_ATTR_CONST(CODE); - TIDY_ATTR_CONST(CODEBASE); - TIDY_ATTR_CONST(CODETYPE); - TIDY_ATTR_CONST(COLOR); - TIDY_ATTR_CONST(COLS); - TIDY_ATTR_CONST(COLSPAN); - TIDY_ATTR_CONST(COMPACT); - TIDY_ATTR_CONST(CONTENT); - TIDY_ATTR_CONST(COORDS); - TIDY_ATTR_CONST(DATA); - TIDY_ATTR_CONST(DATAFLD); - /* TIDY_ATTR_CONST(DATAFORMATSAS); */ - TIDY_ATTR_CONST(DATAPAGESIZE); - TIDY_ATTR_CONST(DATASRC); - TIDY_ATTR_CONST(DATETIME); - TIDY_ATTR_CONST(DECLARE); - TIDY_ATTR_CONST(DEFER); - TIDY_ATTR_CONST(DIR); - TIDY_ATTR_CONST(DISABLED); - TIDY_ATTR_CONST(ENCODING); - TIDY_ATTR_CONST(ENCTYPE); - TIDY_ATTR_CONST(FACE); - TIDY_ATTR_CONST(FOR); - TIDY_ATTR_CONST(FRAME); - TIDY_ATTR_CONST(FRAMEBORDER); - TIDY_ATTR_CONST(FRAMESPACING); - TIDY_ATTR_CONST(GRIDX); - TIDY_ATTR_CONST(GRIDY); - TIDY_ATTR_CONST(HEADERS); - TIDY_ATTR_CONST(HEIGHT); - TIDY_ATTR_CONST(HREF); - TIDY_ATTR_CONST(HREFLANG); - TIDY_ATTR_CONST(HSPACE); - TIDY_ATTR_CONST(HTTP_EQUIV); - TIDY_ATTR_CONST(ID); - TIDY_ATTR_CONST(ISMAP); - TIDY_ATTR_CONST(LABEL); - TIDY_ATTR_CONST(LANG); - TIDY_ATTR_CONST(LANGUAGE); - TIDY_ATTR_CONST(LAST_MODIFIED); - TIDY_ATTR_CONST(LAST_VISIT); - TIDY_ATTR_CONST(LEFTMARGIN); - TIDY_ATTR_CONST(LINK); - TIDY_ATTR_CONST(LONGDESC); - TIDY_ATTR_CONST(LOWSRC); - TIDY_ATTR_CONST(MARGINHEIGHT); - TIDY_ATTR_CONST(MARGINWIDTH); - TIDY_ATTR_CONST(MAXLENGTH); - TIDY_ATTR_CONST(MEDIA); - TIDY_ATTR_CONST(METHOD); - TIDY_ATTR_CONST(MULTIPLE); - TIDY_ATTR_CONST(NAME); - TIDY_ATTR_CONST(NOHREF); - TIDY_ATTR_CONST(NORESIZE); - TIDY_ATTR_CONST(NOSHADE); - TIDY_ATTR_CONST(NOWRAP); - TIDY_ATTR_CONST(OBJECT); - TIDY_ATTR_CONST(OnAFTERUPDATE); - TIDY_ATTR_CONST(OnBEFOREUNLOAD); - TIDY_ATTR_CONST(OnBEFOREUPDATE); - TIDY_ATTR_CONST(OnBLUR); - TIDY_ATTR_CONST(OnCHANGE); - TIDY_ATTR_CONST(OnCLICK); - TIDY_ATTR_CONST(OnDATAAVAILABLE); - TIDY_ATTR_CONST(OnDATASETCHANGED); - TIDY_ATTR_CONST(OnDATASETCOMPLETE); - TIDY_ATTR_CONST(OnDBLCLICK); - TIDY_ATTR_CONST(OnERRORUPDATE); - TIDY_ATTR_CONST(OnFOCUS); - TIDY_ATTR_CONST(OnKEYDOWN); - TIDY_ATTR_CONST(OnKEYPRESS); - TIDY_ATTR_CONST(OnKEYUP); - TIDY_ATTR_CONST(OnLOAD); - TIDY_ATTR_CONST(OnMOUSEDOWN); - TIDY_ATTR_CONST(OnMOUSEMOVE); - TIDY_ATTR_CONST(OnMOUSEOUT); - TIDY_ATTR_CONST(OnMOUSEOVER); - TIDY_ATTR_CONST(OnMOUSEUP); - TIDY_ATTR_CONST(OnRESET); - TIDY_ATTR_CONST(OnROWENTER); - TIDY_ATTR_CONST(OnROWEXIT); - TIDY_ATTR_CONST(OnSELECT); - TIDY_ATTR_CONST(OnSUBMIT); - TIDY_ATTR_CONST(OnUNLOAD); - TIDY_ATTR_CONST(PROFILE); - TIDY_ATTR_CONST(PROMPT); - TIDY_ATTR_CONST(RBSPAN); - TIDY_ATTR_CONST(READONLY); - TIDY_ATTR_CONST(REL); - TIDY_ATTR_CONST(REV); - TIDY_ATTR_CONST(RIGHTMARGIN); - TIDY_ATTR_CONST(ROWS); - TIDY_ATTR_CONST(ROWSPAN); - TIDY_ATTR_CONST(RULES); - TIDY_ATTR_CONST(SCHEME); - TIDY_ATTR_CONST(SCOPE); - TIDY_ATTR_CONST(SCROLLING); - TIDY_ATTR_CONST(SELECTED); - TIDY_ATTR_CONST(SHAPE); - TIDY_ATTR_CONST(SHOWGRID); - TIDY_ATTR_CONST(SHOWGRIDX); - TIDY_ATTR_CONST(SHOWGRIDY); - TIDY_ATTR_CONST(SIZE); - TIDY_ATTR_CONST(SPAN); - TIDY_ATTR_CONST(SRC); - TIDY_ATTR_CONST(STANDBY); - TIDY_ATTR_CONST(START); - TIDY_ATTR_CONST(STYLE); - TIDY_ATTR_CONST(SUMMARY); - TIDY_ATTR_CONST(TABINDEX); - TIDY_ATTR_CONST(TARGET); - TIDY_ATTR_CONST(TEXT); - TIDY_ATTR_CONST(TITLE); - TIDY_ATTR_CONST(TOPMARGIN); - TIDY_ATTR_CONST(TYPE); - TIDY_ATTR_CONST(USEMAP); - TIDY_ATTR_CONST(VALIGN); - TIDY_ATTR_CONST(VALUE); - TIDY_ATTR_CONST(VALUETYPE); - TIDY_ATTR_CONST(VERSION); - TIDY_ATTR_CONST(VLINK); - TIDY_ATTR_CONST(VSPACE); - TIDY_ATTR_CONST(WIDTH); - TIDY_ATTR_CONST(WRAP); - TIDY_ATTR_CONST(XML_LANG); - TIDY_ATTR_CONST(XML_SPACE); - TIDY_ATTR_CONST(XMLNS); - -} diff --git a/ext/tidy/tidy.dsp b/ext/tidy/tidy.dsp deleted file mode 100755 index 75e33ec8cf..0000000000 --- a/ext/tidy/tidy.dsp +++ /dev/null @@ -1,108 +0,0 @@ -# Microsoft Developer Studio Project File - Name="tidy" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=tidy - 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 "tidy.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 "tidy.mak" CFG="tidy - Win32 Debug_TS"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "tidy - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "tidy - Win32 Debug_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)" == "tidy - 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 Ignore_Export_Lib 0
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release_TS"
-# PROP Intermediate_Dir "Release_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TIDY_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\include" /I "..\..\..\php_build\include\libtidy" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_TIDY" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D "PHP_TIDY_EXPORTS" /D "HAVE_ZLIB" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x407 /d "NDEBUG"
-# ADD RSC /l 0x407 /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 libtidy.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 /out:"..\..\Release_TS/php_tidy.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline" /libpath:"..\..\..\php_build\release"
-
-!ELSEIF "$(CFG)" == "tidy - 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 "Debug_TS"
-# PROP Intermediate_Dir "Debug_TS"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TIDY_EXPORTS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\TSRM" /I "..\..\..\php_build\include" /I "..\..\..\php_build\include\libtidy" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_TIDY" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D "PHP_TIDY_EXPORTS" /D "HAVE_ZLIB" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x407 /d "_DEBUG"
-# ADD RSC /l 0x407 /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 libtidy.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 /out:"..\..\Debug_TS/php_tidy.dll" /pdbtype:sept /libpath:"..\..\Debug_TS" /libpath:"..\..\..\php_build\release"
-
-!ENDIF
-
-# Begin Target
-
-# Name "tidy - Win32 Release_TS"
-# Name "tidy - Win32 Debug_TS"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\tidy.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\php_tidy.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/ext/xsl/tests/documentxpath.xsl b/ext/xsl/tests/documentxpath.xsl deleted file mode 100644 index 0e5c5c181d..0000000000 --- a/ext/xsl/tests/documentxpath.xsl +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Id: documentxpath.xsl,v 1.1 2003-10-27 15:12:20 chregu Exp $ --> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > - <xsl:output method="xml" encoding="iso-8859-1" indent="no"/> -<xsl:template match="/"> - -<xsl:value-of select="document('compress.zlib://ext/xsl/tests/xslt.xsl.gz')/xsl:stylesheet/xsl:param/@name"/> -</xsl:template> - - </xsl:stylesheet> diff --git a/ext/xsl/tests/prepare.inc b/ext/xsl/tests/prepare.inc deleted file mode 100644 index c2e76fd4b3..0000000000 --- a/ext/xsl/tests/prepare.inc +++ /dev/null @@ -1,20 +0,0 @@ -<?php -$dom = new domDocument; -$dom->load(dirname(__FILE__)."/xslt.xml"); -if(!$dom) { - echo "Error while parsing the document\n"; - exit; -} -$xsl = new domDocument; -$xsl->load(dirname(__FILE__)."/xslt.xsl"); -if(!$xsl) { - echo "Error while parsing the document\n"; - exit; -} -$proc = new xsltprocessor; -if(!$xsl) { - echo "Error while making xsltprocessor object\n"; - exit; -} - -?> diff --git a/ext/xsl/tests/skipif.inc b/ext/xsl/tests/skipif.inc deleted file mode 100644 index 0ef73723a3..0000000000 --- a/ext/xsl/tests/skipif.inc +++ /dev/null @@ -1 +0,0 @@ -<?php if (!extension_loaded('xsl')) die('skip xsl extension not available');?> diff --git a/ext/xsl/tests/streamsinclude.xsl b/ext/xsl/tests/streamsinclude.xsl deleted file mode 100644 index 6f8bc40ed9..0000000000 --- a/ext/xsl/tests/streamsinclude.xsl +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Id: streamsinclude.xsl,v 1.1 2003-10-27 15:12:20 chregu Exp $ --> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > - <xsl:output method="xml" encoding="iso-8859-1" indent="no"/> - <xsl:include href="compress.zlib://xslt.xsl.gz"/> -</xsl:stylesheet> diff --git a/ext/xsl/tests/xslt.xml b/ext/xsl/tests/xslt.xml deleted file mode 100644 index b0e9506c7b..0000000000 --- a/ext/xsl/tests/xslt.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version='1.0' encoding="iso-8859-1" ?> -<chapter language="en"> - <title language="en">Title</title> - <para language="ge"> - -<!-- comment --> - <informaltable> - <tgroup cols="3"> - <tbody> - <row> - <entry>a1</entry> - <entry morerows="1">b1</entry> - <entry>c1</entry> - </row> - <row> - <entry>a2</entry> - <entry>c2</entry> - </row> - <row> - <entry>ä3</entry> - <entry>b3</entry> - <entry>c3</entry> - </row> - </tbody> - </tgroup> - </informaltable> - </para> -</chapter> diff --git a/ext/xsl/tests/xslt.xsl b/ext/xsl/tests/xslt.xsl deleted file mode 100644 index 6248a28580..0000000000 --- a/ext/xsl/tests/xslt.xsl +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Id: xslt.xsl,v 1.1 2003-10-27 08:46:55 chregu Exp $ --> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > - <xsl:output method="xml" encoding="iso-8859-1" indent="no"/> - <xsl:param name="foo" select="'bar'"/> - <xsl:template match="/"> - <html> - <body> - <xsl:value-of select="$foo"/><xsl:text> -</xsl:text> - <xsl:apply-templates select="/chapter/para/informaltable/tgroup/tbody/row"/> - </body> - </html> - </xsl:template> - - <xsl:template match="row"> - <xsl:for-each select="entry"> - <xsl:value-of select="."/> - <xsl:text> </xsl:text> - </xsl:for-each> - <br/> <xsl:text> -</xsl:text> - - </xsl:template> -</xsl:stylesheet> diff --git a/ext/xsl/tests/xslt.xsl.gz b/ext/xsl/tests/xslt.xsl.gz Binary files differdeleted file mode 100644 index 910bb63c8e..0000000000 --- a/ext/xsl/tests/xslt.xsl.gz +++ /dev/null diff --git a/ext/xsl/tests/xslt001.phpt b/ext/xsl/tests/xslt001.phpt deleted file mode 100644 index 885e7c9824..0000000000 --- a/ext/xsl/tests/xslt001.phpt +++ /dev/null @@ -1,22 +0,0 @@ ---TEST-- -Test 1: Transform To XML String ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php -echo "Test 1: Transform To XML String"; -include("prepare.inc"); -$proc->importStylesheet($xsl); -print "\n"; -print $proc->transformToXml($dom); -print "\n"; - - ---EXPECT-- -Test 1: Transform To XML String -<?xml version="1.0" encoding="iso-8859-1"?> -<html><body>bar -a1 b1 c1 <br/> -a2 c2 <br/> -ä3 b3 c3 <br/> -</body></html> diff --git a/ext/xsl/tests/xslt002.phpt b/ext/xsl/tests/xslt002.phpt deleted file mode 100644 index d8a0458d01..0000000000 --- a/ext/xsl/tests/xslt002.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -Test 2: Transform To HTML String ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php -echo "Test 2: Transform To HTML String"; -include("prepare.inc"); -// changing output method to html -$xp = new domxpath($xsl); -$res = $xp->query("/xsl:stylesheet/xsl:output/@method"); -if (count($res) != 1) { - print "No or more than one xsl:output/@method found"; - exit; -} -$res[0]->value = "html"; -$proc->importStylesheet($xsl); -print "\n"; -print $proc->transformToXml($dom); -print "\n"; - - ---EXPECT-- -Test 2: Transform To HTML String -<html><body>bar -a1 b1 c1 <br> -a2 c2 <br> -ä3 b3 c3 <br> -</body></html> diff --git a/ext/xsl/tests/xslt003.phpt b/ext/xsl/tests/xslt003.phpt deleted file mode 100644 index a3c848b1b7..0000000000 --- a/ext/xsl/tests/xslt003.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Test 3: Using Parameters ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php -echo "Test 3: Using Parameters"; -include("prepare.inc"); -$proc->importStylesheet($xsl); -$proc->setParameter( "", "foo","hello world"); -print "\n"; -print $proc->transformToXml($dom); -print "\n"; - - ---EXPECT-- -Test 3: Using Parameters -<?xml version="1.0" encoding="iso-8859-1"?> -<html><body>hello world -a1 b1 c1 <br/> -a2 c2 <br/> -ä3 b3 c3 <br/> -</body></html> diff --git a/ext/xsl/tests/xslt004.phpt b/ext/xsl/tests/xslt004.phpt deleted file mode 100644 index 6c4da2d0ef..0000000000 --- a/ext/xsl/tests/xslt004.phpt +++ /dev/null @@ -1,29 +0,0 @@ ---TEST-- -Test 4: Checking UTF8 Output ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php -echo "Test 4: Checking UTF8 Output"; -include("prepare.inc"); -$xp = new domxpath($xsl); -$res = $xp->query("/xsl:stylesheet/xsl:output/@encoding"); -if (count($res) != 1) { - print "No or more than one xsl:output/@encoding found"; - exit; -} -$res[0]->value = "utf-8"; -$proc->importStylesheet($xsl); -print "\n"; -print $proc->transformToXml($dom); -print "\n"; - - ---EXPECT-- -Test 4: Checking UTF8 Output -<?xml version="1.0" encoding="utf-8"?> -<html><body>bar -a1 b1 c1 <br/> -a2 c2 <br/> -ä3 b3 c3 <br/> -</body></html> diff --git a/ext/xsl/tests/xslt005.phpt b/ext/xsl/tests/xslt005.phpt deleted file mode 100644 index 272a226c79..0000000000 --- a/ext/xsl/tests/xslt005.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -Test 5: Checking Indent ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php -echo "Test 5: Checking Indent"; -include("prepare.inc"); -$xp = new domxpath($xsl); -$res = $xp->query("/xsl:stylesheet/xsl:output/@indent"); -if (count($res) != 1) { - print "No or more than one xsl:output/@indent found"; - exit; -} -$res[0]->value = "yes"; -$proc->importStylesheet($xsl); -print "\n"; -print $proc->transformToXml($dom); -print "\n"; - - ---EXPECT-- -Test 5: Checking Indent -<?xml version="1.0" encoding="iso-8859-1"?> -<html> - <body>bar -a1 b1 c1 <br/> -a2 c2 <br/> -ä3 b3 c3 <br/> -</body> -</html> diff --git a/ext/xsl/tests/xslt006.phpt b/ext/xsl/tests/xslt006.phpt deleted file mode 100644 index 26fada1650..0000000000 --- a/ext/xsl/tests/xslt006.phpt +++ /dev/null @@ -1,23 +0,0 @@ ---TEST-- -Test 6: Transform To Doc ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php -echo "Test 6: Transform To Doc"; -include("prepare.inc"); -$proc->importStylesheet($xsl); -print "\n"; -$doc = $proc->transformToDoc($dom); -print $doc->saveXML(); -print "\n"; - - ---EXPECT-- -Test 6: Transform To Doc -<?xml version="1.0" encoding="iso-8859-1"?> -<html><body>bar -a1 b1 c1 <br/> -a2 c2 <br/> -ä3 b3 c3 <br/> -</body></html> diff --git a/ext/xsl/tests/xslt007.phpt b/ext/xsl/tests/xslt007.phpt deleted file mode 100644 index bc6ad8477a..0000000000 --- a/ext/xsl/tests/xslt007.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -Test 7: Transform To Uri ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php -echo "Test 7: Transform To Uri"; -include("prepare.inc"); -$proc->importStylesheet($xsl); -print "\n"; -$doc = $proc->transformToUri($dom, "file://".dirname(__FILE__)."/out.xml"); -print file_get_contents(dirname(__FILE__)."/out.xml"); -unlink(dirname(__FILE__)."/out.xml"); -print "\n"; - - ---EXPECT-- -Test 7: Transform To Uri -<?xml version="1.0" encoding="iso-8859-1"?> -<html><body>bar -a1 b1 c1 <br/> -a2 c2 <br/> -ä3 b3 c3 <br/> -</body></html> diff --git a/ext/xsl/tests/xslt008.phpt b/ext/xsl/tests/xslt008.phpt deleted file mode 100644 index 76dcb1174d..0000000000 --- a/ext/xsl/tests/xslt008.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -Test 8: Stream Wrapper Includes ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php -echo "Test 8: Stream Wrapper Includes "; -include("prepare.inc"); - -$xsl = new domDocument; -$xsl->load(dirname(__FILE__)."/streamsinclude.xsl"); -if(!$xsl) { - echo "Error while parsing the document\n"; - exit; -} -$xp = new domxpath($xsl); -$res = $xp->query("/xsl:stylesheet/xsl:include/@href"); -$res[0]->value = "compress.zlib://".dirname(__FILE__)."/xslt.xsl.gz"; -$proc->importStylesheet($xsl); -print "\n"; -print $proc->transformToXML($dom); - - ---EXPECT-- -Test 8: Stream Wrapper Includes -<?xml version="1.0" encoding="iso-8859-1"?> -<html><body>bar -a1 b1 c1 <br/> -a2 c2 <br/> -ä3 b3 c3 <br/> -</body></html> diff --git a/ext/xsl/tests/xslt009.phpt b/ext/xsl/tests/xslt009.phpt deleted file mode 100644 index dd8060f4b9..0000000000 --- a/ext/xsl/tests/xslt009.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -Test 9: Stream Wrapper XPath-Document() ---SKIPIF-- -<?php require_once('skipif.inc'); ?> ---FILE-- -<?php -echo "Test 9: Stream Wrapper XPath-Document()"; -include("prepare.inc"); - -$xsl = new domDocument; -$xsl->load(dirname(__FILE__)."/documentxpath.xsl"); -if(!$xsl) { - echo "Error while parsing the document\n"; - exit; -} - -$proc->importStylesheet($xsl); -print "\n"; -print $proc->transformToXML($dom); - - ---EXPECT-- -Test 9: Stream Wrapper XPath-Document() -<?xml version="1.0" encoding="iso-8859-1"?> -foo diff --git a/main/php_realpath.c b/main/php_realpath.c deleted file mode 100644 index 8c7cef5f86..0000000000 --- a/main/php_realpath.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP version 4.0 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997, 1998, 1999, 2000 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: Sander Steffann (sander@steffann.nl) | - +----------------------------------------------------------------------+ - */ - -#include "php.h" - -#if HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <sys/stat.h> - -#ifndef MAXSYMLINKS -#define MAXSYMLINKS 32 -#endif - -#ifndef S_ISDIR -#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) -#endif - -char *php_realpath(char *path, char resolved_path[]); - -#ifdef PHP_WIN32 -#define IS_SLASH(p) ((p) == '/' || (p) == '\\') -#else -#define IS_SLASH(p) ((p) == '/') -#endif - -char *php_realpath(char *path, char resolved_path []) { - char path_construction[MAXPATHLEN]; /* We build the result in here */ - char *writepos; /* Position to write next char */ - - char path_copy[MAXPATHLEN]; /* A work-copy of the path */ - char *workpos; /* working position in *path */ - -#if !defined(PHP_WIN32) - char buf[MAXPATHLEN]; /* Buffer for readlink */ - int linklength; /* The result from readlink */ -#endif - int linkcount = 0; /* Count symlinks to avoid loops */ - - struct stat filestat; /* result from stat */ - -#ifdef PHP_WIN32 - char *temppos; /* position while counting '.' */ - int dotcount; /* number of '.' */ - int t; /* counter */ -#endif - - /* Set the work-position to the beginning of the given path */ - strcpy(path_copy, path); - workpos = path_copy; - -#ifdef PHP_WIN32 - /* Find out where we start - Windows version */ - if (IS_SLASH(*workpos)) { - /* We start at the root of the current drive */ - /* Get the current directory */ - if (V_GETCWD(path_construction, MAXPATHLEN-1) == NULL) { - /* Unable to get cwd */ - resolved_path[0] = 0; - return NULL; - } - /* We only need the first three chars (for example "C:\") */ - path_construction[3] = 0; - workpos++; - } else if (workpos[1] == ':') { - /* A drive-letter is specified, copy it */ - strncpy(path_construction, path, 2); - strcat(path_construction, "\\"); - workpos++; - workpos++; - } else { - /* Use the current directory */ - if (V_GETCWD(path_construction, MAXPATHLEN-1) == NULL) { - /* Unable to get cwd */ - resolved_path[0] = 0; - return NULL; - } - strcat(path_construction, "\\"); - } -#else - /* Find out where we start - Unix version */ - if (*workpos == '/') { - /* We start at the root */ - strcpy(path_construction, "/"); - workpos++; - } else { - /* Use the current directory */ - if (V_GETCWD(path_construction, MAXPATHLEN-1) == NULL) { - /* Unable to get cwd */ - resolved_path[0] = 0; - return NULL; - } - strcat(path_construction, "/"); - } -#endif - - /* Set the next-char-position */ - writepos = &path_construction[strlen(path_construction)]; - - /* Go to the end, then stop */ - while(*workpos != 0) { - /* Strip (back)slashes */ - while(IS_SLASH(*workpos)) workpos++; - -#ifdef PHP_WIN32 - /* reset dotcount */ - dotcount = 0; - - /* Look for .. */ - if ((workpos[0] == '.') && (workpos[1] != 0)) { - /* Windows accepts \...\ as \..\..\, \....\ as \..\..\..\, etc */ - /* At least Win98 does */ - - temppos = workpos; - while(*temppos++ == '.') { - dotcount++; - if (!IS_SLASH(*temppos) && (*temppos != 0) && (*temppos != '.')) { - /* This is not a /../ component, but a filename that starts with '.' */ - dotcount = 0; - } - } - - /* Go back dotcount-1 times */ - for (t=0 ; t<(dotcount-1) ; t++) { - workpos++; /* move to next '.' */ - - /* Can we still go back? */ - if ((writepos-3) <= path_construction) return NULL; - - /* Go back */ - writepos--; /* move to '\' */ - writepos--; - while(!IS_SLASH(*writepos)) writepos--; /* skip until previous '\\' */ - } - workpos++; - } - - /* No special case */ - if (dotcount == 0) { - /* Append */ - while(!IS_SLASH(*workpos) && (*workpos != 0)) { - *writepos++ = *workpos++; - } - } - - /* Just one '.', go to next element */ - if (dotcount == 1) { - while(!IS_SLASH(*workpos) && (*workpos != 0)) { - *workpos++; - } - - /* Avoid double \ in the result */ - writepos--; - } - - /* If it was a directory, append a slash */ - if (IS_SLASH(*workpos)) { - *writepos++ = *workpos++; - } - *writepos = 0; -#else /* defined(PHP_WIN32) */ - /* Look for .. */ - if ((workpos[0] == '.') && (workpos[1] != 0)) { - if ((workpos[1] == '.') && ((workpos[2] == '/') || (workpos[2] == 0))) { - /* One directory back */ - /* Set pointers to right position */ - workpos++; /* move to second '.' */ - workpos++; /* move to '/' */ - - /* Only apply .. if not in root */ - if ((writepos-1) > path_construction) { - writepos--; /* move to '/' */ - while(*--writepos != '/') ; /* skip until previous '/' */ - } - } else { - if (workpos[1] == '/') { - /* Found a /./ skip it */ - workpos++; /* move to '/' */ - - /* Avoid double / in the result */ - writepos--; - } else { - /* No special case, the name just started with a . */ - /* Append */ - while((*workpos != '/') && (*workpos != 0)) { - *writepos++ = *workpos++; - } - } - } - } else { - /* No special case */ - /* Append */ - while((*workpos != '/') && (*workpos != 0)) { - *writepos++ = *workpos++; - } - } - -#if HAVE_SYMLINK - /* We are going to use path_construction, so close it */ - *writepos = 0; - - /* Check the current location to see if it is a symlink */ - if((linklength = readlink(path_construction, buf, MAXPATHLEN)) != -1) { - /* Check linkcount */ - if (linkcount > MAXSYMLINKS) return NULL; - - /* Count this symlink */ - linkcount++; - - /* Set end of buf */ - buf[linklength] = 0; - - /* Check for overflow */ - if ((strlen(workpos) + strlen(buf) + 1) >= MAXPATHLEN) return NULL; - - /* Remove the symlink-component wrom path_construction */ - writepos--; /* move to '/' */ - while(*--writepos != '/') ; /* skip until previous '/' */ - *++writepos = 0; /* end of string after '/' */ - - /* If the symlink starts with a '/', empty path_construction */ - if (*buf == '/') { - *path_construction = 0; - writepos = path_construction; - } - - /* Insert symlink into path_copy */ - strcat(buf, workpos); - strcpy(path_copy, buf); - workpos = path_copy; - } -#endif /* HAVE_SYMLINK */ - - /* If it was a directory, append a slash */ - if (*workpos == '/') { - *writepos++ = *workpos++; - } - *writepos = 0; -#endif /* defined(PHP_WIN32) */ - } - - /* Check if the resolved path is a directory */ - if (V_STAT(path_construction, &filestat) != 0) { - if (errno != ENOENT) return NULL; - } else { - if (S_ISDIR(filestat.st_mode)) { - /* It's a directory, append a / if needed */ - if (*(writepos-1) != '/') { - /* Check for overflow */ - if ((strlen(workpos) + 2) >= MAXPATHLEN) { - return NULL; - } - *writepos++ = '/'; - *writepos = 0; - } - } - } - - strcpy(resolved_path, path_construction); - return resolved_path; -} - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ |