]>
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 */ | |
bc6c8fbe | 399 | #define QCMD_HIDDEN QCMD_ALIAS |
c86edd1d Q |
400 | |
401 | #define CS_INIT_DB 0x1 /* Loading database.. */ | |
402 | #define CS_INIT_NOUSER 0x2 /* Loaded DB, waiting for user to be created */ | |
403 | #define CS_INIT_READY 0x3 /* Ready for action! */ | |
404 | ||
405 | struct regchanuser; | |
406 | struct reguser; | |
407 | ||
e3805f60 P |
408 | typedef struct maildomain { |
409 | #ifdef CS_PARANOID | |
410 | unsigned int maildomain_magic; | |
411 | #endif | |
412 | unsigned int ID; | |
413 | sstring *name; | |
414 | unsigned int count; | |
415 | unsigned int limit; | |
416 | unsigned int actlimit; | |
417 | flag_t flags; | |
418 | struct reguser *users; | |
419 | struct maildomain *parent; | |
420 | struct maildomain *nextbyname; | |
421 | struct maildomain *nextbyID; | |
422 | } maildomain; | |
423 | ||
424 | #define MDFLAG_LIMIT 0x0001 /* +l */ | |
425 | #define MDFLAG_BANNED 0x0002 /* +b */ | |
426 | #define MDFLAG_ACTLIMIT 0x0004 /* +u */ | |
427 | #define MDFLAG_ALL 0x0007 | |
428 | ||
96e1f81d CP |
429 | #define MDFLAG_DEFAULT MDFLAG_ACTLIMIT |
430 | ||
e3805f60 P |
431 | #define MDHasLimit(x) ((x)->flags & MDFLAG_LIMIT) |
432 | #define MDSetLimit(x) ((x)->flags |= MDFLAG_LIMIT) | |
433 | #define MDClearLimit(x) ((x)->flags &= ~MDFLAG_LIMIT) | |
434 | #define MDIsBanned(x) ((x)->flags & MDFLAG_BANNED) | |
435 | #define MDSetBanned(x) ((x)->flags |= MDFLAG_BANNED) | |
436 | #define MDClearBanned(x) ((x)->flags &= ~MDFLAG_BANNED) | |
437 | #define MDHasActLimit(x) ((x)->flags & MDFLAG_ACTLIMIT) | |
438 | #define MDSetActLimit(x) ((x)->flags |= MDFLAG_ACTLIMIT) | |
439 | #define MDClearActLimit(x) ((x)->flags &= ~MDFLAG_ACTLIMIT) | |
440 | ||
c86edd1d Q |
441 | /* "Q" ban */ |
442 | typedef struct regban { | |
443 | #ifdef CS_PARANOID | |
444 | unsigned int regchanban_magic; | |
445 | #endif | |
446 | unsigned int ID; /* ID in the database */ | |
447 | struct chanban *cbp; /* Standard chanban struct */ | |
448 | unsigned int setby; /* Who set the ban */ | |
449 | time_t expiry; /* When the ban expires */ | |
450 | sstring *reason; /* Reason to attach to related kicks */ | |
451 | struct regban *next; /* Next ban on this channel */ | |
452 | } regban; | |
453 | ||
454 | /* Registered channel */ | |
455 | typedef struct regchan { | |
456 | #ifdef CS_PARANOID | |
457 | unsigned int regchan_magic; | |
458 | #endif | |
459 | unsigned int ID; /* Unique number from database */ | |
460 | chanindex *index; /* Pointer to the channel index record */ | |
a54e438d | 461 | time_t ltimestamp; /* The last timestamp we saw on this channel */ |
c86edd1d Q |
462 | |
463 | flag_t flags; /* Chanflags */ | |
464 | flag_t status; /* Runtime status codes */ | |
465 | flag_t forcemodes; /* Forced modes */ | |
466 | flag_t denymodes; /* Denied modes */ | |
467 | ||
eee34485 | 468 | unsigned short limit; /* Limit to enforce if +l is set */ |
c86edd1d Q |
469 | short autolimit; /* How many slots to leave when autolimiting */ |
470 | short banstyle; /* Ban style for +b type bans */ | |
471 | ||
472 | time_t created; /* When the service was added */ | |
473 | time_t lastactive; /* When the channel was last "active" */ | |
474 | time_t statsreset; /* When the users stats were last reset */ | |
475 | time_t ostatsreset; /* When the oper stats were last reset */ | |
476 | time_t banduration; /* How long to remove bans after (0=don't) */ | |
477 | time_t autoupdate; /* When the autolimit next needs checking */ | |
478 | time_t lastbancheck; /* Timestamp of last ban check */ | |
479 | time_t lastcountersync; /* When the counters were last synced.. */ | |
480 | time_t lastpart; /* When the last user left the channel */ | |
88d191e3 | 481 | time_t suspendtime; /* When the channel was suspended */ |
c86edd1d Q |
482 | |
483 | unsigned int founder; /* founder */ | |
484 | unsigned int addedby; /* oper adding chan */ | |
485 | unsigned int suspendby; /* who suspended chan */ | |
486 | ||
487 | short chantype; /* What "type" the channel is */ | |
488 | ||
489 | unsigned int totaljoins; /* Total joins since created */ | |
490 | unsigned int tripjoins; /* Total joins since last stats reset */ | |
491 | unsigned int otripjoins; /* Total joins since last oper stats reset */ | |
492 | unsigned int maxusers; /* Max users since created */ | |
493 | unsigned int tripusers; /* Max users since last stats reset */ | |
494 | unsigned int otripusers; /* Max users since last oper stats reset */ | |
495 | ||
496 | sstring *welcome; /* Welcome message */ | |
497 | sstring *topic; /* "default" topic set by settopic */ | |
498 | sstring *key; /* Key as enforced by +k */ | |
499 | sstring *suspendreason; /* Suspend reason */ | |
500 | sstring *comment; /* Oper-settable channel comment */ | |
501 | ||
502 | void *checksched; /* Handle for channel check schedule */ | |
503 | ||
504 | struct regchanuser *regusers[REGCHANUSERHASHSIZE]; | |
505 | struct regban *bans; /* List of bans on the channel */ | |
1482fb78 | 506 | |
507 | char chanopnicks[CHANOPHISTORY][NICKLEN+1]; /* Last CHANOPHISTORY ppl to get ops */ | |
508 | unsigned int chanopaccts[CHANOPHISTORY]; /* Which account was responsible for each one */ | |
509 | short chanoppos; /* Position in the array */ | |
c86edd1d Q |
510 | } regchan; |
511 | ||
c86edd1d Q |
512 | /* Registered user */ |
513 | typedef struct reguser { | |
514 | #ifdef CS_PARANOID | |
515 | unsigned int reguser_magic; | |
516 | #endif | |
c86edd1d Q |
517 | unsigned int ID; /* From the database */ |
518 | ||
519 | char username[NICKLEN+1]; | |
520 | ||
521 | time_t created; | |
522 | time_t lastauth; | |
523 | time_t lastemailchange; | |
524 | ||
525 | flag_t flags; /* user flags */ | |
526 | flag_t status; /* runtime status */ | |
527 | short languageid; /* what language to speak to the user */ | |
528 | ||
529 | unsigned int suspendby; /* Userid of oper who suspended this user */ | |
530 | time_t suspendexp; /* Expiry date of suspension */ | |
88d191e3 | 531 | time_t suspendtime; /* When user was suspended */ |
ad3f4566 | 532 | time_t lockuntil; /* Time until users account is unlocked (pass change, email, etc) */ |
c86edd1d Q |
533 | |
534 | char password[PASSLEN+1]; | |
72ca906c | 535 | |
e3805f60 P |
536 | sstring *localpart; |
537 | maildomain *domain; | |
538 | ||
9708f78f CP |
539 | sstring *email; /* Registered e-mail */ |
540 | sstring *lastemail; /* Last registered e-mail */ | |
c86edd1d Q |
541 | sstring *lastuserhost; /* Last user@host */ |
542 | sstring *suspendreason; /* Why the account is suspended */ | |
543 | sstring *comment; /* Oper-settable user comment */ | |
544 | sstring *info; /* User-settable info line */ | |
545 | ||
546 | struct regchanuser *knownon; /* Which channels this user is known on */ | |
547 | ||
c86edd1d Q |
548 | /* These fields are for the nick protection system */ |
549 | void *checkshd; /* When we're going to check for an imposter */ | |
550 | int stealcount; /* How many times we've had to free the nick up */ | |
551 | nick *fakeuser; /* If we had to "take" the nick, here's the pointer */ | |
552 | ||
86d2bc73 CP |
553 | time_t lastpasschange; |
554 | ||
e3805f60 | 555 | struct reguser *nextbydomain; |
c86edd1d Q |
556 | struct reguser *nextbyname; |
557 | struct reguser *nextbyID; | |
558 | } reguser; | |
559 | ||
560 | /* Registered channel user */ | |
561 | typedef struct regchanuser { | |
562 | #ifdef CS_PARANOID | |
563 | unsigned int regchanuser_magic; | |
564 | #endif | |
565 | struct reguser *user; | |
566 | struct regchan *chan; | |
567 | flag_t flags; | |
568 | time_t changetime; /* Timestamp of last "significant" change */ | |
569 | time_t usetime; /* Timestamp of last use */ | |
570 | sstring *info; /* User-settable info line */ | |
571 | struct regchanuser *nextbyuser; | |
572 | struct regchanuser *nextbychan; | |
573 | } regchanuser; | |
574 | ||
575 | typedef struct cslang { | |
576 | char code[3]; | |
577 | sstring *name; | |
578 | } cslang; | |
579 | ||
580 | typedef struct cmdsummary { | |
581 | sstring *def; | |
582 | sstring *bylang[MAXLANG]; | |
1f0d7c8b | 583 | char *defhelp; |
c86edd1d Q |
584 | } cmdsummary; |
585 | ||
586 | typedef struct activeuser { | |
587 | #ifdef CS_PARANOID | |
588 | unsigned int activeuser_magic; | |
589 | #endif | |
bd87ef68 CP |
590 | unsigned short authattempts; /* number of times user has attempted to auth */ |
591 | unsigned short helloattempts; /* number of times user has attempted to hello... */ | |
0ba70e7b CP |
592 | unsigned char entropy[ENTROPYLEN]; /* entropy used for challengeauth */ |
593 | time_t entropyttl; | |
c86edd1d Q |
594 | struct activeuser *next; /* purely for keeping track of free, but not free'd structures */ |
595 | } activeuser; | |
596 | ||
97390b65 CP |
597 | typedef struct maillock { |
598 | #ifdef CS_PARANOID | |
599 | unsigned int maillock_magic; | |
600 | #endif | |
601 | unsigned int id; | |
602 | sstring *pattern; | |
603 | sstring *reason; | |
604 | unsigned int createdby; | |
605 | time_t created; | |
606 | struct maillock *next; | |
607 | } maillock; | |
608 | ||
c86edd1d Q |
609 | #ifdef CS_PARANOID |
610 | ||
611 | #define REGUSERMAGIC 0x4d42de03 | |
612 | #define REGCHANMAGIC 0x5bf2aa30 | |
613 | #define REGCHANUSERMAGIC 0x19628b63 | |
614 | #define REGCHANBANMAGIC 0x5a6f555a | |
615 | #define ACTIVEUSERMAGIC 0x897f98a0 | |
e3805f60 | 616 | #define MAILDOMAINMAGIC 0x27cde46f |
97390b65 | 617 | #define MAILLOCKMAGIC 0x3c81d762 |
c86edd1d Q |
618 | |
619 | #define verifyreguser(x) assert((x)->reguser_magic == REGUSERMAGIC) | |
620 | #define verifyregchan(x) assert((x)->regchan_magic == REGCHANMAGIC) | |
621 | #define verifyregchanuser(x) assert((x)->regchanuser_magic == REGCHANUSERMAGIC) | |
622 | #define verifyregchanban(x) assert((x)->regchanban_magic == REGCHANBANMAGIC) | |
623 | #define verifyactiveuser(x) assert((x)->activeuser_magic == ACTIVEUSERMAGIC) | |
e3805f60 | 624 | #define verifymaildomain(x) assert((x)->maildomain_magic == MAILDOMAINMAGIC) |
97390b65 | 625 | #define verifymaillock(x) assert((x)->maillock_magic == MAILLOCKMAGIC) |
c86edd1d Q |
626 | |
627 | #define tagreguser(x) ((x)->reguser_magic = REGUSERMAGIC) | |
628 | #define tagregchan(x) ((x)->regchan_magic = REGCHANMAGIC) | |
629 | #define tagregchanuser(x) ((x)->regchanuser_magic = REGCHANUSERMAGIC) | |
630 | #define tagregchanban(x) ((x)->regchanban_magic = REGCHANBANMAGIC) | |
631 | #define tagactiveuser(x) ((x)->activeuser_magic = ACTIVEUSERMAGIC) | |
e3805f60 | 632 | #define tagmaildomain(x) ((x)->maildomain_magic = MAILDOMAINMAGIC) |
97390b65 | 633 | #define tagmaillock(x) ((x)->maillock_magic = MAILLOCKMAGIC) |
c86edd1d Q |
634 | #else |
635 | ||
636 | #define verifyreguser(x) | |
637 | #define verifyregchan(x) | |
638 | #define verifyregchanuser(x) | |
639 | #define verifyregchanban(x) | |
640 | #define verifyactiveuser(x) | |
e3805f60 | 641 | #define verifymaildomain(x) |
97390b65 | 642 | #define verifymaillock(x) |
c86edd1d Q |
643 | |
644 | #define tagreguser(x) | |
645 | #define tagregchan(x) | |
646 | #define tagregchanuser(x) | |
647 | #define tagregchanban(x) | |
648 | #define tagactiveuser(x) | |
e3805f60 | 649 | #define tagmaildomain(x) |
97390b65 | 650 | #define tagmaillock(x) |
c86edd1d Q |
651 | |
652 | #endif | |
653 | ||
654 | #define getactiveuserfromnick(x) ((activeuser*)(x)->exts[chanservnext]) | |
23b85e10 | 655 | #define getreguserfromnick(x) ((x)->auth?(reguser *)(x)->auth->exts[chanservaext]:NULL) |
c86edd1d Q |
656 | |
657 | /* Global variables for chanserv module */ | |
c86edd1d Q |
658 | extern unsigned int lastuserID; |
659 | extern unsigned int lastchannelID; | |
660 | extern unsigned int lastbanID; | |
e3805f60 | 661 | extern unsigned int lastdomainID; |
97390b65 | 662 | extern unsigned int lastmaillockID; |
c86edd1d Q |
663 | |
664 | extern int chanserv_init_status; | |
b263aa79 | 665 | extern int chanservdb_ready; |
dbbee796 CP |
666 | |
667 | #ifndef CS_NODB | |
ee8cd7d0 | 668 | extern DBModuleIdentifier q9dbid, q9adbid, q9cdbid, q9udbid; |
dbbee796 | 669 | #endif |
c86edd1d | 670 | |
e3805f60 P |
671 | extern maildomain *maildomainnametable[MAILDOMAINHASHSIZE]; |
672 | extern maildomain *maildomainIDtable[MAILDOMAINHASHSIZE]; | |
673 | ||
c86edd1d Q |
674 | extern reguser *regusernicktable[REGUSERHASHSIZE]; |
675 | extern reguser *deadusers; | |
676 | ||
677 | extern nick *chanservnick; | |
678 | extern int chanservext; | |
679 | extern int chanservnext; | |
316959c1 | 680 | extern int chanservaext; |
c86edd1d Q |
681 | |
682 | extern cslang *cslanguages[MAXLANG]; | |
683 | extern unsigned int cslangcount; | |
684 | ||
685 | extern sstring *csmessages[MAXLANG][MAXMESSAGES]; | |
c86edd1d Q |
686 | |
687 | extern const flag rcflags[]; | |
688 | extern const flag rcuflags[]; | |
689 | extern const flag ruflags[]; | |
e3805f60 | 690 | extern const flag mdflags[]; |
c86edd1d Q |
691 | |
692 | extern CommandTree *cscommands; | |
693 | ||
694 | extern sstring **chantypes; | |
695 | ||
97390b65 CP |
696 | extern maillock *maillocks; |
697 | ||
9ecce0e8 | 698 | extern sstring *cs_quitreason; |
699 | ||
c86edd1d Q |
700 | /* Function prototypes */ |
701 | ||
702 | /* chanserv.c */ | |
703 | void chanserv_finalinit(); | |
704 | ||
705 | /* chanservalloc.c */ | |
706 | void chanservallocinit(); | |
707 | void csfreeall(); | |
708 | regchan *getregchan(); | |
709 | void freeregchan(regchan *rcp); | |
710 | reguser *getreguser(); | |
711 | void freereguser(reguser *rup); | |
712 | regchanuser *getregchanuser(); | |
713 | void freeregchanuser(regchanuser *rcup); | |
c86edd1d Q |
714 | regban *getregban(); |
715 | void freeregban(regban *rbp); | |
716 | activeuser *getactiveuser(); | |
717 | void freeactiveuser(activeuser *aup); | |
e3805f60 P |
718 | maildomain *getmaildomain(); |
719 | void freemaildomain(maildomain *mdp); | |
97390b65 CP |
720 | maillock *getmaillock(); |
721 | void freemaillock(maillock *mlp); | |
c86edd1d Q |
722 | |
723 | /* chanservhash.c */ | |
724 | void chanservhashinit(); | |
725 | void addregusertohash(reguser *rup); | |
726 | reguser *findreguserbyID(unsigned int ID); | |
727 | reguser *findreguserbynick(const char *nick); | |
728 | reguser *findreguser(nick *sender, const char *str); | |
729 | void removereguserfromhash(reguser *rup); | |
730 | void addregchantohash(regchan *rcp); | |
731 | regchan *findregchanbyID(unsigned int ID); | |
732 | regchan *findregchanbyname(const char *name); | |
733 | void removeregchanfromhash(regchan *rcp); | |
734 | void addregusertochannel(regchanuser *rcup); | |
735 | regchanuser *findreguseronchannel(regchan *rcp, reguser *rup); | |
736 | void delreguserfromchannel(regchan *rcp, reguser *rup); | |
e3805f60 P |
737 | void addmaildomaintohash(maildomain *mdp); |
738 | maildomain *findmaildomainbyID(unsigned int ID); | |
739 | maildomain *findmaildomainbydomain(char *domain); | |
740 | maildomain *findmaildomainbyemail(char *email); | |
741 | maildomain *findorcreatemaildomain(char *email); | |
96e1f81d | 742 | maildomain *findnearestmaildomain(char *domain); |
e3805f60 P |
743 | void removemaildomainfromhash(maildomain *mdp); |
744 | void addregusertomaildomain(reguser *rup, maildomain *mdp); | |
745 | void delreguserfrommaildomain(reguser *rup, maildomain *mdp); | |
b7ae0f2c | 746 | reguser *findreguserbyemail(const char *email); |
c86edd1d Q |
747 | |
748 | /* chanservdb.c */ | |
749 | int chanservdbinit(); | |
750 | void loadmessages(); | |
751 | void loadcommandsummary(Command *cmd); | |
752 | void chanservdbclose(); | |
753 | void csdb_updatetopic(regchan *rcp); | |
754 | void csdb_updatelastjoin(regchanuser *rcup); | |
755 | void csdb_updateauthinfo(reguser *rup); | |
756 | void csdb_updatechannel(regchan *rcp); | |
757 | void csdb_createchannel(regchan *rcp); | |
758 | void csdb_deletechannel(regchan *rcp); | |
759 | void csdb_deleteuser(reguser *rup); | |
760 | void csdb_updatechannelcounters(regchan *rcp); | |
a54e438d | 761 | void csdb_updatechanneltimestamp(regchan *rcp); |
c86edd1d Q |
762 | void csdb_updatechanuser(regchanuser *rcup); |
763 | void csdb_createchanuser(regchanuser *rcup); | |
764 | void csdb_deletechanuser(regchanuser *rcup); | |
765 | void csdb_createuser(reguser *rup); | |
766 | void csdb_updateuser(reguser *rup); | |
767 | void csdb_createban(regchan *rcp, regban *rbp); | |
768 | void csdb_deleteban(regban *rbp); | |
3fbc2554 | 769 | void csdb_updateban(regchan *rcp, regban *rbp); |
c86edd1d Q |
770 | char *csdb_gethelpstr(char *command, int language); |
771 | void csdb_createmail(reguser *rup, int type); | |
4ad1cf7a | 772 | void csdb_dohelp(nick *np, Command *cmd); |
c86edd1d | 773 | |
ee8cd7d0 CP |
774 | #define q9asyncquery(handler, tag, format, ...) dbasyncqueryi(q9dbid, handler, tag, format , ##__VA_ARGS__) |
775 | #define q9a_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9adbid, handler, tag, format , ##__VA_ARGS__) | |
776 | #define q9u_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9udbid, handler, tag, format , ##__VA_ARGS__) | |
777 | #define q9c_asyncquery(handler, tag, format, ...) dbasyncqueryi(q9cdbid, handler, tag, format , ##__VA_ARGS__) | |
b3565978 | 778 | |
b7a95f03 CP |
779 | /* chanservcrypto.c */ |
780 | typedef int (*CRAlgorithm)(char *, const char *, const char *, const char *); | |
781 | void chanservcryptoinit(void); | |
30a66d6c | 782 | void chanservcryptofree(void); |
b7a95f03 CP |
783 | void cs_getrandbytes(unsigned char *buf, size_t bytes); |
784 | char *cs_calcchallenge(const unsigned char *entropy); | |
785 | CRAlgorithm cs_cralgorithm(const char *algorithm); | |
786 | const char *cs_cralgorithmlist(void); | |
721cc8ce | 787 | int cs_checkhashpass(const char *username, const char *password, const char *junk, const char *hash); |
30a66d6c | 788 | char *csc_generateresetcode(time_t lockuntil, char *username); |
bc6c8fbe | 789 | int csc_verifyqticket(char *data, char *digest); |
b7a95f03 | 790 | |
c86edd1d Q |
791 | /* chanservuser.c */ |
792 | void chanservreguser(void *arg); | |
793 | void chanservjoinchan(channel *cp); | |
dd258305 | 794 | #define chanservsendmessage(np, fmt, args...) chanservsendmessage_real(np, 0, fmt , ## args) |
795 | #define chanservsendmessageoneline(np, fmt, args...) chanservsendmessage_real(np, 1, fmt , ## args) | |
bb4b25ee CP |
796 | void chanservsendmessage_real(nick *np, int oneline, char *message, ... ) __attribute__ ((format (printf, 3, 4)));; |
797 | void chanservwallmessage(char *message, ... ) __attribute__ ((format (printf, 1, 2))); | |
c86edd1d Q |
798 | void chanservcommandinit(); |
799 | void chanservcommandclose(); | |
800 | void chanservstdmessage(nick *np, int messageid, ... ); | |
1f0d7c8b | 801 | void chanservaddcommand(char *command, int flags, int maxparams, CommandHandler handler, char *description, const char *help); |
c86edd1d Q |
802 | void chanservremovecommand(char *command, CommandHandler handler); |
803 | void chanservaddctcpcommand(char *command, CommandHandler hander); | |
804 | void chanservremovectcpcommand(char *command, CommandHandler handler); | |
805 | void chanservkillstdmessage(nick *target, int messageid, ... ); | |
c86edd1d | 806 | int checkpassword(reguser *rup, const char *pass); |
c86edd1d Q |
807 | int setpassword(reguser *rup, const char *pass); |
808 | /*reguser *getreguserfromnick(nick *np); | |
809 | activeuser *getactiveuserfromnick(nick *np);*/ | |
810 | void cs_checknick(nick *np); | |
811 | void cs_checkchanmodes(channel *cp); | |
812 | void cs_docheckchanmodes(channel *cp, modechanges *changes); | |
813 | void cs_docheckopvoice(channel *cp, modechanges *changes); | |
814 | void cs_checkbans(channel *cp); | |
815 | void cs_schedupdate(chanindex *cip, int mintime, int maxtime); | |
816 | void cs_timerfunc(void *arg); | |
817 | void cs_removechannel(regchan *rcp); | |
5f7881b2 | 818 | int cs_removechannelifempty(nick *sender, regchan *rcp); |
c86edd1d Q |
819 | void cs_doallautomodes(nick *np); |
820 | void cs_checknickbans(nick *np); | |
821 | void cs_setregban(chanindex *cip, regban *rbp); | |
822 | int cs_bancheck(nick *np, channel *cp); | |
823 | void cs_banuser(modechanges *changes, chanindex *cip, nick *np, const char *reason); | |
4ad1cf7a | 824 | void cs_removeuser(reguser *rup); |
b7a95f03 | 825 | int checkresponse(reguser *rup, const unsigned char *entropy, const char *response, CRAlgorithm algorithm); |
721cc8ce | 826 | int checkhashpass(reguser *rup, const char *junk, const char *hash); |
95332d7b | 827 | flag_t cs_sanitisechanlev(flag_t flags); |
336765cd | 828 | typedef int (*UnbanFN)(void *arg, struct chanban *ban); |
0a53499c | 829 | int cs_unbanfn(nick *sender, chanindex *cip, UnbanFN fn, void *arg, int removepermbans, int abortonfailure); |
1482fb78 | 830 | void cs_logchanop(regchan *rcp, char *nick, reguser *rup); |
336765cd | 831 | |
c86edd1d Q |
832 | /* chanservstdcmds.c */ |
833 | int cs_doshowcommands(void *source, int cargc, char **cargv); | |
834 | int cs_dohelp(void *source, int cargc, char **cargv); | |
835 | int cs_doquit(void *source, int cargc, char **cargv); | |
9ecce0e8 | 836 | int cs_dosetquitreason(void *source, int cargc, char **cargv); |
c86edd1d Q |
837 | int cs_dorename(void *source, int cargc, char **cargv); |
838 | int cs_dorehash(void *source, int cargc, char **cargv); | |
80d2de64 | 839 | int cs_doversion(void *source, int cargc, char **cargv); |
c86edd1d Q |
840 | int cs_doctcpping(void *source, int cargc, char **cargv); |
841 | int cs_doctcpversion(void *source, int cargc, char **cargv); | |
842 | int cs_doctcpgender(void *source, int cargc, char **cargv); | |
dd258305 | 843 | int cs_sendhelp(nick *sender, char *cmd, int oneline); |
c86edd1d Q |
844 | |
845 | /* chanservnetevents.c */ | |
846 | void cs_handlenick(int hooknum, void *arg); | |
847 | void cs_handlesethost(int hooknum, void *arg); | |
848 | void cs_handlelostnick(int hooknum, void *arg); | |
849 | void cs_handlenewchannel(int hooknum, void *arg); | |
850 | void cs_handlelostchannel(int hooknum, void *arg); | |
851 | void cs_handlejoin(int hooknum, void *arg); | |
852 | void cs_handlemodechange(int hooknum, void *arg); | |
853 | void cs_handleburst(int hooknum, void *arg); | |
854 | void cs_handletopicchange(int hooknum, void *arg); | |
855 | void cs_handleopchange(int hooknum, void *arg); | |
856 | void cs_handlenewban(int hooknum, void *arg); | |
857 | void cs_handlechanlostuser(int hooknum, void *arg); | |
858 | ||
859 | /* chanservmessages.c */ | |
860 | void initmessages(); | |
861 | ||
862 | /* chanservprivs.c */ | |
863 | int cs_privcheck(int privnum, nick *np); | |
864 | chanindex *cs_checkaccess(nick *np, const char *chan, unsigned int flags, chanindex *cip, const char *cmdname, int priv, int quiet); | |
865 | ||
866 | /* chanservlog.c */ | |
867 | void cs_initlog(); | |
868 | void cs_closelog(); | |
bb4b25ee | 869 | void cs_log(nick *np, char *event, ...) __attribute__ ((format (printf, 2, 3))); |
c86edd1d Q |
870 | |
871 | /* chanservdump.c */ | |
872 | int dumplastjoindata(const char *filename); | |
873 | int readlastjoindata(const char *filename); | |
874 | ||
875 | /* chanservschedule.c */ | |
876 | void chanservdgline(void *arg); | |
877 | ||
4ad1cf7a CP |
878 | /* authlib.c */ |
879 | int csa_checkeboy(nick *sender, char *eboy); | |
880 | void csa_createrandompw(char *pw, int n); | |
1dd6d55d | 881 | int csa_checkthrottled(nick *sender, reguser *rup, char *s); |
4ad1cf7a | 882 | |
80d2de64 P |
883 | /* chanservdb_updates.c */ |
884 | void csdb_updateauthinfo(reguser *rup); | |
885 | void csdb_updatelastjoin(regchanuser *rcup); | |
886 | void csdb_updatetopic(regchan *rcp); | |
887 | void csdb_updatechannel(regchan *rcp); | |
888 | void csdb_updatechannelcounters(regchan *rcp); | |
889 | void csdb_updatechanneltimestamp(regchan *rcp); | |
890 | void csdb_createchannel(regchan *rcp); | |
891 | void csdb_deletechannel(regchan *rcp); | |
892 | void csdb_deleteuser(reguser *rup); | |
893 | void csdb_updateuser(reguser *rup); | |
894 | void csdb_createuser(reguser *rup); | |
895 | void csdb_updatechanuser(regchanuser *rcup); | |
896 | void csdb_createchanuser(regchanuser *rcup); | |
897 | void csdb_deletechanuser(regchanuser *rcup); | |
898 | void csdb_createban(regchan *rcp, regban *rbp); | |
899 | void csdb_deleteban(regban *rbp); | |
900 | void csdb_createmail(reguser *rup, int type); | |
901 | void csdb_deletemaildomain(maildomain *mdp); | |
902 | void csdb_createmaildomain(maildomain *mdp); | |
903 | void csdb_updatemaildomain(maildomain *mdp); | |
80d2de64 | 904 | void csdb_chanlevhistory_insert(regchan *rcp, nick *np, reguser *trup, flag_t oldflags, flag_t newflags); |
0f32b411 | 905 | void csdb_accounthistory_insert(nick *np, char *oldpass, char *newpass, char *oldemail, char *newemail); |
80d2de64 | 906 | void csdb_cleanuphistories(); |
97390b65 CP |
907 | void csdb_deletemaillock(maillock *mlp); |
908 | void csdb_createmaillock(maillock *mlp); | |
909 | void csdb_updatemaillock(maillock *mlp); | |
80d2de64 | 910 | |
b7ed259b CP |
911 | /* q9snprintf.c */ |
912 | void q9snprintf(char *buf, size_t size, const char *format, const char *args, ...); | |
913 | void q9vsnprintf(char *buf, size_t size, const char *format, const char *args, va_list ap); | |
3294b10b CP |
914 | |
915 | /* chanserv_flags.c */ | |
92acf9ae CP |
916 | u_int64_t cs_accountflagmap(reguser *rup); |
917 | u_int64_t cs_accountflagmap_str(char *flags); | |
3294b10b | 918 | |
c86edd1d | 919 | #endif |