[sr-dev] git:master:8960972b: htable: exported iterator functions to kemi framework

Daniel-Constantin Mierla miconda at gmail.com
Tue Apr 18 14:08:34 CEST 2017


Module: kamailio
Branch: master
Commit: 8960972b2ad5d460ed494b24a3bba1cb118e8b1f
URL: https://github.com/kamailio/kamailio/commit/8960972b2ad5d460ed494b24a3bba1cb118e8b1f

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-04-17T20:27:01+02:00

htable: exported iterator functions to kemi framework

---

Modified: src/modules/htable/htable.c

---

Diff:  https://github.com/kamailio/kamailio/commit/8960972b2ad5d460ed494b24a3bba1cb118e8b1f.diff
Patch: https://github.com/kamailio/kamailio/commit/8960972b2ad5d460ed494b24a3bba1cb118e8b1f.patch

---

diff --git a/src/modules/htable/htable.c b/src/modules/htable/htable.c
index 1876b28..18a3ab8 100644
--- a/src/modules/htable/htable.c
+++ b/src/modules/htable/htable.c
@@ -458,6 +458,18 @@ static int w_ht_iterator_start(struct sip_msg* msg, char* iname, char* hname)
 	return 1;
 }
 
+static int ki_ht_iterator_start(sip_msg_t *msg, str *iname, str *hname)
+{
+	if(iname==NULL || iname->s==NULL || iname->len<=0
+			|| hname==NULL || hname->s==NULL || hname->len<=0) {
+		LM_ERR("invalid parameters\n");
+		return -1;
+	}
+	if(ht_iterator_start(iname, hname)<0)
+		return -1;
+	return 1;
+}
+
 static int w_ht_iterator_next(struct sip_msg* msg, char* iname, char* foo)
 {
 	str siname;
@@ -472,6 +484,17 @@ static int w_ht_iterator_next(struct sip_msg* msg, char* iname, char* foo)
 	return 1;
 }
 
+static int ki_ht_iterator_next(sip_msg_t *msg, str *iname)
+{
+	if(iname==NULL || iname->s==NULL || iname->len<=0) {
+		LM_ERR("invalid parameters\n");
+		return -1;
+	}
+	if(ht_iterator_next(iname)<0)
+		return -1;
+	return 1;
+}
+
 static int w_ht_iterator_end(struct sip_msg* msg, char* iname, char* foo)
 {
 	str siname;
@@ -486,6 +509,17 @@ static int w_ht_iterator_end(struct sip_msg* msg, char* iname, char* foo)
 	return 1;
 }
 
+static int ki_ht_iterator_end(sip_msg_t *msg, str *iname)
+{
+	if(iname==NULL || iname->s==NULL || iname->len<=0) {
+		LM_ERR("invalid parameters\n");
+		return -1;
+	}
+	if(ht_iterator_end(iname)<0)
+		return -1;
+	return 1;
+}
+
 static int ki_ht_slot_xlock(sip_msg_t *msg, str *htname, str *skey, int lmode)
 {
 	ht_t *ht;
@@ -1138,6 +1172,21 @@ static sr_kemi_t sr_kemi_htable_exports[] = {
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
+	{ str_init("htable"), str_init("sht_iterator_start"),
+		SR_KEMIP_INT, ki_ht_iterator_start,
+		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init("htable"), str_init("sht_iterator_next"),
+		SR_KEMIP_INT, ki_ht_iterator_next,
+		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init("htable"), str_init("sht_iterator_end"),
+		SR_KEMIP_INT, ki_ht_iterator_end,
+		{ 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