CVS update: php3/functions

From: Date: Sun, 10 Jan 1999 18:04:48 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-3449@lists.php.net to get a copy of this message
Date: Sunday January 10, 1999 @ 13:04 Author: sas Update of /repository/php3/functions In directory asf:/u/temp/cvs-serv13508/functions Modified Files: wddx.c Log Message: - handle top level variables correctly - optional variable $prefix while unserializing for top level variables Index: php3/functions/wddx.c diff -c php3/functions/wddx.c:1.5 php3/functions/wddx.c:1.6 *** php3/functions/wddx.c:1.5 Sun Jan 10 12:20:13 1999 --- php3/functions/wddx.c Sun Jan 10 13:04:47 1999 *************** *** 27,33 **** +----------------------------------------------------------------------+ */ ! /* $Id: wddx.c,v 1.5 1999/01/10 17:20:13 sas Exp $ */ #include "php.h" #include "internal_functions.h" --- 27,33 ---- +----------------------------------------------------------------------+ */ ! /* $Id: wddx.c,v 1.6 1999/01/10 18:04:47 sas Exp $ */ #include "php.h" #include "internal_functions.h" *************** *** 62,69 **** --- 62,71 ---- int notfirst; char *var_name; char *buf; + char *prefix; int len; int depth; + int type; } _php3_wddx_parser; /* }}} */ *************** *** 325,336 **** /* do we have a var name? could be an associative array or a top level assign */ #define VAR_NAME \ if(wddx->var_name) { \ ! if(wddx->depth) { \ ATTACH("\""); \ ATTACH(wddx->var_name); \ ATTACH("\" => "); \ } else { \ ATTACH("$"); \ ATTACH(wddx->var_name); \ ATTACH(" = "); \ } \ --- 327,339 ---- /* do we have a var name? could be an associative array or a top level assign */ #define VAR_NAME \ if(wddx->var_name) { \ ! if(wddx->type) { \ ATTACH("\""); \ ATTACH(wddx->var_name); \ ATTACH("\" => "); \ } else { \ ATTACH("$"); \ + if(wddx->prefix) ATTACH(wddx->prefix) \ ATTACH(wddx->var_name); \ ATTACH(" = "); \ } \ *************** *** 347,352 **** --- 350,356 ---- if(!strcmp(name, "var")) { int i; + /* required for top level arrays */ wddx->last_type = LT_VAR; for(i = 0; atts[i]; i++) if(!strcmp("name", atts[i])) { *************** *** 358,364 **** } else if(!strcmp(name, "number")) { wddx->last_type = LT_NUMBER; } else if(!strcmp(name, "array") || !strcmp(name, "struct")) { ! wddx->depth++; wddx->last_type = LT_ARRAY; FIRST; VAR_NAME; --- 362,369 ---- } else if(!strcmp(name, "number")) { wddx->last_type = LT_NUMBER; } else if(!strcmp(name, "array") || !strcmp(name, "struct")) { ! if(wddx->depth++ || wddx->last_type != LT_VAR) ! wddx->type++; wddx->last_type = LT_ARRAY; FIRST; VAR_NAME; *************** *** 375,380 **** --- 380,386 ---- if(!strcmp(name, "array") || !strcmp(name, "struct")) { wddx->depth--; + wddx->type--; ATTACH(")"); } } *************** *** 416,427 **** /* }}} */ /* {{{ _php3_wddx_unserialize() */ ! static char *_php3_wddx_unserialize(char *buf) { XML_Parser parser = XML_ParserCreate(NULL); _php3_wddx_parser wddx; memset(&wddx, 0, sizeof(wddx)); XML_SetUserData(parser, &wddx); XML_SetElementHandler(parser, _php3_wddx_start_element, _php3_wddx_end_element), --- 422,434 ---- /* }}} */ /* {{{ _php3_wddx_unserialize() */ ! static char *_php3_wddx_unserialize(char *buf, char *prefix) { XML_Parser parser = XML_ParserCreate(NULL); _php3_wddx_parser wddx; memset(&wddx, 0, sizeof(wddx)); + wddx.prefix = prefix; XML_SetUserData(parser, &wddx); XML_SetElementHandler(parser, _php3_wddx_start_element, _php3_wddx_end_element), *************** *** 433,439 **** } /* }}} */ ! /* {{{ proto string wddx_serialize(array list) creates a WDDX conforming representation of its arguments */ PHP_FUNCTION(wddx_serialize) { --- 440,446 ---- } /* }}} */ ! /* {{{ proto string wddx_serialize(...) creates a WDDX conforming representation of its arguments */ PHP_FUNCTION(wddx_serialize) { *************** *** 469,487 **** } /* }}} */ ! /* {{{ proto array wddx_unserialize(string arg) unserializes a string in WDDX format */ PHP_FUNCTION(wddx_unserialize) { ! pval *arg; ! if(ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) { WRONG_PARAM_COUNT; } ! convert_to_string(arg); ! RETURN_STRING(_php3_wddx_unserialize(arg->value.str.val), 0); } /* }}} */ --- 476,502 ---- } /* }}} */ ! /* {{{ proto array wddx_unserialize(string arg [, string prefix]) unserializes a string in WDDX format */ PHP_FUNCTION(wddx_unserialize) { ! pval *arg, *pprefix; ! int ac = ARG_COUNT(ht); ! char *prefix = NULL; ! if(ac < 1 || ac > 2 || getParameters(ht, ac, &arg, &pprefix) == FAILURE) { WRONG_PARAM_COUNT; } ! switch(ac) { ! case 2: ! convert_to_string(pprefix); ! prefix = pprefix->value.str.val; ! default: ! convert_to_string(arg); ! } ! RETURN_STRING(_php3_wddx_unserialize(arg->value.str.val, prefix), 0); } /* }}} */ -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#3449) next »