Module: kamailio
Branch: master
Commit: 115fa38f427b1bc3730add9078c44219b25960cb
URL:
https://github.com/kamailio/kamailio/commit/115fa38f427b1bc3730add9078c4421…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-05-18T08:48:37+02:00
app_python: added KSR.pv.getw(...)
---
Modified: src/modules/app_python/apy_kemi.c
---
Diff:
https://github.com/kamailio/kamailio/commit/115fa38f427b1bc3730add9078c4421…
Patch:
https://github.com/kamailio/kamailio/commit/115fa38f427b1bc3730add9078c4421…
---
diff --git a/src/modules/app_python/apy_kemi.c b/src/modules/app_python/apy_kemi.c
index e9759d43d6..b7cca69bdf 100644
--- a/src/modules/app_python/apy_kemi.c
+++ b/src/modules/app_python/apy_kemi.c
@@ -660,7 +660,8 @@ static sr_kemi_t _sr_apy_kemi_test[] = {
/**
*
*/
-static PyObject *sr_apy_kemi_f_pv_get(PyObject *self, PyObject *args)
+static PyObject *sr_apy_kemi_f_pv_get_mode(PyObject *self, PyObject *args,
+ int rmode)
{
str pvn;
pv_spec_t *pvs;
@@ -673,7 +674,11 @@ static PyObject *sr_apy_kemi_f_pv_get(PyObject *self, PyObject
*args)
if(env_P==NULL) {
LM_ERR("invalid Python environment attributes\n");
- return sr_apy_kemi_return_none();
+ if(rmode) {
+ return sr_apy_kemi_return_str(NULL, "<<null>>", 8);
+ } else {
+ return sr_apy_kemi_return_none();
+ }
}
if(env_P->msg==NULL) {
lmsg = faked_msg_next();
@@ -683,12 +688,20 @@ static PyObject *sr_apy_kemi_f_pv_get(PyObject *self, PyObject
*args)
if(!PyArg_ParseTuple(args, "s:pv.get", &pvn.s)) {
LM_ERR("unable to retrieve str param\n");
- return sr_apy_kemi_return_none();
+ if(rmode) {
+ return sr_apy_kemi_return_str(NULL, "<<null>>", 8);
+ } else {
+ return sr_apy_kemi_return_none();
+ }
}
if(pvn.s==NULL || lmsg==NULL) {
LM_ERR("invalid context attributes\n");
- return sr_apy_kemi_return_none();
+ if(rmode) {
+ return sr_apy_kemi_return_str(NULL, "<<null>>", 8);
+ } else {
+ return sr_apy_kemi_return_none();
+ }
}
pvn.len = strlen(pvn.s);
@@ -696,21 +709,37 @@ static PyObject *sr_apy_kemi_f_pv_get(PyObject *self, PyObject
*args)
pl = pv_locate_name(&pvn);
if(pl != pvn.len) {
LM_ERR("invalid pv [%s] (%d/%d)\n", pvn.s, pl, pvn.len);
- return sr_apy_kemi_return_none();
+ if(rmode) {
+ return sr_apy_kemi_return_str(NULL, "<<null>>", 8);
+ } else {
+ return sr_apy_kemi_return_none();
+ }
}
pvs = pv_cache_get(&pvn);
if(pvs==NULL) {
LM_ERR("cannot get pv spec for [%s]\n", pvn.s);
- return sr_apy_kemi_return_none();
+ if(rmode) {
+ return sr_apy_kemi_return_str(NULL, "<<null>>", 8);
+ } else {
+ return sr_apy_kemi_return_none();
+ }
}
memset(&val, 0, sizeof(pv_value_t));
if(pv_get_spec_value(lmsg, pvs, &val) != 0)
{
LM_ERR("unable to get pv value for [%s]\n", pvn.s);
- return sr_apy_kemi_return_none();
+ if(rmode) {
+ return sr_apy_kemi_return_str(NULL, "<<null>>", 8);
+ } else {
+ return sr_apy_kemi_return_none();
+ }
}
if(val.flags&PV_VAL_NULL) {
- return sr_apy_kemi_return_none();
+ if(rmode) {
+ return sr_apy_kemi_return_str(NULL, "<<null>>", 8);
+ } else {
+ return sr_apy_kemi_return_none();
+ }
}
if(val.flags&PV_TYPE_INT) {
return sr_kemi_apy_return_int(NULL, val.ri);
@@ -718,6 +747,22 @@ static PyObject *sr_apy_kemi_f_pv_get(PyObject *self, PyObject
*args)
return sr_apy_kemi_return_str(NULL, val.rs.s, val.rs.len);
}
+/**
+ *
+ */
+static PyObject *sr_apy_kemi_f_pv_get(PyObject *self, PyObject *args)
+{
+ return sr_apy_kemi_f_pv_get_mode(self, args, 0);
+}
+
+/**
+ *
+ */
+static PyObject *sr_apy_kemi_f_pv_get_w(PyObject *self, PyObject *args)
+{
+ return sr_apy_kemi_f_pv_get_mode(self, args, 1);
+}
+
/**
*
*/