]>
jfr.im git - irc/quakenet/newserv.git/blob - channel/channel.h
6 #include "../lib/flags.h"
7 #include "../lib/sstring.h"
8 #include "../irc/irc_config.h"
9 #include "../lib/array.h"
10 #include "../lib/sstring.h"
11 #include "../core/hooks.h"
12 #include "../core/error.h"
13 #include "../nick/nick.h"
18 #define CHANMODE_NOEXTMSG 0x0001
19 #define CHANMODE_TOPICLIMIT 0x0002
20 #define CHANMODE_SECRET 0x0004
21 #define CHANMODE_PRIVATE 0x0008
22 #define CHANMODE_INVITEONLY 0x0010
23 #define CHANMODE_LIMIT 0x0020
24 #define CHANMODE_KEY 0x0040
25 #define CHANMODE_MODERATE 0x0080
26 #define CHANMODE_NOCOLOUR 0x0100
27 #define CHANMODE_NOCTCP 0x0200
28 #define CHANMODE_REGONLY 0x0400
29 #define CHANMODE_DELJOINS 0x0800
30 #define CHANMODE_NOQUITMSG 0x1000
31 #define CHANMODE_NONOTICE 0x2000
33 #define CHANMODE_ALL 0x3FFF
35 #define CHANBAN_NICKEXACT 0x0001 /* Ban includes an exact nick (no wildcards) */
36 #define CHANBAN_NICKMASK 0x0002 /* Ban includes a nick mask with wildcards */
37 #define CHANBAN_NICKANY 0x0004 /* Ban is *!.. */
38 #define CHANBAN_NICKNULL 0x0008 /* Ban has no nick */
39 #define CHANBAN_USEREXACT 0x0010 /* Ban includes an exact user (no wildcards) */
40 #define CHANBAN_USERMASK 0x0020 /* Ban includes a user mask with wildcards */
41 #define CHANBAN_USERANY 0x0040 /* Ban is ..!*@.. */
42 #define CHANBAN_USERNULL 0x0080 /* Ban has no user */
43 #define CHANBAN_HOSTEXACT 0x0100 /* Ban includes an exact host */
44 #define CHANBAN_HOSTMASK 0x0200 /* Ban includes a host mask */
45 #define CHANBAN_HOSTANY 0x0400 /* Ban is ..@* */
46 #define CHANBAN_HOSTNULL 0x0800 /* Ban has no host */
47 #define CHANBAN_IP 0x1000 /* Ban could match against IP address */
48 #define CHANBAN_CIDR 0x2000 /* Ban includes a CIDR mask (e.g. 192.168.0.0/16 ) */
49 #define CHANBAN_INVALID 0x4000 /* Ban is nonsensical, i.e. has at least one really NULL component*/
50 #define CHANBAN_HIDDENHOST 0x8000 /* Ban could possibly match hidden host */
52 #define IsNoExtMsg(x) ((x)->flags & CHANMODE_NOEXTMSG)
53 #define IsTopicLimit(x) ((x)->flags & CHANMODE_TOPICLIMIT)
54 #define IsSecret(x) ((x)->flags & CHANMODE_SECRET)
55 #define IsPrivate(x) ((x)->flags & CHANMODE_PRIVATE)
56 #define IsInviteOnly(x) ((x)->flags & CHANMODE_INVITEONLY)
57 #define IsLimit(x) ((x)->flags & CHANMODE_LIMIT)
58 #define IsKey(x) ((x)->flags & CHANMODE_KEY)
59 #define IsModerated(x) ((x)->flags & CHANMODE_MODERATE)
60 #define IsNoColour(x) ((x)->flags & CHANMODE_NOCOLOUR)
61 #define IsNoCTCP(x) ((x)->flags & CHANMODE_NOCTCP)
62 #define IsRegOnly(x) ((x)->flags & CHANMODE_REGONLY)
63 #define IsDelJoins(x) ((x)->flags & CHANMODE_DELJOINS)
64 #define IsNoQuitMsg(x) ((x)->flags & CHANMODE_NOQUITMSG)
65 #define IsNoNotice(x) ((x)->flags & CHANMODE_NONOTICE)
67 #define SetNoExtMsg(x) ((x)->flags |= CHANMODE_NOEXTMSG)
68 #define SetTopicLimit(x) ((x)->flags |= CHANMODE_TOPICLIMIT)
69 #define SetSecret(x) ((x)->flags |= CHANMODE_SECRET)
70 #define SetPrivate(x) ((x)->flags |= CHANMODE_PRIVATE)
71 #define SetInviteOnly(x) ((x)->flags |= CHANMODE_INVITEONLY)
72 #define SetLimit(x) ((x)->flags |= CHANMODE_LIMIT)
73 #define SetKey(x) ((x)->flags |= CHANMODE_KEY)
74 #define SetModerated(x) ((x)->flags |= CHANMODE_MODERATE)
75 #define SetNoColour(x) ((x)->flags |= CHANMODE_NOCOLOUR)
76 #define SetNoCTCP(x) ((x)->flags |= CHANMODE_NOCTCP)
77 #define SetRegOnly(x) ((x)->flags |= CHANMODE_REGONLY)
78 #define SetDelJoins(x) ((x)->flags |= CHANMODE_DELJOINS)
79 #define SetNoQuitMsg(x) ((x)->flags |= CHANMODE_NOQUITMSG)
80 #define SetNoNotice(x) ((x)->flags |= CHANMODE_NONOTICE)
82 #define ClearNoExtMsg(x) ((x)->flags &= ~CHANMODE_NOEXTMSG)
83 #define ClearTopicLimit(x) ((x)->flags &= ~CHANMODE_TOPICLIMIT)
84 #define ClearSecret(x) ((x)->flags &= ~CHANMODE_SECRET)
85 #define ClearPrivate(x) ((x)->flags &= ~CHANMODE_PRIVATE)
86 #define ClearInviteOnly(x) ((x)->flags &= ~CHANMODE_INVITEONLY)
87 #define ClearLimit(x) ((x)->flags &= ~CHANMODE_LIMIT)
88 #define ClearKey(x) ((x)->flags &= ~CHANMODE_KEY)
89 #define ClearModerated(x) ((x)->flags &= ~CHANMODE_MODERATE)
90 #define ClearNoColour(x) ((x)->flags &= ~CHANMODE_NOCOLOUR)
91 #define ClearNoCTCP(x) ((x)->flags &= ~CHANMODE_NOCTCP)
92 #define ClearRegOnly(x) ((x)->flags &= ~CHANMODE_REGONLY)
93 #define ClearDelJoins(x) ((x)->flags &= ~CHANMODE_DELJOINS)
94 #define ClearNoQuitMsg(x) ((x)->flags &= ~CHANMODE_NOQUITMSG)
95 #define ClearNoNotice(x) ((x)->flags &= ~CHANMODE_NONOTICE)
97 #define CUMODE_OP 0x80000000
98 #define CUMODE_VOICE 0x40000000
100 #define CU_NUMERICMASK 0x3FFFFFFF
101 #define CU_MODEMASK 0xC0000000
103 #define CU_NOUSERMASK 0x0003FFFF
105 /* Maximum allowed hash search depth */
107 #define CUHASH_DEPTH 10
109 #define MAGIC_REMOTE_JOIN_TS 1270080000
111 #define CHANNELHASHSIZE 60000
112 #define MAXCHANNELEXTS 7
114 #define MODECHANGE_MODES 0x00000001
115 #define MODECHANGE_USERS 0x00000002
116 #define MODECHANGE_BANS 0x00000004
120 typedef struct chanindex
{
122 struct channel
*channel
;
123 struct chanindex
*next
;
125 void *exts
[MAXCHANNELEXTS
];
128 typedef struct chanban
{
134 struct chanban
*next
;
137 typedef struct chanuserhash
{
138 unsigned short hashsize
;
139 unsigned short totalusers
;
140 unsigned long *content
;
143 typedef struct channel
{
155 extern unsigned long nouser
;
156 extern const flag cmodeflags
[];
157 extern chanindex
*chantable
[CHANNELHASHSIZE
];
159 /* functions from channel.c */
160 int addnicktochannel(channel
*cp
, long numeric
);
161 void delnickfromchannel(channel
*cp
, long numeric
, int updateuser
);
162 void delchannel(channel
*cp
);
163 channel
*createchannel(char *name
);
164 channel
*findchannel(char *name
);
165 void addchanneltohash(channel
*cp
);
166 void removechannelfromhash(channel
*cp
);
167 void addordelnick(int hooknum
, void *arg
);
168 void onconnect(int hooknum
, void *arg
);
169 unsigned int countuniquehosts(channel
*cp
);
171 /* functions from channelhandlers.c */
172 int handleburstmsg(void *source
, int cargc
, char **cargv
);
173 int handlejoinmsg(void *source
, int cargc
, char **cargv
);
174 int handlecreatemsg(void *source
, int cargc
, char **cargv
);
175 int handlepartmsg(void *source
, int cargc
, char **cargv
);
176 int handlekickmsg(void *source
, int cargc
, char **cargv
);
177 int handletopicmsg(void *source
, int cargc
, char **cargv
);
178 int handlemodemsg(void *source
, int cargc
, char **cargv
);
179 int handleclearmodemsg(void *source
, int cargc
, char **cargv
);
180 void handlewhoischannels(int hooknum
, void *arg
);
182 /* functions from chanuserhash.c */
183 void rehashchannel(channel
*cp
);
184 int addnumerictochanuserhash(chanuserhash
*cuh
, long numeric
);
185 unsigned long *getnumerichandlefromchanhash(chanuserhash
*cuh
, long numeric
);
187 /* functions from channelalloc.c */
188 void initchannelalloc();
190 void freechan(channel
*cp
);
191 chanuserhash
*newchanuserhash(int numbuckets
);
192 void freechanuserhash(chanuserhash
*cuhp
);
193 chanban
*getchanban();
194 void freechanban(chanban
*cbp
);
195 chanindex
*getchanindex();
196 void freechanindex(chanindex
*cip
);
198 /* functions from channelbans.c */
199 chanban
*makeban(const char *mask
);
200 int banoverlap(const chanban
*bana
, const chanban
*banb
);
201 int banequal(chanban
*bana
, chanban
*banb
);
202 char *bantostring(chanban
*bp
);
203 char *bantostringdebug(chanban
*bp
);
204 void setban(channel
*cp
, const char *ban
);
205 int clearban(channel
*cp
, const char *ban
, int optional
);
206 void clearallbans(channel
*cp
);
207 int nickmatchban(nick
*np
, chanban
*bp
);
208 int nickbanned(nick
*np
, channel
*cp
);
210 /* functions from channelindex.c */
211 void initchannelindex();
212 chanindex
*findchanindex(const char *name
);
213 chanindex
*findorcreatechanindex(const char *name
);
214 void releasechanindex(chanindex
*cip
);
215 int registerchanext(const char *name
);
216 int findchanext(const char *name
);
217 void releasechanext(int index
);
218 unsigned int nextchanmarker();