--- libaitrpc/src/lists.c 2010/06/24 11:01:46 1.1.2.3 +++ libaitrpc/src/lists.c 2010/06/24 15:01:19 1.1.2.4 @@ -2,6 +2,28 @@ /* + * rpc_srv_retValsCall() Declare return variables for RPC call and zeroed values + (for safe handling return values, use this!) + * @call = RPC function call + * @return_vals = Number of return variables + * return: NULL error, !=NULL array with return values for RPC call with return_vals items + */ +inline rpc_val_t * +rpc_srv_retValsCall(rpc_func_t * __restrict call, int return_vals) +{ + rpc_val_t *v = NULL; + + if (rpc_srv_declValsCall(call, return_vals) == -1) + return NULL; + else + rpc_srv_zeroValsCall(call); + if (rpc_srv_getValsCall(call, &v) == -1) + return NULL; + + return v; +} + +/* * rpc_srv_freeValsCall() Free return variables for RPC call * @call = RPC function call * return: none @@ -13,7 +35,9 @@ rpc_srv_freeValsCall(rpc_func_t * __restrict call) } /* - * rpc_srv_declValsCall() Declare return variables for RPC call + * rpc_srv_declValsCall() Declare return variables for RPC call, + if already allocated memory for RPC call return values + function reallocate used space with return_vals count elements * @call = RPC function call * @return_vals = Number of return variables * return: -1 error, !=-1 ok @@ -47,12 +71,12 @@ rpc_srv_declValsCall(rpc_func_t * __restrict call, int } /* - * rpc_srv_delValsCall() Clean values from return variables of RPC call + * rpc_srv_zeroValsCall() Clean values from return variables of RPC call * @call = RPC function call * return: -1 error, !=-1 Returned number of cleaned RPC variables */ inline int -rpc_srv_delValsCall(rpc_func_t * __restrict call) +rpc_srv_zeroValsCall(rpc_func_t * __restrict call) { if (!call) { rpc_SetErr(EINVAL, "Error:: Invalid parameter can`t delete return variables ...\n"); @@ -143,6 +167,8 @@ rpc_srv_registerCall(rpc_srv_t * __restrict srv, const func->func_tag = crcFletcher16((u_short*) str, (MAXPATHLEN + UCHAR_MAX + 1) / 2); func->func_hash = hash_fnv((char*) str, MAXPATHLEN + UCHAR_MAX + 1); + + func->func_parent = srv; if (rpc_srv_declValsCall(func, args) == -1) { free(func);