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