[sr-dev] git:master:851a8c0f: kemix: added KSR.kx.ifdef() and KSR.kx.ifndef()

Daniel-Constantin Mierla miconda at gmail.com
Wed Jul 14 18:59:24 CEST 2021


Module: kamailio
Branch: master
Commit: 851a8c0f0c8f7cc7ab22cb905bdb3987e9fa461b
URL: https://github.com/kamailio/kamailio/commit/851a8c0f0c8f7cc7ab22cb905bdb3987e9fa461b

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at 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/851a8c0f0c8f7cc7ab22cb905bdb3987e9fa461b.diff
Patch: https://github.com/kamailio/kamailio/commit/851a8c0f0c8f7cc7ab22cb905bdb3987e9fa461b.patch

---

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,




More information about the sr-dev mailing list