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 3580 2007-11-07 23:45:14Z jilles $
37 #include "s_serv.h" /* captab */
41 #include "s_conf.h" /* ConfigFileEntry, ConfigChannel */
42 #include "s_newconf.h"
45 #include "irc_dictionary.h"
47 /* bitmasks for error returns, so we send once per call */
48 #define SM_ERR_NOTS 0x00000001 /* No TS on channel */
49 #define SM_ERR_NOOPS 0x00000002 /* No chan ops */
50 #define SM_ERR_UNKNOWN 0x00000004
51 #define SM_ERR_RPL_C 0x00000008
52 #define SM_ERR_RPL_B 0x00000010
53 #define SM_ERR_RPL_E 0x00000020
54 #define SM_ERR_NOTONCHANNEL 0x00000040 /* Not on channel */
55 #define SM_ERR_RPL_I 0x00000100
56 #define SM_ERR_RPL_D 0x00000200
57 #define SM_ERR_NOPRIVS 0x00000400
58 #define SM_ERR_RPL_Q 0x00000800
59 #define SM_ERR_RPL_F 0x00001000
61 #define MAXMODES_SIMPLE 46 /* a-zA-Z except bqeIov */
63 static struct ChModeChange mode_changes
[BUFSIZE
];
64 static int mode_count
;
65 static int mode_limit
;
66 static int mode_limit_simple
;
68 static int no_override_deop
;
71 char cflagsmyinfo
[256];
73 int chmode_flags
[256];
75 /* OPTIMIZE ME! -- dwr */
77 construct_cflags_strings(void)
80 char *ptr
= cflagsbuf
;
81 char *ptr2
= cflagsmyinfo
;
86 for(i
= 0; i
< 256; i
++)
88 if( !(chmode_table
[i
].set_func
== chm_ban
) &&
89 !(chmode_table
[i
].set_func
== chm_forward
) &&
90 !(chmode_table
[i
].set_func
== chm_throttle
) &&
91 !(chmode_table
[i
].set_func
== chm_key
) &&
92 !(chmode_table
[i
].set_func
== chm_limit
) &&
93 !(chmode_table
[i
].set_func
== chm_admin
) &&
94 !(chmode_table
[i
].set_func
== chm_op
) &&
95 !(chmode_table
[i
].set_func
== chm_halfop
) &&
96 !(chmode_table
[i
].set_func
== chm_voice
))
98 chmode_flags
[i
] = chmode_table
[i
].mode_type
;
105 switch (chmode_flags
[i
])
108 case MODE_DISFORWARD
:
109 if(ConfigChannel
.use_forward
)
116 if(rb_dlink_list_length(&service_list
))
123 if(chmode_flags
[i
] != 0)
129 /* Should we leave orphaned check here? -- dwr */
130 if(!(chmode_table
[i
].set_func
== chm_nosuch
) && !(chmode_table
[i
].set_func
== chm_orphaned
))
144 * outputs - an available cflag bitmask or
145 * 0 if no cflags are available
146 * side effects - NONE
149 find_cflag_slot(void)
151 unsigned int all_cflags
= 0, my_cflag
= 0, i
;
153 for (i
= 0; i
< 256; i
++)
154 all_cflags
|= chmode_flags
[i
];
156 for (my_cflag
= 1; my_cflag
&& (all_cflags
& my_cflag
);
163 cflag_add(char c_
, ChannelModeFunc function
)
165 int c
= (unsigned char)c_
;
167 if (chmode_table
[c
].set_func
!= chm_nosuch
&&
168 chmode_table
[c
].set_func
!= chm_orphaned
)
171 if (chmode_table
[c
].set_func
== chm_nosuch
)
172 chmode_table
[c
].mode_type
= find_cflag_slot();
173 if (chmode_table
[c
].mode_type
== 0)
175 chmode_table
[c
].set_func
= function
;
176 construct_cflags_strings();
177 return chmode_table
[c
].mode_type
;
181 cflag_orphan(char c_
)
183 int c
= (unsigned char)c_
;
185 s_assert(chmode_flags
[c
] != 0);
186 chmode_table
[c
].set_func
= chm_orphaned
;
187 construct_cflags_strings();
191 get_channel_access(struct Client
*source_p
, struct membership
*msptr
)
193 if(!MyClient(source_p
) || is_admin(msptr
))
195 else if(is_chanop(msptr
))
197 else if(is_halfop(msptr
))
205 * inputs - client, channel, id to add, type
206 * outputs - 0 on failure, 1 on success
207 * side effects - given id is added to the appropriate list
210 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
,
211 rb_dlink_list
* list
, long mode_type
)
213 struct Ban
*actualBan
;
214 static char who
[USERHOST_REPLYLEN
];
215 char *realban
= LOCAL_COPY(banid
);
218 /* dont let local clients overflow the banlist, or set redundant
221 if(MyClient(source_p
))
223 if((rb_dlink_list_length(&chptr
->banlist
) + rb_dlink_list_length(&chptr
->exceptlist
) + rb_dlink_list_length(&chptr
->invexlist
) + rb_dlink_list_length(&chptr
->quietlist
)) >= (chptr
->mode
.mode
& MODE_EXLIMIT
? ConfigChannel
.max_bans_large
: ConfigChannel
.max_bans
))
225 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
226 me
.name
, source_p
->name
, chptr
->chname
, realban
);
230 RB_DLINK_FOREACH(ptr
, list
->head
)
232 actualBan
= ptr
->data
;
233 if(mask_match(actualBan
->banstr
, realban
))
237 /* dont let remotes set duplicates */
240 RB_DLINK_FOREACH(ptr
, list
->head
)
242 actualBan
= ptr
->data
;
243 if(!irccmp(actualBan
->banstr
, realban
))
249 if(IsPerson(source_p
))
250 rb_sprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
252 rb_strlcpy(who
, source_p
->name
, sizeof(who
));
254 actualBan
= allocate_ban(realban
, who
);
255 actualBan
->when
= rb_current_time();
257 rb_dlinkAdd(actualBan
, &actualBan
->node
, list
);
259 /* invalidate the can_send() cache */
260 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
268 * inputs - channel, id to remove, type
269 * outputs - 0 on failure, 1 on success
270 * side effects - given id is removed from the appropriate list
273 del_id(struct Channel
*chptr
, const char *banid
, rb_dlink_list
* list
, long mode_type
)
278 if(EmptyString(banid
))
281 RB_DLINK_FOREACH(ptr
, list
->head
)
285 if(irccmp(banid
, banptr
->banstr
) == 0)
287 rb_dlinkDelete(&banptr
->node
, list
);
290 /* invalidate the can_send() cache */
291 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
303 * input - string to check
304 * output - pointer to 'fixed' string, or "*" if empty
305 * side effects - any white space found becomes \0
308 check_string(char *s
)
311 static char splat
[] = "*";
328 * inputs - mask to pretty
329 * outputs - better version of the mask
330 * side effects - mask is chopped to limits, and transformed:
338 pretty_mask(const char *idmask
)
340 static char mask_buf
[BUFSIZE
];
342 char *nick
, *user
, *host
;
345 char ne
= 0, ue
= 0, he
= 0; /* save values at nick[NICKLEN], et all */
348 mask
= LOCAL_COPY(idmask
);
349 mask
= check_string(mask
);
352 nick
= user
= host
= splat
;
354 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
357 old_mask_pos
= mask_pos
;
361 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
362 t
= mask_buf
+ old_mask_pos
+ 1;
368 return mask_buf
+ old_mask_pos
;
372 if((t
= strchr(mask
, '@')) != NULL
)
379 if((t
= strchr(mask
, '!')) != NULL
)
394 else if((t
= strchr(mask
, '!')) != NULL
)
403 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
|| strchr(mask
, '/') != NULL
)
414 /* truncate values to max lengths */
415 if(strlen(nick
) > NICKLEN
- 1)
417 ne
= nick
[NICKLEN
- 1];
418 nick
[NICKLEN
- 1] = '\0';
420 if(strlen(user
) > USERLEN
)
423 user
[USERLEN
] = '\0';
425 if(strlen(host
) > HOSTLEN
)
428 host
[HOSTLEN
] = '\0';
431 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
433 /* restore mask, since we may need to use it again later */
439 nick
[NICKLEN
- 1] = ne
;
445 return mask_buf
+ old_mask_pos
;
451 * output - the same key, fixed
452 * side effects - anything below ascii 13 is discarded, ':' discarded,
453 * high ascii is dropped to lower half of ascii table
460 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
463 if(c
!= ':' && c
!= ',' && c
> ' ')
474 * ouput - the same key, fixed
475 * side effects - high ascii dropped to lower half of table,
476 * CR/LF/':' are dropped
479 fix_key_remote(char *arg
)
483 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
486 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
496 * The handlers for each specific mode.
499 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
500 int alevel
, int parc
, int *parn
,
501 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
503 if(*errors
& SM_ERR_UNKNOWN
)
505 *errors
|= SM_ERR_UNKNOWN
;
506 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
510 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
511 int alevel
, int parc
, int *parn
,
512 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
517 struct DictionaryIter iter
;
519 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
521 if (IsOverride(source_p
))
525 if(!(*errors
& SM_ERR_NOOPS
))
526 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
527 me
.name
, source_p
->name
, chptr
->chname
);
528 *errors
|= SM_ERR_NOOPS
;
533 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
537 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
539 /* if +f is disabled, ignore an attempt to set +QF locally */
540 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
541 (c
== 'Q' || c
== 'F'))
544 chptr
->mode
.mode
|= mode_type
;
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
].override
= override
;
553 mode_changes
[mode_count
++].arg
= NULL
;
555 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
557 /* cleanup metadata when the related mode is removed */
560 DICTIONARY_FOREACH(md
, &iter
, chptr
->metadata
)
562 if(!strcmp(md
->value
, "KICKNOREJOIN"))
563 channel_metadata_delete(chptr
, md
->name
, 0);
567 channel_metadata_delete(chptr
, "NOREPEAT", 0);
569 chptr
->mode
.mode
&= ~mode_type
;
571 mode_changes
[mode_count
].letter
= c
;
572 mode_changes
[mode_count
].dir
= MODE_DEL
;
573 mode_changes
[mode_count
].caps
= 0;
574 mode_changes
[mode_count
].nocaps
= 0;
575 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
576 mode_changes
[mode_count
].id
= NULL
;
577 mode_changes
[mode_count
].override
= override
;
578 mode_changes
[mode_count
++].arg
= NULL
;
583 chm_orphaned(struct Client
*source_p
, struct Channel
*chptr
,
584 int alevel
, int parc
, int *parn
,
585 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
587 if(MyClient(source_p
))
590 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
592 chptr
->mode
.mode
|= mode_type
;
594 mode_changes
[mode_count
].letter
= c
;
595 mode_changes
[mode_count
].dir
= MODE_ADD
;
596 mode_changes
[mode_count
].caps
= 0;
597 mode_changes
[mode_count
].nocaps
= 0;
598 mode_changes
[mode_count
].id
= NULL
;
599 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
600 mode_changes
[mode_count
++].arg
= NULL
;
602 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
604 chptr
->mode
.mode
&= ~mode_type
;
606 mode_changes
[mode_count
].letter
= c
;
607 mode_changes
[mode_count
].dir
= MODE_DEL
;
608 mode_changes
[mode_count
].caps
= 0;
609 mode_changes
[mode_count
].nocaps
= 0;
610 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
611 mode_changes
[mode_count
].id
= NULL
;
612 mode_changes
[mode_count
++].arg
= NULL
;
617 chm_hidden(struct Client
*source_p
, struct Channel
*chptr
,
618 int alevel
, int parc
, int *parn
,
619 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
621 if(!IsOper(source_p
) && !IsServer(source_p
))
623 if(!(*errors
& SM_ERR_NOPRIVS
))
624 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
625 *errors
|= SM_ERR_NOPRIVS
;
628 if(MyClient(source_p
) && !IsOperAdmin(source_p
))
630 if(!(*errors
& SM_ERR_NOPRIVS
))
631 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
632 source_p
->name
, "cmodes");
633 *errors
|= SM_ERR_NOPRIVS
;
637 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
641 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
643 chptr
->mode
.mode
|= mode_type
;
645 mode_changes
[mode_count
].letter
= c
;
646 mode_changes
[mode_count
].dir
= MODE_ADD
;
647 mode_changes
[mode_count
].caps
= 0;
648 mode_changes
[mode_count
].nocaps
= 0;
649 mode_changes
[mode_count
].id
= NULL
;
650 mode_changes
[mode_count
].mems
= ONLY_OPERS
;
651 mode_changes
[mode_count
].override
= 0;
652 mode_changes
[mode_count
++].arg
= NULL
;
654 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
656 chptr
->mode
.mode
&= ~mode_type
;
658 mode_changes
[mode_count
].letter
= c
;
659 mode_changes
[mode_count
].dir
= MODE_DEL
;
660 mode_changes
[mode_count
].caps
= 0;
661 mode_changes
[mode_count
].nocaps
= 0;
662 mode_changes
[mode_count
].mems
= ONLY_OPERS
;
663 mode_changes
[mode_count
].id
= NULL
;
664 mode_changes
[mode_count
].override
= 0;
665 mode_changes
[mode_count
++].arg
= NULL
;
670 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
671 int alevel
, int parc
, int *parn
,
672 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
676 if(!IsOper(source_p
) && !IsServer(source_p
))
678 if(!(*errors
& SM_ERR_NOPRIVS
))
679 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
680 *errors
|= SM_ERR_NOPRIVS
;
683 if(MyClient(source_p
) && !IsOperResv(source_p
))
685 if(!(*errors
& SM_ERR_NOPRIVS
))
686 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
687 source_p
->name
, "resv");
688 *errors
|= SM_ERR_NOPRIVS
;
692 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
694 if (IsOverride(source_p
))
698 if(!(*errors
& SM_ERR_NOOPS
))
699 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
700 me
.name
, source_p
->name
, chptr
->chname
);
701 *errors
|= SM_ERR_NOOPS
;
706 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
710 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
712 chptr
->mode
.mode
|= mode_type
;
714 mode_changes
[mode_count
].letter
= c
;
715 mode_changes
[mode_count
].dir
= MODE_ADD
;
716 mode_changes
[mode_count
].caps
= 0;
717 mode_changes
[mode_count
].nocaps
= 0;
718 mode_changes
[mode_count
].id
= NULL
;
719 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
720 mode_changes
[mode_count
].override
= override
;
721 mode_changes
[mode_count
++].arg
= NULL
;
723 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
725 chptr
->mode
.mode
&= ~mode_type
;
727 mode_changes
[mode_count
].letter
= c
;
728 mode_changes
[mode_count
].dir
= MODE_DEL
;
729 mode_changes
[mode_count
].caps
= 0;
730 mode_changes
[mode_count
].nocaps
= 0;
731 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
732 mode_changes
[mode_count
].override
= override
;
733 mode_changes
[mode_count
].id
= NULL
;
734 mode_changes
[mode_count
++].arg
= NULL
;
739 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
740 int alevel
, int parc
, int *parn
,
741 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
744 const char *raw_mask
;
758 list
= &chptr
->banlist
;
759 errorval
= SM_ERR_RPL_B
;
760 rpl_list
= RPL_BANLIST
;
761 rpl_endlist
= RPL_ENDOFBANLIST
;
767 /* if +e is disabled, allow all but +e locally */
768 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
769 ((dir
== MODE_ADD
) && (parc
> *parn
)))
772 list
= &chptr
->exceptlist
;
773 errorval
= SM_ERR_RPL_E
;
774 rpl_list
= RPL_EXCEPTLIST
;
775 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
778 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
785 /* if +I is disabled, allow all but +I locally */
786 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
787 (dir
== MODE_ADD
) && (parc
> *parn
))
790 list
= &chptr
->invexlist
;
791 errorval
= SM_ERR_RPL_I
;
792 rpl_list
= RPL_INVITELIST
;
793 rpl_endlist
= RPL_ENDOFINVITELIST
;
796 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
803 list
= &chptr
->quietlist
;
804 errorval
= SM_ERR_RPL_Q
;
805 rpl_list
= RPL_QUIETLIST
;
806 rpl_endlist
= RPL_ENDOFQUIETLIST
;
812 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
817 if(dir
== 0 || parc
<= *parn
)
819 if((*errors
& errorval
) != 0)
823 /* non-ops cant see +eI lists.. */
824 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
&& mode_type
!= CHFL_BAN
&&
825 mode_type
!= CHFL_QUIET
)
827 if(IsOverride(source_p
))
829 sendto_wallops_flags(UMODE_WALLOP
, &me
,
830 "%s is overriding modes on %s: (%s list)",
831 get_oper_name(source_p
), chptr
->chname
, mode_type
== CHFL_INVEX
? "invex" : "exempt");
832 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
833 ":%s WALLOPS :%s is overriding modes on %s: (%s list)",
834 me
.name
, get_oper_name(source_p
), chptr
->chname
, mode_type
== CHFL_INVEX
? "invex" : "exempt");
839 if(!(*errors
& SM_ERR_NOOPS
))
840 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
841 me
.name
, source_p
->name
, chptr
->chname
);
842 *errors
|= SM_ERR_NOOPS
;
847 RB_DLINK_FOREACH(ptr
, list
->head
)
850 sendto_one(source_p
, form_str(rpl_list
),
851 me
.name
, source_p
->name
, chptr
->chname
,
852 banptr
->banstr
, banptr
->who
, banptr
->when
);
854 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
858 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
860 if(IsOverride(source_p
))
865 if(!(*errors
& SM_ERR_NOOPS
))
866 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
867 me
.name
, source_p
->name
, chptr
->chname
);
868 *errors
|= SM_ERR_NOOPS
;
873 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
876 raw_mask
= parv
[(*parn
)];
879 /* empty ban, or starts with ':' which messes up s2s, ignore it */
880 if(EmptyString(raw_mask
) || *raw_mask
== ':')
883 if(!MyClient(source_p
))
885 if(strchr(raw_mask
, ' '))
891 mask
= pretty_mask(raw_mask
);
893 /* we'd have problems parsing this, hyb6 does it too
894 * also make sure it will always fit on a line with channel
897 if(strlen(mask
) > IRCD_MIN(BANLEN
, MODEBUFLEN
- 5))
900 /* if we're adding a NEW id */
903 if (*mask
== '$' && MyClient(source_p
))
905 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
906 /* XXX perhaps return an error message here */
910 /* dont allow local clients to overflow the banlist, dont
911 * let remote servers set duplicate bans
913 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
916 mode_changes
[mode_count
].letter
= c
;
917 mode_changes
[mode_count
].dir
= MODE_ADD
;
918 mode_changes
[mode_count
].caps
= caps
;
919 mode_changes
[mode_count
].nocaps
= 0;
920 mode_changes
[mode_count
].mems
= mems
;
921 mode_changes
[mode_count
].id
= NULL
;
922 mode_changes
[mode_count
].override
= override
;
923 mode_changes
[mode_count
++].arg
= mask
;
925 else if(dir
== MODE_DEL
)
927 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
929 /* mask isn't a valid ban, check raw_mask */
930 if(del_id(chptr
, raw_mask
, list
, mode_type
))
934 mode_changes
[mode_count
].letter
= c
;
935 mode_changes
[mode_count
].dir
= MODE_DEL
;
936 mode_changes
[mode_count
].caps
= caps
;
937 mode_changes
[mode_count
].nocaps
= 0;
938 mode_changes
[mode_count
].mems
= mems
;
939 mode_changes
[mode_count
].id
= NULL
;
940 mode_changes
[mode_count
].override
= override
;
941 mode_changes
[mode_count
++].arg
= mask
;
946 chm_admin(struct Client
*source_p
, struct Channel
*chptr
,
947 int alevel
, int parc
, int *parn
,
948 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
950 struct membership
*mstptr
;
951 const char *adminnick
;
952 struct Client
*targ_p
;
955 if(!ConfigChannel
.use_admin
)
957 if(*errors
& SM_ERR_UNKNOWN
)
959 *errors
|= SM_ERR_UNKNOWN
;
960 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
964 if(alevel
!= CHFL_ADMIN
)
966 if(IsOverride(source_p
))
971 if(!(*errors
& SM_ERR_NOOPS
))
972 sendto_one(source_p
, ":%s 482 %s %s :You're not a channel administrator", me
.name
, source_p
->name
, chptr
->chname
);
973 *errors
|= SM_ERR_NOOPS
;
978 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
981 adminnick
= parv
[(*parn
)];
985 if(EmptyString(adminnick
))
987 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
991 if((targ_p
= find_chasing(source_p
, adminnick
, NULL
)) == NULL
)
996 mstptr
= find_channel_membership(chptr
, targ_p
);
1000 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1001 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1002 form_str(ERR_USERNOTINCHANNEL
), adminnick
, chptr
->chname
);
1003 *errors
|= SM_ERR_NOTONCHANNEL
;
1007 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1012 if(targ_p
== source_p
)
1014 no_override_deop
= 1;
1015 /* Don't reject modes from remote. It desyncs, and this is perfectly
1016 * legitimate from a remote override oper.
1022 mode_changes
[mode_count
].letter
= c
;
1023 mode_changes
[mode_count
].dir
= MODE_ADD
;
1024 mode_changes
[mode_count
].caps
= 0;
1025 mode_changes
[mode_count
].nocaps
= 0;
1026 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1027 mode_changes
[mode_count
].id
= targ_p
->id
;
1028 mode_changes
[mode_count
].arg
= targ_p
->name
;
1029 mode_changes
[mode_count
].override
= override
;
1030 mode_changes
[mode_count
++].client
= targ_p
;
1032 mstptr
->flags
|= CHFL_ADMIN
;
1036 if(MyClient(source_p
) && IsService(targ_p
))
1038 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1039 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1043 mode_changes
[mode_count
].letter
= c
;
1044 mode_changes
[mode_count
].dir
= MODE_DEL
;
1045 mode_changes
[mode_count
].caps
= 0;
1046 mode_changes
[mode_count
].nocaps
= 0;
1047 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1048 mode_changes
[mode_count
].id
= targ_p
->id
;
1049 mode_changes
[mode_count
].arg
= targ_p
->name
;
1050 mode_changes
[mode_count
].override
= override
;
1051 mode_changes
[mode_count
++].client
= targ_p
;
1053 mstptr
->flags
&= ~CHFL_ADMIN
;
1058 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
1059 int alevel
, int parc
, int *parn
,
1060 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1062 struct membership
*mstptr
;
1064 struct Client
*targ_p
;
1067 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
)
1069 if(IsOverride(source_p
))
1074 if(!(*errors
& SM_ERR_NOOPS
))
1075 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1076 me
.name
, source_p
->name
, chptr
->chname
);
1077 *errors
|= SM_ERR_NOOPS
;
1082 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
1085 opnick
= parv
[(*parn
)];
1089 if(EmptyString(opnick
))
1091 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1095 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
1100 mstptr
= find_channel_membership(chptr
, targ_p
);
1104 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1105 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1106 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
1107 *errors
|= SM_ERR_NOTONCHANNEL
;
1111 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1116 if(targ_p
== source_p
)
1118 no_override_deop
= 1;
1119 /* Don't reject modes from remote. It desyncs, and this is perfectly
1120 * legitimate from a remote override oper.
1126 mode_changes
[mode_count
].letter
= c
;
1127 mode_changes
[mode_count
].dir
= MODE_ADD
;
1128 mode_changes
[mode_count
].caps
= 0;
1129 mode_changes
[mode_count
].nocaps
= 0;
1130 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1131 mode_changes
[mode_count
].id
= targ_p
->id
;
1132 mode_changes
[mode_count
].arg
= targ_p
->name
;
1133 mode_changes
[mode_count
].override
= override
;
1134 mode_changes
[mode_count
++].client
= targ_p
;
1136 mstptr
->flags
|= CHFL_CHANOP
;
1140 if(MyClient(source_p
) && IsService(targ_p
))
1142 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1143 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1147 mode_changes
[mode_count
].letter
= c
;
1148 mode_changes
[mode_count
].dir
= MODE_DEL
;
1149 mode_changes
[mode_count
].caps
= 0;
1150 mode_changes
[mode_count
].nocaps
= 0;
1151 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1152 mode_changes
[mode_count
].id
= targ_p
->id
;
1153 mode_changes
[mode_count
].arg
= targ_p
->name
;
1154 mode_changes
[mode_count
].override
= override
;
1155 mode_changes
[mode_count
++].client
= targ_p
;
1157 mstptr
->flags
&= ~CHFL_CHANOP
;
1162 chm_halfop(struct Client
*source_p
, struct Channel
*chptr
,
1163 int alevel
, int parc
, int *parn
,
1164 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1166 struct membership
*mstptr
;
1167 const char *halfopnick
;
1168 struct Client
*targ_p
;
1171 if(!ConfigChannel
.use_halfop
)
1173 if(*errors
& SM_ERR_UNKNOWN
)
1175 *errors
|= SM_ERR_UNKNOWN
;
1176 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
1180 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
)
1182 if(IsOverride(source_p
))
1187 if(!(*errors
& SM_ERR_NOOPS
))
1188 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1189 me
.name
, source_p
->name
, chptr
->chname
);
1190 *errors
|= SM_ERR_NOOPS
;
1195 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
1198 halfopnick
= parv
[(*parn
)];
1202 if(EmptyString(halfopnick
))
1204 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1208 if((targ_p
= find_chasing(source_p
, halfopnick
, NULL
)) == NULL
)
1213 mstptr
= find_channel_membership(chptr
, targ_p
);
1217 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1218 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1219 form_str(ERR_USERNOTINCHANNEL
), halfopnick
, chptr
->chname
);
1220 *errors
|= SM_ERR_NOTONCHANNEL
;
1224 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1229 if(targ_p
== source_p
)
1231 no_override_deop
= 1;
1232 /* Don't reject modes from remote. It desyncs, and this is perfectly
1233 * legitimate from a remote override oper.
1239 mode_changes
[mode_count
].letter
= c
;
1240 mode_changes
[mode_count
].dir
= MODE_ADD
;
1241 mode_changes
[mode_count
].caps
= 0;
1242 mode_changes
[mode_count
].nocaps
= 0;
1243 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1244 mode_changes
[mode_count
].id
= targ_p
->id
;
1245 mode_changes
[mode_count
].arg
= targ_p
->name
;
1246 mode_changes
[mode_count
].override
= override
;
1247 mode_changes
[mode_count
++].client
= targ_p
;
1249 mstptr
->flags
|= CHFL_HALFOP
;
1253 if(MyClient(source_p
) && IsService(targ_p
))
1255 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1256 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1260 mode_changes
[mode_count
].letter
= c
;
1261 mode_changes
[mode_count
].dir
= MODE_DEL
;
1262 mode_changes
[mode_count
].caps
= 0;
1263 mode_changes
[mode_count
].nocaps
= 0;
1264 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1265 mode_changes
[mode_count
].id
= targ_p
->id
;
1266 mode_changes
[mode_count
].arg
= targ_p
->name
;
1267 mode_changes
[mode_count
].override
= override
;
1268 mode_changes
[mode_count
++].client
= targ_p
;
1270 mstptr
->flags
&= ~CHFL_HALFOP
;
1275 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
1276 int alevel
, int parc
, int *parn
,
1277 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1279 struct membership
*mstptr
;
1281 struct Client
*targ_p
;
1284 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1286 if(IsOverride(source_p
))
1291 if(!(*errors
& SM_ERR_NOOPS
))
1292 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1293 me
.name
, source_p
->name
, chptr
->chname
);
1294 *errors
|= SM_ERR_NOOPS
;
1299 if((dir
== MODE_QUERY
) || parc
<= *parn
)
1302 opnick
= parv
[(*parn
)];
1306 if(EmptyString(opnick
))
1308 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1312 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
1317 mstptr
= find_channel_membership(chptr
, targ_p
);
1321 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1322 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1323 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
1324 *errors
|= SM_ERR_NOTONCHANNEL
;
1328 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1333 mode_changes
[mode_count
].letter
= c
;
1334 mode_changes
[mode_count
].dir
= MODE_ADD
;
1335 mode_changes
[mode_count
].caps
= 0;
1336 mode_changes
[mode_count
].nocaps
= 0;
1337 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1338 mode_changes
[mode_count
].id
= targ_p
->id
;
1339 mode_changes
[mode_count
].arg
= targ_p
->name
;
1340 mode_changes
[mode_count
].override
= override
;
1341 mode_changes
[mode_count
++].client
= targ_p
;
1343 mstptr
->flags
|= CHFL_VOICE
;
1347 mode_changes
[mode_count
].letter
= 'v';
1348 mode_changes
[mode_count
].dir
= MODE_DEL
;
1349 mode_changes
[mode_count
].caps
= 0;
1350 mode_changes
[mode_count
].nocaps
= 0;
1351 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1352 mode_changes
[mode_count
].id
= targ_p
->id
;
1353 mode_changes
[mode_count
].arg
= targ_p
->name
;
1354 mode_changes
[mode_count
].override
= override
;
1355 mode_changes
[mode_count
++].client
= targ_p
;
1357 mstptr
->flags
&= ~CHFL_VOICE
;
1362 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
1363 int alevel
, int parc
, int *parn
,
1364 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1367 static char limitstr
[30];
1371 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1373 if(IsOverride(source_p
))
1377 if(!(*errors
& SM_ERR_NOOPS
))
1378 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1379 me
.name
, source_p
->name
, chptr
->chname
);
1380 *errors
|= SM_ERR_NOOPS
;
1385 if(dir
== MODE_QUERY
)
1388 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1391 if((dir
== MODE_ADD
) && parc
> *parn
)
1393 lstr
= parv
[(*parn
)];
1396 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
1399 rb_sprintf(limitstr
, "%d", limit
);
1401 mode_changes
[mode_count
].letter
= c
;
1402 mode_changes
[mode_count
].dir
= MODE_ADD
;
1403 mode_changes
[mode_count
].caps
= 0;
1404 mode_changes
[mode_count
].nocaps
= 0;
1405 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1406 mode_changes
[mode_count
].id
= NULL
;
1407 mode_changes
[mode_count
].override
= override
;
1408 mode_changes
[mode_count
++].arg
= limitstr
;
1410 chptr
->mode
.limit
= limit
;
1412 else if(dir
== MODE_DEL
)
1414 if(!chptr
->mode
.limit
)
1417 chptr
->mode
.limit
= 0;
1419 mode_changes
[mode_count
].letter
= c
;
1420 mode_changes
[mode_count
].dir
= MODE_DEL
;
1421 mode_changes
[mode_count
].caps
= 0;
1422 mode_changes
[mode_count
].nocaps
= 0;
1423 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1424 mode_changes
[mode_count
].id
= NULL
;
1425 mode_changes
[mode_count
].override
= override
;
1426 mode_changes
[mode_count
++].arg
= NULL
;
1431 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
1432 int alevel
, int parc
, int *parn
,
1433 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1435 int joins
= 0, timeslice
= 0;
1438 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1440 if(IsOverride(source_p
))
1445 if(!(*errors
& SM_ERR_NOOPS
))
1446 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1447 me
.name
, source_p
->name
, chptr
->chname
);
1448 *errors
|= SM_ERR_NOOPS
;
1453 if(dir
== MODE_QUERY
)
1456 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1459 if((dir
== MODE_ADD
) && parc
> *parn
)
1461 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
1463 if(!joins
|| !timeslice
)
1466 mode_changes
[mode_count
].letter
= c
;
1467 mode_changes
[mode_count
].dir
= MODE_ADD
;
1468 mode_changes
[mode_count
].caps
= 0;
1469 mode_changes
[mode_count
].nocaps
= 0;
1470 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1471 mode_changes
[mode_count
].id
= NULL
;
1472 mode_changes
[mode_count
].override
= override
;
1473 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
1477 chptr
->mode
.join_num
= joins
;
1478 chptr
->mode
.join_time
= timeslice
;
1480 else if(dir
== MODE_DEL
)
1482 if(!chptr
->mode
.join_num
)
1485 chptr
->mode
.join_num
= 0;
1486 chptr
->mode
.join_time
= 0;
1487 chptr
->join_count
= 0;
1488 chptr
->join_delta
= 0;
1490 mode_changes
[mode_count
].letter
= c
;
1491 mode_changes
[mode_count
].dir
= MODE_DEL
;
1492 mode_changes
[mode_count
].caps
= 0;
1493 mode_changes
[mode_count
].nocaps
= 0;
1494 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1495 mode_changes
[mode_count
].id
= NULL
;
1496 mode_changes
[mode_count
].override
= override
;
1497 mode_changes
[mode_count
++].arg
= NULL
;
1502 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
1503 int alevel
, int parc
, int *parn
,
1504 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1506 struct Channel
*targptr
= NULL
;
1507 struct membership
*msptr
;
1508 const char *forward
;
1511 /* if +f is disabled, ignore local attempts to set it */
1512 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
1513 (dir
== MODE_ADD
) && (parc
> *parn
))
1516 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
1518 if (!(*errors
& SM_ERR_RPL_F
))
1520 if (*chptr
->mode
.forward
== '\0')
1521 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
1523 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
1524 *errors
|= SM_ERR_RPL_F
;
1529 #ifndef FORWARD_OPERONLY
1530 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1532 if(IsOverride(source_p
))
1536 if(!(*errors
& SM_ERR_NOOPS
))
1537 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1538 me
.name
, source_p
->name
, chptr
->chname
);
1539 *errors
|= SM_ERR_NOOPS
;
1544 if(!IsOper(source_p
) && !IsServer(source_p
))
1546 if(!(*errors
& SM_ERR_NOPRIVS
))
1547 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
1548 *errors
|= SM_ERR_NOPRIVS
;
1553 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1556 if(dir
== MODE_ADD
&& parc
> *parn
)
1558 forward
= parv
[(*parn
)];
1561 if(EmptyString(forward
))
1563 if(!check_channel_name(forward
) ||
1564 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1566 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1569 /* don't forward to inconsistent target -- jilles */
1570 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
1572 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
1573 form_str(ERR_BADCHANNAME
), forward
);
1576 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1578 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1579 form_str(ERR_NOSUCHCHANNEL
), forward
);
1582 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1584 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1587 if(IsOverride(source_p
))
1591 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1592 me
.name
, source_p
->name
, targptr
->chname
);
1598 rb_strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1600 mode_changes
[mode_count
].letter
= c
;
1601 mode_changes
[mode_count
].dir
= MODE_ADD
;
1602 mode_changes
[mode_count
].caps
= 0;
1603 mode_changes
[mode_count
].nocaps
= 0;
1604 mode_changes
[mode_count
].mems
= ConfigChannel
.use_forward
? ALL_MEMBERS
: ONLY_SERVERS
;
1605 mode_changes
[mode_count
].id
= NULL
;
1606 mode_changes
[mode_count
].override
= override
;
1607 mode_changes
[mode_count
++].arg
= forward
;
1609 else if(dir
== MODE_DEL
)
1611 if(!(*chptr
->mode
.forward
))
1614 *chptr
->mode
.forward
= '\0';
1616 mode_changes
[mode_count
].letter
= c
;
1617 mode_changes
[mode_count
].dir
= MODE_DEL
;
1618 mode_changes
[mode_count
].caps
= 0;
1619 mode_changes
[mode_count
].nocaps
= 0;
1620 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1621 mode_changes
[mode_count
].id
= NULL
;
1622 mode_changes
[mode_count
].override
= override
;
1623 mode_changes
[mode_count
++].arg
= NULL
;
1628 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1629 int alevel
, int parc
, int *parn
,
1630 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1635 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1637 if(IsOverride(source_p
))
1641 if(!(*errors
& SM_ERR_NOOPS
))
1642 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1643 me
.name
, source_p
->name
, chptr
->chname
);
1644 *errors
|= SM_ERR_NOOPS
;
1649 if(dir
== MODE_QUERY
)
1652 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1655 if((dir
== MODE_ADD
) && parc
> *parn
)
1657 key
= LOCAL_COPY(parv
[(*parn
)]);
1660 if(MyClient(source_p
))
1663 fix_key_remote(key
);
1665 if(EmptyString(key
))
1668 s_assert(key
[0] != ' ');
1669 rb_strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1671 mode_changes
[mode_count
].letter
= c
;
1672 mode_changes
[mode_count
].dir
= MODE_ADD
;
1673 mode_changes
[mode_count
].caps
= 0;
1674 mode_changes
[mode_count
].nocaps
= 0;
1675 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1676 mode_changes
[mode_count
].id
= NULL
;
1677 mode_changes
[mode_count
].override
= override
;
1678 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1680 else if(dir
== MODE_DEL
)
1682 static char splat
[] = "*";
1688 if(!(*chptr
->mode
.key
))
1691 /* hack time. when we get a +k-k mode, the +k arg is
1692 * chptr->mode.key, which the -k sets to \0, so hunt for a
1693 * +k when we get a -k, and set the arg to splat. --anfl
1695 for(i
= 0; i
< mode_count
; i
++)
1697 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1698 mode_changes
[i
].arg
= splat
;
1701 *chptr
->mode
.key
= 0;
1703 mode_changes
[mode_count
].letter
= c
;
1704 mode_changes
[mode_count
].dir
= MODE_DEL
;
1705 mode_changes
[mode_count
].caps
= 0;
1706 mode_changes
[mode_count
].nocaps
= 0;
1707 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1708 mode_changes
[mode_count
].id
= NULL
;
1709 mode_changes
[mode_count
].override
= override
;
1710 mode_changes
[mode_count
++].arg
= "*";
1715 chm_regonly(struct Client
*source_p
, struct Channel
*chptr
,
1716 int alevel
, int parc
, int *parn
,
1717 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1721 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1723 if(IsOverride(source_p
))
1727 if(!(*errors
& SM_ERR_NOOPS
))
1728 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1729 me
.name
, source_p
->name
, chptr
->chname
);
1730 *errors
|= SM_ERR_NOOPS
;
1735 if(dir
== MODE_QUERY
)
1738 if(((dir
== MODE_ADD
) && (chptr
->mode
.mode
& mode_type
)) ||
1739 ((dir
== MODE_DEL
) && !(chptr
->mode
.mode
& mode_type
)))
1742 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1746 chptr
->mode
.mode
|= mode_type
;
1748 chptr
->mode
.mode
&= ~mode_type
;
1750 mode_changes
[mode_count
].letter
= c
;
1751 mode_changes
[mode_count
].dir
= dir
;
1752 mode_changes
[mode_count
].caps
= CAP_SERVICE
;
1753 mode_changes
[mode_count
].nocaps
= 0;
1754 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1755 mode_changes
[mode_count
].id
= NULL
;
1756 mode_changes
[mode_count
].override
= override
;
1757 mode_changes
[mode_count
++].arg
= NULL
;
1761 struct ChannelMode chmode_table
[256] =
1763 {chm_nosuch
, 0 }, /* 0x00 */
1764 {chm_nosuch
, 0 }, /* 0x01 */
1765 {chm_nosuch
, 0 }, /* 0x02 */
1766 {chm_nosuch
, 0 }, /* 0x03 */
1767 {chm_nosuch
, 0 }, /* 0x04 */
1768 {chm_nosuch
, 0 }, /* 0x05 */
1769 {chm_nosuch
, 0 }, /* 0x06 */
1770 {chm_nosuch
, 0 }, /* 0x07 */
1771 {chm_nosuch
, 0 }, /* 0x08 */
1772 {chm_nosuch
, 0 }, /* 0x09 */
1773 {chm_nosuch
, 0 }, /* 0x0a */
1774 {chm_nosuch
, 0 }, /* 0x0b */
1775 {chm_nosuch
, 0 }, /* 0x0c */
1776 {chm_nosuch
, 0 }, /* 0x0d */
1777 {chm_nosuch
, 0 }, /* 0x0e */
1778 {chm_nosuch
, 0 }, /* 0x0f */
1779 {chm_nosuch
, 0 }, /* 0x10 */
1780 {chm_nosuch
, 0 }, /* 0x11 */
1781 {chm_nosuch
, 0 }, /* 0x12 */
1782 {chm_nosuch
, 0 }, /* 0x13 */
1783 {chm_nosuch
, 0 }, /* 0x14 */
1784 {chm_nosuch
, 0 }, /* 0x15 */
1785 {chm_nosuch
, 0 }, /* 0x16 */
1786 {chm_nosuch
, 0 }, /* 0x17 */
1787 {chm_nosuch
, 0 }, /* 0x18 */
1788 {chm_nosuch
, 0 }, /* 0x19 */
1789 {chm_nosuch
, 0 }, /* 0x1a */
1790 {chm_nosuch
, 0 }, /* 0x1b */
1791 {chm_nosuch
, 0 }, /* 0x1c */
1792 {chm_nosuch
, 0 }, /* 0x1d */
1793 {chm_nosuch
, 0 }, /* 0x1e */
1794 {chm_nosuch
, 0 }, /* 0x1f */
1795 {chm_nosuch
, 0 }, /* 0x20 */
1796 {chm_nosuch
, 0 }, /* 0x21 */
1797 {chm_nosuch
, 0 }, /* 0x22 */
1798 {chm_nosuch
, 0 }, /* 0x23 */
1799 {chm_nosuch
, 0 }, /* 0x24 */
1800 {chm_nosuch
, 0 }, /* 0x25 */
1801 {chm_nosuch
, 0 }, /* 0x26 */
1802 {chm_nosuch
, 0 }, /* 0x27 */
1803 {chm_nosuch
, 0 }, /* 0x28 */
1804 {chm_nosuch
, 0 }, /* 0x29 */
1805 {chm_nosuch
, 0 }, /* 0x2a */
1806 {chm_nosuch
, 0 }, /* 0x2b */
1807 {chm_nosuch
, 0 }, /* 0x2c */
1808 {chm_nosuch
, 0 }, /* 0x2d */
1809 {chm_nosuch
, 0 }, /* 0x2e */
1810 {chm_nosuch
, 0 }, /* 0x2f */
1811 {chm_nosuch
, 0 }, /* 0x30 */
1812 {chm_nosuch
, 0 }, /* 0x31 */
1813 {chm_nosuch
, 0 }, /* 0x32 */
1814 {chm_nosuch
, 0 }, /* 0x33 */
1815 {chm_nosuch
, 0 }, /* 0x34 */
1816 {chm_nosuch
, 0 }, /* 0x35 */
1817 {chm_nosuch
, 0 }, /* 0x36 */
1818 {chm_nosuch
, 0 }, /* 0x37 */
1819 {chm_nosuch
, 0 }, /* 0x38 */
1820 {chm_nosuch
, 0 }, /* 0x39 */
1821 {chm_nosuch
, 0 }, /* 0x3a */
1822 {chm_nosuch
, 0 }, /* 0x3b */
1823 {chm_nosuch
, 0 }, /* 0x3c */
1824 {chm_nosuch
, 0 }, /* 0x3d */
1825 {chm_nosuch
, 0 }, /* 0x3e */
1826 {chm_nosuch
, 0 }, /* 0x3f */
1828 {chm_nosuch
, 0 }, /* @ */
1829 {chm_nosuch
, 0 }, /* A */
1830 {chm_nosuch
, 0 }, /* B */
1831 {chm_simple
, MODE_NOCTCP
}, /* C */
1832 {chm_simple
, MODE_NOACTION
}, /* D */
1833 {chm_simple
, MODE_NOKICK
}, /* E */
1834 {chm_simple
, MODE_FREETARGET
}, /* F */
1835 {chm_simple
, MODE_NOCAPS
}, /* G */
1836 {chm_nosuch
, 0 }, /* H */
1837 {chm_ban
, CHFL_INVEX
}, /* I */
1838 {chm_simple
, MODE_NOREJOIN
}, /* J */
1839 {chm_simple
, MODE_NOREPEAT
}, /* K */
1840 {chm_staff
, MODE_EXLIMIT
}, /* L */
1841 {chm_hidden
, MODE_NOOPERKICK
}, /* M */
1842 {chm_simple
, MODE_NONICK
}, /* N */
1843 {chm_nosuch
, 0 }, /* O */
1844 {chm_staff
, MODE_PERMANENT
}, /* P */
1845 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1846 {chm_nosuch
, 0 }, /* R */
1847 {chm_nosuch
, 0 }, /* S */
1848 {chm_simple
, MODE_NONOTICE
}, /* T */
1849 {chm_nosuch
, 0 }, /* U */
1850 {chm_nosuch
, 0 }, /* V */
1851 {chm_nosuch
, 0 }, /* W */
1852 {chm_nosuch
, 0 }, /* X */
1853 {chm_nosuch
, 0 }, /* Y */
1854 {chm_nosuch
, 0 }, /* Z */
1861 {chm_admin
, 0 }, /* a */
1862 {chm_ban
, CHFL_BAN
}, /* b */
1863 {chm_simple
, MODE_NOCOLOR
}, /* c */
1864 {chm_nosuch
, 0 }, /* d */
1865 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1866 {chm_forward
, 0 }, /* f */
1867 {chm_simple
, MODE_FREEINVITE
}, /* g */
1868 {chm_halfop
, 0 }, /* h */
1869 {chm_simple
, MODE_INVITEONLY
}, /* i */
1870 {chm_throttle
, 0 }, /* j */
1871 {chm_key
, 0 }, /* k */
1872 {chm_limit
, 0 }, /* l */
1873 {chm_simple
, MODE_MODERATED
}, /* m */
1874 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1875 {chm_op
, 0 }, /* o */
1876 {chm_simple
, MODE_PRIVATE
}, /* p */
1877 {chm_ban
, CHFL_QUIET
}, /* q */
1878 {chm_regonly
, MODE_REGONLY
}, /* r */
1879 {chm_simple
, MODE_SECRET
}, /* s */
1880 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1881 {chm_nosuch
, 0 }, /* u */
1882 {chm_voice
, 0 }, /* v */
1883 {chm_nosuch
, 0 }, /* w */
1884 {chm_nosuch
, 0 }, /* x */
1885 {chm_nosuch
, 0 }, /* y */
1886 {chm_simple
, MODE_OPMODERATE
}, /* z */
1888 {chm_nosuch
, 0 }, /* 0x7b */
1889 {chm_nosuch
, 0 }, /* 0x7c */
1890 {chm_nosuch
, 0 }, /* 0x7d */
1891 {chm_nosuch
, 0 }, /* 0x7e */
1892 {chm_nosuch
, 0 }, /* 0x7f */
1894 {chm_nosuch
, 0 }, /* 0x80 */
1895 {chm_nosuch
, 0 }, /* 0x81 */
1896 {chm_nosuch
, 0 }, /* 0x82 */
1897 {chm_nosuch
, 0 }, /* 0x83 */
1898 {chm_nosuch
, 0 }, /* 0x84 */
1899 {chm_nosuch
, 0 }, /* 0x85 */
1900 {chm_nosuch
, 0 }, /* 0x86 */
1901 {chm_nosuch
, 0 }, /* 0x87 */
1902 {chm_nosuch
, 0 }, /* 0x88 */
1903 {chm_nosuch
, 0 }, /* 0x89 */
1904 {chm_nosuch
, 0 }, /* 0x8a */
1905 {chm_nosuch
, 0 }, /* 0x8b */
1906 {chm_nosuch
, 0 }, /* 0x8c */
1907 {chm_nosuch
, 0 }, /* 0x8d */
1908 {chm_nosuch
, 0 }, /* 0x8e */
1909 {chm_nosuch
, 0 }, /* 0x8f */
1911 {chm_nosuch
, 0 }, /* 0x90 */
1912 {chm_nosuch
, 0 }, /* 0x91 */
1913 {chm_nosuch
, 0 }, /* 0x92 */
1914 {chm_nosuch
, 0 }, /* 0x93 */
1915 {chm_nosuch
, 0 }, /* 0x94 */
1916 {chm_nosuch
, 0 }, /* 0x95 */
1917 {chm_nosuch
, 0 }, /* 0x96 */
1918 {chm_nosuch
, 0 }, /* 0x97 */
1919 {chm_nosuch
, 0 }, /* 0x98 */
1920 {chm_nosuch
, 0 }, /* 0x99 */
1921 {chm_nosuch
, 0 }, /* 0x9a */
1922 {chm_nosuch
, 0 }, /* 0x9b */
1923 {chm_nosuch
, 0 }, /* 0x9c */
1924 {chm_nosuch
, 0 }, /* 0x9d */
1925 {chm_nosuch
, 0 }, /* 0x9e */
1926 {chm_nosuch
, 0 }, /* 0x9f */
1928 {chm_nosuch
, 0 }, /* 0xa0 */
1929 {chm_nosuch
, 0 }, /* 0xa1 */
1930 {chm_nosuch
, 0 }, /* 0xa2 */
1931 {chm_nosuch
, 0 }, /* 0xa3 */
1932 {chm_nosuch
, 0 }, /* 0xa4 */
1933 {chm_nosuch
, 0 }, /* 0xa5 */
1934 {chm_nosuch
, 0 }, /* 0xa6 */
1935 {chm_nosuch
, 0 }, /* 0xa7 */
1936 {chm_nosuch
, 0 }, /* 0xa8 */
1937 {chm_nosuch
, 0 }, /* 0xa9 */
1938 {chm_nosuch
, 0 }, /* 0xaa */
1939 {chm_nosuch
, 0 }, /* 0xab */
1940 {chm_nosuch
, 0 }, /* 0xac */
1941 {chm_nosuch
, 0 }, /* 0xad */
1942 {chm_nosuch
, 0 }, /* 0xae */
1943 {chm_nosuch
, 0 }, /* 0xaf */
1945 {chm_nosuch
, 0 }, /* 0xb0 */
1946 {chm_nosuch
, 0 }, /* 0xb1 */
1947 {chm_nosuch
, 0 }, /* 0xb2 */
1948 {chm_nosuch
, 0 }, /* 0xb3 */
1949 {chm_nosuch
, 0 }, /* 0xb4 */
1950 {chm_nosuch
, 0 }, /* 0xb5 */
1951 {chm_nosuch
, 0 }, /* 0xb6 */
1952 {chm_nosuch
, 0 }, /* 0xb7 */
1953 {chm_nosuch
, 0 }, /* 0xb8 */
1954 {chm_nosuch
, 0 }, /* 0xb9 */
1955 {chm_nosuch
, 0 }, /* 0xba */
1956 {chm_nosuch
, 0 }, /* 0xbb */
1957 {chm_nosuch
, 0 }, /* 0xbc */
1958 {chm_nosuch
, 0 }, /* 0xbd */
1959 {chm_nosuch
, 0 }, /* 0xbe */
1960 {chm_nosuch
, 0 }, /* 0xbf */
1962 {chm_nosuch
, 0 }, /* 0xc0 */
1963 {chm_nosuch
, 0 }, /* 0xc1 */
1964 {chm_nosuch
, 0 }, /* 0xc2 */
1965 {chm_nosuch
, 0 }, /* 0xc3 */
1966 {chm_nosuch
, 0 }, /* 0xc4 */
1967 {chm_nosuch
, 0 }, /* 0xc5 */
1968 {chm_nosuch
, 0 }, /* 0xc6 */
1969 {chm_nosuch
, 0 }, /* 0xc7 */
1970 {chm_nosuch
, 0 }, /* 0xc8 */
1971 {chm_nosuch
, 0 }, /* 0xc9 */
1972 {chm_nosuch
, 0 }, /* 0xca */
1973 {chm_nosuch
, 0 }, /* 0xcb */
1974 {chm_nosuch
, 0 }, /* 0xcc */
1975 {chm_nosuch
, 0 }, /* 0xcd */
1976 {chm_nosuch
, 0 }, /* 0xce */
1977 {chm_nosuch
, 0 }, /* 0xcf */
1979 {chm_nosuch
, 0 }, /* 0xd0 */
1980 {chm_nosuch
, 0 }, /* 0xd1 */
1981 {chm_nosuch
, 0 }, /* 0xd2 */
1982 {chm_nosuch
, 0 }, /* 0xd3 */
1983 {chm_nosuch
, 0 }, /* 0xd4 */
1984 {chm_nosuch
, 0 }, /* 0xd5 */
1985 {chm_nosuch
, 0 }, /* 0xd6 */
1986 {chm_nosuch
, 0 }, /* 0xd7 */
1987 {chm_nosuch
, 0 }, /* 0xd8 */
1988 {chm_nosuch
, 0 }, /* 0xd9 */
1989 {chm_nosuch
, 0 }, /* 0xda */
1990 {chm_nosuch
, 0 }, /* 0xdb */
1991 {chm_nosuch
, 0 }, /* 0xdc */
1992 {chm_nosuch
, 0 }, /* 0xdd */
1993 {chm_nosuch
, 0 }, /* 0xde */
1994 {chm_nosuch
, 0 }, /* 0xdf */
1996 {chm_nosuch
, 0 }, /* 0xe0 */
1997 {chm_nosuch
, 0 }, /* 0xe1 */
1998 {chm_nosuch
, 0 }, /* 0xe2 */
1999 {chm_nosuch
, 0 }, /* 0xe3 */
2000 {chm_nosuch
, 0 }, /* 0xe4 */
2001 {chm_nosuch
, 0 }, /* 0xe5 */
2002 {chm_nosuch
, 0 }, /* 0xe6 */
2003 {chm_nosuch
, 0 }, /* 0xe7 */
2004 {chm_nosuch
, 0 }, /* 0xe8 */
2005 {chm_nosuch
, 0 }, /* 0xe9 */
2006 {chm_nosuch
, 0 }, /* 0xea */
2007 {chm_nosuch
, 0 }, /* 0xeb */
2008 {chm_nosuch
, 0 }, /* 0xec */
2009 {chm_nosuch
, 0 }, /* 0xed */
2010 {chm_nosuch
, 0 }, /* 0xee */
2011 {chm_nosuch
, 0 }, /* 0xef */
2013 {chm_nosuch
, 0 }, /* 0xf0 */
2014 {chm_nosuch
, 0 }, /* 0xf1 */
2015 {chm_nosuch
, 0 }, /* 0xf2 */
2016 {chm_nosuch
, 0 }, /* 0xf3 */
2017 {chm_nosuch
, 0 }, /* 0xf4 */
2018 {chm_nosuch
, 0 }, /* 0xf5 */
2019 {chm_nosuch
, 0 }, /* 0xf6 */
2020 {chm_nosuch
, 0 }, /* 0xf7 */
2021 {chm_nosuch
, 0 }, /* 0xf8 */
2022 {chm_nosuch
, 0 }, /* 0xf9 */
2023 {chm_nosuch
, 0 }, /* 0xfa */
2024 {chm_nosuch
, 0 }, /* 0xfb */
2025 {chm_nosuch
, 0 }, /* 0xfc */
2026 {chm_nosuch
, 0 }, /* 0xfd */
2027 {chm_nosuch
, 0 }, /* 0xfe */
2028 {chm_nosuch
, 0 }, /* 0xff */
2033 /* set_channel_mode()
2035 * inputs - client, source, channel, membership pointer, params
2037 * side effects - channel modes/memberships are changed, MODE is issued
2039 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
2042 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
2043 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
2045 static char cmdbuf
[BUFSIZE
];
2046 static char modebuf
[BUFSIZE
];
2047 static char parabuf
[BUFSIZE
];
2050 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
2051 int i
, j
, flags
, override
;
2056 const char *ml
= parv
[0];
2058 struct Client
*fakesource_p
;
2059 int flags_list
[3] = { ALL_MEMBERS
, ONLY_CHANOPS
, ONLY_OPERS
};
2064 mode_limit_simple
= 0;
2066 alevel
= get_channel_access(source_p
, msptr
);
2068 no_override_deop
= 0;
2070 /* Hide connecting server on netburst -- jilles */
2071 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
2074 fakesource_p
= source_p
;
2076 for(; (c
= *ml
) != 0; ml
++)
2090 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
2093 chmode_table
[(unsigned char) c
].mode_type
);
2098 /* bail out if we have nothing to do... */
2102 if(IsServer(source_p
))
2103 rb_sprintf(cmdbuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
2105 rb_sprintf(cmdbuf
, ":%s!%s@%s MODE %s ",
2106 source_p
->name
, source_p
->username
,
2107 source_p
->host
, chptr
->chname
);
2111 for (override
= 0; override
< (IsOverride(source_p
) && alevel
!= CHFL_CHANOP
? 2 : 1); ++override
)
2113 int was_on_chan
= 0;
2120 msptr
->flags
|= CHFL_CHANOP
;
2123 add_user_to_channel(chptr
, source_p
, CHFL_CHANOP
);
2126 for(j
= 0, flags
= flags_list
[0]; j
< 3; j
++, flags
= flags_list
[j
])
2129 mbuf
= modebuf
+ mlen
;
2132 paracount
= paralen
= 0;
2135 for(i
= 0; i
< mode_count
; i
++)
2137 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
2140 if(mode_changes
[i
].override
!= override
)
2143 if(mode_changes
[i
].arg
!= NULL
)
2145 arglen
= strlen(mode_changes
[i
].arg
);
2147 if(arglen
> MODEBUFLEN
- 5)
2153 /* if we're creeping over MAXMODEPARAMSSERV, or over
2154 * bufsize (4 == +/-,modechar,two spaces) send now.
2156 if(mode_changes
[i
].arg
!= NULL
&&
2157 ((paracount
== MAXMODEPARAMSSERV
) ||
2158 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
2164 sendto_channel_local(flags
, chptr
, "%s%s %s",
2165 cmdbuf
, modebuf
, parabuf
);
2168 sendto_wallops_flags(UMODE_WALLOP
, &me
,
2169 "%s is overriding modes on %s: %s %s",
2170 get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2171 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
2172 ":%s WALLOPS :%s is overriding modes on %s: %s %s",
2173 me
.name
, get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2179 paracount
= paralen
= 0;
2181 mbuf
= modebuf
+ mlen
;
2187 if(dir
!= mode_changes
[i
].dir
)
2189 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
2191 dir
= mode_changes
[i
].dir
;
2194 *mbuf
++ = mode_changes
[i
].letter
;
2197 if(mode_changes
[i
].arg
!= NULL
)
2200 len
= rb_sprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
2206 if(paralen
&& parabuf
[paralen
- 1] == ' ')
2207 parabuf
[paralen
- 1] = '\0';
2212 sendto_channel_local(flags
, chptr
, "%s%s %s", cmdbuf
, modebuf
, parabuf
);
2215 sendto_wallops_flags(UMODE_WALLOP
, &me
,
2216 "%s is overriding modes on %s: %s %s",
2217 get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2218 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
2219 ":%s WALLOPS :%s is overriding modes on %s: %s %s",
2220 me
.name
, get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2227 remove_user_from_channel(find_channel_membership(chptr
, source_p
));
2228 else if (!no_override_deop
)
2229 msptr
->flags
&= ~CHFL_CHANOP
;
2233 /* only propagate modes originating locally, or if we're hubbing */
2234 if(MyClient(source_p
) || rb_dlink_list_length(&serv_list
) > 1)
2235 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);