Module: sip-router Branch: master Commit: 72a52d2cbd76eb47e832551ab46bcd6b93e7c203 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=72a52d2c...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Wed Apr 23 23:07:21 2014 +0200
xhttp_rpc: added handling for specifier '['
- add array into rpc result - new rpc api member aliased to rpc_struct_add (needs update for proper array value insertion)
---
modules/xhttp_rpc/xhttp_rpc.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/modules/xhttp_rpc/xhttp_rpc.c b/modules/xhttp_rpc/xhttp_rpc.c index b251409..372f0db 100644 --- a/modules/xhttp_rpc/xhttp_rpc.c +++ b/modules/xhttp_rpc/xhttp_rpc.c @@ -354,7 +354,7 @@ static int rpc_add(rpc_ctx_t* ctx, char* fmt, ...) } va_start(ap, fmt); while(*fmt) { - if (*fmt == '{') { + if (*fmt == '{' || *fmt == '[') { void_ptr = va_arg(ap, void**); ds = new_data_struct(ctx); if (!ds) goto err; @@ -544,7 +544,7 @@ static int rpc_struct_add(struct rpc_data_struct* rpc_s, char* fmt, ...) while(*fmt) { member_name.s = va_arg(ap, char*); member_name.len = (member_name.s?strlen(member_name.s):0); - if (*fmt == '{') { + if (*fmt == '{' || *fmt == '[') { void_ptr = va_arg(ap, void**); ds = new_data_struct(ctx); if (!ds) goto err; @@ -641,12 +641,15 @@ static int mod_init(void) } }
+ memset(&func_param, 0, sizeof(func_param)); func_param.send = (rpc_send_f)rpc_send; func_param.fault = (rpc_fault_f)rpc_fault; func_param.add = (rpc_add_f)rpc_add; func_param.scan = (rpc_scan_f)rpc_scan; func_param.printf = (rpc_printf_f)rpc_printf; func_param.struct_add = (rpc_struct_add_f)rpc_struct_add; + /* use rpc_struct_add for array_add */ + func_param.array_add = (rpc_struct_add_f)rpc_struct_add; func_param.struct_scan = (rpc_struct_scan_f)rpc_struct_scan; func_param.struct_printf = (rpc_struct_printf_f)rpc_struct_printf; func_param.capabilities = (rpc_capabilities_f)rpc_capabilities;