summaryrefslogtreecommitdiff
path: root/radsecproxy/hash.h
diff options
context:
space:
mode:
authorSam Hartman <hartmans@debian.org>2014-08-24 13:23:12 -0400
committerSam Hartman <hartmans@debian.org>2014-08-24 13:23:12 -0400
commit25541859118c92a6497b52bba46c6bc4e582fcb2 (patch)
tree6eb7faaa084ef9251b7c9805fc391b46e1aa8bf1 /radsecproxy/hash.h
Import libradsec_0.0.5.orig.tar.gz
[dgit import orig libradsec_0.0.5.orig.tar.gz]
Diffstat (limited to 'radsecproxy/hash.h')
-rw-r--r--radsecproxy/hash.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/radsecproxy/hash.h b/radsecproxy/hash.h
new file mode 100644
index 0000000..90ba64b
--- /dev/null
+++ b/radsecproxy/hash.h
@@ -0,0 +1,51 @@
+/* Copyright (c) 2008, UNINETT AS */
+/* See LICENSE for licensing information. */
+
+#ifndef SYS_SOLARIS9
+#include <stdint.h>
+#endif
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+struct hash {
+ struct list *hashlist;
+ pthread_mutex_t mutex;
+};
+
+struct hash_entry {
+ void *key;
+ uint32_t keylen;
+ void *data;
+ struct list_node *next; /* used when walking through hash */
+};
+
+/* allocates and initialises hash structure; returns NULL if malloc fails */
+struct hash *hash_create();
+
+/* frees all memory associated with the hash */
+void hash_destroy(struct hash *hash);
+
+/* insert entry in hash; returns 1 if ok, 0 if malloc fails */
+int hash_insert(struct hash *hash, void *key, uint32_t keylen, void *data);
+
+/* reads entry from hash */
+void *hash_read(struct hash *hash, void *key, uint32_t keylen);
+
+/* extracts (read and remove) entry from hash */
+void *hash_extract(struct hash *hash, void *key, uint32_t keylen);
+
+/* returns first entry */
+struct hash_entry *hash_first(struct hash *hash);
+
+/* returns the next entry after the argument */
+struct hash_entry *hash_next(struct hash_entry *entry);
+
+#if defined (__cplusplus)
+}
+#endif
+
+/* Local Variables: */
+/* c-file-style: "stroustrup" */
+/* End: */