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