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