--- libaitrpc/src/cli.c 2011/11/03 13:35:39 1.5.2.6 +++ libaitrpc/src/cli.c 2011/11/03 14:28:48 1.5.2.7 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: cli.c,v 1.5.2.6 2011/11/03 13:35:39 misho Exp $ +* $Id: cli.c,v 1.5.2.7 2011/11/03 14:28:48 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -328,7 +328,7 @@ rpc_cli_execCall(rpc_cli_t *cli, const char *csModule, if (io_arraySize(in_vars)) { /* marshaling variables */ - ret = io_vals2buffer(buf + Limit, cli->cli_netbuf - Limit, in_vars); + ret = io_vars2buffer(buf + Limit, cli->cli_netbuf - Limit, in_vars); if (ret == -1) { rpc_SetErr(EBADRPC, "Error:: in prepare RPC packet values (-7) ...\n"); free(buf); @@ -404,7 +404,7 @@ rpc_cli_execCall(rpc_cli_t *cli, const char *csModule, /* RPC is OK! Go de-marshaling variables ... */ if (ntohs(rrpc->ret_argc)) { - *out_vars = io_buffer2vals(buf + Limit, cli->cli_netbuf - Limit, + *out_vars = io_buffer2vars(buf + Limit, cli->cli_netbuf - Limit, ntohs(rrpc->ret_argc), 0); if (!*out_vars) { free(buf); @@ -415,58 +415,4 @@ rpc_cli_execCall(rpc_cli_t *cli, const char *csModule, ret = ntohl(rrpc->ret_retcode); free(buf); return ret; -} - -/* - * rpc_cli_freeVars() Free ait_val_t array returned from RPC call - * @vars = Variable array - * return: none - */ -inline void -rpc_cli_freeVars(array_t ** __restrict vars) -{ - register int i; - - if (!vars || !*vars) - return; - - for (i = 0; i < io_arraySize(*vars); i++) - if (io_arrayGet(*vars, i)) - AIT_FREE_VAL(io_array(*vars, i, ait_val_t*)); - - io_arrayFree(*vars); - io_arrayDestroy(vars); -} - -/* - * rpc_cli_allocVars() Allocate ait_val_t array for RPC call - * @args = Number of arguments - * return: =NULL error or !=NULL allocated array - */ -inline array_t * -rpc_cli_allocVars(u_short args) -{ - array_t *arr; - register int i; - ait_val_t *v; - - if (!args) - return NULL; - - if (!(arr = io_arrayInit(args))) - return NULL; - - for (i = 0; i < io_arraySize(arr); i++) { - v = malloc(sizeof(ait_val_t)); - if (!v) { - LOGERR; - rpc_cli_freeVars(&arr); - return NULL; - } else { - memset(v, 0, sizeof(ait_val_t)); - io_arraySet(arr, i, v); - } - } - - return arr; }