[sr-dev] git:master:112f38a4: pv: added {val.ne} transformation
Daniel-Constantin Mierla
miconda at gmail.com
Mon Nov 22 18:54:52 CET 2021
Module: kamailio
Branch: master
Commit: 112f38a4787c4ea5a3b3df3ebc8619f08a05e790
URL: https://github.com/kamailio/kamailio/commit/112f38a4787c4ea5a3b3df3ebc8619f08a05e790
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-11-22T18:54:02+01:00
pv: added {val.ne} transformation
- return empty string if the variable value is $null
---
Modified: src/modules/pv/pv_trans.c
Modified: src/modules/pv/pv_trans.h
---
Diff: https://github.com/kamailio/kamailio/commit/112f38a4787c4ea5a3b3df3ebc8619f08a05e790.diff
Patch: https://github.com/kamailio/kamailio/commit/112f38a4787c4ea5a3b3df3ebc8619f08a05e790.patch
---
diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index 4848936d62..e221cb300e 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -2551,6 +2551,16 @@ int tr_eval_val(struct sip_msg *msg, tr_param_t *tp, int subtype,
val->flags = PV_TYPE_INT|PV_VAL_INT|PV_VAL_STR;
}
break;
+ case TR_VAL_NE:
+ if(val->flags&PV_VAL_NULL) {
+ val->ri = 0;
+ tr_set_crt_buffer();
+ val->rs.s = _tr_buffer;
+ val->rs.s[0] = '\0';
+ val->rs.len = 0;
+ val->flags = PV_VAL_STR;
+ }
+ break;
case TR_VAL_JSON:
if(val->flags&PV_VAL_NULL) {
val->ri = 0;
@@ -3831,6 +3841,9 @@ char* tr_parse_val(str* in, trans_t *t)
if(name.len==2 && strncasecmp(name.s, "n0", 2)==0) {
t->subtype = TR_VAL_N0;
goto done;
+ } else if(name.len==2 && strncasecmp(name.s, "ne", 2)==0) {
+ t->subtype = TR_VAL_NE;
+ goto done;
} else if(name.len==4 && strncasecmp(name.s, "json", 4)==0) {
t->subtype = TR_VAL_JSON;
goto done;
diff --git a/src/modules/pv/pv_trans.h b/src/modules/pv/pv_trans.h
index ebae2720f9..329f09a8a2 100644
--- a/src/modules/pv/pv_trans.h
+++ b/src/modules/pv/pv_trans.h
@@ -73,7 +73,7 @@ enum _tr_urialias_subtype {
};
enum _tr_val_subtype {
- TR_VAL_NONE=0, TR_VAL_N0, TR_VAL_JSON
+ TR_VAL_NONE=0, TR_VAL_N0, TR_VAL_NE, TR_VAL_JSON
};
More information about the sr-dev
mailing list