diff options
Diffstat (limited to 'ecp/src/ecp/htable/htable.c')
-rw-r--r-- | ecp/src/ecp/htable/htable.c | 56 |
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); +} |