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