summaryrefslogtreecommitdiff
path: root/code/ecp/htable/htable.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2018-01-11 21:28:22 +0100
committerUros Majstorovic <majstor@majstor.org>2018-01-11 21:28:22 +0100
commit0d0e9facfcea3cf96da3b63285865182fdd5477e (patch)
treecca42e7aab184cad981c794073a4376aa2616193 /code/ecp/htable/htable.c
parent05e11f491b84a110b9ca08612df370b91e9bdcbc (diff)
refatoring dirs
Diffstat (limited to 'code/ecp/htable/htable.c')
-rw-r--r--code/ecp/htable/htable.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/code/ecp/htable/htable.c b/code/ecp/htable/htable.c
new file mode 100644
index 0000000..6330ef8
--- /dev/null
+++ b/code/ecp/htable/htable.c
@@ -0,0 +1,39 @@
+#include <core.h>
+
+#include <string.h>
+
+#include "hashtable.h"
+
+static void *h_create(ECPContext *ctx) {
+ return create_hashtable(1000, (unsigned int (*)(void *))ctx->cr.dh_pub_hash_fn, (int (*)(void *, void *))ctx->cr.dh_pub_hash_eq, NULL, NULL, NULL);
+}
+
+static void h_destroy(void *h) {
+ hashtable_destroy(h);
+}
+
+static int h_insert(void *h, unsigned char *k, ECPConnection *v) {
+ int rv = hashtable_insert(h, k, v);
+ if (!rv) return ECP_ERR;
+ return ECP_OK;
+}
+
+static ECPConnection *h_remove(void *h, unsigned char *k) {
+ return hashtable_remove(h, k);
+}
+
+static ECPConnection *h_search(void *h, unsigned char *k) {
+ return hashtable_search(h, k);
+}
+
+#ifdef ECP_WITH_HTABLE
+int ecp_htable_init(ECPHTableIface *h) {
+ h->init = 1;
+ h->create = h_create;
+ h->destroy = h_destroy;
+ h->insert = h_insert;
+ h->remove = h_remove;
+ h->search = h_search;
+ return ECP_OK;
+}
+#endif \ No newline at end of file