[sr-dev] git:master:73fc1f94: htable: split ht_reset() cfg wrapper to allow kemi export

Daniel-Constantin Mierla miconda at gmail.com
Fri Jan 20 16:37:25 CET 2017


Module: kamailio
Branch: master
Commit: 73fc1f94919e8df5b37b3fe7cc7cebb99a3b2a4d
URL: https://github.com/kamailio/kamailio/commit/73fc1f94919e8df5b37b3fe7cc7cebb99a3b2a4d

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-01-20T16:36:41+01:00

htable: split ht_reset() cfg wrapper to allow kemi export

---

Modified: src/modules/htable/htable.c

---

Diff:  https://github.com/kamailio/kamailio/commit/73fc1f94919e8df5b37b3fe7cc7cebb99a3b2a4d.diff
Patch: https://github.com/kamailio/kamailio/commit/73fc1f94919e8df5b37b3fe7cc7cebb99a3b2a4d.patch

---

diff --git a/src/modules/htable/htable.c b/src/modules/htable/htable.c
index 3fb59c8..d04143d 100644
--- a/src/modules/htable/htable.c
+++ b/src/modules/htable/htable.c
@@ -407,9 +407,22 @@ static int ht_rm_value_re(struct sip_msg* msg, char* key, char* foo)
 	return 1;
 }
 
-static int ht_reset(struct sip_msg* msg, char* htname, char* foo)
+static int ht_reset_by_name(str *hname)
 {
 	ht_t *ht;
+	ht = ht_get_table(hname);
+	if(ht==NULL) {
+		LM_ERR("cannot get hash table [%.*s]\n", hname->len, hname->s);
+		return -1;
+	}
+	if(ht_reset_content(ht)<0)
+		return -1;
+	return 0;
+
+}
+
+static int ht_reset(struct sip_msg* msg, char* htname, char* foo)
+{
 	str sname;
 
 	if(fixup_get_svalue(msg, (gparam_t*)htname, &sname)<0 || sname.len<=0)
@@ -417,14 +430,10 @@ static int ht_reset(struct sip_msg* msg, char* htname, char* foo)
 		LM_ERR("cannot get hash table name\n");
 		return -1;
 	}
-	ht = ht_get_table(&sname);
-	if(ht==NULL)
-	{
-		LM_ERR("cannot get hash table [%.*s]\n", sname.len, sname.s);
+	if(ht_reset_by_name(&sname)<0) {
 		return -1;
 	}
-	if(ht_reset_content(ht)<0)
-		return -1;
+
 	return 1;
 }
 
@@ -1124,6 +1133,11 @@ static sr_kemi_t sr_kemi_htable_exports[] = {
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
+	{ str_init("htable"), str_init("sht_reset"),
+		SR_KEMIP_INT, ht_reset_by_name,
+		{ 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