[sr-dev] git:master:0dfd5bd1: dialog: kemi functions to remove or test for null vars

Daniel-Constantin Mierla miconda at gmail.com
Tue Jun 11 12:11:43 CEST 2019


Module: kamailio
Branch: master
Commit: 0dfd5bd14792353b47ca397f22b3c323fd276b28
URL: https://github.com/kamailio/kamailio/commit/0dfd5bd14792353b47ca397f22b3c323fd276b28

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-06-11T12:10:53+02:00

dialog: kemi functions to remove or test for null vars

---

Modified: src/modules/dialog/dialog.c

---

Diff:  https://github.com/kamailio/kamailio/commit/0dfd5bd14792353b47ca397f22b3c323fd276b28.diff
Patch: https://github.com/kamailio/kamailio/commit/0dfd5bd14792353b47ca397f22b3c323fd276b28.patch

---

diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index cb3a80b3b1..34d243a3f1 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -1928,6 +1928,37 @@ static sr_kemi_xval_t* ki_dlg_var_getw(sip_msg_t *msg, str *name)
 	return ki_dlg_var_get_mode(msg, name, SR_KEMI_XVAL_NULL_PRINT);
 }
 
+/**
+ *
+ */
+static int ki_dlg_var_rm(sip_msg_t *msg, str *name)
+{
+	dlg_cell_t *dlg;
+
+	dlg = dlg_get_msg_dialog(msg);
+	set_dlg_variable_unsafe(dlg, name, NULL);
+	return 1;
+}
+
+/**
+ *
+ */
+static int ki_dlg_var_is_null(sip_msg_t *msg, str *name)
+{
+	dlg_cell_t *dlg;
+	str *pval;
+
+	dlg = dlg_get_msg_dialog(msg);
+	if(dlg==NULL) {
+		return 1;
+	}
+	pval = get_dlg_variable(dlg, name);
+	if(pval==NULL || pval->s==NULL) {
+		return 1;
+	}
+	return -1;
+}
+
 /**
  *
  */
@@ -2053,6 +2084,16 @@ static sr_kemi_t sr_kemi_dialog_exports[] = {
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
+	{ str_init("dialog"), str_init("var_rm"),
+		SR_KEMIP_XVAL, ki_dlg_var_rm,
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init("dialog"), str_init("var_is_null"),
+		SR_KEMIP_XVAL, ki_dlg_var_is_null,
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
 
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
 };




More information about the sr-dev mailing list