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