cvs: /php4/ext/wddx php_wddx_api.h /php4/ext/wddx wddx.c
| From: | Sascha Schumann | Date: | Thu, 16 Sep 1999 13:25:55 +0000 |
| Subject: | cvs: /php4/ext/wddx php_wddx_api.h /php4/ext/wddx wddx.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-4519@lists.php.net to get a copy of this message | ||
sas Thu Sep 16 09:25:55 1999 EDT
Added files:
/php4/ext/wddx php_wddx_api.h
Modified files:
/php4/ext/wddx wddx.c
Log:
Make some things accessible from outside for session module
Index: php4/ext/wddx/wddx.c
diff -u php4/ext/wddx/wddx.c:1.9 php4/ext/wddx/wddx.c:1.10
--- php4/ext/wddx/wddx.c:1.9 Wed Sep 15 09:28:33 1999
+++ php4/ext/wddx/wddx.c Thu Sep 16 09:25:54 1999
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: wddx.c,v 1.9 1999/09/15 13:28:33 andrey Exp $ */
+/* $Id: wddx.c,v 1.10 1999/09/16 13:25:54 sas Exp $ */
#include "php.h"
#include "php_wddx.h"
@@ -35,22 +35,7 @@
#if HAVE_WDDX
#include "dlist.h"
-#define WDDX_PACKET_S "<wddxPacket version='0.9'>"
-#define WDDX_PACKET_E "</wddxPacket>"
-#define WDDX_HEADER "<header/>"
-#define WDDX_HEADER_COMMENT "<header comment='%s'/>"
-#define WDDX_DATA_S "<data>"
-#define WDDX_DATA_E "</data>"
-#define WDDX_STRING_S "<string>"
-#define WDDX_STRING_E "</string>"
-#define WDDX_CHAR "<char code='%02X'/>"
-#define WDDX_NUMBER "<number>%s</number>"
-#define WDDX_ARRAY_S "<array length='%d'>"
-#define WDDX_ARRAY_E "</array>"
-#define WDDX_VAR_S "<var name='%s'>"
-#define WDDX_VAR_E "</var>"
-#define WDDX_STRUCT_S "<struct>"
-#define WDDX_STRUCT_E "</struct>"
+#include "php_wddx_api.h"
#define WDDX_BUF_LEN 256
@@ -65,12 +50,15 @@
#define EL_PACKET "wddxPacket"
#define EL_VERSION "version"
+#define _php_wddx_deserialize(a,b) \
+ _php_wddx_deserialize_ex((a)->value.str.val, (a)->value.str.len, (b))
+
static int le_wddx;
-typedef struct {
+struct _wddx_packet {
DLIST *packet_head;
int packet_length;
-} wddx_packet;
+};
typedef struct {
zval *data;
@@ -91,7 +79,6 @@
/* {{{ function prototypes */
-static void _php_wddx_serialize_var(wddx_packet *packet, zval *var, char *name);
static void _php_wddx_process_data(void *user_data, const char *s, int len);
/* }}} */
@@ -205,7 +192,7 @@
/* {{{ _php_wddx_destructor */
-static void _php_wddx_destructor(wddx_packet *packet)
+void _php_wddx_destructor(wddx_packet *packet)
{
dlst_kill(packet->packet_head, (void (*)(void *))_php_free_packet_chunk);
efree(packet);
@@ -224,7 +211,7 @@
/* {{{ _php_wddx_add_chunk */
-static void _php_wddx_add_chunk(wddx_packet *packet, char *str)
+void _php_wddx_add_chunk(wddx_packet *packet, char *str)
{
char **chunk_ptr;
@@ -237,7 +224,7 @@
/* {{{ _php_wddx_gather */
-static char* _php_wddx_gather(wddx_packet *packet)
+char* _php_wddx_gather(wddx_packet *packet)
{
char **chunk;
char *buf;
@@ -256,7 +243,7 @@
/* {{{ void _php_wddx_packet_start */
-static void _php_wddx_packet_start(wddx_packet *packet, char *comment)
+void _php_wddx_packet_start(wddx_packet *packet, char *comment)
{
char tmp_buf[WDDX_BUF_LEN];
@@ -274,7 +261,7 @@
/* {{{ int _php_wddx_packet_end */
-static void _php_wddx_packet_end(wddx_packet *packet)
+void _php_wddx_packet_end(wddx_packet *packet)
{
_php_wddx_add_chunk(packet, WDDX_DATA_E);
_php_wddx_add_chunk(packet, WDDX_PACKET_E);
@@ -385,7 +372,7 @@
/* {{{ void _php_wddx_serialize_var(wddx_packet *packet, zval *var, char *name) */
-static void _php_wddx_serialize_var(wddx_packet *packet, zval *var, char *name)
+void _php_wddx_serialize_var(wddx_packet *packet, zval *var, char *name)
{
char tmp_buf[WDDX_BUF_LEN];
@@ -607,8 +594,8 @@
/* }}} */
-/* {{{ void _php_wddx_deserialize(zval *packet, zval *return_value) */
-static void _php_wddx_deserialize(zval *packet, zval *return_value)
+/* {{{ void _php_wddx_deserialize_ex(char *value, int vallen, zval *return_value) */
+void _php_wddx_deserialize_ex(char *value, int vallen, zval *return_value)
{
wddx_stack stack;
XML_Parser parser;
@@ -621,7 +608,7 @@
XML_SetElementHandler(parser, _php_wddx_push_element, _php_wddx_pop_element);
XML_SetCharacterDataHandler(parser, _php_wddx_process_data);
- XML_Parse(parser, packet->value.str.val, packet->value.str.len, 1);
+ XML_Parse(parser, value, vallen, 1);
XML_ParserFree(parser);
@@ -723,6 +710,18 @@
}
/* }}} */
+wddx_packet *_php_wddx_constructor(void)
+{
+ wddx_packet *packet;
+
+ packet = emalloc(sizeof(wddx_packet));
+ if(!packet) return NULL;
+
+ packet->packet_head = dlst_init();
+ packet->packet_length = 0;
+
+ return packet;
+}
/* {{{ proto int wddx_packet_start([ string comment ])
Starts a WDDX packet with optional comment and returns the packet id */
@@ -739,14 +738,11 @@
WRONG_PARAM_COUNT;
}
- packet = emalloc(sizeof(wddx_packet));
+ packet = _php_wddx_constructor();
if (!packet) {
zend_error(E_WARNING, "Unable to allocate memory in wddx_packet_start");
RETURN_FALSE;
}
-
- packet->packet_head = dlst_init();
- packet->packet_length = 0;
if (argc == 1) {
convert_to_string(comment);