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