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