]>
Commit | Line | Data |
---|---|---|
85958381 VY |
1 | /*\r |
2 | * ircd-ratbox: A slightly useful ircd.\r | |
3 | * hash.h: A header for the ircd hashtable code.\r | |
4 | *\r | |
5 | * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center\r | |
6 | * Copyright (C) 1996-2002 Hybrid Development Team\r | |
7 | * Copyright (C) 2002-2005 ircd-ratbox development team\r | |
8 | *\r | |
9 | * This program is free software; you can redistribute it and/or modify\r | |
10 | * it under the terms of the GNU General Public License as published by\r | |
11 | * the Free Software Foundation; either version 2 of the License, or\r | |
12 | * (at your option) any later version.\r | |
13 | *\r | |
14 | * This program is distributed in the hope that it will be useful,\r | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of\r | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r | |
17 | * GNU General Public License for more details.\r | |
18 | *\r | |
19 | * You should have received a copy of the GNU General Public License\r | |
20 | * along with this program; if not, write to the Free Software\r | |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301\r | |
22 | * USA\r | |
23 | *\r | |
24 | * $Id: hash.h 24794 2007-12-28 02:36:59Z androsyn $\r | |
25 | */\r | |
26 | \r | |
27 | #ifndef INCLUDED_hash_h\r | |
28 | #define INCLUDED_hash_h\r | |
29 | \r | |
002bc9e8 VY |
30 | extern struct Dictionary *nd_dict;\r |
31 | \r | |
85958381 VY |
32 | extern rb_dlink_list resvTable[];\r |
33 | extern rb_dlink_list ndTable[];\r | |
34 | \r | |
35 | /* Magic value for FNV hash functions */\r | |
36 | #define FNV1_32_INIT 0x811c9dc5UL\r | |
37 | \r | |
38 | /* Client hash table size, used in hash.c/s_debug.c */\r | |
39 | #define U_MAX_BITS 17\r | |
40 | #define U_MAX (1<<U_MAX_BITS)\r | |
41 | \r | |
42 | /* Client fd hash table size, used in hash.c */\r | |
43 | #define CLI_FD_MAX 4096\r | |
44 | \r | |
45 | /* Channel hash table size, hash.c/s_debug.c */\r | |
46 | #define CH_MAX_BITS 16\r | |
47 | #define CH_MAX (1<<CH_MAX_BITS) /* 2^16 */\r | |
48 | \r | |
49 | /* hostname hash table size */\r | |
50 | #define HOST_MAX_BITS 17\r | |
51 | #define HOST_MAX (1<<HOST_MAX_BITS) /* 2^17 */\r | |
52 | \r | |
53 | /* RESV/XLINE hash table size, used in hash.c */\r | |
54 | #define R_MAX_BITS 10\r | |
55 | #define R_MAX (1<<R_MAX_BITS) /* 2^10 */\r | |
56 | \r | |
57 | \r | |
58 | #define HASH_WALK(i, max, ptr, table) for (i = 0; i < max; i++) { RB_DLINK_FOREACH(ptr, table[i].head)\r | |
59 | #define HASH_WALK_SAFE(i, max, ptr, nptr, table) for (i = 0; i < max; i++) { RB_DLINK_FOREACH_SAFE(ptr, nptr, table[i].head)\r | |
60 | #define HASH_WALK_END }\r | |
61 | \r | |
62 | typedef enum\r | |
63 | {\r | |
64 | HASH_CLIENT,\r | |
65 | HASH_ID,\r | |
66 | HASH_CHANNEL,\r | |
67 | HASH_HOSTNAME,\r | |
68 | HASH_RESV\r | |
69 | } hash_type;\r | |
70 | \r | |
71 | struct Client;\r | |
72 | struct Channel;\r | |
73 | struct ConfItem;\r | |
74 | struct cachefile;\r | |
75 | struct nd_entry;\r | |
76 | \r | |
77 | uint32_t fnv_hash_upper(const unsigned char *s, unsigned int bits, unsigned int unused);\r | |
78 | uint32_t fnv_hash(const unsigned char *s, unsigned int bits, unsigned int unused);\r | |
79 | uint32_t fnv_hash_len(const unsigned char *s, unsigned int bits, unsigned int len);\r | |
80 | uint32_t fnv_hash_upper_len(const unsigned char *s, unsigned int bits, unsigned int len);\r | |
81 | \r | |
82 | void init_hash(void);\r | |
83 | \r | |
84 | void add_to_hash(hash_type, const char *, void *);\r | |
85 | void del_from_hash(hash_type, const char *, void *);\r | |
86 | \r | |
87 | struct Client *find_any_client(const char *name);\r | |
88 | struct Client *find_client(const char *name);\r | |
89 | struct Client *find_named_client(const char *name);\r | |
90 | struct Client *find_server(struct Client *source_p, const char *name);\r | |
91 | \r | |
92 | struct Client *find_id(const char *name);\r | |
93 | \r | |
94 | struct Channel *get_or_create_channel(struct Client *client_p, const char *chname, int *isnew);\r | |
95 | struct Channel *find_channel(const char *name);\r | |
96 | \r | |
97 | rb_dlink_node *find_hostname(const char *);\r | |
98 | \r | |
99 | struct ConfItem *hash_find_resv(const char *name);\r | |
100 | void clear_resv_hash(void);\r | |
101 | \r | |
102 | void add_to_help_hash(const char *name, struct cachefile *hptr);\r | |
103 | void clear_help_hash(void);\r | |
104 | struct cachefile *hash_find_help(const char *name, int flags);\r | |
105 | \r | |
106 | void add_to_nd_hash(const char *name, struct nd_entry *nd);\r | |
107 | struct nd_entry *hash_find_nd(const char *name);\r | |
108 | \r | |
109 | void add_to_cli_fd_hash(struct Client *client_p);\r | |
110 | void del_from_cli_fd_hash(struct Client *client_p);\r | |
111 | struct Client *find_cli_fd_hash(int fd);\r | |
112 | \r | |
113 | void hash_stats(struct Client *);\r | |
114 | \r | |
115 | #endif /* INCLUDED_hash_h */\r |