Module: sip-router
Branch: master
Commit: 938373a28545a51f335e9489541b106c8261b81d
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=938373a…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Wed Sep 3 09:45:42 2014 +0200
jsonrpc-s: initial support for 'u' specifier
- auto-convert to unsigned int
---
modules/jsonrpc-s/jsonrpc-s_mod.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/modules/jsonrpc-s/jsonrpc-s_mod.c b/modules/jsonrpc-s/jsonrpc-s_mod.c
index 4e65894..1ecd135 100644
--- a/modules/jsonrpc-s/jsonrpc-s_mod.c
+++ b/modules/jsonrpc-s/jsonrpc-s_mod.c
@@ -303,6 +303,9 @@ static srjson_t* jsonrpc_print_value(jsonrpc_ctx_t* ctx, char fmt,
va_list* ap)
case 'd':
nj = srjson_CreateNumber(ctx->jrpl, va_arg(*ap, int));
break;
+ case 'u':
+ nj = srjson_CreateNumber(ctx->jrpl, va_arg(*ap, unsigned int));
+ break;
case 'f':
nj = srjson_CreateNumber(ctx->jrpl, va_arg(*ap, double));
break;
@@ -396,6 +399,7 @@ err:
static int jsonrpc_scan(jsonrpc_ctx_t* ctx, char* fmt, ...)
{
int *int_ptr;
+ unsigned int *uint_ptr;
char **char_ptr;
double *double_ptr;
str *str_ptr;
@@ -429,6 +433,10 @@ static int jsonrpc_scan(jsonrpc_ctx_t* ctx, char* fmt, ...)
int_ptr = va_arg(ap, int*);
*int_ptr = ctx->req_node->valueint;
break;
+ case 'u': /* Integer */
+ uint_ptr = va_arg(ap, unsigned int*);
+ *uint_ptr = (unsigned int)ctx->req_node->valueint;
+ break;
case 'f': /* double */
double_ptr = va_arg(ap, double*);
*double_ptr = ctx->req_node->valuedouble;