[sr-dev] git:master:d92216eb: app_jsdt: implemented kemi KSR.pv.gete(...)
Daniel-Constantin Mierla
miconda at gmail.com
Sun Aug 26 10:39:53 CEST 2018
Module: kamailio
Branch: master
Commit: d92216ebdb94c4a068437c083c9f1809ddfa8857
URL: https://github.com/kamailio/kamailio/commit/d92216ebdb94c4a068437c083c9f1809ddfa8857
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-08-26T09:53:03+02:00
app_jsdt: implemented kemi KSR.pv.gete(...)
---
Modified: src/modules/app_jsdt/app_jsdt_api.c
---
Diff: https://github.com/kamailio/kamailio/commit/d92216ebdb94c4a068437c083c9f1809ddfa8857.diff
Patch: https://github.com/kamailio/kamailio/commit/d92216ebdb94c4a068437c083c9f1809ddfa8857.patch
---
diff --git a/src/modules/app_jsdt/app_jsdt_api.c b/src/modules/app_jsdt/app_jsdt_api.c
index 224d54bfe6..9b6dda8472 100644
--- a/src/modules/app_jsdt/app_jsdt_api.c
+++ b/src/modules/app_jsdt/app_jsdt_api.c
@@ -158,14 +158,16 @@ int sr_kemi_jsdt_return_int(duk_context *J, sr_kemi_t *ket, int rc)
/**
*
*/
-static int jsdt_sr_return_none(duk_context *J, int rmode)
+static int jsdt_sr_return_pv_null(duk_context *J, int rmode)
{
- if(rmode) {
+ if(rmode==1) {
duk_push_lstring(J, "<<null>>", 8);
- return 1;
+ } else if(rmode==2) {
+ duk_push_lstring(J, "", 0);
} else {
- return 0;
+ duk_push_string(J, NULL);
}
+ return 1;
}
/**
@@ -183,32 +185,27 @@ static int jsdt_sr_pv_get_mode(duk_context *J, int rmode)
pvn.s = (char*)duk_to_string(J, 0);
if(pvn.s==NULL || env_J->msg==NULL)
- return jsdt_sr_return_none(J, rmode);
+ return jsdt_sr_return_pv_null(J, rmode);
pvn.len = strlen(pvn.s);
LM_DBG("pv get: %s\n", pvn.s);
pl = pv_locate_name(&pvn);
if(pl != pvn.len) {
LM_ERR("invalid pv [%s] (%d/%d)\n", pvn.s, pl, pvn.len);
- return jsdt_sr_return_none(J, rmode);
+ return jsdt_sr_return_pv_null(J, rmode);
}
pvs = pv_cache_get(&pvn);
if(pvs==NULL) {
LM_ERR("cannot get pv spec for [%s]\n", pvn.s);
- return jsdt_sr_return_none(J, rmode);
+ return jsdt_sr_return_pv_null(J, rmode);
}
memset(&val, 0, sizeof(pv_value_t));
if(pv_get_spec_value(env_J->msg, pvs, &val) != 0) {
LM_ERR("unable to get pv value for [%s]\n", pvn.s);
- return jsdt_sr_return_none(J, rmode);
+ return jsdt_sr_return_pv_null(J, rmode);
}
if(val.flags&PV_VAL_NULL) {
- if(rmode) {
- jsdt_sr_return_none(J, rmode);
- } else {
- duk_push_string(J, NULL);
- return 1;
- }
+ return jsdt_sr_return_pv_null(J, rmode);
}
if(val.flags&PV_TYPE_INT) {
duk_push_int(J, val.ri);
@@ -234,6 +231,14 @@ static int jsdt_sr_pv_getw(duk_context *J)
return jsdt_sr_pv_get_mode(J, 1);
}
+/**
+ *
+ */
+static int jsdt_sr_pv_gete(duk_context *J)
+{
+ return jsdt_sr_pv_get_mode(J, 2);
+}
+
/**
*
*/
@@ -425,6 +430,7 @@ static int jsdt_sr_pv_is_null (duk_context *J)
const duk_function_list_entry _sr_kemi_pv_J_Map[] = {
{ "get", jsdt_sr_pv_get, 1 /* 1 args */ },
{ "getw", jsdt_sr_pv_getw, 1 /* 1 args */ },
+ { "gete", jsdt_sr_pv_gete, 1 /* 1 args */ },
{ "seti", jsdt_sr_pv_seti, 2 /* 2 args */ },
{ "sets", jsdt_sr_pv_sets, 2 /* 2 args */ },
{ "unset", jsdt_sr_pv_unset, 1 /* 1 args */ },
More information about the sr-dev
mailing list