]>
Commit | Line | Data |
---|---|---|
c86edd1d Q |
1 | /* |
2 | * chanserv.h: | |
3 | * Top level data structures and function prototypes for the | |
4 | * channel service module | |
5 | */ | |
6 | ||
7 | #ifndef __CHANSERV_H | |
8 | #define __CHANSERV_H | |
9 | ||
524d28f9 CP |
10 | #define _GNU_SOURCE |
11 | #include <string.h> | |
c86edd1d Q |
12 | #include <time.h> |
13 | #include "../lib/sstring.h" | |
4ad1cf7a | 14 | #include "../core/schedule.h" |
c86edd1d Q |
15 | #include "../lib/flags.h" |
16 | #include "../nick/nick.h" | |
17 | #include "../channel/channel.h" | |
18 | #include "../parser/parser.h" | |
19 | #include "../localuser/localuserchannel.h" | |
20 | ||
21 | #define CS_PARANOID | |
22 | ||
23 | #ifdef CS_PARANOID | |
24 | #include <assert.h> | |
25 | #endif | |
26 | ||
64f17f02 P |
27 | /* Q9 Version */ |
28 | #define QVERSION "0.80" | |
29 | ||
c86edd1d Q |
30 | /* Mini-hash of known users on channels to make lookups faster; |
31 | * how big do we make it? */ | |
32 | #define REGCHANUSERHASHSIZE 5 | |
33 | #define PASSLEN 10 | |
34 | #define WELCOMELEN 250 | |
35 | #define INFOLEN 100 | |
36 | #define AUTOLIMIT_INTERVAL 60 | |
37 | #define COUNTERSYNCINTERVAL 600 | |
38 | #define LINGERTIME 300 | |
39 | #define DUMPINTERVAL 300 | |
40 | #define EMAILLEN 60 | |
41 | #define CHANTYPES 7 | |
42 | ||
43 | /* Suspension and g-line hit count limits */ | |
44 | #define MAXGLINEUSERS 50 | |
45 | #define MAXSUSPENDHIT 500 | |
46 | ||
47 | /* Maximum number of times a user may attempt to auth */ | |
48 | #define MAXAUTHATTEMPT 3 | |
49 | ||
bd87ef68 CP |
50 | /* Maximum number of hellos in a session */ |
51 | #define MAXHELLOS 3 | |
52 | ||
c86edd1d Q |
53 | /* Maximum number of times a user may actually be authed */ |
54 | #define MAXAUTHCOUNT 2 | |
55 | ||
96e1f81d CP |
56 | /* Maximum number of accounts that may share an email address */ |
57 | #define MD_DEFAULTACTLIMIT 2 | |
58 | ||
c86edd1d Q |
59 | /* Sizes of the main hashes */ |
60 | #define REGUSERHASHSIZE 60000 | |
e3805f60 | 61 | #define MAILDOMAINHASHSIZE 60000 |
c86edd1d Q |
62 | |
63 | /* Number of languages and messages */ | |
64 | #define MAXLANG 50 | |
65 | #define MAXMESSAGES 200 | |
66 | ||
705542fa CP |
67 | /* Maximum number of user chanlevs and bans */ |
68 | #define MAXCHANLEVS 250 | |
69 | #define MAXBANS 50 | |
70 | ||
0ba70e7b CP |
71 | /* Sources of entropy and standard length defines */ |
72 | #define ENTROPYSOURCE "/dev/urandom" | |
73 | #define ENTROPYLEN 8 | |
74 | ||
c86edd1d Q |
75 | /* The list of messages */ |
76 | #define QM_PROTECTED 0 | |
77 | #define QM_UNKNOWNCMD 1 | |
78 | #define QM_SECUREONLY 2 | |
79 | #define QM_AUTHEDONLY 3 | |
80 | #define QM_UNAUTHEDONLY 4 | |
81 | #define QM_COMMANDLIST 5 | |
82 | #define QM_ENDOFLIST 6 | |
83 | #define QM_DONE 7 | |
84 | #define QM_NOTENOUGHPARAMS 8 | |
85 | #define QM_UNKNOWNCHAN 9 | |
86 | #define QM_NOACCESSONCHAN 10 | |
87 | #define QM_CURCHANFLAGS 11 | |
88 | #define QM_CURFORCEMODES 12 | |
89 | #define QM_NOACCESS 13 | |
90 | #define QM_UNKNOWNUSER 14 | |
91 | #define QM_USERNOTAUTHED 15 | |
92 | #define QM_CHANLEVHEADER 16 | |
93 | #define QM_CHANLEVCOLSHORT 17 | |
94 | #define QM_CHANLEVCOLFULL 18 | |
95 | #define QM_NOUSERSONCHANLEV 19 | |
96 | #define QM_CHANUSERFLAGS 20 | |
97 | #define QM_CHANUSERUNKNOWN 21 | |
98 | #define QM_INVALIDCHANLEVCHANGE 22 | |
99 | #define QM_USERISAUTHEDAS 23 | |
100 | #define QM_USERISHELPER 24 | |
101 | #define QM_USERISOPER 25 | |
102 | #define QM_USERISADMIN 26 | |
103 | #define QM_USERISDEV 27 | |
104 | #define QM_WHOISHEADER 28 | |
105 | #define QM_WHOISCOLS 29 | |
106 | #define QM_USERONNOCHANS 30 | |
107 | #define QM_CHANAUTOLIMIT 31 | |
108 | #define QM_CHANBANAUTOREMOVE 32 | |
109 | #define QM_NOCHANBANAUTOREMOVE 33 | |
110 | #define QM_INVALIDCHANNAME 34 | |
111 | #define QM_ALREADYREGISTERED 35 | |
112 | #define QM_CURUSERFLAGS 36 | |
113 | #define QM_WELCOMEMESSAGEIS 37 | |
114 | #define QM_GLOBALINFO 38 | |
115 | #define QM_CHANNELINFO 39 | |
116 | #define QM_PROTECTEDNICK 40 | |
117 | #define QM_NICKWASFAKED 41 | |
118 | #define QM_NOTPROTECTED 42 | |
119 | #define QM_SAMEAUTH 43 | |
120 | #define QM_AUTHFAIL 44 | |
121 | #define QM_AUTHOK 45 | |
122 | #define QM_NEWACCOUNT 46 | |
123 | #define QM_AUTHNAMEINUSE 47 | |
124 | #define QM_ALREADYONCHAN 48 | |
125 | #define QM_NOTONCHAN 49 | |
126 | #define QM_ALREADYOPPED 50 | |
127 | #define QM_USERNOTONCHAN 51 | |
128 | #define QM_USEROPPEDONCHAN 52 | |
129 | #define QM_CANTOP 53 | |
130 | #define QM_NOTOPPED 54 | |
131 | #define QM_ALREADYVOICED 55 | |
132 | #define QM_NOTVOICED 56 | |
133 | #define QM_USERVOICEDONCHAN 57 | |
134 | #define QM_REGBANHEADER 58 | |
135 | #define QM_NOBANS 59 | |
136 | #define QM_REMOVEDCHANBAN 60 | |
137 | #define QM_NOTREMOVEDPERMBAN 61 | |
138 | #define QM_REMOVEDPERMBAN 62 | |
139 | #define QM_CANTVOICE 63 | |
140 | #define QM_NOHELP 64 | |
141 | #define QM_WHOISHEADER_NICK 65 | |
142 | #define QM_WHOISHEADER_AUTH 66 | |
143 | #define QM_WHOIS_USERS 67 | |
144 | #define QM_WHOIS_LASTAUTH 68 | |
145 | #define QM_WHOIS_LASTUSERHOST 69 | |
146 | #define QM_WHOIS_USERID 70 | |
147 | #define QM_WHOIS_INFO 71 | |
148 | #define QM_WHOIS_COMMENT 72 | |
149 | #define QM_WHOIS_FLAGS 73 | |
150 | #define QM_WHOIS_CREATED 74 | |
151 | #define QM_WHOIS_CHANHEADER 75 | |
152 | #define QM_WHOIS_EMAIL 76 | |
153 | #define QM_WHOIS_EMAILSET 77 | |
154 | #define QM_COMMENT 78 | |
155 | #define QM_NOCOMMENT 79 | |
156 | #define QM_BADAUTH 80 | |
157 | #define QM_USERHASBADAUTH 81 | |
158 | #define QM_BADEMAIL 82 | |
159 | #define QM_MAILTHROTTLED 83 | |
160 | #define QM_MAILQUEUED 84 | |
161 | #define QM_PWDONTMATCH 85 | |
162 | #define QM_PWTOSHORT 86 | |
163 | #define QM_PWCHANGED 87 | |
fdedb559 | 164 | #define QM_INVALIDDURATION2 88 |
c86edd1d Q |
165 | #define QM_EMAILCHANGED 89 |
166 | #define QM_EMAILDONTMATCH 90 | |
167 | #define QM_INVALIDEMAIL 91 | |
168 | #define QM_EMAILTOOSHORT 92 | |
169 | #define QM_NOTYOUREMAIL 93 | |
170 | #define QM_EMAILNOAT 94 | |
171 | #define QM_EMAILATEND 95 | |
172 | #define QM_EMAILINVCHR 96 | |
173 | #define QM_CHANNELNOTSUSPENDED 97 | |
174 | #define QM_CHANNELALREADYSUSPENDED 98 | |
175 | #define QM_CHANTYPE 99 | |
176 | #define QM_UNKNOWNCHANTYPE 100 | |
177 | #define QM_FOUNDER 101 | |
178 | #define QM_ADDEDBY 102 | |
179 | #define QM_ALREADYKNOWNONCHAN 103 | |
180 | #define QM_CANNOTREMOVEOWNER 104 | |
181 | #define QM_CANNOTREMOVEMASTER 105 | |
182 | #define QM_UNKNOWNBAN 106 | |
183 | #define QM_YOURLANGUAGE 107 | |
184 | #define QM_LANGUAGELIST 108 | |
185 | #define QM_UNKNOWNLANGUAGE 109 | |
186 | #define QM_WHOIS_USERLANG 110 | |
187 | #define QM_CHANTYPEIS 111 | |
188 | #define QM_STATSHEADER 112 | |
189 | #define QM_STATSADDED 113 | |
190 | #define QM_STATSJOINS 114 | |
191 | #define QM_STATSLASTACTIVE 115 | |
192 | #define QM_AUTHSUSPENDED 116 | |
193 | #define QM_REASON 117 | |
194 | #define QM_EXPIRES 118 | |
195 | #define QM_TOOMANYAUTHS 119 | |
196 | #define QM_INVALIDDURATION 120 | |
197 | #define QM_DISCONNECTINGUSER 121 | |
198 | #define QM_USERALREADYSUSPENDED 122 | |
199 | #define QM_USERNOTSUSPENDED 123 | |
200 | #define QM_SPEWHEADER 124 | |
201 | #define QM_TOOMANYRESULTS 125 | |
202 | #define QM_RESULTCOUNT 126 | |
203 | #define QM_SUSPENDKILL 127 | |
204 | #define QM_LISTFLAGSHEADER 128 | |
205 | #define QM_SUSPENDUSERLISTHEADER 129 | |
206 | #define QM_SUSPENDCHANLISTHEADER 130 | |
e3805f60 P |
207 | #define QM_NOREQUESTOWNER 131 |
208 | #define QM_GRANTEDOWNER 132 | |
209 | #define QM_AUTHHISTORYHEADER 133 | |
210 | #define QM_CURDOMAINMODES 134 | |
211 | #define QM_SPEWDOMAINHEADER 135 | |
212 | #define QM_DOMAINLIMIT 136 | |
213 | #define QM_PWTOWEAK 137 | |
5a4ec14f | 214 | #define QM_GIVEOWNERNOTMASTER 138 |
215 | #define QM_GIVEOWNERALREADYOWNER 139 | |
216 | #define QM_GIVEOWNERNEEDHASH 140 | |
217 | #define QM_GIVEOWNERWRONGHASH 141 | |
aa321230 | 218 | #define QM_SHOWINGDURATION 142 |
dc9548f4 | 219 | #define QM_INVALIDACCOUNTNAME 143 |
b7a95f03 CP |
220 | #define QM_CHALLENGEBADALGORITHM 144 |
221 | #define QM_NOCHALLENGE 145 | |
8fab5f64 | 222 | #define QM_USEGIVEOWNER 146 |
95332d7b | 223 | #define QM_NOFLAGSPECIFIED 147 |
3fbc2554 CP |
224 | #define QM_NEWBANALREADYBANNED 148 |
225 | #define QM_NEWBANOVERLAPS 149 | |
226 | #define QM_REPLACINGTEMPBAN 150 | |
227 | #define QM_PERMBANALREADYSET 151 | |
189772f2 CP |
228 | #define QM_NOTREPLACINGBANLDURATION 152 |
229 | #define QM_REPLACINGBANSDURATION 153 | |
705542fa CP |
230 | #define QM_TOOMANYCHANLEVS 154 |
231 | #define QM_TOOMANYBANS 155 | |
336765cd | 232 | #define QM_WARNNOTREMOVEDPERMBAN 156 |
bd87ef68 | 233 | #define QM_MAXHELLOLIMIT 157 |
96e1f81d CP |
234 | #define QM_ADDRESSLIMIT 158 |
235 | #define QM_DOMAINBANNED 159 | |
cce4c955 | 236 | #define QM_TYPEHELPFORHELP 160 |
a03c04b3 | 237 | #define QM_REQUESTPASSPRIVUSER 161 |
e2792f61 | 238 | #define QM_EMAILMATCHESOLD 162 |
fdedb559 | 239 | #define QM_INVALIDLIMIT 163 |
c86edd1d Q |
240 | |
241 | /* List of privileged operations */ | |
242 | ||
243 | #define QPRIV_SUSPENDBYPASS 1 | |
244 | #define QPRIV_VIEWCHANFLAGS 100 | |
245 | #define QPRIV_VIEWFULLCHANLEV 101 | |
246 | #define QPRIV_VIEWFULLWHOIS 102 | |
247 | #define QPRIV_VIEWCHANMODES 103 | |
248 | #define QPRIV_VIEWAUTOLIMIT 104 | |
249 | #define QPRIV_VIEWBANTIMER 105 | |
250 | #define QPRIV_VIEWUSERFLAGS 106 | |
251 | #define QPRIV_VIEWWELCOME 107 | |
252 | #define QPRIV_VIEWCOMMENTS 108 | |
253 | #define QPRIV_VIEWEMAIL 109 | |
254 | ||
255 | #define QPRIV_CHANGECHANFLAGS 200 | |
256 | #define QPRIV_CHANGECHANLEV 201 | |
257 | #define QPRIV_CHANGECHANMODES 202 | |
258 | #define QPRIV_CHANGEAUTOLIMIT 203 | |
259 | #define QPRIV_CHANGEBANTIMER 204 | |
260 | #define QPRIV_CHANGEUSERFLAGS 205 | |
261 | #define QPRIV_CHANGEWELCOME 206 | |
262 | ||
263 | /* List of access checks */ | |
264 | ||
265 | #define CA_AUTHED 0x0001 | |
266 | #define CA_TOPICPRIV 0x0008 | |
267 | #define CA_KNOWN 0x0010 | |
268 | #define CA_VOICEPRIV 0x0020 | |
269 | #define CA_OPPRIV 0x0040 | |
270 | #define CA_MASTERPRIV 0x0080 | |
271 | #define CA_OWNERPRIV 0x0100 | |
272 | /* SPARE 0x0200 */ | |
273 | #define CA_ONCHAN 0x0400 | |
274 | #define CA_OFFCHAN 0x0800 | |
275 | #define CA_OPPED 0x1000 | |
276 | #define CA_DEOPPED 0x2000 | |
277 | #define CA_VOICED 0x4000 | |
278 | #define CA_DEVOICED 0x8000 | |
279 | ||
280 | #define CA_NEEDKNOWN (CA_KNOWN|CA_OPPRIV|CA_MASTERPRIV|CA_TOPICPRIV|CA_OWNERPRIV) | |
281 | #define CA_ONCHANREQ (CA_ONCHAN|CA_OPPED|CA_DEOPPED|CA_VOICED|CA_DEVOICED) | |
282 | ||
283 | ||
284 | /* User flags */ | |
7e0b37b0 P |
285 | #define QUFLAG_NEEDAUTH 0x0001 /* +l */ |
286 | #define QUFLAG_GLINE 0x0002 /* +g */ | |
287 | #define QUFLAG_NOTICE 0x0004 /* +n */ | |
288 | #define QUFLAG_RESTRICTED 0x0008 /* +r */ | |
289 | #define QUFLAG_SUSPENDED 0x0010 /* +z */ | |
290 | #define QUFLAG_OPER 0x0020 /* +o */ | |
291 | #define QUFLAG_DEV 0x0040 /* +d */ | |
292 | #define QUFLAG_PROTECT 0x0080 /* +p */ | |
293 | #define QUFLAG_HELPER 0x0100 /* +h */ | |
294 | #define QUFLAG_ADMIN 0x0200 /* +a */ | |
295 | #define QUFLAG_INFO 0x0400 /* +i */ | |
296 | #define QUFLAG_DELAYEDGLINE 0x0800 /* +G */ | |
297 | #define QUFLAG_NOAUTHLIMIT 0x1000 /* +L */ | |
298 | #define QUFLAG_CLEANUPEXEMPT 0x4000 /* +D */ | |
e58b744c CP |
299 | #define QUFLAG_TRUST 0x8000 /* +T */ |
300 | #define QUFLAG_ALL 0xdfff | |
c86edd1d Q |
301 | |
302 | #define UIsNeedAuth(x) ((x)->flags & QUFLAG_NEEDAUTH) | |
303 | #define UIsGline(x) ((x)->flags & QUFLAG_GLINE) | |
304 | #define UIsNotice(x) ((x)->flags & QUFLAG_NOTICE) | |
305 | #define UIsRestricted(x) ((x)->flags & QUFLAG_RESTRICTED) | |
306 | #define UIsSuspended(x) ((x)->flags & QUFLAG_SUSPENDED) | |
307 | #define UIsOper(x) ((x)->flags & QUFLAG_OPER) | |
308 | #define UIsDev(x) ((x)->flags & QUFLAG_DEV) | |
309 | #define UIsProtect(x) ((x)->flags & QUFLAG_PROTECT) | |
310 | #define UIsHelper(x) ((x)->flags & QUFLAG_HELPER) | |
311 | #define UIsAdmin(x) ((x)->flags & QUFLAG_ADMIN) | |
312 | #define UIsInfo(x) ((x)->flags & QUFLAG_INFO) | |
313 | #define UIsDelayedGline(x) ((x)->flags & QUFLAG_DELAYEDGLINE) | |
314 | #define UIsNoAuthLimit(x) ((x)->flags & QUFLAG_NOAUTHLIMIT) | |
183b8e2f | 315 | #define UIsCleanupExempt(x) ((x)->flags & QUFLAG_CLEANUPEXEMPT) |
c86edd1d Q |
316 | |
317 | #define UHasSuspension(x) ((x)->flags & (QUFLAG_GLINE|QUFLAG_DELAYEDGLINE|QUFLAG_SUSPENDED|QUFLAG_NEEDAUTH)) | |
318 | ||
319 | #define UHasHelperPriv(x) ((x)->flags & (QUFLAG_HELPER | QUFLAG_OPER | QUFLAG_ADMIN | QUFLAG_DEV)) | |
320 | #define UHasOperPriv(x) ((x)->flags & (QUFLAG_OPER | QUFLAG_ADMIN | QUFLAG_DEV)) | |
321 | #define UHasAdminPriv(x) ((x)->flags & (QUFLAG_ADMIN | QUFLAG_DEV)) | |
322 | ||
7e0b37b0 P |
323 | #define USetNeedAuth(x) ((x)->flags |= QUFLAG_NEEDAUTH) |
324 | #define USetGline(x) ((x)->flags |= QUFLAG_GLINE) | |
325 | #define USetNotice(x) ((x)->flags |= QUFLAG_NOTICE) | |
326 | #define USetRestricted(x) ((x)->flags |= QUFLAG_RESTRICTED) | |
327 | #define USetSuspended(x) ((x)->flags |= QUFLAG_SUSPENDED) | |
328 | #define USetOper(x) ((x)->flags |= QUFLAG_OPER) | |
329 | #define USetDev(x) ((x)->flags |= QUFLAG_DEV) | |
330 | #define USetProtect(x) ((x)->flags |= QUFLAG_PROTECT) | |
331 | #define USetHelper(x) ((x)->flags |= QUFLAG_HELPER) | |
332 | #define USetAdmin(x) ((x)->flags |= QUFLAG_ADMIN) | |
333 | #define USetInfo(x) ((x)->flags |= QUFLAG_INFO) | |
334 | #define USetDelayedGline(x) ((x)->flags |= QUFLAG_DELAYEDGLINE) | |
335 | #define USetNoAuthLimit(x) ((x)->flags |= QUFLAG_NOAUTHLIMIT) | |
336 | #define USetCleanupExempt(x) ((x)->flags |= QUFLAG_CLEANUPEXEMPT) | |
337 | #define USetTrust(x) ((x)->flags |= QUFLAG_TRUST) | |
338 | ||
339 | #define UClearNeedAuth(x) ((x)->flags &= ~QUFLAG_NEEDAUTH) | |
340 | #define UClearGline(x) ((x)->flags &= ~QUFLAG_GLINE) | |
341 | #define UClearNotice(x) ((x)->flags &= ~QUFLAG_NOTICE) | |
342 | #define UClearRestricted(x) ((x)->flags &= ~QUFLAG_RESTRICTED) | |
343 | #define UClearSuspended(x) ((x)->flags &= ~QUFLAG_SUSPENDED) | |
344 | #define UClearOper(x) ((x)->flags &= ~QUFLAG_OPER) | |
345 | #define UClearDev(x) ((x)->flags &= ~QUFLAG_DEV) | |
346 | #define UClearProtect(x) ((x)->flags &= ~QUFLAG_PROTECT) | |
347 | #define UClearHelper(x) ((x)->flags &= ~QUFLAG_HELPER) | |
348 | #define UClearAdmin(x) ((x)->flags &= ~QUFLAG_ADMIN) | |
349 | #define UClearInfo(x) ((x)->flags &= ~QUFLAG_INFO) | |
350 | #define UClearDelayedGline(x) ((x)->flags &= ~QUFLAG_DELAYEDGLINE) | |
351 | #define UClearNoAuthLimit(x) ((x)->flags &= ~QUFLAG_NOAUTHLIMIT) | |
352 | #define UClearCleanupExempt(x) ((x)->flags &= ~QUFLAG_CLEANUPEXEMPT) | |
353 | #define UClearTrust(x) ((x)->flags &= ~QUFLAG_TRUST) | |
354 | ||
c86edd1d Q |
355 | /* email */ |
356 | #define MAX_RESEND_TIME 2*3600L /* cooling off period */ | |
357 | #define VALID_EMAIL "^[-_.+[:alpha:][:digit:]]+(\\.[-_[:digit:][:alpha:]]+)*@([[:digit:][:alpha:]](-?[[:digit:][:alpha:]])*\\.)+[[:alpha:]]{2}([zmuvtgo]|fo|me|seum|op|ro)?$" | |
358 | ||
dc9548f4 CP |
359 | #define VALID_ACCOUNT_NAME "^[-a-z0-9]*$" |
360 | ||
c86edd1d Q |
361 | #define QMAIL_NEWACCOUNT 1 /* new account */ |
362 | #define QMAIL_REQPW 2 /* requestpassword */ | |
363 | #define QMAIL_NEWPW 3 /* new password */ | |
c86edd1d Q |
364 | #define QMAIL_NEWEMAIL 5 /* new email address */ |
365 | ||
c86edd1d Q |
366 | |
367 | /* Channel flags */ | |
368 | #define QCFLAG_AUTOOP 0x0001 /* +a */ | |
369 | #define QCFLAG_BITCH 0x0002 /* +b */ | |
370 | #define QCFLAG_AUTOLIMIT 0x0004 /* +c */ | |
371 | #define QCFLAG_ENFORCE 0x0008 /* +e */ | |
372 | #define QCFLAG_FORCETOPIC 0x0010 /* +f */ | |
373 | #define QCFLAG_AUTOVOICE 0x0020 /* +g */ | |
374 | #define QCFLAG_INFO 0x0040 /* +i */ | |
375 | #define QCFLAG_JOINED 0x0080 /* +j */ | |
376 | #define QCFLAG_KNOWNONLY 0x0100 /* +k */ | |
377 | #define QCFLAG_PROTECT 0x0200 /* +p */ | |
c86edd1d Q |
378 | #define QCFLAG_TOPICSAVE 0x0800 /* +t */ |
379 | #define QCFLAG_VOICEALL 0x1000 /* +v */ | |
380 | #define QCFLAG_WELCOME 0x2000 /* +w */ | |
381 | #define QCFLAG_SUSPENDED 0x4000 /* +z */ | |
382 | ||
383 | #define CIsAutoOp(x) ((x)->flags & QCFLAG_AUTOOP) | |
384 | #define CIsBitch(x) ((x)->flags & QCFLAG_BITCH) | |
385 | #define CIsAutoLimit(x) ((x)->flags & QCFLAG_AUTOLIMIT) | |
386 | #define CIsEnforce(x) ((x)->flags & QCFLAG_ENFORCE) | |
387 | #define CIsForceTopic(x) ((x)->flags & QCFLAG_FORCETOPIC) | |
388 | #define CIsAutoVoice(x) ((x)->flags & QCFLAG_AUTOVOICE) | |
389 | #define CIsJoined(x) ((x)->flags & QCFLAG_JOINED) | |
390 | #define CIsKnownOnly(x) ((x)->flags & QCFLAG_KNOWNONLY) | |
391 | #define CIsProtect(x) ((x)->flags & QCFLAG_PROTECT) | |
c86edd1d Q |
392 | #define CIsTopicSave(x) ((x)->flags & QCFLAG_TOPICSAVE) |
393 | #define CIsVoiceAll(x) ((x)->flags & QCFLAG_VOICEALL) | |
394 | #define CIsWelcome(x) ((x)->flags & QCFLAG_WELCOME) | |
395 | #define CIsSuspended(x) ((x)->flags & QCFLAG_SUSPENDED) | |
396 | #define CIsInfo(x) ((x)->flags & QCFLAG_INFO) | |
397 | ||
398 | #define CSetAutoOp(x) ((x)->flags |= QCFLAG_AUTOOP) | |
399 | #define CSetBitch(x) ((x)->flags |= QCFLAG_BITCH) | |
400 | #define CSetAutoLimit(x) ((x)->flags |= QCFLAG_AUTOLIMIT) | |
401 | #define CSetEnforce(x) ((x)->flags |= QCFLAG_ENFORCE) | |
402 | #define CSetForceTopic(x) ((x)->flags |= QCFLAG_FORCETOPIC) | |
403 | #define CSetAutoVoice(x) ((x)->flags |= QCFLAG_AUTOVOICE) | |
404 | #define CSetJoined(x) ((x)->flags |= QCFLAG_JOINED) | |
405 | #define CSetKnownOnly(x) ((x)->flags |= QCFLAG_KNOWNONLY) | |
406 | #define CSetProtect(x) ((x)->flags |= QCFLAG_PROTECT) | |
c86edd1d Q |
407 | #define CSetTopicSave(x) ((x)->flags |= QCFLAG_TOPICSAVE) |
408 | #define CSetVoiceAll(x) ((x)->flags |= QCFLAG_VOICEALL) | |
409 | #define CSetWelcome(x) ((x)->flags |= QCFLAG_WELCOME) | |
410 | #define CSetSuspended(x) ((x)->flags |= QCFLAG_SUSPENDED) | |
411 | ||
412 | #define CClearAutoOp(x) ((x)->flags &= ~QCFLAG_AUTOOP) | |
413 | #define CClearBitch(x) ((x)->flags &= ~QCFLAG_BITCH) | |
414 | #define CClearAutoLimit(x) ((x)->flags &= ~QCFLAG_AUTOLIMIT) | |
415 | #define CClearEnforce(x) ((x)->flags &= ~QCFLAG_ENFORCE) | |
416 | #define CClearForceTopic(x) ((x)->flags &= ~QCFLAG_FORCETOPIC) | |
417 | #define CClearAutoVoice(x) ((x)->flags &= ~QCFLAG_AUTOVOICE) | |
418 | #define CClearJoined(x) ((x)->flags &= ~QCFLAG_JOINED) | |
419 | #define CClearKnownOnly(x) ((x)->flags &= ~QCFLAG_KNOWNONLY) | |
420 | #define CClearProtect(x) ((x)->flags &= ~QCFLAG_PROTECT) | |
c86edd1d Q |
421 | #define CClearTopicSave(x) ((x)->flags &= ~QCFLAG_TOPICSAVE) |
422 | #define CClearVoiceAll(x) ((x)->flags &= ~QCFLAG_VOICEALL) | |
423 | #define CClearWelcome(x) ((x)->flags &= ~QCFLAG_WELCOME) | |
424 | #define CClearSuspended(x) ((x)->flags &= ~QCFLAG_SUSPENDED) | |
425 | ||
426 | #define QCFLAG_USERCONTROL (QCFLAG_AUTOOP|QCFLAG_BITCH|QCFLAG_AUTOLIMIT| \ | |
427 | QCFLAG_ENFORCE|QCFLAG_FORCETOPIC|QCFLAG_AUTOVOICE| \ | |
72ca906c | 428 | QCFLAG_PROTECT|QCFLAG_TOPICSAVE|QCFLAG_VOICEALL| \ |
c86edd1d Q |
429 | QCFLAG_WELCOME|QCFLAG_KNOWNONLY) |
430 | ||
e58b744c | 431 | #define QCFLAG_ALL 0x7bff |
c86edd1d Q |
432 | |
433 | ||
434 | /* Channel user ("chanlev") flags */ | |
435 | /* Slightly funny order here: list the "biggest" flags at the | |
436 | * top so we can do sorted "chanlev" output more easily */ | |
437 | #define QCUFLAG_OWNER 0x8000 /* +n */ | |
438 | #define QCUFLAG_MASTER 0x4000 /* +m */ | |
439 | #define QCUFLAG_OP 0x2000 /* +o */ | |
440 | #define QCUFLAG_VOICE 0x1000 /* +v */ | |
441 | #define QCUFLAG_AUTOOP 0x0001 /* +a */ | |
442 | #define QCUFLAG_BANNED 0x0002 /* +b */ | |
443 | #define QCUFLAG_DENY 0x0004 /* +d */ | |
444 | #define QCUFLAG_AUTOVOICE 0x0008 /* +g */ | |
445 | #define QCUFLAG_QUIET 0x0010 /* +q */ | |
c86edd1d Q |
446 | #define QCUFLAG_TOPIC 0x0040 /* +t */ |
447 | #define QCUFLAG_HIDEWELCOME 0x0080 /* +w */ | |
448 | #define QCUFLAG_PROTECT 0x0100 /* +p */ | |
449 | #define QCUFLAG_HIDEINFO 0x0200 /* +i */ | |
450 | #define QCUFLAG_KNOWN 0x0400 /* +k */ | |
451 | #define QCUFLAG_AUTOINVITE 0x0800 /* +j */ | |
452 | ||
453 | #define QCUFLAG_SIGNIFICANT (QCUFLAG_MASTER|QCUFLAG_OWNER|QCUFLAG_OP) | |
454 | ||
455 | #define QCUFLAG_MASTERCON (QCUFLAG_AUTOOP|QCUFLAG_BANNED|QCUFLAG_DENY| \ | |
456 | QCUFLAG_GIVE|QCUFLAG_OP|QCUFLAG_QUIET|QCUFLAG_TOPIC| \ | |
457 | QCUFLAG_VOICE|QCUFLAG_PROTECT) | |
458 | ||
459 | #define QCUFLAG_SELFCON (QCUFLAG_OP | QCUFLAG_VOICE | QCUFLAG_AUTOOP | QCUFLAG_AUTOVOICE | \ | |
72ca906c | 460 | QCUFLAG_TOPIC | QCUFLAG_HIDEINFO) |
c86edd1d | 461 | |
156f6bad | 462 | #define QCUFLAGS_PERSONAL (QCUFLAG_HIDEINFO | QCUFLAG_HIDEWELCOME | QCUFLAG_AUTOINVITE) |
463 | ||
e58b744c | 464 | #define QCUFLAG_ALL 0xffdf |
c86edd1d Q |
465 | |
466 | #define CUIsOwner(x) ((x)->flags & QCUFLAG_OWNER) | |
467 | #define CUIsMaster(x) ((x)->flags & QCUFLAG_MASTER) | |
468 | #define CUIsOp(x) ((x)->flags & QCUFLAG_OP) | |
469 | #define CUIsVoice(x) ((x)->flags & QCUFLAG_VOICE) | |
470 | #define CUIsAutoOp(x) ((x)->flags & QCUFLAG_AUTOOP) | |
471 | #define CUIsBanned(x) ((x)->flags & QCUFLAG_BANNED) | |
472 | #define CUIsDeny(x) ((x)->flags & QCUFLAG_DENY) | |
473 | #define CUIsAutoVoice(x) ((x)->flags & QCUFLAG_AUTOVOICE) | |
474 | #define CUIsQuiet(x) ((x)->flags & QCUFLAG_QUIET) | |
c86edd1d Q |
475 | #define CUIsTopic(x) ((x)->flags & QCUFLAG_TOPIC) |
476 | #define CUIsHideWelcome(x) ((x)->flags & QCUFLAG_HIDEWELCOME) | |
477 | #define CUIsProtect(x) ((x)->flags & QCUFLAG_PROTECT) | |
478 | #define CUIsHideInfo(x) ((x)->flags & QCUFLAG_HIDEINFO) | |
479 | #define CUIsKnown(x) ((x)->flags & QCUFLAG_KNOWN) | |
480 | #define CUIsAutoInvite(x) ((x)->flags & QCUFLAG_AUTOINVITE) | |
481 | ||
482 | #define CUKnown(x) (CUIsKnown(x) || CUHasVoicePriv(x)) | |
483 | #define CUHasVoicePriv(x) ((x)->flags & (QCUFLAG_VOICE | QCUFLAG_OP | QCUFLAG_MASTER | QCUFLAG_OWNER)) | |
484 | #define CUHasOpPriv(x) ((x)->flags & (QCUFLAG_OP | QCUFLAG_MASTER | QCUFLAG_OWNER)) | |
485 | #define CUHasMasterPriv(x) ((x)->flags & (QCUFLAG_MASTER | QCUFLAG_OWNER)) | |
486 | #define CUHasTopicPriv(x) ((x)->flags & (QCUFLAG_MASTER | QCUFLAG_OWNER | QCUFLAG_TOPIC)) | |
487 | ||
488 | #define CUSetOwner(x) ((x)->flags |= QCUFLAG_OWNER) | |
489 | #define CUSetMaster(x) ((x)->flags |= QCUFLAG_MASTER) | |
490 | #define CUSetOp(x) ((x)->flags |= QCUFLAG_OP) | |
491 | #define CUSetVoice(x) ((x)->flags |= QCUFLAG_VOICE) | |
492 | #define CUSetAutoOp(x) ((x)->flags |= QCUFLAG_AUTOOP) | |
493 | #define CUSetBanned(x) ((x)->flags |= QCUFLAG_BANNED) | |
494 | #define CUSetDeny(x) ((x)->flags |= QCUFLAG_DENY) | |
495 | #define CUSetAutoVoice(x) ((x)->flags |= QCUFLAG_AUTOVOICE) | |
496 | #define CUSetQuiet(x) ((x)->flags |= QCUFLAG_QUIET) | |
c86edd1d Q |
497 | #define CUSetTopic(x) ((x)->flags |= QCUFLAG_TOPIC) |
498 | #define CUSetHideWelcome(x) ((x)->flags |= QCUFLAG_HIDEWELCOME) | |
499 | #define CUSetKnown(x) ((x)->flags |= QCUFLAG_KNOWN) | |
500 | #define CUSetAutoInvite(x) ((x)->flags |= QCUFLAG_AUTOINVITE) | |
501 | ||
502 | #define CUClearOwner(x) ((x)->flags &= ~QCUFLAG_OWNER) | |
503 | #define CUClearMaster(x) ((x)->flags &= ~QCUFLAG_MASTER) | |
504 | #define CUClearOp(x) ((x)->flags &= ~QCUFLAG_OP) | |
505 | #define CUClearVoice(x) ((x)->flags &= ~QCUFLAG_VOICE) | |
506 | #define CUClearAutoOp(x) ((x)->flags &= ~QCUFLAG_AUTOOP) | |
507 | #define CUClearBanned(x) ((x)->flags &= ~QCUFLAG_BANNED) | |
508 | #define CUClearDeny(x) ((x)->flags &= ~QCUFLAG_DENY) | |
509 | #define CUClearAutoVoice(x) ((x)->flags &= ~QCUFLAG_AUTOVOICE) | |
510 | #define CUClearQuiet(x) ((x)->flags &= ~QCUFLAG_QUIET) | |
c86edd1d Q |
511 | #define CUClearTopic(x) ((x)->flags &= ~QCUFLAG_TOPIC) |
512 | #define CUClearHideWelcome(x) ((x)->flags &= ~QCUFLAG_HIDEWELCOME) | |
513 | #define CUClearKnown(x) ((x)->flags &= ~QCUFLAG_KNOWN) | |
514 | #define CUClearAutoInvite(x) ((x)->flags &= ~QCUFLAG_AUTOINVITE) | |
515 | ||
516 | #define QCSTAT_OPCHECK 0x0001 /* Do op check */ | |
517 | #define QCSTAT_MODECHECK 0x0002 /* Do mode check */ | |
518 | #define QCSTAT_BANCHECK 0x0004 /* Do ban check */ | |
519 | ||
520 | #define QUSTAT_DEAD 0x8000 /* User has been deleted.. */ | |
521 | ||
522 | #define QCMD_SECURE 0x0001 /* Must use "user@server" to use this command */ | |
523 | #define QCMD_AUTHED 0x0002 /* Only available to authed users */ | |
524 | #define QCMD_NOTAUTHED 0x0004 /* Only available to NON-authed users */ | |
525 | ||
526 | #define QCMD_HELPER 0x0010 /* Only available to helpers */ | |
527 | #define QCMD_OPER 0x0020 /* Only available to opers */ | |
528 | #define QCMD_ADMIN 0x0040 /* Only available to admins */ | |
529 | #define QCMD_DEV 0x0080 /* Only available to developers */ | |
530 | ||
531 | #define QCMD_ALIAS 0x0100 /* Don't list on SHOWCOMMANDS */ | |
532 | ||
533 | #define CS_INIT_DB 0x1 /* Loading database.. */ | |
534 | #define CS_INIT_NOUSER 0x2 /* Loaded DB, waiting for user to be created */ | |
535 | #define CS_INIT_READY 0x3 /* Ready for action! */ | |
536 | ||
537 | struct regchanuser; | |
538 | struct reguser; | |
539 | ||
e3805f60 P |
540 | typedef struct maildomain { |
541 | #ifdef CS_PARANOID | |
542 | unsigned int maildomain_magic; | |
543 | #endif | |
544 | unsigned int ID; | |
545 | sstring *name; | |
546 | unsigned int count; | |
547 | unsigned int limit; | |
548 | unsigned int actlimit; | |
549 | flag_t flags; | |
550 | struct reguser *users; | |
551 | struct maildomain *parent; | |
552 | struct maildomain *nextbyname; | |
553 | struct maildomain *nextbyID; | |
554 | } maildomain; | |
555 | ||
556 | #define MDFLAG_LIMIT 0x0001 /* +l */ | |
557 | #define MDFLAG_BANNED 0x0002 /* +b */ | |
558 | #define MDFLAG_ACTLIMIT 0x0004 /* +u */ | |
559 | #define MDFLAG_ALL 0x0007 | |
560 | ||
96e1f81d CP |
561 | #define MDFLAG_DEFAULT MDFLAG_ACTLIMIT |
562 | ||
e3805f60 P |
563 | #define MDHasLimit(x) ((x)->flags & MDFLAG_LIMIT) |
564 | #define MDSetLimit(x) ((x)->flags |= MDFLAG_LIMIT) | |
565 | #define MDClearLimit(x) ((x)->flags &= ~MDFLAG_LIMIT) | |
566 | #define MDIsBanned(x) ((x)->flags & MDFLAG_BANNED) | |
567 | #define MDSetBanned(x) ((x)->flags |= MDFLAG_BANNED) | |
568 | #define MDClearBanned(x) ((x)->flags &= ~MDFLAG_BANNED) | |
569 | #define MDHasActLimit(x) ((x)->flags & MDFLAG_ACTLIMIT) | |
570 | #define MDSetActLimit(x) ((x)->flags |= MDFLAG_ACTLIMIT) | |
571 | #define MDClearActLimit(x) ((x)->flags &= ~MDFLAG_ACTLIMIT) | |
572 | ||
c86edd1d Q |
573 | /* "Q" ban */ |
574 | typedef struct regban { | |
575 | #ifdef CS_PARANOID | |
576 | unsigned int regchanban_magic; | |
577 | #endif | |
578 | unsigned int ID; /* ID in the database */ | |
579 | struct chanban *cbp; /* Standard chanban struct */ | |
580 | unsigned int setby; /* Who set the ban */ | |
581 | time_t expiry; /* When the ban expires */ | |
582 | sstring *reason; /* Reason to attach to related kicks */ | |
583 | struct regban *next; /* Next ban on this channel */ | |
584 | } regban; | |
585 | ||
586 | /* Registered channel */ | |
587 | typedef struct regchan { | |
588 | #ifdef CS_PARANOID | |
589 | unsigned int regchan_magic; | |
590 | #endif | |
591 | unsigned int ID; /* Unique number from database */ | |
592 | chanindex *index; /* Pointer to the channel index record */ | |
a54e438d | 593 | time_t ltimestamp; /* The last timestamp we saw on this channel */ |
c86edd1d Q |
594 | |
595 | flag_t flags; /* Chanflags */ | |
596 | flag_t status; /* Runtime status codes */ | |
597 | flag_t forcemodes; /* Forced modes */ | |
598 | flag_t denymodes; /* Denied modes */ | |
599 | ||
600 | short limit; /* Limit to enforce if +l is set */ | |
601 | short autolimit; /* How many slots to leave when autolimiting */ | |
602 | short banstyle; /* Ban style for +b type bans */ | |
603 | ||
604 | time_t created; /* When the service was added */ | |
605 | time_t lastactive; /* When the channel was last "active" */ | |
606 | time_t statsreset; /* When the users stats were last reset */ | |
607 | time_t ostatsreset; /* When the oper stats were last reset */ | |
608 | time_t banduration; /* How long to remove bans after (0=don't) */ | |
609 | time_t autoupdate; /* When the autolimit next needs checking */ | |
610 | time_t lastbancheck; /* Timestamp of last ban check */ | |
611 | time_t lastcountersync; /* When the counters were last synced.. */ | |
612 | time_t lastpart; /* When the last user left the channel */ | |
88d191e3 | 613 | time_t suspendtime; /* When the channel was suspended */ |
c86edd1d Q |
614 | |
615 | unsigned int founder; /* founder */ | |
616 | unsigned int addedby; /* oper adding chan */ | |
617 | unsigned int suspendby; /* who suspended chan */ | |
618 | ||
619 | short chantype; /* What "type" the channel is */ | |
620 | ||
621 | unsigned int totaljoins; /* Total joins since created */ | |
622 | unsigned int tripjoins; /* Total joins since last stats reset */ | |
623 | unsigned int otripjoins; /* Total joins since last oper stats reset */ | |
624 | unsigned int maxusers; /* Max users since created */ | |
625 | unsigned int tripusers; /* Max users since last stats reset */ | |
626 | unsigned int otripusers; /* Max users since last oper stats reset */ | |
627 | ||
628 | sstring *welcome; /* Welcome message */ | |
629 | sstring *topic; /* "default" topic set by settopic */ | |
630 | sstring *key; /* Key as enforced by +k */ | |
631 | sstring *suspendreason; /* Suspend reason */ | |
632 | sstring *comment; /* Oper-settable channel comment */ | |
633 | ||
634 | void *checksched; /* Handle for channel check schedule */ | |
635 | ||
636 | struct regchanuser *regusers[REGCHANUSERHASHSIZE]; | |
637 | struct regban *bans; /* List of bans on the channel */ | |
638 | } regchan; | |
639 | ||
c86edd1d Q |
640 | /* Registered user */ |
641 | typedef struct reguser { | |
642 | #ifdef CS_PARANOID | |
643 | unsigned int reguser_magic; | |
644 | #endif | |
c86edd1d Q |
645 | unsigned int ID; /* From the database */ |
646 | ||
647 | char username[NICKLEN+1]; | |
648 | ||
649 | time_t created; | |
650 | time_t lastauth; | |
651 | time_t lastemailchange; | |
652 | ||
653 | flag_t flags; /* user flags */ | |
654 | flag_t status; /* runtime status */ | |
655 | short languageid; /* what language to speak to the user */ | |
656 | ||
657 | unsigned int suspendby; /* Userid of oper who suspended this user */ | |
658 | time_t suspendexp; /* Expiry date of suspension */ | |
88d191e3 | 659 | time_t suspendtime; /* When user was suspended */ |
ad3f4566 | 660 | time_t lockuntil; /* Time until users account is unlocked (pass change, email, etc) */ |
c86edd1d Q |
661 | |
662 | char password[PASSLEN+1]; | |
72ca906c | 663 | |
e3805f60 P |
664 | sstring *localpart; |
665 | maildomain *domain; | |
666 | ||
c86edd1d Q |
667 | sstring *email; /* Registered e-mail */ |
668 | sstring *lastuserhost; /* Last user@host */ | |
669 | sstring *suspendreason; /* Why the account is suspended */ | |
670 | sstring *comment; /* Oper-settable user comment */ | |
671 | sstring *info; /* User-settable info line */ | |
672 | ||
673 | struct regchanuser *knownon; /* Which channels this user is known on */ | |
674 | ||
c86edd1d Q |
675 | /* These fields are for the nick protection system */ |
676 | void *checkshd; /* When we're going to check for an imposter */ | |
677 | int stealcount; /* How many times we've had to free the nick up */ | |
678 | nick *fakeuser; /* If we had to "take" the nick, here's the pointer */ | |
679 | ||
e3805f60 | 680 | struct reguser *nextbydomain; |
c86edd1d Q |
681 | struct reguser *nextbyname; |
682 | struct reguser *nextbyID; | |
683 | } reguser; | |
684 | ||
685 | /* Registered channel user */ | |
686 | typedef struct regchanuser { | |
687 | #ifdef CS_PARANOID | |
688 | unsigned int regchanuser_magic; | |
689 | #endif | |
690 | struct reguser *user; | |
691 | struct regchan *chan; | |
692 | flag_t flags; | |
693 | time_t changetime; /* Timestamp of last "significant" change */ | |
694 | time_t usetime; /* Timestamp of last use */ | |
695 | sstring *info; /* User-settable info line */ | |
696 | struct regchanuser *nextbyuser; | |
697 | struct regchanuser *nextbychan; | |
698 | } regchanuser; | |
699 | ||
700 | typedef struct cslang { | |
701 | char code[3]; | |
702 | sstring *name; | |
703 | } cslang; | |
704 | ||
705 | typedef struct cmdsummary { | |
706 | sstring *def; | |
707 | sstring *bylang[MAXLANG]; | |
1f0d7c8b | 708 | char *defhelp; |
c86edd1d Q |
709 | } cmdsummary; |
710 | ||
711 | typedef struct activeuser { | |
712 | #ifdef CS_PARANOID | |
713 | unsigned int activeuser_magic; | |
714 | #endif | |
bd87ef68 CP |
715 | unsigned short authattempts; /* number of times user has attempted to auth */ |
716 | unsigned short helloattempts; /* number of times user has attempted to hello... */ | |
0ba70e7b CP |
717 | unsigned char entropy[ENTROPYLEN]; /* entropy used for challengeauth */ |
718 | time_t entropyttl; | |
c86edd1d Q |
719 | struct activeuser *next; /* purely for keeping track of free, but not free'd structures */ |
720 | } activeuser; | |
721 | ||
722 | #ifdef CS_PARANOID | |
723 | ||
724 | #define REGUSERMAGIC 0x4d42de03 | |
725 | #define REGCHANMAGIC 0x5bf2aa30 | |
726 | #define REGCHANUSERMAGIC 0x19628b63 | |
727 | #define REGCHANBANMAGIC 0x5a6f555a | |
728 | #define ACTIVEUSERMAGIC 0x897f98a0 | |
e3805f60 | 729 | #define MAILDOMAINMAGIC 0x27cde46f |
c86edd1d Q |
730 | |
731 | #define verifyreguser(x) assert((x)->reguser_magic == REGUSERMAGIC) | |
732 | #define verifyregchan(x) assert((x)->regchan_magic == REGCHANMAGIC) | |
733 | #define verifyregchanuser(x) assert((x)->regchanuser_magic == REGCHANUSERMAGIC) | |
734 | #define verifyregchanban(x) assert((x)->regchanban_magic == REGCHANBANMAGIC) | |
735 | #define verifyactiveuser(x) assert((x)->activeuser_magic == ACTIVEUSERMAGIC) | |
e3805f60 | 736 | #define verifymaildomain(x) assert((x)->maildomain_magic == MAILDOMAINMAGIC) |
c86edd1d Q |
737 | |
738 | #define tagreguser(x) ((x)->reguser_magic = REGUSERMAGIC) | |
739 | #define tagregchan(x) ((x)->regchan_magic = REGCHANMAGIC) | |
740 | #define tagregchanuser(x) ((x)->regchanuser_magic = REGCHANUSERMAGIC) | |
741 | #define tagregchanban(x) ((x)->regchanban_magic = REGCHANBANMAGIC) | |
742 | #define tagactiveuser(x) ((x)->activeuser_magic = ACTIVEUSERMAGIC) | |
e3805f60 | 743 | #define tagmaildomain(x) ((x)->maildomain_magic = MAILDOMAINMAGIC) |
c86edd1d Q |
744 | |
745 | #else | |
746 | ||
747 | #define verifyreguser(x) | |
748 | #define verifyregchan(x) | |
749 | #define verifyregchanuser(x) | |
750 | #define verifyregchanban(x) | |
751 | #define verifyactiveuser(x) | |
e3805f60 | 752 | #define verifymaildomain(x) |
c86edd1d Q |
753 | |
754 | #define tagreguser(x) | |
755 | #define tagregchan(x) | |
756 | #define tagregchanuser(x) | |
757 | #define tagregchanban(x) | |
758 | #define tagactiveuser(x) | |
e3805f60 | 759 | #define tagmaildomain(x) |
c86edd1d Q |
760 | |
761 | #endif | |
762 | ||
763 | #define getactiveuserfromnick(x) ((activeuser*)(x)->exts[chanservnext]) | |
23b85e10 | 764 | #define getreguserfromnick(x) ((x)->auth?(reguser *)(x)->auth->exts[chanservaext]:NULL) |
c86edd1d Q |
765 | |
766 | /* Global variables for chanserv module */ | |
c86edd1d Q |
767 | extern unsigned int lastuserID; |
768 | extern unsigned int lastchannelID; | |
769 | extern unsigned int lastbanID; | |
e3805f60 | 770 | extern unsigned int lastdomainID; |
c86edd1d Q |
771 | |
772 | extern int chanserv_init_status; | |
b263aa79 | 773 | extern int chanservdb_ready; |
c86edd1d | 774 | |
e3805f60 P |
775 | extern maildomain *maildomainnametable[MAILDOMAINHASHSIZE]; |
776 | extern maildomain *maildomainIDtable[MAILDOMAINHASHSIZE]; | |
777 | ||
c86edd1d Q |
778 | extern reguser *regusernicktable[REGUSERHASHSIZE]; |
779 | extern reguser *deadusers; | |
780 | ||
781 | extern nick *chanservnick; | |
782 | extern int chanservext; | |
783 | extern int chanservnext; | |
316959c1 | 784 | extern int chanservaext; |
c86edd1d Q |
785 | |
786 | extern cslang *cslanguages[MAXLANG]; | |
787 | extern unsigned int cslangcount; | |
788 | ||
789 | extern sstring *csmessages[MAXLANG][MAXMESSAGES]; | |
790 | extern char *defaultmessages[MAXMESSAGES]; | |
791 | ||
792 | extern const flag rcflags[]; | |
793 | extern const flag rcuflags[]; | |
794 | extern const flag ruflags[]; | |
e3805f60 | 795 | extern const flag mdflags[]; |
c86edd1d Q |
796 | |
797 | extern CommandTree *cscommands; | |
798 | ||
799 | extern sstring **chantypes; | |
800 | ||
801 | /* Function prototypes */ | |
802 | ||
803 | /* chanserv.c */ | |
804 | void chanserv_finalinit(); | |
805 | ||
806 | /* chanservalloc.c */ | |
807 | void chanservallocinit(); | |
808 | void csfreeall(); | |
809 | regchan *getregchan(); | |
810 | void freeregchan(regchan *rcp); | |
811 | reguser *getreguser(); | |
812 | void freereguser(reguser *rup); | |
813 | regchanuser *getregchanuser(); | |
814 | void freeregchanuser(regchanuser *rcup); | |
c86edd1d Q |
815 | regban *getregban(); |
816 | void freeregban(regban *rbp); | |
817 | activeuser *getactiveuser(); | |
818 | void freeactiveuser(activeuser *aup); | |
e3805f60 P |
819 | maildomain *getmaildomain(); |
820 | void freemaildomain(maildomain *mdp); | |
c86edd1d Q |
821 | |
822 | /* chanservhash.c */ | |
823 | void chanservhashinit(); | |
824 | void addregusertohash(reguser *rup); | |
825 | reguser *findreguserbyID(unsigned int ID); | |
826 | reguser *findreguserbynick(const char *nick); | |
827 | reguser *findreguser(nick *sender, const char *str); | |
828 | void removereguserfromhash(reguser *rup); | |
829 | void addregchantohash(regchan *rcp); | |
830 | regchan *findregchanbyID(unsigned int ID); | |
831 | regchan *findregchanbyname(const char *name); | |
832 | void removeregchanfromhash(regchan *rcp); | |
833 | void addregusertochannel(regchanuser *rcup); | |
834 | regchanuser *findreguseronchannel(regchan *rcp, reguser *rup); | |
835 | void delreguserfromchannel(regchan *rcp, reguser *rup); | |
e3805f60 P |
836 | void addmaildomaintohash(maildomain *mdp); |
837 | maildomain *findmaildomainbyID(unsigned int ID); | |
838 | maildomain *findmaildomainbydomain(char *domain); | |
839 | maildomain *findmaildomainbyemail(char *email); | |
840 | maildomain *findorcreatemaildomain(char *email); | |
96e1f81d | 841 | maildomain *findnearestmaildomain(char *domain); |
e3805f60 P |
842 | void removemaildomainfromhash(maildomain *mdp); |
843 | void addregusertomaildomain(reguser *rup, maildomain *mdp); | |
844 | void delreguserfrommaildomain(reguser *rup, maildomain *mdp); | |
b7ae0f2c | 845 | reguser *findreguserbyemail(const char *email); |
c86edd1d Q |
846 | |
847 | /* chanservdb.c */ | |
848 | int chanservdbinit(); | |
849 | void loadmessages(); | |
850 | void loadcommandsummary(Command *cmd); | |
851 | void chanservdbclose(); | |
852 | void csdb_updatetopic(regchan *rcp); | |
853 | void csdb_updatelastjoin(regchanuser *rcup); | |
854 | void csdb_updateauthinfo(reguser *rup); | |
855 | void csdb_updatechannel(regchan *rcp); | |
856 | void csdb_createchannel(regchan *rcp); | |
857 | void csdb_deletechannel(regchan *rcp); | |
858 | void csdb_deleteuser(reguser *rup); | |
859 | void csdb_updatechannelcounters(regchan *rcp); | |
a54e438d | 860 | void csdb_updatechanneltimestamp(regchan *rcp); |
c86edd1d Q |
861 | void csdb_updatechanuser(regchanuser *rcup); |
862 | void csdb_createchanuser(regchanuser *rcup); | |
863 | void csdb_deletechanuser(regchanuser *rcup); | |
864 | void csdb_createuser(reguser *rup); | |
865 | void csdb_updateuser(reguser *rup); | |
866 | void csdb_createban(regchan *rcp, regban *rbp); | |
867 | void csdb_deleteban(regban *rbp); | |
3fbc2554 | 868 | void csdb_updateban(regchan *rcp, regban *rbp); |
c86edd1d Q |
869 | char *csdb_gethelpstr(char *command, int language); |
870 | void csdb_createmail(reguser *rup, int type); | |
4ad1cf7a | 871 | void csdb_dohelp(nick *np, Command *cmd); |
c86edd1d | 872 | |
b7a95f03 CP |
873 | /* chanservcrypto.c */ |
874 | typedef int (*CRAlgorithm)(char *, const char *, const char *, const char *); | |
875 | void chanservcryptoinit(void); | |
876 | void cs_getrandbytes(unsigned char *buf, size_t bytes); | |
877 | char *cs_calcchallenge(const unsigned char *entropy); | |
878 | CRAlgorithm cs_cralgorithm(const char *algorithm); | |
879 | const char *cs_cralgorithmlist(void); | |
721cc8ce | 880 | int cs_checkhashpass(const char *username, const char *password, const char *junk, const char *hash); |
b7a95f03 | 881 | |
c86edd1d Q |
882 | /* chanservuser.c */ |
883 | void chanservreguser(void *arg); | |
884 | void chanservjoinchan(channel *cp); | |
dd258305 | 885 | #define chanservsendmessage(np, fmt, args...) chanservsendmessage_real(np, 0, fmt , ## args) |
886 | #define chanservsendmessageoneline(np, fmt, args...) chanservsendmessage_real(np, 1, fmt , ## args) | |
887 | void chanservsendmessage_real(nick *np, int oneline, char *message, ... ); | |
c86edd1d Q |
888 | void chanservwallmessage(char *message, ... ); |
889 | void chanservcommandinit(); | |
890 | void chanservcommandclose(); | |
891 | void chanservstdmessage(nick *np, int messageid, ... ); | |
1f0d7c8b | 892 | void chanservaddcommand(char *command, int flags, int maxparams, CommandHandler handler, char *description, const char *help); |
c86edd1d Q |
893 | void chanservremovecommand(char *command, CommandHandler handler); |
894 | void chanservaddctcpcommand(char *command, CommandHandler hander); | |
895 | void chanservremovectcpcommand(char *command, CommandHandler handler); | |
896 | void chanservkillstdmessage(nick *target, int messageid, ... ); | |
c86edd1d | 897 | int checkpassword(reguser *rup, const char *pass); |
c86edd1d Q |
898 | int setpassword(reguser *rup, const char *pass); |
899 | /*reguser *getreguserfromnick(nick *np); | |
900 | activeuser *getactiveuserfromnick(nick *np);*/ | |
901 | void cs_checknick(nick *np); | |
902 | void cs_checkchanmodes(channel *cp); | |
903 | void cs_docheckchanmodes(channel *cp, modechanges *changes); | |
904 | void cs_docheckopvoice(channel *cp, modechanges *changes); | |
905 | void cs_checkbans(channel *cp); | |
906 | void cs_schedupdate(chanindex *cip, int mintime, int maxtime); | |
907 | void cs_timerfunc(void *arg); | |
908 | void cs_removechannel(regchan *rcp); | |
909 | void cs_doallautomodes(nick *np); | |
910 | void cs_checknickbans(nick *np); | |
911 | void cs_setregban(chanindex *cip, regban *rbp); | |
912 | int cs_bancheck(nick *np, channel *cp); | |
913 | void cs_banuser(modechanges *changes, chanindex *cip, nick *np, const char *reason); | |
4ad1cf7a | 914 | void cs_removeuser(reguser *rup); |
b7a95f03 | 915 | int checkresponse(reguser *rup, const unsigned char *entropy, const char *response, CRAlgorithm algorithm); |
721cc8ce | 916 | int checkhashpass(reguser *rup, const char *junk, const char *hash); |
95332d7b | 917 | flag_t cs_sanitisechanlev(flag_t flags); |
c86edd1d | 918 | |
336765cd CP |
919 | typedef int (*UnbanFN)(void *arg, struct chanban *ban); |
920 | void cs_unbanfn(nick *sender, chanindex *cip, UnbanFN fn, void *arg, int removepermbans); | |
921 | ||
c86edd1d Q |
922 | /* chanservstdcmds.c */ |
923 | int cs_doshowcommands(void *source, int cargc, char **cargv); | |
924 | int cs_dohelp(void *source, int cargc, char **cargv); | |
925 | int cs_doquit(void *source, int cargc, char **cargv); | |
926 | int cs_dorename(void *source, int cargc, char **cargv); | |
927 | int cs_dorehash(void *source, int cargc, char **cargv); | |
80d2de64 | 928 | int cs_doversion(void *source, int cargc, char **cargv); |
c86edd1d Q |
929 | int cs_doctcpping(void *source, int cargc, char **cargv); |
930 | int cs_doctcpversion(void *source, int cargc, char **cargv); | |
931 | int cs_doctcpgender(void *source, int cargc, char **cargv); | |
dd258305 | 932 | int cs_sendhelp(nick *sender, char *cmd, int oneline); |
c86edd1d Q |
933 | |
934 | /* chanservnetevents.c */ | |
935 | void cs_handlenick(int hooknum, void *arg); | |
936 | void cs_handlesethost(int hooknum, void *arg); | |
937 | void cs_handlelostnick(int hooknum, void *arg); | |
938 | void cs_handlenewchannel(int hooknum, void *arg); | |
939 | void cs_handlelostchannel(int hooknum, void *arg); | |
940 | void cs_handlejoin(int hooknum, void *arg); | |
941 | void cs_handlemodechange(int hooknum, void *arg); | |
942 | void cs_handleburst(int hooknum, void *arg); | |
943 | void cs_handletopicchange(int hooknum, void *arg); | |
944 | void cs_handleopchange(int hooknum, void *arg); | |
945 | void cs_handlenewban(int hooknum, void *arg); | |
946 | void cs_handlechanlostuser(int hooknum, void *arg); | |
947 | ||
948 | /* chanservmessages.c */ | |
949 | void initmessages(); | |
950 | ||
951 | /* chanservprivs.c */ | |
952 | int cs_privcheck(int privnum, nick *np); | |
953 | chanindex *cs_checkaccess(nick *np, const char *chan, unsigned int flags, chanindex *cip, const char *cmdname, int priv, int quiet); | |
954 | ||
955 | /* chanservlog.c */ | |
956 | void cs_initlog(); | |
957 | void cs_closelog(); | |
958 | void cs_log(nick *np, char *event, ...); | |
959 | ||
960 | /* chanservdump.c */ | |
961 | int dumplastjoindata(const char *filename); | |
962 | int readlastjoindata(const char *filename); | |
963 | ||
964 | /* chanservschedule.c */ | |
965 | void chanservdgline(void *arg); | |
966 | ||
4ad1cf7a CP |
967 | /* authlib.c */ |
968 | int csa_checkeboy(nick *sender, char *eboy); | |
969 | void csa_createrandompw(char *pw, int n); | |
1dd6d55d | 970 | int csa_checkthrottled(nick *sender, reguser *rup, char *s); |
4ad1cf7a | 971 | |
80d2de64 P |
972 | /* chanservdb_updates.c */ |
973 | void csdb_updateauthinfo(reguser *rup); | |
974 | void csdb_updatelastjoin(regchanuser *rcup); | |
975 | void csdb_updatetopic(regchan *rcp); | |
976 | void csdb_updatechannel(regchan *rcp); | |
977 | void csdb_updatechannelcounters(regchan *rcp); | |
978 | void csdb_updatechanneltimestamp(regchan *rcp); | |
979 | void csdb_createchannel(regchan *rcp); | |
980 | void csdb_deletechannel(regchan *rcp); | |
981 | void csdb_deleteuser(reguser *rup); | |
982 | void csdb_updateuser(reguser *rup); | |
983 | void csdb_createuser(reguser *rup); | |
984 | void csdb_updatechanuser(regchanuser *rcup); | |
985 | void csdb_createchanuser(regchanuser *rcup); | |
986 | void csdb_deletechanuser(regchanuser *rcup); | |
987 | void csdb_createban(regchan *rcp, regban *rbp); | |
988 | void csdb_deleteban(regban *rbp); | |
989 | void csdb_createmail(reguser *rup, int type); | |
990 | void csdb_deletemaildomain(maildomain *mdp); | |
991 | void csdb_createmaildomain(maildomain *mdp); | |
992 | void csdb_updatemaildomain(maildomain *mdp); | |
80d2de64 P |
993 | void csdb_chanlevhistory_insert(regchan *rcp, nick *np, reguser *trup, flag_t oldflags, flag_t newflags); |
994 | void csdb_accounthistory_insert(nick *np, char *oldpass, char *newpass, sstring *oldemail, sstring *newemail); | |
995 | void csdb_cleanuphistories(); | |
996 | ||
c86edd1d | 997 | #endif |