summaryrefslogtreecommitdiff
path: root/ecp/src/ecp/htable/htable.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2022-04-08 04:41:46 +0200
committerUros Majstorovic <majstor@majstor.org>2022-04-08 04:41:46 +0200
commiteb4833fc5dddd755c974f5ac7a8b4829c95ffa7b (patch)
treeb7afa21ea22a94519e0c0628b0330a05d66d9c3a /ecp/src/ecp/htable/htable.c
parentd09e20a8a46a17524df0b737d85e9684006a4c74 (diff)
connection exire added
Diffstat (limited to 'ecp/src/ecp/htable/htable.c')
-rw-r--r--ecp/src/ecp/htable/htable.c56
1 files changed, 46 insertions, 10 deletions
diff --git a/ecp/src/ecp/htable/htable.c b/ecp/src/ecp/htable/htable.c
index bd8ab2d..c0efebb 100644
--- a/ecp/src/ecp/htable/htable.c
+++ b/ecp/src/ecp/htable/htable.c
@@ -5,30 +5,66 @@
#include <tr.h>
#include <ht.h>
-#include "hashtable.h"
-
-void *ecp_ht_create_keys(void) {
+ecp_ht_table_t *ecp_ht_create_keys(void) {
return hashtable_create(1000, (unsigned int (*)(void *))ecp_ecdh_pub_hash, (int (*)(void *, void *))ecp_ecdh_pub_eq);
}
-void *ecp_ht_create_addrs(void) {
+ecp_ht_table_t *ecp_ht_create_addrs(void) {
return hashtable_create(1000, (unsigned int (*)(void *))ecp_tr_addr_hash, (int (*)(void *, void *))ecp_tr_addr_eq);
}
-void ecp_ht_destroy(void *h) {
+void ecp_ht_destroy(ecp_ht_table_t *h) {
hashtable_destroy(h, 0);
}
-int ecp_ht_insert(void *h, void *k, ECPConnection *v) {
- int rv = hashtable_insert(h, k, v);
- if (!rv) return ECP_ERR;
+int ecp_ht_insert(ecp_ht_table_t *h, void *k, ECPConnection *v) {
+ int rv;
+
+ rv = hashtable_insert(h, k, v);
+ if (rv == 0) return ECP_ERR;
return ECP_OK;
}
-ECPConnection *ecp_ht_remove(void *h, void *k) {
+ECPConnection *ecp_ht_remove(ecp_ht_table_t *h, void *k) {
return hashtable_remove(h, k);
}
-ECPConnection *ecp_ht_search(void *h, void *k) {
+ECPConnection *ecp_ht_search(ecp_ht_table_t *h, void *k) {
return hashtable_search(h, k);
}
+
+void ecp_ht_itr_create(ecp_ht_itr_t *i, ecp_ht_table_t *h) {
+ hashtable_iterator(i, h);
+}
+
+int ecp_ht_itr_advance(ecp_ht_itr_t *i) {
+ int rv;
+
+ rv = hashtable_iterator_advance(i);
+ if (rv == 0) return ECP_ITR_END;
+ return rv;
+}
+
+int ecp_ht_itr_remove(ecp_ht_itr_t *i) {
+ int rv;
+
+ rv = hashtable_iterator_remove(i);
+ if (rv == 0) return ECP_ITR_END;
+ return ECP_OK;
+}
+
+int ecp_ht_itr_search(ecp_ht_itr_t *i, void *k) {
+ int rv;
+
+ rv = hashtable_iterator_search(i, k);
+ if (rv == 0) return ECP_ERR;
+ return ECP_OK;
+}
+
+void *ecp_ht_itr_key(ecp_ht_itr_t *i) {
+ return hashtable_iterator_key(i);
+}
+
+ECPConnection *ecp_ht_itr_value(ecp_ht_itr_t *i) {
+ return hashtable_iterator_value(i);
+}