3 * Top level data structures and function prototypes for the
4 * channel service module
16 #include "../lib/sstring.h"
17 #include "../core/schedule.h"
18 #include "../lib/flags.h"
19 #include "../nick/nick.h"
20 #include "../channel/channel.h"
21 #include "../parser/parser.h"
22 #include "../localuser/localuserchannel.h"
25 #include "../dbapi/dbapi.h"
35 #define QVERSION "1.00"
37 /* Achievements: Nothing before ACHIEVEMENTS_START
38 * opt-in only after ACHIEVEMENTS_END
39 * Titles are valid only between ACHIEVEMENTS_START and ACHIEVEMENTS_END */
41 //#define ACH_TEST_APRIL1
43 #ifdef ACH_TEST_APRIL1
45 #define ACHIEVEMENTS_START 1269702917
46 #define ACHIEVEMENTS_END 1270162800
48 #elif defined(ACH_TEST_POSTAPRIL1)
50 #define ACHIEVEMENTS_START 0
51 #define ACHIEVEMENTS_END 1269702917
55 #define ACHIEVEMENTS_START 1270076400
56 #define ACHIEVEMENTS_END 1270162800
60 /* Mini-hash of known users on channels to make lookups faster;
61 * how big do we make it? */
62 #define REGCHANUSERHASHSIZE 5
64 #define WELCOMELEN 250
66 #define AUTOLIMIT_INTERVAL 60
67 #define COUNTERSYNCINTERVAL 600
68 #define LINGERTIME 300
69 #define DUMPINTERVAL 300
72 #define CHANOPHISTORY 10
74 /* Suspension and g-line hit count limits */
75 #define MAXGLINEUSERS 50
76 #define MAXSUSPENDHIT 500
78 /* Maximum number of times a user may attempt to auth */
79 #define MAXAUTHATTEMPT 5
81 /* Maximum number of hellos in a session */
84 /* Maximum number of times a user may actually be authed */
85 #define MAXAUTHCOUNT 4
87 /* Maximum number of accounts that may share an email address */
88 #define MD_DEFAULTACTLIMIT 2
90 /* If set will issue warnings when authgate cached stuff changes */
91 #define AUTHGATE_WARNINGS
93 /* Challenge auth faq site */
94 #define CHALLENGEAUTHSITE "http://www.quakenet.org/development/challengeauth/"
97 #define CLEANUP_ACCOUNT_INACTIVE 240 /* make sure you update CLEANUP_AUTHHISTORY too... */
98 #define CLEANUP_ACCOUNT_UNUSED 3
99 #define CLEANUP_CHANNEL_INACTIVE 120
101 #define CLEANUP_AUTHHISTORY 300
103 #define CLEANUP_MIN_CHAN_SIZE 2
105 /* Sizes of the main hashes */
106 #define REGUSERHASHSIZE 60000
107 #define MAILDOMAINHASHSIZE 60000
109 /* Number of languages and messages */
112 /* Maximum number of user chanlevs and bans */
113 #define MAXCHANLEVS 500
116 /* Maximum number of channels a user may be known on */
117 #define MAXCHANNELS 500
119 /* Sources of entropy and standard length defines */
120 #define ENTROPYSOURCE "/dev/urandom"
123 /* Minimum acceptable reason length for stuff like deluser */
124 #define MIN_REASONLEN 15
126 /* Maximum number of usernames displayed by the lastreg command */
127 #define MAX_LASTREG 100
129 #include "chanserv_messages.h"
131 #define CSMIN(a, b) ((a)<(b)?(a):(b))
132 #define CSMAX(a, b) ((a)>(b)?(a):(b))
134 /* List of privileged operations */
136 #define QPRIV_SUSPENDBYPASS 1
137 #define QPRIV_VIEWCHANFLAGS 100
138 #define QPRIV_VIEWFULLCHANLEV 101
139 #define QPRIV_VIEWFULLWHOIS 102
140 #define QPRIV_VIEWCHANMODES 103
141 #define QPRIV_VIEWAUTOLIMIT 104
142 #define QPRIV_VIEWBANTIMER 105
143 #define QPRIV_VIEWUSERFLAGS 106
144 #define QPRIV_VIEWWELCOME 107
145 #define QPRIV_VIEWCOMMENTS 108
146 #define QPRIV_VIEWEMAIL 109
147 #define QPRIV_VIEWCHANSUSPENSION 110
148 #define QPRIV_VIEWSUSPENDEDBY 111
149 #define QPRIV_VIEWWALLMESSAGE 112
150 #define QPRIV_VIEWREALHOST 113
152 #define QPRIV_CHANGECHANFLAGS 200
153 #define QPRIV_CHANGECHANLEV 201
154 #define QPRIV_CHANGECHANMODES 202
155 #define QPRIV_CHANGEAUTOLIMIT 203
156 #define QPRIV_CHANGEBANTIMER 204
157 #define QPRIV_CHANGEUSERFLAGS 205
158 #define QPRIV_CHANGEWELCOME 206
159 #define QPRIV_RESETCHANSTAT 207
161 /* List of access checks */
163 #define CA_AUTHED 0x0001
164 #define CA_TOPICPRIV 0x0008
165 #define CA_KNOWN 0x0010
166 #define CA_VOICEPRIV 0x0020
167 #define CA_OPPRIV 0x0040
168 #define CA_MASTERPRIV 0x0080
169 #define CA_OWNERPRIV 0x0100
171 #define CA_ONCHAN 0x0400
172 #define CA_OFFCHAN 0x0800
173 #define CA_OPPED 0x1000
174 #define CA_DEOPPED 0x2000
175 #define CA_VOICED 0x4000
176 #define CA_DEVOICED 0x8000
178 #define CA_NEEDKNOWN (CA_KNOWN|CA_OPPRIV|CA_MASTERPRIV|CA_TOPICPRIV|CA_OWNERPRIV)
179 #define CA_ONCHANREQ (CA_ONCHAN|CA_OPPED|CA_DEOPPED|CA_VOICED|CA_DEVOICED)
183 /* to reenable this also grep for NOINFO... as some code has been commented out */
184 //#define QUFLAG_NOINFO 0x0001 /* +s */
185 #define QUFLAG_INACTIVE 0x0001 /* +I */
186 #define QUFLAG_GLINE 0x0002 /* +g */
187 #define QUFLAG_NOTICE 0x0004 /* +n */
188 #define QUFLAG_STAFF 0x0008 /* +q */
189 #define QUFLAG_SUSPENDED 0x0010 /* +z */
190 #define QUFLAG_OPER 0x0020 /* +o */
191 #define QUFLAG_DEV 0x0040 /* +d */
192 #define QUFLAG_PROTECT 0x0080 /* +p */
193 #define QUFLAG_HELPER 0x0100 /* +h */
194 #define QUFLAG_ADMIN 0x0200 /* +a */
195 #define QUFLAG_INFO 0x0400 /* +i */
196 #define QUFLAG_DELAYEDGLINE 0x0800 /* +G */
197 #define QUFLAG_NOAUTHLIMIT 0x1000 /* +L */
198 #define QUFLAG_ACHIEVEMENTS 0x2000 /* +c */
199 #define QUFLAG_CLEANUPEXEMPT 0x4000 /* +D */
200 #define QUFLAG_TRUST 0x8000 /* +T */
201 #define QUFLAG_ALL 0xffff
203 //#define UIsNoInfo(x) ((x)->flags & QUFLAG_NOINFO)
204 #define UIsNoInfo(x) 0
205 #define UIsInactive(x) ((x)->flags & QUFLAG_INACTIVE)
206 #define UIsGline(x) ((x)->flags & QUFLAG_GLINE)
207 #define UIsNotice(x) ((x)->flags & QUFLAG_NOTICE)
208 #define UIsSuspended(x) ((x)->flags & QUFLAG_SUSPENDED)
209 #define UIsOper(x) ((x)->flags & QUFLAG_OPER)
210 #define UIsDev(x) ((x)->flags & QUFLAG_DEV)
211 #define UIsProtect(x) ((x)->flags & QUFLAG_PROTECT)
212 #define UIsHelper(x) ((x)->flags & QUFLAG_HELPER)
213 #define UIsAdmin(x) ((x)->flags & QUFLAG_ADMIN)
214 #define UIsInfo(x) ((x)->flags & QUFLAG_INFO)
215 #define UIsDelayedGline(x) ((x)->flags & QUFLAG_DELAYEDGLINE)
216 #define UIsNoAuthLimit(x) ((x)->flags & QUFLAG_NOAUTHLIMIT)
217 #define UIsCleanupExempt(x) ((x)->flags & QUFLAG_CLEANUPEXEMPT)
218 #define UIsStaff(x) ((x)->flags & QUFLAG_STAFF)
219 #define UIsAchievements(x) ((x)->flags & QUFLAG_ACHIEVEMENTS)
221 #define UHasSuspension(x) ((x)->flags & (QUFLAG_GLINE|QUFLAG_DELAYEDGLINE|QUFLAG_SUSPENDED))
223 #define UHasStaffPriv(x) ((x)->flags & (QUFLAG_STAFF | QUFLAG_HELPER | QUFLAG_OPER | QUFLAG_ADMIN | QUFLAG_DEV))
224 #define UHasHelperPriv(x) ((x)->flags & (QUFLAG_HELPER | QUFLAG_OPER | QUFLAG_ADMIN | QUFLAG_DEV))
225 #define UHasOperPriv(x) ((x)->flags & (QUFLAG_OPER | QUFLAG_ADMIN | QUFLAG_DEV))
226 #define UHasAdminPriv(x) ((x)->flags & (QUFLAG_ADMIN | QUFLAG_DEV))
228 #define USetInactive(x) ((x)->flags |= QUFLAG_INACTIVE)
229 #define USetGline(x) ((x)->flags |= QUFLAG_GLINE)
230 #define USetNotice(x) ((x)->flags |= QUFLAG_NOTICE)
231 #define USetSuspended(x) ((x)->flags |= QUFLAG_SUSPENDED)
232 #define USetOper(x) ((x)->flags |= QUFLAG_OPER)
233 #define USetDev(x) ((x)->flags |= QUFLAG_DEV)
234 #define USetProtect(x) ((x)->flags |= QUFLAG_PROTECT)
235 #define USetHelper(x) ((x)->flags |= QUFLAG_HELPER)
236 #define USetAdmin(x) ((x)->flags |= QUFLAG_ADMIN)
237 #define USetInfo(x) ((x)->flags |= QUFLAG_INFO)
238 #define USetDelayedGline(x) ((x)->flags |= QUFLAG_DELAYEDGLINE)
239 #define USetNoAuthLimit(x) ((x)->flags |= QUFLAG_NOAUTHLIMIT)
240 #define USetCleanupExempt(x) ((x)->flags |= QUFLAG_CLEANUPEXEMPT)
241 #define USetTrust(x) ((x)->flags |= QUFLAG_TRUST)
243 #define UClearInactive(x) ((x)->flags &= ~QUFLAG_INACTIVE)
244 #define UClearGline(x) ((x)->flags &= ~QUFLAG_GLINE)
245 #define UClearNotice(x) ((x)->flags &= ~QUFLAG_NOTICE)
246 #define UClearSuspended(x) ((x)->flags &= ~QUFLAG_SUSPENDED)
247 #define UClearOper(x) ((x)->flags &= ~QUFLAG_OPER)
248 #define UClearDev(x) ((x)->flags &= ~QUFLAG_DEV)
249 #define UClearProtect(x) ((x)->flags &= ~QUFLAG_PROTECT)
250 #define UClearHelper(x) ((x)->flags &= ~QUFLAG_HELPER)
251 #define UClearAdmin(x) ((x)->flags &= ~QUFLAG_ADMIN)
252 #define UClearInfo(x) ((x)->flags &= ~QUFLAG_INFO)
253 #define UClearDelayedGline(x) ((x)->flags &= ~QUFLAG_DELAYEDGLINE)
254 #define UClearNoAuthLimit(x) ((x)->flags &= ~QUFLAG_NOAUTHLIMIT)
255 #define UClearCleanupExempt(x) ((x)->flags &= ~QUFLAG_CLEANUPEXEMPT)
256 #define UClearTrust(x) ((x)->flags &= ~QUFLAG_TRUST)
259 #define MAX_RESEND_TIME 2*3600L /* cooling off period */
260 #define VALID_EMAIL "\\A[^\\s\\+@]+@([a-z0-9][a-z0-9\\-]*\\.)+[a-z]{2,}\\Z"
262 #define VALID_ACCOUNT_NAME "\\A[a-z][a-z0-9\\-]+\\Z"
264 #define QMAIL_NEWACCOUNT 1 /* new account */
265 #define QMAIL_REQPW 2 /* requestpassword */
266 #define QMAIL_NEWPW 3 /* new password */
267 #define QMAIL_RESET 4 /* reset account */
268 #define QMAIL_NEWEMAIL 5 /* new email address */
269 #define QMAIL_ACTIVATEEMAIL 6 /* new style new account */
273 #define QCFLAG_AUTOOP 0x0001 /* +a */
274 #define QCFLAG_BITCH 0x0002 /* +b */
275 #define QCFLAG_AUTOLIMIT 0x0004 /* +c */
276 #define QCFLAG_ENFORCE 0x0008 /* +e */
277 #define QCFLAG_FORCETOPIC 0x0010 /* +f */
278 #define QCFLAG_AUTOVOICE 0x0020 /* +g */
279 #define QCFLAG_INFO 0x0040 /* +i */
280 #define QCFLAG_JOINED 0x0080 /* +j */
281 #define QCFLAG_KNOWNONLY 0x0100 /* +k */
282 #define QCFLAG_PROTECT 0x0200 /* +p */
283 #define QCFLAG_NOINFO 0x0400 /* +s */
284 #define QCFLAG_TOPICSAVE 0x0800 /* +t */
285 #define QCFLAG_VOICEALL 0x1000 /* +v */
286 #define QCFLAG_WELCOME 0x2000 /* +w */
287 #define QCFLAG_SUSPENDED 0x4000 /* +z */
288 #define QCFLAG_ACHIEVEMENTS 0x8000 /* +h */
290 #define CIsAutoOp(x) ((x)->flags & QCFLAG_AUTOOP)
291 #define CIsBitch(x) ((x)->flags & QCFLAG_BITCH)
292 #define CIsAutoLimit(x) ((x)->flags & QCFLAG_AUTOLIMIT)
293 #define CIsEnforce(x) ((x)->flags & QCFLAG_ENFORCE)
294 #define CIsForceTopic(x) ((x)->flags & QCFLAG_FORCETOPIC)
295 #define CIsAutoVoice(x) ((x)->flags & QCFLAG_AUTOVOICE)
296 #define CIsJoined(x) ((x)->flags & QCFLAG_JOINED)
297 #define CIsKnownOnly(x) ((x)->flags & QCFLAG_KNOWNONLY)
298 #define CIsProtect(x) ((x)->flags & QCFLAG_PROTECT)
299 #define CIsTopicSave(x) ((x)->flags & QCFLAG_TOPICSAVE)
300 #define CIsVoiceAll(x) ((x)->flags & QCFLAG_VOICEALL)
301 #define CIsWelcome(x) ((x)->flags & QCFLAG_WELCOME)
302 #define CIsSuspended(x) ((x)->flags & QCFLAG_SUSPENDED)
303 #define CIsInfo(x) ((x)->flags & QCFLAG_INFO)
304 #define CIsNoInfo(x) ((x)->flags & QCFLAG_NOINFO)
305 #define CIsAchievements(x) ((x)->flags & QCFLAG_ACHIEVEMENTS)
307 #define CSetAutoOp(x) ((x)->flags |= QCFLAG_AUTOOP)
308 #define CSetBitch(x) ((x)->flags |= QCFLAG_BITCH)
309 #define CSetAutoLimit(x) ((x)->flags |= QCFLAG_AUTOLIMIT)
310 #define CSetEnforce(x) ((x)->flags |= QCFLAG_ENFORCE)
311 #define CSetForceTopic(x) ((x)->flags |= QCFLAG_FORCETOPIC)
312 #define CSetAutoVoice(x) ((x)->flags |= QCFLAG_AUTOVOICE)
313 #define CSetJoined(x) ((x)->flags |= QCFLAG_JOINED)
314 #define CSetKnownOnly(x) ((x)->flags |= QCFLAG_KNOWNONLY)
315 #define CSetProtect(x) ((x)->flags |= QCFLAG_PROTECT)
316 #define CSetTopicSave(x) ((x)->flags |= QCFLAG_TOPICSAVE)
317 #define CSetVoiceAll(x) ((x)->flags |= QCFLAG_VOICEALL)
318 #define CSetWelcome(x) ((x)->flags |= QCFLAG_WELCOME)
319 #define CSetSuspended(x) ((x)->flags |= QCFLAG_SUSPENDED)
321 #define CClearAutoOp(x) ((x)->flags &= ~QCFLAG_AUTOOP)
322 #define CClearBitch(x) ((x)->flags &= ~QCFLAG_BITCH)
323 #define CClearAutoLimit(x) ((x)->flags &= ~QCFLAG_AUTOLIMIT)
324 #define CClearEnforce(x) ((x)->flags &= ~QCFLAG_ENFORCE)
325 #define CClearForceTopic(x) ((x)->flags &= ~QCFLAG_FORCETOPIC)
326 #define CClearAutoVoice(x) ((x)->flags &= ~QCFLAG_AUTOVOICE)
327 #define CClearJoined(x) ((x)->flags &= ~QCFLAG_JOINED)
328 #define CClearKnownOnly(x) ((x)->flags &= ~QCFLAG_KNOWNONLY)
329 #define CClearProtect(x) ((x)->flags &= ~QCFLAG_PROTECT)
330 #define CClearTopicSave(x) ((x)->flags &= ~QCFLAG_TOPICSAVE)
331 #define CClearVoiceAll(x) ((x)->flags &= ~QCFLAG_VOICEALL)
332 #define CClearWelcome(x) ((x)->flags &= ~QCFLAG_WELCOME)
333 #define CClearSuspended(x) ((x)->flags &= ~QCFLAG_SUSPENDED)
335 #define QCFLAG_USERCONTROL (QCFLAG_AUTOOP|QCFLAG_BITCH|QCFLAG_AUTOLIMIT| \
336 QCFLAG_ENFORCE|QCFLAG_FORCETOPIC|QCFLAG_AUTOVOICE| \
337 QCFLAG_PROTECT|QCFLAG_TOPICSAVE|QCFLAG_VOICEALL| \
338 QCFLAG_WELCOME|QCFLAG_KNOWNONLY|QCFLAG_ACHIEVEMENTS )
340 #define QCFLAG_ALL 0xffff
343 /* Channel user ("chanlev") flags */
344 /* Slightly funny order here: list the "biggest" flags at the
345 * top so we can do sorted "chanlev" output more easily */
346 #define QCUFLAG_OWNER 0x8000 /* +n */
347 #define QCUFLAG_MASTER 0x4000 /* +m */
348 #define QCUFLAG_OP 0x2000 /* +o */
349 #define QCUFLAG_VOICE 0x1000 /* +v */
350 #define QCUFLAG_AUTOOP 0x0001 /* +a */
351 #define QCUFLAG_BANNED 0x0002 /* +b */
352 #define QCUFLAG_DENY 0x0004 /* +d */
353 #define QCUFLAG_AUTOVOICE 0x0008 /* +g */
354 #define QCUFLAG_QUIET 0x0010 /* +q */
355 #define QCUFLAG_NOINFO 0x0020 /* +s */
356 #define QCUFLAG_TOPIC 0x0040 /* +t */
357 #define QCUFLAG_HIDEWELCOME 0x0080 /* +w */
358 #define QCUFLAG_PROTECT 0x0100 /* +p */
359 #define QCUFLAG_INFO 0x0200 /* +i */
360 #define QCUFLAG_KNOWN 0x0400 /* +k */
361 #define QCUFLAG_AUTOINVITE 0x0800 /* +j */
363 #define QCUFLAG_SIGNIFICANT (QCUFLAG_MASTER|QCUFLAG_OWNER|QCUFLAG_OP)
365 #define QCUFLAG_MASTERCON (QCUFLAG_AUTOOP|QCUFLAG_BANNED|QCUFLAG_DENY| \
366 QCUFLAG_GIVE|QCUFLAG_OP|QCUFLAG_QUIET|QCUFLAG_TOPIC| \
367 QCUFLAG_VOICE|QCUFLAG_PROTECT)
369 #define QCUFLAG_SELFCON (QCUFLAG_OP | QCUFLAG_VOICE | QCUFLAG_AUTOOP | QCUFLAG_AUTOVOICE | \
370 QCUFLAG_TOPIC | QCUFLAG_INFO)
372 #define QCUFLAGS_PUBLIC (QCUFLAG_OWNER | QCUFLAG_MASTER | QCUFLAG_OP | QCUFLAG_VOICE | \
373 QCUFLAG_KNOWN | QCUFLAG_AUTOOP | QCUFLAG_AUTOVOICE | QCUFLAG_TOPIC | \
376 #define QCUFLAGS_PUNISH (QCUFLAG_BANNED | QCUFLAG_QUIET | QCUFLAG_DENY)
377 #define QCUFLAGS_PERSONAL (QCUFLAG_HIDEWELCOME | QCUFLAG_AUTOINVITE)
379 #define QCUFLAG_ALL 0xffff
381 #define CUIsOwner(x) ((x)->flags & QCUFLAG_OWNER)
382 #define CUIsMaster(x) ((x)->flags & QCUFLAG_MASTER)
383 #define CUIsOp(x) ((x)->flags & QCUFLAG_OP)
384 #define CUIsVoice(x) ((x)->flags & QCUFLAG_VOICE)
385 #define CUIsAutoOp(x) ((x)->flags & QCUFLAG_AUTOOP)
386 #define CUIsBanned(x) ((x)->flags & QCUFLAG_BANNED)
387 #define CUIsDeny(x) ((x)->flags & QCUFLAG_DENY)
388 #define CUIsAutoVoice(x) ((x)->flags & QCUFLAG_AUTOVOICE)
389 #define CUIsQuiet(x) ((x)->flags & QCUFLAG_QUIET)
390 #define CUIsNoInfo(x) ((x)->flags & QCUFLAG_NOINFO)
391 #define CUIsTopic(x) ((x)->flags & QCUFLAG_TOPIC)
392 #define CUIsHideWelcome(x) ((x)->flags & QCUFLAG_HIDEWELCOME)
393 #define CUIsProtect(x) ((x)->flags & QCUFLAG_PROTECT)
394 #define CUIsInfo(x) ((x)->flags & QCUFLAG_INFO)
395 #define CUIsKnown(x) ((x)->flags & QCUFLAG_KNOWN)
396 #define CUIsAutoInvite(x) ((x)->flags & QCUFLAG_AUTOINVITE)
398 #define CUKnown(x) (CUIsKnown(x) || CUHasVoicePriv(x))
399 #define CUHasVoicePriv(x) ((x)->flags & (QCUFLAG_VOICE | QCUFLAG_OP | QCUFLAG_MASTER | QCUFLAG_OWNER))
400 #define CUHasOpPriv(x) ((x)->flags & (QCUFLAG_OP | QCUFLAG_MASTER | QCUFLAG_OWNER))
401 #define CUHasMasterPriv(x) ((x)->flags & (QCUFLAG_MASTER | QCUFLAG_OWNER))
402 #define CUHasTopicPriv(x) ((x)->flags & (QCUFLAG_MASTER | QCUFLAG_OWNER | QCUFLAG_TOPIC))
404 #define CUSetOwner(x) ((x)->flags |= QCUFLAG_OWNER)
405 #define CUSetMaster(x) ((x)->flags |= QCUFLAG_MASTER)
406 #define CUSetOp(x) ((x)->flags |= QCUFLAG_OP)
407 #define CUSetVoice(x) ((x)->flags |= QCUFLAG_VOICE)
408 #define CUSetAutoOp(x) ((x)->flags |= QCUFLAG_AUTOOP)
409 #define CUSetBanned(x) ((x)->flags |= QCUFLAG_BANNED)
410 #define CUSetDeny(x) ((x)->flags |= QCUFLAG_DENY)
411 #define CUSetAutoVoice(x) ((x)->flags |= QCUFLAG_AUTOVOICE)
412 #define CUSetQuiet(x) ((x)->flags |= QCUFLAG_QUIET)
413 #define CUSetTopic(x) ((x)->flags |= QCUFLAG_TOPIC)
414 #define CUSetHideWelcome(x) ((x)->flags |= QCUFLAG_HIDEWELCOME)
415 #define CUSetKnown(x) ((x)->flags |= QCUFLAG_KNOWN)
416 #define CUSetAutoInvite(x) ((x)->flags |= QCUFLAG_AUTOINVITE)
418 #define CUClearOwner(x) ((x)->flags &= ~QCUFLAG_OWNER)
419 #define CUClearMaster(x) ((x)->flags &= ~QCUFLAG_MASTER)
420 #define CUClearOp(x) ((x)->flags &= ~QCUFLAG_OP)
421 #define CUClearVoice(x) ((x)->flags &= ~QCUFLAG_VOICE)
422 #define CUClearAutoOp(x) ((x)->flags &= ~QCUFLAG_AUTOOP)
423 #define CUClearBanned(x) ((x)->flags &= ~QCUFLAG_BANNED)
424 #define CUClearDeny(x) ((x)->flags &= ~QCUFLAG_DENY)
425 #define CUClearAutoVoice(x) ((x)->flags &= ~QCUFLAG_AUTOVOICE)
426 #define CUClearQuiet(x) ((x)->flags &= ~QCUFLAG_QUIET)
427 #define CUClearTopic(x) ((x)->flags &= ~QCUFLAG_TOPIC)
428 #define CUClearHideWelcome(x) ((x)->flags &= ~QCUFLAG_HIDEWELCOME)
429 #define CUClearKnown(x) ((x)->flags &= ~QCUFLAG_KNOWN)
430 #define CUClearAutoInvite(x) ((x)->flags &= ~QCUFLAG_AUTOINVITE)
432 #define QCSTAT_OPCHECK 0x0001 /* Do op check */
433 #define QCSTAT_MODECHECK 0x0002 /* Do mode check */
434 #define QCSTAT_BANCHECK 0x0004 /* Do ban check */
436 #define QUSTAT_DEAD 0x8000 /* User has been deleted.. */
438 #define QCMD_SECURE 0x0001 /* Must use "user@server" to use this command */
439 #define QCMD_AUTHED 0x0002 /* Only available to authed users */
440 #define QCMD_NOTAUTHED 0x0004 /* Only available to NON-authed users */
442 #define QCMD_HELPER 0x0010 /* Only available to helpers */
443 #define QCMD_OPER 0x0020 /* Only available to opers */
444 #define QCMD_ADMIN 0x0040 /* Only available to admins */
445 #define QCMD_DEV 0x0080 /* Only available to developers */
446 #define QCMD_STAFF 0x0200 /* Only available to staff */
448 #define QCMD_ALIAS 0x0100 /* Don't list on SHOWCOMMANDS */
449 #define QCMD_HIDDEN QCMD_ALIAS
451 #define QCMD_ACHIEVEMENTS 0x0400 /* Achievement-related commands */
452 #define QCMD_TITLES 0x0800 /* Title-related commands */
454 #define CS_INIT_DB 0x1 /* Loading database.. */
455 #define CS_INIT_NOUSER 0x2 /* Loaded DB, waiting for user to be created */
456 #define CS_INIT_READY 0x3 /* Ready for action! */
461 typedef struct maildomain
{
463 unsigned int maildomain_magic
;
469 unsigned int actlimit
;
471 struct reguser
*users
;
472 struct maildomain
*parent
;
473 struct maildomain
*nextbyname
;
474 struct maildomain
*nextbyID
;
477 #define MDFLAG_LIMIT 0x0001 /* +l */
478 #define MDFLAG_BANNED 0x0002 /* +b */
479 #define MDFLAG_ACTLIMIT 0x0004 /* +u */
480 #define MDFLAG_ALL 0x0007
482 #define MDFLAG_DEFAULT MDFLAG_ACTLIMIT
484 #define MDHasLimit(x) ((x)->flags & MDFLAG_LIMIT)
485 #define MDSetLimit(x) ((x)->flags |= MDFLAG_LIMIT)
486 #define MDClearLimit(x) ((x)->flags &= ~MDFLAG_LIMIT)
487 #define MDIsBanned(x) ((x)->flags & MDFLAG_BANNED)
488 #define MDSetBanned(x) ((x)->flags |= MDFLAG_BANNED)
489 #define MDClearBanned(x) ((x)->flags &= ~MDFLAG_BANNED)
490 #define MDHasActLimit(x) ((x)->flags & MDFLAG_ACTLIMIT)
491 #define MDSetActLimit(x) ((x)->flags |= MDFLAG_ACTLIMIT)
492 #define MDClearActLimit(x) ((x)->flags &= ~MDFLAG_ACTLIMIT)
495 typedef struct regban
{
497 unsigned int regchanban_magic
;
499 unsigned int ID
; /* ID in the database */
500 struct chanban
*cbp
; /* Standard chanban struct */
501 unsigned int setby
; /* Who set the ban */
502 time_t expiry
; /* When the ban expires */
503 sstring
*reason
; /* Reason to attach to related kicks */
504 struct regban
*next
; /* Next ban on this channel */
507 /* Registered channel */
508 typedef struct regchan
{
510 unsigned int regchan_magic
;
512 unsigned int ID
; /* Unique number from database */
513 chanindex
*index
; /* Pointer to the channel index record */
514 time_t ltimestamp
; /* The last timestamp we saw on this channel */
516 flag_t flags
; /* Chanflags */
517 flag_t status
; /* Runtime status codes */
518 flag_t forcemodes
; /* Forced modes */
519 flag_t denymodes
; /* Denied modes */
521 unsigned short limit
; /* Limit to enforce if +l is set */
522 short autolimit
; /* How many slots to leave when autolimiting */
523 short banstyle
; /* Ban style for +b type bans */
525 time_t created
; /* When the service was added */
526 time_t lastactive
; /* When the channel was last "active" */
527 time_t statsreset
; /* When the users stats were last reset */
528 time_t ostatsreset
; /* When the oper stats were last reset */
529 time_t banduration
; /* How long to remove bans after (0=don't) */
530 time_t autoupdate
; /* When the autolimit next needs checking */
531 time_t lastbancheck
; /* Timestamp of last ban check */
532 time_t lastcountersync
; /* When the counters were last synced.. */
533 time_t lastpart
; /* When the last user left the channel */
534 time_t suspendtime
; /* When the channel was suspended */
536 unsigned int founder
; /* founder */
537 unsigned int addedby
; /* oper adding chan */
538 unsigned int suspendby
; /* who suspended chan */
540 short chantype
; /* What "type" the channel is */
542 unsigned int totaljoins
; /* Total joins since created */
543 unsigned int tripjoins
; /* Total joins since last stats reset */
544 unsigned int otripjoins
; /* Total joins since last oper stats reset */
545 unsigned int maxusers
; /* Max users since created */
546 unsigned int tripusers
; /* Max users since last stats reset */
547 unsigned int otripusers
; /* Max users since last oper stats reset */
549 sstring
*welcome
; /* Welcome message */
550 sstring
*topic
; /* "default" topic set by settopic */
551 sstring
*key
; /* Key as enforced by +k */
552 sstring
*suspendreason
; /* Suspend reason */
553 sstring
*comment
; /* Oper-settable channel comment */
555 void *checksched
; /* Handle for channel check schedule */
557 struct regchanuser
*regusers
[REGCHANUSERHASHSIZE
];
558 struct regban
*bans
; /* List of bans on the channel */
560 char chanopnicks
[CHANOPHISTORY
][NICKLEN
+1]; /* Last CHANOPHISTORY ppl to get ops */
561 unsigned int chanopaccts
[CHANOPHISTORY
]; /* Which account was responsible for each one */
562 short chanoppos
; /* Position in the array */
565 struct achievement_record
;
567 /* Registered user */
568 typedef struct reguser
{
570 unsigned int reguser_magic
;
572 unsigned int ID
; /* From the database */
574 char username
[NICKLEN
+1];
578 time_t lastemailchange
;
580 flag_t flags
; /* user flags */
581 flag_t status
; /* runtime status */
582 short languageid
; /* what language to speak to the user */
584 unsigned int suspendby
; /* Userid of oper who suspended this user */
585 time_t suspendexp
; /* Expiry date of suspension */
586 time_t suspendtime
; /* When user was suspended */
587 time_t lockuntil
; /* Time until users account is unlocked (pass change, email, etc) */
589 char password
[PASSLEN
+1];
594 sstring
*email
; /* Registered e-mail */
595 sstring
*lastemail
; /* Last registered e-mail */
596 sstring
*lastuserhost
; /* Last user@host */
597 sstring
*suspendreason
; /* Why the account is suspended */
598 sstring
*comment
; /* Oper-settable user comment */
599 sstring
*info
; /* User-settable info line */
601 struct regchanuser
*knownon
; /* Which channels this user is known on */
603 /* These fields are for the nick protection system */
604 void *checkshd
; /* When we're going to check for an imposter */
605 int stealcount
; /* How many times we've had to free the nick up */
606 nick
*fakeuser
; /* If we had to "take" the nick, here's the pointer */
608 time_t lastpasschange
;
610 struct reguser
*nextbydomain
;
611 struct reguser
*nextbyname
;
612 struct reguser
*nextbyID
;
615 /* Registered channel user */
616 typedef struct regchanuser
{
618 unsigned int regchanuser_magic
;
620 struct reguser
*user
;
621 struct regchan
*chan
;
623 time_t changetime
; /* Timestamp of last "significant" change */
624 time_t usetime
; /* Timestamp of last use */
625 sstring
*info
; /* User-settable info line */
626 struct regchanuser
*nextbyuser
;
627 struct regchanuser
*nextbychan
;
630 typedef struct cslang
{
635 typedef struct cmdsummary
{
637 sstring
*bylang
[MAXLANG
];
641 typedef struct activeuser
{
643 unsigned int activeuser_magic
;
645 unsigned short authattempts
; /* number of times user has attempted to auth */
646 unsigned short helloattempts
; /* number of times user has attempted to hello... */
647 unsigned char entropy
[ENTROPYLEN
]; /* entropy used for challengeauth */
649 struct activeuser
*next
; /* purely for keeping track of free, but not free'd structures */
652 typedef struct maillock
{
654 unsigned int maillock_magic
;
659 unsigned int createdby
;
661 struct maillock
*next
;
666 #define REGUSERMAGIC 0x4d42de03
667 #define REGCHANMAGIC 0x5bf2aa30
668 #define REGCHANUSERMAGIC 0x19628b63
669 #define REGCHANBANMAGIC 0x5a6f555a
670 #define ACTIVEUSERMAGIC 0x897f98a0
671 #define MAILDOMAINMAGIC 0x27cde46f
672 #define MAILLOCKMAGIC 0x3c81d762
674 #define verifyreguser(x) assert((x)->reguser_magic == REGUSERMAGIC)
675 #define verifyregchan(x) assert((x)->regchan_magic == REGCHANMAGIC)
676 #define verifyregchanuser(x) assert((x)->regchanuser_magic == REGCHANUSERMAGIC)
677 #define verifyregchanban(x) assert((x)->regchanban_magic == REGCHANBANMAGIC)
678 #define verifyactiveuser(x) assert((x)->activeuser_magic == ACTIVEUSERMAGIC)
679 #define verifymaildomain(x) assert((x)->maildomain_magic == MAILDOMAINMAGIC)
680 #define verifymaillock(x) assert((x)->maillock_magic == MAILLOCKMAGIC)
682 #define tagreguser(x) ((x)->reguser_magic = REGUSERMAGIC)
683 #define tagregchan(x) ((x)->regchan_magic = REGCHANMAGIC)
684 #define tagregchanuser(x) ((x)->regchanuser_magic = REGCHANUSERMAGIC)
685 #define tagregchanban(x) ((x)->regchanban_magic = REGCHANBANMAGIC)
686 #define tagactiveuser(x) ((x)->activeuser_magic = ACTIVEUSERMAGIC)
687 #define tagmaildomain(x) ((x)->maildomain_magic = MAILDOMAINMAGIC)
688 #define tagmaillock(x) ((x)->maillock_magic = MAILLOCKMAGIC)
691 #define verifyreguser(x)
692 #define verifyregchan(x)
693 #define verifyregchanuser(x)
694 #define verifyregchanban(x)
695 #define verifyactiveuser(x)
696 #define verifymaildomain(x)
697 #define verifymaillock(x)
699 #define tagreguser(x)
700 #define tagregchan(x)
701 #define tagregchanuser(x)
702 #define tagregchanban(x)
703 #define tagactiveuser(x)
704 #define tagmaildomain(x)
705 #define tagmaillock(x)
709 #define getactiveuserfromnick(x) ((activeuser*)(x)->exts[chanservnext])
710 #define getreguserfromnick(x) ((x)->auth?(reguser *)(x)->auth->exts[chanservaext]:NULL)
712 /* Global variables for chanserv module */
713 extern unsigned int lastuserID
;
714 extern unsigned int lastchannelID
;
715 extern unsigned int lastbanID
;
716 extern unsigned int lastdomainID
;
717 extern unsigned int lastmaillockID
;
719 extern int chanserv_init_status
;
720 extern int chanservdb_ready
;
723 extern DBModuleIdentifier q9dbid
, q9adbid
, q9cdbid
, q9udbid
;
726 extern maildomain
*maildomainnametable
[MAILDOMAINHASHSIZE
];
727 extern maildomain
*maildomainIDtable
[MAILDOMAINHASHSIZE
];
729 extern reguser
*regusernicktable
[REGUSERHASHSIZE
];
730 extern reguser
*deadusers
;
732 extern nick
*chanservnick
;
733 extern int chanservext
;
734 extern int chanservnext
;
735 extern int chanservaext
;
737 extern cslang
*cslanguages
[MAXLANG
];
738 extern unsigned int cslangcount
;
740 extern sstring
*csmessages
[MAXLANG
][MAXMESSAGES
];
742 extern const flag rcflags
[];
743 extern const flag rcuflags
[];
744 extern const flag ruflags
[];
745 extern const flag mdflags
[];
747 extern CommandTree
*cscommands
;
749 extern sstring
**chantypes
;
751 extern maillock
*maillocks
;
753 extern sstring
*cs_quitreason
;
755 /* Function prototypes */
758 void chanserv_finalinit();
760 /* chanservalloc.c */
761 regchan
*getregchan();
762 void freeregchan(regchan
*rcp
);
763 reguser
*getreguser();
764 void freereguser(reguser
*rup
);
765 regchanuser
*getregchanuser();
766 void freeregchanuser(regchanuser
*rcup
);
768 void freeregban(regban
*rbp
);
769 activeuser
*getactiveuser();
770 void freeactiveuser(activeuser
*aup
);
771 maildomain
*getmaildomain();
772 void freemaildomain(maildomain
*mdp
);
773 maillock
*getmaillock();
774 void freemaillock(maillock
*mlp
);
777 void chanservhashinit();
778 void addregusertohash(reguser
*rup
);
779 reguser
*findreguserbyID(unsigned int ID
);
780 reguser
*findreguserbynick(const char *nick
);
781 reguser
*findreguser(nick
*sender
, const char *str
);
782 void removereguserfromhash(reguser
*rup
);
783 void addregchantohash(regchan
*rcp
);
784 regchan
*findregchanbyID(unsigned int ID
);
785 regchan
*findregchanbyname(const char *name
);
786 void removeregchanfromhash(regchan
*rcp
);
787 void addregusertochannel(regchanuser
*rcup
);
788 regchanuser
*findreguseronchannel(regchan
*rcp
, reguser
*rup
);
789 void delreguserfromchannel(regchan
*rcp
, reguser
*rup
);
790 void addmaildomaintohash(maildomain
*mdp
);
791 maildomain
*findmaildomainbyID(unsigned int ID
);
792 maildomain
*findmaildomainbydomain(char *domain
);
793 maildomain
*findmaildomainbyemail(char *email
);
794 maildomain
*findorcreatemaildomain(char *email
);
795 maildomain
*findnearestmaildomain(char *domain
);
796 void removemaildomainfromhash(maildomain
*mdp
);
797 void addregusertomaildomain(reguser
*rup
, maildomain
*mdp
);
798 void delreguserfrommaildomain(reguser
*rup
, maildomain
*mdp
);
799 reguser
*findreguserbyemail(const char *email
);
802 int chanservdbinit();
804 void loadcommandsummary(Command
*cmd
);
805 void chanservdbclose();
806 void csdb_updatetopic(regchan
*rcp
);
807 void csdb_updatelastjoin(regchanuser
*rcup
);
808 void csdb_updateauthinfo(reguser
*rup
);
809 void csdb_updatechannel(regchan
*rcp
);
810 void csdb_createchannel(regchan
*rcp
);
811 void csdb_deletechannel(regchan
*rcp
);
812 void csdb_deleteuser(reguser
*rup
);
813 void csdb_updatechannelcounters(regchan
*rcp
);
814 void csdb_updatechanneltimestamp(regchan
*rcp
);
815 void csdb_updatechanuser(regchanuser
*rcup
);
816 void csdb_createchanuser(regchanuser
*rcup
);
817 void csdb_deletechanuser(regchanuser
*rcup
);
818 void csdb_createuser(reguser
*rup
);
819 void csdb_updateuser(reguser
*rup
);
820 void csdb_createban(regchan
*rcp
, regban
*rbp
);
821 void csdb_deleteban(regban
*rbp
);
822 void csdb_updateban(regchan
*rcp
, regban
*rbp
);
823 char *csdb_gethelpstr(char *command
, int language
);
824 void csdb_createmail(reguser
*rup
, int type
);
825 void csdb_dohelp(nick
*np
, Command
*cmd
);
826 void csdb_flushchannelcounters(void *arg
);
828 #define q9asyncquery(handler, tag, format, ...) dbasyncqueryi(q9dbid, handler, tag, format , ##__VA_ARGS__)
829 #define q9a_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9adbid, handler, tag, format , ##__VA_ARGS__)
830 #define q9u_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9udbid, handler, tag, format , ##__VA_ARGS__)
831 #define q9c_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9cdbid, handler, tag, format , ##__VA_ARGS__)
832 #define q9cleanup_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9cleanupdbid, handler, tag, format , ##__VA_ARGS__)
834 /* chanservcrypto.c */
835 typedef int (*CRAlgorithm
)(char *, const char *, const char *, const char *);
836 void chanservcryptoinit(void);
837 void chanservcryptofree(void);
838 void cs_getrandbytes(unsigned char *buf
, size_t bytes
);
839 char *cs_calcchallenge(const unsigned char *entropy
);
840 CRAlgorithm
cs_cralgorithm(const char *algorithm
);
841 const char *cs_cralgorithmlist(void);
842 int cs_checkhashpass(const char *username
, const char *password
, const char *junk
, const char *hash
);
843 char *csc_generateresetcode(time_t lockuntil
, char *username
);
844 int csc_verifyqticket(char *data
, char *digest
);
847 void chanservreguser(void *arg
);
848 void chanservjoinchan(channel
*cp
);
849 void chanservpartchan(channel
*cp
, char *reason
);
850 #define chanservsendmessage(np, fmt, ...) chanservsendmessage_real(np, 0, fmt , ##__VA_ARGS__)
851 #define chanservsendmessageoneline(np, fmt, ...) chanservsendmessage_real(np, 1, fmt , ##__VA_ARGS__)
852 void chanservsendmessage_real(nick
*np
, int oneline
, char *message
, ... ) __attribute__ ((format (printf
, 3, 4)));
853 void chanservwallmessage(char *message
, ... ) __attribute__ ((format (printf
, 1, 2)));
854 void chanservcommandinit();
855 void chanservcommandclose();
856 void chanservstdmessage(nick
*np
, int messageid
, ... );
857 void chanservstdvmessage(nick
*np
, reguser
*rup
, int messageid
, int max_line_len
, void (*callback
)(nick
*, char *), va_list va
);
858 void chanservaddcommand(char *command
, int flags
, int maxparams
, CommandHandler handler
, char *description
, const char *help
);
859 void chanservremovecommand(char *command
, CommandHandler handler
);
860 void chanservaddctcpcommand(char *command
, CommandHandler hander
);
861 void chanservremovectcpcommand(char *command
, CommandHandler handler
);
862 void chanservkillstdmessage(nick
*target
, int messageid
, ... );
863 int checkpassword(reguser
*rup
, const char *pass
);
864 int setpassword(reguser
*rup
, const char *pass
);
865 /*reguser *getreguserfromnick(nick *np);
866 activeuser *getactiveuserfromnick(nick *np);*/
867 void cs_checknick(nick
*np
);
868 void cs_checkchanmodes(channel
*cp
);
869 void cs_docheckchanmodes(channel
*cp
, modechanges
*changes
);
870 void cs_docheckopvoice(channel
*cp
, modechanges
*changes
);
871 void cs_checkbans(channel
*cp
);
872 void cs_schedupdate(chanindex
*cip
, int mintime
, int maxtime
);
873 void cs_timerfunc(void *arg
);
874 void cs_removechannel(regchan
*rcp
, char *reason
);
875 int cs_removechannelifempty(nick
*sender
, regchan
*rcp
);
876 void cs_doallautomodes(nick
*np
);
877 void cs_checknickbans(nick
*np
);
878 void cs_setregban(chanindex
*cip
, regban
*rbp
);
879 int cs_bancheck(nick
*np
, channel
*cp
);
880 void cs_banuser(modechanges
*changes
, chanindex
*cip
, nick
*np
, const char *reason
);
881 void cs_removeuser(reguser
*rup
);
882 int checkresponse(reguser
*rup
, const unsigned char *entropy
, const char *response
, CRAlgorithm algorithm
);
883 int checkhashpass(reguser
*rup
, const char *junk
, const char *hash
);
884 flag_t
cs_sanitisechanlev(flag_t flags
);
885 int cs_unbanfn(nick
*sender
, chanindex
*cip
, int (*fn
)(void *arg
, struct chanban
*ban
), void *arg
, int removepermbans
, int abortonfailure
);
886 void cs_logchanop(regchan
*rcp
, char *nick
, reguser
*rup
);
887 int checkreason(nick
*np
, char *reason
);
888 regchan
*cs_addchan(chanindex
*cip
, nick
*sender
, reguser
*addedby
, reguser
*founder
, flag_t flags
, flag_t forcemodes
, flag_t denymodes
, short type
);
890 /* chanservstdcmds.c */
891 int cs_doshowcommands(void *source
, int cargc
, char **cargv
);
892 int cs_dohelp(void *source
, int cargc
, char **cargv
);
893 int cs_doquit(void *source
, int cargc
, char **cargv
);
894 int cs_dosetquitreason(void *source
, int cargc
, char **cargv
);
895 int cs_dorename(void *source
, int cargc
, char **cargv
);
896 int cs_dorehash(void *source
, int cargc
, char **cargv
);
897 int cs_doversion(void *source
, int cargc
, char **cargv
);
898 int cs_doctcpping(void *source
, int cargc
, char **cargv
);
899 int cs_doctcpversion(void *source
, int cargc
, char **cargv
);
900 int cs_doctcpgender(void *source
, int cargc
, char **cargv
);
901 int cs_sendhelp(nick
*sender
, char *cmd
, int oneline
);
903 /* chanservnetevents.c */
904 void cs_handlenick(int hooknum
, void *arg
);
905 void cs_handlesethost(int hooknum
, void *arg
);
906 void cs_handlelostnick(int hooknum
, void *arg
);
907 void cs_handlenewchannel(int hooknum
, void *arg
);
908 void cs_handlelostchannel(int hooknum
, void *arg
);
909 void cs_handlejoin(int hooknum
, void *arg
);
910 void cs_handlemodechange(int hooknum
, void *arg
);
911 void cs_handleburst(int hooknum
, void *arg
);
912 void cs_handletopicchange(int hooknum
, void *arg
);
913 void cs_handleopchange(int hooknum
, void *arg
);
914 void cs_handlenewban(int hooknum
, void *arg
);
915 void cs_handlechanlostuser(int hooknum
, void *arg
);
916 int cs_ischannelactive(channel
*cp
, regchan
*rcp
);
918 /* chanservmessages.c */
921 /* chanservprivs.c */
922 int cs_privcheck(int privnum
, nick
*np
);
923 chanindex
*cs_checkaccess(nick
*np
, const char *chan
, unsigned int flags
, chanindex
*cip
, const char *cmdname
, int priv
, int quiet
);
928 void cs_log(nick
*np
, char *event
, ...) __attribute__ ((format (printf
, 2, 3)));
931 int dumplastjoindata(const char *filename
);
932 int readlastjoindata(const char *filename
);
934 /* chanservschedule.c */
935 void chanservdgline(void *arg
);
937 /* chanservdb_updates.c */
938 void csdb_updateauthinfo(reguser
*rup
);
939 void csdb_updatelastjoin(regchanuser
*rcup
);
940 void csdb_updatetopic(regchan
*rcp
);
941 void csdb_updatechannel(regchan
*rcp
);
942 void csdb_updatechannelcounters(regchan
*rcp
);
943 void csdb_updatechanneltimestamp(regchan
*rcp
);
944 void csdb_createchannel(regchan
*rcp
);
945 void csdb_deletechannel(regchan
*rcp
);
946 void csdb_deleteuser(reguser
*rup
);
947 void csdb_updateuser(reguser
*rup
);
948 void csdb_createuser(reguser
*rup
);
949 void csdb_updatechanuser(regchanuser
*rcup
);
950 void csdb_createchanuser(regchanuser
*rcup
);
951 void csdb_deletechanuser(regchanuser
*rcup
);
952 void csdb_createban(regchan
*rcp
, regban
*rbp
);
953 void csdb_deleteban(regban
*rbp
);
954 void csdb_createmail(reguser
*rup
, int type
);
955 void csdb_deletemaildomain(maildomain
*mdp
);
956 void csdb_createmaildomain(maildomain
*mdp
);
957 void csdb_updatemaildomain(maildomain
*mdp
);
958 void csdb_chanlevhistory_insert(regchan
*rcp
, nick
*np
, reguser
*trup
, flag_t oldflags
, flag_t newflags
);
959 void csdb_accounthistory_insert(nick
*np
, char *oldpass
, char *newpass
, char *oldemail
, char *newemail
);
960 void csdb_cleanuphistories(time_t);
961 void csdb_deletemaillock(maillock
*mlp
);
962 void csdb_createmaillock(maillock
*mlp
);
963 void csdb_updatemaillock(maillock
*mlp
);
966 void q9snprintf(char *buf
, size_t size
, const char *format
, const char *args
, ...);
967 void q9vsnprintf(char *buf
, size_t size
, const char *format
, const char *args
, va_list ap
);
968 void q9strftime(char *buf
, size_t size
, time_t t
);
970 /* chanserv_flags.c */
971 u_int64_t
cs_accountflagmap(reguser
*rup
);
972 u_int64_t
cs_accountflagmap_str(char *flags
);
974 /* chanserv_cleanupdb.c */
975 void cs_cleanupdb(nick
*np
);