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