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