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