Module: kamailio
Branch: master
Commit: 92683311d16dafe56951d9603a3a1e9a1b219d9a
URL:
https://github.com/kamailio/kamailio/commit/92683311d16dafe56951d9603a3a1e9…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-12-20T10:15:36+01:00
jsonrpcs: support for long/long values in rpc messages
- l and j for long and unsigned long
- L and J for long long and unsigned long long
---
Modified: src/modules/jsonrpcs/jsonrpcs_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/92683311d16dafe56951d9603a3a1e9…
Patch:
https://github.com/kamailio/kamailio/commit/92683311d16dafe56951d9603a3a1e9…
---
diff --git a/src/modules/jsonrpcs/jsonrpcs_mod.c b/src/modules/jsonrpcs/jsonrpcs_mod.c
index a5a92e1537..a966f6438e 100644
--- a/src/modules/jsonrpcs/jsonrpcs_mod.c
+++ b/src/modules/jsonrpcs/jsonrpcs_mod.c
@@ -484,6 +484,18 @@ static srjson_t* jsonrpc_print_value(jsonrpc_ctx_t* ctx, char fmt,
va_list* ap)
case 'f':
nj = srjson_CreateNumber(ctx->jrpl, va_arg(*ap, double));
break;
+ case 'l':
+ nj = srjson_CreateNumber(ctx->jrpl, va_arg(*ap, long));
+ break;
+ case 'j':
+ nj = srjson_CreateNumber(ctx->jrpl, va_arg(*ap, unsigned long));
+ break;
+ case 'L':
+ nj = srjson_CreateNumber(ctx->jrpl, va_arg(*ap, long long));
+ break;
+ case 'J':
+ nj = srjson_CreateNumber(ctx->jrpl, va_arg(*ap, unsigned long long));
+ break;
case 'b':
nj = srjson_CreateBool(ctx->jrpl, ((va_arg(*ap, int)==0)?0:1));
break;
@@ -586,6 +598,10 @@ static int jsonrpc_scan(jsonrpc_ctx_t* ctx, char* fmt, ...)
{
int *int_ptr;
unsigned int *uint_ptr;
+ long *long_ptr;
+ unsigned long *ulong_ptr;
+ long long *llong_ptr;
+ unsigned long long *ullong_ptr;
char **char_ptr;
double *double_ptr;
str *str_ptr;
@@ -635,6 +651,22 @@ static int jsonrpc_scan(jsonrpc_ctx_t* ctx, char* fmt, ...)
double_ptr = va_arg(ap, double*);
*double_ptr = ctx->req_node->valuedouble;
break;
+ case 'l': /* Long */
+ long_ptr = va_arg(ap, long*);
+ *long_ptr = SRJSON_GET_LONG(ctx->req_node);
+ break;
+ case 'j': /* Unsigned Long */
+ ulong_ptr = va_arg(ap, unsigned long*);
+ *ulong_ptr = SRJSON_GET_ULONG(ctx->req_node);
+ break;
+ case 'L': /* Long Long */
+ llong_ptr = va_arg(ap, long long*);
+ *llong_ptr = SRJSON_GET_LLONG(ctx->req_node);
+ break;
+ case 'J': /* Unsigned Long Long */
+ ullong_ptr = va_arg(ap, unsigned long long*);
+ *ullong_ptr = SRJSON_GET_ULLONG(ctx->req_node);
+ break;
case 's': /* zero terminated string */
char_ptr = va_arg(ap, char**);
if(ctx->req_node->type==srjson_String) {