1 /*
2  *  ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3  *
4  *  Copyright (c) 1997-2021 ircd-hybrid development team
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19  *  USA
20  */
21 
22 /*! \file hash.h
23  * \brief A header for the ircd hashtable code.
24  * \version $Id: hash.h 9858 2021-01-01 04:43:42Z michael $
25  */
26 
27 #ifndef INCLUDED_hash_h
28 #define INCLUDED_hash_h
29 
30 #define FNV1_32_INIT 0x811c9dc5
31 #define FNV1_32_BITS 16
32 #define FNV1_32_SIZE (1 << FNV1_32_BITS)  /* 2^16 = 65536 */
33 #define HASHSIZE FNV1_32_SIZE
34 
35 struct Client;
36 struct Channel;
37 
38 enum
39 {
40   HASH_TYPE_ID,
41   HASH_TYPE_CLIENT,
42   HASH_TYPE_CHANNEL
43 };
44 
45 extern void hash_add_client(struct Client *);
46 extern void hash_del_client(struct Client *);
47 extern void hash_add_channel(struct Channel *);
48 extern void hash_del_channel(struct Channel *);
49 extern void hash_add_id(struct Client *);
50 extern void hash_del_id(struct Client *);
51 
52 extern struct Client *hash_find_id(const char *);
53 extern struct Client *hash_find_client(const char *);
54 extern struct Client *hash_find_server(const char *);
55 extern struct Channel *hash_find_channel(const char *);
56 extern void *hash_get_bucket(int, unsigned int);
57 
58 extern void free_list_task(struct Client *);
59 extern void safe_list_channels(struct Client *, bool);
60 
61 extern unsigned int strhash(const char *);
62 #endif  /* INCLUDED_hash_h */
63