1 |
adx |
30 |
/* |
2 |
michael |
2916 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
adx |
30 |
* |
4 |
michael |
2916 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
adx |
30 |
* |
6 |
|
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
|
|
* USA |
20 |
|
|
*/ |
21 |
|
|
|
22 |
michael |
2916 |
/*! \file channel_mode.c |
23 |
|
|
* \brief Controls modes on channels. |
24 |
|
|
* \version $Id$ |
25 |
|
|
*/ |
26 |
|
|
|
27 |
adx |
30 |
#include "stdinc.h" |
28 |
michael |
1011 |
#include "list.h" |
29 |
adx |
30 |
#include "channel.h" |
30 |
|
|
#include "channel_mode.h" |
31 |
|
|
#include "client.h" |
32 |
michael |
1632 |
#include "conf.h" |
33 |
michael |
371 |
#include "hostmask.h" |
34 |
adx |
30 |
#include "irc_string.h" |
35 |
|
|
#include "ircd.h" |
36 |
|
|
#include "numeric.h" |
37 |
michael |
2892 |
#include "s_serv.h" |
38 |
adx |
30 |
#include "send.h" |
39 |
|
|
#include "memory.h" |
40 |
michael |
1654 |
#include "mempool.h" |
41 |
michael |
1243 |
#include "parse.h" |
42 |
adx |
30 |
|
43 |
|
|
/* 10 is a magic number in hybrid 6 NFI where it comes from -db */ |
44 |
michael |
2892 |
#define BAN_FUDGE 10 |
45 |
adx |
30 |
#define NCHCAPS (sizeof(channel_capabs)/sizeof(int)) |
46 |
|
|
#define NCHCAP_COMBOS (1 << NCHCAPS) |
47 |
|
|
|
48 |
michael |
2892 |
|
49 |
michael |
388 |
static char nuh_mask[MAXPARA][IRCD_BUFSIZE]; |
50 |
adx |
30 |
/* some buffers for rebuilding channel/nick lists with ,'s */ |
51 |
|
|
static char modebuf[IRCD_BUFSIZE]; |
52 |
|
|
static char parabuf[MODEBUFLEN]; |
53 |
|
|
static struct ChModeChange mode_changes[IRCD_BUFSIZE]; |
54 |
|
|
static int mode_count; |
55 |
michael |
2892 |
static int mode_limit; /* number of modes set other than simple */ |
56 |
|
|
static int simple_modes_mask; /* bit mask of simple modes already set */ |
57 |
adx |
356 |
#ifdef HALFOPS |
58 |
|
|
static int channel_capabs[] = { CAP_EX, CAP_IE, CAP_TS6, CAP_HOPS }; |
59 |
|
|
#else |
60 |
adx |
30 |
static int channel_capabs[] = { CAP_EX, CAP_IE, CAP_TS6 }; |
61 |
adx |
356 |
#endif |
62 |
adx |
30 |
static struct ChCapCombo chcap_combos[NCHCAP_COMBOS]; |
63 |
michael |
1654 |
extern mp_pool_t *ban_pool; |
64 |
adx |
30 |
|
65 |
|
|
|
66 |
|
|
/* check_string() |
67 |
|
|
* |
68 |
|
|
* inputs - string to check |
69 |
|
|
* output - pointer to modified string |
70 |
|
|
* side effects - Fixes a string so that the first white space found |
71 |
|
|
* becomes an end of string marker (`\0`). |
72 |
|
|
* returns the 'fixed' string or "*" if the string |
73 |
|
|
* was NULL length or a NULL pointer. |
74 |
|
|
*/ |
75 |
|
|
static char * |
76 |
|
|
check_string(char *s) |
77 |
|
|
{ |
78 |
|
|
char *str = s; |
79 |
|
|
static char star[] = "*"; |
80 |
|
|
|
81 |
michael |
1772 |
if (EmptyString(str)) |
82 |
michael |
593 |
return star; |
83 |
adx |
30 |
|
84 |
|
|
for (; *s; ++s) |
85 |
|
|
{ |
86 |
|
|
if (IsSpace(*s)) |
87 |
|
|
{ |
88 |
|
|
*s = '\0'; |
89 |
|
|
break; |
90 |
|
|
} |
91 |
|
|
} |
92 |
|
|
|
93 |
michael |
1772 |
return EmptyString(str) ? star : str; |
94 |
adx |
30 |
} |
95 |
|
|
|
96 |
|
|
/* |
97 |
|
|
* Ban functions to work with mode +b/e/d/I |
98 |
|
|
*/ |
99 |
michael |
2892 |
/* add the specified ID to the channel. |
100 |
|
|
* -is 8/9/00 |
101 |
adx |
30 |
*/ |
102 |
|
|
|
103 |
|
|
int |
104 |
michael |
3044 |
add_id(struct Client *client_p, struct Channel *chptr, char *banid, unsigned int type) |
105 |
adx |
30 |
{ |
106 |
michael |
593 |
dlink_list *list = NULL; |
107 |
|
|
dlink_node *ban = NULL; |
108 |
adx |
30 |
size_t len = 0; |
109 |
michael |
593 |
struct Ban *ban_p = NULL; |
110 |
adx |
30 |
unsigned int num_mask; |
111 |
michael |
1431 |
char name[NICKLEN + 1]; |
112 |
michael |
593 |
char user[USERLEN + 1]; |
113 |
|
|
char host[HOSTLEN + 1]; |
114 |
|
|
struct split_nuh_item nuh; |
115 |
adx |
30 |
|
116 |
|
|
/* dont let local clients overflow the b/e/I lists */ |
117 |
|
|
if (MyClient(client_p)) |
118 |
|
|
{ |
119 |
|
|
num_mask = dlink_list_length(&chptr->banlist) + |
120 |
|
|
dlink_list_length(&chptr->exceptlist) + |
121 |
|
|
dlink_list_length(&chptr->invexlist); |
122 |
|
|
|
123 |
|
|
if (num_mask >= ConfigChannel.max_bans) |
124 |
|
|
{ |
125 |
michael |
1834 |
sendto_one(client_p, form_str(ERR_BANLISTFULL), |
126 |
adx |
30 |
me.name, client_p->name, chptr->chname, banid); |
127 |
|
|
return 0; |
128 |
|
|
} |
129 |
|
|
|
130 |
|
|
collapse(banid); |
131 |
|
|
} |
132 |
|
|
|
133 |
michael |
593 |
nuh.nuhmask = check_string(banid); |
134 |
|
|
nuh.nickptr = name; |
135 |
|
|
nuh.userptr = user; |
136 |
|
|
nuh.hostptr = host; |
137 |
adx |
30 |
|
138 |
michael |
593 |
nuh.nicksize = sizeof(name); |
139 |
|
|
nuh.usersize = sizeof(user); |
140 |
|
|
nuh.hostsize = sizeof(host); |
141 |
|
|
|
142 |
|
|
split_nuh(&nuh); |
143 |
|
|
|
144 |
adx |
30 |
/* |
145 |
michael |
593 |
* Re-assemble a new n!u@h and print it back to banid for sending |
146 |
adx |
30 |
* the mode to the channel. |
147 |
|
|
*/ |
148 |
michael |
1793 |
len = sprintf(banid, "%s!%s@%s", name, user, host); |
149 |
adx |
30 |
|
150 |
|
|
switch (type) |
151 |
|
|
{ |
152 |
|
|
case CHFL_BAN: |
153 |
|
|
list = &chptr->banlist; |
154 |
|
|
clear_ban_cache(chptr); |
155 |
|
|
break; |
156 |
|
|
case CHFL_EXCEPTION: |
157 |
|
|
list = &chptr->exceptlist; |
158 |
|
|
clear_ban_cache(chptr); |
159 |
|
|
break; |
160 |
|
|
case CHFL_INVEX: |
161 |
|
|
list = &chptr->invexlist; |
162 |
|
|
break; |
163 |
|
|
default: |
164 |
|
|
assert(0); |
165 |
|
|
return 0; |
166 |
|
|
} |
167 |
|
|
|
168 |
|
|
DLINK_FOREACH(ban, list->head) |
169 |
|
|
{ |
170 |
michael |
593 |
ban_p = ban->data; |
171 |
michael |
2892 |
|
172 |
michael |
593 |
if (!irccmp(ban_p->name, name) && |
173 |
michael |
2296 |
!irccmp(ban_p->user, user) && |
174 |
michael |
593 |
!irccmp(ban_p->host, host)) |
175 |
adx |
30 |
return 0; |
176 |
|
|
} |
177 |
|
|
|
178 |
michael |
1654 |
ban_p = mp_pool_get(ban_pool); |
179 |
|
|
memset(ban_p, 0, sizeof(*ban_p)); |
180 |
michael |
1646 |
ban_p->name = xstrdup(name); |
181 |
michael |
2296 |
ban_p->user = xstrdup(user); |
182 |
michael |
1646 |
ban_p->host = xstrdup(host); |
183 |
michael |
593 |
ban_p->when = CurrentTime; |
184 |
michael |
2892 |
ban_p->len = len - 2; /* -2 for @ and ! */ |
185 |
michael |
593 |
ban_p->type = parse_netmask(host, &ban_p->addr, &ban_p->bits); |
186 |
|
|
|
187 |
adx |
30 |
if (IsClient(client_p)) |
188 |
|
|
{ |
189 |
michael |
593 |
ban_p->who = MyMalloc(strlen(client_p->name) + |
190 |
|
|
strlen(client_p->username) + |
191 |
|
|
strlen(client_p->host) + 3); |
192 |
michael |
1793 |
sprintf(ban_p->who, "%s!%s@%s", client_p->name, |
193 |
michael |
2296 |
client_p->username, client_p->host); |
194 |
adx |
30 |
} |
195 |
michael |
2242 |
else if (IsHidden(client_p) || (IsServer(client_p) && ConfigServerHide.hide_servers)) |
196 |
|
|
ban_p->who = xstrdup(me.name); |
197 |
adx |
30 |
else |
198 |
michael |
1646 |
ban_p->who = xstrdup(client_p->name); |
199 |
adx |
30 |
|
200 |
michael |
593 |
dlinkAdd(ban_p, &ban_p->node, list); |
201 |
adx |
30 |
|
202 |
|
|
return 1; |
203 |
|
|
} |
204 |
|
|
|
205 |
|
|
/* |
206 |
|
|
* inputs - pointer to channel |
207 |
|
|
* - pointer to ban id |
208 |
|
|
* - type of ban, i.e. ban, exception, invex |
209 |
|
|
* output - 0 for failure, 1 for success |
210 |
|
|
* side effects - |
211 |
|
|
*/ |
212 |
|
|
static int |
213 |
michael |
3044 |
del_id(struct Channel *chptr, char *banid, unsigned int type) |
214 |
adx |
30 |
{ |
215 |
|
|
dlink_list *list; |
216 |
|
|
dlink_node *ban; |
217 |
|
|
struct Ban *banptr; |
218 |
michael |
1431 |
char name[NICKLEN + 1]; |
219 |
michael |
593 |
char user[USERLEN + 1]; |
220 |
|
|
char host[HOSTLEN + 1]; |
221 |
|
|
struct split_nuh_item nuh; |
222 |
adx |
30 |
|
223 |
michael |
2892 |
assert(banid); |
224 |
adx |
30 |
|
225 |
michael |
593 |
nuh.nuhmask = check_string(banid); |
226 |
|
|
nuh.nickptr = name; |
227 |
|
|
nuh.userptr = user; |
228 |
|
|
nuh.hostptr = host; |
229 |
adx |
30 |
|
230 |
michael |
593 |
nuh.nicksize = sizeof(name); |
231 |
|
|
nuh.usersize = sizeof(user); |
232 |
|
|
nuh.hostsize = sizeof(host); |
233 |
|
|
|
234 |
|
|
split_nuh(&nuh); |
235 |
|
|
|
236 |
adx |
30 |
/* |
237 |
michael |
593 |
* Re-assemble a new n!u@h and print it back to banid for sending |
238 |
adx |
30 |
* the mode to the channel. |
239 |
|
|
*/ |
240 |
michael |
1793 |
sprintf(banid, "%s!%s@%s", name, user, host); |
241 |
adx |
30 |
|
242 |
|
|
switch (type) |
243 |
|
|
{ |
244 |
|
|
case CHFL_BAN: |
245 |
|
|
list = &chptr->banlist; |
246 |
|
|
clear_ban_cache(chptr); |
247 |
|
|
break; |
248 |
|
|
case CHFL_EXCEPTION: |
249 |
|
|
list = &chptr->exceptlist; |
250 |
|
|
clear_ban_cache(chptr); |
251 |
|
|
break; |
252 |
|
|
case CHFL_INVEX: |
253 |
|
|
list = &chptr->invexlist; |
254 |
|
|
break; |
255 |
|
|
default: |
256 |
michael |
2892 |
assert(0); |
257 |
michael |
593 |
return 0; |
258 |
adx |
30 |
} |
259 |
|
|
|
260 |
|
|
DLINK_FOREACH(ban, list->head) |
261 |
|
|
{ |
262 |
|
|
banptr = ban->data; |
263 |
|
|
|
264 |
|
|
if (!irccmp(name, banptr->name) && |
265 |
michael |
2296 |
!irccmp(user, banptr->user) && |
266 |
michael |
593 |
!irccmp(host, banptr->host)) |
267 |
adx |
30 |
{ |
268 |
|
|
remove_ban(banptr, list); |
269 |
|
|
return 1; |
270 |
|
|
} |
271 |
|
|
} |
272 |
|
|
|
273 |
|
|
return 0; |
274 |
|
|
} |
275 |
|
|
|
276 |
michael |
2892 |
const struct mode_letter chan_modes[] = |
277 |
|
|
{ |
278 |
michael |
1937 |
{ MODE_NOCTRL, 'c' }, |
279 |
adx |
30 |
{ MODE_INVITEONLY, 'i' }, |
280 |
|
|
{ MODE_MODERATED, 'm' }, |
281 |
|
|
{ MODE_NOPRIVMSGS, 'n' }, |
282 |
|
|
{ MODE_PRIVATE, 'p' }, |
283 |
michael |
1167 |
{ MODE_REGISTERED, 'r' }, |
284 |
adx |
30 |
{ MODE_SECRET, 's' }, |
285 |
|
|
{ MODE_TOPICLIMIT, 't' }, |
286 |
michael |
1954 |
{ MODE_MODREG, 'M' }, |
287 |
michael |
1150 |
{ MODE_OPERONLY, 'O' }, |
288 |
michael |
1175 |
{ MODE_REGONLY, 'R' }, |
289 |
michael |
1150 |
{ MODE_SSLONLY, 'S' }, |
290 |
adx |
30 |
{ 0, '\0' } |
291 |
|
|
}; |
292 |
|
|
|
293 |
|
|
/* channel_modes() |
294 |
|
|
* |
295 |
|
|
* inputs - pointer to channel |
296 |
|
|
* - pointer to client |
297 |
|
|
* - pointer to mode buf |
298 |
|
|
* - pointer to parameter buf |
299 |
|
|
* output - NONE |
300 |
|
|
* side effects - write the "simple" list of channel modes for channel |
301 |
|
|
* chptr onto buffer mbuf with the parameters in pbuf. |
302 |
|
|
*/ |
303 |
|
|
void |
304 |
|
|
channel_modes(struct Channel *chptr, struct Client *client_p, |
305 |
|
|
char *mbuf, char *pbuf) |
306 |
|
|
{ |
307 |
michael |
1175 |
const struct mode_letter *tab = chan_modes; |
308 |
adx |
30 |
|
309 |
|
|
*mbuf++ = '+'; |
310 |
|
|
*pbuf = '\0'; |
311 |
|
|
|
312 |
michael |
1175 |
for (; tab->mode; ++tab) |
313 |
|
|
if (chptr->mode.mode & tab->mode) |
314 |
|
|
*mbuf++ = tab->letter; |
315 |
adx |
30 |
|
316 |
|
|
if (chptr->mode.limit) |
317 |
|
|
{ |
318 |
|
|
*mbuf++ = 'l'; |
319 |
|
|
|
320 |
michael |
1219 |
if (IsServer(client_p) || HasFlag(client_p, FLAGS_SERVICE) || IsMember(client_p, chptr)) |
321 |
michael |
1793 |
pbuf += sprintf(pbuf, "%d ", chptr->mode.limit); |
322 |
adx |
30 |
} |
323 |
|
|
|
324 |
|
|
if (chptr->mode.key[0]) |
325 |
|
|
{ |
326 |
|
|
*mbuf++ = 'k'; |
327 |
|
|
|
328 |
michael |
1219 |
if (IsServer(client_p) || HasFlag(client_p, FLAGS_SERVICE) || IsMember(client_p, chptr)) |
329 |
michael |
1793 |
sprintf(pbuf, "%s ", chptr->mode.key); |
330 |
adx |
30 |
} |
331 |
|
|
|
332 |
|
|
*mbuf = '\0'; |
333 |
|
|
} |
334 |
|
|
|
335 |
|
|
/* fix_key() |
336 |
michael |
2892 |
* |
337 |
adx |
30 |
* inputs - pointer to key to clean up |
338 |
|
|
* output - pointer to cleaned up key |
339 |
|
|
* side effects - input string is modified |
340 |
|
|
* |
341 |
|
|
* stolen from Undernet's ircd -orabidoo |
342 |
|
|
*/ |
343 |
|
|
static char * |
344 |
|
|
fix_key(char *arg) |
345 |
|
|
{ |
346 |
|
|
unsigned char *s, *t, c; |
347 |
|
|
|
348 |
|
|
for (s = t = (unsigned char *)arg; (c = *s); s++) |
349 |
|
|
{ |
350 |
|
|
c &= 0x7f; |
351 |
michael |
2892 |
|
352 |
adx |
30 |
if (c != ':' && c > ' ' && c != ',') |
353 |
|
|
*t++ = c; |
354 |
|
|
} |
355 |
|
|
|
356 |
|
|
*t = '\0'; |
357 |
michael |
2892 |
return arg; |
358 |
adx |
30 |
} |
359 |
|
|
|
360 |
|
|
/* fix_key_old() |
361 |
michael |
2892 |
* |
362 |
adx |
30 |
* inputs - pointer to key to clean up |
363 |
|
|
* output - pointer to cleaned up key |
364 |
michael |
2892 |
* side effects - input string is modifed |
365 |
adx |
30 |
* |
366 |
|
|
* Here we attempt to be compatible with older non-hybrid servers. |
367 |
|
|
* We can't back down from the ':' issue however. --Rodder |
368 |
|
|
*/ |
369 |
|
|
static char * |
370 |
|
|
fix_key_old(char *arg) |
371 |
|
|
{ |
372 |
|
|
unsigned char *s, *t, c; |
373 |
|
|
|
374 |
|
|
for (s = t = (unsigned char *)arg; (c = *s); s++) |
375 |
|
|
{ |
376 |
|
|
c &= 0x7f; |
377 |
michael |
2892 |
|
378 |
|
|
if ((c != 0x0a) && (c != ':') && |
379 |
|
|
(c != 0x0d) && (c != ',')) |
380 |
adx |
30 |
*t++ = c; |
381 |
|
|
} |
382 |
|
|
|
383 |
|
|
*t = '\0'; |
384 |
michael |
2892 |
return arg; |
385 |
adx |
30 |
} |
386 |
|
|
|
387 |
|
|
/* bitmasks for various error returns that set_channel_mode should only return |
388 |
|
|
* once per call -orabidoo |
389 |
|
|
*/ |
390 |
|
|
|
391 |
|
|
#define SM_ERR_NOTS 0x00000001 /* No TS on channel */ |
392 |
|
|
#define SM_ERR_NOOPS 0x00000002 /* No chan ops */ |
393 |
|
|
#define SM_ERR_UNKNOWN 0x00000004 |
394 |
|
|
#define SM_ERR_RPL_B 0x00000008 |
395 |
|
|
#define SM_ERR_RPL_E 0x00000010 |
396 |
|
|
#define SM_ERR_NOTONCHANNEL 0x00000020 /* Not on channel */ |
397 |
|
|
#define SM_ERR_RPL_I 0x00000040 |
398 |
michael |
1150 |
#define SM_ERR_NOTOPER 0x00000080 |
399 |
michael |
1167 |
#define SM_ERR_ONLYSERVER 0x00000100 |
400 |
adx |
30 |
|
401 |
|
|
/* Now lets do some stuff to keep track of what combinations of |
402 |
|
|
* servers exist... |
403 |
|
|
* Note that the number of combinations doubles each time you add |
404 |
|
|
* something to this list. Each one is only quick if no servers use that |
405 |
|
|
* combination, but if the numbers get too high here MODE will get too |
406 |
|
|
* slow. I suggest if you get more than 7 here, you consider getting rid |
407 |
|
|
* of some and merging or something. If it wasn't for irc+cs we would |
408 |
|
|
* probably not even need to bother about most of these, but unfortunately |
409 |
|
|
* we do. -A1kmm |
410 |
|
|
*/ |
411 |
|
|
|
412 |
|
|
/* void init_chcap_usage_counts(void) |
413 |
|
|
* |
414 |
|
|
* Inputs - none |
415 |
|
|
* Output - none |
416 |
|
|
* Side-effects - Initialises the usage counts to zero. Fills in the |
417 |
|
|
* chcap_yes and chcap_no combination tables. |
418 |
|
|
*/ |
419 |
|
|
void |
420 |
|
|
init_chcap_usage_counts(void) |
421 |
|
|
{ |
422 |
|
|
unsigned long m, c, y, n; |
423 |
|
|
|
424 |
|
|
memset(chcap_combos, 0, sizeof(chcap_combos)); |
425 |
|
|
|
426 |
|
|
/* For every possible combination */ |
427 |
|
|
for (m = 0; m < NCHCAP_COMBOS; m++) |
428 |
|
|
{ |
429 |
|
|
/* Check each capab */ |
430 |
|
|
for (c = y = n = 0; c < NCHCAPS; c++) |
431 |
|
|
{ |
432 |
|
|
if ((m & (1 << c)) == 0) |
433 |
|
|
n |= channel_capabs[c]; |
434 |
|
|
else |
435 |
|
|
y |= channel_capabs[c]; |
436 |
|
|
} |
437 |
michael |
2892 |
|
438 |
adx |
30 |
chcap_combos[m].cap_yes = y; |
439 |
|
|
chcap_combos[m].cap_no = n; |
440 |
|
|
} |
441 |
|
|
} |
442 |
|
|
|
443 |
|
|
/* void set_chcap_usage_counts(struct Client *serv_p) |
444 |
|
|
* Input: serv_p; The client whose capabs to register. |
445 |
|
|
* Output: none |
446 |
|
|
* Side-effects: Increments the usage counts for the correct capab |
447 |
|
|
* combination. |
448 |
|
|
*/ |
449 |
|
|
void |
450 |
|
|
set_chcap_usage_counts(struct Client *serv_p) |
451 |
|
|
{ |
452 |
|
|
int n; |
453 |
|
|
|
454 |
|
|
for (n = 0; n < NCHCAP_COMBOS; n++) |
455 |
|
|
{ |
456 |
|
|
if (((serv_p->localClient->caps & chcap_combos[n].cap_yes) == |
457 |
|
|
chcap_combos[n].cap_yes) && |
458 |
|
|
((serv_p->localClient->caps & chcap_combos[n].cap_no) == 0)) |
459 |
|
|
{ |
460 |
|
|
chcap_combos[n].count++; |
461 |
|
|
return; |
462 |
|
|
} |
463 |
|
|
} |
464 |
|
|
|
465 |
|
|
/* This should be impossible -A1kmm. */ |
466 |
|
|
assert(0); |
467 |
|
|
} |
468 |
|
|
|
469 |
|
|
/* void set_chcap_usage_counts(struct Client *serv_p) |
470 |
|
|
* |
471 |
|
|
* Inputs - serv_p; The client whose capabs to register. |
472 |
|
|
* Output - none |
473 |
|
|
* Side-effects - Decrements the usage counts for the correct capab |
474 |
|
|
* combination. |
475 |
|
|
*/ |
476 |
|
|
void |
477 |
|
|
unset_chcap_usage_counts(struct Client *serv_p) |
478 |
|
|
{ |
479 |
|
|
int n; |
480 |
|
|
|
481 |
|
|
for (n = 0; n < NCHCAP_COMBOS; n++) |
482 |
|
|
{ |
483 |
|
|
if ((serv_p->localClient->caps & chcap_combos[n].cap_yes) == |
484 |
|
|
chcap_combos[n].cap_yes && |
485 |
|
|
(serv_p->localClient->caps & chcap_combos[n].cap_no) == 0) |
486 |
|
|
{ |
487 |
|
|
/* Hopefully capabs can't change dynamically or anything... */ |
488 |
|
|
assert(chcap_combos[n].count > 0); |
489 |
|
|
chcap_combos[n].count--; |
490 |
|
|
return; |
491 |
|
|
} |
492 |
|
|
} |
493 |
|
|
|
494 |
|
|
/* This should be impossible -A1kmm. */ |
495 |
|
|
assert(0); |
496 |
|
|
} |
497 |
|
|
|
498 |
|
|
/* Mode functions handle mode changes for a particular mode... */ |
499 |
|
|
static void |
500 |
|
|
chm_nosuch(struct Client *client_p, struct Client *source_p, |
501 |
|
|
struct Channel *chptr, int parc, int *parn, |
502 |
michael |
2937 |
char **parv, int *errors, int alev, int dir, char c, unsigned int d) |
503 |
adx |
30 |
{ |
504 |
|
|
if (*errors & SM_ERR_UNKNOWN) |
505 |
|
|
return; |
506 |
|
|
|
507 |
|
|
*errors |= SM_ERR_UNKNOWN; |
508 |
michael |
1834 |
sendto_one(source_p, form_str(ERR_UNKNOWNMODE), me.name, |
509 |
adx |
30 |
source_p->name, c); |
510 |
|
|
} |
511 |
|
|
|
512 |
|
|
static void |
513 |
|
|
chm_simple(struct Client *client_p, struct Client *source_p, struct Channel *chptr, |
514 |
|
|
int parc, int *parn, char **parv, int *errors, int alev, int dir, |
515 |
michael |
2937 |
char c, unsigned int d) |
516 |
adx |
30 |
{ |
517 |
|
|
if ((alev < CHACCESS_HALFOP) || |
518 |
michael |
2937 |
((d == MODE_PRIVATE) && (alev < CHACCESS_CHANOP))) |
519 |
adx |
30 |
{ |
520 |
|
|
if (!(*errors & SM_ERR_NOOPS)) |
521 |
michael |
1834 |
sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ? |
522 |
|
|
ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED), |
523 |
michael |
2937 |
me.name, source_p->name, chptr->chname); |
524 |
adx |
30 |
*errors |= SM_ERR_NOOPS; |
525 |
|
|
return; |
526 |
|
|
} |
527 |
|
|
|
528 |
|
|
/* If have already dealt with this simple mode, ignore it */ |
529 |
michael |
2937 |
if (simple_modes_mask & d) |
530 |
adx |
30 |
return; |
531 |
|
|
|
532 |
michael |
2937 |
simple_modes_mask |= d; |
533 |
adx |
30 |
|
534 |
|
|
/* setting + */ |
535 |
michael |
2892 |
/* Apparently, (though no one has ever told the hybrid group directly) |
536 |
|
|
* admins don't like redundant mode checking. ok. It would have been nice |
537 |
|
|
* if you had have told us directly. I've left the original code snippets |
538 |
|
|
* in place. |
539 |
|
|
* |
540 |
|
|
* -Dianora |
541 |
|
|
*/ |
542 |
michael |
2937 |
if (dir == MODE_ADD) /* && !(chptr->mode.mode & d)) */ |
543 |
adx |
30 |
{ |
544 |
michael |
2937 |
chptr->mode.mode |= d; |
545 |
adx |
30 |
|
546 |
|
|
mode_changes[mode_count].letter = c; |
547 |
|
|
mode_changes[mode_count].dir = MODE_ADD; |
548 |
|
|
mode_changes[mode_count].caps = 0; |
549 |
|
|
mode_changes[mode_count].nocaps = 0; |
550 |
|
|
mode_changes[mode_count].id = NULL; |
551 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
552 |
|
|
mode_changes[mode_count++].arg = NULL; |
553 |
|
|
} |
554 |
michael |
2937 |
else if (dir == MODE_DEL) /* && (chptr->mode.mode & d)) */ |
555 |
adx |
30 |
{ |
556 |
|
|
/* setting - */ |
557 |
|
|
|
558 |
michael |
2937 |
chptr->mode.mode &= ~d; |
559 |
adx |
30 |
|
560 |
|
|
mode_changes[mode_count].letter = c; |
561 |
|
|
mode_changes[mode_count].dir = MODE_DEL; |
562 |
|
|
mode_changes[mode_count].caps = 0; |
563 |
|
|
mode_changes[mode_count].nocaps = 0; |
564 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
565 |
|
|
mode_changes[mode_count].id = NULL; |
566 |
|
|
mode_changes[mode_count++].arg = NULL; |
567 |
|
|
} |
568 |
|
|
} |
569 |
|
|
|
570 |
|
|
static void |
571 |
michael |
1167 |
chm_registered(struct Client *client_p, struct Client *source_p, struct Channel *chptr, |
572 |
|
|
int parc, int *parn, char **parv, int *errors, int alev, int dir, |
573 |
michael |
2937 |
char c, unsigned int d) |
574 |
michael |
1167 |
{ |
575 |
michael |
1219 |
if (!IsServer(source_p) && !HasFlag(source_p, FLAGS_SERVICE)) |
576 |
michael |
1167 |
{ |
577 |
|
|
if (!(*errors & SM_ERR_ONLYSERVER)) |
578 |
michael |
1834 |
sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ? |
579 |
|
|
ERR_NOTONCHANNEL : ERR_ONLYSERVERSCANCHANGE), |
580 |
michael |
2937 |
me.name, source_p->name, chptr->chname); |
581 |
michael |
1167 |
*errors |= SM_ERR_ONLYSERVER; |
582 |
|
|
return; |
583 |
|
|
} |
584 |
|
|
|
585 |
|
|
/* If have already dealt with this simple mode, ignore it */ |
586 |
michael |
2937 |
if (simple_modes_mask & d) |
587 |
michael |
1167 |
return; |
588 |
|
|
|
589 |
michael |
2937 |
simple_modes_mask |= d; |
590 |
michael |
1167 |
|
591 |
|
|
/* setting + */ |
592 |
michael |
2892 |
/* Apparently, (though no one has ever told the hybrid group directly) |
593 |
|
|
* admins don't like redundant mode checking. ok. It would have been nice |
594 |
|
|
* if you had have told us directly. I've left the original code snippets |
595 |
|
|
* in place. |
596 |
|
|
* |
597 |
|
|
* -Dianora |
598 |
michael |
1167 |
*/ |
599 |
michael |
2937 |
if (dir == MODE_ADD) /* && !(chptr->mode.mode & d)) */ |
600 |
michael |
1167 |
{ |
601 |
michael |
2937 |
chptr->mode.mode |= d; |
602 |
michael |
1167 |
|
603 |
|
|
mode_changes[mode_count].letter = c; |
604 |
|
|
mode_changes[mode_count].dir = MODE_ADD; |
605 |
|
|
mode_changes[mode_count].caps = 0; |
606 |
|
|
mode_changes[mode_count].nocaps = 0; |
607 |
|
|
mode_changes[mode_count].id = NULL; |
608 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
609 |
|
|
mode_changes[mode_count++].arg = NULL; |
610 |
|
|
} |
611 |
michael |
2937 |
else if (dir == MODE_DEL) /* && (chptr->mode.mode & d)) */ |
612 |
michael |
1167 |
{ |
613 |
|
|
/* setting - */ |
614 |
|
|
|
615 |
michael |
2937 |
chptr->mode.mode &= ~d; |
616 |
michael |
1167 |
|
617 |
|
|
mode_changes[mode_count].letter = c; |
618 |
|
|
mode_changes[mode_count].dir = MODE_DEL; |
619 |
|
|
mode_changes[mode_count].caps = 0; |
620 |
|
|
mode_changes[mode_count].nocaps = 0; |
621 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
622 |
|
|
mode_changes[mode_count].id = NULL; |
623 |
|
|
mode_changes[mode_count++].arg = NULL; |
624 |
|
|
} |
625 |
|
|
} |
626 |
|
|
|
627 |
|
|
static void |
628 |
michael |
1150 |
chm_operonly(struct Client *client_p, struct Client *source_p, struct Channel *chptr, |
629 |
|
|
int parc, int *parn, char **parv, int *errors, int alev, int dir, |
630 |
michael |
2937 |
char c, unsigned int d) |
631 |
michael |
1150 |
{ |
632 |
|
|
if ((alev < CHACCESS_HALFOP) || |
633 |
michael |
2937 |
((d == MODE_PRIVATE) && (alev < CHACCESS_CHANOP))) |
634 |
michael |
1150 |
{ |
635 |
|
|
if (!(*errors & SM_ERR_NOOPS)) |
636 |
michael |
1834 |
sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ? |
637 |
|
|
ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED), |
638 |
michael |
2937 |
me.name, source_p->name, chptr->chname); |
639 |
michael |
1150 |
*errors |= SM_ERR_NOOPS; |
640 |
|
|
return; |
641 |
|
|
} |
642 |
michael |
1219 |
else if (MyClient(source_p) && !HasUMode(source_p, UMODE_OPER)) |
643 |
michael |
1150 |
{ |
644 |
|
|
if (!(*errors & SM_ERR_NOTOPER)) |
645 |
|
|
{ |
646 |
|
|
if (alev == CHACCESS_NOTONCHAN) |
647 |
michael |
1834 |
sendto_one(source_p, form_str(ERR_NOTONCHANNEL), |
648 |
michael |
2937 |
me.name, source_p->name, chptr->chname); |
649 |
michael |
1150 |
else |
650 |
michael |
1834 |
sendto_one(source_p, form_str(ERR_NOPRIVILEGES), |
651 |
michael |
1150 |
me.name, source_p->name); |
652 |
|
|
} |
653 |
|
|
|
654 |
|
|
*errors |= SM_ERR_NOTOPER; |
655 |
|
|
return; |
656 |
|
|
} |
657 |
|
|
|
658 |
|
|
/* If have already dealt with this simple mode, ignore it */ |
659 |
michael |
2937 |
if (simple_modes_mask & d) |
660 |
michael |
1150 |
return; |
661 |
|
|
|
662 |
michael |
2937 |
simple_modes_mask |= d; |
663 |
michael |
1150 |
|
664 |
michael |
2937 |
if (dir == MODE_ADD) /* && !(chptr->mode.mode & d)) */ |
665 |
michael |
1150 |
{ |
666 |
michael |
2937 |
chptr->mode.mode |= d; |
667 |
michael |
1150 |
|
668 |
|
|
mode_changes[mode_count].letter = c; |
669 |
|
|
mode_changes[mode_count].dir = MODE_ADD; |
670 |
|
|
mode_changes[mode_count].caps = 0; |
671 |
|
|
mode_changes[mode_count].nocaps = 0; |
672 |
|
|
mode_changes[mode_count].id = NULL; |
673 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
674 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
675 |
|
|
mode_changes[mode_count++].arg = NULL; |
676 |
|
|
} |
677 |
michael |
2937 |
else if (dir == MODE_DEL) /* && (chptr->mode.mode & d)) */ |
678 |
michael |
1150 |
{ |
679 |
|
|
/* setting - */ |
680 |
|
|
|
681 |
michael |
2937 |
chptr->mode.mode &= ~d; |
682 |
michael |
1150 |
|
683 |
|
|
mode_changes[mode_count].letter = c; |
684 |
|
|
mode_changes[mode_count].dir = MODE_DEL; |
685 |
|
|
mode_changes[mode_count].caps = 0; |
686 |
|
|
mode_changes[mode_count].nocaps = 0; |
687 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
688 |
|
|
mode_changes[mode_count].id = NULL; |
689 |
|
|
mode_changes[mode_count++].arg = NULL; |
690 |
|
|
} |
691 |
|
|
} |
692 |
|
|
|
693 |
|
|
static void |
694 |
adx |
30 |
chm_ban(struct Client *client_p, struct Client *source_p, |
695 |
|
|
struct Channel *chptr, int parc, int *parn, |
696 |
michael |
2937 |
char **parv, int *errors, int alev, int dir, char c, unsigned int d) |
697 |
adx |
30 |
{ |
698 |
|
|
char *mask = NULL; |
699 |
|
|
|
700 |
|
|
if (dir == MODE_QUERY || parc <= *parn) |
701 |
|
|
{ |
702 |
|
|
dlink_node *ptr = NULL; |
703 |
|
|
|
704 |
|
|
if (*errors & SM_ERR_RPL_B) |
705 |
|
|
return; |
706 |
|
|
|
707 |
|
|
*errors |= SM_ERR_RPL_B; |
708 |
|
|
|
709 |
|
|
DLINK_FOREACH(ptr, chptr->banlist.head) |
710 |
|
|
{ |
711 |
|
|
const struct Ban *banptr = ptr->data; |
712 |
michael |
1834 |
sendto_one(client_p, form_str(RPL_BANLIST), |
713 |
michael |
2937 |
me.name, client_p->name, chptr->chname, |
714 |
michael |
2296 |
banptr->name, banptr->user, banptr->host, |
715 |
michael |
2892 |
banptr->who, banptr->when); |
716 |
adx |
30 |
} |
717 |
|
|
|
718 |
michael |
1834 |
sendto_one(source_p, form_str(RPL_ENDOFBANLIST), me.name, |
719 |
michael |
2937 |
source_p->name, chptr->chname); |
720 |
adx |
30 |
return; |
721 |
|
|
} |
722 |
|
|
|
723 |
|
|
if (alev < CHACCESS_HALFOP) |
724 |
|
|
{ |
725 |
|
|
if (!(*errors & SM_ERR_NOOPS)) |
726 |
michael |
1834 |
sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ? |
727 |
|
|
ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED), |
728 |
michael |
2937 |
me.name, source_p->name, chptr->chname); |
729 |
adx |
30 |
*errors |= SM_ERR_NOOPS; |
730 |
|
|
return; |
731 |
|
|
} |
732 |
|
|
|
733 |
|
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
734 |
|
|
return; |
735 |
|
|
|
736 |
michael |
388 |
mask = nuh_mask[*parn]; |
737 |
|
|
memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn])); |
738 |
|
|
++*parn; |
739 |
|
|
|
740 |
adx |
30 |
if (IsServer(client_p)) |
741 |
|
|
if (strchr(mask, ' ')) |
742 |
|
|
return; |
743 |
|
|
|
744 |
|
|
switch (dir) |
745 |
|
|
{ |
746 |
|
|
case MODE_ADD: |
747 |
|
|
if (!add_id(source_p, chptr, mask, CHFL_BAN)) |
748 |
|
|
return; |
749 |
|
|
break; |
750 |
|
|
case MODE_DEL: |
751 |
|
|
if (!del_id(chptr, mask, CHFL_BAN)) |
752 |
|
|
return; |
753 |
|
|
break; |
754 |
|
|
default: |
755 |
|
|
assert(0); |
756 |
|
|
} |
757 |
|
|
|
758 |
|
|
mode_changes[mode_count].letter = c; |
759 |
|
|
mode_changes[mode_count].dir = dir; |
760 |
|
|
mode_changes[mode_count].caps = 0; |
761 |
|
|
mode_changes[mode_count].nocaps = 0; |
762 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
763 |
|
|
mode_changes[mode_count].id = NULL; |
764 |
|
|
mode_changes[mode_count++].arg = mask; |
765 |
|
|
} |
766 |
|
|
|
767 |
|
|
static void |
768 |
|
|
chm_except(struct Client *client_p, struct Client *source_p, |
769 |
|
|
struct Channel *chptr, int parc, int *parn, |
770 |
michael |
2937 |
char **parv, int *errors, int alev, int dir, char c, unsigned int d) |
771 |
adx |
30 |
{ |
772 |
|
|
char *mask = NULL; |
773 |
|
|
|
774 |
|
|
if (alev < CHACCESS_HALFOP) |
775 |
|
|
{ |
776 |
|
|
if (!(*errors & SM_ERR_NOOPS)) |
777 |
michael |
1834 |
sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ? |
778 |
|
|
ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED), |
779 |
michael |
2937 |
me.name, source_p->name, chptr->chname); |
780 |
adx |
30 |
*errors |= SM_ERR_NOOPS; |
781 |
|
|
return; |
782 |
|
|
} |
783 |
|
|
|
784 |
|
|
if (dir == MODE_QUERY || parc <= *parn) |
785 |
|
|
{ |
786 |
|
|
dlink_node *ptr = NULL; |
787 |
|
|
|
788 |
|
|
if (*errors & SM_ERR_RPL_E) |
789 |
|
|
return; |
790 |
|
|
|
791 |
|
|
*errors |= SM_ERR_RPL_E; |
792 |
|
|
|
793 |
|
|
DLINK_FOREACH(ptr, chptr->exceptlist.head) |
794 |
|
|
{ |
795 |
|
|
const struct Ban *banptr = ptr->data; |
796 |
michael |
1834 |
sendto_one(client_p, form_str(RPL_EXCEPTLIST), |
797 |
michael |
2937 |
me.name, client_p->name, chptr->chname, |
798 |
michael |
2296 |
banptr->name, banptr->user, banptr->host, |
799 |
michael |
2892 |
banptr->who, banptr->when); |
800 |
adx |
30 |
} |
801 |
|
|
|
802 |
michael |
1834 |
sendto_one(source_p, form_str(RPL_ENDOFEXCEPTLIST), me.name, |
803 |
michael |
2937 |
source_p->name, chptr->chname); |
804 |
adx |
30 |
return; |
805 |
|
|
} |
806 |
|
|
|
807 |
|
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
808 |
|
|
return; |
809 |
|
|
|
810 |
michael |
388 |
mask = nuh_mask[*parn]; |
811 |
|
|
memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn])); |
812 |
|
|
++*parn; |
813 |
adx |
30 |
|
814 |
|
|
if (IsServer(client_p)) |
815 |
|
|
if (strchr(mask, ' ')) |
816 |
|
|
return; |
817 |
|
|
|
818 |
|
|
switch (dir) |
819 |
|
|
{ |
820 |
|
|
case MODE_ADD: |
821 |
|
|
if (!add_id(source_p, chptr, mask, CHFL_EXCEPTION)) |
822 |
|
|
return; |
823 |
|
|
break; |
824 |
|
|
case MODE_DEL: |
825 |
|
|
if (!del_id(chptr, mask, CHFL_EXCEPTION)) |
826 |
|
|
return; |
827 |
|
|
break; |
828 |
|
|
default: |
829 |
|
|
assert(0); |
830 |
|
|
} |
831 |
|
|
|
832 |
|
|
mode_changes[mode_count].letter = c; |
833 |
|
|
mode_changes[mode_count].dir = dir; |
834 |
michael |
1684 |
mode_changes[mode_count].caps = 0; |
835 |
adx |
30 |
mode_changes[mode_count].nocaps = 0; |
836 |
michael |
1495 |
mode_changes[mode_count].mems = ONLY_CHANOPS; |
837 |
adx |
30 |
mode_changes[mode_count].id = NULL; |
838 |
|
|
mode_changes[mode_count++].arg = mask; |
839 |
|
|
} |
840 |
|
|
|
841 |
|
|
static void |
842 |
|
|
chm_invex(struct Client *client_p, struct Client *source_p, |
843 |
|
|
struct Channel *chptr, int parc, int *parn, |
844 |
michael |
2937 |
char **parv, int *errors, int alev, int dir, char c, unsigned int d) |
845 |
adx |
30 |
{ |
846 |
|
|
char *mask = NULL; |
847 |
|
|
|
848 |
|
|
if (alev < CHACCESS_HALFOP) |
849 |
|
|
{ |
850 |
|
|
if (!(*errors & SM_ERR_NOOPS)) |
851 |
michael |
1834 |
sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ? |
852 |
|
|
ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED), |
853 |
michael |
2937 |
me.name, source_p->name, chptr->chname); |
854 |
adx |
30 |
*errors |= SM_ERR_NOOPS; |
855 |
|
|
return; |
856 |
|
|
} |
857 |
|
|
|
858 |
|
|
if (dir == MODE_QUERY || parc <= *parn) |
859 |
|
|
{ |
860 |
|
|
dlink_node *ptr = NULL; |
861 |
|
|
|
862 |
|
|
if (*errors & SM_ERR_RPL_I) |
863 |
|
|
return; |
864 |
|
|
|
865 |
|
|
*errors |= SM_ERR_RPL_I; |
866 |
|
|
|
867 |
|
|
DLINK_FOREACH(ptr, chptr->invexlist.head) |
868 |
|
|
{ |
869 |
|
|
const struct Ban *banptr = ptr->data; |
870 |
michael |
1834 |
sendto_one(client_p, form_str(RPL_INVITELIST), me.name, |
871 |
michael |
2937 |
client_p->name, chptr->chname, |
872 |
michael |
2892 |
banptr->name, banptr->user, banptr->host, |
873 |
adx |
30 |
banptr->who, banptr->when); |
874 |
|
|
} |
875 |
|
|
|
876 |
michael |
1834 |
sendto_one(source_p, form_str(RPL_ENDOFINVITELIST), me.name, |
877 |
michael |
2937 |
source_p->name, chptr->chname); |
878 |
adx |
30 |
return; |
879 |
|
|
} |
880 |
|
|
|
881 |
|
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
882 |
|
|
return; |
883 |
|
|
|
884 |
michael |
388 |
mask = nuh_mask[*parn]; |
885 |
|
|
memcpy(mask, parv[*parn], sizeof(nuh_mask[*parn])); |
886 |
|
|
++*parn; |
887 |
adx |
30 |
|
888 |
|
|
if (IsServer(client_p)) |
889 |
|
|
if (strchr(mask, ' ')) |
890 |
|
|
return; |
891 |
|
|
|
892 |
|
|
switch (dir) |
893 |
|
|
{ |
894 |
|
|
case MODE_ADD: |
895 |
|
|
if (!add_id(source_p, chptr, mask, CHFL_INVEX)) |
896 |
|
|
return; |
897 |
|
|
break; |
898 |
|
|
case MODE_DEL: |
899 |
|
|
if (!del_id(chptr, mask, CHFL_INVEX)) |
900 |
|
|
return; |
901 |
|
|
break; |
902 |
|
|
default: |
903 |
|
|
assert(0); |
904 |
|
|
} |
905 |
|
|
|
906 |
|
|
mode_changes[mode_count].letter = c; |
907 |
|
|
mode_changes[mode_count].dir = dir; |
908 |
michael |
1684 |
mode_changes[mode_count].caps = 0; |
909 |
adx |
30 |
mode_changes[mode_count].nocaps = 0; |
910 |
michael |
1495 |
mode_changes[mode_count].mems = ONLY_CHANOPS; |
911 |
adx |
30 |
mode_changes[mode_count].id = NULL; |
912 |
|
|
mode_changes[mode_count++].arg = mask; |
913 |
|
|
} |
914 |
|
|
|
915 |
|
|
/* |
916 |
|
|
* inputs - pointer to channel |
917 |
|
|
* output - none |
918 |
|
|
* side effects - clear ban cache |
919 |
|
|
*/ |
920 |
|
|
void |
921 |
|
|
clear_ban_cache(struct Channel *chptr) |
922 |
|
|
{ |
923 |
|
|
dlink_node *ptr = NULL; |
924 |
|
|
|
925 |
michael |
572 |
DLINK_FOREACH(ptr, chptr->members.head) |
926 |
adx |
30 |
{ |
927 |
|
|
struct Membership *ms = ptr->data; |
928 |
michael |
572 |
|
929 |
|
|
if (MyConnect(ms->client_p)) |
930 |
|
|
ms->flags &= ~(CHFL_BAN_SILENCED|CHFL_BAN_CHECKED); |
931 |
adx |
30 |
} |
932 |
|
|
} |
933 |
|
|
|
934 |
michael |
759 |
void |
935 |
|
|
clear_ban_cache_client(struct Client *client_p) |
936 |
|
|
{ |
937 |
|
|
dlink_node *ptr = NULL; |
938 |
|
|
|
939 |
michael |
760 |
DLINK_FOREACH(ptr, client_p->channel.head) |
940 |
michael |
759 |
{ |
941 |
|
|
struct Membership *ms = ptr->data; |
942 |
|
|
ms->flags &= ~(CHFL_BAN_SILENCED|CHFL_BAN_CHECKED); |
943 |
|
|
} |
944 |
|
|
} |
945 |
|
|
|
946 |
adx |
30 |
static void |
947 |
michael |
2951 |
chm_voice(struct Client *client_p, struct Client *source_p, |
948 |
|
|
struct Channel *chptr, int parc, int *parn, |
949 |
|
|
char **parv, int *errors, int alev, int dir, char c, unsigned int d) |
950 |
adx |
30 |
{ |
951 |
michael |
2892 |
const char *opnick = NULL; |
952 |
adx |
30 |
struct Client *targ_p; |
953 |
|
|
struct Membership *member; |
954 |
|
|
|
955 |
michael |
2951 |
if (alev < CHACCESS_HALFOP) |
956 |
adx |
30 |
{ |
957 |
|
|
if (!(*errors & SM_ERR_NOOPS)) |
958 |
michael |
1834 |
sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ? |
959 |
|
|
ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED), |
960 |
michael |
2937 |
me.name, source_p->name, chptr->chname); |
961 |
adx |
30 |
*errors |= SM_ERR_NOOPS; |
962 |
|
|
return; |
963 |
|
|
} |
964 |
|
|
|
965 |
michael |
2951 |
if ((dir == MODE_QUERY) || parc <= *parn) |
966 |
adx |
30 |
return; |
967 |
|
|
|
968 |
|
|
opnick = parv[(*parn)++]; |
969 |
|
|
|
970 |
michael |
2475 |
if ((targ_p = find_chasing(source_p, opnick, NULL)) == NULL) |
971 |
adx |
30 |
return; |
972 |
|
|
if (!IsClient(targ_p)) |
973 |
|
|
return; |
974 |
|
|
|
975 |
|
|
if ((member = find_channel_link(targ_p, chptr)) == NULL) |
976 |
|
|
{ |
977 |
|
|
if (!(*errors & SM_ERR_NOTONCHANNEL)) |
978 |
michael |
2951 |
sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL), |
979 |
|
|
me.name, source_p->name, opnick, chptr->chname); |
980 |
adx |
30 |
*errors |= SM_ERR_NOTONCHANNEL; |
981 |
|
|
return; |
982 |
|
|
} |
983 |
|
|
|
984 |
|
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
985 |
|
|
return; |
986 |
|
|
|
987 |
|
|
/* no redundant mode changes */ |
988 |
michael |
2951 |
if (dir == MODE_ADD && has_member_flags(member, CHFL_VOICE)) |
989 |
adx |
30 |
return; |
990 |
michael |
2951 |
if (dir == MODE_DEL && !has_member_flags(member, CHFL_VOICE)) |
991 |
adx |
30 |
return; |
992 |
|
|
|
993 |
michael |
2951 |
mode_changes[mode_count].letter = 'v'; |
994 |
adx |
30 |
mode_changes[mode_count].dir = dir; |
995 |
michael |
2951 |
mode_changes[mode_count].caps = 0; |
996 |
adx |
30 |
mode_changes[mode_count].nocaps = 0; |
997 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
998 |
|
|
mode_changes[mode_count].id = targ_p->id; |
999 |
|
|
mode_changes[mode_count].arg = targ_p->name; |
1000 |
|
|
mode_changes[mode_count++].client = targ_p; |
1001 |
|
|
|
1002 |
|
|
if (dir == MODE_ADD) |
1003 |
michael |
2951 |
AddMemberFlag(member, CHFL_VOICE); |
1004 |
adx |
30 |
else |
1005 |
michael |
2951 |
DelMemberFlag(member, CHFL_VOICE); |
1006 |
adx |
30 |
} |
1007 |
|
|
|
1008 |
|
|
#ifdef HALFOPS |
1009 |
|
|
static void |
1010 |
|
|
chm_hop(struct Client *client_p, struct Client *source_p, |
1011 |
|
|
struct Channel *chptr, int parc, int *parn, |
1012 |
michael |
2937 |
char **parv, int *errors, int alev, int dir, char c, unsigned int d) |
1013 |
adx |
30 |
{ |
1014 |
michael |
2892 |
const char *opnick = NULL; |
1015 |
adx |
30 |
struct Client *targ_p; |
1016 |
|
|
struct Membership *member; |
1017 |
|
|
|
1018 |
|
|
/* *sigh* - dont allow halfops to set +/-h, they could fully control a |
1019 |
|
|
* channel if there were no ops - it doesnt solve anything.. MODE_PRIVATE |
1020 |
|
|
* when used with MODE_SECRET is paranoid - cant use +p |
1021 |
|
|
* |
1022 |
|
|
* it needs to be optional per channel - but not via +p, that or remove |
1023 |
|
|
* paranoid.. -- fl_ |
1024 |
|
|
* |
1025 |
|
|
* +p means paranoid, it is useless for anything else on modern IRC, as |
1026 |
|
|
* list isn't really usable. If you want to have a private channel these |
1027 |
|
|
* days, you set it +s. Halfops can no longer remove simple modes when |
1028 |
|
|
* +p is set (although they can set +p) so it is safe to use this to |
1029 |
|
|
* control whether they can (de)halfop... |
1030 |
|
|
*/ |
1031 |
|
|
if (alev < |
1032 |
|
|
((chptr->mode.mode & MODE_PRIVATE) ? CHACCESS_CHANOP : CHACCESS_HALFOP)) |
1033 |
|
|
{ |
1034 |
|
|
if (!(*errors & SM_ERR_NOOPS)) |
1035 |
michael |
1834 |
sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ? |
1036 |
|
|
ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED), |
1037 |
michael |
2937 |
me.name, source_p->name, chptr->chname); |
1038 |
adx |
30 |
*errors |= SM_ERR_NOOPS; |
1039 |
|
|
return; |
1040 |
|
|
} |
1041 |
|
|
|
1042 |
|
|
if ((dir == MODE_QUERY) || (parc <= *parn)) |
1043 |
|
|
return; |
1044 |
|
|
|
1045 |
|
|
opnick = parv[(*parn)++]; |
1046 |
|
|
|
1047 |
michael |
2475 |
if ((targ_p = find_chasing(source_p, opnick, NULL)) == NULL) |
1048 |
adx |
30 |
return; |
1049 |
|
|
if (!IsClient(targ_p)) |
1050 |
|
|
return; |
1051 |
|
|
|
1052 |
|
|
if ((member = find_channel_link(targ_p, chptr)) == NULL) |
1053 |
|
|
{ |
1054 |
|
|
if (!(*errors & SM_ERR_NOTONCHANNEL)) |
1055 |
michael |
1834 |
sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL), |
1056 |
michael |
2937 |
me.name, source_p->name, opnick, chptr->chname); |
1057 |
adx |
30 |
*errors |= SM_ERR_NOTONCHANNEL; |
1058 |
|
|
return; |
1059 |
|
|
} |
1060 |
|
|
|
1061 |
|
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
1062 |
|
|
return; |
1063 |
|
|
|
1064 |
|
|
/* no redundant mode changes */ |
1065 |
adx |
356 |
if (dir == MODE_ADD && has_member_flags(member, CHFL_HALFOP | CHFL_CHANOP)) |
1066 |
adx |
30 |
return; |
1067 |
|
|
if (dir == MODE_DEL && !has_member_flags(member, CHFL_HALFOP)) |
1068 |
|
|
return; |
1069 |
|
|
|
1070 |
|
|
mode_changes[mode_count].letter = 'h'; |
1071 |
|
|
mode_changes[mode_count].dir = dir; |
1072 |
adx |
356 |
mode_changes[mode_count].caps = CAP_HOPS; |
1073 |
adx |
30 |
mode_changes[mode_count].nocaps = 0; |
1074 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
1075 |
|
|
mode_changes[mode_count].id = targ_p->id; |
1076 |
|
|
mode_changes[mode_count].arg = targ_p->name; |
1077 |
|
|
mode_changes[mode_count++].client = targ_p; |
1078 |
|
|
|
1079 |
adx |
356 |
mode_changes[mode_count].letter = 'o'; |
1080 |
|
|
mode_changes[mode_count].dir = dir; |
1081 |
|
|
mode_changes[mode_count].caps = 0; |
1082 |
|
|
mode_changes[mode_count].nocaps = CAP_HOPS; |
1083 |
|
|
mode_changes[mode_count].mems = ONLY_SERVERS; |
1084 |
|
|
mode_changes[mode_count].id = targ_p->id; |
1085 |
|
|
mode_changes[mode_count].arg = targ_p->name; |
1086 |
|
|
mode_changes[mode_count++].client = targ_p; |
1087 |
|
|
|
1088 |
adx |
30 |
if (dir == MODE_ADD) |
1089 |
|
|
{ |
1090 |
|
|
AddMemberFlag(member, CHFL_HALFOP); |
1091 |
|
|
DelMemberFlag(member, CHFL_DEOPPED); |
1092 |
|
|
} |
1093 |
|
|
else |
1094 |
|
|
DelMemberFlag(member, CHFL_HALFOP); |
1095 |
|
|
} |
1096 |
|
|
#endif |
1097 |
|
|
|
1098 |
|
|
static void |
1099 |
michael |
2951 |
chm_op(struct Client *client_p, struct Client *source_p, |
1100 |
|
|
struct Channel *chptr, int parc, int *parn, |
1101 |
|
|
char **parv, int *errors, int alev, int dir, char c, unsigned int d) |
1102 |
adx |
30 |
{ |
1103 |
michael |
2892 |
const char *opnick = NULL; |
1104 |
adx |
30 |
struct Client *targ_p; |
1105 |
|
|
struct Membership *member; |
1106 |
michael |
2951 |
int caps = 0; |
1107 |
adx |
30 |
|
1108 |
michael |
2951 |
if (alev < CHACCESS_CHANOP) |
1109 |
adx |
30 |
{ |
1110 |
|
|
if (!(*errors & SM_ERR_NOOPS)) |
1111 |
michael |
1834 |
sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ? |
1112 |
|
|
ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED), |
1113 |
michael |
2937 |
me.name, source_p->name, chptr->chname); |
1114 |
adx |
30 |
*errors |= SM_ERR_NOOPS; |
1115 |
|
|
return; |
1116 |
|
|
} |
1117 |
|
|
|
1118 |
michael |
2951 |
if ((dir == MODE_QUERY) || (parc <= *parn)) |
1119 |
adx |
30 |
return; |
1120 |
|
|
|
1121 |
|
|
opnick = parv[(*parn)++]; |
1122 |
|
|
|
1123 |
michael |
2475 |
if ((targ_p = find_chasing(source_p, opnick, NULL)) == NULL) |
1124 |
adx |
30 |
return; |
1125 |
|
|
if (!IsClient(targ_p)) |
1126 |
|
|
return; |
1127 |
|
|
|
1128 |
|
|
if ((member = find_channel_link(targ_p, chptr)) == NULL) |
1129 |
|
|
{ |
1130 |
|
|
if (!(*errors & SM_ERR_NOTONCHANNEL)) |
1131 |
michael |
2951 |
sendto_one(source_p, form_str(ERR_USERNOTINCHANNEL), me.name, |
1132 |
|
|
source_p->name, opnick, chptr->chname); |
1133 |
adx |
30 |
*errors |= SM_ERR_NOTONCHANNEL; |
1134 |
|
|
return; |
1135 |
|
|
} |
1136 |
|
|
|
1137 |
|
|
if (MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) |
1138 |
|
|
return; |
1139 |
|
|
|
1140 |
|
|
/* no redundant mode changes */ |
1141 |
michael |
2951 |
if (dir == MODE_ADD && has_member_flags(member, CHFL_CHANOP)) |
1142 |
adx |
30 |
return; |
1143 |
michael |
2951 |
if (dir == MODE_DEL && !has_member_flags(member, CHFL_CHANOP)) |
1144 |
|
|
{ |
1145 |
|
|
#ifdef HALFOPS |
1146 |
|
|
if (has_member_flags(member, CHFL_HALFOP)) |
1147 |
|
|
{ |
1148 |
|
|
--*parn; |
1149 |
|
|
chm_hop(client_p, source_p, chptr, parc, parn, parv, errors, alev, |
1150 |
|
|
dir, c, d); |
1151 |
|
|
} |
1152 |
|
|
#endif |
1153 |
adx |
30 |
return; |
1154 |
michael |
2951 |
} |
1155 |
adx |
30 |
|
1156 |
michael |
2951 |
#ifdef HALFOPS |
1157 |
|
|
if (dir == MODE_ADD && has_member_flags(member, CHFL_HALFOP)) |
1158 |
|
|
{ |
1159 |
|
|
/* promoting from % to @ is visible only to CAP_HOPS servers */ |
1160 |
|
|
mode_changes[mode_count].letter = 'h'; |
1161 |
|
|
mode_changes[mode_count].dir = MODE_DEL; |
1162 |
|
|
mode_changes[mode_count].caps = caps = CAP_HOPS; |
1163 |
|
|
mode_changes[mode_count].nocaps = 0; |
1164 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
1165 |
|
|
mode_changes[mode_count].id = NULL; |
1166 |
|
|
mode_changes[mode_count].arg = targ_p->name; |
1167 |
|
|
mode_changes[mode_count++].client = targ_p; |
1168 |
|
|
} |
1169 |
|
|
#endif |
1170 |
|
|
|
1171 |
|
|
mode_changes[mode_count].letter = 'o'; |
1172 |
adx |
30 |
mode_changes[mode_count].dir = dir; |
1173 |
michael |
2951 |
mode_changes[mode_count].caps = caps; |
1174 |
adx |
30 |
mode_changes[mode_count].nocaps = 0; |
1175 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
1176 |
|
|
mode_changes[mode_count].id = targ_p->id; |
1177 |
|
|
mode_changes[mode_count].arg = targ_p->name; |
1178 |
|
|
mode_changes[mode_count++].client = targ_p; |
1179 |
|
|
|
1180 |
|
|
if (dir == MODE_ADD) |
1181 |
michael |
2951 |
{ |
1182 |
|
|
AddMemberFlag(member, CHFL_CHANOP); |
1183 |
|
|
DelMemberFlag(member, CHFL_DEOPPED | CHFL_HALFOP); |
1184 |
|
|
} |
1185 |
adx |
30 |
else |
1186 |
michael |
2951 |
DelMemberFlag(member, CHFL_CHANOP); |
1187 |
adx |
30 |
} |
1188 |
|
|
|
1189 |
|
|
static void |
1190 |
|
|
chm_limit(struct Client *client_p, struct Client *source_p, |
1191 |
|
|
struct Channel *chptr, int parc, int *parn, |
1192 |
michael |
2937 |
char **parv, int *errors, int alev, int dir, char c, unsigned int d) |
1193 |
adx |
30 |
{ |
1194 |
|
|
int i, limit; |
1195 |
|
|
char *lstr; |
1196 |
|
|
|
1197 |
|
|
if (alev < CHACCESS_HALFOP) |
1198 |
|
|
{ |
1199 |
|
|
if (!(*errors & SM_ERR_NOOPS)) |
1200 |
michael |
1834 |
sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ? |
1201 |
|
|
ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED), |
1202 |
michael |
2937 |
me.name, source_p->name, chptr->chname); |
1203 |
adx |
30 |
*errors |= SM_ERR_NOOPS; |
1204 |
|
|
return; |
1205 |
|
|
} |
1206 |
|
|
|
1207 |
|
|
if (dir == MODE_QUERY) |
1208 |
|
|
return; |
1209 |
|
|
|
1210 |
|
|
if ((dir == MODE_ADD) && parc > *parn) |
1211 |
|
|
{ |
1212 |
|
|
lstr = parv[(*parn)++]; |
1213 |
|
|
|
1214 |
|
|
if ((limit = atoi(lstr)) <= 0) |
1215 |
|
|
return; |
1216 |
|
|
|
1217 |
michael |
1793 |
sprintf(lstr, "%d", limit); |
1218 |
adx |
30 |
|
1219 |
|
|
/* if somebody sets MODE #channel +ll 1 2, accept latter --fl */ |
1220 |
|
|
for (i = 0; i < mode_count; i++) |
1221 |
|
|
if (mode_changes[i].letter == c && mode_changes[i].dir == MODE_ADD) |
1222 |
|
|
mode_changes[i].letter = 0; |
1223 |
|
|
|
1224 |
|
|
mode_changes[mode_count].letter = c; |
1225 |
|
|
mode_changes[mode_count].dir = MODE_ADD; |
1226 |
|
|
mode_changes[mode_count].caps = 0; |
1227 |
|
|
mode_changes[mode_count].nocaps = 0; |
1228 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
1229 |
|
|
mode_changes[mode_count].id = NULL; |
1230 |
|
|
mode_changes[mode_count++].arg = lstr; |
1231 |
|
|
|
1232 |
|
|
chptr->mode.limit = limit; |
1233 |
|
|
} |
1234 |
|
|
else if (dir == MODE_DEL) |
1235 |
|
|
{ |
1236 |
|
|
if (!chptr->mode.limit) |
1237 |
|
|
return; |
1238 |
|
|
|
1239 |
|
|
chptr->mode.limit = 0; |
1240 |
|
|
|
1241 |
|
|
mode_changes[mode_count].letter = c; |
1242 |
|
|
mode_changes[mode_count].dir = MODE_DEL; |
1243 |
|
|
mode_changes[mode_count].caps = 0; |
1244 |
|
|
mode_changes[mode_count].nocaps = 0; |
1245 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
1246 |
|
|
mode_changes[mode_count].id = NULL; |
1247 |
|
|
mode_changes[mode_count++].arg = NULL; |
1248 |
|
|
} |
1249 |
|
|
} |
1250 |
|
|
|
1251 |
|
|
static void |
1252 |
|
|
chm_key(struct Client *client_p, struct Client *source_p, |
1253 |
|
|
struct Channel *chptr, int parc, int *parn, |
1254 |
michael |
2937 |
char **parv, int *errors, int alev, int dir, char c, unsigned int d) |
1255 |
adx |
30 |
{ |
1256 |
|
|
int i; |
1257 |
|
|
char *key; |
1258 |
|
|
|
1259 |
|
|
if (alev < CHACCESS_HALFOP) |
1260 |
|
|
{ |
1261 |
|
|
if (!(*errors & SM_ERR_NOOPS)) |
1262 |
michael |
1834 |
sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ? |
1263 |
|
|
ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED), |
1264 |
michael |
2937 |
me.name, source_p->name, chptr->chname); |
1265 |
adx |
30 |
*errors |= SM_ERR_NOOPS; |
1266 |
|
|
return; |
1267 |
|
|
} |
1268 |
|
|
|
1269 |
|
|
if (dir == MODE_QUERY) |
1270 |
|
|
return; |
1271 |
|
|
|
1272 |
|
|
if ((dir == MODE_ADD) && parc > *parn) |
1273 |
|
|
{ |
1274 |
|
|
key = parv[(*parn)++]; |
1275 |
|
|
|
1276 |
|
|
if (MyClient(source_p)) |
1277 |
|
|
fix_key(key); |
1278 |
|
|
else |
1279 |
|
|
fix_key_old(key); |
1280 |
|
|
|
1281 |
|
|
if (*key == '\0') |
1282 |
|
|
return; |
1283 |
|
|
|
1284 |
|
|
assert(key[0] != ' '); |
1285 |
|
|
strlcpy(chptr->mode.key, key, sizeof(chptr->mode.key)); |
1286 |
|
|
|
1287 |
|
|
/* if somebody does MODE #channel +kk a b, accept latter --fl */ |
1288 |
|
|
for (i = 0; i < mode_count; i++) |
1289 |
|
|
if (mode_changes[i].letter == c && mode_changes[i].dir == MODE_ADD) |
1290 |
|
|
mode_changes[i].letter = 0; |
1291 |
|
|
|
1292 |
|
|
mode_changes[mode_count].letter = c; |
1293 |
|
|
mode_changes[mode_count].dir = MODE_ADD; |
1294 |
|
|
mode_changes[mode_count].caps = 0; |
1295 |
|
|
mode_changes[mode_count].nocaps = 0; |
1296 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
1297 |
|
|
mode_changes[mode_count].id = NULL; |
1298 |
|
|
mode_changes[mode_count++].arg = chptr->mode.key; |
1299 |
|
|
} |
1300 |
|
|
else if (dir == MODE_DEL) |
1301 |
|
|
{ |
1302 |
|
|
if (parc > *parn) |
1303 |
|
|
(*parn)++; |
1304 |
|
|
|
1305 |
|
|
if (chptr->mode.key[0] == '\0') |
1306 |
|
|
return; |
1307 |
|
|
|
1308 |
|
|
chptr->mode.key[0] = '\0'; |
1309 |
|
|
|
1310 |
|
|
mode_changes[mode_count].letter = c; |
1311 |
|
|
mode_changes[mode_count].dir = MODE_DEL; |
1312 |
|
|
mode_changes[mode_count].caps = 0; |
1313 |
|
|
mode_changes[mode_count].nocaps = 0; |
1314 |
|
|
mode_changes[mode_count].mems = ALL_MEMBERS; |
1315 |
|
|
mode_changes[mode_count].id = NULL; |
1316 |
|
|
mode_changes[mode_count++].arg = "*"; |
1317 |
|
|
} |
1318 |
|
|
} |
1319 |
|
|
|
1320 |
|
|
struct ChannelMode |
1321 |
|
|
{ |
1322 |
michael |
2937 |
void (*func)(struct Client *, struct Client *, |
1323 |
|
|
struct Channel *, int, int *, char **, |
1324 |
|
|
int *, int, int, char, unsigned int); |
1325 |
|
|
unsigned int d; |
1326 |
adx |
30 |
}; |
1327 |
|
|
|
1328 |
michael |
2939 |
static struct ChannelMode ModeTable[256] = |
1329 |
adx |
30 |
{ |
1330 |
michael |
2939 |
{ chm_nosuch, 0 }, /* 0x00 */ |
1331 |
|
|
{ chm_nosuch, 0 }, /* 0x01 */ |
1332 |
|
|
{ chm_nosuch, 0 }, /* 0x02 */ |
1333 |
|
|
{ chm_nosuch, 0 }, /* 0x03 */ |
1334 |
|
|
{ chm_nosuch, 0 }, /* 0x04 */ |
1335 |
|
|
{ chm_nosuch, 0 }, /* 0x05 */ |
1336 |
|
|
{ chm_nosuch, 0 }, /* 0x06 */ |
1337 |
|
|
{ chm_nosuch, 0 }, /* 0x07 */ |
1338 |
|
|
{ chm_nosuch, 0 }, /* 0x08 */ |
1339 |
|
|
{ chm_nosuch, 0 }, /* 0x09 */ |
1340 |
|
|
{ chm_nosuch, 0 }, /* 0x0a */ |
1341 |
|
|
{ chm_nosuch, 0 }, /* 0x0b */ |
1342 |
|
|
{ chm_nosuch, 0 }, /* 0x0c */ |
1343 |
|
|
{ chm_nosuch, 0 }, /* 0x0d */ |
1344 |
|
|
{ chm_nosuch, 0 }, /* 0x0e */ |
1345 |
|
|
{ chm_nosuch, 0 }, /* 0x0f */ |
1346 |
|
|
{ chm_nosuch, 0 }, /* 0x10 */ |
1347 |
|
|
{ chm_nosuch, 0 }, /* 0x11 */ |
1348 |
|
|
{ chm_nosuch, 0 }, /* 0x12 */ |
1349 |
|
|
{ chm_nosuch, 0 }, /* 0x13 */ |
1350 |
|
|
{ chm_nosuch, 0 }, /* 0x14 */ |
1351 |
|
|
{ chm_nosuch, 0 }, /* 0x15 */ |
1352 |
|
|
{ chm_nosuch, 0 }, /* 0x16 */ |
1353 |
|
|
{ chm_nosuch, 0 }, /* 0x17 */ |
1354 |
|
|
{ chm_nosuch, 0 }, /* 0x18 */ |
1355 |
|
|
{ chm_nosuch, 0 }, /* 0x19 */ |
1356 |
|
|
{ chm_nosuch, 0 }, /* 0x1a */ |
1357 |
|
|
{ chm_nosuch, 0 }, /* 0x1b */ |
1358 |
|
|
{ chm_nosuch, 0 }, /* 0x1c */ |
1359 |
|
|
{ chm_nosuch, 0 }, /* 0x1d */ |
1360 |
|
|
{ chm_nosuch, 0 }, /* 0x1e */ |
1361 |
|
|
{ chm_nosuch, 0 }, /* 0x1f */ |
1362 |
|
|
{ chm_nosuch, 0 }, /* 0x20 */ |
1363 |
|
|
{ chm_nosuch, 0 }, /* 0x21 */ |
1364 |
|
|
{ chm_nosuch, 0 }, /* 0x22 */ |
1365 |
|
|
{ chm_nosuch, 0 }, /* 0x23 */ |
1366 |
|
|
{ chm_nosuch, 0 }, /* 0x24 */ |
1367 |
|
|
{ chm_nosuch, 0 }, /* 0x25 */ |
1368 |
|
|
{ chm_nosuch, 0 }, /* 0x26 */ |
1369 |
|
|
{ chm_nosuch, 0 }, /* 0x27 */ |
1370 |
|
|
{ chm_nosuch, 0 }, /* 0x28 */ |
1371 |
|
|
{ chm_nosuch, 0 }, /* 0x29 */ |
1372 |
|
|
{ chm_nosuch, 0 }, /* 0x2a */ |
1373 |
|
|
{ chm_nosuch, 0 }, /* 0x2b */ |
1374 |
|
|
{ chm_nosuch, 0 }, /* 0x2c */ |
1375 |
|
|
{ chm_nosuch, 0 }, /* 0x2d */ |
1376 |
|
|
{ chm_nosuch, 0 }, /* 0x2e */ |
1377 |
|
|
{ chm_nosuch, 0 }, /* 0x2f */ |
1378 |
|
|
{ chm_nosuch, 0 }, /* 0x30 */ |
1379 |
|
|
{ chm_nosuch, 0 }, /* 0x31 */ |
1380 |
|
|
{ chm_nosuch, 0 }, /* 0x32 */ |
1381 |
|
|
{ chm_nosuch, 0 }, /* 0x33 */ |
1382 |
|
|
{ chm_nosuch, 0 }, /* 0x34 */ |
1383 |
|
|
{ chm_nosuch, 0 }, /* 0x35 */ |
1384 |
|
|
{ chm_nosuch, 0 }, /* 0x36 */ |
1385 |
|
|
{ chm_nosuch, 0 }, /* 0x37 */ |
1386 |
|
|
{ chm_nosuch, 0 }, /* 0x38 */ |
1387 |
|
|
{ chm_nosuch, 0 }, /* 0x39 */ |
1388 |
|
|
{ chm_nosuch, 0 }, /* 0x3a */ |
1389 |
|
|
{ chm_nosuch, 0 }, /* 0x3b */ |
1390 |
|
|
{ chm_nosuch, 0 }, /* 0x3c */ |
1391 |
|
|
{ chm_nosuch, 0 }, /* 0x3d */ |
1392 |
|
|
{ chm_nosuch, 0 }, /* 0x3e */ |
1393 |
|
|
{ chm_nosuch, 0 }, /* 0x3f */ |
1394 |
|
|
{ chm_nosuch, 0 }, /* @ */ |
1395 |
|
|
{ chm_nosuch, 0 }, /* A */ |
1396 |
|
|
{ chm_nosuch, 0 }, /* B */ |
1397 |
|
|
{ chm_nosuch, 0 }, /* C */ |
1398 |
|
|
{ chm_nosuch, 0 }, /* D */ |
1399 |
|
|
{ chm_nosuch, 0 }, /* E */ |
1400 |
|
|
{ chm_nosuch, 0 }, /* F */ |
1401 |
|
|
{ chm_nosuch, 0 }, /* G */ |
1402 |
|
|
{ chm_nosuch, 0 }, /* H */ |
1403 |
|
|
{ chm_invex, 0 }, /* I */ |
1404 |
|
|
{ chm_nosuch, 0 }, /* J */ |
1405 |
|
|
{ chm_nosuch, 0 }, /* K */ |
1406 |
|
|
{ chm_nosuch, 0 }, /* L */ |
1407 |
|
|
{ chm_simple, MODE_MODREG}, /* M */ |
1408 |
|
|
{ chm_nosuch, 0 }, /* N */ |
1409 |
|
|
{ chm_operonly, MODE_OPERONLY}, /* O */ |
1410 |
|
|
{ chm_nosuch, 0 }, /* P */ |
1411 |
|
|
{ chm_nosuch, 0 }, /* Q */ |
1412 |
|
|
{ chm_simple, MODE_REGONLY}, /* R */ |
1413 |
|
|
{ chm_simple, MODE_SSLONLY}, /* S */ |
1414 |
|
|
{ chm_nosuch, 0 }, /* T */ |
1415 |
|
|
{ chm_nosuch, 0 }, /* U */ |
1416 |
|
|
{ chm_nosuch, 0 }, /* V */ |
1417 |
|
|
{ chm_nosuch, 0 }, /* W */ |
1418 |
|
|
{ chm_nosuch, 0 }, /* X */ |
1419 |
|
|
{ chm_nosuch, 0 }, /* Y */ |
1420 |
|
|
{ chm_nosuch, 0 }, /* Z */ |
1421 |
|
|
{ chm_nosuch, 0 }, |
1422 |
|
|
{ chm_nosuch, 0 }, |
1423 |
|
|
{ chm_nosuch, 0 }, |
1424 |
|
|
{ chm_nosuch, 0 }, |
1425 |
|
|
{ chm_nosuch, 0 }, |
1426 |
|
|
{ chm_nosuch, 0 }, |
1427 |
|
|
{ chm_nosuch, 0 }, /* a */ |
1428 |
|
|
{ chm_ban, 0 }, /* b */ |
1429 |
|
|
{ chm_simple, MODE_NOCTRL}, /* c */ |
1430 |
|
|
{ chm_nosuch, 0 }, /* d */ |
1431 |
|
|
{ chm_except, 0 }, /* e */ |
1432 |
|
|
{ chm_nosuch, 0 }, /* f */ |
1433 |
|
|
{ chm_nosuch, 0 }, /* g */ |
1434 |
adx |
30 |
#ifdef HALFOPS |
1435 |
michael |
2939 |
{ chm_hop, 0 }, /* h */ |
1436 |
adx |
30 |
#else |
1437 |
michael |
2939 |
{ chm_nosuch, 0 }, /* h */ |
1438 |
adx |
30 |
#endif |
1439 |
michael |
2939 |
{ chm_simple, MODE_INVITEONLY }, /* i */ |
1440 |
|
|
{ chm_nosuch, 0 }, /* j */ |
1441 |
|
|
{ chm_key, 0 }, /* k */ |
1442 |
|
|
{ chm_limit, 0 }, /* l */ |
1443 |
|
|
{ chm_simple, MODE_MODERATED }, /* m */ |
1444 |
|
|
{ chm_simple, MODE_NOPRIVMSGS }, /* n */ |
1445 |
|
|
{ chm_op, 0 }, /* o */ |
1446 |
|
|
{ chm_simple, MODE_PRIVATE }, /* p */ |
1447 |
|
|
{ chm_nosuch, 0 }, /* q */ |
1448 |
|
|
{ chm_registered, MODE_REGISTERED }, /* r */ |
1449 |
|
|
{ chm_simple, MODE_SECRET }, /* s */ |
1450 |
|
|
{ chm_simple, MODE_TOPICLIMIT }, /* t */ |
1451 |
|
|
{ chm_nosuch, 0 }, /* u */ |
1452 |
|
|
{ chm_voice, 0 }, /* v */ |
1453 |
|
|
{ chm_nosuch, 0 }, /* w */ |
1454 |
|
|
{ chm_nosuch, 0 }, /* x */ |
1455 |
|
|
{ chm_nosuch, 0 }, /* y */ |
1456 |
|
|
{ chm_nosuch, 0 }, /* z */ |
1457 |
|
|
{ chm_nosuch, 0 }, /* 0x7b */ |
1458 |
|
|
{ chm_nosuch, 0 }, /* 0x7c */ |
1459 |
|
|
{ chm_nosuch, 0 }, /* 0x7d */ |
1460 |
|
|
{ chm_nosuch, 0 }, /* 0x7e */ |
1461 |
|
|
{ chm_nosuch, 0 }, /* 0x7f */ |
1462 |
|
|
{ chm_nosuch, 0 }, /* 0x80 */ |
1463 |
|
|
{ chm_nosuch, 0 }, /* 0x81 */ |
1464 |
|
|
{ chm_nosuch, 0 }, /* 0x82 */ |
1465 |
|
|
{ chm_nosuch, 0 }, /* 0x83 */ |
1466 |
|
|
{ chm_nosuch, 0 }, /* 0x84 */ |
1467 |
|
|
{ chm_nosuch, 0 }, /* 0x85 */ |
1468 |
|
|
{ chm_nosuch, 0 }, /* 0x86 */ |
1469 |
|
|
{ chm_nosuch, 0 }, /* 0x87 */ |
1470 |
|
|
{ chm_nosuch, 0 }, /* 0x88 */ |
1471 |
|
|
{ chm_nosuch, 0 }, /* 0x89 */ |
1472 |
|
|
{ chm_nosuch, 0 }, /* 0x8a */ |
1473 |
|
|
{ chm_nosuch, 0 }, /* 0x8b */ |
1474 |
|
|
{ chm_nosuch, 0 }, /* 0x8c */ |
1475 |
|
|
{ chm_nosuch, 0 }, /* 0x8d */ |
1476 |
|
|
{ chm_nosuch, 0 }, /* 0x8e */ |
1477 |
|
|
{ chm_nosuch, 0 }, /* 0x8f */ |
1478 |
|
|
{ chm_nosuch, 0 }, /* 0x90 */ |
1479 |
|
|
{ chm_nosuch, 0 }, /* 0x91 */ |
1480 |
|
|
{ chm_nosuch, 0 }, /* 0x92 */ |
1481 |
|
|
{ chm_nosuch, 0 }, /* 0x93 */ |
1482 |
|
|
{ chm_nosuch, 0 }, /* 0x94 */ |
1483 |
|
|
{ chm_nosuch, 0 }, /* 0x95 */ |
1484 |
|
|
{ chm_nosuch, 0 }, /* 0x96 */ |
1485 |
|
|
{ chm_nosuch, 0 }, /* 0x97 */ |
1486 |
|
|
{ chm_nosuch, 0 }, /* 0x98 */ |
1487 |
|
|
{ chm_nosuch, 0 }, /* 0x99 */ |
1488 |
|
|
{ chm_nosuch, 0 }, /* 0x9a */ |
1489 |
|
|
{ chm_nosuch, 0 }, /* 0x9b */ |
1490 |
|
|
{ chm_nosuch, 0 }, /* 0x9c */ |
1491 |
|
|
{ chm_nosuch, 0 }, /* 0x9d */ |
1492 |
|
|
{ chm_nosuch, 0 }, /* 0x9e */ |
1493 |
|
|
{ chm_nosuch, 0 }, /* 0x9f */ |
1494 |
|
|
{ chm_nosuch, 0 }, /* 0xa0 */ |
1495 |
|
|
{ chm_nosuch, 0 }, /* 0xa1 */ |
1496 |
|
|
{ chm_nosuch, 0 }, /* 0xa2 */ |
1497 |
|
|
{ chm_nosuch, 0 }, /* 0xa3 */ |
1498 |
|
|
{ chm_nosuch, 0 }, /* 0xa4 */ |
1499 |
|
|
{ chm_nosuch, 0 }, /* 0xa5 */ |
1500 |
|
|
{ chm_nosuch, 0 }, /* 0xa6 */ |
1501 |
|
|
{ chm_nosuch, 0 }, /* 0xa7 */ |
1502 |
|
|
{ chm_nosuch, 0 }, /* 0xa8 */ |
1503 |
|
|
{ chm_nosuch, 0 }, /* 0xa9 */ |
1504 |
|
|
{ chm_nosuch, 0 }, /* 0xaa */ |
1505 |
|
|
{ chm_nosuch, 0 }, /* 0xab */ |
1506 |
|
|
{ chm_nosuch, 0 }, /* 0xac */ |
1507 |
|
|
{ chm_nosuch, 0 }, /* 0xad */ |
1508 |
|
|
{ chm_nosuch, 0 }, /* 0xae */ |
1509 |
|
|
{ chm_nosuch, 0 }, /* 0xaf */ |
1510 |
|
|
{ chm_nosuch, 0 }, /* 0xb0 */ |
1511 |
|
|
{ chm_nosuch, 0 }, /* 0xb1 */ |
1512 |
|
|
{ chm_nosuch, 0 }, /* 0xb2 */ |
1513 |
|
|
{ chm_nosuch, 0 }, /* 0xb3 */ |
1514 |
|
|
{ chm_nosuch, 0 }, /* 0xb4 */ |
1515 |
|
|
{ chm_nosuch, 0 }, /* 0xb5 */ |
1516 |
|
|
{ chm_nosuch, 0 }, /* 0xb6 */ |
1517 |
|
|
{ chm_nosuch, 0 }, /* 0xb7 */ |
1518 |
|
|
{ chm_nosuch, 0 }, /* 0xb8 */ |
1519 |
|
|
{ chm_nosuch, 0 }, /* 0xb9 */ |
1520 |
|
|
{ chm_nosuch, 0 }, /* 0xba */ |
1521 |
|
|
{ chm_nosuch, 0 }, /* 0xbb */ |
1522 |
|
|
{ chm_nosuch, 0 }, /* 0xbc */ |
1523 |
|
|
{ chm_nosuch, 0 }, /* 0xbd */ |
1524 |
|
|
{ chm_nosuch, 0 }, /* 0xbe */ |
1525 |
|
|
{ chm_nosuch, 0 }, /* 0xbf */ |
1526 |
|
|
{ chm_nosuch, 0 }, /* 0xc0 */ |
1527 |
|
|
{ chm_nosuch, 0 }, /* 0xc1 */ |
1528 |
|
|
{ chm_nosuch, 0 }, /* 0xc2 */ |
1529 |
|
|
{ chm_nosuch, 0 }, /* 0xc3 */ |
1530 |
|
|
{ chm_nosuch, 0 }, /* 0xc4 */ |
1531 |
|
|
{ chm_nosuch, 0 }, /* 0xc5 */ |
1532 |
|
|
{ chm_nosuch, 0 }, /* 0xc6 */ |
1533 |
|
|
{ chm_nosuch, 0 }, /* 0xc7 */ |
1534 |
|
|
{ chm_nosuch, 0 }, /* 0xc8 */ |
1535 |
|
|
{ chm_nosuch, 0 }, /* 0xc9 */ |
1536 |
|
|
{ chm_nosuch, 0 }, /* 0xca */ |
1537 |
|
|
{ chm_nosuch, 0 }, /* 0xcb */ |
1538 |
|
|
{ chm_nosuch, 0 }, /* 0xcc */ |
1539 |
|
|
{ chm_nosuch, 0 }, /* 0xcd */ |
1540 |
|
|
{ chm_nosuch, 0 }, /* 0xce */ |
1541 |
|
|
{ chm_nosuch, 0 }, /* 0xcf */ |
1542 |
|
|
{ chm_nosuch, 0 }, /* 0xd0 */ |
1543 |
|
|
{ chm_nosuch, 0 }, /* 0xd1 */ |
1544 |
|
|
{ chm_nosuch, 0 }, /* 0xd2 */ |
1545 |
|
|
{ chm_nosuch, 0 }, /* 0xd3 */ |
1546 |
|
|
{ chm_nosuch, 0 }, /* 0xd4 */ |
1547 |
|
|
{ chm_nosuch, 0 }, /* 0xd5 */ |
1548 |
|
|
{ chm_nosuch, 0 }, /* 0xd6 */ |
1549 |
|
|
{ chm_nosuch, 0 }, /* 0xd7 */ |
1550 |
|
|
{ chm_nosuch, 0 }, /* 0xd8 */ |
1551 |
|
|
{ chm_nosuch, 0 }, /* 0xd9 */ |
1552 |
|
|
{ chm_nosuch, 0 }, /* 0xda */ |
1553 |
|
|
{ chm_nosuch, 0 }, /* 0xdb */ |
1554 |
|
|
{ chm_nosuch, 0 }, /* 0xdc */ |
1555 |
|
|
{ chm_nosuch, 0 }, /* 0xdd */ |
1556 |
|
|
{ chm_nosuch, 0 }, /* 0xde */ |
1557 |
|
|
{ chm_nosuch, 0 }, /* 0xdf */ |
1558 |
|
|
{ chm_nosuch, 0 }, /* 0xe0 */ |
1559 |
|
|
{ chm_nosuch, 0 }, /* 0xe1 */ |
1560 |
|
|
{ chm_nosuch, 0 }, /* 0xe2 */ |
1561 |
|
|
{ chm_nosuch, 0 }, /* 0xe3 */ |
1562 |
|
|
{ chm_nosuch, 0 }, /* 0xe4 */ |
1563 |
|
|
{ chm_nosuch, 0 }, /* 0xe5 */ |
1564 |
|
|
{ chm_nosuch, 0 }, /* 0xe6 */ |
1565 |
|
|
{ chm_nosuch, 0 }, /* 0xe7 */ |
1566 |
|
|
{ chm_nosuch, 0 }, /* 0xe8 */ |
1567 |
|
|
{ chm_nosuch, 0 }, /* 0xe9 */ |
1568 |
|
|
{ chm_nosuch, 0 }, /* 0xea */ |
1569 |
|
|
{ chm_nosuch, 0 }, /* 0xeb */ |
1570 |
|
|
{ chm_nosuch, 0 }, /* 0xec */ |
1571 |
|
|
{ chm_nosuch, 0 }, /* 0xed */ |
1572 |
|
|
{ chm_nosuch, 0 }, /* 0xee */ |
1573 |
|
|
{ chm_nosuch, 0 }, /* 0xef */ |
1574 |
|
|
{ chm_nosuch, 0 }, /* 0xf0 */ |
1575 |
|
|
{ chm_nosuch, 0 }, /* 0xf1 */ |
1576 |
|
|
{ chm_nosuch, 0 }, /* 0xf2 */ |
1577 |
|
|
{ chm_nosuch, 0 }, /* 0xf3 */ |
1578 |
|
|
{ chm_nosuch, 0 }, /* 0xf4 */ |
1579 |
|
|
{ chm_nosuch, 0 }, /* 0xf5 */ |
1580 |
|
|
{ chm_nosuch, 0 }, /* 0xf6 */ |
1581 |
|
|
{ chm_nosuch, 0 }, /* 0xf7 */ |
1582 |
|
|
{ chm_nosuch, 0 }, /* 0xf8 */ |
1583 |
|
|
{ chm_nosuch, 0 }, /* 0xf9 */ |
1584 |
|
|
{ chm_nosuch, 0 }, /* 0xfa */ |
1585 |
|
|
{ chm_nosuch, 0 }, /* 0xfb */ |
1586 |
|
|
{ chm_nosuch, 0 }, /* 0xfc */ |
1587 |
|
|
{ chm_nosuch, 0 }, /* 0xfd */ |
1588 |
|
|
{ chm_nosuch, 0 }, /* 0xfe */ |
1589 |
|
|
{ chm_nosuch, 0 }, /* 0xff */ |
1590 |
adx |
30 |
}; |
1591 |
|
|
|
1592 |
|
|
/* get_channel_access() |
1593 |
|
|
* |
1594 |
|
|
* inputs - pointer to Client struct |
1595 |
|
|
* - pointer to Membership struct |
1596 |
|
|
* output - CHACCESS_CHANOP if we should let them have |
1597 |
|
|
* chanop level access, 0 for peon level access. |
1598 |
|
|
* side effects - NONE |
1599 |
|
|
*/ |
1600 |
|
|
static int |
1601 |
michael |
2941 |
get_channel_access(const struct Client *source_p, |
1602 |
|
|
const struct Membership *member) |
1603 |
adx |
30 |
{ |
1604 |
|
|
/* Let hacked servers in for now... */ |
1605 |
|
|
if (!MyClient(source_p)) |
1606 |
|
|
return CHACCESS_CHANOP; |
1607 |
|
|
|
1608 |
|
|
if (member == NULL) |
1609 |
|
|
return CHACCESS_NOTONCHAN; |
1610 |
|
|
|
1611 |
|
|
/* just to be sure.. */ |
1612 |
|
|
assert(source_p == member->client_p); |
1613 |
|
|
|
1614 |
|
|
if (has_member_flags(member, CHFL_CHANOP)) |
1615 |
|
|
return CHACCESS_CHANOP; |
1616 |
|
|
|
1617 |
|
|
#ifdef HALFOPS |
1618 |
|
|
if (has_member_flags(member, CHFL_HALFOP)) |
1619 |
|
|
return CHACCESS_HALFOP; |
1620 |
|
|
#endif |
1621 |
|
|
|
1622 |
|
|
return CHACCESS_PEON; |
1623 |
|
|
} |
1624 |
|
|
|
1625 |
|
|
/* void send_cap_mode_changes(struct Client *client_p, |
1626 |
|
|
* struct Client *source_p, |
1627 |
|
|
* struct Channel *chptr, int cap, int nocap) |
1628 |
|
|
* Input: The client sending(client_p), the source client(source_p), |
1629 |
|
|
* the channel to send mode changes for(chptr) |
1630 |
|
|
* Output: None. |
1631 |
|
|
* Side-effects: Sends the appropriate mode changes to capable servers. |
1632 |
|
|
* |
1633 |
|
|
* send_cap_mode_changes() will loop the server list itself, because |
1634 |
|
|
* at this point in time we have 4 capabs for channels, CAP_IE, CAP_EX, |
1635 |
|
|
* and a server could support any number of these.. |
1636 |
|
|
* so we make the modebufs per server, tailoring them to each servers |
1637 |
|
|
* specific demand. Its not very pretty, but its one of the few realistic |
1638 |
|
|
* ways to handle having this many capabs for channel modes.. --fl_ |
1639 |
|
|
* |
1640 |
|
|
* Reverted back to my original design, except that we now keep a count |
1641 |
|
|
* of the number of servers which each combination as an optimisation, so |
1642 |
|
|
* the capabs combinations which are not needed are not worked out. -A1kmm |
1643 |
|
|
*/ |
1644 |
|
|
/* rewritten to ensure parabuf < MODEBUFLEN -db */ |
1645 |
|
|
|
1646 |
|
|
static void |
1647 |
|
|
send_cap_mode_changes(struct Client *client_p, struct Client *source_p, |
1648 |
michael |
1015 |
struct Channel *chptr, unsigned int cap, unsigned int nocap) |
1649 |
adx |
30 |
{ |
1650 |
|
|
int i, mbl, pbl, arglen, nc, mc; |
1651 |
|
|
int len; |
1652 |
|
|
const char *arg = NULL; |
1653 |
|
|
char *parptr; |
1654 |
|
|
int dir = MODE_QUERY; |
1655 |
|
|
|
1656 |
|
|
mc = 0; |
1657 |
|
|
nc = 0; |
1658 |
|
|
pbl = 0; |
1659 |
|
|
|
1660 |
|
|
parabuf[0] = '\0'; |
1661 |
|
|
parptr = parabuf; |
1662 |
|
|
|
1663 |
|
|
if ((cap & CAP_TS6) && source_p->id[0] != '\0') |
1664 |
michael |
3029 |
mbl = snprintf(modebuf, sizeof(modebuf), ":%s TMODE %lu %s ", source_p->id, |
1665 |
|
|
(unsigned long)chptr->channelts, chptr->chname); |
1666 |
adx |
30 |
else |
1667 |
michael |
3029 |
mbl = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s ", source_p->name, |
1668 |
|
|
chptr->chname); |
1669 |
adx |
30 |
|
1670 |
|
|
/* loop the list of - modes we have */ |
1671 |
|
|
for (i = 0; i < mode_count; i++) |
1672 |
|
|
{ |
1673 |
|
|
/* if they dont support the cap we need, or they do support a cap they |
1674 |
|
|
* cant have, then dont add it to the modebuf.. that way they wont see |
1675 |
|
|
* the mode |
1676 |
|
|
*/ |
1677 |
|
|
if ((mode_changes[i].letter == 0) || |
1678 |
michael |
2892 |
((cap & mode_changes[i].caps) != mode_changes[i].caps) || |
1679 |
|
|
((nocap & mode_changes[i].nocaps) != mode_changes[i].nocaps)) |
1680 |
adx |
30 |
continue; |
1681 |
|
|
|
1682 |
|
|
arg = ""; |
1683 |
|
|
|
1684 |
|
|
if ((cap & CAP_TS6) && mode_changes[i].id) |
1685 |
|
|
arg = mode_changes[i].id; |
1686 |
|
|
if (*arg == '\0') |
1687 |
|
|
arg = mode_changes[i].arg; |
1688 |
|
|
|
1689 |
|
|
/* if we're creeping past the buf size, we need to send it and make |
1690 |
|
|
* another line for the other modes |
1691 |
|
|
* XXX - this could give away server topology with uids being |
1692 |
|
|
* different lengths, but not much we can do, except possibly break |
1693 |
|
|
* them as if they were the longest of the nick or uid at all times, |
1694 |
|
|
* which even then won't work as we don't always know the uid -A1kmm. |
1695 |
|
|
*/ |
1696 |
|
|
if (arg != NULL) |
1697 |
|
|
arglen = strlen(arg); |
1698 |
|
|
else |
1699 |
|
|
arglen = 0; |
1700 |
|
|
|
1701 |
|
|
if ((mc == MAXMODEPARAMS) || |
1702 |
|
|
((arglen + mbl + pbl + 2) > IRCD_BUFSIZE) || |
1703 |
|
|
(pbl + arglen + BAN_FUDGE) >= MODEBUFLEN) |
1704 |
|
|
{ |
1705 |
|
|
if (nc != 0) |
1706 |
michael |
2892 |
sendto_server(client_p, cap, nocap, "%s %s", modebuf, parabuf); |
1707 |
adx |
30 |
nc = 0; |
1708 |
|
|
mc = 0; |
1709 |
|
|
|
1710 |
|
|
if ((cap & CAP_TS6) && source_p->id[0] != '\0') |
1711 |
michael |
3029 |
mbl = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s ", source_p->id, |
1712 |
|
|
chptr->chname); |
1713 |
adx |
30 |
else |
1714 |
michael |
3029 |
mbl = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s ", source_p->name, |
1715 |
|
|
chptr->chname); |
1716 |
adx |
30 |
|
1717 |
|
|
pbl = 0; |
1718 |
|
|
parabuf[0] = '\0'; |
1719 |
|
|
parptr = parabuf; |
1720 |
|
|
dir = MODE_QUERY; |
1721 |
|
|
} |
1722 |
|
|
|
1723 |
|
|
if (dir != mode_changes[i].dir) |
1724 |
|
|
{ |
1725 |
|
|
modebuf[mbl++] = (mode_changes[i].dir == MODE_ADD) ? '+' : '-'; |
1726 |
|
|
dir = mode_changes[i].dir; |
1727 |
|
|
} |
1728 |
|
|
|
1729 |
|
|
modebuf[mbl++] = mode_changes[i].letter; |
1730 |
|
|
modebuf[mbl] = '\0'; |
1731 |
|
|
nc++; |
1732 |
|
|
|
1733 |
|
|
if (arg != NULL) |
1734 |
|
|
{ |
1735 |
michael |
1793 |
len = sprintf(parptr, "%s ", arg); |
1736 |
adx |
30 |
pbl += len; |
1737 |
|
|
parptr += len; |
1738 |
|
|
mc++; |
1739 |
|
|
} |
1740 |
|
|
} |
1741 |
|
|
|
1742 |
|
|
if (pbl && parabuf[pbl - 1] == ' ') |
1743 |
|
|
parabuf[pbl - 1] = 0; |
1744 |
|
|
|
1745 |
|
|
if (nc != 0) |
1746 |
michael |
2892 |
sendto_server(client_p, cap, nocap, "%s %s", modebuf, parabuf); |
1747 |
adx |
30 |
} |
1748 |
|
|
|
1749 |
|
|
/* void send_mode_changes(struct Client *client_p, |
1750 |
|
|
* struct Client *source_p, |
1751 |
|
|
* struct Channel *chptr) |
1752 |
|
|
* Input: The client sending(client_p), the source client(source_p), |
1753 |
|
|
* the channel to send mode changes for(chptr), |
1754 |
|
|
* mode change globals. |
1755 |
|
|
* Output: None. |
1756 |
|
|
* Side-effects: Sends the appropriate mode changes to other clients |
1757 |
|
|
* and propagates to servers. |
1758 |
|
|
*/ |
1759 |
|
|
/* ensure parabuf < MODEBUFLEN -db */ |
1760 |
|
|
static void |
1761 |
|
|
send_mode_changes(struct Client *client_p, struct Client *source_p, |
1762 |
michael |
2937 |
struct Channel *chptr) |
1763 |
adx |
30 |
{ |
1764 |
|
|
int i, mbl, pbl, arglen, nc, mc; |
1765 |
|
|
int len; |
1766 |
|
|
const char *arg = NULL; |
1767 |
|
|
char *parptr; |
1768 |
|
|
int dir = MODE_QUERY; |
1769 |
|
|
|
1770 |
|
|
/* bail out if we have nothing to do... */ |
1771 |
|
|
if (!mode_count) |
1772 |
|
|
return; |
1773 |
|
|
|
1774 |
|
|
if (IsServer(source_p)) |
1775 |
michael |
3029 |
mbl = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s ", (IsHidden(source_p) || |
1776 |
|
|
ConfigServerHide.hide_servers) ? |
1777 |
|
|
me.name : source_p->name, chptr->chname); |
1778 |
adx |
30 |
else |
1779 |
michael |
3029 |
mbl = snprintf(modebuf, sizeof(modebuf), ":%s!%s@%s MODE %s ", source_p->name, |
1780 |
|
|
source_p->username, source_p->host, chptr->chname); |
1781 |
adx |
30 |
|
1782 |
|
|
mc = 0; |
1783 |
|
|
nc = 0; |
1784 |
|
|
pbl = 0; |
1785 |
|
|
|
1786 |
|
|
parabuf[0] = '\0'; |
1787 |
|
|
parptr = parabuf; |
1788 |
|
|
|
1789 |
|
|
for (i = 0; i < mode_count; i++) |
1790 |
|
|
{ |
1791 |
|
|
if (mode_changes[i].letter == 0 || |
1792 |
|
|
mode_changes[i].mems == NON_CHANOPS || |
1793 |
|
|
mode_changes[i].mems == ONLY_SERVERS) |
1794 |
|
|
continue; |
1795 |
|
|
|
1796 |
|
|
arg = mode_changes[i].arg; |
1797 |
|
|
if (arg != NULL) |
1798 |
|
|
arglen = strlen(arg); |
1799 |
|
|
else |
1800 |
|
|
arglen = 0; |
1801 |
|
|
|
1802 |
michael |
2892 |
if ((mc == MAXMODEPARAMS) || |
1803 |
adx |
30 |
((arglen + mbl + pbl + 2) > IRCD_BUFSIZE) || |
1804 |
michael |
2892 |
((arglen + pbl + BAN_FUDGE) >= MODEBUFLEN)) |
1805 |
adx |
30 |
{ |
1806 |
|
|
if (mbl && modebuf[mbl - 1] == '-') |
1807 |
|
|
modebuf[mbl - 1] = '\0'; |
1808 |
|
|
|
1809 |
|
|
if (nc != 0) |
1810 |
michael |
1243 |
sendto_channel_local(ALL_MEMBERS, 0, chptr, "%s %s", modebuf, parabuf); |
1811 |
adx |
30 |
|
1812 |
|
|
nc = 0; |
1813 |
|
|
mc = 0; |
1814 |
|
|
|
1815 |
|
|
if (IsServer(source_p)) |
1816 |
michael |
3029 |
mbl = snprintf(modebuf, sizeof(modebuf), ":%s MODE %s ", (IsHidden(source_p) || |
1817 |
|
|
ConfigServerHide.hide_servers) ? |
1818 |
|
|
me.name : source_p->name, chptr->chname); |
1819 |
adx |
30 |
else |
1820 |
michael |
3029 |
mbl = snprintf(modebuf, sizeof(modebuf), ":%s!%s@%s MODE %s ", source_p->name, |
1821 |
|
|
source_p->username, source_p->host, chptr->chname); |
1822 |
adx |
30 |
|
1823 |
|
|
pbl = 0; |
1824 |
|
|
parabuf[0] = '\0'; |
1825 |
|
|
parptr = parabuf; |
1826 |
|
|
dir = MODE_QUERY; |
1827 |
|
|
} |
1828 |
|
|
|
1829 |
|
|
if (dir != mode_changes[i].dir) |
1830 |
|
|
{ |
1831 |
|
|
modebuf[mbl++] = (mode_changes[i].dir == MODE_ADD) ? '+' : '-'; |
1832 |
|
|
dir = mode_changes[i].dir; |
1833 |
|
|
} |
1834 |
|
|
|
1835 |
|
|
modebuf[mbl++] = mode_changes[i].letter; |
1836 |
|
|
modebuf[mbl] = '\0'; |
1837 |
|
|
nc++; |
1838 |
|
|
|
1839 |
|
|
if (arg != NULL) |
1840 |
|
|
{ |
1841 |
michael |
1793 |
len = sprintf(parptr, "%s ", arg); |
1842 |
adx |
30 |
pbl += len; |
1843 |
|
|
parptr += len; |
1844 |
|
|
mc++; |
1845 |
|
|
} |
1846 |
|
|
} |
1847 |
|
|
|
1848 |
|
|
if (pbl && parabuf[pbl - 1] == ' ') |
1849 |
|
|
parabuf[pbl - 1] = 0; |
1850 |
|
|
|
1851 |
|
|
if (nc != 0) |
1852 |
michael |
1243 |
sendto_channel_local(ALL_MEMBERS, 0, chptr, "%s %s", modebuf, parabuf); |
1853 |
adx |
30 |
|
1854 |
|
|
nc = 0; |
1855 |
|
|
mc = 0; |
1856 |
|
|
|
1857 |
|
|
/* Now send to servers... */ |
1858 |
|
|
for (i = 0; i < NCHCAP_COMBOS; i++) |
1859 |
|
|
if (chcap_combos[i].count != 0) |
1860 |
|
|
send_cap_mode_changes(client_p, source_p, chptr, |
1861 |
|
|
chcap_combos[i].cap_yes, |
1862 |
|
|
chcap_combos[i].cap_no); |
1863 |
|
|
} |
1864 |
|
|
|
1865 |
|
|
/* void set_channel_mode(struct Client *client_p, struct Client *source_p, |
1866 |
|
|
* struct Channel *chptr, int parc, char **parv, |
1867 |
|
|
* char *chname) |
1868 |
|
|
* Input: The client we received this from, the client this originated |
1869 |
|
|
* from, the channel, the parameter count starting at the modes, |
1870 |
|
|
* the parameters, the channel name. |
1871 |
|
|
* Output: None. |
1872 |
|
|
* Side-effects: Changes the channel membership and modes appropriately, |
1873 |
|
|
* sends the appropriate MODE messages to the appropriate |
1874 |
|
|
* clients. |
1875 |
|
|
*/ |
1876 |
|
|
void |
1877 |
|
|
set_channel_mode(struct Client *client_p, struct Client *source_p, struct Channel *chptr, |
1878 |
michael |
2937 |
struct Membership *member, int parc, char *parv[]) |
1879 |
adx |
30 |
{ |
1880 |
|
|
int dir = MODE_ADD; |
1881 |
|
|
int parn = 1; |
1882 |
|
|
int alevel, errors = 0; |
1883 |
|
|
char *ml = parv[0], c; |
1884 |
|
|
|
1885 |
|
|
mode_count = 0; |
1886 |
|
|
mode_limit = 0; |
1887 |
|
|
simple_modes_mask = 0; |
1888 |
|
|
|
1889 |
|
|
alevel = get_channel_access(source_p, member); |
1890 |
|
|
|
1891 |
michael |
2939 |
for (; (c = *ml); ++ml) |
1892 |
adx |
30 |
{ |
1893 |
|
|
switch (c) |
1894 |
|
|
{ |
1895 |
|
|
case '+': |
1896 |
|
|
dir = MODE_ADD; |
1897 |
|
|
break; |
1898 |
|
|
case '-': |
1899 |
|
|
dir = MODE_DEL; |
1900 |
|
|
break; |
1901 |
|
|
case '=': |
1902 |
|
|
dir = MODE_QUERY; |
1903 |
|
|
break; |
1904 |
|
|
default: |
1905 |
michael |
2939 |
{ |
1906 |
|
|
struct ChannelMode *tptr = &ModeTable[(unsigned char)c]; |
1907 |
|
|
|
1908 |
|
|
tptr->func(client_p, source_p, chptr, parc, &parn, |
1909 |
|
|
parv, &errors, alevel, dir, c, tptr->d); |
1910 |
adx |
30 |
break; |
1911 |
michael |
2939 |
} |
1912 |
adx |
30 |
} |
1913 |
|
|
} |
1914 |
|
|
|
1915 |
michael |
2937 |
send_mode_changes(client_p, source_p, chptr); |
1916 |
adx |
30 |
} |