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 2
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 #include "chanserv_messages.h"
128 #define CSMIN(a, b) ((a)<(b)?(a):(b))
129 #define CSMAX(a, b) ((a)>(b)?(a):(b))
131 /* List of privileged operations */
133 #define QPRIV_SUSPENDBYPASS 1
134 #define QPRIV_VIEWCHANFLAGS 100
135 #define QPRIV_VIEWFULLCHANLEV 101
136 #define QPRIV_VIEWFULLWHOIS 102
137 #define QPRIV_VIEWCHANMODES 103
138 #define QPRIV_VIEWAUTOLIMIT 104
139 #define QPRIV_VIEWBANTIMER 105
140 #define QPRIV_VIEWUSERFLAGS 106
141 #define QPRIV_VIEWWELCOME 107
142 #define QPRIV_VIEWCOMMENTS 108
143 #define QPRIV_VIEWEMAIL 109
144 #define QPRIV_VIEWCHANSUSPENSION 110
145 #define QPRIV_VIEWSUSPENDEDBY 111
146 #define QPRIV_VIEWWALLMESSAGE 112
147 #define QPRIV_VIEWREALHOST 113
149 #define QPRIV_CHANGECHANFLAGS 200
150 #define QPRIV_CHANGECHANLEV 201
151 #define QPRIV_CHANGECHANMODES 202
152 #define QPRIV_CHANGEAUTOLIMIT 203
153 #define QPRIV_CHANGEBANTIMER 204
154 #define QPRIV_CHANGEUSERFLAGS 205
155 #define QPRIV_CHANGEWELCOME 206
156 #define QPRIV_RESETCHANSTAT 207
158 /* List of access checks */
160 #define CA_AUTHED 0x0001
161 #define CA_TOPICPRIV 0x0008
162 #define CA_KNOWN 0x0010
163 #define CA_VOICEPRIV 0x0020
164 #define CA_OPPRIV 0x0040
165 #define CA_MASTERPRIV 0x0080
166 #define CA_OWNERPRIV 0x0100
168 #define CA_ONCHAN 0x0400
169 #define CA_OFFCHAN 0x0800
170 #define CA_OPPED 0x1000
171 #define CA_DEOPPED 0x2000
172 #define CA_VOICED 0x4000
173 #define CA_DEVOICED 0x8000
175 #define CA_NEEDKNOWN (CA_KNOWN|CA_OPPRIV|CA_MASTERPRIV|CA_TOPICPRIV|CA_OWNERPRIV)
176 #define CA_ONCHANREQ (CA_ONCHAN|CA_OPPED|CA_DEOPPED|CA_VOICED|CA_DEVOICED)
180 /* to reenable this also grep for NOINFO... as some code has been commented out */
181 //#define QUFLAG_NOINFO 0x0001 /* +s */
182 #define QUFLAG_INACTIVE 0x0001 /* +I */
183 #define QUFLAG_GLINE 0x0002 /* +g */
184 #define QUFLAG_NOTICE 0x0004 /* +n */
185 #define QUFLAG_STAFF 0x0008 /* +q */
186 #define QUFLAG_SUSPENDED 0x0010 /* +z */
187 #define QUFLAG_OPER 0x0020 /* +o */
188 #define QUFLAG_DEV 0x0040 /* +d */
189 #define QUFLAG_PROTECT 0x0080 /* +p */
190 #define QUFLAG_HELPER 0x0100 /* +h */
191 #define QUFLAG_ADMIN 0x0200 /* +a */
192 #define QUFLAG_INFO 0x0400 /* +i */
193 #define QUFLAG_DELAYEDGLINE 0x0800 /* +G */
194 #define QUFLAG_NOAUTHLIMIT 0x1000 /* +L */
195 #define QUFLAG_ACHIEVEMENTS 0x2000 /* +c */
196 #define QUFLAG_CLEANUPEXEMPT 0x4000 /* +D */
197 #define QUFLAG_TRUST 0x8000 /* +T */
198 #define QUFLAG_ALL 0xffff
200 //#define UIsNoInfo(x) ((x)->flags & QUFLAG_NOINFO)
201 #define UIsNoInfo(x) 0
202 #define UIsInactive(x) ((x)->flags & QUFLAG_INACTIVE)
203 #define UIsGline(x) ((x)->flags & QUFLAG_GLINE)
204 #define UIsNotice(x) ((x)->flags & QUFLAG_NOTICE)
205 #define UIsSuspended(x) ((x)->flags & QUFLAG_SUSPENDED)
206 #define UIsOper(x) ((x)->flags & QUFLAG_OPER)
207 #define UIsDev(x) ((x)->flags & QUFLAG_DEV)
208 #define UIsProtect(x) ((x)->flags & QUFLAG_PROTECT)
209 #define UIsHelper(x) ((x)->flags & QUFLAG_HELPER)
210 #define UIsAdmin(x) ((x)->flags & QUFLAG_ADMIN)
211 #define UIsInfo(x) ((x)->flags & QUFLAG_INFO)
212 #define UIsDelayedGline(x) ((x)->flags & QUFLAG_DELAYEDGLINE)
213 #define UIsNoAuthLimit(x) ((x)->flags & QUFLAG_NOAUTHLIMIT)
214 #define UIsCleanupExempt(x) ((x)->flags & QUFLAG_CLEANUPEXEMPT)
215 #define UIsStaff(x) ((x)->flags & QUFLAG_STAFF)
216 #define UIsAchievements(x) ((x)->flags & QUFLAG_ACHIEVEMENTS)
218 #define UHasSuspension(x) ((x)->flags & (QUFLAG_GLINE|QUFLAG_DELAYEDGLINE|QUFLAG_SUSPENDED))
220 #define UHasStaffPriv(x) ((x)->flags & (QUFLAG_STAFF | QUFLAG_HELPER | QUFLAG_OPER | QUFLAG_ADMIN | QUFLAG_DEV))
221 #define UHasHelperPriv(x) ((x)->flags & (QUFLAG_HELPER | QUFLAG_OPER | QUFLAG_ADMIN | QUFLAG_DEV))
222 #define UHasOperPriv(x) ((x)->flags & (QUFLAG_OPER | QUFLAG_ADMIN | QUFLAG_DEV))
223 #define UHasAdminPriv(x) ((x)->flags & (QUFLAG_ADMIN | QUFLAG_DEV))
225 #define USetInactive(x) ((x)->flags |= QUFLAG_INACTIVE)
226 #define USetGline(x) ((x)->flags |= QUFLAG_GLINE)
227 #define USetNotice(x) ((x)->flags |= QUFLAG_NOTICE)
228 #define USetSuspended(x) ((x)->flags |= QUFLAG_SUSPENDED)
229 #define USetOper(x) ((x)->flags |= QUFLAG_OPER)
230 #define USetDev(x) ((x)->flags |= QUFLAG_DEV)
231 #define USetProtect(x) ((x)->flags |= QUFLAG_PROTECT)
232 #define USetHelper(x) ((x)->flags |= QUFLAG_HELPER)
233 #define USetAdmin(x) ((x)->flags |= QUFLAG_ADMIN)
234 #define USetInfo(x) ((x)->flags |= QUFLAG_INFO)
235 #define USetDelayedGline(x) ((x)->flags |= QUFLAG_DELAYEDGLINE)
236 #define USetNoAuthLimit(x) ((x)->flags |= QUFLAG_NOAUTHLIMIT)
237 #define USetCleanupExempt(x) ((x)->flags |= QUFLAG_CLEANUPEXEMPT)
238 #define USetTrust(x) ((x)->flags |= QUFLAG_TRUST)
240 #define UClearInactive(x) ((x)->flags &= ~QUFLAG_INACTIVE)
241 #define UClearGline(x) ((x)->flags &= ~QUFLAG_GLINE)
242 #define UClearNotice(x) ((x)->flags &= ~QUFLAG_NOTICE)
243 #define UClearSuspended(x) ((x)->flags &= ~QUFLAG_SUSPENDED)
244 #define UClearOper(x) ((x)->flags &= ~QUFLAG_OPER)
245 #define UClearDev(x) ((x)->flags &= ~QUFLAG_DEV)
246 #define UClearProtect(x) ((x)->flags &= ~QUFLAG_PROTECT)
247 #define UClearHelper(x) ((x)->flags &= ~QUFLAG_HELPER)
248 #define UClearAdmin(x) ((x)->flags &= ~QUFLAG_ADMIN)
249 #define UClearInfo(x) ((x)->flags &= ~QUFLAG_INFO)
250 #define UClearDelayedGline(x) ((x)->flags &= ~QUFLAG_DELAYEDGLINE)
251 #define UClearNoAuthLimit(x) ((x)->flags &= ~QUFLAG_NOAUTHLIMIT)
252 #define UClearCleanupExempt(x) ((x)->flags &= ~QUFLAG_CLEANUPEXEMPT)
253 #define UClearTrust(x) ((x)->flags &= ~QUFLAG_TRUST)
256 #define MAX_RESEND_TIME 2*3600L /* cooling off period */
257 #define VALID_EMAIL "\\A[^\\s\\+@]+@([a-z0-9][a-z0-9\\-]*\\.)+[a-z]{2,}\\Z"
259 #define VALID_ACCOUNT_NAME "\\A[a-z][a-z0-9\\-]+\\Z"
261 #define QMAIL_NEWACCOUNT 1 /* new account */
262 #define QMAIL_REQPW 2 /* requestpassword */
263 #define QMAIL_NEWPW 3 /* new password */
264 #define QMAIL_RESET 4 /* reset account */
265 #define QMAIL_NEWEMAIL 5 /* new email address */
266 #define QMAIL_ACTIVATEEMAIL 6 /* new style new account */
270 #define QCFLAG_AUTOOP 0x0001 /* +a */
271 #define QCFLAG_BITCH 0x0002 /* +b */
272 #define QCFLAG_AUTOLIMIT 0x0004 /* +c */
273 #define QCFLAG_ENFORCE 0x0008 /* +e */
274 #define QCFLAG_FORCETOPIC 0x0010 /* +f */
275 #define QCFLAG_AUTOVOICE 0x0020 /* +g */
276 #define QCFLAG_INFO 0x0040 /* +i */
277 #define QCFLAG_JOINED 0x0080 /* +j */
278 #define QCFLAG_KNOWNONLY 0x0100 /* +k */
279 #define QCFLAG_PROTECT 0x0200 /* +p */
280 #define QCFLAG_NOINFO 0x0400 /* +s */
281 #define QCFLAG_TOPICSAVE 0x0800 /* +t */
282 #define QCFLAG_VOICEALL 0x1000 /* +v */
283 #define QCFLAG_WELCOME 0x2000 /* +w */
284 #define QCFLAG_SUSPENDED 0x4000 /* +z */
285 #define QCFLAG_ACHIEVEMENTS 0x8000 /* +h */
287 #define CIsAutoOp(x) ((x)->flags & QCFLAG_AUTOOP)
288 #define CIsBitch(x) ((x)->flags & QCFLAG_BITCH)
289 #define CIsAutoLimit(x) ((x)->flags & QCFLAG_AUTOLIMIT)
290 #define CIsEnforce(x) ((x)->flags & QCFLAG_ENFORCE)
291 #define CIsForceTopic(x) ((x)->flags & QCFLAG_FORCETOPIC)
292 #define CIsAutoVoice(x) ((x)->flags & QCFLAG_AUTOVOICE)
293 #define CIsJoined(x) ((x)->flags & QCFLAG_JOINED)
294 #define CIsKnownOnly(x) ((x)->flags & QCFLAG_KNOWNONLY)
295 #define CIsProtect(x) ((x)->flags & QCFLAG_PROTECT)
296 #define CIsTopicSave(x) ((x)->flags & QCFLAG_TOPICSAVE)
297 #define CIsVoiceAll(x) ((x)->flags & QCFLAG_VOICEALL)
298 #define CIsWelcome(x) ((x)->flags & QCFLAG_WELCOME)
299 #define CIsSuspended(x) ((x)->flags & QCFLAG_SUSPENDED)
300 #define CIsInfo(x) ((x)->flags & QCFLAG_INFO)
301 #define CIsNoInfo(x) ((x)->flags & QCFLAG_NOINFO)
302 #define CIsAchievements(x) ((x)->flags & QCFLAG_ACHIEVEMENTS)
304 #define CSetAutoOp(x) ((x)->flags |= QCFLAG_AUTOOP)
305 #define CSetBitch(x) ((x)->flags |= QCFLAG_BITCH)
306 #define CSetAutoLimit(x) ((x)->flags |= QCFLAG_AUTOLIMIT)
307 #define CSetEnforce(x) ((x)->flags |= QCFLAG_ENFORCE)
308 #define CSetForceTopic(x) ((x)->flags |= QCFLAG_FORCETOPIC)
309 #define CSetAutoVoice(x) ((x)->flags |= QCFLAG_AUTOVOICE)
310 #define CSetJoined(x) ((x)->flags |= QCFLAG_JOINED)
311 #define CSetKnownOnly(x) ((x)->flags |= QCFLAG_KNOWNONLY)
312 #define CSetProtect(x) ((x)->flags |= QCFLAG_PROTECT)
313 #define CSetTopicSave(x) ((x)->flags |= QCFLAG_TOPICSAVE)
314 #define CSetVoiceAll(x) ((x)->flags |= QCFLAG_VOICEALL)
315 #define CSetWelcome(x) ((x)->flags |= QCFLAG_WELCOME)
316 #define CSetSuspended(x) ((x)->flags |= QCFLAG_SUSPENDED)
318 #define CClearAutoOp(x) ((x)->flags &= ~QCFLAG_AUTOOP)
319 #define CClearBitch(x) ((x)->flags &= ~QCFLAG_BITCH)
320 #define CClearAutoLimit(x) ((x)->flags &= ~QCFLAG_AUTOLIMIT)
321 #define CClearEnforce(x) ((x)->flags &= ~QCFLAG_ENFORCE)
322 #define CClearForceTopic(x) ((x)->flags &= ~QCFLAG_FORCETOPIC)
323 #define CClearAutoVoice(x) ((x)->flags &= ~QCFLAG_AUTOVOICE)
324 #define CClearJoined(x) ((x)->flags &= ~QCFLAG_JOINED)
325 #define CClearKnownOnly(x) ((x)->flags &= ~QCFLAG_KNOWNONLY)
326 #define CClearProtect(x) ((x)->flags &= ~QCFLAG_PROTECT)
327 #define CClearTopicSave(x) ((x)->flags &= ~QCFLAG_TOPICSAVE)
328 #define CClearVoiceAll(x) ((x)->flags &= ~QCFLAG_VOICEALL)
329 #define CClearWelcome(x) ((x)->flags &= ~QCFLAG_WELCOME)
330 #define CClearSuspended(x) ((x)->flags &= ~QCFLAG_SUSPENDED)
332 #define QCFLAG_USERCONTROL (QCFLAG_AUTOOP|QCFLAG_BITCH|QCFLAG_AUTOLIMIT| \
333 QCFLAG_ENFORCE|QCFLAG_FORCETOPIC|QCFLAG_AUTOVOICE| \
334 QCFLAG_PROTECT|QCFLAG_TOPICSAVE|QCFLAG_VOICEALL| \
335 QCFLAG_WELCOME|QCFLAG_KNOWNONLY|QCFLAG_ACHIEVEMENTS )
337 #define QCFLAG_ALL 0xffff
340 /* Channel user ("chanlev") flags */
341 /* Slightly funny order here: list the "biggest" flags at the
342 * top so we can do sorted "chanlev" output more easily */
343 #define QCUFLAG_OWNER 0x8000 /* +n */
344 #define QCUFLAG_MASTER 0x4000 /* +m */
345 #define QCUFLAG_OP 0x2000 /* +o */
346 #define QCUFLAG_VOICE 0x1000 /* +v */
347 #define QCUFLAG_AUTOOP 0x0001 /* +a */
348 #define QCUFLAG_BANNED 0x0002 /* +b */
349 #define QCUFLAG_DENY 0x0004 /* +d */
350 #define QCUFLAG_AUTOVOICE 0x0008 /* +g */
351 #define QCUFLAG_QUIET 0x0010 /* +q */
352 #define QCUFLAG_NOINFO 0x0020 /* +s */
353 #define QCUFLAG_TOPIC 0x0040 /* +t */
354 #define QCUFLAG_HIDEWELCOME 0x0080 /* +w */
355 #define QCUFLAG_PROTECT 0x0100 /* +p */
356 #define QCUFLAG_INFO 0x0200 /* +i */
357 #define QCUFLAG_KNOWN 0x0400 /* +k */
358 #define QCUFLAG_AUTOINVITE 0x0800 /* +j */
360 #define QCUFLAG_SIGNIFICANT (QCUFLAG_MASTER|QCUFLAG_OWNER|QCUFLAG_OP)
362 #define QCUFLAG_MASTERCON (QCUFLAG_AUTOOP|QCUFLAG_BANNED|QCUFLAG_DENY| \
363 QCUFLAG_GIVE|QCUFLAG_OP|QCUFLAG_QUIET|QCUFLAG_TOPIC| \
364 QCUFLAG_VOICE|QCUFLAG_PROTECT)
366 #define QCUFLAG_SELFCON (QCUFLAG_OP | QCUFLAG_VOICE | QCUFLAG_AUTOOP | QCUFLAG_AUTOVOICE | \
367 QCUFLAG_TOPIC | QCUFLAG_INFO)
369 #define QCUFLAGS_PUBLIC (QCUFLAG_OWNER | QCUFLAG_MASTER | QCUFLAG_OP | QCUFLAG_VOICE | \
370 QCUFLAG_KNOWN | QCUFLAG_AUTOOP | QCUFLAG_AUTOVOICE | QCUFLAG_TOPIC | \
373 #define QCUFLAGS_PUNISH (QCUFLAG_BANNED | QCUFLAG_QUIET | QCUFLAG_DENY)
374 #define QCUFLAGS_PERSONAL (QCUFLAG_HIDEWELCOME | QCUFLAG_AUTOINVITE)
376 #define QCUFLAG_ALL 0xffff
378 #define CUIsOwner(x) ((x)->flags & QCUFLAG_OWNER)
379 #define CUIsMaster(x) ((x)->flags & QCUFLAG_MASTER)
380 #define CUIsOp(x) ((x)->flags & QCUFLAG_OP)
381 #define CUIsVoice(x) ((x)->flags & QCUFLAG_VOICE)
382 #define CUIsAutoOp(x) ((x)->flags & QCUFLAG_AUTOOP)
383 #define CUIsBanned(x) ((x)->flags & QCUFLAG_BANNED)
384 #define CUIsDeny(x) ((x)->flags & QCUFLAG_DENY)
385 #define CUIsAutoVoice(x) ((x)->flags & QCUFLAG_AUTOVOICE)
386 #define CUIsQuiet(x) ((x)->flags & QCUFLAG_QUIET)
387 #define CUIsNoInfo(x) ((x)->flags & QCUFLAG_NOINFO)
388 #define CUIsTopic(x) ((x)->flags & QCUFLAG_TOPIC)
389 #define CUIsHideWelcome(x) ((x)->flags & QCUFLAG_HIDEWELCOME)
390 #define CUIsProtect(x) ((x)->flags & QCUFLAG_PROTECT)
391 #define CUIsInfo(x) ((x)->flags & QCUFLAG_INFO)
392 #define CUIsKnown(x) ((x)->flags & QCUFLAG_KNOWN)
393 #define CUIsAutoInvite(x) ((x)->flags & QCUFLAG_AUTOINVITE)
395 #define CUKnown(x) (CUIsKnown(x) || CUHasVoicePriv(x))
396 #define CUHasVoicePriv(x) ((x)->flags & (QCUFLAG_VOICE | QCUFLAG_OP | QCUFLAG_MASTER | QCUFLAG_OWNER))
397 #define CUHasOpPriv(x) ((x)->flags & (QCUFLAG_OP | QCUFLAG_MASTER | QCUFLAG_OWNER))
398 #define CUHasMasterPriv(x) ((x)->flags & (QCUFLAG_MASTER | QCUFLAG_OWNER))
399 #define CUHasTopicPriv(x) ((x)->flags & (QCUFLAG_MASTER | QCUFLAG_OWNER | QCUFLAG_TOPIC))
401 #define CUSetOwner(x) ((x)->flags |= QCUFLAG_OWNER)
402 #define CUSetMaster(x) ((x)->flags |= QCUFLAG_MASTER)
403 #define CUSetOp(x) ((x)->flags |= QCUFLAG_OP)
404 #define CUSetVoice(x) ((x)->flags |= QCUFLAG_VOICE)
405 #define CUSetAutoOp(x) ((x)->flags |= QCUFLAG_AUTOOP)
406 #define CUSetBanned(x) ((x)->flags |= QCUFLAG_BANNED)
407 #define CUSetDeny(x) ((x)->flags |= QCUFLAG_DENY)
408 #define CUSetAutoVoice(x) ((x)->flags |= QCUFLAG_AUTOVOICE)
409 #define CUSetQuiet(x) ((x)->flags |= QCUFLAG_QUIET)
410 #define CUSetTopic(x) ((x)->flags |= QCUFLAG_TOPIC)
411 #define CUSetHideWelcome(x) ((x)->flags |= QCUFLAG_HIDEWELCOME)
412 #define CUSetKnown(x) ((x)->flags |= QCUFLAG_KNOWN)
413 #define CUSetAutoInvite(x) ((x)->flags |= QCUFLAG_AUTOINVITE)
415 #define CUClearOwner(x) ((x)->flags &= ~QCUFLAG_OWNER)
416 #define CUClearMaster(x) ((x)->flags &= ~QCUFLAG_MASTER)
417 #define CUClearOp(x) ((x)->flags &= ~QCUFLAG_OP)
418 #define CUClearVoice(x) ((x)->flags &= ~QCUFLAG_VOICE)
419 #define CUClearAutoOp(x) ((x)->flags &= ~QCUFLAG_AUTOOP)
420 #define CUClearBanned(x) ((x)->flags &= ~QCUFLAG_BANNED)
421 #define CUClearDeny(x) ((x)->flags &= ~QCUFLAG_DENY)
422 #define CUClearAutoVoice(x) ((x)->flags &= ~QCUFLAG_AUTOVOICE)
423 #define CUClearQuiet(x) ((x)->flags &= ~QCUFLAG_QUIET)
424 #define CUClearTopic(x) ((x)->flags &= ~QCUFLAG_TOPIC)
425 #define CUClearHideWelcome(x) ((x)->flags &= ~QCUFLAG_HIDEWELCOME)
426 #define CUClearKnown(x) ((x)->flags &= ~QCUFLAG_KNOWN)
427 #define CUClearAutoInvite(x) ((x)->flags &= ~QCUFLAG_AUTOINVITE)
429 #define QCSTAT_OPCHECK 0x0001 /* Do op check */
430 #define QCSTAT_MODECHECK 0x0002 /* Do mode check */
431 #define QCSTAT_BANCHECK 0x0004 /* Do ban check */
433 #define QUSTAT_DEAD 0x8000 /* User has been deleted.. */
435 #define QCMD_SECURE 0x0001 /* Must use "user@server" to use this command */
436 #define QCMD_AUTHED 0x0002 /* Only available to authed users */
437 #define QCMD_NOTAUTHED 0x0004 /* Only available to NON-authed users */
439 #define QCMD_HELPER 0x0010 /* Only available to helpers */
440 #define QCMD_OPER 0x0020 /* Only available to opers */
441 #define QCMD_ADMIN 0x0040 /* Only available to admins */
442 #define QCMD_DEV 0x0080 /* Only available to developers */
443 #define QCMD_STAFF 0x0200 /* Only available to staff */
445 #define QCMD_ALIAS 0x0100 /* Don't list on SHOWCOMMANDS */
446 #define QCMD_HIDDEN QCMD_ALIAS
448 #define QCMD_ACHIEVEMENTS 0x0400 /* Achievement-related commands */
449 #define QCMD_TITLES 0x0800 /* Title-related commands */
451 #define CS_INIT_DB 0x1 /* Loading database.. */
452 #define CS_INIT_NOUSER 0x2 /* Loaded DB, waiting for user to be created */
453 #define CS_INIT_READY 0x3 /* Ready for action! */
458 typedef struct maildomain
{
460 unsigned int maildomain_magic
;
466 unsigned int actlimit
;
468 struct reguser
*users
;
469 struct maildomain
*parent
;
470 struct maildomain
*nextbyname
;
471 struct maildomain
*nextbyID
;
474 #define MDFLAG_LIMIT 0x0001 /* +l */
475 #define MDFLAG_BANNED 0x0002 /* +b */
476 #define MDFLAG_ACTLIMIT 0x0004 /* +u */
477 #define MDFLAG_ALL 0x0007
479 #define MDFLAG_DEFAULT MDFLAG_ACTLIMIT
481 #define MDHasLimit(x) ((x)->flags & MDFLAG_LIMIT)
482 #define MDSetLimit(x) ((x)->flags |= MDFLAG_LIMIT)
483 #define MDClearLimit(x) ((x)->flags &= ~MDFLAG_LIMIT)
484 #define MDIsBanned(x) ((x)->flags & MDFLAG_BANNED)
485 #define MDSetBanned(x) ((x)->flags |= MDFLAG_BANNED)
486 #define MDClearBanned(x) ((x)->flags &= ~MDFLAG_BANNED)
487 #define MDHasActLimit(x) ((x)->flags & MDFLAG_ACTLIMIT)
488 #define MDSetActLimit(x) ((x)->flags |= MDFLAG_ACTLIMIT)
489 #define MDClearActLimit(x) ((x)->flags &= ~MDFLAG_ACTLIMIT)
492 typedef struct regban
{
494 unsigned int regchanban_magic
;
496 unsigned int ID
; /* ID in the database */
497 struct chanban
*cbp
; /* Standard chanban struct */
498 unsigned int setby
; /* Who set the ban */
499 time_t expiry
; /* When the ban expires */
500 sstring
*reason
; /* Reason to attach to related kicks */
501 struct regban
*next
; /* Next ban on this channel */
504 /* Registered channel */
505 typedef struct regchan
{
507 unsigned int regchan_magic
;
509 unsigned int ID
; /* Unique number from database */
510 chanindex
*index
; /* Pointer to the channel index record */
511 time_t ltimestamp
; /* The last timestamp we saw on this channel */
513 flag_t flags
; /* Chanflags */
514 flag_t status
; /* Runtime status codes */
515 flag_t forcemodes
; /* Forced modes */
516 flag_t denymodes
; /* Denied modes */
518 unsigned short limit
; /* Limit to enforce if +l is set */
519 short autolimit
; /* How many slots to leave when autolimiting */
520 short banstyle
; /* Ban style for +b type bans */
522 time_t created
; /* When the service was added */
523 time_t lastactive
; /* When the channel was last "active" */
524 time_t statsreset
; /* When the users stats were last reset */
525 time_t ostatsreset
; /* When the oper stats were last reset */
526 time_t banduration
; /* How long to remove bans after (0=don't) */
527 time_t autoupdate
; /* When the autolimit next needs checking */
528 time_t lastbancheck
; /* Timestamp of last ban check */
529 time_t lastcountersync
; /* When the counters were last synced.. */
530 time_t lastpart
; /* When the last user left the channel */
531 time_t suspendtime
; /* When the channel was suspended */
533 unsigned int founder
; /* founder */
534 unsigned int addedby
; /* oper adding chan */
535 unsigned int suspendby
; /* who suspended chan */
537 short chantype
; /* What "type" the channel is */
539 unsigned int totaljoins
; /* Total joins since created */
540 unsigned int tripjoins
; /* Total joins since last stats reset */
541 unsigned int otripjoins
; /* Total joins since last oper stats reset */
542 unsigned int maxusers
; /* Max users since created */
543 unsigned int tripusers
; /* Max users since last stats reset */
544 unsigned int otripusers
; /* Max users since last oper stats reset */
546 sstring
*welcome
; /* Welcome message */
547 sstring
*topic
; /* "default" topic set by settopic */
548 sstring
*key
; /* Key as enforced by +k */
549 sstring
*suspendreason
; /* Suspend reason */
550 sstring
*comment
; /* Oper-settable channel comment */
552 void *checksched
; /* Handle for channel check schedule */
554 struct regchanuser
*regusers
[REGCHANUSERHASHSIZE
];
555 struct regban
*bans
; /* List of bans on the channel */
557 char chanopnicks
[CHANOPHISTORY
][NICKLEN
+1]; /* Last CHANOPHISTORY ppl to get ops */
558 unsigned int chanopaccts
[CHANOPHISTORY
]; /* Which account was responsible for each one */
559 short chanoppos
; /* Position in the array */
562 struct achievement_record
;
564 /* Registered user */
565 typedef struct reguser
{
567 unsigned int reguser_magic
;
569 unsigned int ID
; /* From the database */
571 char username
[NICKLEN
+1];
575 time_t lastemailchange
;
577 flag_t flags
; /* user flags */
578 flag_t status
; /* runtime status */
579 short languageid
; /* what language to speak to the user */
581 unsigned int suspendby
; /* Userid of oper who suspended this user */
582 time_t suspendexp
; /* Expiry date of suspension */
583 time_t suspendtime
; /* When user was suspended */
584 time_t lockuntil
; /* Time until users account is unlocked (pass change, email, etc) */
586 char password
[PASSLEN
+1];
591 sstring
*email
; /* Registered e-mail */
592 sstring
*lastemail
; /* Last registered e-mail */
593 sstring
*lastuserhost
; /* Last user@host */
594 sstring
*suspendreason
; /* Why the account is suspended */
595 sstring
*comment
; /* Oper-settable user comment */
596 sstring
*info
; /* User-settable info line */
598 struct regchanuser
*knownon
; /* Which channels this user is known on */
600 /* These fields are for the nick protection system */
601 void *checkshd
; /* When we're going to check for an imposter */
602 int stealcount
; /* How many times we've had to free the nick up */
603 nick
*fakeuser
; /* If we had to "take" the nick, here's the pointer */
605 time_t lastpasschange
;
607 struct reguser
*nextbydomain
;
608 struct reguser
*nextbyname
;
609 struct reguser
*nextbyID
;
612 /* Registered channel user */
613 typedef struct regchanuser
{
615 unsigned int regchanuser_magic
;
617 struct reguser
*user
;
618 struct regchan
*chan
;
620 time_t changetime
; /* Timestamp of last "significant" change */
621 time_t usetime
; /* Timestamp of last use */
622 sstring
*info
; /* User-settable info line */
623 struct regchanuser
*nextbyuser
;
624 struct regchanuser
*nextbychan
;
627 typedef struct cslang
{
632 typedef struct cmdsummary
{
634 sstring
*bylang
[MAXLANG
];
638 typedef struct activeuser
{
640 unsigned int activeuser_magic
;
642 unsigned short authattempts
; /* number of times user has attempted to auth */
643 unsigned short helloattempts
; /* number of times user has attempted to hello... */
644 unsigned char entropy
[ENTROPYLEN
]; /* entropy used for challengeauth */
646 struct activeuser
*next
; /* purely for keeping track of free, but not free'd structures */
649 typedef struct maillock
{
651 unsigned int maillock_magic
;
656 unsigned int createdby
;
658 struct maillock
*next
;
663 #define REGUSERMAGIC 0x4d42de03
664 #define REGCHANMAGIC 0x5bf2aa30
665 #define REGCHANUSERMAGIC 0x19628b63
666 #define REGCHANBANMAGIC 0x5a6f555a
667 #define ACTIVEUSERMAGIC 0x897f98a0
668 #define MAILDOMAINMAGIC 0x27cde46f
669 #define MAILLOCKMAGIC 0x3c81d762
671 #define verifyreguser(x) assert((x)->reguser_magic == REGUSERMAGIC)
672 #define verifyregchan(x) assert((x)->regchan_magic == REGCHANMAGIC)
673 #define verifyregchanuser(x) assert((x)->regchanuser_magic == REGCHANUSERMAGIC)
674 #define verifyregchanban(x) assert((x)->regchanban_magic == REGCHANBANMAGIC)
675 #define verifyactiveuser(x) assert((x)->activeuser_magic == ACTIVEUSERMAGIC)
676 #define verifymaildomain(x) assert((x)->maildomain_magic == MAILDOMAINMAGIC)
677 #define verifymaillock(x) assert((x)->maillock_magic == MAILLOCKMAGIC)
679 #define tagreguser(x) ((x)->reguser_magic = REGUSERMAGIC)
680 #define tagregchan(x) ((x)->regchan_magic = REGCHANMAGIC)
681 #define tagregchanuser(x) ((x)->regchanuser_magic = REGCHANUSERMAGIC)
682 #define tagregchanban(x) ((x)->regchanban_magic = REGCHANBANMAGIC)
683 #define tagactiveuser(x) ((x)->activeuser_magic = ACTIVEUSERMAGIC)
684 #define tagmaildomain(x) ((x)->maildomain_magic = MAILDOMAINMAGIC)
685 #define tagmaillock(x) ((x)->maillock_magic = MAILLOCKMAGIC)
688 #define verifyreguser(x)
689 #define verifyregchan(x)
690 #define verifyregchanuser(x)
691 #define verifyregchanban(x)
692 #define verifyactiveuser(x)
693 #define verifymaildomain(x)
694 #define verifymaillock(x)
696 #define tagreguser(x)
697 #define tagregchan(x)
698 #define tagregchanuser(x)
699 #define tagregchanban(x)
700 #define tagactiveuser(x)
701 #define tagmaildomain(x)
702 #define tagmaillock(x)
706 #define getactiveuserfromnick(x) ((activeuser*)(x)->exts[chanservnext])
707 #define getreguserfromnick(x) ((x)->auth?(reguser *)(x)->auth->exts[chanservaext]:NULL)
709 /* Global variables for chanserv module */
710 extern unsigned int lastuserID
;
711 extern unsigned int lastchannelID
;
712 extern unsigned int lastbanID
;
713 extern unsigned int lastdomainID
;
714 extern unsigned int lastmaillockID
;
716 extern int chanserv_init_status
;
717 extern int chanservdb_ready
;
720 extern DBModuleIdentifier q9dbid
, q9adbid
, q9cdbid
, q9udbid
;
723 extern maildomain
*maildomainnametable
[MAILDOMAINHASHSIZE
];
724 extern maildomain
*maildomainIDtable
[MAILDOMAINHASHSIZE
];
726 extern reguser
*regusernicktable
[REGUSERHASHSIZE
];
727 extern reguser
*deadusers
;
729 extern nick
*chanservnick
;
730 extern int chanservext
;
731 extern int chanservnext
;
732 extern int chanservaext
;
734 extern cslang
*cslanguages
[MAXLANG
];
735 extern unsigned int cslangcount
;
737 extern sstring
*csmessages
[MAXLANG
][MAXMESSAGES
];
739 extern const flag rcflags
[];
740 extern const flag rcuflags
[];
741 extern const flag ruflags
[];
742 extern const flag mdflags
[];
744 extern CommandTree
*cscommands
;
746 extern sstring
**chantypes
;
748 extern maillock
*maillocks
;
750 extern sstring
*cs_quitreason
;
752 /* Function prototypes */
755 void chanserv_finalinit();
757 /* chanservalloc.c */
758 regchan
*getregchan();
759 void freeregchan(regchan
*rcp
);
760 reguser
*getreguser();
761 void freereguser(reguser
*rup
);
762 regchanuser
*getregchanuser();
763 void freeregchanuser(regchanuser
*rcup
);
765 void freeregban(regban
*rbp
);
766 activeuser
*getactiveuser();
767 void freeactiveuser(activeuser
*aup
);
768 maildomain
*getmaildomain();
769 void freemaildomain(maildomain
*mdp
);
770 maillock
*getmaillock();
771 void freemaillock(maillock
*mlp
);
774 void chanservhashinit();
775 void addregusertohash(reguser
*rup
);
776 reguser
*findreguserbyID(unsigned int ID
);
777 reguser
*findreguserbynick(const char *nick
);
778 reguser
*findreguser(nick
*sender
, const char *str
);
779 void removereguserfromhash(reguser
*rup
);
780 void addregchantohash(regchan
*rcp
);
781 regchan
*findregchanbyID(unsigned int ID
);
782 regchan
*findregchanbyname(const char *name
);
783 void removeregchanfromhash(regchan
*rcp
);
784 void addregusertochannel(regchanuser
*rcup
);
785 regchanuser
*findreguseronchannel(regchan
*rcp
, reguser
*rup
);
786 void delreguserfromchannel(regchan
*rcp
, reguser
*rup
);
787 void addmaildomaintohash(maildomain
*mdp
);
788 maildomain
*findmaildomainbyID(unsigned int ID
);
789 maildomain
*findmaildomainbydomain(char *domain
);
790 maildomain
*findmaildomainbyemail(char *email
);
791 maildomain
*findorcreatemaildomain(char *email
);
792 maildomain
*findnearestmaildomain(char *domain
);
793 void removemaildomainfromhash(maildomain
*mdp
);
794 void addregusertomaildomain(reguser
*rup
, maildomain
*mdp
);
795 void delreguserfrommaildomain(reguser
*rup
, maildomain
*mdp
);
796 reguser
*findreguserbyemail(const char *email
);
799 int chanservdbinit();
801 void loadcommandsummary(Command
*cmd
);
802 void chanservdbclose();
803 void csdb_updatetopic(regchan
*rcp
);
804 void csdb_updatelastjoin(regchanuser
*rcup
);
805 void csdb_updateauthinfo(reguser
*rup
);
806 void csdb_updatechannel(regchan
*rcp
);
807 void csdb_createchannel(regchan
*rcp
);
808 void csdb_deletechannel(regchan
*rcp
);
809 void csdb_deleteuser(reguser
*rup
);
810 void csdb_updatechannelcounters(regchan
*rcp
);
811 void csdb_updatechanneltimestamp(regchan
*rcp
);
812 void csdb_updatechanuser(regchanuser
*rcup
);
813 void csdb_createchanuser(regchanuser
*rcup
);
814 void csdb_deletechanuser(regchanuser
*rcup
);
815 void csdb_createuser(reguser
*rup
);
816 void csdb_updateuser(reguser
*rup
);
817 void csdb_createban(regchan
*rcp
, regban
*rbp
);
818 void csdb_deleteban(regban
*rbp
);
819 void csdb_updateban(regchan
*rcp
, regban
*rbp
);
820 char *csdb_gethelpstr(char *command
, int language
);
821 void csdb_createmail(reguser
*rup
, int type
);
822 void csdb_dohelp(nick
*np
, Command
*cmd
);
823 void csdb_flushchannelcounters(void *arg
);
825 #define q9asyncquery(handler, tag, format, ...) dbasyncqueryi(q9dbid, handler, tag, format , ##__VA_ARGS__)
826 #define q9a_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9adbid, handler, tag, format , ##__VA_ARGS__)
827 #define q9u_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9udbid, handler, tag, format , ##__VA_ARGS__)
828 #define q9c_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9cdbid, handler, tag, format , ##__VA_ARGS__)
829 #define q9cleanup_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9cleanupdbid, handler, tag, format , ##__VA_ARGS__)
831 /* chanservcrypto.c */
832 typedef int (*CRAlgorithm
)(char *, const char *, const char *, const char *);
833 void chanservcryptoinit(void);
834 void chanservcryptofree(void);
835 void cs_getrandbytes(unsigned char *buf
, size_t bytes
);
836 char *cs_calcchallenge(const unsigned char *entropy
);
837 CRAlgorithm
cs_cralgorithm(const char *algorithm
);
838 const char *cs_cralgorithmlist(void);
839 int cs_checkhashpass(const char *username
, const char *password
, const char *junk
, const char *hash
);
840 char *csc_generateresetcode(time_t lockuntil
, char *username
);
841 int csc_verifyqticket(char *data
, char *digest
);
844 void chanservreguser(void *arg
);
845 void chanservjoinchan(channel
*cp
);
846 void chanservpartchan(channel
*cp
, char *reason
);
847 #define chanservsendmessage(np, fmt, ...) chanservsendmessage_real(np, 0, fmt , ##__VA_ARGS__)
848 #define chanservsendmessageoneline(np, fmt, ...) chanservsendmessage_real(np, 1, fmt , ##__VA_ARGS__)
849 void chanservsendmessage_real(nick
*np
, int oneline
, char *message
, ... ) __attribute__ ((format (printf
, 3, 4)));
850 void chanservwallmessage(char *message
, ... ) __attribute__ ((format (printf
, 1, 2)));
851 void chanservcommandinit();
852 void chanservcommandclose();
853 void chanservstdmessage(nick
*np
, int messageid
, ... );
854 void chanservstdvmessage(nick
*np
, reguser
*rup
, int messageid
, int max_line_len
, void (*callback
)(nick
*, char *), va_list va
);
855 void chanservaddcommand(char *command
, int flags
, int maxparams
, CommandHandler handler
, char *description
, const char *help
);
856 void chanservremovecommand(char *command
, CommandHandler handler
);
857 void chanservaddctcpcommand(char *command
, CommandHandler hander
);
858 void chanservremovectcpcommand(char *command
, CommandHandler handler
);
859 void chanservkillstdmessage(nick
*target
, int messageid
, ... );
860 int checkpassword(reguser
*rup
, const char *pass
);
861 int setpassword(reguser
*rup
, const char *pass
);
862 /*reguser *getreguserfromnick(nick *np);
863 activeuser *getactiveuserfromnick(nick *np);*/
864 void cs_checknick(nick
*np
);
865 void cs_checkchanmodes(channel
*cp
);
866 void cs_docheckchanmodes(channel
*cp
, modechanges
*changes
);
867 void cs_docheckopvoice(channel
*cp
, modechanges
*changes
);
868 void cs_checkbans(channel
*cp
);
869 void cs_schedupdate(chanindex
*cip
, int mintime
, int maxtime
);
870 void cs_timerfunc(void *arg
);
871 void cs_removechannel(regchan
*rcp
, char *reason
);
872 int cs_removechannelifempty(nick
*sender
, regchan
*rcp
);
873 void cs_doallautomodes(nick
*np
);
874 void cs_checknickbans(nick
*np
);
875 void cs_setregban(chanindex
*cip
, regban
*rbp
);
876 int cs_bancheck(nick
*np
, channel
*cp
);
877 void cs_banuser(modechanges
*changes
, chanindex
*cip
, nick
*np
, const char *reason
);
878 void cs_removeuser(reguser
*rup
);
879 int checkresponse(reguser
*rup
, const unsigned char *entropy
, const char *response
, CRAlgorithm algorithm
);
880 int checkhashpass(reguser
*rup
, const char *junk
, const char *hash
);
881 flag_t
cs_sanitisechanlev(flag_t flags
);
882 int cs_unbanfn(nick
*sender
, chanindex
*cip
, int (*fn
)(void *arg
, struct chanban
*ban
), void *arg
, int removepermbans
, int abortonfailure
);
883 void cs_logchanop(regchan
*rcp
, char *nick
, reguser
*rup
);
884 int checkreason(nick
*np
, char *reason
);
885 regchan
*cs_addchan(chanindex
*cip
, nick
*sender
, reguser
*addedby
, reguser
*founder
, flag_t flags
, flag_t forcemodes
, flag_t denymodes
, short type
);
887 /* chanservstdcmds.c */
888 int cs_doshowcommands(void *source
, int cargc
, char **cargv
);
889 int cs_dohelp(void *source
, int cargc
, char **cargv
);
890 int cs_doquit(void *source
, int cargc
, char **cargv
);
891 int cs_dosetquitreason(void *source
, int cargc
, char **cargv
);
892 int cs_dorename(void *source
, int cargc
, char **cargv
);
893 int cs_dorehash(void *source
, int cargc
, char **cargv
);
894 int cs_doversion(void *source
, int cargc
, char **cargv
);
895 int cs_doctcpping(void *source
, int cargc
, char **cargv
);
896 int cs_doctcpversion(void *source
, int cargc
, char **cargv
);
897 int cs_doctcpgender(void *source
, int cargc
, char **cargv
);
898 int cs_sendhelp(nick
*sender
, char *cmd
, int oneline
);
900 /* chanservnetevents.c */
901 void cs_handlenick(int hooknum
, void *arg
);
902 void cs_handlesethost(int hooknum
, void *arg
);
903 void cs_handlelostnick(int hooknum
, void *arg
);
904 void cs_handlenewchannel(int hooknum
, void *arg
);
905 void cs_handlelostchannel(int hooknum
, void *arg
);
906 void cs_handlejoin(int hooknum
, void *arg
);
907 void cs_handlemodechange(int hooknum
, void *arg
);
908 void cs_handleburst(int hooknum
, void *arg
);
909 void cs_handletopicchange(int hooknum
, void *arg
);
910 void cs_handleopchange(int hooknum
, void *arg
);
911 void cs_handlenewban(int hooknum
, void *arg
);
912 void cs_handlechanlostuser(int hooknum
, void *arg
);
913 int cs_ischannelactive(channel
*cp
, regchan
*rcp
);
915 /* chanservmessages.c */
918 /* chanservprivs.c */
919 int cs_privcheck(int privnum
, nick
*np
);
920 chanindex
*cs_checkaccess(nick
*np
, const char *chan
, unsigned int flags
, chanindex
*cip
, const char *cmdname
, int priv
, int quiet
);
925 void cs_log(nick
*np
, char *event
, ...) __attribute__ ((format (printf
, 2, 3)));
928 int dumplastjoindata(const char *filename
);
929 int readlastjoindata(const char *filename
);
931 /* chanservschedule.c */
932 void chanservdgline(void *arg
);
934 /* chanservdb_updates.c */
935 void csdb_updateauthinfo(reguser
*rup
);
936 void csdb_updatelastjoin(regchanuser
*rcup
);
937 void csdb_updatetopic(regchan
*rcp
);
938 void csdb_updatechannel(regchan
*rcp
);
939 void csdb_updatechannelcounters(regchan
*rcp
);
940 void csdb_updatechanneltimestamp(regchan
*rcp
);
941 void csdb_createchannel(regchan
*rcp
);
942 void csdb_deletechannel(regchan
*rcp
);
943 void csdb_deleteuser(reguser
*rup
);
944 void csdb_updateuser(reguser
*rup
);
945 void csdb_createuser(reguser
*rup
);
946 void csdb_updatechanuser(regchanuser
*rcup
);
947 void csdb_createchanuser(regchanuser
*rcup
);
948 void csdb_deletechanuser(regchanuser
*rcup
);
949 void csdb_createban(regchan
*rcp
, regban
*rbp
);
950 void csdb_deleteban(regban
*rbp
);
951 void csdb_createmail(reguser
*rup
, int type
);
952 void csdb_deletemaildomain(maildomain
*mdp
);
953 void csdb_createmaildomain(maildomain
*mdp
);
954 void csdb_updatemaildomain(maildomain
*mdp
);
955 void csdb_chanlevhistory_insert(regchan
*rcp
, nick
*np
, reguser
*trup
, flag_t oldflags
, flag_t newflags
);
956 void csdb_accounthistory_insert(nick
*np
, char *oldpass
, char *newpass
, char *oldemail
, char *newemail
);
957 void csdb_cleanuphistories(time_t);
958 void csdb_deletemaillock(maillock
*mlp
);
959 void csdb_createmaillock(maillock
*mlp
);
960 void csdb_updatemaillock(maillock
*mlp
);
963 void q9snprintf(char *buf
, size_t size
, const char *format
, const char *args
, ...);
964 void q9vsnprintf(char *buf
, size_t size
, const char *format
, const char *args
, va_list ap
);
965 void q9strftime(char *buf
, size_t size
, time_t t
);
967 /* chanserv_flags.c */
968 u_int64_t
cs_accountflagmap(reguser
*rup
);
969 u_int64_t
cs_accountflagmap_str(char *flags
);
971 /* chanserv_cleanupdb.c */
972 void cs_cleanupdb(nick
*np
);