aboutsummaryrefslogtreecommitdiff
path: root/src/lib/third_party/include
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2018-05-16 00:09:12 +0200
committerLuca Deri <deri@ntop.org>2018-05-16 00:09:12 +0200
commitdcdd7562f42e9e6a54a19bf471ebef80236b8845 (patch)
treec12aabe8775b4b53a24fd08f1180de7eeffc768c /src/lib/third_party/include
parent66b759ca690425aa94b88b05f5a23818dce0b4be (diff)
Implemented hash-based categories
Diffstat (limited to 'src/lib/third_party/include')
-rw-r--r--src/lib/third_party/include/hash.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/third_party/include/hash.h b/src/lib/third_party/include/hash.h
new file mode 100644
index 000000000..8862671b1
--- /dev/null
+++ b/src/lib/third_party/include/hash.h
@@ -0,0 +1,27 @@
+/* Based on https://gist.github.com/tonious/1377667 */
+
+#ifndef _HASH_H_
+#define _HASH_H_
+
+struct entry_s {
+ char *key;
+ u_int16_t value;
+ struct entry_s *next;
+};
+
+typedef struct entry_s entry_t;
+
+struct hashtable_s {
+ int size;
+ struct entry_s **table;
+};
+
+typedef struct hashtable_s hashtable_t;
+
+extern hashtable_t *ht_create( int size );
+extern int ht_hash( hashtable_t *hashtable, char *key );
+extern entry_t *ht_newpair( char *key, u_int16_t value );
+extern void ht_set( hashtable_t *hashtable, char *key, u_int16_t value );
+extern u_int16_t ht_get( hashtable_t *hashtable, char *key );
+
+#endif /* _HASH_H_ */