]> jfr.im git - irc/quakenet/snircd.git/blame - include/hash.h
Import of u2_10_12_08
[irc/quakenet/snircd.git] / include / hash.h
CommitLineData
189935b1 1/*
2 * IRC - Internet Relay Chat, include/hash.h
3 * Copyright (C) 1998 by Andrea "Nemesi" Cocito
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 1, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19/** @file
20 * @brief Hash table management APIs.
21 * @version $Id: hash.h,v 1.7 2005/03/30 03:48:22 entrope Exp $
22 */
23
24#ifndef INCLUDED_hash_h
25#define INCLUDED_hash_h
26
27struct Client;
28struct Channel;
29struct StatDesc;
30
31/*
32 * general defines
33 */
34
35/** Size of client and channel hash tables.
36 * Both must be of the same size.
37 */
38#define HASHSIZE 32000
39
40/*
41 * Structures
42 */
43
44/*
45 * Macros for internal use
46 */
47
48/*
49 * Externally visible pseudofunctions (macro interface to internal functions)
50 */
51
52/* Raw calls, expect a core if you pass a NULL or zero-length name */
53/** Search for a channel by name. */
54#define SeekChannel(name) hSeekChannel((name))
55/** Search for any client by name. */
56#define SeekClient(name) hSeekClient((name), ~0)
57/** Search for a registered user by name. */
58#define SeekUser(name) hSeekClient((name), (STAT_USER))
59/** Search for a server by name. */
60#define SeekServer(name) hSeekClient((name), (STAT_ME | STAT_SERVER))
61
62/* Safer macros with sanity check on name, WARNING: these are _macros_,
63 no side effects allowed on <name> ! */
64/** Search for a channel by name. */
65#define FindChannel(name) (BadPtr((name)) ? 0 : SeekChannel(name))
66/** Search for any client by name. */
67#define FindClient(name) (BadPtr((name)) ? 0 : SeekClient(name))
68/** Search for a registered user by name. */
69#define FindUser(name) (BadPtr((name)) ? 0 : SeekUser(name))
70/** Search for a server by name. */
71#define FindServer(name) (BadPtr((name)) ? 0 : SeekServer(name))
72
73/*
74 * Proto types
75 */
76
77extern void init_hash(void); /* Call me on startup */
78extern int hAddClient(struct Client *cptr);
79extern int hAddChannel(struct Channel *chptr);
80extern int hRemClient(struct Client *cptr);
81extern int hChangeClient(struct Client *cptr, const char *newname);
82extern int hRemChannel(struct Channel *chptr);
83extern struct Client *hSeekClient(const char *name, int TMask);
84extern struct Channel *hSeekChannel(const char *name);
85
86extern int m_hash(struct Client *cptr, struct Client *sptr, int parc, char *parv[]);
87
88extern int isNickJuped(const char *nick);
89extern int addNickJupes(const char *nicks);
90extern void clearNickJupes(void);
91extern void stats_nickjupes(struct Client* to, const struct StatDesc* sd,
92 char* param);
93extern void list_next_channels(struct Client *cptr);
94
95#endif /* INCLUDED_hash_h */