]> jfr.im git - solanum.git/blame - include/hash.h
Explanatory comment for LFLAGS_FAKE
[solanum.git] / include / hash.h
CommitLineData
ae78a571
VY
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
ae78a571
VY
23 */
24
25#ifndef INCLUDED_hash_h
26#define INCLUDED_hash_h
27
4177311e
EM
28#include "rb_dictionary.h"
29#include "rb_radixtree.h"
ae78a571 30
4177311e 31extern rb_dictionary *nd_dict;
2fc6772e
EM
32extern rb_radixtree *resv_tree;
33extern rb_radixtree *channel_tree;
ae78a571
VY
34
35/* Magic value for FNV hash functions */
36#define FNV1_32_INIT 0x811c9dc5UL
37
38/* Client hash table size, used in hash.c/s_debug.c */
39#define U_MAX_BITS 17
40#define U_MAX 131072 /* 2^17 */
41
b5b4a0e7
AC
42/* Client connid hash table size, used in hash.c */
43#define CLI_CONNID_MAX 4096
c6d72037 44
ae78a571
VY
45/* Channel hash table size, hash.c/s_debug.c */
46#define CH_MAX_BITS 16
47#define CH_MAX 65536 /* 2^16 */
48
49/* hostname hash table size */
50#define HOST_MAX_BITS 17
51#define HOST_MAX 131072 /* 2^17 */
52
53/* RESV/XLINE hash table size, used in hash.c */
54#define R_MAX_BITS 10
55#define R_MAX 1024 /* 2^10 */
56
57
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 }
61
62struct Client;
63struct Channel;
64struct ConfItem;
65struct cachefile;
66struct nd_entry;
67
2e45f5d8
MU
68extern uint32_t fnv_hash_upper(const unsigned char *s, int bits);
69extern uint32_t fnv_hash(const unsigned char *s, int bits);
70extern uint32_t fnv_hash_len(const unsigned char *s, int bits, int len);
71extern uint32_t fnv_hash_upper_len(const unsigned char *s, int bits, int len);
ae78a571
VY
72
73extern void init_hash(void);
74
75extern void add_to_client_hash(const char *name, struct Client *client);
76extern void del_from_client_hash(const char *name, struct Client *client);
77extern struct Client *find_client(const char *name);
78extern struct Client *find_named_client(const char *name);
79extern struct Client *find_server(struct Client *source_p, const char *name);
80
81extern void add_to_id_hash(const char *, struct Client *);
82extern void del_from_id_hash(const char *name, struct Client *client);
83extern struct Client *find_id(const char *name);
84
aa7eff28 85extern struct Channel *get_or_create_channel(struct Client *client_p, const char *chname, bool *isnew);
ae78a571
VY
86extern void del_from_channel_hash(const char *name, struct Channel *chan);
87extern struct Channel *find_channel(const char *name);
88
89extern void add_to_hostname_hash(const char *, struct Client *);
90extern void del_from_hostname_hash(const char *, struct Client *);
91extern rb_dlink_node *find_hostname(const char *);
92
93extern void add_to_resv_hash(const char *name, struct ConfItem *aconf);
94extern void del_from_resv_hash(const char *name, struct ConfItem *aconf);
95extern struct ConfItem *hash_find_resv(const char *name);
96extern void clear_resv_hash(void);
97
de7cf7e0
AC
98void add_to_cli_connid_hash(struct Client *client_p, uint32_t id);
99void del_from_cli_connid_hash(uint32_t id);
5c7c7d65 100struct Client *find_cli_connid_hash(uint32_t connid);
b5b4a0e7 101
ae78a571 102#endif /* INCLUDED_hash_h */