cvs: php4(PHP_4) /ext/wddx wddx.c
| From: | Andrei Zmievski | Date: | Wed, 14 May 2003 18:13:54 +0000 |
| Subject: | cvs: php4(PHP_4) /ext/wddx wddx.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-20906@lists.php.net to get a copy of this message | ||
andrei Wed May 14 14:13:54 2003 EDT
Modified files: (Branch: PHP_4)
/php4/ext/wddx wddx.c
Log:
Let wddx_deserialize() work with streams as well.
Index: php4/ext/wddx/wddx.c
diff -u php4/ext/wddx/wddx.c:1.96.2.3 php4/ext/wddx/wddx.c:1.96.2.3.2.1
--- php4/ext/wddx/wddx.c:1.96.2.3 Sat Jan 4 14:51:46 2003
+++ php4/ext/wddx/wddx.c Wed May 14 14:13:54 2003
@@ -16,14 +16,15 @@
+----------------------------------------------------------------------+
*/
-/* $Id: wddx.c,v 1.96.2.3 2003/01/04 19:51:46 helly Exp $ */
+/* $Id: wddx.c,v 1.96.2.3.2.1 2003/05/14 18:13:54 andrei Exp $ */
#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"
@@ -1286,16 +1287,36 @@
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 (packet_len == 0)
+ 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;
-
- php_wddx_deserialize_ex(packet, packet_len, return_value);
+ }
+
+ if (payload_len == 0)
+ return;
+
+ php_wddx_deserialize_ex(payload, payload_len, return_value);
+
+ if (stream)
+ pefree(payload, 0);
}
/* }}} */