]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * charybdis: A slightly useful ircd. | |
3 | * chmode.c: channel mode management | |
4 | * | |
5 | * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center | |
6 | * Copyright (C) 1996-2002 Hybrid Development Team | |
7 | * Copyright (C) 2002-2005 ircd-ratbox development team | |
8 | * Copyright (C) 2005-2006 charybdis development team | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License as published by | |
12 | * the Free Software Foundation; either version 2 of the License, or | |
13 | * (at your option) any later version. | |
14 | * | |
15 | * This program is distributed in the hope that it will be useful, | |
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | * GNU General Public License for more details. | |
19 | * | |
20 | * You should have received a copy of the GNU General Public License | |
21 | * along with this program; if not, write to the Free Software | |
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
23 | * USA | |
24 | * | |
83294285 | 25 | * $Id: chmode.c 3580 2007-11-07 23:45:14Z jilles $ |
212380e3 AC |
26 | */ |
27 | ||
28 | #include "stdinc.h" | |
29 | #include "tools.h" | |
30 | #include "channel.h" | |
31 | #include "client.h" | |
32 | #include "common.h" | |
33 | #include "hash.h" | |
34 | #include "hook.h" | |
35 | #include "irc_string.h" | |
36 | #include "sprintf_irc.h" | |
37 | #include "ircd.h" | |
38 | #include "numeric.h" | |
39 | #include "s_serv.h" /* captab */ | |
40 | #include "s_user.h" | |
41 | #include "send.h" | |
42 | #include "whowas.h" | |
43 | #include "s_conf.h" /* ConfigFileEntry, ConfigChannel */ | |
44 | #include "s_newconf.h" | |
45 | #include "event.h" | |
46 | #include "memory.h" | |
47 | #include "balloc.h" | |
48 | #include "s_log.h" | |
49 | ||
50 | /* bitmasks for error returns, so we send once per call */ | |
51 | #define SM_ERR_NOTS 0x00000001 /* No TS on channel */ | |
52 | #define SM_ERR_NOOPS 0x00000002 /* No chan ops */ | |
53 | #define SM_ERR_UNKNOWN 0x00000004 | |
54 | #define SM_ERR_RPL_C 0x00000008 | |
55 | #define SM_ERR_RPL_B 0x00000010 | |
56 | #define SM_ERR_RPL_E 0x00000020 | |
57 | #define SM_ERR_NOTONCHANNEL 0x00000040 /* Not on channel */ | |
58 | #define SM_ERR_RPL_I 0x00000100 | |
59 | #define SM_ERR_RPL_D 0x00000200 | |
60 | #define SM_ERR_NOPRIVS 0x00000400 | |
61 | #define SM_ERR_RPL_Q 0x00000800 | |
62 | #define SM_ERR_RPL_F 0x00001000 | |
63 | ||
64 | void set_channel_mode(struct Client *, struct Client *, | |
65 | struct Channel *, struct membership *, int, const char **); | |
66 | ||
67 | int add_id(struct Client *source_p, struct Channel *chptr, | |
68 | const char *banid, dlink_list * list, long mode_type); | |
69 | ||
70 | static struct ChModeChange mode_changes[BUFSIZE]; | |
71 | static int mode_count; | |
72 | static int mode_limit; | |
73 | static int mask_pos; | |
74 | ||
75 | int | |
76 | get_channel_access(struct Client *source_p, struct membership *msptr) | |
77 | { | |
78 | if(!MyClient(source_p) || is_chanop(msptr)) | |
79 | return CHFL_CHANOP; | |
80 | ||
81 | return CHFL_PEON; | |
82 | } | |
83 | ||
84 | /* add_id() | |
85 | * | |
86 | * inputs - client, channel, id to add, type | |
87 | * outputs - 0 on failure, 1 on success | |
88 | * side effects - given id is added to the appropriate list | |
89 | */ | |
90 | int | |
91 | add_id(struct Client *source_p, struct Channel *chptr, const char *banid, | |
92 | dlink_list * list, long mode_type) | |
93 | { | |
94 | struct Ban *actualBan; | |
83294285 | 95 | static char who[USERHOST_REPLYLEN]; |
212380e3 AC |
96 | char *realban = LOCAL_COPY(banid); |
97 | dlink_node *ptr; | |
98 | ||
99 | /* dont let local clients overflow the banlist, or set redundant | |
100 | * bans | |
101 | */ | |
102 | if(MyClient(source_p)) | |
103 | { | |
104 | if((dlink_list_length(&chptr->banlist) + dlink_list_length(&chptr->exceptlist) + dlink_list_length(&chptr->invexlist) + dlink_list_length(&chptr->quietlist)) >= (chptr->mode.mode & MODE_EXLIMIT ? ConfigChannel.max_bans_large : ConfigChannel.max_bans)) | |
105 | { | |
106 | sendto_one(source_p, form_str(ERR_BANLISTFULL), | |
107 | me.name, source_p->name, chptr->chname, realban); | |
108 | return 0; | |
109 | } | |
110 | ||
212380e3 AC |
111 | DLINK_FOREACH(ptr, list->head) |
112 | { | |
113 | actualBan = ptr->data; | |
fd488ac1 | 114 | if(mask_match(actualBan->banstr, realban)) |
212380e3 AC |
115 | return 0; |
116 | } | |
117 | } | |
118 | /* dont let remotes set duplicates */ | |
119 | else | |
120 | { | |
121 | DLINK_FOREACH(ptr, list->head) | |
122 | { | |
123 | actualBan = ptr->data; | |
124 | if(!irccmp(actualBan->banstr, realban)) | |
125 | return 0; | |
126 | } | |
127 | } | |
128 | ||
129 | ||
130 | if(IsPerson(source_p)) | |
131 | ircsprintf(who, "%s!%s@%s", source_p->name, source_p->username, source_p->host); | |
132 | else | |
133 | strlcpy(who, source_p->name, sizeof(who)); | |
134 | ||
135 | actualBan = allocate_ban(realban, who); | |
136 | actualBan->when = CurrentTime; | |
137 | ||
138 | dlinkAdd(actualBan, &actualBan->node, list); | |
139 | ||
140 | /* invalidate the can_send() cache */ | |
141 | if(mode_type == CHFL_BAN || mode_type == CHFL_QUIET || mode_type == CHFL_EXCEPTION) | |
142 | chptr->bants++; | |
143 | ||
144 | return 1; | |
145 | } | |
146 | ||
147 | /* del_id() | |
148 | * | |
149 | * inputs - channel, id to remove, type | |
150 | * outputs - 0 on failure, 1 on success | |
151 | * side effects - given id is removed from the appropriate list | |
152 | */ | |
153 | int | |
154 | del_id(struct Channel *chptr, const char *banid, dlink_list * list, long mode_type) | |
155 | { | |
156 | dlink_node *ptr; | |
157 | struct Ban *banptr; | |
158 | ||
159 | if(EmptyString(banid)) | |
160 | return 0; | |
161 | ||
162 | DLINK_FOREACH(ptr, list->head) | |
163 | { | |
164 | banptr = ptr->data; | |
165 | ||
166 | if(irccmp(banid, banptr->banstr) == 0) | |
167 | { | |
168 | dlinkDelete(&banptr->node, list); | |
169 | free_ban(banptr); | |
170 | ||
171 | /* invalidate the can_send() cache */ | |
172 | if(mode_type == CHFL_BAN || mode_type == CHFL_QUIET || mode_type == CHFL_EXCEPTION) | |
173 | chptr->bants++; | |
174 | ||
175 | return 1; | |
176 | } | |
177 | } | |
178 | ||
179 | return 0; | |
180 | } | |
181 | ||
182 | /* check_string() | |
183 | * | |
184 | * input - string to check | |
185 | * output - pointer to 'fixed' string, or "*" if empty | |
186 | * side effects - any white space found becomes \0 | |
187 | */ | |
188 | static char * | |
189 | check_string(char *s) | |
190 | { | |
191 | char *str = s; | |
192 | static char splat[] = "*"; | |
193 | if(!(s && *s)) | |
194 | return splat; | |
195 | ||
196 | for(; *s; ++s) | |
197 | { | |
198 | if(IsSpace(*s)) | |
199 | { | |
200 | *s = '\0'; | |
201 | break; | |
202 | } | |
203 | } | |
204 | return str; | |
205 | } | |
206 | ||
207 | /* pretty_mask() | |
208 | * | |
209 | * inputs - mask to pretty | |
210 | * outputs - better version of the mask | |
211 | * side effects - mask is chopped to limits, and transformed: | |
212 | * x!y@z => x!y@z | |
213 | * y@z => *!y@z | |
214 | * x!y => x!y@* | |
215 | * x => x!*@* | |
216 | * z.d => *!*@z.d | |
217 | */ | |
218 | static char * | |
219 | pretty_mask(const char *idmask) | |
220 | { | |
221 | static char mask_buf[BUFSIZE]; | |
222 | int old_mask_pos; | |
223 | char *nick, *user, *host; | |
224 | char splat[] = "*"; | |
225 | char *t, *at, *ex; | |
226 | char ne = 0, ue = 0, he = 0; /* save values at nick[NICKLEN], et all */ | |
227 | char *mask; | |
228 | ||
229 | mask = LOCAL_COPY(idmask); | |
230 | mask = check_string(mask); | |
231 | collapse(mask); | |
232 | ||
233 | nick = user = host = splat; | |
234 | ||
235 | if((size_t) BUFSIZE - mask_pos < strlen(mask) + 5) | |
236 | return NULL; | |
237 | ||
238 | old_mask_pos = mask_pos; | |
239 | ||
240 | if (*mask == '$') | |
241 | { | |
242 | mask_pos += ircsprintf(mask_buf + mask_pos, "%s", mask) + 1; | |
243 | t = mask_buf + old_mask_pos + 1; | |
244 | if (*t == '!') | |
245 | *t = '~'; | |
246 | if (*t == '~') | |
247 | t++; | |
248 | *t = ToLower(*t); | |
249 | return mask_buf + old_mask_pos; | |
250 | } | |
251 | ||
252 | at = ex = NULL; | |
253 | if((t = strchr(mask, '@')) != NULL) | |
254 | { | |
255 | at = t; | |
256 | *t++ = '\0'; | |
257 | if(*t != '\0') | |
258 | host = t; | |
259 | ||
260 | if((t = strchr(mask, '!')) != NULL) | |
261 | { | |
262 | ex = t; | |
263 | *t++ = '\0'; | |
264 | if(*t != '\0') | |
265 | user = t; | |
266 | if(*mask != '\0') | |
267 | nick = mask; | |
268 | } | |
269 | else | |
270 | { | |
271 | if(*mask != '\0') | |
272 | user = mask; | |
273 | } | |
274 | } | |
275 | else if((t = strchr(mask, '!')) != NULL) | |
276 | { | |
277 | ex = t; | |
278 | *t++ = '\0'; | |
279 | if(*mask != '\0') | |
280 | nick = mask; | |
281 | if(*t != '\0') | |
282 | user = t; | |
283 | } | |
284 | else if(strchr(mask, '.') != NULL || strchr(mask, ':') != NULL) | |
285 | { | |
286 | if(*mask != '\0') | |
287 | host = mask; | |
288 | } | |
289 | else | |
290 | { | |
291 | if(*mask != '\0') | |
292 | nick = mask; | |
293 | } | |
294 | ||
295 | /* truncate values to max lengths */ | |
296 | if(strlen(nick) > NICKLEN - 1) | |
297 | { | |
298 | ne = nick[NICKLEN - 1]; | |
299 | nick[NICKLEN - 1] = '\0'; | |
300 | } | |
301 | if(strlen(user) > USERLEN) | |
302 | { | |
303 | ue = user[USERLEN]; | |
304 | user[USERLEN] = '\0'; | |
305 | } | |
306 | if(strlen(host) > HOSTLEN) | |
307 | { | |
308 | he = host[HOSTLEN]; | |
309 | host[HOSTLEN] = '\0'; | |
310 | } | |
311 | ||
312 | mask_pos += ircsprintf(mask_buf + mask_pos, "%s!%s@%s", nick, user, host) + 1; | |
313 | ||
314 | /* restore mask, since we may need to use it again later */ | |
315 | if(at) | |
316 | *at = '@'; | |
317 | if(ex) | |
318 | *ex = '!'; | |
319 | if(ne) | |
320 | nick[NICKLEN - 1] = ne; | |
321 | if(ue) | |
322 | user[USERLEN] = ue; | |
323 | if(he) | |
324 | host[HOSTLEN] = he; | |
325 | ||
326 | return mask_buf + old_mask_pos; | |
327 | } | |
328 | ||
329 | /* fix_key() | |
330 | * | |
331 | * input - key to fix | |
332 | * output - the same key, fixed | |
333 | * side effects - anything below ascii 13 is discarded, ':' discarded, | |
334 | * high ascii is dropped to lower half of ascii table | |
335 | */ | |
336 | static char * | |
337 | fix_key(char *arg) | |
338 | { | |
339 | u_char *s, *t, c; | |
340 | ||
341 | for(s = t = (u_char *) arg; (c = *s); s++) | |
342 | { | |
343 | c &= 0x7f; | |
344 | if(c != ':' && c != ',' && c > ' ') | |
345 | *t++ = c; | |
346 | } | |
347 | ||
348 | *t = '\0'; | |
349 | return arg; | |
350 | } | |
351 | ||
352 | /* fix_key_remote() | |
353 | * | |
354 | * input - key to fix | |
355 | * ouput - the same key, fixed | |
356 | * side effects - high ascii dropped to lower half of table, | |
357 | * CR/LF/':' are dropped | |
358 | */ | |
359 | static char * | |
360 | fix_key_remote(char *arg) | |
361 | { | |
362 | u_char *s, *t, c; | |
363 | ||
364 | for(s = t = (u_char *) arg; (c = *s); s++) | |
365 | { | |
366 | c &= 0x7f; | |
367 | if((c != 0x0a) && (c != ':') && (c != ',') && (c != 0x0d) && (c != ' ')) | |
368 | *t++ = c; | |
369 | } | |
370 | ||
371 | *t = '\0'; | |
372 | return arg; | |
373 | } | |
374 | ||
375 | /* chm_*() | |
376 | * | |
377 | * The handlers for each specific mode. | |
378 | */ | |
379 | void | |
380 | chm_nosuch(struct Client *source_p, struct Channel *chptr, | |
381 | int alevel, int parc, int *parn, | |
382 | const char **parv, int *errors, int dir, char c, long mode_type) | |
383 | { | |
384 | if(*errors & SM_ERR_UNKNOWN) | |
385 | return; | |
386 | *errors |= SM_ERR_UNKNOWN; | |
387 | sendto_one(source_p, form_str(ERR_UNKNOWNMODE), me.name, source_p->name, c); | |
388 | } | |
389 | ||
390 | void | |
391 | chm_simple(struct Client *source_p, struct Channel *chptr, | |
392 | int alevel, int parc, int *parn, | |
393 | const char **parv, int *errors, int dir, char c, long mode_type) | |
394 | { | |
395 | if(alevel != CHFL_CHANOP) | |
396 | { | |
397 | if(!(*errors & SM_ERR_NOOPS)) | |
398 | sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), | |
399 | me.name, source_p->name, chptr->chname); | |
400 | *errors |= SM_ERR_NOOPS; | |
401 | return; | |
402 | } | |
403 | ||
404 | /* +ntspmaikl == 9 + MAXMODEPARAMS (4 * +o) */ | |
405 | if(MyClient(source_p) && (++mode_limit > (9 + MAXMODEPARAMS))) | |
406 | return; | |
407 | ||
408 | /* setting + */ | |
409 | if((dir == MODE_ADD) && !(chptr->mode.mode & mode_type)) | |
410 | { | |
411 | /* if +f is disabled, ignore an attempt to set +QF locally */ | |
412 | if(!ConfigChannel.use_forward && MyClient(source_p) && | |
413 | (c == 'Q' || c == 'F')) | |
414 | return; | |
415 | ||
416 | chptr->mode.mode |= mode_type; | |
417 | ||
418 | mode_changes[mode_count].letter = c; | |
419 | mode_changes[mode_count].dir = MODE_ADD; | |
420 | mode_changes[mode_count].caps = 0; | |
421 | mode_changes[mode_count].nocaps = 0; | |
422 | mode_changes[mode_count].id = NULL; | |
423 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
424 | mode_changes[mode_count++].arg = NULL; | |
425 | } | |
426 | else if((dir == MODE_DEL) && (chptr->mode.mode & mode_type)) | |
427 | { | |
428 | chptr->mode.mode &= ~mode_type; | |
429 | ||
430 | mode_changes[mode_count].letter = c; | |
431 | mode_changes[mode_count].dir = MODE_DEL; | |
432 | mode_changes[mode_count].caps = 0; | |
433 | mode_changes[mode_count].nocaps = 0; | |
434 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
435 | mode_changes[mode_count].id = NULL; | |
436 | mode_changes[mode_count++].arg = NULL; | |
437 | } | |
438 | } | |
439 | ||
440 | void | |
441 | chm_staff(struct Client *source_p, struct Channel *chptr, | |
442 | int alevel, int parc, int *parn, | |
443 | const char **parv, int *errors, int dir, char c, long mode_type) | |
444 | { | |
445 | if(!IsOper(source_p) && !IsServer(source_p)) | |
446 | { | |
447 | if(!(*errors & SM_ERR_NOPRIVS)) | |
448 | sendto_one_numeric(source_p, ERR_NOPRIVILEGES, form_str(ERR_NOPRIVILEGES)); | |
449 | *errors |= SM_ERR_NOPRIVS; | |
450 | return; | |
451 | } | |
1ef5b430 JT |
452 | if(MyClient(source_p) && !IsOperResv(source_p)) |
453 | { | |
454 | if(!(*errors & SM_ERR_NOPRIVS)) | |
455 | sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, | |
456 | source_p->name, "resv"); | |
457 | *errors |= SM_ERR_NOPRIVS; | |
458 | return; | |
459 | } | |
212380e3 AC |
460 | |
461 | /* setting + */ | |
462 | if((dir == MODE_ADD) && !(chptr->mode.mode & mode_type)) | |
463 | { | |
464 | chptr->mode.mode |= mode_type; | |
465 | ||
466 | mode_changes[mode_count].letter = c; | |
467 | mode_changes[mode_count].dir = MODE_ADD; | |
468 | mode_changes[mode_count].caps = 0; | |
469 | mode_changes[mode_count].nocaps = 0; | |
470 | mode_changes[mode_count].id = NULL; | |
471 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
472 | mode_changes[mode_count++].arg = NULL; | |
473 | } | |
474 | else if((dir == MODE_DEL) && (chptr->mode.mode & mode_type)) | |
475 | { | |
476 | chptr->mode.mode &= ~mode_type; | |
477 | ||
478 | mode_changes[mode_count].letter = c; | |
479 | mode_changes[mode_count].dir = MODE_DEL; | |
480 | mode_changes[mode_count].caps = 0; | |
481 | mode_changes[mode_count].nocaps = 0; | |
482 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
483 | mode_changes[mode_count].id = NULL; | |
484 | mode_changes[mode_count++].arg = NULL; | |
485 | } | |
486 | } | |
487 | ||
488 | void | |
489 | chm_ban(struct Client *source_p, struct Channel *chptr, | |
490 | int alevel, int parc, int *parn, | |
491 | const char **parv, int *errors, int dir, char c, long mode_type) | |
492 | { | |
493 | const char *mask; | |
494 | const char *raw_mask; | |
495 | dlink_list *list; | |
496 | dlink_node *ptr; | |
497 | struct Ban *banptr; | |
498 | int errorval; | |
499 | int rpl_list; | |
500 | int rpl_endlist; | |
501 | int caps; | |
502 | int mems; | |
503 | ||
504 | switch (mode_type) | |
505 | { | |
506 | case CHFL_BAN: | |
507 | list = &chptr->banlist; | |
508 | errorval = SM_ERR_RPL_B; | |
509 | rpl_list = RPL_BANLIST; | |
510 | rpl_endlist = RPL_ENDOFBANLIST; | |
511 | mems = ALL_MEMBERS; | |
512 | caps = 0; | |
513 | break; | |
514 | ||
515 | case CHFL_EXCEPTION: | |
516 | /* if +e is disabled, allow all but +e locally */ | |
517 | if(!ConfigChannel.use_except && MyClient(source_p) && | |
518 | ((dir == MODE_ADD) && (parc > *parn))) | |
519 | return; | |
520 | ||
521 | list = &chptr->exceptlist; | |
522 | errorval = SM_ERR_RPL_E; | |
523 | rpl_list = RPL_EXCEPTLIST; | |
524 | rpl_endlist = RPL_ENDOFEXCEPTLIST; | |
525 | caps = CAP_EX; | |
526 | ||
527 | if(ConfigChannel.use_except || (dir == MODE_DEL)) | |
528 | mems = ONLY_CHANOPS; | |
529 | else | |
530 | mems = ONLY_SERVERS; | |
531 | break; | |
532 | ||
533 | case CHFL_INVEX: | |
534 | /* if +I is disabled, allow all but +I locally */ | |
535 | if(!ConfigChannel.use_invex && MyClient(source_p) && | |
536 | (dir == MODE_ADD) && (parc > *parn)) | |
537 | return; | |
538 | ||
539 | list = &chptr->invexlist; | |
540 | errorval = SM_ERR_RPL_I; | |
541 | rpl_list = RPL_INVITELIST; | |
542 | rpl_endlist = RPL_ENDOFINVITELIST; | |
543 | caps = CAP_IE; | |
544 | ||
545 | if(ConfigChannel.use_invex || (dir == MODE_DEL)) | |
546 | mems = ONLY_CHANOPS; | |
547 | else | |
548 | mems = ONLY_SERVERS; | |
549 | break; | |
550 | ||
551 | case CHFL_QUIET: | |
552 | list = &chptr->quietlist; | |
553 | errorval = SM_ERR_RPL_Q; | |
554 | rpl_list = RPL_BANLIST; | |
555 | rpl_endlist = RPL_ENDOFBANLIST; | |
556 | mems = ALL_MEMBERS; | |
557 | caps = 0; | |
558 | break; | |
559 | ||
560 | default: | |
561 | sendto_realops_snomask(SNO_GENERAL, L_ALL, "chm_ban() called with unknown type!"); | |
562 | return; | |
563 | break; | |
564 | } | |
565 | ||
566 | if(dir == 0 || parc <= *parn) | |
567 | { | |
568 | if((*errors & errorval) != 0) | |
569 | return; | |
570 | *errors |= errorval; | |
571 | ||
572 | /* non-ops cant see +eI lists.. */ | |
573 | if(alevel != CHFL_CHANOP && mode_type != CHFL_BAN && | |
574 | mode_type != CHFL_QUIET) | |
575 | { | |
576 | if(!(*errors & SM_ERR_NOOPS)) | |
577 | sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), | |
578 | me.name, source_p->name, chptr->chname); | |
579 | *errors |= SM_ERR_NOOPS; | |
580 | return; | |
581 | } | |
582 | ||
583 | DLINK_FOREACH(ptr, list->head) | |
584 | { | |
585 | banptr = ptr->data; | |
586 | sendto_one(source_p, form_str(rpl_list), | |
587 | me.name, source_p->name, chptr->chname, | |
588 | banptr->banstr, banptr->who, banptr->when); | |
589 | } | |
11781253 JT |
590 | if (mode_type == CHFL_QUIET) |
591 | sendto_one(source_p, ":%s %d %s %s :End of Channel Quiet List", me.name, rpl_endlist, source_p->name, chptr->chname); | |
592 | else | |
593 | sendto_one(source_p, form_str(rpl_endlist), me.name, source_p->name, chptr->chname); | |
212380e3 AC |
594 | return; |
595 | } | |
596 | ||
597 | if(alevel != CHFL_CHANOP) | |
598 | { | |
599 | if(!(*errors & SM_ERR_NOOPS)) | |
600 | sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), | |
601 | me.name, source_p->name, chptr->chname); | |
602 | *errors |= SM_ERR_NOOPS; | |
603 | return; | |
604 | } | |
605 | ||
606 | if(MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) | |
607 | return; | |
608 | ||
609 | raw_mask = parv[(*parn)]; | |
610 | (*parn)++; | |
611 | ||
612 | /* empty ban, or starts with ':' which messes up s2s, ignore it */ | |
613 | if(EmptyString(raw_mask) || *raw_mask == ':') | |
614 | return; | |
615 | ||
616 | if(!MyClient(source_p)) | |
617 | { | |
618 | if(strchr(raw_mask, ' ')) | |
619 | return; | |
620 | ||
621 | mask = raw_mask; | |
622 | } | |
623 | else | |
624 | mask = pretty_mask(raw_mask); | |
625 | ||
83294285 JT |
626 | /* we'd have problems parsing this, hyb6 does it too |
627 | * also make sure it will always fit on a line with channel | |
628 | * name etc. | |
629 | */ | |
630 | if(strlen(mask) > IRCD_MIN(BANLEN, MODEBUFLEN - 5)) | |
212380e3 AC |
631 | return; |
632 | ||
633 | /* if we're adding a NEW id */ | |
634 | if(dir == MODE_ADD) | |
635 | { | |
636 | if (*mask == '$' && MyClient(source_p)) | |
637 | { | |
638 | if (!valid_extban(mask, source_p, chptr, mode_type)) | |
639 | /* XXX perhaps return an error message here */ | |
640 | return; | |
641 | } | |
642 | ||
643 | /* dont allow local clients to overflow the banlist, dont | |
644 | * let remote servers set duplicate bans | |
645 | */ | |
646 | if(!add_id(source_p, chptr, mask, list, mode_type)) | |
647 | return; | |
648 | ||
649 | mode_changes[mode_count].letter = c; | |
650 | mode_changes[mode_count].dir = MODE_ADD; | |
651 | mode_changes[mode_count].caps = caps; | |
652 | mode_changes[mode_count].nocaps = 0; | |
653 | mode_changes[mode_count].mems = mems; | |
654 | mode_changes[mode_count].id = NULL; | |
655 | mode_changes[mode_count++].arg = mask; | |
656 | } | |
657 | else if(dir == MODE_DEL) | |
658 | { | |
659 | if(del_id(chptr, mask, list, mode_type) == 0) | |
660 | { | |
661 | /* mask isn't a valid ban, check raw_mask */ | |
662 | if(del_id(chptr, raw_mask, list, mode_type)) | |
663 | mask = raw_mask; | |
664 | } | |
665 | ||
666 | mode_changes[mode_count].letter = c; | |
667 | mode_changes[mode_count].dir = MODE_DEL; | |
668 | mode_changes[mode_count].caps = caps; | |
669 | mode_changes[mode_count].nocaps = 0; | |
670 | mode_changes[mode_count].mems = mems; | |
671 | mode_changes[mode_count].id = NULL; | |
672 | mode_changes[mode_count++].arg = mask; | |
673 | } | |
674 | } | |
675 | ||
676 | void | |
677 | chm_op(struct Client *source_p, struct Channel *chptr, | |
678 | int alevel, int parc, int *parn, | |
679 | const char **parv, int *errors, int dir, char c, long mode_type) | |
680 | { | |
681 | struct membership *mstptr; | |
682 | const char *opnick; | |
683 | struct Client *targ_p; | |
684 | ||
685 | if(alevel != CHFL_CHANOP) | |
686 | { | |
687 | if(!(*errors & SM_ERR_NOOPS)) | |
688 | sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), | |
689 | me.name, source_p->name, chptr->chname); | |
690 | *errors |= SM_ERR_NOOPS; | |
691 | return; | |
692 | } | |
693 | ||
694 | if((dir == MODE_QUERY) || (parc <= *parn)) | |
695 | return; | |
696 | ||
697 | opnick = parv[(*parn)]; | |
698 | (*parn)++; | |
699 | ||
700 | /* empty nick */ | |
701 | if(EmptyString(opnick)) | |
702 | { | |
703 | sendto_one_numeric(source_p, ERR_NOSUCHNICK, form_str(ERR_NOSUCHNICK), "*"); | |
704 | return; | |
705 | } | |
706 | ||
707 | if((targ_p = find_chasing(source_p, opnick, NULL)) == NULL) | |
708 | { | |
709 | return; | |
710 | } | |
711 | ||
712 | mstptr = find_channel_membership(chptr, targ_p); | |
713 | ||
714 | if(mstptr == NULL) | |
715 | { | |
716 | if(!(*errors & SM_ERR_NOTONCHANNEL) && MyClient(source_p)) | |
717 | sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL, | |
718 | form_str(ERR_USERNOTINCHANNEL), opnick, chptr->chname); | |
719 | *errors |= SM_ERR_NOTONCHANNEL; | |
720 | return; | |
721 | } | |
722 | ||
723 | if(MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) | |
724 | return; | |
725 | ||
726 | if(dir == MODE_ADD) | |
727 | { | |
728 | if(targ_p == source_p) | |
729 | return; | |
730 | ||
731 | mode_changes[mode_count].letter = c; | |
732 | mode_changes[mode_count].dir = MODE_ADD; | |
733 | mode_changes[mode_count].caps = 0; | |
734 | mode_changes[mode_count].nocaps = 0; | |
735 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
736 | mode_changes[mode_count].id = targ_p->id; | |
737 | mode_changes[mode_count].arg = targ_p->name; | |
738 | mode_changes[mode_count++].client = targ_p; | |
739 | ||
740 | mstptr->flags |= CHFL_CHANOP; | |
212380e3 AC |
741 | } |
742 | else | |
743 | { | |
744 | if(MyClient(source_p) && IsService(targ_p)) | |
745 | { | |
746 | sendto_one(source_p, form_str(ERR_ISCHANSERVICE), | |
747 | me.name, source_p->name, targ_p->name, chptr->chname); | |
748 | return; | |
749 | } | |
750 | ||
751 | mode_changes[mode_count].letter = c; | |
752 | mode_changes[mode_count].dir = MODE_DEL; | |
753 | mode_changes[mode_count].caps = 0; | |
754 | mode_changes[mode_count].nocaps = 0; | |
755 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
756 | mode_changes[mode_count].id = targ_p->id; | |
757 | mode_changes[mode_count].arg = targ_p->name; | |
758 | mode_changes[mode_count++].client = targ_p; | |
759 | ||
760 | mstptr->flags &= ~CHFL_CHANOP; | |
761 | } | |
762 | } | |
763 | ||
764 | void | |
765 | chm_voice(struct Client *source_p, struct Channel *chptr, | |
766 | int alevel, int parc, int *parn, | |
767 | const char **parv, int *errors, int dir, char c, long mode_type) | |
768 | { | |
769 | struct membership *mstptr; | |
770 | const char *opnick; | |
771 | struct Client *targ_p; | |
772 | ||
773 | if(alevel != CHFL_CHANOP) | |
774 | { | |
775 | if(!(*errors & SM_ERR_NOOPS)) | |
776 | sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), | |
777 | me.name, source_p->name, chptr->chname); | |
778 | *errors |= SM_ERR_NOOPS; | |
779 | return; | |
780 | } | |
781 | ||
782 | if((dir == MODE_QUERY) || parc <= *parn) | |
783 | return; | |
784 | ||
785 | opnick = parv[(*parn)]; | |
786 | (*parn)++; | |
787 | ||
788 | /* empty nick */ | |
789 | if(EmptyString(opnick)) | |
790 | { | |
791 | sendto_one_numeric(source_p, ERR_NOSUCHNICK, form_str(ERR_NOSUCHNICK), "*"); | |
792 | return; | |
793 | } | |
794 | ||
795 | if((targ_p = find_chasing(source_p, opnick, NULL)) == NULL) | |
796 | { | |
797 | return; | |
798 | } | |
799 | ||
800 | mstptr = find_channel_membership(chptr, targ_p); | |
801 | ||
802 | if(mstptr == NULL) | |
803 | { | |
804 | if(!(*errors & SM_ERR_NOTONCHANNEL) && MyClient(source_p)) | |
805 | sendto_one_numeric(source_p, ERR_USERNOTINCHANNEL, | |
806 | form_str(ERR_USERNOTINCHANNEL), opnick, chptr->chname); | |
807 | *errors |= SM_ERR_NOTONCHANNEL; | |
808 | return; | |
809 | } | |
810 | ||
811 | if(MyClient(source_p) && (++mode_limit > MAXMODEPARAMS)) | |
812 | return; | |
813 | ||
814 | if(dir == MODE_ADD) | |
815 | { | |
816 | mode_changes[mode_count].letter = c; | |
817 | mode_changes[mode_count].dir = MODE_ADD; | |
818 | mode_changes[mode_count].caps = 0; | |
819 | mode_changes[mode_count].nocaps = 0; | |
820 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
821 | mode_changes[mode_count].id = targ_p->id; | |
822 | mode_changes[mode_count].arg = targ_p->name; | |
823 | mode_changes[mode_count++].client = targ_p; | |
824 | ||
825 | mstptr->flags |= CHFL_VOICE; | |
826 | } | |
827 | else | |
828 | { | |
829 | mode_changes[mode_count].letter = 'v'; | |
830 | mode_changes[mode_count].dir = MODE_DEL; | |
831 | mode_changes[mode_count].caps = 0; | |
832 | mode_changes[mode_count].nocaps = 0; | |
833 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
834 | mode_changes[mode_count].id = targ_p->id; | |
835 | mode_changes[mode_count].arg = targ_p->name; | |
836 | mode_changes[mode_count++].client = targ_p; | |
837 | ||
838 | mstptr->flags &= ~CHFL_VOICE; | |
839 | } | |
840 | } | |
841 | ||
842 | void | |
843 | chm_limit(struct Client *source_p, struct Channel *chptr, | |
844 | int alevel, int parc, int *parn, | |
845 | const char **parv, int *errors, int dir, char c, long mode_type) | |
846 | { | |
847 | const char *lstr; | |
848 | static char limitstr[30]; | |
849 | int limit; | |
850 | ||
851 | if(alevel != CHFL_CHANOP) | |
852 | { | |
853 | if(!(*errors & SM_ERR_NOOPS)) | |
854 | sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), | |
855 | me.name, source_p->name, chptr->chname); | |
856 | *errors |= SM_ERR_NOOPS; | |
857 | return; | |
858 | } | |
859 | ||
860 | if(dir == MODE_QUERY) | |
861 | return; | |
862 | ||
863 | if((dir == MODE_ADD) && parc > *parn) | |
864 | { | |
865 | lstr = parv[(*parn)]; | |
866 | (*parn)++; | |
867 | ||
868 | if(EmptyString(lstr) || (limit = atoi(lstr)) <= 0) | |
869 | return; | |
870 | ||
871 | ircsprintf(limitstr, "%d", limit); | |
872 | ||
873 | mode_changes[mode_count].letter = c; | |
874 | mode_changes[mode_count].dir = MODE_ADD; | |
875 | mode_changes[mode_count].caps = 0; | |
876 | mode_changes[mode_count].nocaps = 0; | |
877 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
878 | mode_changes[mode_count].id = NULL; | |
879 | mode_changes[mode_count++].arg = limitstr; | |
880 | ||
881 | chptr->mode.limit = limit; | |
882 | } | |
883 | else if(dir == MODE_DEL) | |
884 | { | |
885 | if(!chptr->mode.limit) | |
886 | return; | |
887 | ||
888 | chptr->mode.limit = 0; | |
889 | ||
890 | mode_changes[mode_count].letter = c; | |
891 | mode_changes[mode_count].dir = MODE_DEL; | |
892 | mode_changes[mode_count].caps = 0; | |
893 | mode_changes[mode_count].nocaps = 0; | |
894 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
895 | mode_changes[mode_count].id = NULL; | |
896 | mode_changes[mode_count++].arg = NULL; | |
897 | } | |
898 | } | |
899 | ||
900 | void | |
901 | chm_throttle(struct Client *source_p, struct Channel *chptr, | |
902 | int alevel, int parc, int *parn, | |
903 | const char **parv, int *errors, int dir, char c, long mode_type) | |
904 | { | |
905 | int joins = 0, timeslice = 0; | |
906 | ||
907 | if(alevel != CHFL_CHANOP) | |
908 | { | |
909 | if(!(*errors & SM_ERR_NOOPS)) | |
910 | sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), | |
911 | me.name, source_p->name, chptr->chname); | |
912 | *errors |= SM_ERR_NOOPS; | |
913 | return; | |
914 | } | |
915 | ||
916 | if(dir == MODE_QUERY) | |
917 | return; | |
918 | ||
919 | if((dir == MODE_ADD) && parc > *parn) | |
920 | { | |
921 | sscanf(parv[(*parn)], "%d:%d", &joins, ×lice); | |
922 | ||
923 | if(!joins || !timeslice) | |
924 | return; | |
925 | ||
926 | mode_changes[mode_count].letter = c; | |
927 | mode_changes[mode_count].dir = MODE_ADD; | |
928 | mode_changes[mode_count].caps = 0; | |
929 | mode_changes[mode_count].nocaps = 0; | |
930 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
931 | mode_changes[mode_count].id = NULL; | |
932 | mode_changes[mode_count++].arg = parv[(*parn)]; | |
933 | ||
934 | (*parn)++; | |
935 | ||
936 | chptr->mode.join_num = joins; | |
937 | chptr->mode.join_time = timeslice; | |
938 | } | |
939 | else if(dir == MODE_DEL) | |
940 | { | |
941 | if(!chptr->mode.join_num) | |
942 | return; | |
943 | ||
944 | chptr->mode.join_num = 0; | |
945 | chptr->mode.join_time = 0; | |
946 | chptr->join_count = 0; | |
947 | chptr->join_delta = 0; | |
948 | ||
949 | mode_changes[mode_count].letter = c; | |
950 | mode_changes[mode_count].dir = MODE_DEL; | |
951 | mode_changes[mode_count].caps = 0; | |
952 | mode_changes[mode_count].nocaps = 0; | |
953 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
954 | mode_changes[mode_count].id = NULL; | |
955 | mode_changes[mode_count++].arg = NULL; | |
956 | } | |
957 | } | |
958 | ||
959 | void | |
960 | chm_forward(struct Client *source_p, struct Channel *chptr, | |
961 | int alevel, int parc, int *parn, | |
962 | const char **parv, int *errors, int dir, char c, long mode_type) | |
963 | { | |
964 | struct Channel *targptr = NULL; | |
965 | struct membership *msptr; | |
966 | const char *forward; | |
967 | ||
968 | /* if +f is disabled, ignore local attempts to set it */ | |
969 | if(!ConfigChannel.use_forward && MyClient(source_p) && | |
970 | (dir == MODE_ADD) && (parc > *parn)) | |
971 | return; | |
972 | ||
973 | if(dir == MODE_QUERY || (dir == MODE_ADD && parc <= *parn)) | |
974 | { | |
975 | if (!(*errors & SM_ERR_RPL_F)) | |
976 | { | |
977 | if (*chptr->mode.forward == '\0') | |
5366977b | 978 | sendto_one_notice(source_p, ":%s has no forward channel", chptr->chname); |
212380e3 | 979 | else |
5366977b | 980 | sendto_one_notice(source_p, ":%s forward channel is %s", chptr->chname, chptr->mode.forward); |
212380e3 AC |
981 | *errors |= SM_ERR_RPL_F; |
982 | } | |
983 | return; | |
984 | } | |
985 | ||
986 | #ifndef FORWARD_OPERONLY | |
987 | if(alevel != CHFL_CHANOP) | |
988 | { | |
989 | if(!(*errors & SM_ERR_NOOPS)) | |
990 | sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), | |
991 | me.name, source_p->name, chptr->chname); | |
992 | *errors |= SM_ERR_NOOPS; | |
993 | return; | |
994 | } | |
995 | #else | |
996 | if(!IsOper(source_p) && !IsServer(source_p)) | |
997 | { | |
998 | if(!(*errors & SM_ERR_NOPRIVS)) | |
999 | sendto_one_numeric(source_p, ERR_NOPRIVILEGES, form_str(ERR_NOPRIVILEGES)); | |
1000 | *errors |= SM_ERR_NOPRIVS; | |
1001 | return; | |
1002 | } | |
1003 | #endif | |
1004 | ||
1005 | if(dir == MODE_ADD && parc > *parn) | |
1006 | { | |
1007 | forward = parv[(*parn)]; | |
1008 | (*parn)++; | |
1009 | ||
1010 | if(EmptyString(forward)) | |
1011 | return; | |
1012 | if(!check_channel_name(forward) || | |
1013 | (MyClient(source_p) && (strlen(forward) > LOC_CHANNELLEN || hash_find_resv(forward)))) | |
1014 | { | |
1015 | sendto_one_numeric(source_p, ERR_BADCHANNAME, form_str(ERR_BADCHANNAME), forward); | |
1016 | return; | |
1017 | } | |
1018 | /* don't forward to inconsistent target -- jilles */ | |
1019 | if(chptr->chname[0] == '#' && forward[0] == '&') | |
1020 | { | |
1021 | sendto_one_numeric(source_p, ERR_BADCHANNAME, | |
1022 | form_str(ERR_BADCHANNAME), forward); | |
1023 | return; | |
1024 | } | |
1025 | if(MyClient(source_p) && (targptr = find_channel(forward)) == NULL) | |
1026 | { | |
1027 | sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, | |
1028 | form_str(ERR_NOSUCHCHANNEL), forward); | |
1029 | return; | |
1030 | } | |
1031 | if(MyClient(source_p) && !(targptr->mode.mode & MODE_FREETARGET)) | |
1032 | { | |
1033 | if((msptr = find_channel_membership(targptr, source_p)) == NULL || | |
1034 | get_channel_access(source_p, msptr) != CHFL_CHANOP) | |
1035 | { | |
1036 | sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), | |
1037 | me.name, source_p->name, targptr->chname); | |
1038 | return; | |
1039 | } | |
1040 | } | |
1041 | ||
1042 | strlcpy(chptr->mode.forward, forward, sizeof(chptr->mode.forward)); | |
1043 | ||
1044 | mode_changes[mode_count].letter = c; | |
1045 | mode_changes[mode_count].dir = MODE_ADD; | |
1046 | mode_changes[mode_count].caps = 0; | |
1047 | mode_changes[mode_count].nocaps = 0; | |
1048 | mode_changes[mode_count].mems = ConfigChannel.use_forward ? ALL_MEMBERS : ONLY_SERVERS; | |
1049 | mode_changes[mode_count].id = NULL; | |
1050 | mode_changes[mode_count++].arg = forward; | |
1051 | } | |
1052 | else if(dir == MODE_DEL) | |
1053 | { | |
1054 | if(!(*chptr->mode.forward)) | |
1055 | return; | |
1056 | ||
1057 | *chptr->mode.forward = '\0'; | |
1058 | ||
1059 | mode_changes[mode_count].letter = c; | |
1060 | mode_changes[mode_count].dir = MODE_DEL; | |
1061 | mode_changes[mode_count].caps = 0; | |
1062 | mode_changes[mode_count].nocaps = 0; | |
1063 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
1064 | mode_changes[mode_count].id = NULL; | |
1065 | mode_changes[mode_count++].arg = NULL; | |
1066 | } | |
1067 | } | |
1068 | ||
1069 | void | |
1070 | chm_key(struct Client *source_p, struct Channel *chptr, | |
1071 | int alevel, int parc, int *parn, | |
1072 | const char **parv, int *errors, int dir, char c, long mode_type) | |
1073 | { | |
1074 | char *key; | |
1075 | ||
1076 | if(alevel != CHFL_CHANOP) | |
1077 | { | |
1078 | if(!(*errors & SM_ERR_NOOPS)) | |
1079 | sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), | |
1080 | me.name, source_p->name, chptr->chname); | |
1081 | *errors |= SM_ERR_NOOPS; | |
1082 | return; | |
1083 | } | |
1084 | ||
1085 | if(dir == MODE_QUERY) | |
1086 | return; | |
1087 | ||
1088 | if((dir == MODE_ADD) && parc > *parn) | |
1089 | { | |
1090 | key = LOCAL_COPY(parv[(*parn)]); | |
1091 | (*parn)++; | |
1092 | ||
1093 | if(MyClient(source_p)) | |
1094 | fix_key(key); | |
1095 | else | |
1096 | fix_key_remote(key); | |
1097 | ||
1098 | if(EmptyString(key)) | |
1099 | return; | |
1100 | ||
1101 | s_assert(key[0] != ' '); | |
1102 | strlcpy(chptr->mode.key, key, sizeof(chptr->mode.key)); | |
1103 | ||
1104 | mode_changes[mode_count].letter = c; | |
1105 | mode_changes[mode_count].dir = MODE_ADD; | |
1106 | mode_changes[mode_count].caps = 0; | |
1107 | mode_changes[mode_count].nocaps = 0; | |
1108 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
1109 | mode_changes[mode_count].id = NULL; | |
1110 | mode_changes[mode_count++].arg = chptr->mode.key; | |
1111 | } | |
1112 | else if(dir == MODE_DEL) | |
1113 | { | |
1114 | static char splat[] = "*"; | |
1115 | int i; | |
1116 | ||
1117 | if(parc > *parn) | |
1118 | (*parn)++; | |
1119 | ||
1120 | if(!(*chptr->mode.key)) | |
1121 | return; | |
1122 | ||
1123 | /* hack time. when we get a +k-k mode, the +k arg is | |
1124 | * chptr->mode.key, which the -k sets to \0, so hunt for a | |
1125 | * +k when we get a -k, and set the arg to splat. --anfl | |
1126 | */ | |
1127 | for(i = 0; i < mode_count; i++) | |
1128 | { | |
1129 | if(mode_changes[i].letter == 'k' && mode_changes[i].dir == MODE_ADD) | |
1130 | mode_changes[i].arg = splat; | |
1131 | } | |
1132 | ||
1133 | *chptr->mode.key = 0; | |
1134 | ||
1135 | mode_changes[mode_count].letter = c; | |
1136 | mode_changes[mode_count].dir = MODE_DEL; | |
1137 | mode_changes[mode_count].caps = 0; | |
1138 | mode_changes[mode_count].nocaps = 0; | |
1139 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
1140 | mode_changes[mode_count].id = NULL; | |
1141 | mode_changes[mode_count++].arg = "*"; | |
1142 | } | |
1143 | } | |
1144 | ||
1145 | void | |
1146 | chm_regonly(struct Client *source_p, struct Channel *chptr, | |
1147 | int alevel, int parc, int *parn, | |
1148 | const char **parv, int *errors, int dir, char c, long mode_type) | |
1149 | { | |
1150 | if(alevel != CHFL_CHANOP) | |
1151 | { | |
1152 | if(!(*errors & SM_ERR_NOOPS)) | |
1153 | sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED), | |
1154 | me.name, source_p->name, chptr->chname); | |
1155 | *errors |= SM_ERR_NOOPS; | |
1156 | return; | |
1157 | } | |
1158 | ||
1159 | if(dir == MODE_QUERY) | |
1160 | return; | |
1161 | ||
1162 | if(((dir == MODE_ADD) && (chptr->mode.mode & MODE_REGONLY)) || | |
1163 | ((dir == MODE_DEL) && !(chptr->mode.mode & MODE_REGONLY))) | |
1164 | return; | |
1165 | ||
1166 | if(dir == MODE_ADD) | |
1167 | chptr->mode.mode |= MODE_REGONLY; | |
1168 | else | |
1169 | chptr->mode.mode &= ~MODE_REGONLY; | |
1170 | ||
1171 | mode_changes[mode_count].letter = c; | |
1172 | mode_changes[mode_count].dir = dir; | |
1173 | mode_changes[mode_count].caps = CAP_SERVICE; | |
1174 | mode_changes[mode_count].nocaps = 0; | |
1175 | mode_changes[mode_count].mems = ALL_MEMBERS; | |
1176 | mode_changes[mode_count].id = NULL; | |
1177 | mode_changes[mode_count++].arg = NULL; | |
1178 | } | |
1179 | ||
1180 | /* *INDENT-OFF* */ | |
1181 | struct ChannelMode chmode_table[256] = | |
1182 | { | |
1183 | {chm_nosuch, 0 }, /* 0x00 */ | |
1184 | {chm_nosuch, 0 }, /* 0x01 */ | |
1185 | {chm_nosuch, 0 }, /* 0x02 */ | |
1186 | {chm_nosuch, 0 }, /* 0x03 */ | |
1187 | {chm_nosuch, 0 }, /* 0x04 */ | |
1188 | {chm_nosuch, 0 }, /* 0x05 */ | |
1189 | {chm_nosuch, 0 }, /* 0x06 */ | |
1190 | {chm_nosuch, 0 }, /* 0x07 */ | |
1191 | {chm_nosuch, 0 }, /* 0x08 */ | |
1192 | {chm_nosuch, 0 }, /* 0x09 */ | |
1193 | {chm_nosuch, 0 }, /* 0x0a */ | |
1194 | {chm_nosuch, 0 }, /* 0x0b */ | |
1195 | {chm_nosuch, 0 }, /* 0x0c */ | |
1196 | {chm_nosuch, 0 }, /* 0x0d */ | |
1197 | {chm_nosuch, 0 }, /* 0x0e */ | |
1198 | {chm_nosuch, 0 }, /* 0x0f */ | |
1199 | {chm_nosuch, 0 }, /* 0x10 */ | |
1200 | {chm_nosuch, 0 }, /* 0x11 */ | |
1201 | {chm_nosuch, 0 }, /* 0x12 */ | |
1202 | {chm_nosuch, 0 }, /* 0x13 */ | |
1203 | {chm_nosuch, 0 }, /* 0x14 */ | |
1204 | {chm_nosuch, 0 }, /* 0x15 */ | |
1205 | {chm_nosuch, 0 }, /* 0x16 */ | |
1206 | {chm_nosuch, 0 }, /* 0x17 */ | |
1207 | {chm_nosuch, 0 }, /* 0x18 */ | |
1208 | {chm_nosuch, 0 }, /* 0x19 */ | |
1209 | {chm_nosuch, 0 }, /* 0x1a */ | |
1210 | {chm_nosuch, 0 }, /* 0x1b */ | |
1211 | {chm_nosuch, 0 }, /* 0x1c */ | |
1212 | {chm_nosuch, 0 }, /* 0x1d */ | |
1213 | {chm_nosuch, 0 }, /* 0x1e */ | |
1214 | {chm_nosuch, 0 }, /* 0x1f */ | |
1215 | {chm_nosuch, 0 }, /* 0x20 */ | |
1216 | {chm_nosuch, 0 }, /* 0x21 */ | |
1217 | {chm_nosuch, 0 }, /* 0x22 */ | |
1218 | {chm_nosuch, 0 }, /* 0x23 */ | |
1219 | {chm_nosuch, 0 }, /* 0x24 */ | |
1220 | {chm_nosuch, 0 }, /* 0x25 */ | |
1221 | {chm_nosuch, 0 }, /* 0x26 */ | |
1222 | {chm_nosuch, 0 }, /* 0x27 */ | |
1223 | {chm_nosuch, 0 }, /* 0x28 */ | |
1224 | {chm_nosuch, 0 }, /* 0x29 */ | |
1225 | {chm_nosuch, 0 }, /* 0x2a */ | |
1226 | {chm_nosuch, 0 }, /* 0x2b */ | |
1227 | {chm_nosuch, 0 }, /* 0x2c */ | |
1228 | {chm_nosuch, 0 }, /* 0x2d */ | |
1229 | {chm_nosuch, 0 }, /* 0x2e */ | |
1230 | {chm_nosuch, 0 }, /* 0x2f */ | |
1231 | {chm_nosuch, 0 }, /* 0x30 */ | |
1232 | {chm_nosuch, 0 }, /* 0x31 */ | |
1233 | {chm_nosuch, 0 }, /* 0x32 */ | |
1234 | {chm_nosuch, 0 }, /* 0x33 */ | |
1235 | {chm_nosuch, 0 }, /* 0x34 */ | |
1236 | {chm_nosuch, 0 }, /* 0x35 */ | |
1237 | {chm_nosuch, 0 }, /* 0x36 */ | |
1238 | {chm_nosuch, 0 }, /* 0x37 */ | |
1239 | {chm_nosuch, 0 }, /* 0x38 */ | |
1240 | {chm_nosuch, 0 }, /* 0x39 */ | |
1241 | {chm_nosuch, 0 }, /* 0x3a */ | |
1242 | {chm_nosuch, 0 }, /* 0x3b */ | |
1243 | {chm_nosuch, 0 }, /* 0x3c */ | |
1244 | {chm_nosuch, 0 }, /* 0x3d */ | |
1245 | {chm_nosuch, 0 }, /* 0x3e */ | |
1246 | {chm_nosuch, 0 }, /* 0x3f */ | |
1247 | ||
1248 | {chm_nosuch, 0 }, /* @ */ | |
1249 | {chm_nosuch, 0 }, /* A */ | |
1250 | {chm_nosuch, 0 }, /* B */ | |
1251 | {chm_nosuch, 0 }, /* C */ | |
1252 | {chm_nosuch, 0 }, /* D */ | |
1253 | {chm_nosuch, 0 }, /* E */ | |
1254 | {chm_simple, MODE_FREETARGET }, /* F */ | |
1255 | {chm_nosuch, 0 }, /* G */ | |
1256 | {chm_nosuch, 0 }, /* H */ | |
1257 | {chm_ban, CHFL_INVEX }, /* I */ | |
1258 | {chm_nosuch, 0 }, /* J */ | |
1259 | {chm_nosuch, 0 }, /* K */ | |
1260 | {chm_staff, MODE_EXLIMIT }, /* L */ | |
1261 | {chm_nosuch, 0 }, /* M */ | |
1262 | {chm_nosuch, 0 }, /* N */ | |
1263 | {chm_nosuch, 0 }, /* O */ | |
1264 | {chm_staff, MODE_PERMANENT }, /* P */ | |
1265 | {chm_simple, MODE_DISFORWARD }, /* Q */ | |
1266 | {chm_nosuch, 0 }, /* R */ | |
1267 | {chm_nosuch, 0 }, /* S */ | |
1268 | {chm_nosuch, 0 }, /* T */ | |
1269 | {chm_nosuch, 0 }, /* U */ | |
1270 | {chm_nosuch, 0 }, /* V */ | |
1271 | {chm_nosuch, 0 }, /* W */ | |
1272 | {chm_nosuch, 0 }, /* X */ | |
1273 | {chm_nosuch, 0 }, /* Y */ | |
1274 | {chm_nosuch, 0 }, /* Z */ | |
1275 | {chm_nosuch, 0 }, | |
1276 | {chm_nosuch, 0 }, | |
1277 | {chm_nosuch, 0 }, | |
1278 | {chm_nosuch, 0 }, | |
1279 | {chm_nosuch, 0 }, | |
1280 | {chm_nosuch, 0 }, | |
1281 | {chm_nosuch, 0 }, /* a */ | |
1282 | {chm_ban, CHFL_BAN }, /* b */ | |
1283 | {chm_simple, MODE_NOCOLOR }, /* c */ | |
1284 | {chm_nosuch, 0 }, /* d */ | |
1285 | {chm_ban, CHFL_EXCEPTION }, /* e */ | |
1286 | {chm_forward, 0 }, /* f */ | |
1287 | {chm_simple, MODE_FREEINVITE }, /* g */ | |
1288 | {chm_nosuch, 0 }, /* h */ | |
1289 | {chm_simple, MODE_INVITEONLY }, /* i */ | |
1290 | {chm_throttle, 0 }, /* j */ | |
1291 | {chm_key, 0 }, /* k */ | |
1292 | {chm_limit, 0 }, /* l */ | |
1293 | {chm_simple, MODE_MODERATED }, /* m */ | |
1294 | {chm_simple, MODE_NOPRIVMSGS }, /* n */ | |
1295 | {chm_op, 0 }, /* o */ | |
1296 | {chm_simple, MODE_PRIVATE }, /* p */ | |
1297 | {chm_ban, CHFL_QUIET }, /* q */ | |
1298 | {chm_regonly, 0 }, /* r */ | |
1299 | {chm_simple, MODE_SECRET }, /* s */ | |
1300 | {chm_simple, MODE_TOPICLIMIT }, /* t */ | |
1301 | {chm_nosuch, 0 }, /* u */ | |
1302 | {chm_voice, 0 }, /* v */ | |
1303 | {chm_nosuch, 0 }, /* w */ | |
1304 | {chm_nosuch, 0 }, /* x */ | |
1305 | {chm_nosuch, 0 }, /* y */ | |
1306 | {chm_simple, MODE_OPMODERATE }, /* z */ | |
1307 | ||
1308 | {chm_nosuch, 0 }, /* 0x7b */ | |
1309 | {chm_nosuch, 0 }, /* 0x7c */ | |
1310 | {chm_nosuch, 0 }, /* 0x7d */ | |
1311 | {chm_nosuch, 0 }, /* 0x7e */ | |
1312 | {chm_nosuch, 0 }, /* 0x7f */ | |
1313 | ||
1314 | {chm_nosuch, 0 }, /* 0x80 */ | |
1315 | {chm_nosuch, 0 }, /* 0x81 */ | |
1316 | {chm_nosuch, 0 }, /* 0x82 */ | |
1317 | {chm_nosuch, 0 }, /* 0x83 */ | |
1318 | {chm_nosuch, 0 }, /* 0x84 */ | |
1319 | {chm_nosuch, 0 }, /* 0x85 */ | |
1320 | {chm_nosuch, 0 }, /* 0x86 */ | |
1321 | {chm_nosuch, 0 }, /* 0x87 */ | |
1322 | {chm_nosuch, 0 }, /* 0x88 */ | |
1323 | {chm_nosuch, 0 }, /* 0x89 */ | |
1324 | {chm_nosuch, 0 }, /* 0x8a */ | |
1325 | {chm_nosuch, 0 }, /* 0x8b */ | |
1326 | {chm_nosuch, 0 }, /* 0x8c */ | |
1327 | {chm_nosuch, 0 }, /* 0x8d */ | |
1328 | {chm_nosuch, 0 }, /* 0x8e */ | |
1329 | {chm_nosuch, 0 }, /* 0x8f */ | |
1330 | ||
1331 | {chm_nosuch, 0 }, /* 0x90 */ | |
1332 | {chm_nosuch, 0 }, /* 0x91 */ | |
1333 | {chm_nosuch, 0 }, /* 0x92 */ | |
1334 | {chm_nosuch, 0 }, /* 0x93 */ | |
1335 | {chm_nosuch, 0 }, /* 0x94 */ | |
1336 | {chm_nosuch, 0 }, /* 0x95 */ | |
1337 | {chm_nosuch, 0 }, /* 0x96 */ | |
1338 | {chm_nosuch, 0 }, /* 0x97 */ | |
1339 | {chm_nosuch, 0 }, /* 0x98 */ | |
1340 | {chm_nosuch, 0 }, /* 0x99 */ | |
1341 | {chm_nosuch, 0 }, /* 0x9a */ | |
1342 | {chm_nosuch, 0 }, /* 0x9b */ | |
1343 | {chm_nosuch, 0 }, /* 0x9c */ | |
1344 | {chm_nosuch, 0 }, /* 0x9d */ | |
1345 | {chm_nosuch, 0 }, /* 0x9e */ | |
1346 | {chm_nosuch, 0 }, /* 0x9f */ | |
1347 | ||
1348 | {chm_nosuch, 0 }, /* 0xa0 */ | |
1349 | {chm_nosuch, 0 }, /* 0xa1 */ | |
1350 | {chm_nosuch, 0 }, /* 0xa2 */ | |
1351 | {chm_nosuch, 0 }, /* 0xa3 */ | |
1352 | {chm_nosuch, 0 }, /* 0xa4 */ | |
1353 | {chm_nosuch, 0 }, /* 0xa5 */ | |
1354 | {chm_nosuch, 0 }, /* 0xa6 */ | |
1355 | {chm_nosuch, 0 }, /* 0xa7 */ | |
1356 | {chm_nosuch, 0 }, /* 0xa8 */ | |
1357 | {chm_nosuch, 0 }, /* 0xa9 */ | |
1358 | {chm_nosuch, 0 }, /* 0xaa */ | |
1359 | {chm_nosuch, 0 }, /* 0xab */ | |
1360 | {chm_nosuch, 0 }, /* 0xac */ | |
1361 | {chm_nosuch, 0 }, /* 0xad */ | |
1362 | {chm_nosuch, 0 }, /* 0xae */ | |
1363 | {chm_nosuch, 0 }, /* 0xaf */ | |
1364 | ||
1365 | {chm_nosuch, 0 }, /* 0xb0 */ | |
1366 | {chm_nosuch, 0 }, /* 0xb1 */ | |
1367 | {chm_nosuch, 0 }, /* 0xb2 */ | |
1368 | {chm_nosuch, 0 }, /* 0xb3 */ | |
1369 | {chm_nosuch, 0 }, /* 0xb4 */ | |
1370 | {chm_nosuch, 0 }, /* 0xb5 */ | |
1371 | {chm_nosuch, 0 }, /* 0xb6 */ | |
1372 | {chm_nosuch, 0 }, /* 0xb7 */ | |
1373 | {chm_nosuch, 0 }, /* 0xb8 */ | |
1374 | {chm_nosuch, 0 }, /* 0xb9 */ | |
1375 | {chm_nosuch, 0 }, /* 0xba */ | |
1376 | {chm_nosuch, 0 }, /* 0xbb */ | |
1377 | {chm_nosuch, 0 }, /* 0xbc */ | |
1378 | {chm_nosuch, 0 }, /* 0xbd */ | |
1379 | {chm_nosuch, 0 }, /* 0xbe */ | |
1380 | {chm_nosuch, 0 }, /* 0xbf */ | |
1381 | ||
1382 | {chm_nosuch, 0 }, /* 0xc0 */ | |
1383 | {chm_nosuch, 0 }, /* 0xc1 */ | |
1384 | {chm_nosuch, 0 }, /* 0xc2 */ | |
1385 | {chm_nosuch, 0 }, /* 0xc3 */ | |
1386 | {chm_nosuch, 0 }, /* 0xc4 */ | |
1387 | {chm_nosuch, 0 }, /* 0xc5 */ | |
1388 | {chm_nosuch, 0 }, /* 0xc6 */ | |
1389 | {chm_nosuch, 0 }, /* 0xc7 */ | |
1390 | {chm_nosuch, 0 }, /* 0xc8 */ | |
1391 | {chm_nosuch, 0 }, /* 0xc9 */ | |
1392 | {chm_nosuch, 0 }, /* 0xca */ | |
1393 | {chm_nosuch, 0 }, /* 0xcb */ | |
1394 | {chm_nosuch, 0 }, /* 0xcc */ | |
1395 | {chm_nosuch, 0 }, /* 0xcd */ | |
1396 | {chm_nosuch, 0 }, /* 0xce */ | |
1397 | {chm_nosuch, 0 }, /* 0xcf */ | |
1398 | ||
1399 | {chm_nosuch, 0 }, /* 0xd0 */ | |
1400 | {chm_nosuch, 0 }, /* 0xd1 */ | |
1401 | {chm_nosuch, 0 }, /* 0xd2 */ | |
1402 | {chm_nosuch, 0 }, /* 0xd3 */ | |
1403 | {chm_nosuch, 0 }, /* 0xd4 */ | |
1404 | {chm_nosuch, 0 }, /* 0xd5 */ | |
1405 | {chm_nosuch, 0 }, /* 0xd6 */ | |
1406 | {chm_nosuch, 0 }, /* 0xd7 */ | |
1407 | {chm_nosuch, 0 }, /* 0xd8 */ | |
1408 | {chm_nosuch, 0 }, /* 0xd9 */ | |
1409 | {chm_nosuch, 0 }, /* 0xda */ | |
1410 | {chm_nosuch, 0 }, /* 0xdb */ | |
1411 | {chm_nosuch, 0 }, /* 0xdc */ | |
1412 | {chm_nosuch, 0 }, /* 0xdd */ | |
1413 | {chm_nosuch, 0 }, /* 0xde */ | |
1414 | {chm_nosuch, 0 }, /* 0xdf */ | |
1415 | ||
1416 | {chm_nosuch, 0 }, /* 0xe0 */ | |
1417 | {chm_nosuch, 0 }, /* 0xe1 */ | |
1418 | {chm_nosuch, 0 }, /* 0xe2 */ | |
1419 | {chm_nosuch, 0 }, /* 0xe3 */ | |
1420 | {chm_nosuch, 0 }, /* 0xe4 */ | |
1421 | {chm_nosuch, 0 }, /* 0xe5 */ | |
1422 | {chm_nosuch, 0 }, /* 0xe6 */ | |
1423 | {chm_nosuch, 0 }, /* 0xe7 */ | |
1424 | {chm_nosuch, 0 }, /* 0xe8 */ | |
1425 | {chm_nosuch, 0 }, /* 0xe9 */ | |
1426 | {chm_nosuch, 0 }, /* 0xea */ | |
1427 | {chm_nosuch, 0 }, /* 0xeb */ | |
1428 | {chm_nosuch, 0 }, /* 0xec */ | |
1429 | {chm_nosuch, 0 }, /* 0xed */ | |
1430 | {chm_nosuch, 0 }, /* 0xee */ | |
1431 | {chm_nosuch, 0 }, /* 0xef */ | |
1432 | ||
1433 | {chm_nosuch, 0 }, /* 0xf0 */ | |
1434 | {chm_nosuch, 0 }, /* 0xf1 */ | |
1435 | {chm_nosuch, 0 }, /* 0xf2 */ | |
1436 | {chm_nosuch, 0 }, /* 0xf3 */ | |
1437 | {chm_nosuch, 0 }, /* 0xf4 */ | |
1438 | {chm_nosuch, 0 }, /* 0xf5 */ | |
1439 | {chm_nosuch, 0 }, /* 0xf6 */ | |
1440 | {chm_nosuch, 0 }, /* 0xf7 */ | |
1441 | {chm_nosuch, 0 }, /* 0xf8 */ | |
1442 | {chm_nosuch, 0 }, /* 0xf9 */ | |
1443 | {chm_nosuch, 0 }, /* 0xfa */ | |
1444 | {chm_nosuch, 0 }, /* 0xfb */ | |
1445 | {chm_nosuch, 0 }, /* 0xfc */ | |
1446 | {chm_nosuch, 0 }, /* 0xfd */ | |
1447 | {chm_nosuch, 0 }, /* 0xfe */ | |
1448 | {chm_nosuch, 0 }, /* 0xff */ | |
1449 | }; | |
1450 | ||
1451 | /* *INDENT-ON* */ | |
1452 | ||
1453 | /* set_channel_mode() | |
1454 | * | |
1455 | * inputs - client, source, channel, membership pointer, params | |
1456 | * output - | |
1457 | * side effects - channel modes/memberships are changed, MODE is issued | |
1458 | * | |
1459 | * Extensively modified to be hotpluggable, 03/09/06 -- nenolod | |
1460 | */ | |
1461 | void | |
1462 | set_channel_mode(struct Client *client_p, struct Client *source_p, | |
1463 | struct Channel *chptr, struct membership *msptr, int parc, const char *parv[]) | |
1464 | { | |
1465 | static char modebuf[BUFSIZE]; | |
1466 | static char parabuf[BUFSIZE]; | |
1467 | char *mbuf; | |
1468 | char *pbuf; | |
1469 | int cur_len, mlen, paralen, paracount, arglen, len; | |
1470 | int i, j, flags; | |
1471 | int dir = MODE_ADD; | |
1472 | int parn = 1; | |
1473 | int errors = 0; | |
1474 | int alevel; | |
1475 | const char *ml = parv[0]; | |
1476 | char c; | |
1477 | struct Client *fakesource_p; | |
1478 | ||
1479 | mask_pos = 0; | |
1480 | mode_count = 0; | |
1481 | mode_limit = 0; | |
1482 | ||
1483 | alevel = get_channel_access(source_p, msptr); | |
1484 | ||
1485 | /* Hide connecting server on netburst -- jilles */ | |
1486 | if (ConfigServerHide.flatten_links && IsServer(source_p) && !has_id(source_p) && !HasSentEob(source_p)) | |
1487 | fakesource_p = &me; | |
1488 | else | |
1489 | fakesource_p = source_p; | |
1490 | ||
1491 | for(; (c = *ml) != 0; ml++) | |
1492 | { | |
1493 | switch (c) | |
1494 | { | |
1495 | case '+': | |
1496 | dir = MODE_ADD; | |
1497 | break; | |
1498 | case '-': | |
1499 | dir = MODE_DEL; | |
1500 | break; | |
1501 | case '=': | |
1502 | dir = MODE_QUERY; | |
1503 | break; | |
1504 | default: | |
1505 | chmode_table[(unsigned char) c].set_func(fakesource_p, chptr, alevel, | |
1506 | parc, &parn, parv, | |
1507 | &errors, dir, c, | |
1508 | chmode_table[(unsigned char) c].mode_type); | |
1509 | break; | |
1510 | } | |
1511 | } | |
1512 | ||
1513 | /* bail out if we have nothing to do... */ | |
1514 | if(!mode_count) | |
1515 | return; | |
1516 | ||
1517 | if(IsServer(source_p)) | |
1518 | mlen = ircsprintf(modebuf, ":%s MODE %s ", fakesource_p->name, chptr->chname); | |
1519 | else | |
1520 | mlen = ircsprintf(modebuf, ":%s!%s@%s MODE %s ", | |
1521 | source_p->name, source_p->username, | |
1522 | source_p->host, chptr->chname); | |
1523 | ||
1524 | for(j = 0, flags = ALL_MEMBERS; j < 2; j++, flags = ONLY_CHANOPS) | |
1525 | { | |
1526 | cur_len = mlen; | |
1527 | mbuf = modebuf + mlen; | |
1528 | pbuf = parabuf; | |
1529 | parabuf[0] = '\0'; | |
1530 | paracount = paralen = 0; | |
1531 | dir = MODE_QUERY; | |
1532 | ||
1533 | for(i = 0; i < mode_count; i++) | |
1534 | { | |
1535 | if(mode_changes[i].letter == 0 || mode_changes[i].mems != flags) | |
1536 | continue; | |
1537 | ||
1538 | if(mode_changes[i].arg != NULL) | |
1539 | { | |
1540 | arglen = strlen(mode_changes[i].arg); | |
1541 | ||
1542 | if(arglen > MODEBUFLEN - 5) | |
1543 | continue; | |
1544 | } | |
1545 | else | |
1546 | arglen = 0; | |
1547 | ||
1548 | /* if we're creeping over MAXMODEPARAMSSERV, or over | |
1549 | * bufsize (4 == +/-,modechar,two spaces) send now. | |
1550 | */ | |
1551 | if(mode_changes[i].arg != NULL && | |
1552 | ((paracount == MAXMODEPARAMSSERV) || | |
1553 | ((cur_len + paralen + arglen + 4) > (BUFSIZE - 3)))) | |
1554 | { | |
1555 | *mbuf = '\0'; | |
1556 | ||
1557 | if(cur_len > mlen) | |
1558 | sendto_channel_local(flags, chptr, "%s %s", modebuf, | |
1559 | parabuf); | |
1560 | else | |
1561 | continue; | |
1562 | ||
1563 | paracount = paralen = 0; | |
1564 | cur_len = mlen; | |
1565 | mbuf = modebuf + mlen; | |
1566 | pbuf = parabuf; | |
1567 | parabuf[0] = '\0'; | |
1568 | dir = MODE_QUERY; | |
1569 | } | |
1570 | ||
1571 | if(dir != mode_changes[i].dir) | |
1572 | { | |
1573 | *mbuf++ = (mode_changes[i].dir == MODE_ADD) ? '+' : '-'; | |
1574 | cur_len++; | |
1575 | dir = mode_changes[i].dir; | |
1576 | } | |
1577 | ||
1578 | *mbuf++ = mode_changes[i].letter; | |
1579 | cur_len++; | |
1580 | ||
1581 | if(mode_changes[i].arg != NULL) | |
1582 | { | |
1583 | paracount++; | |
1584 | len = ircsprintf(pbuf, "%s ", mode_changes[i].arg); | |
1585 | pbuf += len; | |
1586 | paralen += len; | |
1587 | } | |
1588 | } | |
1589 | ||
1590 | if(paralen && parabuf[paralen - 1] == ' ') | |
1591 | parabuf[paralen - 1] = '\0'; | |
1592 | ||
1593 | *mbuf = '\0'; | |
1594 | if(cur_len > mlen) | |
1595 | sendto_channel_local(flags, chptr, "%s %s", modebuf, parabuf); | |
1596 | } | |
1597 | ||
1598 | /* only propagate modes originating locally, or if we're hubbing */ | |
1599 | if(MyClient(source_p) || dlink_list_length(&serv_list) > 1) | |
1600 | send_cap_mode_changes(client_p, source_p, chptr, mode_changes, mode_count); | |
1601 | } |