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