Browse code

dialog: reworked kemi export for dlg_get_var()

- return SR_KEMIP_XVAL type

Daniel-Constantin Mierla authored on 20/05/2022 14:07:56
Showing 1 changed files
... ...
@@ -1511,7 +1511,7 @@ static int fixup_dlg_bridge(void** param, int param_no)
1511 1511
 	return 0;
1512 1512
 }
1513 1513
 
1514
-static str *ki_dlg_get_var(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
1514
+static str *ki_dlg_get_var_helper(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
1515 1515
 {
1516 1516
 	dlg_cell_t *dlg = NULL;
1517 1517
 	unsigned int dir = 0;
... ...
@@ -1538,6 +1538,30 @@ static str *ki_dlg_get_var(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
1538 1538
 	return val;
1539 1539
 }
1540 1540
 
1541
+/**
1542
+ *
1543
+ */
1544
+static sr_kemi_xval_t _sr_kemi_dialog_xval = {0};
1545
+
1546
+static sr_kemi_xval_t *ki_dlg_get_var(sip_msg_t *msg, str *sc, str *sf, str *st, str *key)
1547
+{
1548
+	str *val = NULL;
1549
+
1550
+	memset(&_sr_kemi_dialog_xval, 0, sizeof(sr_kemi_xval_t));
1551
+
1552
+	val = ki_dlg_get_var_helper(msg, &sc, &sf, &st, &k);
1553
+	if(!val) {
1554
+		sr_kemi_xval_null(&_sr_kemi_dialog_xval, SR_KEMI_XVAL_NULL_NONE);
1555
+		return &_sr_kemi_dialog_xval;
1556
+	}
1557
+
1558
+	_sr_kemi_dialog_xval.vtype = SR_KEMIP_STR;
1559
+	_sr_kemi_dialog_xval.v.s = *pval;
1560
+
1561
+	return &_sr_kemi_dialog_xval;
1562
+
1563
+}
1564
+
1541 1565
 static int w_dlg_get_var(struct sip_msg *msg, char *ci, char *ft, char *tt, char *key, char *pv)
1542 1566
 {
1543 1567
 	str sc = STR_NULL;
... ...
@@ -1582,7 +1606,7 @@ static int w_dlg_get_var(struct sip_msg *msg, char *ci, char *ft, char *tt, char
1582 1606
 		return -1;
1583 1607
 	}
1584 1608
 	dst_pv = (pv_spec_t *)pv;
1585
-	val = ki_dlg_get_var(msg, &sc, &sf, &st, &k);
1609
+	val = ki_dlg_get_var_helper(msg, &sc, &sf, &st, &k);
1586 1610
 	if(val) {
1587 1611
 		memset(&dst_val, 0, sizeof(pv_value_t));
1588 1612
 		dst_val.flags |= PV_VAL_STR;
... ...
@@ -2155,11 +2179,6 @@ static int ki_dlg_var_sets(sip_msg_t *msg, str *name, str *val)
2155 2179
 	return (ret==0)?1:ret;
2156 2180
 }
2157 2181
 
2158
-/**
2159
- *
2160
- */
2161
-static sr_kemi_xval_t _sr_kemi_dialog_xval = {0};
2162
-
2163 2182
 /**
2164 2183
  *
2165 2184
  */
... ...
@@ -2289,7 +2308,7 @@ static sr_kemi_t sr_kemi_dialog_exports[] = {
2289 2308
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
2290 2309
 	},
2291 2310
 	{ str_init("dialog"), str_init("dlg_get_var"),
2292
-		SR_KEMIP_STR, ki_dlg_get_var,
2311
+		SR_KEMIP_XVAL, ki_dlg_get_var,
2293 2312
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR,
2294 2313
 			SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE }
2295 2314
 	},