Browse code

kemix: added KSR.kx.ifdef() and KSR.kx.ifndef()

- return true/false if a specified id is defined or not

Daniel-Constantin Mierla authored on 14/07/2021 08:08:50
Showing 1 changed files
... ...
@@ -1138,6 +1138,36 @@ static int ki_kx_get_defn(sip_msg_t *msg, str *dname)
1138 1138
 	return n;
1139 1139
 }
1140 1140
 
1141
+/**
1142
+ *
1143
+ */
1144
+static int ki_kx_ifdef(sip_msg_t *msg, str *dname)
1145
+{
1146
+	str *val;
1147
+
1148
+	val = pp_define_get(dname->len, dname->s);
1149
+
1150
+	if (val!=NULL) {
1151
+		return SR_KEMI_TRUE;
1152
+	}
1153
+	return SR_KEMI_FALSE;
1154
+}
1155
+
1156
+/**
1157
+ *
1158
+ */
1159
+static int ki_kx_ifndef(sip_msg_t *msg, str *dname)
1160
+{
1161
+	str *val;
1162
+
1163
+	val = pp_define_get(dname->len, dname->s);
1164
+
1165
+	if (val==NULL) {
1166
+		return SR_KEMI_TRUE;
1167
+	}
1168
+	return SR_KEMI_FALSE;
1169
+}
1170
+
1141 1171
 /**
1142 1172
  *
1143 1173
  */
... ...
@@ -1505,6 +1535,16 @@ static sr_kemi_t sr_kemi_kx_exports[] = {
1505 1535
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
1506 1536
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1507 1537
 	},
1538
+	{ str_init("kx"), str_init("ifdef"),
1539
+		SR_KEMIP_BOOL, ki_kx_ifdef,
1540
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
1541
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1542
+	},
1543
+	{ str_init("kx"), str_init("ifndef"),
1544
+		SR_KEMIP_BOOL, ki_kx_ifndef,
1545
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
1546
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1547
+	},
1508 1548
 	{ str_init("kx"), str_init("get_env"),
1509 1549
 		SR_KEMIP_XVAL, ki_kx_get_env,
1510 1550
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,