]>
jfr.im git - irc/rqf/shadowircd.git/blob - include/hash.h
2 * ircd-ratbox: A slightly useful ircd.
3 * hash.h: A header for the ircd hashtable code.
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
24 * $Id: hash.h 24794 2007-12-28 02:36:59Z androsyn $
27 #ifndef INCLUDED_hash_h
28 #define INCLUDED_hash_h
30 extern struct Dictionary
*nd_dict
;
32 extern rb_dlink_list resvTable
[];
33 extern rb_dlink_list ndTable
[];
35 /* Magic value for FNV hash functions */
36 #define FNV1_32_INIT 0x811c9dc5UL
38 /* Client hash table size, used in hash.c/s_debug.c */
40 #define U_MAX (1<<U_MAX_BITS)
42 /* Client fd hash table size, used in hash.c */
43 #define CLI_FD_MAX 4096
45 /* Channel hash table size, hash.c/s_debug.c */
46 #define CH_MAX_BITS 16
47 #define CH_MAX (1<<CH_MAX_BITS) /* 2^16 */
49 /* hostname hash table size */
50 #define HOST_MAX_BITS 17
51 #define HOST_MAX (1<<HOST_MAX_BITS) /* 2^17 */
53 /* RESV/XLINE hash table size, used in hash.c */
55 #define R_MAX (1<<R_MAX_BITS) /* 2^10 */
58 #define HASH_WALK(i, max, ptr, table) for (i = 0; i < max; i++) { RB_DLINK_FOREACH(ptr, table[i].head)
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)
60 #define HASH_WALK_END }
77 uint32_t fnv_hash_upper(const unsigned char *s
, unsigned int bits
, unsigned int unused
);
78 uint32_t fnv_hash(const unsigned char *s
, unsigned int bits
, unsigned int unused
);
79 uint32_t fnv_hash_len(const unsigned char *s
, unsigned int bits
, unsigned int len
);
80 uint32_t fnv_hash_upper_len(const unsigned char *s
, unsigned int bits
, unsigned int len
);
84 void add_to_hash(hash_type
, const char *, void *);
85 void del_from_hash(hash_type
, const char *, void *);
87 struct Client
*find_any_client(const char *name
);
88 struct Client
*find_client(const char *name
);
89 struct Client
*find_named_client(const char *name
);
90 struct Client
*find_server(struct Client
*source_p
, const char *name
);
92 struct Client
*find_id(const char *name
);
94 struct Channel
*get_or_create_channel(struct Client
*client_p
, const char *chname
, int *isnew
);
95 struct Channel
*find_channel(const char *name
);
97 rb_dlink_node
*find_hostname(const char *);
99 struct ConfItem
*hash_find_resv(const char *name
);
100 void clear_resv_hash(void);
102 void add_to_help_hash(const char *name
, struct cachefile
*hptr
);
103 void clear_help_hash(void);
104 struct cachefile
*hash_find_help(const char *name
, int flags
);
106 void add_to_nd_hash(const char *name
, struct nd_entry
*nd
);
107 struct nd_entry
*hash_find_nd(const char *name
);
109 void add_to_cli_fd_hash(struct Client
*client_p
);
110 void del_from_cli_fd_hash(struct Client
*client_p
);
111 struct Client
*find_cli_fd_hash(int fd
);
113 void hash_stats(struct Client
*);
115 #endif /* INCLUDED_hash_h */