cvs: php4 /ext/wddx php_wddx_api.h wddx.c

From: Date: Mon, 07 Aug 2000 17:25:57 +0000
Subject: cvs: php4 /ext/wddx php_wddx_api.h wddx.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-1093@lists.php.net to get a copy of this message
sas Mon Aug 7 10:25:57 2000 EDT Modified files: /php4/ext/wddx php_wddx_api.h wddx.c Log: Add support for <binary> WDDX element. Index: php4/ext/wddx/php_wddx_api.h diff -u php4/ext/wddx/php_wddx_api.h:1.9 php4/ext/wddx/php_wddx_api.h:1.10 --- php4/ext/wddx/php_wddx_api.h:1.9 Thu Jun 8 20:00:02 2000 +++ php4/ext/wddx/php_wddx_api.h Mon Aug 7 10:25:57 2000 @@ -16,13 +16,15 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_wddx_api.h,v 1.9 2000/06/09 03:00:02 andrei Exp $ */ +/* $Id: php_wddx_api.h,v 1.10 2000/08/07 17:25:57 sas Exp $ */ #ifndef PHP_WDDX_API_H #define PHP_WDDX_API_H #define WDDX_ARRAY_S "<array length='%d'>" #define WDDX_ARRAY_E "</array>" +#define WDDX_BINARY_S "<binary>" +#define WDDX_BINARY_E "</binary>" #define WDDX_BOOLEAN "<boolean value='%s'/>" #define WDDX_CHAR "<char code='%02X'/>" #define WDDX_COMMENT_S "<comment>" Index: php4/ext/wddx/wddx.c diff -u php4/ext/wddx/wddx.c:1.51 php4/ext/wddx/wddx.c:1.52 --- php4/ext/wddx/wddx.c:1.51 Wed Jul 5 08:18:26 2000 +++ php4/ext/wddx/wddx.c Mon Aug 7 10:25:57 2000 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: wddx.c,v 1.51 2000/07/05 15:18:26 andrei Exp $ */ +/* $Id: wddx.c,v 1.52 2000/08/07 17:25:57 sas Exp $ */ #include "php.h" #include "php_wddx.h" @@ -38,11 +38,13 @@ #define PHP_XML_INTERNAL #include "ext/xml/php_xml.h" #include "ext/standard/php_incomplete_class.h" +#include "ext/standard/base64.h" #define WDDX_BUF_LEN 256 #define PHP_CLASS_NAME_VAR "php_class_name" #define EL_ARRAY "array" +#define EL_BINARY "binary" #define EL_BOOLEAN "boolean" #define EL_CHAR "char" #define EL_CHAR_CODE "code" @@ -82,6 +84,7 @@ ST_NULL, ST_NUMBER, ST_STRING, + ST_BINARY, ST_STRUCT } type; char *varname; @@ -634,6 +637,16 @@ ent.data->value.str.val = empty_string; ent.data->value.str.len = 0; wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry)); + } else if (!strcmp(name, EL_BINARY)) { + ent.type = ST_BINARY; + SET_STACK_VARNAME; + + ALLOC_ZVAL(ent.data); + INIT_PZVAL(ent.data); + ent.data->type = IS_STRING; + ent.data->value.str.val = empty_string; + ent.data->value.str.len = 0; + wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry)); } else if (!strcmp(name, EL_CHAR)) { int i; char tmp_buf[2]; @@ -721,12 +734,23 @@ if (stack->top == 0) return; - + if (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) || !strcmp(name, EL_BOOLEAN) || !strcmp(name, EL_NULL) || - !strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT)) { + !strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT) || + !strcmp(name, EL_BINARY)) { wddx_stack_top(stack, (void**)&ent1); + if (!strcmp(name, EL_BINARY)) { + int new_len=0; + unsigned char *new_str; + + new_str = php_base64_decode(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data), &new_len); + efree(Z_STRVAL_P(ent1->data)); + Z_STRVAL_P(ent1->data) = new_str; + Z_STRLEN_P(ent1->data) = new_len; + } + /* Call __wakeup() method on the object. */ if (ent1->data->type == IS_OBJECT) { zval *fname, *retval = NULL; @@ -833,6 +857,17 @@ } efree(decoded_value); + break; + + case ST_BINARY: + if (Z_STRLEN_P(ent->data) == 0) { + Z_STRVAL_P(ent->data) = estrndup(s, len + 1); + } else { + Z_STRVAL_P(ent->data) = erealloc(Z_STRVAL_P(ent->data), Z_STRLEN_P(ent->data) + len + 1); + memcpy(Z_STRVAL_P(ent->data) + Z_STRLEN_P(ent->data), s, len); + } + Z_STRLEN_P(ent->data) += len; + Z_STRVAL_P(ent->data)[Z_STRLEN_P(ent->data)] = '\0'; break; case ST_NUMBER:

« previous php.cvs (#1093) next »