Only seed database for Debian install if we're using default config
[onak.git] / hash.h
1 /*
2  * hash.h - hashing routines mainly used for caching key details.
3  *
4  * Jonathan McDowell <noodles@earth.li>
5  *
6  * Copyright 2000-2002 Project Purple
7  */
8
9 #ifndef __HASH_H__
10 #define __HASH_H__
11
12 #include "keystructs.h"
13 #include "ll.h"
14
15 #define HASHSIZE 1024
16 #define HASHMASK 0x3FF
17
18 /**
19  *      inithash - Initialize the hash ready for use.
20  *
21  *      This function prepares the hash ready for use. It should be called
22  *      before any of the functions below are used.
23  */
24 void inithash(void);
25
26 /**
27  *      destroyhash - Clean up the hash after use.
28  *
29  *      This function destroys the hash after use, freeing any memory that was
30  *      used during its lifetime.
31  */
32 void destroyhash(void);
33
34 /**
35  *      addtohash - Adds a key to the hash.
36  *      @key: The key to add.
37  *
38  *      Takes a key and stores it in the hash.
39  */
40 void addtohash(struct stats_key *key);
41
42 /**
43  *      createandaddtohash - Creates a key and adds it to the hash.
44  *      @keyid: The key to create and add.
45  *
46  *      Takes a key, checks if it exists in the hash and if not creates it
47  *      and adds it to the hash. Returns the key from the hash whether it
48  *      already existed or we just created it.
49  */
50 struct stats_key *createandaddtohash(uint64_t keyid);
51
52 /**
53  *      findinhash - Finds a key in the hash.
54  *      @keyid: The key we want.
55  *
56  *      Finds a key in the hash and returns it.
57  */
58 struct stats_key *findinhash(uint64_t keyid);
59
60 /**
61  *      hashelements - Returns the size of the hash
62  *
63  *      Returns the number of elements that have been loaded into the hash.
64  */
65 unsigned long hashelements(void);
66
67 /**
68  *      gethashtableentry - Returns an entry from the hash table.
69  *      @entry: The entry to return. 0 <= entry < HASHSIZE must hold.
70  *
71  *      Gets a particular entry from the hash. Useful for doing something over
72  *      all entries in the hash.
73  */
74 struct ll *gethashtableentry(unsigned int entry);
75
76 #endif /* __HASH_H__ */