diff options
author | Linus Nordberg <linus@nordu.net> | 2010-11-11 10:30:35 +0100 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2010-11-11 10:30:35 +0100 |
commit | 83e82dba47aced4a93f9e431b4d8bca94c2f8517 (patch) | |
tree | 7ff1779ea924d557b6ded9bd21c0cc8a65f062dd /lib/rsp_hash.h | |
parent | f9b25cad24ec4e3e89e818457beb29cbe08eed0c (diff) |
Bringing up TLS connections working.
NOTE: Clean up of resources not yet sane. Expect resource leakages.
NOTE: Most failure cases are not handled properly. With the wind at
your back and the sun shining, it might work.
Diffstat (limited to 'lib/rsp_hash.h')
-rw-r--r-- | lib/rsp_hash.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/rsp_hash.h b/lib/rsp_hash.h new file mode 100644 index 0000000..48f54a3 --- /dev/null +++ b/lib/rsp_hash.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2008 Stig Venaas <venaas@uninett.no> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef SYS_SOLARIS9 +#include <stdint.h> +#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); + +/* Local Variables: */ +/* c-file-style: "stroustrup" */ +/* End: */ |