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