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