2 * charybdis: A slightly useful ircd.
3 * chmode.c: channel mode management
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
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.
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.
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
25 * $Id: chmode.c 3161 2007-01-25 07:23:01Z nenolod $
35 #include "irc_string.h"
36 #include "sprintf_irc.h"
39 #include "s_serv.h" /* captab */
43 #include "s_conf.h" /* ConfigFileEntry, ConfigChannel */
44 #include "s_newconf.h"
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
64 void set_channel_mode(struct Client
*, struct Client
*,
65 struct Channel
*, struct membership
*, int, const char **);
67 int add_id(struct Client
*source_p
, struct Channel
*chptr
,
68 const char *banid
, dlink_list
* list
, long mode_type
);
70 static struct ChModeChange mode_changes
[BUFSIZE
];
71 static int mode_count
;
72 static int mode_limit
;
76 get_channel_access(struct Client
*source_p
, struct membership
*msptr
)
78 if(!MyClient(source_p
) || is_chanop(msptr
))
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
91 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
,
92 dlink_list
* list
, long mode_type
)
94 struct Ban
*actualBan
;
95 static char who
[BANLEN
];
96 char *realban
= LOCAL_COPY(banid
);
99 /* dont let local clients overflow the banlist, or set redundant
102 if(MyClient(source_p
))
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
))
106 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
107 me
.name
, source_p
->name
, chptr
->chname
, realban
);
113 DLINK_FOREACH(ptr
, list
->head
)
115 actualBan
= ptr
->data
;
116 if(match(actualBan
->banstr
, realban
))
120 /* dont let remotes set duplicates */
123 DLINK_FOREACH(ptr
, list
->head
)
125 actualBan
= ptr
->data
;
126 if(!irccmp(actualBan
->banstr
, realban
))
132 if(IsPerson(source_p
))
133 ircsprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
135 strlcpy(who
, source_p
->name
, sizeof(who
));
137 actualBan
= allocate_ban(realban
, who
);
138 actualBan
->when
= CurrentTime
;
140 dlinkAdd(actualBan
, &actualBan
->node
, list
);
142 /* invalidate the can_send() cache */
143 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
151 * inputs - channel, id to remove, type
152 * outputs - 0 on failure, 1 on success
153 * side effects - given id is removed from the appropriate list
156 del_id(struct Channel
*chptr
, const char *banid
, dlink_list
* list
, long mode_type
)
161 if(EmptyString(banid
))
164 DLINK_FOREACH(ptr
, list
->head
)
168 if(irccmp(banid
, banptr
->banstr
) == 0)
170 dlinkDelete(&banptr
->node
, list
);
173 /* invalidate the can_send() cache */
174 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
186 * input - string to check
187 * output - pointer to 'fixed' string, or "*" if empty
188 * side effects - any white space found becomes \0
191 check_string(char *s
)
194 static char splat
[] = "*";
211 * inputs - mask to pretty
212 * outputs - better version of the mask
213 * side effects - mask is chopped to limits, and transformed:
221 pretty_mask(const char *idmask
)
223 static char mask_buf
[BUFSIZE
];
225 char *nick
, *user
, *host
;
228 char ne
= 0, ue
= 0, he
= 0; /* save values at nick[NICKLEN], et all */
231 mask
= LOCAL_COPY(idmask
);
232 mask
= check_string(mask
);
235 nick
= user
= host
= splat
;
237 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
240 old_mask_pos
= mask_pos
;
244 mask_pos
+= ircsprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
245 t
= mask_buf
+ old_mask_pos
+ 1;
251 return mask_buf
+ old_mask_pos
;
255 if((t
= strchr(mask
, '@')) != NULL
)
262 if((t
= strchr(mask
, '!')) != NULL
)
277 else if((t
= strchr(mask
, '!')) != NULL
)
286 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
)
297 /* truncate values to max lengths */
298 if(strlen(nick
) > NICKLEN
- 1)
300 ne
= nick
[NICKLEN
- 1];
301 nick
[NICKLEN
- 1] = '\0';
303 if(strlen(user
) > USERLEN
)
306 user
[USERLEN
] = '\0';
308 if(strlen(host
) > HOSTLEN
)
311 host
[HOSTLEN
] = '\0';
314 mask_pos
+= ircsprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
316 /* restore mask, since we may need to use it again later */
322 nick
[NICKLEN
- 1] = ne
;
328 return mask_buf
+ old_mask_pos
;
334 * output - the same key, fixed
335 * side effects - anything below ascii 13 is discarded, ':' discarded,
336 * high ascii is dropped to lower half of ascii table
343 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
346 if(c
!= ':' && c
!= ',' && c
> ' ')
357 * ouput - the same key, fixed
358 * side effects - high ascii dropped to lower half of table,
359 * CR/LF/':' are dropped
362 fix_key_remote(char *arg
)
366 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
369 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
379 * The handlers for each specific mode.
382 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
383 int alevel
, int parc
, int *parn
,
384 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
386 if(*errors
& SM_ERR_UNKNOWN
)
388 *errors
|= SM_ERR_UNKNOWN
;
389 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
393 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
394 int alevel
, int parc
, int *parn
,
395 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
397 if(alevel
!= CHFL_CHANOP
)
399 if(!(*errors
& SM_ERR_NOOPS
))
400 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
401 me
.name
, source_p
->name
, chptr
->chname
);
402 *errors
|= SM_ERR_NOOPS
;
406 /* +ntspmaikl == 9 + MAXMODEPARAMS (4 * +o) */
407 if(MyClient(source_p
) && (++mode_limit
> (9 + MAXMODEPARAMS
)))
411 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
413 /* if +f is disabled, ignore an attempt to set +QF locally */
414 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
415 (c
== 'Q' || c
== 'F'))
418 chptr
->mode
.mode
|= mode_type
;
420 mode_changes
[mode_count
].letter
= c
;
421 mode_changes
[mode_count
].dir
= MODE_ADD
;
422 mode_changes
[mode_count
].caps
= 0;
423 mode_changes
[mode_count
].nocaps
= 0;
424 mode_changes
[mode_count
].id
= NULL
;
425 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
426 mode_changes
[mode_count
++].arg
= NULL
;
428 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
430 chptr
->mode
.mode
&= ~mode_type
;
432 mode_changes
[mode_count
].letter
= c
;
433 mode_changes
[mode_count
].dir
= MODE_DEL
;
434 mode_changes
[mode_count
].caps
= 0;
435 mode_changes
[mode_count
].nocaps
= 0;
436 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
437 mode_changes
[mode_count
].id
= NULL
;
438 mode_changes
[mode_count
++].arg
= NULL
;
443 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
444 int alevel
, int parc
, int *parn
,
445 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
447 if(!IsOper(source_p
) && !IsServer(source_p
))
449 if(!(*errors
& SM_ERR_NOPRIVS
))
450 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
451 *errors
|= SM_ERR_NOPRIVS
;
456 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
458 chptr
->mode
.mode
|= mode_type
;
460 mode_changes
[mode_count
].letter
= c
;
461 mode_changes
[mode_count
].dir
= MODE_ADD
;
462 mode_changes
[mode_count
].caps
= 0;
463 mode_changes
[mode_count
].nocaps
= 0;
464 mode_changes
[mode_count
].id
= NULL
;
465 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
466 mode_changes
[mode_count
++].arg
= NULL
;
468 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
470 chptr
->mode
.mode
&= ~mode_type
;
472 mode_changes
[mode_count
].letter
= c
;
473 mode_changes
[mode_count
].dir
= MODE_DEL
;
474 mode_changes
[mode_count
].caps
= 0;
475 mode_changes
[mode_count
].nocaps
= 0;
476 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
477 mode_changes
[mode_count
].id
= NULL
;
478 mode_changes
[mode_count
++].arg
= NULL
;
483 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
484 int alevel
, int parc
, int *parn
,
485 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
488 const char *raw_mask
;
501 list
= &chptr
->banlist
;
502 errorval
= SM_ERR_RPL_B
;
503 rpl_list
= RPL_BANLIST
;
504 rpl_endlist
= RPL_ENDOFBANLIST
;
510 /* if +e is disabled, allow all but +e locally */
511 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
512 ((dir
== MODE_ADD
) && (parc
> *parn
)))
515 list
= &chptr
->exceptlist
;
516 errorval
= SM_ERR_RPL_E
;
517 rpl_list
= RPL_EXCEPTLIST
;
518 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
521 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
528 /* if +I is disabled, allow all but +I locally */
529 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
530 (dir
== MODE_ADD
) && (parc
> *parn
))
533 list
= &chptr
->invexlist
;
534 errorval
= SM_ERR_RPL_I
;
535 rpl_list
= RPL_INVITELIST
;
536 rpl_endlist
= RPL_ENDOFINVITELIST
;
539 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
546 list
= &chptr
->quietlist
;
547 errorval
= SM_ERR_RPL_Q
;
548 rpl_list
= RPL_BANLIST
;
549 rpl_endlist
= RPL_ENDOFBANLIST
;
555 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
560 if(dir
== 0 || parc
<= *parn
)
562 if((*errors
& errorval
) != 0)
566 /* non-ops cant see +eI lists.. */
567 if(alevel
!= CHFL_CHANOP
&& mode_type
!= CHFL_BAN
&&
568 mode_type
!= CHFL_QUIET
)
570 if(!(*errors
& SM_ERR_NOOPS
))
571 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
572 me
.name
, source_p
->name
, chptr
->chname
);
573 *errors
|= SM_ERR_NOOPS
;
577 DLINK_FOREACH(ptr
, list
->head
)
580 sendto_one(source_p
, form_str(rpl_list
),
581 me
.name
, source_p
->name
, chptr
->chname
,
582 banptr
->banstr
, banptr
->who
, banptr
->when
);
584 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
588 if(alevel
!= CHFL_CHANOP
)
590 if(!(*errors
& SM_ERR_NOOPS
))
591 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
592 me
.name
, source_p
->name
, chptr
->chname
);
593 *errors
|= SM_ERR_NOOPS
;
597 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
600 raw_mask
= parv
[(*parn
)];
603 /* empty ban, or starts with ':' which messes up s2s, ignore it */
604 if(EmptyString(raw_mask
) || *raw_mask
== ':')
607 if(!MyClient(source_p
))
609 if(strchr(raw_mask
, ' '))
615 mask
= pretty_mask(raw_mask
);
617 /* we'd have problems parsing this, hyb6 does it too */
618 if(strlen(mask
) > (MODEBUFLEN
- 2))
621 /* if we're adding a NEW id */
624 if (*mask
== '$' && MyClient(source_p
))
626 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
627 /* XXX perhaps return an error message here */
631 /* dont allow local clients to overflow the banlist, dont
632 * let remote servers set duplicate bans
634 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
637 mode_changes
[mode_count
].letter
= c
;
638 mode_changes
[mode_count
].dir
= MODE_ADD
;
639 mode_changes
[mode_count
].caps
= caps
;
640 mode_changes
[mode_count
].nocaps
= 0;
641 mode_changes
[mode_count
].mems
= mems
;
642 mode_changes
[mode_count
].id
= NULL
;
643 mode_changes
[mode_count
++].arg
= mask
;
645 else if(dir
== MODE_DEL
)
647 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
649 /* mask isn't a valid ban, check raw_mask */
650 if(del_id(chptr
, raw_mask
, list
, mode_type
))
654 mode_changes
[mode_count
].letter
= c
;
655 mode_changes
[mode_count
].dir
= MODE_DEL
;
656 mode_changes
[mode_count
].caps
= caps
;
657 mode_changes
[mode_count
].nocaps
= 0;
658 mode_changes
[mode_count
].mems
= mems
;
659 mode_changes
[mode_count
].id
= NULL
;
660 mode_changes
[mode_count
++].arg
= mask
;
665 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
666 int alevel
, int parc
, int *parn
,
667 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
669 struct membership
*mstptr
;
671 struct Client
*targ_p
;
673 if(alevel
!= CHFL_CHANOP
)
675 if(!(*errors
& SM_ERR_NOOPS
))
676 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
677 me
.name
, source_p
->name
, chptr
->chname
);
678 *errors
|= SM_ERR_NOOPS
;
682 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
685 opnick
= parv
[(*parn
)];
689 if(EmptyString(opnick
))
691 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
695 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
700 mstptr
= find_channel_membership(chptr
, targ_p
);
704 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
705 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
706 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
707 *errors
|= SM_ERR_NOTONCHANNEL
;
711 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
716 if(targ_p
== source_p
)
719 mode_changes
[mode_count
].letter
= c
;
720 mode_changes
[mode_count
].dir
= MODE_ADD
;
721 mode_changes
[mode_count
].caps
= 0;
722 mode_changes
[mode_count
].nocaps
= 0;
723 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
724 mode_changes
[mode_count
].id
= targ_p
->id
;
725 mode_changes
[mode_count
].arg
= targ_p
->name
;
726 mode_changes
[mode_count
++].client
= targ_p
;
728 mstptr
->flags
|= CHFL_CHANOP
;
729 mstptr
->flags
&= ~CHFL_DEOPPED
;
733 if(MyClient(source_p
) && IsService(targ_p
))
735 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
736 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
740 mode_changes
[mode_count
].letter
= c
;
741 mode_changes
[mode_count
].dir
= MODE_DEL
;
742 mode_changes
[mode_count
].caps
= 0;
743 mode_changes
[mode_count
].nocaps
= 0;
744 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
745 mode_changes
[mode_count
].id
= targ_p
->id
;
746 mode_changes
[mode_count
].arg
= targ_p
->name
;
747 mode_changes
[mode_count
++].client
= targ_p
;
749 mstptr
->flags
&= ~CHFL_CHANOP
;
754 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
755 int alevel
, int parc
, int *parn
,
756 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
758 struct membership
*mstptr
;
760 struct Client
*targ_p
;
762 if(alevel
!= CHFL_CHANOP
)
764 if(!(*errors
& SM_ERR_NOOPS
))
765 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
766 me
.name
, source_p
->name
, chptr
->chname
);
767 *errors
|= SM_ERR_NOOPS
;
771 if((dir
== MODE_QUERY
) || parc
<= *parn
)
774 opnick
= parv
[(*parn
)];
778 if(EmptyString(opnick
))
780 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
784 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
789 mstptr
= find_channel_membership(chptr
, targ_p
);
793 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
794 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
795 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
796 *errors
|= SM_ERR_NOTONCHANNEL
;
800 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
805 mode_changes
[mode_count
].letter
= c
;
806 mode_changes
[mode_count
].dir
= MODE_ADD
;
807 mode_changes
[mode_count
].caps
= 0;
808 mode_changes
[mode_count
].nocaps
= 0;
809 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
810 mode_changes
[mode_count
].id
= targ_p
->id
;
811 mode_changes
[mode_count
].arg
= targ_p
->name
;
812 mode_changes
[mode_count
++].client
= targ_p
;
814 mstptr
->flags
|= CHFL_VOICE
;
818 mode_changes
[mode_count
].letter
= 'v';
819 mode_changes
[mode_count
].dir
= MODE_DEL
;
820 mode_changes
[mode_count
].caps
= 0;
821 mode_changes
[mode_count
].nocaps
= 0;
822 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
823 mode_changes
[mode_count
].id
= targ_p
->id
;
824 mode_changes
[mode_count
].arg
= targ_p
->name
;
825 mode_changes
[mode_count
++].client
= targ_p
;
827 mstptr
->flags
&= ~CHFL_VOICE
;
832 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
833 int alevel
, int parc
, int *parn
,
834 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
837 static char limitstr
[30];
840 if(alevel
!= CHFL_CHANOP
)
842 if(!(*errors
& SM_ERR_NOOPS
))
843 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
844 me
.name
, source_p
->name
, chptr
->chname
);
845 *errors
|= SM_ERR_NOOPS
;
849 if(dir
== MODE_QUERY
)
852 if((dir
== MODE_ADD
) && parc
> *parn
)
854 lstr
= parv
[(*parn
)];
857 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
860 ircsprintf(limitstr
, "%d", limit
);
862 mode_changes
[mode_count
].letter
= c
;
863 mode_changes
[mode_count
].dir
= MODE_ADD
;
864 mode_changes
[mode_count
].caps
= 0;
865 mode_changes
[mode_count
].nocaps
= 0;
866 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
867 mode_changes
[mode_count
].id
= NULL
;
868 mode_changes
[mode_count
++].arg
= limitstr
;
870 chptr
->mode
.limit
= limit
;
872 else if(dir
== MODE_DEL
)
874 if(!chptr
->mode
.limit
)
877 chptr
->mode
.limit
= 0;
879 mode_changes
[mode_count
].letter
= c
;
880 mode_changes
[mode_count
].dir
= MODE_DEL
;
881 mode_changes
[mode_count
].caps
= 0;
882 mode_changes
[mode_count
].nocaps
= 0;
883 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
884 mode_changes
[mode_count
].id
= NULL
;
885 mode_changes
[mode_count
++].arg
= NULL
;
890 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
891 int alevel
, int parc
, int *parn
,
892 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
894 int joins
= 0, timeslice
= 0;
896 if(alevel
!= CHFL_CHANOP
)
898 if(!(*errors
& SM_ERR_NOOPS
))
899 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
900 me
.name
, source_p
->name
, chptr
->chname
);
901 *errors
|= SM_ERR_NOOPS
;
905 if(dir
== MODE_QUERY
)
908 if((dir
== MODE_ADD
) && parc
> *parn
)
910 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
912 if(!joins
|| !timeslice
)
915 mode_changes
[mode_count
].letter
= c
;
916 mode_changes
[mode_count
].dir
= MODE_ADD
;
917 mode_changes
[mode_count
].caps
= 0;
918 mode_changes
[mode_count
].nocaps
= 0;
919 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
920 mode_changes
[mode_count
].id
= NULL
;
921 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
925 chptr
->mode
.join_num
= joins
;
926 chptr
->mode
.join_time
= timeslice
;
928 else if(dir
== MODE_DEL
)
930 if(!chptr
->mode
.join_num
)
933 chptr
->mode
.join_num
= 0;
934 chptr
->mode
.join_time
= 0;
935 chptr
->join_count
= 0;
936 chptr
->join_delta
= 0;
938 mode_changes
[mode_count
].letter
= c
;
939 mode_changes
[mode_count
].dir
= MODE_DEL
;
940 mode_changes
[mode_count
].caps
= 0;
941 mode_changes
[mode_count
].nocaps
= 0;
942 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
943 mode_changes
[mode_count
].id
= NULL
;
944 mode_changes
[mode_count
++].arg
= NULL
;
949 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
950 int alevel
, int parc
, int *parn
,
951 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
953 struct Channel
*targptr
= NULL
;
954 struct membership
*msptr
;
957 /* if +f is disabled, ignore local attempts to set it */
958 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
959 (dir
== MODE_ADD
) && (parc
> *parn
))
962 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
964 if (!(*errors
& SM_ERR_RPL_F
))
966 if (*chptr
->mode
.forward
== '\0')
967 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
969 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
970 *errors
|= SM_ERR_RPL_F
;
975 #ifndef FORWARD_OPERONLY
976 if(alevel
!= CHFL_CHANOP
)
978 if(!(*errors
& SM_ERR_NOOPS
))
979 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
980 me
.name
, source_p
->name
, chptr
->chname
);
981 *errors
|= SM_ERR_NOOPS
;
985 if(!IsOper(source_p
) && !IsServer(source_p
))
987 if(!(*errors
& SM_ERR_NOPRIVS
))
988 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
989 *errors
|= SM_ERR_NOPRIVS
;
994 if(dir
== MODE_ADD
&& parc
> *parn
)
996 forward
= parv
[(*parn
)];
999 if(EmptyString(forward
))
1001 if(!check_channel_name(forward
) ||
1002 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1004 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1007 /* don't forward to inconsistent target -- jilles */
1008 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
1010 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
1011 form_str(ERR_BADCHANNAME
), forward
);
1014 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1016 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1017 form_str(ERR_NOSUCHCHANNEL
), forward
);
1020 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1022 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1023 get_channel_access(source_p
, msptr
) != CHFL_CHANOP
)
1025 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1026 me
.name
, source_p
->name
, targptr
->chname
);
1031 strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1033 mode_changes
[mode_count
].letter
= c
;
1034 mode_changes
[mode_count
].dir
= MODE_ADD
;
1035 mode_changes
[mode_count
].caps
= 0;
1036 mode_changes
[mode_count
].nocaps
= 0;
1037 mode_changes
[mode_count
].mems
= ConfigChannel
.use_forward
? ALL_MEMBERS
: ONLY_SERVERS
;
1038 mode_changes
[mode_count
].id
= NULL
;
1039 mode_changes
[mode_count
++].arg
= forward
;
1041 else if(dir
== MODE_DEL
)
1043 if(!(*chptr
->mode
.forward
))
1046 *chptr
->mode
.forward
= '\0';
1048 mode_changes
[mode_count
].letter
= c
;
1049 mode_changes
[mode_count
].dir
= MODE_DEL
;
1050 mode_changes
[mode_count
].caps
= 0;
1051 mode_changes
[mode_count
].nocaps
= 0;
1052 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1053 mode_changes
[mode_count
].id
= NULL
;
1054 mode_changes
[mode_count
++].arg
= NULL
;
1059 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1060 int alevel
, int parc
, int *parn
,
1061 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1065 if(alevel
!= CHFL_CHANOP
)
1067 if(!(*errors
& SM_ERR_NOOPS
))
1068 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1069 me
.name
, source_p
->name
, chptr
->chname
);
1070 *errors
|= SM_ERR_NOOPS
;
1074 if(dir
== MODE_QUERY
)
1077 if((dir
== MODE_ADD
) && parc
> *parn
)
1079 key
= LOCAL_COPY(parv
[(*parn
)]);
1082 if(MyClient(source_p
))
1085 fix_key_remote(key
);
1087 if(EmptyString(key
))
1090 s_assert(key
[0] != ' ');
1091 strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1093 mode_changes
[mode_count
].letter
= c
;
1094 mode_changes
[mode_count
].dir
= MODE_ADD
;
1095 mode_changes
[mode_count
].caps
= 0;
1096 mode_changes
[mode_count
].nocaps
= 0;
1097 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1098 mode_changes
[mode_count
].id
= NULL
;
1099 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1101 else if(dir
== MODE_DEL
)
1103 static char splat
[] = "*";
1109 if(!(*chptr
->mode
.key
))
1112 /* hack time. when we get a +k-k mode, the +k arg is
1113 * chptr->mode.key, which the -k sets to \0, so hunt for a
1114 * +k when we get a -k, and set the arg to splat. --anfl
1116 for(i
= 0; i
< mode_count
; i
++)
1118 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1119 mode_changes
[i
].arg
= splat
;
1122 *chptr
->mode
.key
= 0;
1124 mode_changes
[mode_count
].letter
= c
;
1125 mode_changes
[mode_count
].dir
= MODE_DEL
;
1126 mode_changes
[mode_count
].caps
= 0;
1127 mode_changes
[mode_count
].nocaps
= 0;
1128 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1129 mode_changes
[mode_count
].id
= NULL
;
1130 mode_changes
[mode_count
++].arg
= "*";
1135 chm_regonly(struct Client
*source_p
, struct Channel
*chptr
,
1136 int alevel
, int parc
, int *parn
,
1137 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1139 if(alevel
!= CHFL_CHANOP
)
1141 if(!(*errors
& SM_ERR_NOOPS
))
1142 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1143 me
.name
, source_p
->name
, chptr
->chname
);
1144 *errors
|= SM_ERR_NOOPS
;
1148 if(dir
== MODE_QUERY
)
1151 if(((dir
== MODE_ADD
) && (chptr
->mode
.mode
& MODE_REGONLY
)) ||
1152 ((dir
== MODE_DEL
) && !(chptr
->mode
.mode
& MODE_REGONLY
)))
1156 chptr
->mode
.mode
|= MODE_REGONLY
;
1158 chptr
->mode
.mode
&= ~MODE_REGONLY
;
1160 mode_changes
[mode_count
].letter
= c
;
1161 mode_changes
[mode_count
].dir
= dir
;
1162 mode_changes
[mode_count
].caps
= CAP_SERVICE
;
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
= NULL
;
1170 struct ChannelMode chmode_table
[256] =
1172 {chm_nosuch
, 0 }, /* 0x00 */
1173 {chm_nosuch
, 0 }, /* 0x01 */
1174 {chm_nosuch
, 0 }, /* 0x02 */
1175 {chm_nosuch
, 0 }, /* 0x03 */
1176 {chm_nosuch
, 0 }, /* 0x04 */
1177 {chm_nosuch
, 0 }, /* 0x05 */
1178 {chm_nosuch
, 0 }, /* 0x06 */
1179 {chm_nosuch
, 0 }, /* 0x07 */
1180 {chm_nosuch
, 0 }, /* 0x08 */
1181 {chm_nosuch
, 0 }, /* 0x09 */
1182 {chm_nosuch
, 0 }, /* 0x0a */
1183 {chm_nosuch
, 0 }, /* 0x0b */
1184 {chm_nosuch
, 0 }, /* 0x0c */
1185 {chm_nosuch
, 0 }, /* 0x0d */
1186 {chm_nosuch
, 0 }, /* 0x0e */
1187 {chm_nosuch
, 0 }, /* 0x0f */
1188 {chm_nosuch
, 0 }, /* 0x10 */
1189 {chm_nosuch
, 0 }, /* 0x11 */
1190 {chm_nosuch
, 0 }, /* 0x12 */
1191 {chm_nosuch
, 0 }, /* 0x13 */
1192 {chm_nosuch
, 0 }, /* 0x14 */
1193 {chm_nosuch
, 0 }, /* 0x15 */
1194 {chm_nosuch
, 0 }, /* 0x16 */
1195 {chm_nosuch
, 0 }, /* 0x17 */
1196 {chm_nosuch
, 0 }, /* 0x18 */
1197 {chm_nosuch
, 0 }, /* 0x19 */
1198 {chm_nosuch
, 0 }, /* 0x1a */
1199 {chm_nosuch
, 0 }, /* 0x1b */
1200 {chm_nosuch
, 0 }, /* 0x1c */
1201 {chm_nosuch
, 0 }, /* 0x1d */
1202 {chm_nosuch
, 0 }, /* 0x1e */
1203 {chm_nosuch
, 0 }, /* 0x1f */
1204 {chm_nosuch
, 0 }, /* 0x20 */
1205 {chm_nosuch
, 0 }, /* 0x21 */
1206 {chm_nosuch
, 0 }, /* 0x22 */
1207 {chm_nosuch
, 0 }, /* 0x23 */
1208 {chm_nosuch
, 0 }, /* 0x24 */
1209 {chm_nosuch
, 0 }, /* 0x25 */
1210 {chm_nosuch
, 0 }, /* 0x26 */
1211 {chm_nosuch
, 0 }, /* 0x27 */
1212 {chm_nosuch
, 0 }, /* 0x28 */
1213 {chm_nosuch
, 0 }, /* 0x29 */
1214 {chm_nosuch
, 0 }, /* 0x2a */
1215 {chm_nosuch
, 0 }, /* 0x2b */
1216 {chm_nosuch
, 0 }, /* 0x2c */
1217 {chm_nosuch
, 0 }, /* 0x2d */
1218 {chm_nosuch
, 0 }, /* 0x2e */
1219 {chm_nosuch
, 0 }, /* 0x2f */
1220 {chm_nosuch
, 0 }, /* 0x30 */
1221 {chm_nosuch
, 0 }, /* 0x31 */
1222 {chm_nosuch
, 0 }, /* 0x32 */
1223 {chm_nosuch
, 0 }, /* 0x33 */
1224 {chm_nosuch
, 0 }, /* 0x34 */
1225 {chm_nosuch
, 0 }, /* 0x35 */
1226 {chm_nosuch
, 0 }, /* 0x36 */
1227 {chm_nosuch
, 0 }, /* 0x37 */
1228 {chm_nosuch
, 0 }, /* 0x38 */
1229 {chm_nosuch
, 0 }, /* 0x39 */
1230 {chm_nosuch
, 0 }, /* 0x3a */
1231 {chm_nosuch
, 0 }, /* 0x3b */
1232 {chm_nosuch
, 0 }, /* 0x3c */
1233 {chm_nosuch
, 0 }, /* 0x3d */
1234 {chm_nosuch
, 0 }, /* 0x3e */
1235 {chm_nosuch
, 0 }, /* 0x3f */
1237 {chm_nosuch
, 0 }, /* @ */
1238 {chm_nosuch
, 0 }, /* A */
1239 {chm_nosuch
, 0 }, /* B */
1240 {chm_nosuch
, 0 }, /* C */
1241 {chm_nosuch
, 0 }, /* D */
1242 {chm_nosuch
, 0 }, /* E */
1243 {chm_simple
, MODE_FREETARGET
}, /* F */
1244 {chm_nosuch
, 0 }, /* G */
1245 {chm_nosuch
, 0 }, /* H */
1246 {chm_ban
, CHFL_INVEX
}, /* I */
1247 {chm_nosuch
, 0 }, /* J */
1248 {chm_nosuch
, 0 }, /* K */
1249 {chm_staff
, MODE_EXLIMIT
}, /* L */
1250 {chm_nosuch
, 0 }, /* M */
1251 {chm_nosuch
, 0 }, /* N */
1252 {chm_nosuch
, 0 }, /* O */
1253 {chm_staff
, MODE_PERMANENT
}, /* P */
1254 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1255 {chm_nosuch
, 0 }, /* R */
1256 {chm_nosuch
, 0 }, /* S */
1257 {chm_nosuch
, 0 }, /* T */
1258 {chm_nosuch
, 0 }, /* U */
1259 {chm_nosuch
, 0 }, /* V */
1260 {chm_nosuch
, 0 }, /* W */
1261 {chm_nosuch
, 0 }, /* X */
1262 {chm_nosuch
, 0 }, /* Y */
1263 {chm_nosuch
, 0 }, /* Z */
1270 {chm_nosuch
, 0 }, /* a */
1271 {chm_ban
, CHFL_BAN
}, /* b */
1272 {chm_simple
, MODE_NOCOLOR
}, /* c */
1273 {chm_nosuch
, 0 }, /* d */
1274 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1275 {chm_forward
, 0 }, /* f */
1276 {chm_simple
, MODE_FREEINVITE
}, /* g */
1277 {chm_nosuch
, 0 }, /* h */
1278 {chm_simple
, MODE_INVITEONLY
}, /* i */
1279 {chm_throttle
, 0 }, /* j */
1280 {chm_key
, 0 }, /* k */
1281 {chm_limit
, 0 }, /* l */
1282 {chm_simple
, MODE_MODERATED
}, /* m */
1283 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1284 {chm_op
, 0 }, /* o */
1285 {chm_simple
, MODE_PRIVATE
}, /* p */
1286 {chm_ban
, CHFL_QUIET
}, /* q */
1287 {chm_regonly
, 0 }, /* r */
1288 {chm_simple
, MODE_SECRET
}, /* s */
1289 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1290 {chm_nosuch
, 0 }, /* u */
1291 {chm_voice
, 0 }, /* v */
1292 {chm_nosuch
, 0 }, /* w */
1293 {chm_nosuch
, 0 }, /* x */
1294 {chm_nosuch
, 0 }, /* y */
1295 {chm_simple
, MODE_OPMODERATE
}, /* z */
1297 {chm_nosuch
, 0 }, /* 0x7b */
1298 {chm_nosuch
, 0 }, /* 0x7c */
1299 {chm_nosuch
, 0 }, /* 0x7d */
1300 {chm_nosuch
, 0 }, /* 0x7e */
1301 {chm_nosuch
, 0 }, /* 0x7f */
1303 {chm_nosuch
, 0 }, /* 0x80 */
1304 {chm_nosuch
, 0 }, /* 0x81 */
1305 {chm_nosuch
, 0 }, /* 0x82 */
1306 {chm_nosuch
, 0 }, /* 0x83 */
1307 {chm_nosuch
, 0 }, /* 0x84 */
1308 {chm_nosuch
, 0 }, /* 0x85 */
1309 {chm_nosuch
, 0 }, /* 0x86 */
1310 {chm_nosuch
, 0 }, /* 0x87 */
1311 {chm_nosuch
, 0 }, /* 0x88 */
1312 {chm_nosuch
, 0 }, /* 0x89 */
1313 {chm_nosuch
, 0 }, /* 0x8a */
1314 {chm_nosuch
, 0 }, /* 0x8b */
1315 {chm_nosuch
, 0 }, /* 0x8c */
1316 {chm_nosuch
, 0 }, /* 0x8d */
1317 {chm_nosuch
, 0 }, /* 0x8e */
1318 {chm_nosuch
, 0 }, /* 0x8f */
1320 {chm_nosuch
, 0 }, /* 0x90 */
1321 {chm_nosuch
, 0 }, /* 0x91 */
1322 {chm_nosuch
, 0 }, /* 0x92 */
1323 {chm_nosuch
, 0 }, /* 0x93 */
1324 {chm_nosuch
, 0 }, /* 0x94 */
1325 {chm_nosuch
, 0 }, /* 0x95 */
1326 {chm_nosuch
, 0 }, /* 0x96 */
1327 {chm_nosuch
, 0 }, /* 0x97 */
1328 {chm_nosuch
, 0 }, /* 0x98 */
1329 {chm_nosuch
, 0 }, /* 0x99 */
1330 {chm_nosuch
, 0 }, /* 0x9a */
1331 {chm_nosuch
, 0 }, /* 0x9b */
1332 {chm_nosuch
, 0 }, /* 0x9c */
1333 {chm_nosuch
, 0 }, /* 0x9d */
1334 {chm_nosuch
, 0 }, /* 0x9e */
1335 {chm_nosuch
, 0 }, /* 0x9f */
1337 {chm_nosuch
, 0 }, /* 0xa0 */
1338 {chm_nosuch
, 0 }, /* 0xa1 */
1339 {chm_nosuch
, 0 }, /* 0xa2 */
1340 {chm_nosuch
, 0 }, /* 0xa3 */
1341 {chm_nosuch
, 0 }, /* 0xa4 */
1342 {chm_nosuch
, 0 }, /* 0xa5 */
1343 {chm_nosuch
, 0 }, /* 0xa6 */
1344 {chm_nosuch
, 0 }, /* 0xa7 */
1345 {chm_nosuch
, 0 }, /* 0xa8 */
1346 {chm_nosuch
, 0 }, /* 0xa9 */
1347 {chm_nosuch
, 0 }, /* 0xaa */
1348 {chm_nosuch
, 0 }, /* 0xab */
1349 {chm_nosuch
, 0 }, /* 0xac */
1350 {chm_nosuch
, 0 }, /* 0xad */
1351 {chm_nosuch
, 0 }, /* 0xae */
1352 {chm_nosuch
, 0 }, /* 0xaf */
1354 {chm_nosuch
, 0 }, /* 0xb0 */
1355 {chm_nosuch
, 0 }, /* 0xb1 */
1356 {chm_nosuch
, 0 }, /* 0xb2 */
1357 {chm_nosuch
, 0 }, /* 0xb3 */
1358 {chm_nosuch
, 0 }, /* 0xb4 */
1359 {chm_nosuch
, 0 }, /* 0xb5 */
1360 {chm_nosuch
, 0 }, /* 0xb6 */
1361 {chm_nosuch
, 0 }, /* 0xb7 */
1362 {chm_nosuch
, 0 }, /* 0xb8 */
1363 {chm_nosuch
, 0 }, /* 0xb9 */
1364 {chm_nosuch
, 0 }, /* 0xba */
1365 {chm_nosuch
, 0 }, /* 0xbb */
1366 {chm_nosuch
, 0 }, /* 0xbc */
1367 {chm_nosuch
, 0 }, /* 0xbd */
1368 {chm_nosuch
, 0 }, /* 0xbe */
1369 {chm_nosuch
, 0 }, /* 0xbf */
1371 {chm_nosuch
, 0 }, /* 0xc0 */
1372 {chm_nosuch
, 0 }, /* 0xc1 */
1373 {chm_nosuch
, 0 }, /* 0xc2 */
1374 {chm_nosuch
, 0 }, /* 0xc3 */
1375 {chm_nosuch
, 0 }, /* 0xc4 */
1376 {chm_nosuch
, 0 }, /* 0xc5 */
1377 {chm_nosuch
, 0 }, /* 0xc6 */
1378 {chm_nosuch
, 0 }, /* 0xc7 */
1379 {chm_nosuch
, 0 }, /* 0xc8 */
1380 {chm_nosuch
, 0 }, /* 0xc9 */
1381 {chm_nosuch
, 0 }, /* 0xca */
1382 {chm_nosuch
, 0 }, /* 0xcb */
1383 {chm_nosuch
, 0 }, /* 0xcc */
1384 {chm_nosuch
, 0 }, /* 0xcd */
1385 {chm_nosuch
, 0 }, /* 0xce */
1386 {chm_nosuch
, 0 }, /* 0xcf */
1388 {chm_nosuch
, 0 }, /* 0xd0 */
1389 {chm_nosuch
, 0 }, /* 0xd1 */
1390 {chm_nosuch
, 0 }, /* 0xd2 */
1391 {chm_nosuch
, 0 }, /* 0xd3 */
1392 {chm_nosuch
, 0 }, /* 0xd4 */
1393 {chm_nosuch
, 0 }, /* 0xd5 */
1394 {chm_nosuch
, 0 }, /* 0xd6 */
1395 {chm_nosuch
, 0 }, /* 0xd7 */
1396 {chm_nosuch
, 0 }, /* 0xd8 */
1397 {chm_nosuch
, 0 }, /* 0xd9 */
1398 {chm_nosuch
, 0 }, /* 0xda */
1399 {chm_nosuch
, 0 }, /* 0xdb */
1400 {chm_nosuch
, 0 }, /* 0xdc */
1401 {chm_nosuch
, 0 }, /* 0xdd */
1402 {chm_nosuch
, 0 }, /* 0xde */
1403 {chm_nosuch
, 0 }, /* 0xdf */
1405 {chm_nosuch
, 0 }, /* 0xe0 */
1406 {chm_nosuch
, 0 }, /* 0xe1 */
1407 {chm_nosuch
, 0 }, /* 0xe2 */
1408 {chm_nosuch
, 0 }, /* 0xe3 */
1409 {chm_nosuch
, 0 }, /* 0xe4 */
1410 {chm_nosuch
, 0 }, /* 0xe5 */
1411 {chm_nosuch
, 0 }, /* 0xe6 */
1412 {chm_nosuch
, 0 }, /* 0xe7 */
1413 {chm_nosuch
, 0 }, /* 0xe8 */
1414 {chm_nosuch
, 0 }, /* 0xe9 */
1415 {chm_nosuch
, 0 }, /* 0xea */
1416 {chm_nosuch
, 0 }, /* 0xeb */
1417 {chm_nosuch
, 0 }, /* 0xec */
1418 {chm_nosuch
, 0 }, /* 0xed */
1419 {chm_nosuch
, 0 }, /* 0xee */
1420 {chm_nosuch
, 0 }, /* 0xef */
1422 {chm_nosuch
, 0 }, /* 0xf0 */
1423 {chm_nosuch
, 0 }, /* 0xf1 */
1424 {chm_nosuch
, 0 }, /* 0xf2 */
1425 {chm_nosuch
, 0 }, /* 0xf3 */
1426 {chm_nosuch
, 0 }, /* 0xf4 */
1427 {chm_nosuch
, 0 }, /* 0xf5 */
1428 {chm_nosuch
, 0 }, /* 0xf6 */
1429 {chm_nosuch
, 0 }, /* 0xf7 */
1430 {chm_nosuch
, 0 }, /* 0xf8 */
1431 {chm_nosuch
, 0 }, /* 0xf9 */
1432 {chm_nosuch
, 0 }, /* 0xfa */
1433 {chm_nosuch
, 0 }, /* 0xfb */
1434 {chm_nosuch
, 0 }, /* 0xfc */
1435 {chm_nosuch
, 0 }, /* 0xfd */
1436 {chm_nosuch
, 0 }, /* 0xfe */
1437 {chm_nosuch
, 0 }, /* 0xff */
1442 /* set_channel_mode()
1444 * inputs - client, source, channel, membership pointer, params
1446 * side effects - channel modes/memberships are changed, MODE is issued
1448 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
1451 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
1452 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
1454 static char modebuf
[BUFSIZE
];
1455 static char parabuf
[BUFSIZE
];
1458 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
1464 const char *ml
= parv
[0];
1466 struct Client
*fakesource_p
;
1472 alevel
= get_channel_access(source_p
, msptr
);
1474 /* Hide connecting server on netburst -- jilles */
1475 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
1478 fakesource_p
= source_p
;
1480 for(; (c
= *ml
) != 0; ml
++)
1494 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
1497 chmode_table
[(unsigned char) c
].mode_type
);
1502 /* bail out if we have nothing to do... */
1506 if(IsServer(source_p
))
1507 mlen
= ircsprintf(modebuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
1509 mlen
= ircsprintf(modebuf
, ":%s!%s@%s MODE %s ",
1510 source_p
->name
, source_p
->username
,
1511 source_p
->host
, chptr
->chname
);
1513 for(j
= 0, flags
= ALL_MEMBERS
; j
< 2; j
++, flags
= ONLY_CHANOPS
)
1516 mbuf
= modebuf
+ mlen
;
1519 paracount
= paralen
= 0;
1522 for(i
= 0; i
< mode_count
; i
++)
1524 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
1527 if(mode_changes
[i
].arg
!= NULL
)
1529 arglen
= strlen(mode_changes
[i
].arg
);
1531 if(arglen
> MODEBUFLEN
- 5)
1537 /* if we're creeping over MAXMODEPARAMSSERV, or over
1538 * bufsize (4 == +/-,modechar,two spaces) send now.
1540 if(mode_changes
[i
].arg
!= NULL
&&
1541 ((paracount
== MAXMODEPARAMSSERV
) ||
1542 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
1547 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
,
1552 paracount
= paralen
= 0;
1554 mbuf
= modebuf
+ mlen
;
1560 if(dir
!= mode_changes
[i
].dir
)
1562 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
1564 dir
= mode_changes
[i
].dir
;
1567 *mbuf
++ = mode_changes
[i
].letter
;
1570 if(mode_changes
[i
].arg
!= NULL
)
1573 len
= ircsprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
1579 if(paralen
&& parabuf
[paralen
- 1] == ' ')
1580 parabuf
[paralen
- 1] = '\0';
1584 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
, parabuf
);
1587 /* only propagate modes originating locally, or if we're hubbing */
1588 if(MyClient(source_p
) || dlink_list_length(&serv_list
) > 1)
1589 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);