]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * ircd-ratbox: A slightly useful ircd. | |
3 | * hash.h: A header for the ircd hashtable code. | |
4 | * | |
5 | * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center | |
6 | * Copyright (C) 1996-2002 Hybrid Development Team | |
7 | * Copyright (C) 2002-2004 ircd-ratbox development team | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
22 | * USA | |
23 | * | |
f42e9ceb | 24 | * $Id: hash.h 3177 2007-02-01 00:19:14Z jilles $ |
212380e3 AC |
25 | */ |
26 | ||
27 | #ifndef INCLUDED_hash_h | |
28 | #define INCLUDED_hash_h | |
29 | ||
30 | #include "tools.h" | |
31 | ||
b37021a4 AC |
32 | struct Dictionary; |
33 | ||
5b96d9a6 AC |
34 | extern rb_dlink_list *clientTable; |
35 | extern rb_dlink_list *channelTable; | |
36 | extern rb_dlink_list *idTable; | |
37 | extern rb_dlink_list *resvTable; | |
38 | extern rb_dlink_list *hostTable; | |
39 | extern rb_dlink_list *helpTable; | |
b37021a4 AC |
40 | |
41 | extern struct Dictionary *nd_dict; | |
212380e3 AC |
42 | |
43 | /* Magic value for FNV hash functions */ | |
44 | #define FNV1_32_INIT 0x811c9dc5UL | |
45 | ||
46 | /* Client hash table size, used in hash.c/s_debug.c */ | |
1cda7a9c | 47 | #define U_MAX_BITS 17 |
212380e3 AC |
48 | #define U_MAX 131072 /* 2^17 */ |
49 | ||
50 | /* Channel hash table size, hash.c/s_debug.c */ | |
1cda7a9c | 51 | #define CH_MAX_BITS 16 |
212380e3 AC |
52 | #define CH_MAX 65536 /* 2^16 */ |
53 | ||
54 | /* hostname hash table size */ | |
1cda7a9c | 55 | #define HOST_MAX_BITS 17 |
212380e3 AC |
56 | #define HOST_MAX 131072 /* 2^17 */ |
57 | ||
58 | /* RESV/XLINE hash table size, used in hash.c */ | |
1cda7a9c | 59 | #define R_MAX_BITS 10 |
212380e3 AC |
60 | #define R_MAX 1024 /* 2^10 */ |
61 | ||
62 | ||
5b96d9a6 AC |
63 | #define HASH_WALK(i, max, ptr, table) for (i = 0; i < max; i++) { RB_DLINK_FOREACH(ptr, table[i].head) |
64 | #define HASH_WALK_SAFE(i, max, ptr, nptr, table) for (i = 0; i < max; i++) { RB_DLINK_FOREACH_SAFE(ptr, nptr, table[i].head) | |
212380e3 AC |
65 | #define HASH_WALK_END } |
66 | ||
67 | struct Client; | |
68 | struct Channel; | |
69 | struct ConfItem; | |
70 | struct cachefile; | |
71 | struct nd_entry; | |
72 | ||
73 | extern u_int32_t fnv_hash_upper(const unsigned char *s, int bits); | |
74 | extern u_int32_t fnv_hash(const unsigned char *s, int bits); | |
75 | extern u_int32_t fnv_hash_len(const unsigned char *s, int bits, int len); | |
76 | extern u_int32_t fnv_hash_upper_len(const unsigned char *s, int bits, int len); | |
77 | ||
78 | extern void init_hash(void); | |
79 | ||
80 | extern void add_to_client_hash(const char *name, struct Client *client); | |
81 | extern void del_from_client_hash(const char *name, struct Client *client); | |
212380e3 AC |
82 | extern struct Client *find_client(const char *name); |
83 | extern struct Client *find_named_client(const char *name); | |
84 | extern struct Client *find_server(struct Client *source_p, const char *name); | |
85 | ||
86 | extern void add_to_id_hash(const char *, struct Client *); | |
87 | extern void del_from_id_hash(const char *name, struct Client *client); | |
88 | extern struct Client *find_id(const char *name); | |
89 | ||
90 | extern struct Channel *get_or_create_channel(struct Client *client_p, const char *chname, int *isnew); | |
91 | extern void del_from_channel_hash(const char *name, struct Channel *chan); | |
92 | extern struct Channel *find_channel(const char *name); | |
93 | ||
94 | extern void add_to_hostname_hash(const char *, struct Client *); | |
95 | extern void del_from_hostname_hash(const char *, struct Client *); | |
5b96d9a6 | 96 | extern rb_dlink_node *find_hostname(const char *); |
212380e3 AC |
97 | |
98 | extern void add_to_resv_hash(const char *name, struct ConfItem *aconf); | |
99 | extern void del_from_resv_hash(const char *name, struct ConfItem *aconf); | |
100 | extern struct ConfItem *hash_find_resv(const char *name); | |
101 | extern void clear_resv_hash(void); | |
102 | ||
212380e3 AC |
103 | extern void hash_stats(struct Client *); |
104 | ||
105 | #endif /* INCLUDED_hash_h */ |