Module: kamailio
Branch: master
Commit: 851a8c0f0c8f7cc7ab22cb905bdb3987e9fa461b
URL:
https://github.com/kamailio/kamailio/commit/851a8c0f0c8f7cc7ab22cb905bdb398…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-07-14T10:08:50+02:00
kemix: added KSR.kx.ifdef() and KSR.kx.ifndef()
- return true/false if a specified id is defined or not
---
Modified: src/modules/kemix/kemix_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/851a8c0f0c8f7cc7ab22cb905bdb398…
Patch:
https://github.com/kamailio/kamailio/commit/851a8c0f0c8f7cc7ab22cb905bdb398…
---
diff --git a/src/modules/kemix/kemix_mod.c b/src/modules/kemix/kemix_mod.c
index 1633188089..2b6f6ec9c2 100644
--- a/src/modules/kemix/kemix_mod.c
+++ b/src/modules/kemix/kemix_mod.c
@@ -1138,6 +1138,36 @@ static int ki_kx_get_defn(sip_msg_t *msg, str *dname)
return n;
}
+/**
+ *
+ */
+static int ki_kx_ifdef(sip_msg_t *msg, str *dname)
+{
+ str *val;
+
+ val = pp_define_get(dname->len, dname->s);
+
+ if (val!=NULL) {
+ return SR_KEMI_TRUE;
+ }
+ return SR_KEMI_FALSE;
+}
+
+/**
+ *
+ */
+static int ki_kx_ifndef(sip_msg_t *msg, str *dname)
+{
+ str *val;
+
+ val = pp_define_get(dname->len, dname->s);
+
+ if (val==NULL) {
+ return SR_KEMI_TRUE;
+ }
+ return SR_KEMI_FALSE;
+}
+
/**
*
*/
@@ -1505,6 +1535,16 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("kx"), str_init("ifdef"),
+ SR_KEMIP_BOOL, ki_kx_ifdef,
+ { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
+ { str_init("kx"), str_init("ifndef"),
+ SR_KEMIP_BOOL, ki_kx_ifndef,
+ { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ str_init("kx"), str_init("get_env"),
SR_KEMIP_XVAL, ki_kx_get_env,
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,