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"
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
60 #define SM_ERR_MLOCK 0x00002000
62 #define MAXMODES_SIMPLE 46 /* a-zA-Z except bqeIov */
64 static struct ChModeChange mode_changes
[BUFSIZE
];
65 static int mode_count
;
66 static int mode_limit
;
67 static int mode_limit_simple
;
69 static int no_override_deop
;
72 char cflagsmyinfo
[256];
73 char cflagsparaminfo
[256];
75 int chmode_flags
[256];
77 /* OPTIMIZE ME! -- dwr */
79 construct_cflags_strings(void)
82 char *ptr
= cflagsbuf
;
83 char *ptr2
= cflagsmyinfo
;
88 for(i
= 0; i
< 256; i
++)
90 if( !(chmode_table
[i
].set_func
== chm_ban
) &&
91 !(chmode_table
[i
].set_func
== chm_forward
) &&
92 !(chmode_table
[i
].set_func
== chm_throttle
) &&
93 !(chmode_table
[i
].set_func
== chm_key
) &&
94 !(chmode_table
[i
].set_func
== chm_limit
) &&
95 !(chmode_table
[i
].set_func
== chm_admin
) &&
96 !(chmode_table
[i
].set_func
== chm_op
) &&
97 !(chmode_table
[i
].set_func
== chm_halfop
) &&
98 !(chmode_table
[i
].set_func
== chm_voice
))
100 chmode_flags
[i
] = chmode_table
[i
].mode_type
;
107 switch (chmode_flags
[i
])
110 case MODE_DISFORWARD
:
111 if(ConfigChannel
.use_forward
)
118 if(rb_dlink_list_length(&service_list
))
125 if(chmode_flags
[i
] != 0 && !(chmode_table
[i
].set_func
== chm_orphaned
))
131 /* Should we leave orphaned check here? -- dwr */
132 if( !(chmode_table
[i
].set_func
== chm_nosuch
) &&
133 !(chmode_table
[i
].set_func
== chm_orphaned
) &&
134 !(chmode_table
[i
].set_func
== chm_admin
&& !ConfigChannel
.use_admin
) &&
135 !(chmode_table
[i
].set_func
== chm_halfop
&& !ConfigChannel
.use_halfop
))
146 construct_cflag_param_string(void)
149 *cflagsparaminfo
= '\0';
150 rb_snprintf(cflagsparaminfo
, sizeof cflagsparaminfo
, "%sb%s%s%s%sklov%s%s",
151 ConfigChannel
.use_admin
? "a" : "",
152 ConfigChannel
.use_except
? "e" : "",
153 ConfigChannel
.use_forward
? "f" : "",
154 ConfigChannel
.use_halfop
? "h" : "",
155 strcasecmp(ConfigChannel
.disabledmodes
, "j") ? "" : "j",
156 strcasecmp(ConfigChannel
.disabledmodes
, "q") ? "" : "q",
157 ConfigChannel
.use_invex
? "I" : "");
164 * outputs - an available cflag bitmask or
165 * 0 if no cflags are available
166 * side effects - NONE
169 find_cflag_slot(void)
171 unsigned int all_cflags
= 0, my_cflag
= 0, i
;
173 for (i
= 0; i
< 256; i
++)
174 all_cflags
|= chmode_flags
[i
];
176 for (my_cflag
= 1; my_cflag
&& (all_cflags
& my_cflag
);
183 cflag_add(char c_
, ChannelModeFunc function
)
185 int c
= (unsigned char)c_
;
187 if (chmode_table
[c
].set_func
!= chm_nosuch
&&
188 chmode_table
[c
].set_func
!= chm_orphaned
)
191 if (chmode_table
[c
].set_func
== chm_nosuch
)
192 chmode_table
[c
].mode_type
= find_cflag_slot();
193 if (chmode_table
[c
].mode_type
== 0)
195 chmode_table
[c
].set_func
= function
;
196 construct_cflags_strings();
197 return chmode_table
[c
].mode_type
;
201 cflag_orphan(char c_
)
203 int c
= (unsigned char)c_
;
205 s_assert(chmode_flags
[c
] != 0);
206 chmode_table
[c
].set_func
= chm_orphaned
;
207 construct_cflags_strings();
211 get_channel_access(struct Client
*source_p
, struct membership
*msptr
)
213 if(!MyClient(source_p
) || is_admin(msptr
))
215 else if(is_chanop(msptr
))
217 else if(is_halfop(msptr
))
225 * inputs - client, channel, id to add, type
226 * outputs - 0 on failure, 1 on success
227 * side effects - given id is added to the appropriate list
230 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
,
231 rb_dlink_list
* list
, long mode_type
)
233 struct Ban
*actualBan
;
234 static char who
[USERHOST_REPLYLEN
];
235 char *realban
= LOCAL_COPY(banid
);
238 /* dont let local clients overflow the banlist, or set redundant
241 if(MyClient(source_p
))
243 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
))
245 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
246 me
.name
, source_p
->name
, chptr
->chname
, realban
);
250 RB_DLINK_FOREACH(ptr
, list
->head
)
252 actualBan
= ptr
->data
;
253 if(mask_match(actualBan
->banstr
, realban
))
257 /* dont let remotes set duplicates */
260 RB_DLINK_FOREACH(ptr
, list
->head
)
262 actualBan
= ptr
->data
;
263 if(!irccmp(actualBan
->banstr
, realban
))
269 if(IsPerson(source_p
))
270 rb_sprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
272 rb_strlcpy(who
, source_p
->name
, sizeof(who
));
274 actualBan
= allocate_ban(realban
, who
);
275 actualBan
->when
= rb_current_time();
277 rb_dlinkAdd(actualBan
, &actualBan
->node
, list
);
279 /* invalidate the can_send() cache */
280 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
288 * inputs - channel, id to remove, type
289 * outputs - 0 on failure, 1 on success
290 * side effects - given id is removed from the appropriate list
293 del_id(struct Channel
*chptr
, const char *banid
, rb_dlink_list
* list
, long mode_type
)
298 if(EmptyString(banid
))
301 RB_DLINK_FOREACH(ptr
, list
->head
)
305 if(irccmp(banid
, banptr
->banstr
) == 0)
307 rb_dlinkDelete(&banptr
->node
, list
);
310 /* invalidate the can_send() cache */
311 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
323 * input - string to check
324 * output - pointer to 'fixed' string, or "*" if empty
325 * side effects - any white space found becomes \0
328 check_string(char *s
)
331 static char splat
[] = "*";
348 * inputs - mask to pretty
349 * outputs - better version of the mask
350 * side effects - mask is chopped to limits, and transformed:
358 pretty_mask(const char *idmask
)
360 static char mask_buf
[BUFSIZE
];
362 char *nick
, *user
, *host
;
365 char ne
= 0, ue
= 0, he
= 0; /* save values at nick[NICKLEN], et all */
368 mask
= LOCAL_COPY(idmask
);
369 mask
= check_string(mask
);
372 nick
= user
= host
= splat
;
374 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
377 old_mask_pos
= mask_pos
;
381 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
382 t
= mask_buf
+ old_mask_pos
+ 1;
388 return mask_buf
+ old_mask_pos
;
392 if((t
= strchr(mask
, '@')) != NULL
)
399 if((t
= strchr(mask
, '!')) != NULL
)
414 else if((t
= strchr(mask
, '!')) != NULL
)
423 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
|| strchr(mask
, '/') != NULL
)
434 /* truncate values to max lengths */
435 if(strlen(nick
) > NICKLEN
- 1)
437 ne
= nick
[NICKLEN
- 1];
438 nick
[NICKLEN
- 1] = '\0';
440 if(strlen(user
) > USERLEN
)
443 user
[USERLEN
] = '\0';
445 if(strlen(host
) > HOSTLEN
)
448 host
[HOSTLEN
] = '\0';
451 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
453 /* restore mask, since we may need to use it again later */
459 nick
[NICKLEN
- 1] = ne
;
465 return mask_buf
+ old_mask_pos
;
471 * output - the same key, fixed
472 * side effects - anything below ascii 13 is discarded, ':' discarded,
473 * high ascii is dropped to lower half of ascii table
480 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
483 if(c
!= ':' && c
!= ',' && c
> ' ')
494 * ouput - the same key, fixed
495 * side effects - high ascii dropped to lower half of table,
496 * CR/LF/':' are dropped
499 fix_key_remote(char *arg
)
503 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
506 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
516 * The handlers for each specific mode.
519 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
520 int alevel
, int parc
, int *parn
,
521 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
523 if(*errors
& SM_ERR_UNKNOWN
)
525 *errors
|= SM_ERR_UNKNOWN
;
526 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
530 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
531 int alevel
, int parc
, int *parn
,
532 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
537 struct DictionaryIter iter
;
539 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
541 if (IsOverride(source_p
))
545 if(!(*errors
& SM_ERR_NOOPS
))
546 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
547 me
.name
, source_p
->name
, chptr
->chname
);
548 *errors
|= SM_ERR_NOOPS
;
553 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
557 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
559 /* if +f is disabled, ignore an attempt to set +QF locally */
560 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
561 (c
== 'Q' || c
== 'F'))
564 chptr
->mode
.mode
|= mode_type
;
566 mode_changes
[mode_count
].letter
= c
;
567 mode_changes
[mode_count
].dir
= MODE_ADD
;
568 mode_changes
[mode_count
].caps
= 0;
569 mode_changes
[mode_count
].nocaps
= 0;
570 mode_changes
[mode_count
].id
= NULL
;
571 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
572 mode_changes
[mode_count
].override
= override
;
573 mode_changes
[mode_count
++].arg
= NULL
;
575 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
577 /* cleanup metadata when the related mode is removed */
580 DICTIONARY_FOREACH(md
, &iter
, chptr
->metadata
)
582 if(!strcmp(md
->value
, "KICKNOREJOIN"))
583 channel_metadata_delete(chptr
, md
->name
, 0);
587 channel_metadata_delete(chptr
, "NOREPEAT", 0);
589 chptr
->mode
.mode
&= ~mode_type
;
591 mode_changes
[mode_count
].letter
= c
;
592 mode_changes
[mode_count
].dir
= MODE_DEL
;
593 mode_changes
[mode_count
].caps
= 0;
594 mode_changes
[mode_count
].nocaps
= 0;
595 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
596 mode_changes
[mode_count
].id
= NULL
;
597 mode_changes
[mode_count
].override
= override
;
598 mode_changes
[mode_count
++].arg
= NULL
;
603 chm_orphaned(struct Client
*source_p
, struct Channel
*chptr
,
604 int alevel
, int parc
, int *parn
,
605 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
607 if(MyClient(source_p
))
609 sendto_one_numeric(source_p
, 469, "Mode %c is disabled.", c
);
613 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
615 chptr
->mode
.mode
|= mode_type
;
617 mode_changes
[mode_count
].letter
= c
;
618 mode_changes
[mode_count
].dir
= MODE_ADD
;
619 mode_changes
[mode_count
].caps
= 0;
620 mode_changes
[mode_count
].nocaps
= 0;
621 mode_changes
[mode_count
].id
= NULL
;
622 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
623 mode_changes
[mode_count
++].arg
= NULL
;
625 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
627 chptr
->mode
.mode
&= ~mode_type
;
629 mode_changes
[mode_count
].letter
= c
;
630 mode_changes
[mode_count
].dir
= MODE_DEL
;
631 mode_changes
[mode_count
].caps
= 0;
632 mode_changes
[mode_count
].nocaps
= 0;
633 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
634 mode_changes
[mode_count
].id
= NULL
;
635 mode_changes
[mode_count
++].arg
= NULL
;
640 chm_hidden(struct Client
*source_p
, struct Channel
*chptr
,
641 int alevel
, int parc
, int *parn
,
642 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
644 if(!IsOper(source_p
) && !IsServer(source_p
))
646 if(!(*errors
& SM_ERR_NOPRIVS
))
647 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
648 *errors
|= SM_ERR_NOPRIVS
;
651 if(MyClient(source_p
) && !IsOperAdmin(source_p
))
653 if(!(*errors
& SM_ERR_NOPRIVS
))
654 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
655 source_p
->name
, "cmodes");
656 *errors
|= SM_ERR_NOPRIVS
;
660 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
665 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
667 chptr
->mode
.mode
|= mode_type
;
669 mode_changes
[mode_count
].letter
= c
;
670 mode_changes
[mode_count
].dir
= MODE_ADD
;
671 mode_changes
[mode_count
].caps
= 0;
672 mode_changes
[mode_count
].nocaps
= 0;
673 mode_changes
[mode_count
].id
= NULL
;
674 mode_changes
[mode_count
].mems
= ONLY_OPERS
;
675 mode_changes
[mode_count
].override
= 0;
676 mode_changes
[mode_count
++].arg
= NULL
;
679 sendto_wallops_flags(UMODE_WALLOP
, &me
,
680 "+%c set on [%s] by %s!%s@%s",
681 c
, chptr
->chname
, source_p
->name
, source_p
->username
, source_p
->host
);
682 ilog(L_MAIN
, "+%c set on [%s] by %s",
683 c
, chptr
->chname
, get_oper_name(source_p
));
685 if(*chptr
->chname
!= '&')
686 sendto_server(NULL
, NULL
, NOCAPS
, NOCAPS
,
687 ":%s WALLOPS :+%c set on [%s] by %s!%s@%s",
688 me
.name
, c
, chptr
->chname
, source_p
->name
, source_p
->username
,
691 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
693 chptr
->mode
.mode
&= ~mode_type
;
695 mode_changes
[mode_count
].letter
= c
;
696 mode_changes
[mode_count
].dir
= MODE_DEL
;
697 mode_changes
[mode_count
].caps
= 0;
698 mode_changes
[mode_count
].nocaps
= 0;
699 mode_changes
[mode_count
].mems
= ONLY_OPERS
;
700 mode_changes
[mode_count
].id
= NULL
;
701 mode_changes
[mode_count
].override
= 0;
702 mode_changes
[mode_count
++].arg
= NULL
;
705 sendto_wallops_flags(UMODE_WALLOP
, &me
,
706 "+%c unset from [%s] by %s!%s@%s",
707 c
, chptr
->chname
, source_p
->name
, source_p
->username
, source_p
->host
);
708 ilog(L_MAIN
, "+%c unset from [%s] by %s",
709 c
, chptr
->chname
, get_oper_name(source_p
));
711 if(*chptr
->chname
!= '&')
712 sendto_server(NULL
, NULL
, NOCAPS
, NOCAPS
,
713 ":%s WALLOPS :+%c unset from [%s] by %s!%s@%s",
714 me
.name
, c
, chptr
->chname
, source_p
->name
, source_p
->username
,
720 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
721 int alevel
, int parc
, int *parn
,
722 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
726 if(!IsOper(source_p
) && !IsServer(source_p
))
728 if(!(*errors
& SM_ERR_NOPRIVS
))
729 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
730 *errors
|= SM_ERR_NOPRIVS
;
733 if(MyClient(source_p
) && !IsOperResv(source_p
))
735 if(!(*errors
& SM_ERR_NOPRIVS
))
736 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
737 source_p
->name
, "resv");
738 *errors
|= SM_ERR_NOPRIVS
;
742 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
744 if (IsOverride(source_p
))
748 if(!(*errors
& SM_ERR_NOOPS
))
749 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
750 me
.name
, source_p
->name
, chptr
->chname
);
751 *errors
|= SM_ERR_NOOPS
;
756 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
760 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
762 chptr
->mode
.mode
|= mode_type
;
764 mode_changes
[mode_count
].letter
= c
;
765 mode_changes
[mode_count
].dir
= MODE_ADD
;
766 mode_changes
[mode_count
].caps
= 0;
767 mode_changes
[mode_count
].nocaps
= 0;
768 mode_changes
[mode_count
].id
= NULL
;
769 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
770 mode_changes
[mode_count
].override
= override
;
771 mode_changes
[mode_count
++].arg
= NULL
;
773 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
775 chptr
->mode
.mode
&= ~mode_type
;
777 mode_changes
[mode_count
].letter
= c
;
778 mode_changes
[mode_count
].dir
= MODE_DEL
;
779 mode_changes
[mode_count
].caps
= 0;
780 mode_changes
[mode_count
].nocaps
= 0;
781 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
782 mode_changes
[mode_count
].override
= override
;
783 mode_changes
[mode_count
].id
= NULL
;
784 mode_changes
[mode_count
++].arg
= NULL
;
789 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
790 int alevel
, int parc
, int *parn
,
791 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
794 const char *raw_mask
;
808 list
= &chptr
->banlist
;
809 errorval
= SM_ERR_RPL_B
;
810 rpl_list
= RPL_BANLIST
;
811 rpl_endlist
= RPL_ENDOFBANLIST
;
817 /* if +e is disabled, allow all but +e locally */
818 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
819 ((dir
== MODE_ADD
) && (parc
> *parn
)))
822 list
= &chptr
->exceptlist
;
823 errorval
= SM_ERR_RPL_E
;
824 rpl_list
= RPL_EXCEPTLIST
;
825 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
828 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
835 /* if +I is disabled, allow all but +I locally */
836 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
837 (dir
== MODE_ADD
) && (parc
> *parn
))
840 list
= &chptr
->invexlist
;
841 errorval
= SM_ERR_RPL_I
;
842 rpl_list
= RPL_INVITELIST
;
843 rpl_endlist
= RPL_ENDOFINVITELIST
;
846 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
853 list
= &chptr
->quietlist
;
854 errorval
= SM_ERR_RPL_Q
;
855 rpl_list
= RPL_QUIETLIST
;
856 rpl_endlist
= RPL_ENDOFQUIETLIST
;
862 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
867 if(dir
== 0 || parc
<= *parn
)
869 if((*errors
& errorval
) != 0)
873 /* non-ops cant see +eI lists.. */
874 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
&& mode_type
!= CHFL_BAN
&&
875 mode_type
!= CHFL_QUIET
)
877 if(IsOverride(source_p
))
879 sendto_wallops_flags(UMODE_WALLOP
, &me
,
880 "%s is overriding modes on %s: (%s list)",
881 get_oper_name(source_p
), chptr
->chname
, mode_type
== CHFL_INVEX
? "invex" : "exempt");
882 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
883 ":%s WALLOPS :%s is overriding modes on %s: (%s list)",
884 me
.name
, get_oper_name(source_p
), chptr
->chname
, mode_type
== CHFL_INVEX
? "invex" : "exempt");
889 if(!(*errors
& SM_ERR_NOOPS
))
890 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
891 me
.name
, source_p
->name
, chptr
->chname
);
892 *errors
|= SM_ERR_NOOPS
;
897 RB_DLINK_FOREACH(ptr
, list
->head
)
900 sendto_one(source_p
, form_str(rpl_list
),
901 me
.name
, source_p
->name
, chptr
->chname
,
902 banptr
->banstr
, banptr
->who
, banptr
->when
);
904 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
908 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
910 if(IsOverride(source_p
))
915 if(!(*errors
& SM_ERR_NOOPS
))
916 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
917 me
.name
, source_p
->name
, chptr
->chname
);
918 *errors
|= SM_ERR_NOOPS
;
923 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
926 raw_mask
= parv
[(*parn
)];
929 /* empty ban, or starts with ':' which messes up s2s, ignore it */
930 if(EmptyString(raw_mask
) || *raw_mask
== ':')
933 if(!MyClient(source_p
))
935 if(strchr(raw_mask
, ' '))
941 mask
= pretty_mask(raw_mask
);
943 /* we'd have problems parsing this, hyb6 does it too
944 * also make sure it will always fit on a line with channel
947 if(strlen(mask
) > IRCD_MIN(BANLEN
, MODEBUFLEN
- 5))
950 /* if we're adding a NEW id */
953 if (*mask
== '$' && MyClient(source_p
))
955 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
956 /* XXX perhaps return an error message here */
960 /* dont allow local clients to overflow the banlist, dont
961 * let remote servers set duplicate bans
963 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
966 mode_changes
[mode_count
].letter
= c
;
967 mode_changes
[mode_count
].dir
= MODE_ADD
;
968 mode_changes
[mode_count
].caps
= caps
;
969 mode_changes
[mode_count
].nocaps
= 0;
970 mode_changes
[mode_count
].mems
= mems
;
971 mode_changes
[mode_count
].id
= NULL
;
972 mode_changes
[mode_count
].override
= override
;
973 mode_changes
[mode_count
++].arg
= mask
;
975 else if(dir
== MODE_DEL
)
977 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
979 /* mask isn't a valid ban, check raw_mask */
980 if(del_id(chptr
, raw_mask
, list
, mode_type
))
984 mode_changes
[mode_count
].letter
= c
;
985 mode_changes
[mode_count
].dir
= MODE_DEL
;
986 mode_changes
[mode_count
].caps
= caps
;
987 mode_changes
[mode_count
].nocaps
= 0;
988 mode_changes
[mode_count
].mems
= mems
;
989 mode_changes
[mode_count
].id
= NULL
;
990 mode_changes
[mode_count
].override
= override
;
991 mode_changes
[mode_count
++].arg
= mask
;
996 chm_admin(struct Client
*source_p
, struct Channel
*chptr
,
997 int alevel
, int parc
, int *parn
,
998 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1000 struct membership
*mstptr
;
1001 const char *adminnick
;
1002 struct Client
*targ_p
;
1005 if(!ConfigChannel
.use_admin
)
1007 if(*errors
& SM_ERR_UNKNOWN
)
1009 *errors
|= SM_ERR_UNKNOWN
;
1010 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
1014 if(alevel
!= CHFL_ADMIN
)
1016 if(IsOverride(source_p
))
1021 if(!(*errors
& SM_ERR_NOOPS
))
1022 sendto_one(source_p
, ":%s 482 %s %s :You're not a channel administrator", me
.name
, source_p
->name
, chptr
->chname
);
1023 *errors
|= SM_ERR_NOOPS
;
1028 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
1031 adminnick
= parv
[(*parn
)];
1035 if(EmptyString(adminnick
))
1037 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1041 if((targ_p
= find_chasing(source_p
, adminnick
, NULL
)) == NULL
)
1046 mstptr
= find_channel_membership(chptr
, targ_p
);
1050 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1051 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1052 form_str(ERR_USERNOTINCHANNEL
), adminnick
, chptr
->chname
);
1053 *errors
|= SM_ERR_NOTONCHANNEL
;
1057 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1062 if(targ_p
== source_p
)
1064 no_override_deop
= 1;
1065 /* Don't reject modes from remote. It desyncs, and this is perfectly
1066 * legitimate from a remote override oper.
1072 mode_changes
[mode_count
].letter
= c
;
1073 mode_changes
[mode_count
].dir
= MODE_ADD
;
1074 mode_changes
[mode_count
].caps
= 0;
1075 mode_changes
[mode_count
].nocaps
= 0;
1076 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1077 mode_changes
[mode_count
].id
= targ_p
->id
;
1078 mode_changes
[mode_count
].arg
= targ_p
->name
;
1079 mode_changes
[mode_count
].override
= override
;
1080 mode_changes
[mode_count
++].client
= targ_p
;
1082 mstptr
->flags
|= CHFL_ADMIN
;
1086 if(MyClient(source_p
) && IsService(targ_p
))
1088 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1089 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1093 mode_changes
[mode_count
].letter
= c
;
1094 mode_changes
[mode_count
].dir
= MODE_DEL
;
1095 mode_changes
[mode_count
].caps
= 0;
1096 mode_changes
[mode_count
].nocaps
= 0;
1097 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1098 mode_changes
[mode_count
].id
= targ_p
->id
;
1099 mode_changes
[mode_count
].arg
= targ_p
->name
;
1100 mode_changes
[mode_count
].override
= override
;
1101 mode_changes
[mode_count
++].client
= targ_p
;
1103 mstptr
->flags
&= ~CHFL_ADMIN
;
1108 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
1109 int alevel
, int parc
, int *parn
,
1110 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1112 struct membership
*mstptr
;
1114 struct Client
*targ_p
;
1117 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
)
1119 if(IsOverride(source_p
))
1124 if(!(*errors
& SM_ERR_NOOPS
))
1125 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1126 me
.name
, source_p
->name
, chptr
->chname
);
1127 *errors
|= SM_ERR_NOOPS
;
1132 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
1135 opnick
= parv
[(*parn
)];
1139 if(EmptyString(opnick
))
1141 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1145 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
1150 mstptr
= find_channel_membership(chptr
, targ_p
);
1154 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1155 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1156 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
1157 *errors
|= SM_ERR_NOTONCHANNEL
;
1161 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1166 if(targ_p
== source_p
)
1168 no_override_deop
= 1;
1169 /* Don't reject modes from remote. It desyncs, and this is perfectly
1170 * legitimate from a remote override oper.
1176 mode_changes
[mode_count
].letter
= c
;
1177 mode_changes
[mode_count
].dir
= MODE_ADD
;
1178 mode_changes
[mode_count
].caps
= 0;
1179 mode_changes
[mode_count
].nocaps
= 0;
1180 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1181 mode_changes
[mode_count
].id
= targ_p
->id
;
1182 mode_changes
[mode_count
].arg
= targ_p
->name
;
1183 mode_changes
[mode_count
].override
= override
;
1184 mode_changes
[mode_count
++].client
= targ_p
;
1186 mstptr
->flags
|= CHFL_CHANOP
;
1190 if(MyClient(source_p
) && IsService(targ_p
))
1192 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1193 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1197 mode_changes
[mode_count
].letter
= c
;
1198 mode_changes
[mode_count
].dir
= MODE_DEL
;
1199 mode_changes
[mode_count
].caps
= 0;
1200 mode_changes
[mode_count
].nocaps
= 0;
1201 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1202 mode_changes
[mode_count
].id
= targ_p
->id
;
1203 mode_changes
[mode_count
].arg
= targ_p
->name
;
1204 mode_changes
[mode_count
].override
= override
;
1205 mode_changes
[mode_count
++].client
= targ_p
;
1207 mstptr
->flags
&= ~CHFL_CHANOP
;
1212 chm_halfop(struct Client
*source_p
, struct Channel
*chptr
,
1213 int alevel
, int parc
, int *parn
,
1214 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1216 struct membership
*mstptr
;
1217 const char *halfopnick
;
1218 struct Client
*targ_p
;
1221 if(!ConfigChannel
.use_halfop
)
1223 if(*errors
& SM_ERR_UNKNOWN
)
1225 *errors
|= SM_ERR_UNKNOWN
;
1226 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
1230 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
)
1232 if(IsOverride(source_p
))
1237 if(!(*errors
& SM_ERR_NOOPS
))
1238 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1239 me
.name
, source_p
->name
, chptr
->chname
);
1240 *errors
|= SM_ERR_NOOPS
;
1245 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
1248 halfopnick
= parv
[(*parn
)];
1252 if(EmptyString(halfopnick
))
1254 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1258 if((targ_p
= find_chasing(source_p
, halfopnick
, NULL
)) == NULL
)
1263 mstptr
= find_channel_membership(chptr
, targ_p
);
1267 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1268 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1269 form_str(ERR_USERNOTINCHANNEL
), halfopnick
, chptr
->chname
);
1270 *errors
|= SM_ERR_NOTONCHANNEL
;
1274 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1279 if(targ_p
== source_p
)
1281 no_override_deop
= 1;
1282 /* Don't reject modes from remote. It desyncs, and this is perfectly
1283 * legitimate from a remote override oper.
1289 mode_changes
[mode_count
].letter
= c
;
1290 mode_changes
[mode_count
].dir
= MODE_ADD
;
1291 mode_changes
[mode_count
].caps
= 0;
1292 mode_changes
[mode_count
].nocaps
= 0;
1293 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1294 mode_changes
[mode_count
].id
= targ_p
->id
;
1295 mode_changes
[mode_count
].arg
= targ_p
->name
;
1296 mode_changes
[mode_count
].override
= override
;
1297 mode_changes
[mode_count
++].client
= targ_p
;
1299 mstptr
->flags
|= CHFL_HALFOP
;
1303 if(MyClient(source_p
) && IsService(targ_p
))
1305 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1306 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1310 mode_changes
[mode_count
].letter
= c
;
1311 mode_changes
[mode_count
].dir
= MODE_DEL
;
1312 mode_changes
[mode_count
].caps
= 0;
1313 mode_changes
[mode_count
].nocaps
= 0;
1314 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1315 mode_changes
[mode_count
].id
= targ_p
->id
;
1316 mode_changes
[mode_count
].arg
= targ_p
->name
;
1317 mode_changes
[mode_count
].override
= override
;
1318 mode_changes
[mode_count
++].client
= targ_p
;
1320 mstptr
->flags
&= ~CHFL_HALFOP
;
1325 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
1326 int alevel
, int parc
, int *parn
,
1327 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1329 struct membership
*mstptr
;
1331 struct Client
*targ_p
;
1334 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1336 if(IsOverride(source_p
))
1341 if(!(*errors
& SM_ERR_NOOPS
))
1342 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1343 me
.name
, source_p
->name
, chptr
->chname
);
1344 *errors
|= SM_ERR_NOOPS
;
1349 if((dir
== MODE_QUERY
) || parc
<= *parn
)
1352 opnick
= parv
[(*parn
)];
1356 if(EmptyString(opnick
))
1358 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1362 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
1367 mstptr
= find_channel_membership(chptr
, targ_p
);
1371 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1372 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1373 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
1374 *errors
|= SM_ERR_NOTONCHANNEL
;
1378 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1383 mode_changes
[mode_count
].letter
= c
;
1384 mode_changes
[mode_count
].dir
= MODE_ADD
;
1385 mode_changes
[mode_count
].caps
= 0;
1386 mode_changes
[mode_count
].nocaps
= 0;
1387 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1388 mode_changes
[mode_count
].id
= targ_p
->id
;
1389 mode_changes
[mode_count
].arg
= targ_p
->name
;
1390 mode_changes
[mode_count
].override
= override
;
1391 mode_changes
[mode_count
++].client
= targ_p
;
1393 mstptr
->flags
|= CHFL_VOICE
;
1397 mode_changes
[mode_count
].letter
= 'v';
1398 mode_changes
[mode_count
].dir
= MODE_DEL
;
1399 mode_changes
[mode_count
].caps
= 0;
1400 mode_changes
[mode_count
].nocaps
= 0;
1401 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1402 mode_changes
[mode_count
].id
= targ_p
->id
;
1403 mode_changes
[mode_count
].arg
= targ_p
->name
;
1404 mode_changes
[mode_count
].override
= override
;
1405 mode_changes
[mode_count
++].client
= targ_p
;
1407 mstptr
->flags
&= ~CHFL_VOICE
;
1412 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
1413 int alevel
, int parc
, int *parn
,
1414 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1417 static char limitstr
[30];
1421 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1423 if(IsOverride(source_p
))
1427 if(!(*errors
& SM_ERR_NOOPS
))
1428 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1429 me
.name
, source_p
->name
, chptr
->chname
);
1430 *errors
|= SM_ERR_NOOPS
;
1435 if(dir
== MODE_QUERY
)
1438 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1441 if((dir
== MODE_ADD
) && parc
> *parn
)
1443 lstr
= parv
[(*parn
)];
1446 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
1449 rb_sprintf(limitstr
, "%d", limit
);
1451 mode_changes
[mode_count
].letter
= c
;
1452 mode_changes
[mode_count
].dir
= MODE_ADD
;
1453 mode_changes
[mode_count
].caps
= 0;
1454 mode_changes
[mode_count
].nocaps
= 0;
1455 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1456 mode_changes
[mode_count
].id
= NULL
;
1457 mode_changes
[mode_count
].override
= override
;
1458 mode_changes
[mode_count
++].arg
= limitstr
;
1460 chptr
->mode
.limit
= limit
;
1462 else if(dir
== MODE_DEL
)
1464 if(!chptr
->mode
.limit
)
1467 chptr
->mode
.limit
= 0;
1469 mode_changes
[mode_count
].letter
= c
;
1470 mode_changes
[mode_count
].dir
= MODE_DEL
;
1471 mode_changes
[mode_count
].caps
= 0;
1472 mode_changes
[mode_count
].nocaps
= 0;
1473 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1474 mode_changes
[mode_count
].id
= NULL
;
1475 mode_changes
[mode_count
].override
= override
;
1476 mode_changes
[mode_count
++].arg
= NULL
;
1481 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
1482 int alevel
, int parc
, int *parn
,
1483 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1485 int joins
= 0, timeslice
= 0;
1488 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1490 if(IsOverride(source_p
))
1495 if(!(*errors
& SM_ERR_NOOPS
))
1496 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1497 me
.name
, source_p
->name
, chptr
->chname
);
1498 *errors
|= SM_ERR_NOOPS
;
1503 if(dir
== MODE_QUERY
)
1506 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1509 if((dir
== MODE_ADD
) && parc
> *parn
)
1511 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
1513 if(!joins
|| !timeslice
)
1516 mode_changes
[mode_count
].letter
= c
;
1517 mode_changes
[mode_count
].dir
= MODE_ADD
;
1518 mode_changes
[mode_count
].caps
= 0;
1519 mode_changes
[mode_count
].nocaps
= 0;
1520 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1521 mode_changes
[mode_count
].id
= NULL
;
1522 mode_changes
[mode_count
].override
= override
;
1523 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
1527 chptr
->mode
.join_num
= joins
;
1528 chptr
->mode
.join_time
= timeslice
;
1530 else if(dir
== MODE_DEL
)
1532 if(!chptr
->mode
.join_num
)
1535 chptr
->mode
.join_num
= 0;
1536 chptr
->mode
.join_time
= 0;
1537 chptr
->join_count
= 0;
1538 chptr
->join_delta
= 0;
1540 mode_changes
[mode_count
].letter
= c
;
1541 mode_changes
[mode_count
].dir
= MODE_DEL
;
1542 mode_changes
[mode_count
].caps
= 0;
1543 mode_changes
[mode_count
].nocaps
= 0;
1544 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1545 mode_changes
[mode_count
].id
= NULL
;
1546 mode_changes
[mode_count
].override
= override
;
1547 mode_changes
[mode_count
++].arg
= NULL
;
1552 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
1553 int alevel
, int parc
, int *parn
,
1554 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1556 struct Channel
*targptr
= NULL
;
1557 struct membership
*msptr
;
1558 const char *forward
;
1561 /* if +f is disabled, ignore local attempts to set it */
1562 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
1563 (dir
== MODE_ADD
) && (parc
> *parn
))
1566 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
1568 if (!(*errors
& SM_ERR_RPL_F
))
1570 if (*chptr
->mode
.forward
== '\0')
1571 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
1573 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
1574 *errors
|= SM_ERR_RPL_F
;
1579 #ifndef FORWARD_OPERONLY
1580 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1582 if(IsOverride(source_p
))
1586 if(!(*errors
& SM_ERR_NOOPS
))
1587 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1588 me
.name
, source_p
->name
, chptr
->chname
);
1589 *errors
|= SM_ERR_NOOPS
;
1594 if(!IsOper(source_p
) && !IsServer(source_p
))
1596 if(!(*errors
& SM_ERR_NOPRIVS
))
1597 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
1598 *errors
|= SM_ERR_NOPRIVS
;
1603 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1606 if(dir
== MODE_ADD
&& parc
> *parn
)
1608 forward
= parv
[(*parn
)];
1611 if(EmptyString(forward
))
1613 if(!check_channel_name(forward
) ||
1614 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1616 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1619 /* don't forward to inconsistent target -- jilles */
1620 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
1622 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
1623 form_str(ERR_BADCHANNAME
), forward
);
1626 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1628 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1629 form_str(ERR_NOSUCHCHANNEL
), forward
);
1632 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1634 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1637 if(IsOverride(source_p
))
1641 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1642 me
.name
, source_p
->name
, targptr
->chname
);
1648 rb_strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1650 mode_changes
[mode_count
].letter
= c
;
1651 mode_changes
[mode_count
].dir
= MODE_ADD
;
1652 mode_changes
[mode_count
].caps
= 0;
1653 mode_changes
[mode_count
].nocaps
= 0;
1654 mode_changes
[mode_count
].mems
= ConfigChannel
.use_forward
? ALL_MEMBERS
: ONLY_SERVERS
;
1655 mode_changes
[mode_count
].id
= NULL
;
1656 mode_changes
[mode_count
].override
= override
;
1657 mode_changes
[mode_count
++].arg
= forward
;
1659 else if(dir
== MODE_DEL
)
1661 if(!(*chptr
->mode
.forward
))
1664 *chptr
->mode
.forward
= '\0';
1666 mode_changes
[mode_count
].letter
= c
;
1667 mode_changes
[mode_count
].dir
= MODE_DEL
;
1668 mode_changes
[mode_count
].caps
= 0;
1669 mode_changes
[mode_count
].nocaps
= 0;
1670 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1671 mode_changes
[mode_count
].id
= NULL
;
1672 mode_changes
[mode_count
].override
= override
;
1673 mode_changes
[mode_count
++].arg
= NULL
;
1678 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1679 int alevel
, int parc
, int *parn
,
1680 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1685 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1687 if(IsOverride(source_p
))
1691 if(!(*errors
& SM_ERR_NOOPS
))
1692 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1693 me
.name
, source_p
->name
, chptr
->chname
);
1694 *errors
|= SM_ERR_NOOPS
;
1699 if(dir
== MODE_QUERY
)
1702 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1705 if((dir
== MODE_ADD
) && parc
> *parn
)
1707 key
= LOCAL_COPY(parv
[(*parn
)]);
1710 if(MyClient(source_p
))
1713 fix_key_remote(key
);
1715 if(EmptyString(key
))
1718 s_assert(key
[0] != ' ');
1719 rb_strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1721 mode_changes
[mode_count
].letter
= c
;
1722 mode_changes
[mode_count
].dir
= MODE_ADD
;
1723 mode_changes
[mode_count
].caps
= 0;
1724 mode_changes
[mode_count
].nocaps
= 0;
1725 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1726 mode_changes
[mode_count
].id
= NULL
;
1727 mode_changes
[mode_count
].override
= override
;
1728 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1730 else if(dir
== MODE_DEL
)
1732 static char splat
[] = "*";
1738 if(!(*chptr
->mode
.key
))
1741 /* hack time. when we get a +k-k mode, the +k arg is
1742 * chptr->mode.key, which the -k sets to \0, so hunt for a
1743 * +k when we get a -k, and set the arg to splat. --anfl
1745 for(i
= 0; i
< mode_count
; i
++)
1747 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1748 mode_changes
[i
].arg
= splat
;
1751 *chptr
->mode
.key
= 0;
1753 mode_changes
[mode_count
].letter
= c
;
1754 mode_changes
[mode_count
].dir
= MODE_DEL
;
1755 mode_changes
[mode_count
].caps
= 0;
1756 mode_changes
[mode_count
].nocaps
= 0;
1757 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1758 mode_changes
[mode_count
].id
= NULL
;
1759 mode_changes
[mode_count
].override
= override
;
1760 mode_changes
[mode_count
++].arg
= "*";
1765 struct ChannelMode chmode_table
[256] =
1767 {chm_nosuch
, 0 }, /* 0x00 */
1768 {chm_nosuch
, 0 }, /* 0x01 */
1769 {chm_nosuch
, 0 }, /* 0x02 */
1770 {chm_nosuch
, 0 }, /* 0x03 */
1771 {chm_nosuch
, 0 }, /* 0x04 */
1772 {chm_nosuch
, 0 }, /* 0x05 */
1773 {chm_nosuch
, 0 }, /* 0x06 */
1774 {chm_nosuch
, 0 }, /* 0x07 */
1775 {chm_nosuch
, 0 }, /* 0x08 */
1776 {chm_nosuch
, 0 }, /* 0x09 */
1777 {chm_nosuch
, 0 }, /* 0x0a */
1778 {chm_nosuch
, 0 }, /* 0x0b */
1779 {chm_nosuch
, 0 }, /* 0x0c */
1780 {chm_nosuch
, 0 }, /* 0x0d */
1781 {chm_nosuch
, 0 }, /* 0x0e */
1782 {chm_nosuch
, 0 }, /* 0x0f */
1783 {chm_nosuch
, 0 }, /* 0x10 */
1784 {chm_nosuch
, 0 }, /* 0x11 */
1785 {chm_nosuch
, 0 }, /* 0x12 */
1786 {chm_nosuch
, 0 }, /* 0x13 */
1787 {chm_nosuch
, 0 }, /* 0x14 */
1788 {chm_nosuch
, 0 }, /* 0x15 */
1789 {chm_nosuch
, 0 }, /* 0x16 */
1790 {chm_nosuch
, 0 }, /* 0x17 */
1791 {chm_nosuch
, 0 }, /* 0x18 */
1792 {chm_nosuch
, 0 }, /* 0x19 */
1793 {chm_nosuch
, 0 }, /* 0x1a */
1794 {chm_nosuch
, 0 }, /* 0x1b */
1795 {chm_nosuch
, 0 }, /* 0x1c */
1796 {chm_nosuch
, 0 }, /* 0x1d */
1797 {chm_nosuch
, 0 }, /* 0x1e */
1798 {chm_nosuch
, 0 }, /* 0x1f */
1799 {chm_nosuch
, 0 }, /* 0x20 */
1800 {chm_nosuch
, 0 }, /* 0x21 */
1801 {chm_nosuch
, 0 }, /* 0x22 */
1802 {chm_nosuch
, 0 }, /* 0x23 */
1803 {chm_nosuch
, 0 }, /* 0x24 */
1804 {chm_nosuch
, 0 }, /* 0x25 */
1805 {chm_nosuch
, 0 }, /* 0x26 */
1806 {chm_nosuch
, 0 }, /* 0x27 */
1807 {chm_nosuch
, 0 }, /* 0x28 */
1808 {chm_nosuch
, 0 }, /* 0x29 */
1809 {chm_nosuch
, 0 }, /* 0x2a */
1810 {chm_nosuch
, 0 }, /* 0x2b */
1811 {chm_nosuch
, 0 }, /* 0x2c */
1812 {chm_nosuch
, 0 }, /* 0x2d */
1813 {chm_nosuch
, 0 }, /* 0x2e */
1814 {chm_nosuch
, 0 }, /* 0x2f */
1815 {chm_nosuch
, 0 }, /* 0x30 */
1816 {chm_nosuch
, 0 }, /* 0x31 */
1817 {chm_nosuch
, 0 }, /* 0x32 */
1818 {chm_nosuch
, 0 }, /* 0x33 */
1819 {chm_nosuch
, 0 }, /* 0x34 */
1820 {chm_nosuch
, 0 }, /* 0x35 */
1821 {chm_nosuch
, 0 }, /* 0x36 */
1822 {chm_nosuch
, 0 }, /* 0x37 */
1823 {chm_nosuch
, 0 }, /* 0x38 */
1824 {chm_nosuch
, 0 }, /* 0x39 */
1825 {chm_nosuch
, 0 }, /* 0x3a */
1826 {chm_nosuch
, 0 }, /* 0x3b */
1827 {chm_nosuch
, 0 }, /* 0x3c */
1828 {chm_nosuch
, 0 }, /* 0x3d */
1829 {chm_nosuch
, 0 }, /* 0x3e */
1830 {chm_nosuch
, 0 }, /* 0x3f */
1832 {chm_nosuch
, 0 }, /* @ */
1833 {chm_nosuch
, 0 }, /* A */
1834 {chm_nosuch
, 0 }, /* B */
1835 {chm_simple
, MODE_NOCTCP
}, /* C */
1836 {chm_simple
, MODE_NOACTION
}, /* D */
1837 {chm_simple
, MODE_NOKICK
}, /* E */
1838 {chm_simple
, MODE_FREETARGET
}, /* F */
1839 {chm_simple
, MODE_NOCAPS
}, /* G */
1840 {chm_nosuch
, 0 }, /* H */
1841 {chm_ban
, CHFL_INVEX
}, /* I */
1842 {chm_simple
, MODE_NOREJOIN
}, /* J */
1843 {chm_simple
, MODE_NOREPEAT
}, /* K */
1844 {chm_staff
, MODE_EXLIMIT
}, /* L */
1845 {chm_hidden
, MODE_NOOPERKICK
}, /* M */
1846 {chm_simple
, MODE_NONICK
}, /* N */
1847 {chm_nosuch
, 0 }, /* O */
1848 {chm_staff
, MODE_PERMANENT
}, /* P */
1849 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1850 {chm_nosuch
, 0 }, /* R */
1851 {chm_nosuch
, 0 }, /* S */
1852 {chm_simple
, MODE_NONOTICE
}, /* T */
1853 {chm_nosuch
, 0 }, /* U */
1854 {chm_nosuch
, 0 }, /* V */
1855 {chm_nosuch
, 0 }, /* W */
1856 {chm_nosuch
, 0 }, /* X */
1857 {chm_nosuch
, 0 }, /* Y */
1858 {chm_nosuch
, 0 }, /* Z */
1865 {chm_admin
, 0 }, /* a */
1866 {chm_ban
, CHFL_BAN
}, /* b */
1867 {chm_simple
, MODE_NOCOLOR
}, /* c */
1868 {chm_nosuch
, 0 }, /* d */
1869 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1870 {chm_forward
, 0 }, /* f */
1871 {chm_simple
, MODE_FREEINVITE
}, /* g */
1872 {chm_halfop
, 0 }, /* h */
1873 {chm_simple
, MODE_INVITEONLY
}, /* i */
1874 {chm_throttle
, 0 }, /* j */
1875 {chm_key
, 0 }, /* k */
1876 {chm_limit
, 0 }, /* l */
1877 {chm_simple
, MODE_MODERATED
}, /* m */
1878 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1879 {chm_op
, 0 }, /* o */
1880 {chm_simple
, MODE_PRIVATE
}, /* p */
1881 {chm_ban
, CHFL_QUIET
}, /* q */
1882 {chm_simple
, MODE_REGONLY
}, /* r */
1883 {chm_simple
, MODE_SECRET
}, /* s */
1884 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1885 {chm_nosuch
, 0 }, /* u */
1886 {chm_voice
, 0 }, /* v */
1887 {chm_nosuch
, 0 }, /* w */
1888 {chm_nosuch
, 0 }, /* x */
1889 {chm_nosuch
, 0 }, /* y */
1890 {chm_simple
, MODE_OPMODERATE
}, /* z */
1892 {chm_nosuch
, 0 }, /* 0x7b */
1893 {chm_nosuch
, 0 }, /* 0x7c */
1894 {chm_nosuch
, 0 }, /* 0x7d */
1895 {chm_nosuch
, 0 }, /* 0x7e */
1896 {chm_nosuch
, 0 }, /* 0x7f */
1898 {chm_nosuch
, 0 }, /* 0x80 */
1899 {chm_nosuch
, 0 }, /* 0x81 */
1900 {chm_nosuch
, 0 }, /* 0x82 */
1901 {chm_nosuch
, 0 }, /* 0x83 */
1902 {chm_nosuch
, 0 }, /* 0x84 */
1903 {chm_nosuch
, 0 }, /* 0x85 */
1904 {chm_nosuch
, 0 }, /* 0x86 */
1905 {chm_nosuch
, 0 }, /* 0x87 */
1906 {chm_nosuch
, 0 }, /* 0x88 */
1907 {chm_nosuch
, 0 }, /* 0x89 */
1908 {chm_nosuch
, 0 }, /* 0x8a */
1909 {chm_nosuch
, 0 }, /* 0x8b */
1910 {chm_nosuch
, 0 }, /* 0x8c */
1911 {chm_nosuch
, 0 }, /* 0x8d */
1912 {chm_nosuch
, 0 }, /* 0x8e */
1913 {chm_nosuch
, 0 }, /* 0x8f */
1915 {chm_nosuch
, 0 }, /* 0x90 */
1916 {chm_nosuch
, 0 }, /* 0x91 */
1917 {chm_nosuch
, 0 }, /* 0x92 */
1918 {chm_nosuch
, 0 }, /* 0x93 */
1919 {chm_nosuch
, 0 }, /* 0x94 */
1920 {chm_nosuch
, 0 }, /* 0x95 */
1921 {chm_nosuch
, 0 }, /* 0x96 */
1922 {chm_nosuch
, 0 }, /* 0x97 */
1923 {chm_nosuch
, 0 }, /* 0x98 */
1924 {chm_nosuch
, 0 }, /* 0x99 */
1925 {chm_nosuch
, 0 }, /* 0x9a */
1926 {chm_nosuch
, 0 }, /* 0x9b */
1927 {chm_nosuch
, 0 }, /* 0x9c */
1928 {chm_nosuch
, 0 }, /* 0x9d */
1929 {chm_nosuch
, 0 }, /* 0x9e */
1930 {chm_nosuch
, 0 }, /* 0x9f */
1932 {chm_nosuch
, 0 }, /* 0xa0 */
1933 {chm_nosuch
, 0 }, /* 0xa1 */
1934 {chm_nosuch
, 0 }, /* 0xa2 */
1935 {chm_nosuch
, 0 }, /* 0xa3 */
1936 {chm_nosuch
, 0 }, /* 0xa4 */
1937 {chm_nosuch
, 0 }, /* 0xa5 */
1938 {chm_nosuch
, 0 }, /* 0xa6 */
1939 {chm_nosuch
, 0 }, /* 0xa7 */
1940 {chm_nosuch
, 0 }, /* 0xa8 */
1941 {chm_nosuch
, 0 }, /* 0xa9 */
1942 {chm_nosuch
, 0 }, /* 0xaa */
1943 {chm_nosuch
, 0 }, /* 0xab */
1944 {chm_nosuch
, 0 }, /* 0xac */
1945 {chm_nosuch
, 0 }, /* 0xad */
1946 {chm_nosuch
, 0 }, /* 0xae */
1947 {chm_nosuch
, 0 }, /* 0xaf */
1949 {chm_nosuch
, 0 }, /* 0xb0 */
1950 {chm_nosuch
, 0 }, /* 0xb1 */
1951 {chm_nosuch
, 0 }, /* 0xb2 */
1952 {chm_nosuch
, 0 }, /* 0xb3 */
1953 {chm_nosuch
, 0 }, /* 0xb4 */
1954 {chm_nosuch
, 0 }, /* 0xb5 */
1955 {chm_nosuch
, 0 }, /* 0xb6 */
1956 {chm_nosuch
, 0 }, /* 0xb7 */
1957 {chm_nosuch
, 0 }, /* 0xb8 */
1958 {chm_nosuch
, 0 }, /* 0xb9 */
1959 {chm_nosuch
, 0 }, /* 0xba */
1960 {chm_nosuch
, 0 }, /* 0xbb */
1961 {chm_nosuch
, 0 }, /* 0xbc */
1962 {chm_nosuch
, 0 }, /* 0xbd */
1963 {chm_nosuch
, 0 }, /* 0xbe */
1964 {chm_nosuch
, 0 }, /* 0xbf */
1966 {chm_nosuch
, 0 }, /* 0xc0 */
1967 {chm_nosuch
, 0 }, /* 0xc1 */
1968 {chm_nosuch
, 0 }, /* 0xc2 */
1969 {chm_nosuch
, 0 }, /* 0xc3 */
1970 {chm_nosuch
, 0 }, /* 0xc4 */
1971 {chm_nosuch
, 0 }, /* 0xc5 */
1972 {chm_nosuch
, 0 }, /* 0xc6 */
1973 {chm_nosuch
, 0 }, /* 0xc7 */
1974 {chm_nosuch
, 0 }, /* 0xc8 */
1975 {chm_nosuch
, 0 }, /* 0xc9 */
1976 {chm_nosuch
, 0 }, /* 0xca */
1977 {chm_nosuch
, 0 }, /* 0xcb */
1978 {chm_nosuch
, 0 }, /* 0xcc */
1979 {chm_nosuch
, 0 }, /* 0xcd */
1980 {chm_nosuch
, 0 }, /* 0xce */
1981 {chm_nosuch
, 0 }, /* 0xcf */
1983 {chm_nosuch
, 0 }, /* 0xd0 */
1984 {chm_nosuch
, 0 }, /* 0xd1 */
1985 {chm_nosuch
, 0 }, /* 0xd2 */
1986 {chm_nosuch
, 0 }, /* 0xd3 */
1987 {chm_nosuch
, 0 }, /* 0xd4 */
1988 {chm_nosuch
, 0 }, /* 0xd5 */
1989 {chm_nosuch
, 0 }, /* 0xd6 */
1990 {chm_nosuch
, 0 }, /* 0xd7 */
1991 {chm_nosuch
, 0 }, /* 0xd8 */
1992 {chm_nosuch
, 0 }, /* 0xd9 */
1993 {chm_nosuch
, 0 }, /* 0xda */
1994 {chm_nosuch
, 0 }, /* 0xdb */
1995 {chm_nosuch
, 0 }, /* 0xdc */
1996 {chm_nosuch
, 0 }, /* 0xdd */
1997 {chm_nosuch
, 0 }, /* 0xde */
1998 {chm_nosuch
, 0 }, /* 0xdf */
2000 {chm_nosuch
, 0 }, /* 0xe0 */
2001 {chm_nosuch
, 0 }, /* 0xe1 */
2002 {chm_nosuch
, 0 }, /* 0xe2 */
2003 {chm_nosuch
, 0 }, /* 0xe3 */
2004 {chm_nosuch
, 0 }, /* 0xe4 */
2005 {chm_nosuch
, 0 }, /* 0xe5 */
2006 {chm_nosuch
, 0 }, /* 0xe6 */
2007 {chm_nosuch
, 0 }, /* 0xe7 */
2008 {chm_nosuch
, 0 }, /* 0xe8 */
2009 {chm_nosuch
, 0 }, /* 0xe9 */
2010 {chm_nosuch
, 0 }, /* 0xea */
2011 {chm_nosuch
, 0 }, /* 0xeb */
2012 {chm_nosuch
, 0 }, /* 0xec */
2013 {chm_nosuch
, 0 }, /* 0xed */
2014 {chm_nosuch
, 0 }, /* 0xee */
2015 {chm_nosuch
, 0 }, /* 0xef */
2017 {chm_nosuch
, 0 }, /* 0xf0 */
2018 {chm_nosuch
, 0 }, /* 0xf1 */
2019 {chm_nosuch
, 0 }, /* 0xf2 */
2020 {chm_nosuch
, 0 }, /* 0xf3 */
2021 {chm_nosuch
, 0 }, /* 0xf4 */
2022 {chm_nosuch
, 0 }, /* 0xf5 */
2023 {chm_nosuch
, 0 }, /* 0xf6 */
2024 {chm_nosuch
, 0 }, /* 0xf7 */
2025 {chm_nosuch
, 0 }, /* 0xf8 */
2026 {chm_nosuch
, 0 }, /* 0xf9 */
2027 {chm_nosuch
, 0 }, /* 0xfa */
2028 {chm_nosuch
, 0 }, /* 0xfb */
2029 {chm_nosuch
, 0 }, /* 0xfc */
2030 {chm_nosuch
, 0 }, /* 0xfd */
2031 {chm_nosuch
, 0 }, /* 0xfe */
2032 {chm_nosuch
, 0 }, /* 0xff */
2037 /* set_channel_mode()
2039 * inputs - client, source, channel, membership pointer, params
2041 * side effects - channel modes/memberships are changed, MODE is issued
2043 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
2046 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
2047 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
2049 static char cmdbuf
[BUFSIZE
];
2050 static char modebuf
[BUFSIZE
];
2051 static char parabuf
[BUFSIZE
];
2054 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
2055 int i
, j
, flags
, override
;
2060 const char *ml
= parv
[0];
2062 struct Client
*fakesource_p
;
2063 int flags_list
[3] = { ALL_MEMBERS
, ONLY_CHANOPS
, ONLY_OPERS
};
2068 mode_limit_simple
= 0;
2070 alevel
= get_channel_access(source_p
, msptr
);
2072 no_override_deop
= 0;
2074 /* Hide connecting server on netburst -- jilles */
2075 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
2078 fakesource_p
= source_p
;
2080 for(; (c
= *ml
) != 0; ml
++)
2094 /* If this mode char is locked, don't allow local users to change it. */
2095 if (MyClient(source_p
) && chptr
->mode_lock
&& strchr(chptr
->mode_lock
, c
))
2097 if (!(errors
& SM_ERR_MLOCK
))
2098 sendto_one_numeric(source_p
,
2099 ERR_MLOCKRESTRICTED
,
2100 form_str(ERR_MLOCKRESTRICTED
),
2104 errors
|= SM_ERR_MLOCK
;
2107 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
2110 chmode_table
[(unsigned char) c
].mode_type
);
2115 /* bail out if we have nothing to do... */
2119 if(IsServer(source_p
))
2120 rb_sprintf(cmdbuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
2122 rb_sprintf(cmdbuf
, ":%s!%s@%s MODE %s ",
2123 source_p
->name
, source_p
->username
,
2124 source_p
->host
, chptr
->chname
);
2128 for (override
= 0; override
< (IsOverride(source_p
) && alevel
!= CHFL_CHANOP
? 2 : 1); ++override
)
2130 int was_on_chan
= 0;
2137 msptr
->flags
|= CHFL_CHANOP
;
2140 add_user_to_channel(chptr
, source_p
, CHFL_CHANOP
);
2143 for(j
= 0, flags
= flags_list
[0]; j
< 3; j
++, flags
= flags_list
[j
])
2146 mbuf
= modebuf
+ mlen
;
2149 paracount
= paralen
= 0;
2152 for(i
= 0; i
< mode_count
; i
++)
2154 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
2157 if(mode_changes
[i
].override
!= override
)
2160 if(mode_changes
[i
].arg
!= NULL
)
2162 arglen
= strlen(mode_changes
[i
].arg
);
2164 if(arglen
> MODEBUFLEN
- 5)
2170 /* if we're creeping over MAXMODEPARAMSSERV, or over
2171 * bufsize (4 == +/-,modechar,two spaces) send now.
2173 if(mode_changes
[i
].arg
!= NULL
&&
2174 ((paracount
== MAXMODEPARAMSSERV
) ||
2175 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
2181 sendto_channel_local(flags
, chptr
, "%s%s %s",
2182 cmdbuf
, modebuf
, parabuf
);
2185 sendto_wallops_flags(UMODE_WALLOP
, &me
,
2186 "%s is overriding modes on %s: %s %s",
2187 get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2188 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
2189 ":%s WALLOPS :%s is overriding modes on %s: %s %s",
2190 me
.name
, get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2196 paracount
= paralen
= 0;
2198 mbuf
= modebuf
+ mlen
;
2204 if(dir
!= mode_changes
[i
].dir
)
2206 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
2208 dir
= mode_changes
[i
].dir
;
2211 *mbuf
++ = mode_changes
[i
].letter
;
2214 if(mode_changes
[i
].arg
!= NULL
)
2217 len
= rb_sprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
2223 if(paralen
&& parabuf
[paralen
- 1] == ' ')
2224 parabuf
[paralen
- 1] = '\0';
2229 sendto_channel_local(flags
, chptr
, "%s%s %s", cmdbuf
, modebuf
, parabuf
);
2232 sendto_wallops_flags(UMODE_WALLOP
, &me
,
2233 "%s is overriding modes on %s: %s %s",
2234 get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2235 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
2236 ":%s WALLOPS :%s is overriding modes on %s: %s %s",
2237 me
.name
, get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2244 remove_user_from_channel(find_channel_membership(chptr
, source_p
));
2245 else if (!no_override_deop
)
2246 msptr
->flags
&= ~CHFL_CHANOP
;
2250 /* only propagate modes originating locally, or if we're hubbing */
2251 if(MyClient(source_p
) || rb_dlink_list_length(&serv_list
) > 1)
2252 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);
2255 /* set_channel_mlock()
2257 * inputs - client, source, channel, params
2259 * side effects - channel mlock is changed / MLOCK is propagated
2262 set_channel_mlock(struct Client
*client_p
, struct Client
*source_p
,
2263 struct Channel
*chptr
, const char *newmlock
, int propagate
)
2265 rb_free(chptr
->mode_lock
);
2266 chptr
->mode_lock
= newmlock
? rb_strdup(newmlock
) : NULL
;
2270 sendto_server(client_p
, NULL
, CAP_TS6
| CAP_MLOCK
, NOCAPS
, ":%s MLOCK %ld %s :%s",
2271 source_p
->id
, (long) chptr
->channelts
, chptr
->chname
,
2272 chptr
->mode_lock
? chptr
->mode_lock
: "");