Module: kamailio Branch: master Commit: 8f87e7c4c3ba925a20bd0ab69e1fc885a559d262 URL: https://github.com/kamailio/kamailio/commit/8f87e7c4c3ba925a20bd0ab69e1fc885a559d262
Author: Ovidiu Sas <[email protected]> Committer: Ovidiu Sas <[email protected]> Date: 2017-05-10T13:00:57-04:00 xhttp_rpc: fix rpc_struct_printf --- Modified: src/modules/xhttp_rpc/xhttp_rpc.c --- Diff: https://github.com/kamailio/kamailio/commit/8f87e7c4c3ba925a20bd0ab69e1fc885a559d262.diff Patch: https://github.com/kamailio/kamailio/commit/8f87e7c4c3ba925a20bd0ab69e1fc885a559d262.patch --- diff --git a/src/modules/xhttp_rpc/xhttp_rpc.c b/src/modules/xhttp_rpc/xhttp_rpc.c index 7e50035..6e27409 100644 --- a/src/modules/xhttp_rpc/xhttp_rpc.c +++ b/src/modules/xhttp_rpc/xhttp_rpc.c @@ -562,7 +562,7 @@ static int rpc_struct_add(struct rpc_data_struct* rpc_s, char* fmt, ...) } -static int rpc_struct_scan(void* s, char* fmt, ...) +static int rpc_struct_scan(struct rpc_data_struct* rpc_s, char* fmt, ...) { LM_ERR("Not implemented\n"); return -1; @@ -571,10 +571,34 @@ static int rpc_struct_scan(void* s, char* fmt, ...) /** Create a new member from formatting string and add it to a structure. */ -static int rpc_struct_printf(void* s, char* member_name, char* fmt, ...) +static int rpc_struct_printf(struct rpc_data_struct* rpc_s, char* member_name, char* fmt, ...) { - LM_ERR("Not implemented\n"); - return -1; + va_list ap; + char buf[PRINT_VALUE_BUF_LEN]; + int len; + str _name,_body; + rpc_ctx_t *ctx = rpc_s->ctx; + + if (!ctx) { + LM_ERR("Invalid context\n"); + return -1; + } + + va_start(ap, fmt); + len=vsnprintf(buf, PRINT_VALUE_BUF_LEN, fmt, ap); + va_end(ap); + if ((len<0) || (len>PRINT_VALUE_BUF_LEN)){ + LM_ERR("buffer size exceeded [%d]\n", PRINT_VALUE_BUF_LEN); + return -1; + } + + _name.s = member_name; + _name.len = strlen(member_name); + _body.s = buf; + _body.len = len; + if (0!=xhttp_rpc_build_content(ctx, &_body, &_name)) return -1; + + return 0; } _______________________________________________ Kamailio (SER) - Development Mailing List [email protected] https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
