version 1.6.2.2, 2012/03/13 17:10:13
|
version 1.6.2.4, 2012/03/15 00:44:24
|
Line 90 rpc_srv_getVars(rpc_func_t * __restrict call, array_t
|
Line 90 rpc_srv_getVars(rpc_func_t * __restrict call, array_t
|
return io_arraySize(call->func_vars); |
return io_arraySize(call->func_vars); |
} |
} |
|
|
static inline int | /* --------------------------------------------------------- */ |
calcHashes(rpc_func_t * __restrict func, const char *csModule, const char *csFunc) | |
{ | |
char *str = NULL; | |
int len = 0; | |
|
|
assert(func && csFunc); |
|
|
|
/* set function name */ |
|
AIT_SET_STR(&func->func_name, csFunc); |
|
len = strlen(csFunc) + 3; /* extra 3 bytes, because add string "__" and 0 */ |
|
/* set module name if exists */ |
|
if (csModule) { |
|
AIT_SET_STR(&func->func_file, csModule); |
|
len += strlen(csModule); |
|
} |
|
/* align len to 2 */ |
|
len = (len + 1) & ~1; |
|
|
|
/* prepare hash source string */ |
|
str = malloc(len); |
|
if (!str) { |
|
LOGERR; |
|
return -1; |
|
} else { |
|
memset(str, 0, len); |
|
if (csModule) |
|
strlcpy((char*) str, csModule, len); |
|
strlcat((char*) str, "__", len); |
|
strlcat((char*) str, csFunc, len); |
|
} |
|
|
|
func->func_tag = crcFletcher16((u_short*) str, len / 2); |
|
func->func_hash = hash_fnv((char*) str, len); |
|
|
|
free(str); |
|
return len; |
|
} |
|
|
|
// --------------------------------------------------------- |
|
|
|
/* |
/* |
* rpc_srv_registerCall() - Register call to RPC server |
* rpc_srv_registerCall() - Register call to RPC server |
* |
* |
Line 157 rpc_srv_registerCall(rpc_srv_t * __restrict srv, const
|
Line 118 rpc_srv_registerCall(rpc_srv_t * __restrict srv, const
|
memset(func, 0, sizeof(rpc_func_t)); |
memset(func, 0, sizeof(rpc_func_t)); |
|
|
/* calculate hashes */ |
/* calculate hashes */ |
if (calcHashes(func, csModule, csFunc) == -1) { | if (rpc_calcHashes(func, csModule, csFunc) == -1) { |
AIT_FREE_VAL(&func->func_name); |
AIT_FREE_VAL(&func->func_name); |
AIT_FREE_VAL(&func->func_file); |
AIT_FREE_VAL(&func->func_file); |
free(func); |
free(func); |
Line 202 rpc_srv_unregisterCall(rpc_srv_t * __restrict srv, con
|
Line 163 rpc_srv_unregisterCall(rpc_srv_t * __restrict srv, con
|
memset(&func, 0, sizeof func); |
memset(&func, 0, sizeof func); |
|
|
/* calculate hashes */ |
/* calculate hashes */ |
if (calcHashes(&func, csModule, csFunc) == -1) | if (rpc_calcHashes(&func, csModule, csFunc) == -1) |
return -1; |
return -1; |
|
|
f = rpc_srv_getCall(srv, func.func_tag, func.func_hash); |
f = rpc_srv_getCall(srv, func.func_tag, func.func_hash); |
Line 273 rpc_srv_getFunc(rpc_srv_t * __restrict srv, const char
|
Line 234 rpc_srv_getFunc(rpc_srv_t * __restrict srv, const char
|
memset(&func, 0, sizeof(rpc_func_t)); |
memset(&func, 0, sizeof(rpc_func_t)); |
|
|
/* calculate hashes */ |
/* calculate hashes */ |
if (calcHashes(&func, csModule, csFunc) == -1) | if (rpc_calcHashes(&func, csModule, csFunc) == -1) |
return NULL; |
return NULL; |
|
|
f = rpc_srv_getCall(srv, func.func_tag, func.func_hash); |
f = rpc_srv_getCall(srv, func.func_tag, func.func_hash); |
Line 375 rpc_srv_unregisterBLOB(rpc_srv_t * __restrict srv, uin
|
Line 336 rpc_srv_unregisterBLOB(rpc_srv_t * __restrict srv, uin
|
|
|
return 1; |
return 1; |
} |
} |
|
|
|
/* |
|
* rpc_calcHashes() - Calculate hashes for RPC call |
|
* |
|
* @func = function |
|
* @csModule = Module name, if NULL self binary |
|
* @csFunc = Function name |
|
* return: -1 error or 0 ok |
|
*/ |
|
int |
|
rpc_calcHashes(rpc_func_t * __restrict func, const char *csModule, const char *csFunc) |
|
{ |
|
char *str = NULL; |
|
int len = 0; |
|
|
|
assert(func && csFunc); |
|
|
|
/* set function name */ |
|
AIT_SET_STR(&func->func_name, csFunc); |
|
len = strlen(csFunc) + 3; /* extra 3 bytes, because add string "__" and 0 */ |
|
/* set module name if exists */ |
|
if (csModule) { |
|
AIT_SET_STR(&func->func_file, csModule); |
|
len += strlen(csModule); |
|
} |
|
/* align len to 2 */ |
|
len = io_align(len, 1); |
|
|
|
/* prepare hash source string */ |
|
str = malloc(len); |
|
if (!str) { |
|
LOGERR; |
|
return -1; |
|
} else { |
|
memset(str, 0, len); |
|
if (csModule) |
|
strlcpy((char*) str, csModule, len); |
|
strlcat((char*) str, "__", len); |
|
strlcat((char*) str, csFunc, len); |
|
} |
|
|
|
func->func_tag = crcFletcher16((u_short*) str, len / 2); |
|
func->func_hash = hash_fnv((char*) str, len); |
|
|
|
free(str); |
|
return len; |
|
} |
|
|