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
36 #include "s_serv.h" /* captab */
40 #include "s_conf.h" /* ConfigFileEntry, ConfigChannel */
41 #include "s_newconf.h"
44 #include "irc_dictionary.h"
46 /* bitmasks for error returns, so we send once per call */
47 #define SM_ERR_NOTS 0x00000001 /* No TS on channel */
48 #define SM_ERR_NOOPS 0x00000002 /* No chan ops */
49 #define SM_ERR_UNKNOWN 0x00000004
50 #define SM_ERR_RPL_C 0x00000008
51 #define SM_ERR_RPL_B 0x00000010
52 #define SM_ERR_RPL_E 0x00000020
53 #define SM_ERR_NOTONCHANNEL 0x00000040 /* Not on channel */
54 #define SM_ERR_RPL_I 0x00000100
55 #define SM_ERR_RPL_D 0x00000200
56 #define SM_ERR_NOPRIVS 0x00000400
57 #define SM_ERR_RPL_Q 0x00000800
58 #define SM_ERR_RPL_F 0x00001000
60 #define MAXMODES_SIMPLE 46 /* a-zA-Z except bqeIov */
62 static struct ChModeChange mode_changes
[BUFSIZE
];
63 static int mode_count
;
64 static int mode_limit
;
65 static int mode_limit_simple
;
67 static int no_override_deop
;
70 char cflagsmyinfo
[256];
72 int chmode_flags
[256];
74 /* OPTIMIZE ME! -- dwr */
76 construct_cflags_strings(void)
79 char *ptr
= cflagsbuf
;
80 char *ptr2
= cflagsmyinfo
;
85 for(i
= 0; i
< 256; i
++)
87 if( !(chmode_table
[i
].set_func
== chm_ban
) &&
88 !(chmode_table
[i
].set_func
== chm_forward
) &&
89 !(chmode_table
[i
].set_func
== chm_throttle
) &&
90 !(chmode_table
[i
].set_func
== chm_key
) &&
91 !(chmode_table
[i
].set_func
== chm_limit
) &&
92 !(chmode_table
[i
].set_func
== chm_admin
) &&
93 !(chmode_table
[i
].set_func
== chm_op
) &&
94 !(chmode_table
[i
].set_func
== chm_halfop
) &&
95 !(chmode_table
[i
].set_func
== chm_voice
))
97 chmode_flags
[i
] = chmode_table
[i
].mode_type
;
104 switch (chmode_flags
[i
])
107 case MODE_DISFORWARD
:
108 if(ConfigChannel
.use_forward
)
115 if(rb_dlink_list_length(&service_list
))
122 if(chmode_flags
[i
] != 0)
128 /* Should we leave orphaned check here? -- dwr */
129 if(!(chmode_table
[i
].set_func
== chm_nosuch
) && !(chmode_table
[i
].set_func
== chm_orphaned
))
143 * outputs - an available cflag bitmask or
144 * 0 if no cflags are available
145 * side effects - NONE
148 find_cflag_slot(void)
150 unsigned int all_cflags
= 0, my_cflag
= 0, i
;
152 for (i
= 0; i
< 256; i
++)
153 all_cflags
|= chmode_flags
[i
];
155 for (my_cflag
= 1; my_cflag
&& (all_cflags
& my_cflag
);
162 cflag_add(char c_
, ChannelModeFunc function
)
164 int c
= (unsigned char)c_
;
166 if (chmode_table
[c
].set_func
!= chm_nosuch
&&
167 chmode_table
[c
].set_func
!= chm_orphaned
)
170 if (chmode_table
[c
].set_func
== chm_nosuch
)
171 chmode_table
[c
].mode_type
= find_cflag_slot();
172 if (chmode_table
[c
].mode_type
== 0)
174 chmode_table
[c
].set_func
= function
;
175 construct_cflags_strings();
176 return chmode_table
[c
].mode_type
;
180 cflag_orphan(char c_
)
182 int c
= (unsigned char)c_
;
184 s_assert(chmode_flags
[c
] != 0);
185 chmode_table
[c
].set_func
= chm_orphaned
;
186 construct_cflags_strings();
190 get_channel_access(struct Client
*source_p
, struct membership
*msptr
)
192 if(!MyClient(source_p
) || is_admin(msptr
))
194 else if(is_chanop(msptr
))
196 else if(is_halfop(msptr
))
204 * inputs - client, channel, id to add, type
205 * outputs - 0 on failure, 1 on success
206 * side effects - given id is added to the appropriate list
209 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
,
210 rb_dlink_list
* list
, long mode_type
)
212 struct Ban
*actualBan
;
213 static char who
[USERHOST_REPLYLEN
];
214 char *realban
= LOCAL_COPY(banid
);
217 /* dont let local clients overflow the banlist, or set redundant
220 if(MyClient(source_p
))
222 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
))
224 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
225 me
.name
, source_p
->name
, chptr
->chname
, realban
);
229 RB_DLINK_FOREACH(ptr
, list
->head
)
231 actualBan
= ptr
->data
;
232 if(mask_match(actualBan
->banstr
, realban
))
236 /* dont let remotes set duplicates */
239 RB_DLINK_FOREACH(ptr
, list
->head
)
241 actualBan
= ptr
->data
;
242 if(!irccmp(actualBan
->banstr
, realban
))
248 if(IsPerson(source_p
))
249 rb_sprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
251 rb_strlcpy(who
, source_p
->name
, sizeof(who
));
253 actualBan
= allocate_ban(realban
, who
);
254 actualBan
->when
= rb_current_time();
256 rb_dlinkAdd(actualBan
, &actualBan
->node
, list
);
258 /* invalidate the can_send() cache */
259 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
267 * inputs - channel, id to remove, type
268 * outputs - 0 on failure, 1 on success
269 * side effects - given id is removed from the appropriate list
272 del_id(struct Channel
*chptr
, const char *banid
, rb_dlink_list
* list
, long mode_type
)
277 if(EmptyString(banid
))
280 RB_DLINK_FOREACH(ptr
, list
->head
)
284 if(irccmp(banid
, banptr
->banstr
) == 0)
286 rb_dlinkDelete(&banptr
->node
, list
);
289 /* invalidate the can_send() cache */
290 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
302 * input - string to check
303 * output - pointer to 'fixed' string, or "*" if empty
304 * side effects - any white space found becomes \0
307 check_string(char *s
)
310 static char splat
[] = "*";
327 * inputs - mask to pretty
328 * outputs - better version of the mask
329 * side effects - mask is chopped to limits, and transformed:
337 pretty_mask(const char *idmask
)
339 static char mask_buf
[BUFSIZE
];
341 char *nick
, *user
, *host
;
344 char ne
= 0, ue
= 0, he
= 0; /* save values at nick[NICKLEN], et all */
347 mask
= LOCAL_COPY(idmask
);
348 mask
= check_string(mask
);
351 nick
= user
= host
= splat
;
353 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
356 old_mask_pos
= mask_pos
;
360 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
361 t
= mask_buf
+ old_mask_pos
+ 1;
367 return mask_buf
+ old_mask_pos
;
371 if((t
= strchr(mask
, '@')) != NULL
)
378 if((t
= strchr(mask
, '!')) != NULL
)
393 else if((t
= strchr(mask
, '!')) != NULL
)
402 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
|| strchr(mask
, '/') != NULL
)
413 /* truncate values to max lengths */
414 if(strlen(nick
) > NICKLEN
- 1)
416 ne
= nick
[NICKLEN
- 1];
417 nick
[NICKLEN
- 1] = '\0';
419 if(strlen(user
) > USERLEN
)
422 user
[USERLEN
] = '\0';
424 if(strlen(host
) > HOSTLEN
)
427 host
[HOSTLEN
] = '\0';
430 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
432 /* restore mask, since we may need to use it again later */
438 nick
[NICKLEN
- 1] = ne
;
444 return mask_buf
+ old_mask_pos
;
450 * output - the same key, fixed
451 * side effects - anything below ascii 13 is discarded, ':' discarded,
452 * high ascii is dropped to lower half of ascii table
459 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
462 if(c
!= ':' && c
!= ',' && c
> ' ')
473 * ouput - the same key, fixed
474 * side effects - high ascii dropped to lower half of table,
475 * CR/LF/':' are dropped
478 fix_key_remote(char *arg
)
482 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
485 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
495 * The handlers for each specific mode.
498 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
499 int alevel
, int parc
, int *parn
,
500 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
502 if(*errors
& SM_ERR_UNKNOWN
)
504 *errors
|= SM_ERR_UNKNOWN
;
505 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
509 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
510 int alevel
, int parc
, int *parn
,
511 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
516 struct DictionaryIter iter
;
518 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
520 if (IsOverride(source_p
))
524 if(!(*errors
& SM_ERR_NOOPS
))
525 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
526 me
.name
, source_p
->name
, chptr
->chname
);
527 *errors
|= SM_ERR_NOOPS
;
532 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
536 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
538 /* if +f is disabled, ignore an attempt to set +QF locally */
539 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
540 (c
== 'Q' || c
== 'F'))
543 chptr
->mode
.mode
|= mode_type
;
545 mode_changes
[mode_count
].letter
= c
;
546 mode_changes
[mode_count
].dir
= MODE_ADD
;
547 mode_changes
[mode_count
].caps
= 0;
548 mode_changes
[mode_count
].nocaps
= 0;
549 mode_changes
[mode_count
].id
= NULL
;
550 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
551 mode_changes
[mode_count
].override
= override
;
552 mode_changes
[mode_count
++].arg
= NULL
;
554 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
556 /* cleanup metadata when the related mode is removed */
559 DICTIONARY_FOREACH(md
, &iter
, chptr
->metadata
)
561 if(!strcmp(md
->value
, "KICKNOREJOIN"))
562 channel_metadata_delete(chptr
, md
->name
, 0);
566 channel_metadata_delete(chptr
, "NOREPEAT", 0);
568 chptr
->mode
.mode
&= ~mode_type
;
570 mode_changes
[mode_count
].letter
= c
;
571 mode_changes
[mode_count
].dir
= MODE_DEL
;
572 mode_changes
[mode_count
].caps
= 0;
573 mode_changes
[mode_count
].nocaps
= 0;
574 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
575 mode_changes
[mode_count
].id
= NULL
;
576 mode_changes
[mode_count
].override
= override
;
577 mode_changes
[mode_count
++].arg
= NULL
;
582 chm_orphaned(struct Client
*source_p
, struct Channel
*chptr
,
583 int alevel
, int parc
, int *parn
,
584 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
586 if(MyClient(source_p
))
589 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
591 chptr
->mode
.mode
|= mode_type
;
593 mode_changes
[mode_count
].letter
= c
;
594 mode_changes
[mode_count
].dir
= MODE_ADD
;
595 mode_changes
[mode_count
].caps
= 0;
596 mode_changes
[mode_count
].nocaps
= 0;
597 mode_changes
[mode_count
].id
= NULL
;
598 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
599 mode_changes
[mode_count
++].arg
= NULL
;
601 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
603 chptr
->mode
.mode
&= ~mode_type
;
605 mode_changes
[mode_count
].letter
= c
;
606 mode_changes
[mode_count
].dir
= MODE_DEL
;
607 mode_changes
[mode_count
].caps
= 0;
608 mode_changes
[mode_count
].nocaps
= 0;
609 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
610 mode_changes
[mode_count
].id
= NULL
;
611 mode_changes
[mode_count
++].arg
= NULL
;
616 chm_hidden(struct Client
*source_p
, struct Channel
*chptr
,
617 int alevel
, int parc
, int *parn
,
618 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
620 if(!IsOper(source_p
) && !IsServer(source_p
))
622 if(!(*errors
& SM_ERR_NOPRIVS
))
623 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
624 *errors
|= SM_ERR_NOPRIVS
;
627 if(MyClient(source_p
) && !IsOperAdmin(source_p
))
629 if(!(*errors
& SM_ERR_NOPRIVS
))
630 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
631 source_p
->name
, "cmodes");
632 *errors
|= SM_ERR_NOPRIVS
;
636 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
640 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
642 chptr
->mode
.mode
|= mode_type
;
644 mode_changes
[mode_count
].letter
= c
;
645 mode_changes
[mode_count
].dir
= MODE_ADD
;
646 mode_changes
[mode_count
].caps
= 0;
647 mode_changes
[mode_count
].nocaps
= 0;
648 mode_changes
[mode_count
].id
= NULL
;
649 mode_changes
[mode_count
].mems
= ONLY_OPERS
;
650 mode_changes
[mode_count
].override
= 0;
651 mode_changes
[mode_count
++].arg
= NULL
;
653 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
655 chptr
->mode
.mode
&= ~mode_type
;
657 mode_changes
[mode_count
].letter
= c
;
658 mode_changes
[mode_count
].dir
= MODE_DEL
;
659 mode_changes
[mode_count
].caps
= 0;
660 mode_changes
[mode_count
].nocaps
= 0;
661 mode_changes
[mode_count
].mems
= ONLY_OPERS
;
662 mode_changes
[mode_count
].id
= NULL
;
663 mode_changes
[mode_count
].override
= 0;
664 mode_changes
[mode_count
++].arg
= NULL
;
669 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
670 int alevel
, int parc
, int *parn
,
671 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
675 if(!IsOper(source_p
) && !IsServer(source_p
))
677 if(!(*errors
& SM_ERR_NOPRIVS
))
678 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
679 *errors
|= SM_ERR_NOPRIVS
;
682 if(MyClient(source_p
) && !IsOperResv(source_p
))
684 if(!(*errors
& SM_ERR_NOPRIVS
))
685 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
686 source_p
->name
, "resv");
687 *errors
|= SM_ERR_NOPRIVS
;
691 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
693 if (IsOverride(source_p
))
697 if(!(*errors
& SM_ERR_NOOPS
))
698 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
699 me
.name
, source_p
->name
, chptr
->chname
);
700 *errors
|= SM_ERR_NOOPS
;
705 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
709 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
711 chptr
->mode
.mode
|= mode_type
;
713 mode_changes
[mode_count
].letter
= c
;
714 mode_changes
[mode_count
].dir
= MODE_ADD
;
715 mode_changes
[mode_count
].caps
= 0;
716 mode_changes
[mode_count
].nocaps
= 0;
717 mode_changes
[mode_count
].id
= NULL
;
718 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
719 mode_changes
[mode_count
].override
= override
;
720 mode_changes
[mode_count
++].arg
= NULL
;
722 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
724 chptr
->mode
.mode
&= ~mode_type
;
726 mode_changes
[mode_count
].letter
= c
;
727 mode_changes
[mode_count
].dir
= MODE_DEL
;
728 mode_changes
[mode_count
].caps
= 0;
729 mode_changes
[mode_count
].nocaps
= 0;
730 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
731 mode_changes
[mode_count
].override
= override
;
732 mode_changes
[mode_count
].id
= NULL
;
733 mode_changes
[mode_count
++].arg
= NULL
;
738 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
739 int alevel
, int parc
, int *parn
,
740 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
743 const char *raw_mask
;
757 list
= &chptr
->banlist
;
758 errorval
= SM_ERR_RPL_B
;
759 rpl_list
= RPL_BANLIST
;
760 rpl_endlist
= RPL_ENDOFBANLIST
;
766 /* if +e is disabled, allow all but +e locally */
767 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
768 ((dir
== MODE_ADD
) && (parc
> *parn
)))
771 list
= &chptr
->exceptlist
;
772 errorval
= SM_ERR_RPL_E
;
773 rpl_list
= RPL_EXCEPTLIST
;
774 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
777 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
784 /* if +I is disabled, allow all but +I locally */
785 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
786 (dir
== MODE_ADD
) && (parc
> *parn
))
789 list
= &chptr
->invexlist
;
790 errorval
= SM_ERR_RPL_I
;
791 rpl_list
= RPL_INVITELIST
;
792 rpl_endlist
= RPL_ENDOFINVITELIST
;
795 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
802 list
= &chptr
->quietlist
;
803 errorval
= SM_ERR_RPL_Q
;
804 rpl_list
= RPL_QUIETLIST
;
805 rpl_endlist
= RPL_ENDOFQUIETLIST
;
811 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
816 if(dir
== 0 || parc
<= *parn
)
818 if((*errors
& errorval
) != 0)
822 /* non-ops cant see +eI lists.. */
823 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
&& mode_type
!= CHFL_BAN
&&
824 mode_type
!= CHFL_QUIET
)
826 if(IsOverride(source_p
))
828 sendto_wallops_flags(UMODE_WALLOP
, &me
,
829 "%s is overriding modes on %s: (%s list)",
830 get_oper_name(source_p
), chptr
->chname
, mode_type
== CHFL_INVEX
? "invex" : "exempt");
831 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
832 ":%s WALLOPS :%s is overriding modes on %s: (%s list)",
833 me
.name
, get_oper_name(source_p
), chptr
->chname
, mode_type
== CHFL_INVEX
? "invex" : "exempt");
838 if(!(*errors
& SM_ERR_NOOPS
))
839 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
840 me
.name
, source_p
->name
, chptr
->chname
);
841 *errors
|= SM_ERR_NOOPS
;
846 RB_DLINK_FOREACH(ptr
, list
->head
)
849 sendto_one(source_p
, form_str(rpl_list
),
850 me
.name
, source_p
->name
, chptr
->chname
,
851 banptr
->banstr
, banptr
->who
, banptr
->when
);
853 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
857 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
859 if(IsOverride(source_p
))
864 if(!(*errors
& SM_ERR_NOOPS
))
865 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
866 me
.name
, source_p
->name
, chptr
->chname
);
867 *errors
|= SM_ERR_NOOPS
;
872 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
875 raw_mask
= parv
[(*parn
)];
878 /* empty ban, or starts with ':' which messes up s2s, ignore it */
879 if(EmptyString(raw_mask
) || *raw_mask
== ':')
882 if(!MyClient(source_p
))
884 if(strchr(raw_mask
, ' '))
890 mask
= pretty_mask(raw_mask
);
892 /* we'd have problems parsing this, hyb6 does it too
893 * also make sure it will always fit on a line with channel
896 if(strlen(mask
) > IRCD_MIN(BANLEN
, MODEBUFLEN
- 5))
899 /* if we're adding a NEW id */
902 if (*mask
== '$' && MyClient(source_p
))
904 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
905 /* XXX perhaps return an error message here */
909 /* dont allow local clients to overflow the banlist, dont
910 * let remote servers set duplicate bans
912 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
915 mode_changes
[mode_count
].letter
= c
;
916 mode_changes
[mode_count
].dir
= MODE_ADD
;
917 mode_changes
[mode_count
].caps
= caps
;
918 mode_changes
[mode_count
].nocaps
= 0;
919 mode_changes
[mode_count
].mems
= mems
;
920 mode_changes
[mode_count
].id
= NULL
;
921 mode_changes
[mode_count
].override
= override
;
922 mode_changes
[mode_count
++].arg
= mask
;
924 else if(dir
== MODE_DEL
)
926 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
928 /* mask isn't a valid ban, check raw_mask */
929 if(del_id(chptr
, raw_mask
, list
, mode_type
))
933 mode_changes
[mode_count
].letter
= c
;
934 mode_changes
[mode_count
].dir
= MODE_DEL
;
935 mode_changes
[mode_count
].caps
= caps
;
936 mode_changes
[mode_count
].nocaps
= 0;
937 mode_changes
[mode_count
].mems
= mems
;
938 mode_changes
[mode_count
].id
= NULL
;
939 mode_changes
[mode_count
].override
= override
;
940 mode_changes
[mode_count
++].arg
= mask
;
945 chm_admin(struct Client
*source_p
, struct Channel
*chptr
,
946 int alevel
, int parc
, int *parn
,
947 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
949 struct membership
*mstptr
;
950 const char *adminnick
;
951 struct Client
*targ_p
;
954 if(!ConfigChannel
.use_admin
)
956 if(*errors
& SM_ERR_UNKNOWN
)
958 *errors
|= SM_ERR_UNKNOWN
;
959 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
963 if(alevel
!= CHFL_ADMIN
)
965 if(IsOverride(source_p
))
970 if(!(*errors
& SM_ERR_NOOPS
))
971 sendto_one(source_p
, ":%s 482 %s %s :You're not a channel administrator", me
.name
, source_p
->name
, chptr
->chname
);
972 *errors
|= SM_ERR_NOOPS
;
977 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
980 adminnick
= parv
[(*parn
)];
984 if(EmptyString(adminnick
))
986 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
990 if((targ_p
= find_chasing(source_p
, adminnick
, NULL
)) == NULL
)
995 mstptr
= find_channel_membership(chptr
, targ_p
);
999 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1000 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1001 form_str(ERR_USERNOTINCHANNEL
), adminnick
, chptr
->chname
);
1002 *errors
|= SM_ERR_NOTONCHANNEL
;
1006 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1011 if(targ_p
== source_p
)
1013 no_override_deop
= 1;
1014 /* Don't reject modes from remote. It desyncs, and this is perfectly
1015 * legitimate from a remote override oper.
1021 mode_changes
[mode_count
].letter
= c
;
1022 mode_changes
[mode_count
].dir
= MODE_ADD
;
1023 mode_changes
[mode_count
].caps
= 0;
1024 mode_changes
[mode_count
].nocaps
= 0;
1025 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1026 mode_changes
[mode_count
].id
= targ_p
->id
;
1027 mode_changes
[mode_count
].arg
= targ_p
->name
;
1028 mode_changes
[mode_count
].override
= override
;
1029 mode_changes
[mode_count
++].client
= targ_p
;
1031 mstptr
->flags
|= CHFL_ADMIN
;
1035 if(MyClient(source_p
) && IsService(targ_p
))
1037 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1038 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1042 mode_changes
[mode_count
].letter
= c
;
1043 mode_changes
[mode_count
].dir
= MODE_DEL
;
1044 mode_changes
[mode_count
].caps
= 0;
1045 mode_changes
[mode_count
].nocaps
= 0;
1046 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1047 mode_changes
[mode_count
].id
= targ_p
->id
;
1048 mode_changes
[mode_count
].arg
= targ_p
->name
;
1049 mode_changes
[mode_count
].override
= override
;
1050 mode_changes
[mode_count
++].client
= targ_p
;
1052 mstptr
->flags
&= ~CHFL_ADMIN
;
1057 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
1058 int alevel
, int parc
, int *parn
,
1059 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1061 struct membership
*mstptr
;
1063 struct Client
*targ_p
;
1066 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
)
1068 if(IsOverride(source_p
))
1073 if(!(*errors
& SM_ERR_NOOPS
))
1074 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1075 me
.name
, source_p
->name
, chptr
->chname
);
1076 *errors
|= SM_ERR_NOOPS
;
1081 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
1084 opnick
= parv
[(*parn
)];
1088 if(EmptyString(opnick
))
1090 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1094 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
1099 mstptr
= find_channel_membership(chptr
, targ_p
);
1103 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1104 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1105 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
1106 *errors
|= SM_ERR_NOTONCHANNEL
;
1110 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1115 if(targ_p
== source_p
)
1117 no_override_deop
= 1;
1118 /* Don't reject modes from remote. It desyncs, and this is perfectly
1119 * legitimate from a remote override oper.
1125 mode_changes
[mode_count
].letter
= c
;
1126 mode_changes
[mode_count
].dir
= MODE_ADD
;
1127 mode_changes
[mode_count
].caps
= 0;
1128 mode_changes
[mode_count
].nocaps
= 0;
1129 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1130 mode_changes
[mode_count
].id
= targ_p
->id
;
1131 mode_changes
[mode_count
].arg
= targ_p
->name
;
1132 mode_changes
[mode_count
].override
= override
;
1133 mode_changes
[mode_count
++].client
= targ_p
;
1135 mstptr
->flags
|= CHFL_CHANOP
;
1139 if(MyClient(source_p
) && IsService(targ_p
))
1141 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1142 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1146 mode_changes
[mode_count
].letter
= c
;
1147 mode_changes
[mode_count
].dir
= MODE_DEL
;
1148 mode_changes
[mode_count
].caps
= 0;
1149 mode_changes
[mode_count
].nocaps
= 0;
1150 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1151 mode_changes
[mode_count
].id
= targ_p
->id
;
1152 mode_changes
[mode_count
].arg
= targ_p
->name
;
1153 mode_changes
[mode_count
].override
= override
;
1154 mode_changes
[mode_count
++].client
= targ_p
;
1156 mstptr
->flags
&= ~CHFL_CHANOP
;
1161 chm_halfop(struct Client
*source_p
, struct Channel
*chptr
,
1162 int alevel
, int parc
, int *parn
,
1163 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1165 struct membership
*mstptr
;
1166 const char *halfopnick
;
1167 struct Client
*targ_p
;
1170 if(!ConfigChannel
.use_halfop
)
1172 if(*errors
& SM_ERR_UNKNOWN
)
1174 *errors
|= SM_ERR_UNKNOWN
;
1175 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
1179 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
)
1181 if(IsOverride(source_p
))
1186 if(!(*errors
& SM_ERR_NOOPS
))
1187 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1188 me
.name
, source_p
->name
, chptr
->chname
);
1189 *errors
|= SM_ERR_NOOPS
;
1194 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
1197 halfopnick
= parv
[(*parn
)];
1201 if(EmptyString(halfopnick
))
1203 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1207 if((targ_p
= find_chasing(source_p
, halfopnick
, NULL
)) == NULL
)
1212 mstptr
= find_channel_membership(chptr
, targ_p
);
1216 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1217 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1218 form_str(ERR_USERNOTINCHANNEL
), halfopnick
, chptr
->chname
);
1219 *errors
|= SM_ERR_NOTONCHANNEL
;
1223 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1228 if(targ_p
== source_p
)
1230 no_override_deop
= 1;
1231 /* Don't reject modes from remote. It desyncs, and this is perfectly
1232 * legitimate from a remote override oper.
1238 mode_changes
[mode_count
].letter
= c
;
1239 mode_changes
[mode_count
].dir
= MODE_ADD
;
1240 mode_changes
[mode_count
].caps
= 0;
1241 mode_changes
[mode_count
].nocaps
= 0;
1242 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1243 mode_changes
[mode_count
].id
= targ_p
->id
;
1244 mode_changes
[mode_count
].arg
= targ_p
->name
;
1245 mode_changes
[mode_count
].override
= override
;
1246 mode_changes
[mode_count
++].client
= targ_p
;
1248 mstptr
->flags
|= CHFL_HALFOP
;
1252 if(MyClient(source_p
) && IsService(targ_p
))
1254 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1255 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1259 mode_changes
[mode_count
].letter
= c
;
1260 mode_changes
[mode_count
].dir
= MODE_DEL
;
1261 mode_changes
[mode_count
].caps
= 0;
1262 mode_changes
[mode_count
].nocaps
= 0;
1263 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1264 mode_changes
[mode_count
].id
= targ_p
->id
;
1265 mode_changes
[mode_count
].arg
= targ_p
->name
;
1266 mode_changes
[mode_count
].override
= override
;
1267 mode_changes
[mode_count
++].client
= targ_p
;
1269 mstptr
->flags
&= ~CHFL_HALFOP
;
1274 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
1275 int alevel
, int parc
, int *parn
,
1276 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1278 struct membership
*mstptr
;
1280 struct Client
*targ_p
;
1283 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1285 if(IsOverride(source_p
))
1290 if(!(*errors
& SM_ERR_NOOPS
))
1291 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1292 me
.name
, source_p
->name
, chptr
->chname
);
1293 *errors
|= SM_ERR_NOOPS
;
1298 if((dir
== MODE_QUERY
) || parc
<= *parn
)
1301 opnick
= parv
[(*parn
)];
1305 if(EmptyString(opnick
))
1307 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1311 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
1316 mstptr
= find_channel_membership(chptr
, targ_p
);
1320 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1321 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1322 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
1323 *errors
|= SM_ERR_NOTONCHANNEL
;
1327 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1332 mode_changes
[mode_count
].letter
= c
;
1333 mode_changes
[mode_count
].dir
= MODE_ADD
;
1334 mode_changes
[mode_count
].caps
= 0;
1335 mode_changes
[mode_count
].nocaps
= 0;
1336 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1337 mode_changes
[mode_count
].id
= targ_p
->id
;
1338 mode_changes
[mode_count
].arg
= targ_p
->name
;
1339 mode_changes
[mode_count
].override
= override
;
1340 mode_changes
[mode_count
++].client
= targ_p
;
1342 mstptr
->flags
|= CHFL_VOICE
;
1346 mode_changes
[mode_count
].letter
= 'v';
1347 mode_changes
[mode_count
].dir
= MODE_DEL
;
1348 mode_changes
[mode_count
].caps
= 0;
1349 mode_changes
[mode_count
].nocaps
= 0;
1350 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1351 mode_changes
[mode_count
].id
= targ_p
->id
;
1352 mode_changes
[mode_count
].arg
= targ_p
->name
;
1353 mode_changes
[mode_count
].override
= override
;
1354 mode_changes
[mode_count
++].client
= targ_p
;
1356 mstptr
->flags
&= ~CHFL_VOICE
;
1361 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
1362 int alevel
, int parc
, int *parn
,
1363 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1366 static char limitstr
[30];
1370 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1372 if(IsOverride(source_p
))
1376 if(!(*errors
& SM_ERR_NOOPS
))
1377 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1378 me
.name
, source_p
->name
, chptr
->chname
);
1379 *errors
|= SM_ERR_NOOPS
;
1384 if(dir
== MODE_QUERY
)
1387 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1390 if((dir
== MODE_ADD
) && parc
> *parn
)
1392 lstr
= parv
[(*parn
)];
1395 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
1398 rb_sprintf(limitstr
, "%d", limit
);
1400 mode_changes
[mode_count
].letter
= c
;
1401 mode_changes
[mode_count
].dir
= MODE_ADD
;
1402 mode_changes
[mode_count
].caps
= 0;
1403 mode_changes
[mode_count
].nocaps
= 0;
1404 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1405 mode_changes
[mode_count
].id
= NULL
;
1406 mode_changes
[mode_count
].override
= override
;
1407 mode_changes
[mode_count
++].arg
= limitstr
;
1409 chptr
->mode
.limit
= limit
;
1411 else if(dir
== MODE_DEL
)
1413 if(!chptr
->mode
.limit
)
1416 chptr
->mode
.limit
= 0;
1418 mode_changes
[mode_count
].letter
= c
;
1419 mode_changes
[mode_count
].dir
= MODE_DEL
;
1420 mode_changes
[mode_count
].caps
= 0;
1421 mode_changes
[mode_count
].nocaps
= 0;
1422 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1423 mode_changes
[mode_count
].id
= NULL
;
1424 mode_changes
[mode_count
].override
= override
;
1425 mode_changes
[mode_count
++].arg
= NULL
;
1430 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
1431 int alevel
, int parc
, int *parn
,
1432 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1434 int joins
= 0, timeslice
= 0;
1437 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1439 if(IsOverride(source_p
))
1444 if(!(*errors
& SM_ERR_NOOPS
))
1445 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1446 me
.name
, source_p
->name
, chptr
->chname
);
1447 *errors
|= SM_ERR_NOOPS
;
1452 if(dir
== MODE_QUERY
)
1455 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1458 if((dir
== MODE_ADD
) && parc
> *parn
)
1460 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
1462 if(!joins
|| !timeslice
)
1465 mode_changes
[mode_count
].letter
= c
;
1466 mode_changes
[mode_count
].dir
= MODE_ADD
;
1467 mode_changes
[mode_count
].caps
= 0;
1468 mode_changes
[mode_count
].nocaps
= 0;
1469 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1470 mode_changes
[mode_count
].id
= NULL
;
1471 mode_changes
[mode_count
].override
= override
;
1472 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
1476 chptr
->mode
.join_num
= joins
;
1477 chptr
->mode
.join_time
= timeslice
;
1479 else if(dir
== MODE_DEL
)
1481 if(!chptr
->mode
.join_num
)
1484 chptr
->mode
.join_num
= 0;
1485 chptr
->mode
.join_time
= 0;
1486 chptr
->join_count
= 0;
1487 chptr
->join_delta
= 0;
1489 mode_changes
[mode_count
].letter
= c
;
1490 mode_changes
[mode_count
].dir
= MODE_DEL
;
1491 mode_changes
[mode_count
].caps
= 0;
1492 mode_changes
[mode_count
].nocaps
= 0;
1493 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1494 mode_changes
[mode_count
].id
= NULL
;
1495 mode_changes
[mode_count
].override
= override
;
1496 mode_changes
[mode_count
++].arg
= NULL
;
1501 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
1502 int alevel
, int parc
, int *parn
,
1503 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1505 struct Channel
*targptr
= NULL
;
1506 struct membership
*msptr
;
1507 const char *forward
;
1510 /* if +f is disabled, ignore local attempts to set it */
1511 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
1512 (dir
== MODE_ADD
) && (parc
> *parn
))
1515 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
1517 if (!(*errors
& SM_ERR_RPL_F
))
1519 if (*chptr
->mode
.forward
== '\0')
1520 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
1522 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
1523 *errors
|= SM_ERR_RPL_F
;
1528 #ifndef FORWARD_OPERONLY
1529 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1531 if(IsOverride(source_p
))
1535 if(!(*errors
& SM_ERR_NOOPS
))
1536 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1537 me
.name
, source_p
->name
, chptr
->chname
);
1538 *errors
|= SM_ERR_NOOPS
;
1543 if(!IsOper(source_p
) && !IsServer(source_p
))
1545 if(!(*errors
& SM_ERR_NOPRIVS
))
1546 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
1547 *errors
|= SM_ERR_NOPRIVS
;
1552 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1555 if(dir
== MODE_ADD
&& parc
> *parn
)
1557 forward
= parv
[(*parn
)];
1560 if(EmptyString(forward
))
1562 if(!check_channel_name(forward
) ||
1563 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1565 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1568 /* don't forward to inconsistent target -- jilles */
1569 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
1571 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
1572 form_str(ERR_BADCHANNAME
), forward
);
1575 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1577 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1578 form_str(ERR_NOSUCHCHANNEL
), forward
);
1581 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1583 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1586 if(IsOverride(source_p
))
1590 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1591 me
.name
, source_p
->name
, targptr
->chname
);
1597 rb_strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1599 mode_changes
[mode_count
].letter
= c
;
1600 mode_changes
[mode_count
].dir
= MODE_ADD
;
1601 mode_changes
[mode_count
].caps
= 0;
1602 mode_changes
[mode_count
].nocaps
= 0;
1603 mode_changes
[mode_count
].mems
= ConfigChannel
.use_forward
? ALL_MEMBERS
: ONLY_SERVERS
;
1604 mode_changes
[mode_count
].id
= NULL
;
1605 mode_changes
[mode_count
].override
= override
;
1606 mode_changes
[mode_count
++].arg
= forward
;
1608 else if(dir
== MODE_DEL
)
1610 if(!(*chptr
->mode
.forward
))
1613 *chptr
->mode
.forward
= '\0';
1615 mode_changes
[mode_count
].letter
= c
;
1616 mode_changes
[mode_count
].dir
= MODE_DEL
;
1617 mode_changes
[mode_count
].caps
= 0;
1618 mode_changes
[mode_count
].nocaps
= 0;
1619 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1620 mode_changes
[mode_count
].id
= NULL
;
1621 mode_changes
[mode_count
].override
= override
;
1622 mode_changes
[mode_count
++].arg
= NULL
;
1627 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1628 int alevel
, int parc
, int *parn
,
1629 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1634 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1636 if(IsOverride(source_p
))
1640 if(!(*errors
& SM_ERR_NOOPS
))
1641 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1642 me
.name
, source_p
->name
, chptr
->chname
);
1643 *errors
|= SM_ERR_NOOPS
;
1648 if(dir
== MODE_QUERY
)
1651 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1654 if((dir
== MODE_ADD
) && parc
> *parn
)
1656 key
= LOCAL_COPY(parv
[(*parn
)]);
1659 if(MyClient(source_p
))
1662 fix_key_remote(key
);
1664 if(EmptyString(key
))
1667 s_assert(key
[0] != ' ');
1668 rb_strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1670 mode_changes
[mode_count
].letter
= c
;
1671 mode_changes
[mode_count
].dir
= MODE_ADD
;
1672 mode_changes
[mode_count
].caps
= 0;
1673 mode_changes
[mode_count
].nocaps
= 0;
1674 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1675 mode_changes
[mode_count
].id
= NULL
;
1676 mode_changes
[mode_count
].override
= override
;
1677 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1679 else if(dir
== MODE_DEL
)
1681 static char splat
[] = "*";
1687 if(!(*chptr
->mode
.key
))
1690 /* hack time. when we get a +k-k mode, the +k arg is
1691 * chptr->mode.key, which the -k sets to \0, so hunt for a
1692 * +k when we get a -k, and set the arg to splat. --anfl
1694 for(i
= 0; i
< mode_count
; i
++)
1696 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1697 mode_changes
[i
].arg
= splat
;
1700 *chptr
->mode
.key
= 0;
1702 mode_changes
[mode_count
].letter
= c
;
1703 mode_changes
[mode_count
].dir
= MODE_DEL
;
1704 mode_changes
[mode_count
].caps
= 0;
1705 mode_changes
[mode_count
].nocaps
= 0;
1706 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1707 mode_changes
[mode_count
].id
= NULL
;
1708 mode_changes
[mode_count
].override
= override
;
1709 mode_changes
[mode_count
++].arg
= "*";
1714 chm_regonly(struct Client
*source_p
, struct Channel
*chptr
,
1715 int alevel
, int parc
, int *parn
,
1716 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1720 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1722 if(IsOverride(source_p
))
1726 if(!(*errors
& SM_ERR_NOOPS
))
1727 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1728 me
.name
, source_p
->name
, chptr
->chname
);
1729 *errors
|= SM_ERR_NOOPS
;
1734 if(dir
== MODE_QUERY
)
1737 if(((dir
== MODE_ADD
) && (chptr
->mode
.mode
& mode_type
)) ||
1738 ((dir
== MODE_DEL
) && !(chptr
->mode
.mode
& mode_type
)))
1741 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1745 chptr
->mode
.mode
|= mode_type
;
1747 chptr
->mode
.mode
&= ~mode_type
;
1749 mode_changes
[mode_count
].letter
= c
;
1750 mode_changes
[mode_count
].dir
= dir
;
1751 mode_changes
[mode_count
].caps
= CAP_SERVICE
;
1752 mode_changes
[mode_count
].nocaps
= 0;
1753 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1754 mode_changes
[mode_count
].id
= NULL
;
1755 mode_changes
[mode_count
].override
= override
;
1756 mode_changes
[mode_count
++].arg
= NULL
;
1760 struct ChannelMode chmode_table
[256] =
1762 {chm_nosuch
, 0 }, /* 0x00 */
1763 {chm_nosuch
, 0 }, /* 0x01 */
1764 {chm_nosuch
, 0 }, /* 0x02 */
1765 {chm_nosuch
, 0 }, /* 0x03 */
1766 {chm_nosuch
, 0 }, /* 0x04 */
1767 {chm_nosuch
, 0 }, /* 0x05 */
1768 {chm_nosuch
, 0 }, /* 0x06 */
1769 {chm_nosuch
, 0 }, /* 0x07 */
1770 {chm_nosuch
, 0 }, /* 0x08 */
1771 {chm_nosuch
, 0 }, /* 0x09 */
1772 {chm_nosuch
, 0 }, /* 0x0a */
1773 {chm_nosuch
, 0 }, /* 0x0b */
1774 {chm_nosuch
, 0 }, /* 0x0c */
1775 {chm_nosuch
, 0 }, /* 0x0d */
1776 {chm_nosuch
, 0 }, /* 0x0e */
1777 {chm_nosuch
, 0 }, /* 0x0f */
1778 {chm_nosuch
, 0 }, /* 0x10 */
1779 {chm_nosuch
, 0 }, /* 0x11 */
1780 {chm_nosuch
, 0 }, /* 0x12 */
1781 {chm_nosuch
, 0 }, /* 0x13 */
1782 {chm_nosuch
, 0 }, /* 0x14 */
1783 {chm_nosuch
, 0 }, /* 0x15 */
1784 {chm_nosuch
, 0 }, /* 0x16 */
1785 {chm_nosuch
, 0 }, /* 0x17 */
1786 {chm_nosuch
, 0 }, /* 0x18 */
1787 {chm_nosuch
, 0 }, /* 0x19 */
1788 {chm_nosuch
, 0 }, /* 0x1a */
1789 {chm_nosuch
, 0 }, /* 0x1b */
1790 {chm_nosuch
, 0 }, /* 0x1c */
1791 {chm_nosuch
, 0 }, /* 0x1d */
1792 {chm_nosuch
, 0 }, /* 0x1e */
1793 {chm_nosuch
, 0 }, /* 0x1f */
1794 {chm_nosuch
, 0 }, /* 0x20 */
1795 {chm_nosuch
, 0 }, /* 0x21 */
1796 {chm_nosuch
, 0 }, /* 0x22 */
1797 {chm_nosuch
, 0 }, /* 0x23 */
1798 {chm_nosuch
, 0 }, /* 0x24 */
1799 {chm_nosuch
, 0 }, /* 0x25 */
1800 {chm_nosuch
, 0 }, /* 0x26 */
1801 {chm_nosuch
, 0 }, /* 0x27 */
1802 {chm_nosuch
, 0 }, /* 0x28 */
1803 {chm_nosuch
, 0 }, /* 0x29 */
1804 {chm_nosuch
, 0 }, /* 0x2a */
1805 {chm_nosuch
, 0 }, /* 0x2b */
1806 {chm_nosuch
, 0 }, /* 0x2c */
1807 {chm_nosuch
, 0 }, /* 0x2d */
1808 {chm_nosuch
, 0 }, /* 0x2e */
1809 {chm_nosuch
, 0 }, /* 0x2f */
1810 {chm_nosuch
, 0 }, /* 0x30 */
1811 {chm_nosuch
, 0 }, /* 0x31 */
1812 {chm_nosuch
, 0 }, /* 0x32 */
1813 {chm_nosuch
, 0 }, /* 0x33 */
1814 {chm_nosuch
, 0 }, /* 0x34 */
1815 {chm_nosuch
, 0 }, /* 0x35 */
1816 {chm_nosuch
, 0 }, /* 0x36 */
1817 {chm_nosuch
, 0 }, /* 0x37 */
1818 {chm_nosuch
, 0 }, /* 0x38 */
1819 {chm_nosuch
, 0 }, /* 0x39 */
1820 {chm_nosuch
, 0 }, /* 0x3a */
1821 {chm_nosuch
, 0 }, /* 0x3b */
1822 {chm_nosuch
, 0 }, /* 0x3c */
1823 {chm_nosuch
, 0 }, /* 0x3d */
1824 {chm_nosuch
, 0 }, /* 0x3e */
1825 {chm_nosuch
, 0 }, /* 0x3f */
1827 {chm_nosuch
, 0 }, /* @ */
1828 {chm_nosuch
, 0 }, /* A */
1829 {chm_nosuch
, 0 }, /* B */
1830 {chm_simple
, MODE_NOCTCP
}, /* C */
1831 {chm_simple
, MODE_NOACTION
}, /* D */
1832 {chm_simple
, MODE_NOKICK
}, /* E */
1833 {chm_simple
, MODE_FREETARGET
}, /* F */
1834 {chm_simple
, MODE_NOCAPS
}, /* G */
1835 {chm_nosuch
, 0 }, /* H */
1836 {chm_ban
, CHFL_INVEX
}, /* I */
1837 {chm_simple
, MODE_NOREJOIN
}, /* J */
1838 {chm_simple
, MODE_NOREPEAT
}, /* K */
1839 {chm_staff
, MODE_EXLIMIT
}, /* L */
1840 {chm_hidden
, MODE_NOOPERKICK
}, /* M */
1841 {chm_simple
, MODE_NONICK
}, /* N */
1842 {chm_nosuch
, 0 }, /* O */
1843 {chm_staff
, MODE_PERMANENT
}, /* P */
1844 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1845 {chm_nosuch
, 0 }, /* R */
1846 {chm_nosuch
, 0 }, /* S */
1847 {chm_simple
, MODE_NONOTICE
}, /* T */
1848 {chm_nosuch
, 0 }, /* U */
1849 {chm_nosuch
, 0 }, /* V */
1850 {chm_nosuch
, 0 }, /* W */
1851 {chm_nosuch
, 0 }, /* X */
1852 {chm_nosuch
, 0 }, /* Y */
1853 {chm_nosuch
, 0 }, /* Z */
1860 {chm_admin
, 0 }, /* a */
1861 {chm_ban
, CHFL_BAN
}, /* b */
1862 {chm_simple
, MODE_NOCOLOR
}, /* c */
1863 {chm_nosuch
, 0 }, /* d */
1864 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1865 {chm_forward
, 0 }, /* f */
1866 {chm_simple
, MODE_FREEINVITE
}, /* g */
1867 {chm_halfop
, 0 }, /* h */
1868 {chm_simple
, MODE_INVITEONLY
}, /* i */
1869 {chm_throttle
, 0 }, /* j */
1870 {chm_key
, 0 }, /* k */
1871 {chm_limit
, 0 }, /* l */
1872 {chm_simple
, MODE_MODERATED
}, /* m */
1873 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1874 {chm_op
, 0 }, /* o */
1875 {chm_simple
, MODE_PRIVATE
}, /* p */
1876 {chm_ban
, CHFL_QUIET
}, /* q */
1877 {chm_regonly
, MODE_REGONLY
}, /* r */
1878 {chm_simple
, MODE_SECRET
}, /* s */
1879 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1880 {chm_nosuch
, 0 }, /* u */
1881 {chm_voice
, 0 }, /* v */
1882 {chm_nosuch
, 0 }, /* w */
1883 {chm_nosuch
, 0 }, /* x */
1884 {chm_nosuch
, 0 }, /* y */
1885 {chm_simple
, MODE_OPMODERATE
}, /* z */
1887 {chm_nosuch
, 0 }, /* 0x7b */
1888 {chm_nosuch
, 0 }, /* 0x7c */
1889 {chm_nosuch
, 0 }, /* 0x7d */
1890 {chm_nosuch
, 0 }, /* 0x7e */
1891 {chm_nosuch
, 0 }, /* 0x7f */
1893 {chm_nosuch
, 0 }, /* 0x80 */
1894 {chm_nosuch
, 0 }, /* 0x81 */
1895 {chm_nosuch
, 0 }, /* 0x82 */
1896 {chm_nosuch
, 0 }, /* 0x83 */
1897 {chm_nosuch
, 0 }, /* 0x84 */
1898 {chm_nosuch
, 0 }, /* 0x85 */
1899 {chm_nosuch
, 0 }, /* 0x86 */
1900 {chm_nosuch
, 0 }, /* 0x87 */
1901 {chm_nosuch
, 0 }, /* 0x88 */
1902 {chm_nosuch
, 0 }, /* 0x89 */
1903 {chm_nosuch
, 0 }, /* 0x8a */
1904 {chm_nosuch
, 0 }, /* 0x8b */
1905 {chm_nosuch
, 0 }, /* 0x8c */
1906 {chm_nosuch
, 0 }, /* 0x8d */
1907 {chm_nosuch
, 0 }, /* 0x8e */
1908 {chm_nosuch
, 0 }, /* 0x8f */
1910 {chm_nosuch
, 0 }, /* 0x90 */
1911 {chm_nosuch
, 0 }, /* 0x91 */
1912 {chm_nosuch
, 0 }, /* 0x92 */
1913 {chm_nosuch
, 0 }, /* 0x93 */
1914 {chm_nosuch
, 0 }, /* 0x94 */
1915 {chm_nosuch
, 0 }, /* 0x95 */
1916 {chm_nosuch
, 0 }, /* 0x96 */
1917 {chm_nosuch
, 0 }, /* 0x97 */
1918 {chm_nosuch
, 0 }, /* 0x98 */
1919 {chm_nosuch
, 0 }, /* 0x99 */
1920 {chm_nosuch
, 0 }, /* 0x9a */
1921 {chm_nosuch
, 0 }, /* 0x9b */
1922 {chm_nosuch
, 0 }, /* 0x9c */
1923 {chm_nosuch
, 0 }, /* 0x9d */
1924 {chm_nosuch
, 0 }, /* 0x9e */
1925 {chm_nosuch
, 0 }, /* 0x9f */
1927 {chm_nosuch
, 0 }, /* 0xa0 */
1928 {chm_nosuch
, 0 }, /* 0xa1 */
1929 {chm_nosuch
, 0 }, /* 0xa2 */
1930 {chm_nosuch
, 0 }, /* 0xa3 */
1931 {chm_nosuch
, 0 }, /* 0xa4 */
1932 {chm_nosuch
, 0 }, /* 0xa5 */
1933 {chm_nosuch
, 0 }, /* 0xa6 */
1934 {chm_nosuch
, 0 }, /* 0xa7 */
1935 {chm_nosuch
, 0 }, /* 0xa8 */
1936 {chm_nosuch
, 0 }, /* 0xa9 */
1937 {chm_nosuch
, 0 }, /* 0xaa */
1938 {chm_nosuch
, 0 }, /* 0xab */
1939 {chm_nosuch
, 0 }, /* 0xac */
1940 {chm_nosuch
, 0 }, /* 0xad */
1941 {chm_nosuch
, 0 }, /* 0xae */
1942 {chm_nosuch
, 0 }, /* 0xaf */
1944 {chm_nosuch
, 0 }, /* 0xb0 */
1945 {chm_nosuch
, 0 }, /* 0xb1 */
1946 {chm_nosuch
, 0 }, /* 0xb2 */
1947 {chm_nosuch
, 0 }, /* 0xb3 */
1948 {chm_nosuch
, 0 }, /* 0xb4 */
1949 {chm_nosuch
, 0 }, /* 0xb5 */
1950 {chm_nosuch
, 0 }, /* 0xb6 */
1951 {chm_nosuch
, 0 }, /* 0xb7 */
1952 {chm_nosuch
, 0 }, /* 0xb8 */
1953 {chm_nosuch
, 0 }, /* 0xb9 */
1954 {chm_nosuch
, 0 }, /* 0xba */
1955 {chm_nosuch
, 0 }, /* 0xbb */
1956 {chm_nosuch
, 0 }, /* 0xbc */
1957 {chm_nosuch
, 0 }, /* 0xbd */
1958 {chm_nosuch
, 0 }, /* 0xbe */
1959 {chm_nosuch
, 0 }, /* 0xbf */
1961 {chm_nosuch
, 0 }, /* 0xc0 */
1962 {chm_nosuch
, 0 }, /* 0xc1 */
1963 {chm_nosuch
, 0 }, /* 0xc2 */
1964 {chm_nosuch
, 0 }, /* 0xc3 */
1965 {chm_nosuch
, 0 }, /* 0xc4 */
1966 {chm_nosuch
, 0 }, /* 0xc5 */
1967 {chm_nosuch
, 0 }, /* 0xc6 */
1968 {chm_nosuch
, 0 }, /* 0xc7 */
1969 {chm_nosuch
, 0 }, /* 0xc8 */
1970 {chm_nosuch
, 0 }, /* 0xc9 */
1971 {chm_nosuch
, 0 }, /* 0xca */
1972 {chm_nosuch
, 0 }, /* 0xcb */
1973 {chm_nosuch
, 0 }, /* 0xcc */
1974 {chm_nosuch
, 0 }, /* 0xcd */
1975 {chm_nosuch
, 0 }, /* 0xce */
1976 {chm_nosuch
, 0 }, /* 0xcf */
1978 {chm_nosuch
, 0 }, /* 0xd0 */
1979 {chm_nosuch
, 0 }, /* 0xd1 */
1980 {chm_nosuch
, 0 }, /* 0xd2 */
1981 {chm_nosuch
, 0 }, /* 0xd3 */
1982 {chm_nosuch
, 0 }, /* 0xd4 */
1983 {chm_nosuch
, 0 }, /* 0xd5 */
1984 {chm_nosuch
, 0 }, /* 0xd6 */
1985 {chm_nosuch
, 0 }, /* 0xd7 */
1986 {chm_nosuch
, 0 }, /* 0xd8 */
1987 {chm_nosuch
, 0 }, /* 0xd9 */
1988 {chm_nosuch
, 0 }, /* 0xda */
1989 {chm_nosuch
, 0 }, /* 0xdb */
1990 {chm_nosuch
, 0 }, /* 0xdc */
1991 {chm_nosuch
, 0 }, /* 0xdd */
1992 {chm_nosuch
, 0 }, /* 0xde */
1993 {chm_nosuch
, 0 }, /* 0xdf */
1995 {chm_nosuch
, 0 }, /* 0xe0 */
1996 {chm_nosuch
, 0 }, /* 0xe1 */
1997 {chm_nosuch
, 0 }, /* 0xe2 */
1998 {chm_nosuch
, 0 }, /* 0xe3 */
1999 {chm_nosuch
, 0 }, /* 0xe4 */
2000 {chm_nosuch
, 0 }, /* 0xe5 */
2001 {chm_nosuch
, 0 }, /* 0xe6 */
2002 {chm_nosuch
, 0 }, /* 0xe7 */
2003 {chm_nosuch
, 0 }, /* 0xe8 */
2004 {chm_nosuch
, 0 }, /* 0xe9 */
2005 {chm_nosuch
, 0 }, /* 0xea */
2006 {chm_nosuch
, 0 }, /* 0xeb */
2007 {chm_nosuch
, 0 }, /* 0xec */
2008 {chm_nosuch
, 0 }, /* 0xed */
2009 {chm_nosuch
, 0 }, /* 0xee */
2010 {chm_nosuch
, 0 }, /* 0xef */
2012 {chm_nosuch
, 0 }, /* 0xf0 */
2013 {chm_nosuch
, 0 }, /* 0xf1 */
2014 {chm_nosuch
, 0 }, /* 0xf2 */
2015 {chm_nosuch
, 0 }, /* 0xf3 */
2016 {chm_nosuch
, 0 }, /* 0xf4 */
2017 {chm_nosuch
, 0 }, /* 0xf5 */
2018 {chm_nosuch
, 0 }, /* 0xf6 */
2019 {chm_nosuch
, 0 }, /* 0xf7 */
2020 {chm_nosuch
, 0 }, /* 0xf8 */
2021 {chm_nosuch
, 0 }, /* 0xf9 */
2022 {chm_nosuch
, 0 }, /* 0xfa */
2023 {chm_nosuch
, 0 }, /* 0xfb */
2024 {chm_nosuch
, 0 }, /* 0xfc */
2025 {chm_nosuch
, 0 }, /* 0xfd */
2026 {chm_nosuch
, 0 }, /* 0xfe */
2027 {chm_nosuch
, 0 }, /* 0xff */
2032 /* set_channel_mode()
2034 * inputs - client, source, channel, membership pointer, params
2036 * side effects - channel modes/memberships are changed, MODE is issued
2038 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
2041 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
2042 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
2044 static char cmdbuf
[BUFSIZE
];
2045 static char modebuf
[BUFSIZE
];
2046 static char parabuf
[BUFSIZE
];
2049 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
2050 int i
, j
, flags
, override
;
2055 const char *ml
= parv
[0];
2057 struct Client
*fakesource_p
;
2058 int flags_list
[3] = { ALL_MEMBERS
, ONLY_CHANOPS
, ONLY_OPERS
};
2063 mode_limit_simple
= 0;
2065 alevel
= get_channel_access(source_p
, msptr
);
2067 no_override_deop
= 0;
2069 /* Hide connecting server on netburst -- jilles */
2070 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
2073 fakesource_p
= source_p
;
2075 for(; (c
= *ml
) != 0; ml
++)
2089 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
2092 chmode_table
[(unsigned char) c
].mode_type
);
2097 /* bail out if we have nothing to do... */
2101 if(IsServer(source_p
))
2102 rb_sprintf(cmdbuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
2104 rb_sprintf(cmdbuf
, ":%s!%s@%s MODE %s ",
2105 source_p
->name
, source_p
->username
,
2106 source_p
->host
, chptr
->chname
);
2110 for (override
= 0; override
< (IsOverride(source_p
) && alevel
!= CHFL_CHANOP
? 2 : 1); ++override
)
2112 int was_on_chan
= 0;
2119 msptr
->flags
|= CHFL_CHANOP
;
2122 add_user_to_channel(chptr
, source_p
, CHFL_CHANOP
);
2125 for(j
= 0, flags
= flags_list
[0]; j
< 3; j
++, flags
= flags_list
[j
])
2128 mbuf
= modebuf
+ mlen
;
2131 paracount
= paralen
= 0;
2134 for(i
= 0; i
< mode_count
; i
++)
2136 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
2139 if(mode_changes
[i
].override
!= override
)
2142 if(mode_changes
[i
].arg
!= NULL
)
2144 arglen
= strlen(mode_changes
[i
].arg
);
2146 if(arglen
> MODEBUFLEN
- 5)
2152 /* if we're creeping over MAXMODEPARAMSSERV, or over
2153 * bufsize (4 == +/-,modechar,two spaces) send now.
2155 if(mode_changes
[i
].arg
!= NULL
&&
2156 ((paracount
== MAXMODEPARAMSSERV
) ||
2157 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
2163 sendto_channel_local(flags
, chptr
, "%s%s %s",
2164 cmdbuf
, modebuf
, parabuf
);
2167 sendto_wallops_flags(UMODE_WALLOP
, &me
,
2168 "%s is overriding modes on %s: %s %s",
2169 get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2170 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
2171 ":%s WALLOPS :%s is overriding modes on %s: %s %s",
2172 me
.name
, get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2178 paracount
= paralen
= 0;
2180 mbuf
= modebuf
+ mlen
;
2186 if(dir
!= mode_changes
[i
].dir
)
2188 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
2190 dir
= mode_changes
[i
].dir
;
2193 *mbuf
++ = mode_changes
[i
].letter
;
2196 if(mode_changes
[i
].arg
!= NULL
)
2199 len
= rb_sprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
2205 if(paralen
&& parabuf
[paralen
- 1] == ' ')
2206 parabuf
[paralen
- 1] = '\0';
2211 sendto_channel_local(flags
, chptr
, "%s%s %s", cmdbuf
, modebuf
, parabuf
);
2214 sendto_wallops_flags(UMODE_WALLOP
, &me
,
2215 "%s is overriding modes on %s: %s %s",
2216 get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2217 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
2218 ":%s WALLOPS :%s is overriding modes on %s: %s %s",
2219 me
.name
, get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2226 remove_user_from_channel(find_channel_membership(chptr
, source_p
));
2227 else if (!no_override_deop
)
2228 msptr
->flags
&= ~CHFL_CHANOP
;
2232 /* only propagate modes originating locally, or if we're hubbing */
2233 if(MyClient(source_p
) || rb_dlink_list_length(&serv_list
) > 1)
2234 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);