62f4770918c6527723e1a54feb373fdd1ee0a72b
[ircu2.10.12-pk.git] / include / hash.h
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$
22  */
23
24 #ifndef INCLUDED_hash_h
25 #define INCLUDED_hash_h
26
27 struct Client;
28 struct Channel;
29
30 /*
31  * general defines
32  */
33
34 /** Size of client and channel hash tables.
35  * Both must be of the same size.
36  */
37 #define HASHSIZE                32000
38
39 /*
40  * Structures
41  */
42
43 /*
44  * Macros for internal use
45  */
46
47 /*
48  * Externally visible pseudofunctions (macro interface to internal functions)
49  */
50
51 /* Raw calls, expect a core if you pass a NULL or zero-length name */
52 /** Search for a channel by name. */
53 #define SeekChannel(name)       hSeekChannel((name))
54 /** Search for any client by name. */
55 #define SeekClient(name)        hSeekClient((name), ~0)
56 /** Search for a registered user by name. */
57 #define SeekUser(name)          hSeekClient((name), (STAT_USER))
58 /** Search for a server by name. */
59 #define SeekServer(name)        hSeekClient((name), (STAT_ME | STAT_SERVER))
60
61 /* Safer macros with sanity check on name, WARNING: these are _macros_,
62    no side effects allowed on <name> ! */
63 /** Search for a channel by name. */
64 #define FindChannel(name)       (BadPtr((name)) ? 0 : SeekChannel(name))
65 /** Search for any client by name. */
66 #define FindClient(name)        (BadPtr((name)) ? 0 : SeekClient(name))
67 /** Search for a registered user by name. */
68 #define FindUser(name)          (BadPtr((name)) ? 0 : SeekUser(name))
69 /** Search for a server by name. */
70 #define FindServer(name)        (BadPtr((name)) ? 0 : SeekServer(name))
71
72 /*
73  * Proto types
74  */
75
76 extern void init_hash(void);    /* Call me on startup */
77 extern int hAddClient(struct Client *cptr);
78 extern int hAddChannel(struct Channel *chptr);
79 extern int hRemClient(struct Client *cptr);
80 extern int hChangeClient(struct Client *cptr, const char *newname);
81 extern int hRemChannel(struct Channel *chptr);
82 extern struct Client *hSeekClient(const char *name, int TMask);
83 extern struct Channel *hSeekChannel(const char *name);
84
85 extern int m_hash(struct Client *cptr, struct Client *sptr, int parc, char *parv[]);
86
87 extern int isNickJuped(const char *nick);
88 extern int addNickJupes(const char *nicks);
89 extern void clearNickJupes(void);
90 extern void list_next_channels(struct Client *cptr);
91
92 #endif /* INCLUDED_hash_h */