summaryrefslogtreecommitdiff
path: root/src/common/hash.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/hash.h')
-rw-r--r--src/common/hash.h30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/common/hash.h b/src/common/hash.h
index 7e2cb66..df34a7a 100644
--- a/src/common/hash.h
+++ b/src/common/hash.h
@@ -54,6 +54,14 @@
#ifndef __HSH_H__
#define __HSH_H__
+/*
+ * OPTIONAL FEATURES
+ *
+ * Features to define. You need to build both this file and
+ * the corresponding hash.c file with whatever options you set here.
+ * These affect the method signatures, so see the sections below
+ * for the actual options
+ */
/*
* ARGUMENT DOCUMENTATION
@@ -63,6 +71,7 @@
* klen: The length of the key
* val: Pointer to the value
* hi: A hashtable iterator
+ * stamp: A unix timestamp
*/
@@ -76,16 +85,15 @@ typedef struct hsh_t hsh_t;
/* Abstract type for scanning hash tables. */
typedef struct hsh_index_t hsh_index_t;
-
-/* ----------------------------------------------------------------------------------
- * FUNCS
+/* -----------------------------------------------------------------------------
+ * MAIN
*/
/*
* hsh_create : Create a hash table
* - returns an allocated hashtable
*/
-hsh_t* hsh_create(size_t klen);
+hsh_t* hsh_create();
/*
* hsh_free : Free a hash table
@@ -102,19 +110,19 @@ unsigned int hsh_count(hsh_t* ht);
* hsh_get: Retrieves a value from the hash table
* - returns the value of the entry
*/
-void* hsh_get(hsh_t* ht, const void* key);
+void* hsh_get(hsh_t* ht, const void* key, size_t klen);
/*
* hsh_set: Set a value in the hash table
* - returns 1 if the entry was added properly
*/
-int hsh_set(hsh_t* ht, const void* key, void* val);
+int hsh_set(hsh_t* ht, const void* key, size_t klen, void* val);
/*
* hsh_rem: Remove a value from the hash table
* - returns the value of the removed entry
*/
-void* hsh_rem(hsh_t* ht, const void* key);
+void* hsh_rem(hsh_t* ht, const void* key, size_t klen);
/*
* hsh_first: Start enumerating through the hash table
@@ -132,6 +140,12 @@ hsh_index_t* hsh_next(hsh_index_t* hi);
* hsh_this: While enumerating get current value
* - returns the value that the iterator currently points to
*/
-void* hsh_this(hsh_index_t* hi, const void** key);
+void* hsh_this(hsh_index_t* hi, const void** key, size_t* klen);
+
+/*
+ * This can be passed as 'klen' in any of the above functions to indicate
+ * a string-valued key, and have hash compute the length automatically.
+ */
+#define HSH_KEY_STRING (-1)
#endif /* __HSH_H__ */