WIP: Fix the Proxy-State issue.
[libradsec.git] / hash.h
1 /* Copyright (c) 2008, UNINETT AS */
2 /* See LICENSE for licensing information. */
3
4 #ifndef SYS_SOLARIS9
5 #include <stdint.h>
6 #endif
7
8 struct hash {
9     struct list *hashlist;
10     pthread_mutex_t mutex;
11 };
12
13 struct hash_entry {
14     void *key;
15     uint32_t keylen;
16     void *data;
17     struct list_node *next; /* used when walking through hash */
18 };
19
20 /* allocates and initialises hash structure; returns NULL if malloc fails */
21 struct hash *hash_create();
22
23 /* frees all memory associated with the hash */
24 void hash_destroy(struct hash *hash);
25
26 /* insert entry in hash; returns 1 if ok, 0 if malloc fails */
27 int hash_insert(struct hash *hash, void *key, uint32_t keylen, void *data);
28
29 /* reads entry from hash */
30 void *hash_read(struct hash *hash, void *key, uint32_t keylen);
31
32 /* extracts (read and remove) entry from hash */
33 void *hash_extract(struct hash *hash, void *key, uint32_t keylen);
34
35 /* returns first entry */
36 struct hash_entry *hash_first(struct hash *hash);
37
38 /* returns the next entry after the argument */
39 struct hash_entry *hash_next(struct hash_entry *entry);
40
41 /* Local Variables: */
42 /* c-file-style: "stroustrup" */
43 /* End: */