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