Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / rp-l2tp / libevent / hash.h
blob6169c6ee83741e9647bc29f781679ace78795e15
1 /***********************************************************************
3 * hash.h
5 * Hash table utilities
7 * Copyright (C) 2002 Roaring Penguin Software Inc.
9 * LIC: GPL
11 ***********************************************************************/
13 #ifndef HASH_H
14 #define HASH_H
16 #include <stdlib.h>
17 /* Fixed-size hash tables for now */
18 #define HASHTAB_SIZE 67
20 /* A hash bucket */
21 typedef struct hash_bucket_t {
22 struct hash_bucket_t *next;
23 struct hash_bucket_t *prev;
24 unsigned int hashval;
25 } hash_bucket;
27 /* A hash table */
28 typedef struct hash_table_t {
29 hash_bucket *buckets[HASHTAB_SIZE];
30 size_t hash_offset;
31 unsigned int (*compute_hash)(void *data);
32 int (*compare)(void *item1, void *item2);
33 size_t num_entries;
34 } hash_table;
36 /* Functions */
37 void hash_init(hash_table *tab,
38 size_t hash_offset,
39 unsigned int (*compute)(void *data),
40 int (*compare)(void *item1, void *item2));
41 void hash_insert(hash_table *tab, void *item);
42 void hash_remove(hash_table *tab, void *item);
43 void *hash_find(hash_table *tab, void *item);
44 void *hash_find_next(hash_table *tab, void *item);
45 size_t hash_num_entries(hash_table *tab);
47 /* Iteration functions */
48 void *hash_start(hash_table *tab, void **cursor);
49 void *hash_next(hash_table *tab, void **cursor);
51 /* Utility function: hashpjw for strings */
52 unsigned int hash_pjw(char const *str);
54 #endif