summaryrefslogtreecommitdiff
path: root/ext/wddx
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2003-05-14 18:15:17 +0000
committerAndrei Zmievski <andrei@php.net>2003-05-14 18:15:17 +0000
commit8781970a78f676deccc354243b2f1ad8c1e56f96 (patch)
treef080671350c8268067fe6e57e58843ea7d539683 /ext/wddx
parentaf327304765f2f554f20a85d2ab6057bc6c370ad (diff)
downloadphp-git-8781970a78f676deccc354243b2f1ad8c1e56f96.tar.gz
MFB.
@- Updated wddx_deserialize() to take an open stream as an argument. (Andrei)
Diffstat (limited to 'ext/wddx')
-rw-r--r--ext/wddx/wddx.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index f2af34979c..95c437cbaa 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -19,11 +19,12 @@
/* $Id$ */
#include "php.h"
-#include "php_wddx.h"
#if HAVE_WDDX
+#include "php_wddx.h"
#include "php_wddx_api.h"
+
#define PHP_XML_INTERNAL
#include "ext/xml/php_xml.h"
#include "ext/standard/php_incomplete_class.h"
@@ -1261,20 +1262,40 @@ PHP_FUNCTION(wddx_add_vars)
}
/* }}} */
-/* {{{ proto mixed wddx_deserialize(string packet)
+/* {{{ proto mixed wddx_deserialize(mixed packet)
Deserializes given packet and returns a PHP value */
PHP_FUNCTION(wddx_deserialize)
{
- char *packet;
- int packet_len;
+ zval *packet;
+ char *payload;
+ int payload_len;
+ php_stream *stream = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &packet, &packet_len) == FAILURE)
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &packet) == FAILURE)
+ return;
+
+ if (Z_TYPE_P(packet) == IS_STRING) {
+ payload = Z_STRVAL_P(packet);
+ payload_len = Z_STRLEN_P(packet);
+ }
+ else if (Z_TYPE_P(packet) == IS_RESOURCE) {
+ stream = php_stream_from_zval(stream, &packet);
+ if (stream) {
+ payload_len = php_stream_copy_to_mem(stream, &payload, PHP_STREAM_COPY_ALL, 0 TSRMLS_CC);
+ }
+ } else {
+ php_error(E_WARNING, "%s() expects parameter 1 to be a string or a stream",
+ get_active_function_name());
return;
+ }
- if (packet_len == 0)
+ if (payload_len == 0)
return;
+
+ php_wddx_deserialize_ex(payload, payload_len, return_value);
- php_wddx_deserialize_ex(packet, packet_len, return_value);
+ if (stream)
+ pefree(payload, 0);
}
/* }}} */