Browse code

dialog: kemi functions to remove or test for null vars

Daniel-Constantin Mierla authored on 11/06/2019 10:10:53
Showing 1 changed files
... ...
@@ -1931,6 +1931,37 @@ static sr_kemi_xval_t* ki_dlg_var_getw(sip_msg_t *msg, str *name)
1931 1931
 /**
1932 1932
  *
1933 1933
  */
1934
+static int ki_dlg_var_rm(sip_msg_t *msg, str *name)
1935
+{
1936
+	dlg_cell_t *dlg;
1937
+
1938
+	dlg = dlg_get_msg_dialog(msg);
1939
+	set_dlg_variable_unsafe(dlg, name, NULL);
1940
+	return 1;
1941
+}
1942
+
1943
+/**
1944
+ *
1945
+ */
1946
+static int ki_dlg_var_is_null(sip_msg_t *msg, str *name)
1947
+{
1948
+	dlg_cell_t *dlg;
1949
+	str *pval;
1950
+
1951
+	dlg = dlg_get_msg_dialog(msg);
1952
+	if(dlg==NULL) {
1953
+		return 1;
1954
+	}
1955
+	pval = get_dlg_variable(dlg, name);
1956
+	if(pval==NULL || pval->s==NULL) {
1957
+		return 1;
1958
+	}
1959
+	return -1;
1960
+}
1961
+
1962
+/**
1963
+ *
1964
+ */
1934 1965
 /* clang-format off */
1935 1966
 static sr_kemi_t sr_kemi_dialog_exports[] = {
1936 1967
 	{ str_init("dialog"), str_init("dlg_manage"),
... ...
@@ -2053,6 +2084,16 @@ static sr_kemi_t sr_kemi_dialog_exports[] = {
2053 2053
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
2054 2054
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
2055 2055
 	},
2056
+	{ str_init("dialog"), str_init("var_rm"),
2057
+		SR_KEMIP_XVAL, ki_dlg_var_rm,
2058
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
2059
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
2060
+	},
2061
+	{ str_init("dialog"), str_init("var_is_null"),
2062
+		SR_KEMIP_XVAL, ki_dlg_var_is_null,
2063
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
2064
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
2065
+	},
2056 2066
 
2057 2067
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
2058 2068
 };