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