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 struct module_modes ModuleModes
;
76 /* OPTIMIZE ME! -- dwr */
78 construct_cflags_strings(void)
81 char *ptr
= cflagsbuf
;
82 char *ptr2
= cflagsmyinfo
;
87 for(i
= 0; i
< 256; i
++)
89 if( !(chmode_table
[i
].set_func
== chm_ban
) &&
90 !(chmode_table
[i
].set_func
== chm_forward
) &&
91 !(chmode_table
[i
].set_func
== chm_throttle
) &&
92 !(chmode_table
[i
].set_func
== chm_key
) &&
93 !(chmode_table
[i
].set_func
== chm_limit
) &&
94 !(chmode_table
[i
].set_func
== chm_admin
) &&
95 !(chmode_table
[i
].set_func
== chm_op
) &&
96 !(chmode_table
[i
].set_func
== chm_halfop
) &&
97 !(chmode_table
[i
].set_func
== chm_voice
))
99 chmode_flags
[i
] = chmode_table
[i
].mode_type
;
106 if(chmode_flags
[i
] == ModuleModes
.MODE_DISFORWARD
)
108 if (ModuleModes
.MODE_FORWARD
)
113 else if(chmode_flags
[i
] == ModuleModes
.MODE_REGONLY
)
115 if (rb_dlink_list_length(&service_list
))
120 else if(chmode_flags
[i
] != ModuleModes
.MODE_EXLIMIT
&& chmode_flags
[i
] != 0)
125 /* Should we leave orphaned check here? -- dwr */
126 if(!(chmode_table
[i
].set_func
== chm_nosuch
) && !(chmode_table
[i
].set_func
== chm_orphaned
))
140 * outputs - an available cflag bitmask or
141 * 0 if no cflags are available
142 * side effects - NONE
145 find_cflag_slot(void)
147 unsigned int all_cflags
= 0, my_cflag
= 0, i
;
149 for (i
= 0; i
< 256; i
++)
150 all_cflags
|= chmode_flags
[i
];
152 for (my_cflag
= 1; my_cflag
&& (all_cflags
& my_cflag
);
159 cflag_add(char c_
, ChannelModeFunc function
)
161 int c
= (unsigned char)c_
;
163 if (chmode_table
[c
].set_func
!= chm_nosuch
&&
164 chmode_table
[c
].set_func
!= chm_orphaned
)
167 if (chmode_table
[c
].set_func
== chm_nosuch
)
168 chmode_table
[c
].mode_type
= find_cflag_slot();
169 if (chmode_table
[c
].mode_type
== 0)
171 chmode_table
[c
].set_func
= function
;
172 construct_cflags_strings();
173 return chmode_table
[c
].mode_type
;
177 cflag_orphan(char c_
)
179 int c
= (unsigned char)c_
;
181 s_assert(chmode_flags
[c
] != 0);
182 chmode_table
[c
].set_func
= chm_orphaned
;
183 construct_cflags_strings();
187 get_channel_access(struct Client
*source_p
, struct membership
*msptr
)
189 if(!MyClient(source_p
) || is_admin(msptr
))
191 else if(is_chanop(msptr
))
193 else if(is_halfop(msptr
))
201 * inputs - client, channel, id to add, type
202 * outputs - 0 on failure, 1 on success
203 * side effects - given id is added to the appropriate list
206 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
,
207 rb_dlink_list
* list
, long mode_type
)
209 struct Ban
*actualBan
;
210 static char who
[USERHOST_REPLYLEN
];
211 char *realban
= LOCAL_COPY(banid
);
214 /* dont let local clients overflow the banlist, or set redundant
217 if(MyClient(source_p
))
219 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
& ModuleModes
.MODE_EXLIMIT
? ConfigChannel
.max_bans_large
: ConfigChannel
.max_bans
))
221 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
222 me
.name
, source_p
->name
, chptr
->chname
, realban
);
226 RB_DLINK_FOREACH(ptr
, list
->head
)
228 actualBan
= ptr
->data
;
229 if(mask_match(actualBan
->banstr
, realban
))
233 /* dont let remotes set duplicates */
236 RB_DLINK_FOREACH(ptr
, list
->head
)
238 actualBan
= ptr
->data
;
239 if(!irccmp(actualBan
->banstr
, realban
))
245 if(IsPerson(source_p
))
246 rb_sprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
248 rb_strlcpy(who
, source_p
->name
, sizeof(who
));
250 actualBan
= allocate_ban(realban
, who
);
251 actualBan
->when
= rb_current_time();
253 rb_dlinkAdd(actualBan
, &actualBan
->node
, list
);
255 /* invalidate the can_send() cache */
256 if(mode_type
== CHFL_BAN
|| mode_type
== ModuleModes
.CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
264 * inputs - channel, id to remove, type
265 * outputs - 0 on failure, 1 on success
266 * side effects - given id is removed from the appropriate list
269 del_id(struct Channel
*chptr
, const char *banid
, rb_dlink_list
* list
, long mode_type
)
274 if(EmptyString(banid
))
277 RB_DLINK_FOREACH(ptr
, list
->head
)
281 if(irccmp(banid
, banptr
->banstr
) == 0)
283 rb_dlinkDelete(&banptr
->node
, list
);
286 /* invalidate the can_send() cache */
287 if(mode_type
== CHFL_BAN
|| mode_type
== ModuleModes
.CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
299 * input - string to check
300 * output - pointer to 'fixed' string, or "*" if empty
301 * side effects - any white space found becomes \0
304 check_string(char *s
)
307 static char splat
[] = "*";
324 * inputs - mask to pretty
325 * outputs - better version of the mask
326 * side effects - mask is chopped to limits, and transformed:
334 pretty_mask(const char *idmask
)
336 static char mask_buf
[BUFSIZE
];
338 char *nick
, *user
, *host
;
341 char ne
= 0, ue
= 0, he
= 0; /* save values at nick[NICKLEN], et all */
344 mask
= LOCAL_COPY(idmask
);
345 mask
= check_string(mask
);
348 nick
= user
= host
= splat
;
350 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
353 old_mask_pos
= mask_pos
;
357 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
358 t
= mask_buf
+ old_mask_pos
+ 1;
364 return mask_buf
+ old_mask_pos
;
368 if((t
= strchr(mask
, '@')) != NULL
)
375 if((t
= strchr(mask
, '!')) != NULL
)
390 else if((t
= strchr(mask
, '!')) != NULL
)
399 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
|| strchr(mask
, '/') != NULL
)
410 /* truncate values to max lengths */
411 if(strlen(nick
) > NICKLEN
- 1)
413 ne
= nick
[NICKLEN
- 1];
414 nick
[NICKLEN
- 1] = '\0';
416 if(strlen(user
) > USERLEN
)
419 user
[USERLEN
] = '\0';
421 if(strlen(host
) > HOSTLEN
)
424 host
[HOSTLEN
] = '\0';
427 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
429 /* restore mask, since we may need to use it again later */
435 nick
[NICKLEN
- 1] = ne
;
441 return mask_buf
+ old_mask_pos
;
447 * output - the same key, fixed
448 * side effects - anything below ascii 13 is discarded, ':' discarded,
449 * high ascii is dropped to lower half of ascii table
456 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
459 if(c
!= ':' && c
!= ',' && c
> ' ')
470 * ouput - the same key, fixed
471 * side effects - high ascii dropped to lower half of table,
472 * CR/LF/':' are dropped
475 fix_key_remote(char *arg
)
479 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
482 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
492 * The handlers for each specific mode.
495 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
496 int alevel
, int parc
, int *parn
,
497 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
499 if(*errors
& SM_ERR_UNKNOWN
)
501 *errors
|= SM_ERR_UNKNOWN
;
502 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
506 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
507 int alevel
, int parc
, int *parn
,
508 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
513 struct DictionaryIter iter
;
515 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
517 if (IsOverride(source_p
))
521 if(!(*errors
& SM_ERR_NOOPS
))
522 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
523 me
.name
, source_p
->name
, chptr
->chname
);
524 *errors
|= SM_ERR_NOOPS
;
529 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
533 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
535 /* if +f is disabled, ignore an attempt to set +QF locally */
536 if(!ModuleModes
.MODE_FORWARD
&& MyClient(source_p
) &&
537 (c
== 'Q' || c
== 'F'))
540 chptr
->mode
.mode
|= mode_type
;
542 mode_changes
[mode_count
].letter
= c
;
543 mode_changes
[mode_count
].dir
= MODE_ADD
;
544 mode_changes
[mode_count
].caps
= 0;
545 mode_changes
[mode_count
].nocaps
= 0;
546 mode_changes
[mode_count
].id
= NULL
;
547 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
548 mode_changes
[mode_count
].override
= override
;
549 mode_changes
[mode_count
++].arg
= NULL
;
551 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
553 /* cleanup metadata when the related mode is removed */
556 DICTIONARY_FOREACH(md
, &iter
, chptr
->metadata
)
558 if(!strcmp(md
->value
, "KICKNOREJOIN"))
559 channel_metadata_delete(chptr
, md
->name
, 0);
563 channel_metadata_delete(chptr
, "NOREPEAT", 0);
565 chptr
->mode
.mode
&= ~mode_type
;
567 mode_changes
[mode_count
].letter
= c
;
568 mode_changes
[mode_count
].dir
= MODE_DEL
;
569 mode_changes
[mode_count
].caps
= 0;
570 mode_changes
[mode_count
].nocaps
= 0;
571 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
572 mode_changes
[mode_count
].id
= NULL
;
573 mode_changes
[mode_count
].override
= override
;
574 mode_changes
[mode_count
++].arg
= NULL
;
579 chm_orphaned(struct Client
*source_p
, struct Channel
*chptr
,
580 int alevel
, int parc
, int *parn
,
581 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
583 if(MyClient(source_p
))
586 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
588 chptr
->mode
.mode
|= mode_type
;
590 mode_changes
[mode_count
].letter
= c
;
591 mode_changes
[mode_count
].dir
= MODE_ADD
;
592 mode_changes
[mode_count
].caps
= 0;
593 mode_changes
[mode_count
].nocaps
= 0;
594 mode_changes
[mode_count
].id
= NULL
;
595 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
596 mode_changes
[mode_count
++].arg
= NULL
;
598 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
600 chptr
->mode
.mode
&= ~mode_type
;
602 mode_changes
[mode_count
].letter
= c
;
603 mode_changes
[mode_count
].dir
= MODE_DEL
;
604 mode_changes
[mode_count
].caps
= 0;
605 mode_changes
[mode_count
].nocaps
= 0;
606 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
607 mode_changes
[mode_count
].id
= NULL
;
608 mode_changes
[mode_count
++].arg
= NULL
;
613 chm_hidden(struct Client
*source_p
, struct Channel
*chptr
,
614 int alevel
, int parc
, int *parn
,
615 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
617 if(!IsOper(source_p
) && !IsServer(source_p
))
619 if(!(*errors
& SM_ERR_NOPRIVS
))
620 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
621 *errors
|= SM_ERR_NOPRIVS
;
624 if(MyClient(source_p
) && !IsOperAdmin(source_p
))
626 if(!(*errors
& SM_ERR_NOPRIVS
))
627 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
628 source_p
->name
, "cmodes");
629 *errors
|= SM_ERR_NOPRIVS
;
633 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
637 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
639 chptr
->mode
.mode
|= mode_type
;
641 mode_changes
[mode_count
].letter
= c
;
642 mode_changes
[mode_count
].dir
= MODE_ADD
;
643 mode_changes
[mode_count
].caps
= 0;
644 mode_changes
[mode_count
].nocaps
= 0;
645 mode_changes
[mode_count
].id
= NULL
;
646 mode_changes
[mode_count
].mems
= ONLY_OPERS
;
647 mode_changes
[mode_count
].override
= 0;
648 mode_changes
[mode_count
++].arg
= NULL
;
650 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
652 chptr
->mode
.mode
&= ~mode_type
;
654 mode_changes
[mode_count
].letter
= c
;
655 mode_changes
[mode_count
].dir
= MODE_DEL
;
656 mode_changes
[mode_count
].caps
= 0;
657 mode_changes
[mode_count
].nocaps
= 0;
658 mode_changes
[mode_count
].mems
= ONLY_OPERS
;
659 mode_changes
[mode_count
].id
= NULL
;
660 mode_changes
[mode_count
].override
= 0;
661 mode_changes
[mode_count
++].arg
= NULL
;
666 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
667 int alevel
, int parc
, int *parn
,
668 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
672 if(!IsOper(source_p
) && !IsServer(source_p
))
674 if(!(*errors
& SM_ERR_NOPRIVS
))
675 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
676 *errors
|= SM_ERR_NOPRIVS
;
679 if(MyClient(source_p
) && !IsOperResv(source_p
))
681 if(!(*errors
& SM_ERR_NOPRIVS
))
682 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
683 source_p
->name
, "resv");
684 *errors
|= SM_ERR_NOPRIVS
;
688 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
690 if (IsOverride(source_p
))
694 if(!(*errors
& SM_ERR_NOOPS
))
695 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
696 me
.name
, source_p
->name
, chptr
->chname
);
697 *errors
|= SM_ERR_NOOPS
;
702 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
706 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
708 chptr
->mode
.mode
|= mode_type
;
710 mode_changes
[mode_count
].letter
= c
;
711 mode_changes
[mode_count
].dir
= MODE_ADD
;
712 mode_changes
[mode_count
].caps
= 0;
713 mode_changes
[mode_count
].nocaps
= 0;
714 mode_changes
[mode_count
].id
= NULL
;
715 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
716 mode_changes
[mode_count
].override
= override
;
717 mode_changes
[mode_count
++].arg
= NULL
;
719 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
721 chptr
->mode
.mode
&= ~mode_type
;
723 mode_changes
[mode_count
].letter
= c
;
724 mode_changes
[mode_count
].dir
= MODE_DEL
;
725 mode_changes
[mode_count
].caps
= 0;
726 mode_changes
[mode_count
].nocaps
= 0;
727 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
728 mode_changes
[mode_count
].override
= override
;
729 mode_changes
[mode_count
].id
= NULL
;
730 mode_changes
[mode_count
++].arg
= NULL
;
735 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
736 int alevel
, int parc
, int *parn
,
737 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
740 const char *raw_mask
;
751 if(mode_type
== CHFL_BAN
)
753 list
= &chptr
->banlist
;
754 errorval
= SM_ERR_RPL_B
;
755 rpl_list
= RPL_BANLIST
;
756 rpl_endlist
= RPL_ENDOFBANLIST
;
760 else if(mode_type
== CHFL_EXCEPTION
)
762 /* if +e is disabled, allow all but +e locally */
763 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
764 ((dir
== MODE_ADD
) && (parc
> *parn
)))
767 list
= &chptr
->exceptlist
;
768 errorval
= SM_ERR_RPL_E
;
769 rpl_list
= RPL_EXCEPTLIST
;
770 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
773 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
778 else if(mode_type
== CHFL_INVEX
)
780 /* if +I is disabled, allow all but +I locally */
781 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
782 (dir
== MODE_ADD
) && (parc
> *parn
))
785 list
= &chptr
->invexlist
;
786 errorval
= SM_ERR_RPL_I
;
787 rpl_list
= RPL_INVITELIST
;
788 rpl_endlist
= RPL_ENDOFINVITELIST
;
791 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
796 else if(mode_type
== ModuleModes
.CHFL_QUIET
)
798 list
= &chptr
->quietlist
;
799 errorval
= SM_ERR_RPL_Q
;
800 rpl_list
= RPL_QUIETLIST
;
801 rpl_endlist
= RPL_ENDOFQUIETLIST
;
807 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
811 if(dir
== 0 || parc
<= *parn
)
813 if((*errors
& errorval
) != 0)
817 /* non-ops cant see +eI lists.. */
818 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
&& mode_type
!= CHFL_BAN
&&
819 mode_type
!= ModuleModes
.CHFL_QUIET
)
821 if(IsOverride(source_p
))
823 sendto_wallops_flags(UMODE_WALLOP
, &me
,
824 "%s is overriding modes on %s: (%s list)",
825 get_oper_name(source_p
), chptr
->chname
, mode_type
== CHFL_INVEX
? "invex" : "exempt");
826 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
827 ":%s WALLOPS :%s is overriding modes on %s: (%s list)",
828 me
.name
, get_oper_name(source_p
), chptr
->chname
, mode_type
== CHFL_INVEX
? "invex" : "exempt");
833 if(!(*errors
& SM_ERR_NOOPS
))
834 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
835 me
.name
, source_p
->name
, chptr
->chname
);
836 *errors
|= SM_ERR_NOOPS
;
841 RB_DLINK_FOREACH(ptr
, list
->head
)
844 sendto_one(source_p
, form_str(rpl_list
),
845 me
.name
, source_p
->name
, chptr
->chname
,
846 banptr
->banstr
, banptr
->who
, banptr
->when
);
848 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
852 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
854 if(IsOverride(source_p
))
859 if(!(*errors
& SM_ERR_NOOPS
))
860 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
861 me
.name
, source_p
->name
, chptr
->chname
);
862 *errors
|= SM_ERR_NOOPS
;
867 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
870 raw_mask
= parv
[(*parn
)];
873 /* empty ban, or starts with ':' which messes up s2s, ignore it */
874 if(EmptyString(raw_mask
) || *raw_mask
== ':')
877 if(!MyClient(source_p
))
879 if(strchr(raw_mask
, ' '))
885 mask
= pretty_mask(raw_mask
);
887 /* we'd have problems parsing this, hyb6 does it too
888 * also make sure it will always fit on a line with channel
891 if(strlen(mask
) > IRCD_MIN(BANLEN
, MODEBUFLEN
- 5))
894 /* if we're adding a NEW id */
897 if (*mask
== '$' && MyClient(source_p
))
899 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
900 /* XXX perhaps return an error message here */
904 /* dont allow local clients to overflow the banlist, dont
905 * let remote servers set duplicate bans
907 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
910 mode_changes
[mode_count
].letter
= c
;
911 mode_changes
[mode_count
].dir
= MODE_ADD
;
912 mode_changes
[mode_count
].caps
= caps
;
913 mode_changes
[mode_count
].nocaps
= 0;
914 mode_changes
[mode_count
].mems
= mems
;
915 mode_changes
[mode_count
].id
= NULL
;
916 mode_changes
[mode_count
].override
= override
;
917 mode_changes
[mode_count
++].arg
= mask
;
919 else if(dir
== MODE_DEL
)
921 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
923 /* mask isn't a valid ban, check raw_mask */
924 if(del_id(chptr
, raw_mask
, list
, mode_type
))
928 mode_changes
[mode_count
].letter
= c
;
929 mode_changes
[mode_count
].dir
= MODE_DEL
;
930 mode_changes
[mode_count
].caps
= caps
;
931 mode_changes
[mode_count
].nocaps
= 0;
932 mode_changes
[mode_count
].mems
= mems
;
933 mode_changes
[mode_count
].id
= NULL
;
934 mode_changes
[mode_count
].override
= override
;
935 mode_changes
[mode_count
++].arg
= mask
;
940 chm_admin(struct Client
*source_p
, struct Channel
*chptr
,
941 int alevel
, int parc
, int *parn
,
942 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
944 struct membership
*mstptr
;
945 const char *adminnick
;
946 struct Client
*targ_p
;
949 if(!ConfigChannel
.use_admin
)
951 if(*errors
& SM_ERR_UNKNOWN
)
953 *errors
|= SM_ERR_UNKNOWN
;
954 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
958 if(alevel
!= CHFL_ADMIN
)
960 if(IsOverride(source_p
))
965 if(!(*errors
& SM_ERR_NOOPS
))
966 sendto_one(source_p
, ":%s 482 %s %s :You're not a channel administrator", me
.name
, source_p
->name
, chptr
->chname
);
967 *errors
|= SM_ERR_NOOPS
;
972 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
975 adminnick
= parv
[(*parn
)];
979 if(EmptyString(adminnick
))
981 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
985 if((targ_p
= find_chasing(source_p
, adminnick
, NULL
)) == NULL
)
990 mstptr
= find_channel_membership(chptr
, targ_p
);
994 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
995 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
996 form_str(ERR_USERNOTINCHANNEL
), adminnick
, chptr
->chname
);
997 *errors
|= SM_ERR_NOTONCHANNEL
;
1001 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1006 if(targ_p
== source_p
)
1008 no_override_deop
= 1;
1009 /* Don't reject modes from remote. It desyncs, and this is perfectly
1010 * legitimate from a remote override oper.
1016 mode_changes
[mode_count
].letter
= c
;
1017 mode_changes
[mode_count
].dir
= MODE_ADD
;
1018 mode_changes
[mode_count
].caps
= 0;
1019 mode_changes
[mode_count
].nocaps
= 0;
1020 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1021 mode_changes
[mode_count
].id
= targ_p
->id
;
1022 mode_changes
[mode_count
].arg
= targ_p
->name
;
1023 mode_changes
[mode_count
].override
= override
;
1024 mode_changes
[mode_count
++].client
= targ_p
;
1026 mstptr
->flags
|= CHFL_ADMIN
;
1030 if(MyClient(source_p
) && IsService(targ_p
))
1032 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1033 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1037 mode_changes
[mode_count
].letter
= c
;
1038 mode_changes
[mode_count
].dir
= MODE_DEL
;
1039 mode_changes
[mode_count
].caps
= 0;
1040 mode_changes
[mode_count
].nocaps
= 0;
1041 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1042 mode_changes
[mode_count
].id
= targ_p
->id
;
1043 mode_changes
[mode_count
].arg
= targ_p
->name
;
1044 mode_changes
[mode_count
].override
= override
;
1045 mode_changes
[mode_count
++].client
= targ_p
;
1047 mstptr
->flags
&= ~CHFL_ADMIN
;
1052 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
1053 int alevel
, int parc
, int *parn
,
1054 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1056 struct membership
*mstptr
;
1058 struct Client
*targ_p
;
1061 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
)
1063 if(IsOverride(source_p
))
1068 if(!(*errors
& SM_ERR_NOOPS
))
1069 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1070 me
.name
, source_p
->name
, chptr
->chname
);
1071 *errors
|= SM_ERR_NOOPS
;
1076 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
1079 opnick
= parv
[(*parn
)];
1083 if(EmptyString(opnick
))
1085 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1089 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
1094 mstptr
= find_channel_membership(chptr
, targ_p
);
1098 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1099 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1100 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
1101 *errors
|= SM_ERR_NOTONCHANNEL
;
1105 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1110 if(targ_p
== source_p
)
1112 no_override_deop
= 1;
1113 /* Don't reject modes from remote. It desyncs, and this is perfectly
1114 * legitimate from a remote override oper.
1120 mode_changes
[mode_count
].letter
= c
;
1121 mode_changes
[mode_count
].dir
= MODE_ADD
;
1122 mode_changes
[mode_count
].caps
= 0;
1123 mode_changes
[mode_count
].nocaps
= 0;
1124 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1125 mode_changes
[mode_count
].id
= targ_p
->id
;
1126 mode_changes
[mode_count
].arg
= targ_p
->name
;
1127 mode_changes
[mode_count
].override
= override
;
1128 mode_changes
[mode_count
++].client
= targ_p
;
1130 mstptr
->flags
|= CHFL_CHANOP
;
1134 if(MyClient(source_p
) && IsService(targ_p
))
1136 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1137 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1141 mode_changes
[mode_count
].letter
= c
;
1142 mode_changes
[mode_count
].dir
= MODE_DEL
;
1143 mode_changes
[mode_count
].caps
= 0;
1144 mode_changes
[mode_count
].nocaps
= 0;
1145 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1146 mode_changes
[mode_count
].id
= targ_p
->id
;
1147 mode_changes
[mode_count
].arg
= targ_p
->name
;
1148 mode_changes
[mode_count
].override
= override
;
1149 mode_changes
[mode_count
++].client
= targ_p
;
1151 mstptr
->flags
&= ~CHFL_CHANOP
;
1156 chm_halfop(struct Client
*source_p
, struct Channel
*chptr
,
1157 int alevel
, int parc
, int *parn
,
1158 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1160 struct membership
*mstptr
;
1161 const char *halfopnick
;
1162 struct Client
*targ_p
;
1165 if(!ConfigChannel
.use_halfop
)
1167 if(*errors
& SM_ERR_UNKNOWN
)
1169 *errors
|= SM_ERR_UNKNOWN
;
1170 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
1174 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
)
1176 if(IsOverride(source_p
))
1181 if(!(*errors
& SM_ERR_NOOPS
))
1182 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1183 me
.name
, source_p
->name
, chptr
->chname
);
1184 *errors
|= SM_ERR_NOOPS
;
1189 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
1192 halfopnick
= parv
[(*parn
)];
1196 if(EmptyString(halfopnick
))
1198 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1202 if((targ_p
= find_chasing(source_p
, halfopnick
, NULL
)) == NULL
)
1207 mstptr
= find_channel_membership(chptr
, targ_p
);
1211 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1212 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1213 form_str(ERR_USERNOTINCHANNEL
), halfopnick
, chptr
->chname
);
1214 *errors
|= SM_ERR_NOTONCHANNEL
;
1218 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1223 if(targ_p
== source_p
)
1225 no_override_deop
= 1;
1226 /* Don't reject modes from remote. It desyncs, and this is perfectly
1227 * legitimate from a remote override oper.
1233 mode_changes
[mode_count
].letter
= c
;
1234 mode_changes
[mode_count
].dir
= MODE_ADD
;
1235 mode_changes
[mode_count
].caps
= 0;
1236 mode_changes
[mode_count
].nocaps
= 0;
1237 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1238 mode_changes
[mode_count
].id
= targ_p
->id
;
1239 mode_changes
[mode_count
].arg
= targ_p
->name
;
1240 mode_changes
[mode_count
].override
= override
;
1241 mode_changes
[mode_count
++].client
= targ_p
;
1243 mstptr
->flags
|= CHFL_HALFOP
;
1247 if(MyClient(source_p
) && IsService(targ_p
))
1249 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1250 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1254 mode_changes
[mode_count
].letter
= c
;
1255 mode_changes
[mode_count
].dir
= MODE_DEL
;
1256 mode_changes
[mode_count
].caps
= 0;
1257 mode_changes
[mode_count
].nocaps
= 0;
1258 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1259 mode_changes
[mode_count
].id
= targ_p
->id
;
1260 mode_changes
[mode_count
].arg
= targ_p
->name
;
1261 mode_changes
[mode_count
].override
= override
;
1262 mode_changes
[mode_count
++].client
= targ_p
;
1264 mstptr
->flags
&= ~CHFL_HALFOP
;
1269 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
1270 int alevel
, int parc
, int *parn
,
1271 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1273 struct membership
*mstptr
;
1275 struct Client
*targ_p
;
1278 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1280 if(IsOverride(source_p
))
1285 if(!(*errors
& SM_ERR_NOOPS
))
1286 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1287 me
.name
, source_p
->name
, chptr
->chname
);
1288 *errors
|= SM_ERR_NOOPS
;
1293 if((dir
== MODE_QUERY
) || parc
<= *parn
)
1296 opnick
= parv
[(*parn
)];
1300 if(EmptyString(opnick
))
1302 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1306 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
1311 mstptr
= find_channel_membership(chptr
, targ_p
);
1315 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1316 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1317 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
1318 *errors
|= SM_ERR_NOTONCHANNEL
;
1322 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1327 mode_changes
[mode_count
].letter
= c
;
1328 mode_changes
[mode_count
].dir
= MODE_ADD
;
1329 mode_changes
[mode_count
].caps
= 0;
1330 mode_changes
[mode_count
].nocaps
= 0;
1331 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1332 mode_changes
[mode_count
].id
= targ_p
->id
;
1333 mode_changes
[mode_count
].arg
= targ_p
->name
;
1334 mode_changes
[mode_count
].override
= override
;
1335 mode_changes
[mode_count
++].client
= targ_p
;
1337 mstptr
->flags
|= CHFL_VOICE
;
1341 mode_changes
[mode_count
].letter
= 'v';
1342 mode_changes
[mode_count
].dir
= MODE_DEL
;
1343 mode_changes
[mode_count
].caps
= 0;
1344 mode_changes
[mode_count
].nocaps
= 0;
1345 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1346 mode_changes
[mode_count
].id
= targ_p
->id
;
1347 mode_changes
[mode_count
].arg
= targ_p
->name
;
1348 mode_changes
[mode_count
].override
= override
;
1349 mode_changes
[mode_count
++].client
= targ_p
;
1351 mstptr
->flags
&= ~CHFL_VOICE
;
1356 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
1357 int alevel
, int parc
, int *parn
,
1358 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1361 static char limitstr
[30];
1365 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1367 if(IsOverride(source_p
))
1371 if(!(*errors
& SM_ERR_NOOPS
))
1372 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1373 me
.name
, source_p
->name
, chptr
->chname
);
1374 *errors
|= SM_ERR_NOOPS
;
1379 if(dir
== MODE_QUERY
)
1382 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1385 if((dir
== MODE_ADD
) && parc
> *parn
)
1387 lstr
= parv
[(*parn
)];
1390 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
1393 rb_sprintf(limitstr
, "%d", limit
);
1395 mode_changes
[mode_count
].letter
= c
;
1396 mode_changes
[mode_count
].dir
= MODE_ADD
;
1397 mode_changes
[mode_count
].caps
= 0;
1398 mode_changes
[mode_count
].nocaps
= 0;
1399 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1400 mode_changes
[mode_count
].id
= NULL
;
1401 mode_changes
[mode_count
].override
= override
;
1402 mode_changes
[mode_count
++].arg
= limitstr
;
1404 chptr
->mode
.limit
= limit
;
1406 else if(dir
== MODE_DEL
)
1408 if(!chptr
->mode
.limit
)
1411 chptr
->mode
.limit
= 0;
1413 mode_changes
[mode_count
].letter
= c
;
1414 mode_changes
[mode_count
].dir
= MODE_DEL
;
1415 mode_changes
[mode_count
].caps
= 0;
1416 mode_changes
[mode_count
].nocaps
= 0;
1417 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1418 mode_changes
[mode_count
].id
= NULL
;
1419 mode_changes
[mode_count
].override
= override
;
1420 mode_changes
[mode_count
++].arg
= NULL
;
1425 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
1426 int alevel
, int parc
, int *parn
,
1427 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1429 int joins
= 0, timeslice
= 0;
1432 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1434 if(IsOverride(source_p
))
1439 if(!(*errors
& SM_ERR_NOOPS
))
1440 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1441 me
.name
, source_p
->name
, chptr
->chname
);
1442 *errors
|= SM_ERR_NOOPS
;
1447 if(dir
== MODE_QUERY
)
1450 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1453 if((dir
== MODE_ADD
) && parc
> *parn
)
1455 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
1457 if(!joins
|| !timeslice
)
1460 mode_changes
[mode_count
].letter
= c
;
1461 mode_changes
[mode_count
].dir
= MODE_ADD
;
1462 mode_changes
[mode_count
].caps
= 0;
1463 mode_changes
[mode_count
].nocaps
= 0;
1464 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1465 mode_changes
[mode_count
].id
= NULL
;
1466 mode_changes
[mode_count
].override
= override
;
1467 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
1471 chptr
->mode
.join_num
= joins
;
1472 chptr
->mode
.join_time
= timeslice
;
1474 else if(dir
== MODE_DEL
)
1476 if(!chptr
->mode
.join_num
)
1479 chptr
->mode
.join_num
= 0;
1480 chptr
->mode
.join_time
= 0;
1481 chptr
->join_count
= 0;
1482 chptr
->join_delta
= 0;
1484 mode_changes
[mode_count
].letter
= c
;
1485 mode_changes
[mode_count
].dir
= MODE_DEL
;
1486 mode_changes
[mode_count
].caps
= 0;
1487 mode_changes
[mode_count
].nocaps
= 0;
1488 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1489 mode_changes
[mode_count
].id
= NULL
;
1490 mode_changes
[mode_count
].override
= override
;
1491 mode_changes
[mode_count
++].arg
= NULL
;
1496 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
1497 int alevel
, int parc
, int *parn
,
1498 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1500 struct Channel
*targptr
= NULL
;
1501 struct membership
*msptr
;
1502 const char *forward
;
1505 /* if +f is disabled, ignore local attempts to set it */
1506 if(!ModuleModes
.MODE_FORWARD
&& MyClient(source_p
) &&
1507 (dir
== MODE_ADD
) && (parc
> *parn
))
1510 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
1512 if (!(*errors
& SM_ERR_RPL_F
))
1514 if (*chptr
->mode
.forward
== '\0')
1515 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
1517 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
1518 *errors
|= SM_ERR_RPL_F
;
1523 #ifndef FORWARD_OPERONLY
1524 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1526 if(IsOverride(source_p
))
1530 if(!(*errors
& SM_ERR_NOOPS
))
1531 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1532 me
.name
, source_p
->name
, chptr
->chname
);
1533 *errors
|= SM_ERR_NOOPS
;
1538 if(!IsOper(source_p
) && !IsServer(source_p
))
1540 if(!(*errors
& SM_ERR_NOPRIVS
))
1541 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
1542 *errors
|= SM_ERR_NOPRIVS
;
1547 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1550 if(dir
== MODE_ADD
&& parc
> *parn
)
1552 forward
= parv
[(*parn
)];
1555 if(EmptyString(forward
))
1557 if(!check_channel_name(forward
) ||
1558 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1560 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1563 /* don't forward to inconsistent target -- jilles */
1564 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
1566 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
1567 form_str(ERR_BADCHANNAME
), forward
);
1570 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1572 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1573 form_str(ERR_NOSUCHCHANNEL
), forward
);
1576 if(MyClient(source_p
) && !(targptr
->mode
.mode
& ModuleModes
.MODE_FREETARGET
))
1578 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1581 if(IsOverride(source_p
))
1585 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1586 me
.name
, source_p
->name
, targptr
->chname
);
1592 rb_strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1594 mode_changes
[mode_count
].letter
= c
;
1595 mode_changes
[mode_count
].dir
= MODE_ADD
;
1596 mode_changes
[mode_count
].caps
= 0;
1597 mode_changes
[mode_count
].nocaps
= 0;
1598 mode_changes
[mode_count
].mems
= ModuleModes
.MODE_FORWARD
? ALL_MEMBERS
: ONLY_SERVERS
;
1599 mode_changes
[mode_count
].id
= NULL
;
1600 mode_changes
[mode_count
].override
= override
;
1601 mode_changes
[mode_count
++].arg
= forward
;
1603 else if(dir
== MODE_DEL
)
1605 if(!(*chptr
->mode
.forward
))
1608 *chptr
->mode
.forward
= '\0';
1610 mode_changes
[mode_count
].letter
= c
;
1611 mode_changes
[mode_count
].dir
= MODE_DEL
;
1612 mode_changes
[mode_count
].caps
= 0;
1613 mode_changes
[mode_count
].nocaps
= 0;
1614 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1615 mode_changes
[mode_count
].id
= NULL
;
1616 mode_changes
[mode_count
].override
= override
;
1617 mode_changes
[mode_count
++].arg
= NULL
;
1622 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1623 int alevel
, int parc
, int *parn
,
1624 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1629 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1631 if(IsOverride(source_p
))
1635 if(!(*errors
& SM_ERR_NOOPS
))
1636 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1637 me
.name
, source_p
->name
, chptr
->chname
);
1638 *errors
|= SM_ERR_NOOPS
;
1643 if(dir
== MODE_QUERY
)
1646 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1649 if((dir
== MODE_ADD
) && parc
> *parn
)
1651 key
= LOCAL_COPY(parv
[(*parn
)]);
1654 if(MyClient(source_p
))
1657 fix_key_remote(key
);
1659 if(EmptyString(key
))
1662 s_assert(key
[0] != ' ');
1663 rb_strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1665 mode_changes
[mode_count
].letter
= c
;
1666 mode_changes
[mode_count
].dir
= MODE_ADD
;
1667 mode_changes
[mode_count
].caps
= 0;
1668 mode_changes
[mode_count
].nocaps
= 0;
1669 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1670 mode_changes
[mode_count
].id
= NULL
;
1671 mode_changes
[mode_count
].override
= override
;
1672 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1674 else if(dir
== MODE_DEL
)
1676 static char splat
[] = "*";
1682 if(!(*chptr
->mode
.key
))
1685 /* hack time. when we get a +k-k mode, the +k arg is
1686 * chptr->mode.key, which the -k sets to \0, so hunt for a
1687 * +k when we get a -k, and set the arg to splat. --anfl
1689 for(i
= 0; i
< mode_count
; i
++)
1691 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1692 mode_changes
[i
].arg
= splat
;
1695 *chptr
->mode
.key
= 0;
1697 mode_changes
[mode_count
].letter
= c
;
1698 mode_changes
[mode_count
].dir
= MODE_DEL
;
1699 mode_changes
[mode_count
].caps
= 0;
1700 mode_changes
[mode_count
].nocaps
= 0;
1701 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1702 mode_changes
[mode_count
].id
= NULL
;
1703 mode_changes
[mode_count
].override
= override
;
1704 mode_changes
[mode_count
++].arg
= "*";
1709 chm_regonly(struct Client
*source_p
, struct Channel
*chptr
,
1710 int alevel
, int parc
, int *parn
,
1711 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1715 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1717 if(IsOverride(source_p
))
1721 if(!(*errors
& SM_ERR_NOOPS
))
1722 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1723 me
.name
, source_p
->name
, chptr
->chname
);
1724 *errors
|= SM_ERR_NOOPS
;
1729 if(dir
== MODE_QUERY
)
1732 if(((dir
== MODE_ADD
) && (chptr
->mode
.mode
& mode_type
)) ||
1733 ((dir
== MODE_DEL
) && !(chptr
->mode
.mode
& mode_type
)))
1736 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1740 chptr
->mode
.mode
|= mode_type
;
1742 chptr
->mode
.mode
&= ~mode_type
;
1744 mode_changes
[mode_count
].letter
= c
;
1745 mode_changes
[mode_count
].dir
= dir
;
1746 mode_changes
[mode_count
].caps
= CAP_SERVICE
;
1747 mode_changes
[mode_count
].nocaps
= 0;
1748 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1749 mode_changes
[mode_count
].id
= NULL
;
1750 mode_changes
[mode_count
].override
= override
;
1751 mode_changes
[mode_count
++].arg
= NULL
;
1755 /* Only RFC and ircd-ratbox modes are held in this table
1756 * All other modes are added via loading modules in shadowircd/modes
1757 * Such is documented in the comments for each mode, ex: C - NOCTCP. */
1758 struct ChannelMode chmode_table
[256] =
1760 {chm_nosuch
, 0 }, /* 0x00 */
1761 {chm_nosuch
, 0 }, /* 0x01 */
1762 {chm_nosuch
, 0 }, /* 0x02 */
1763 {chm_nosuch
, 0 }, /* 0x03 */
1764 {chm_nosuch
, 0 }, /* 0x04 */
1765 {chm_nosuch
, 0 }, /* 0x05 */
1766 {chm_nosuch
, 0 }, /* 0x06 */
1767 {chm_nosuch
, 0 }, /* 0x07 */
1768 {chm_nosuch
, 0 }, /* 0x08 */
1769 {chm_nosuch
, 0 }, /* 0x09 */
1770 {chm_nosuch
, 0 }, /* 0x0a */
1771 {chm_nosuch
, 0 }, /* 0x0b */
1772 {chm_nosuch
, 0 }, /* 0x0c */
1773 {chm_nosuch
, 0 }, /* 0x0d */
1774 {chm_nosuch
, 0 }, /* 0x0e */
1775 {chm_nosuch
, 0 }, /* 0x0f */
1776 {chm_nosuch
, 0 }, /* 0x10 */
1777 {chm_nosuch
, 0 }, /* 0x11 */
1778 {chm_nosuch
, 0 }, /* 0x12 */
1779 {chm_nosuch
, 0 }, /* 0x13 */
1780 {chm_nosuch
, 0 }, /* 0x14 */
1781 {chm_nosuch
, 0 }, /* 0x15 */
1782 {chm_nosuch
, 0 }, /* 0x16 */
1783 {chm_nosuch
, 0 }, /* 0x17 */
1784 {chm_nosuch
, 0 }, /* 0x18 */
1785 {chm_nosuch
, 0 }, /* 0x19 */
1786 {chm_nosuch
, 0 }, /* 0x1a */
1787 {chm_nosuch
, 0 }, /* 0x1b */
1788 {chm_nosuch
, 0 }, /* 0x1c */
1789 {chm_nosuch
, 0 }, /* 0x1d */
1790 {chm_nosuch
, 0 }, /* 0x1e */
1791 {chm_nosuch
, 0 }, /* 0x1f */
1792 {chm_nosuch
, 0 }, /* 0x20 */
1793 {chm_nosuch
, 0 }, /* 0x21 */
1794 {chm_nosuch
, 0 }, /* 0x22 */
1795 {chm_nosuch
, 0 }, /* 0x23 */
1796 {chm_nosuch
, 0 }, /* 0x24 */
1797 {chm_nosuch
, 0 }, /* 0x25 */
1798 {chm_nosuch
, 0 }, /* 0x26 */
1799 {chm_nosuch
, 0 }, /* 0x27 */
1800 {chm_nosuch
, 0 }, /* 0x28 */
1801 {chm_nosuch
, 0 }, /* 0x29 */
1802 {chm_nosuch
, 0 }, /* 0x2a */
1803 {chm_nosuch
, 0 }, /* 0x2b */
1804 {chm_nosuch
, 0 }, /* 0x2c */
1805 {chm_nosuch
, 0 }, /* 0x2d */
1806 {chm_nosuch
, 0 }, /* 0x2e */
1807 {chm_nosuch
, 0 }, /* 0x2f */
1808 {chm_nosuch
, 0 }, /* 0x30 */
1809 {chm_nosuch
, 0 }, /* 0x31 */
1810 {chm_nosuch
, 0 }, /* 0x32 */
1811 {chm_nosuch
, 0 }, /* 0x33 */
1812 {chm_nosuch
, 0 }, /* 0x34 */
1813 {chm_nosuch
, 0 }, /* 0x35 */
1814 {chm_nosuch
, 0 }, /* 0x36 */
1815 {chm_nosuch
, 0 }, /* 0x37 */
1816 {chm_nosuch
, 0 }, /* 0x38 */
1817 {chm_nosuch
, 0 }, /* 0x39 */
1818 {chm_nosuch
, 0 }, /* 0x3a */
1819 {chm_nosuch
, 0 }, /* 0x3b */
1820 {chm_nosuch
, 0 }, /* 0x3c */
1821 {chm_nosuch
, 0 }, /* 0x3d */
1822 {chm_nosuch
, 0 }, /* 0x3e */
1823 {chm_nosuch
, 0 }, /* 0x3f */
1825 {chm_nosuch
, 0 }, /* @ */
1826 {chm_nosuch
, 0 }, /* A */
1827 {chm_nosuch
, 0 }, /* B */
1828 {chm_nosuch
, 0 }, /* C - MODE_NOCTCP */
1829 {chm_nosuch
, 0 }, /* D - MODE_NOACTION */
1830 {chm_nosuch
, 0 }, /* E - MODE_NOKICK */
1831 {chm_nosuch
, 0 }, /* F - MODE_FREETARGET */
1832 {chm_nosuch
, 0 }, /* G - MODE_NOCAPS */
1833 {chm_nosuch
, 0 }, /* H */
1834 {chm_ban
, CHFL_INVEX
}, /* I */
1835 {chm_nosuch
, 0 }, /* J - MODE_NOREJOIN */
1836 {chm_nosuch
, 0 }, /* K - MODE_NOREPEAT */
1837 {chm_nosuch
, 0 }, /* L - MODE_EXLIMIT */
1838 {chm_nosuch
, 0 }, /* M - MODE_NOOPERKICK */
1839 {chm_nosuch
, 0 }, /* N - MODE_NONICK */
1840 {chm_nosuch
, 0 }, /* O */
1841 {chm_nosuch
, 0 }, /* P - MODE_PERMANENT */
1842 {chm_nosuch
, 0 }, /* Q - MODE_DISFORWARD */
1843 {chm_nosuch
, 0 }, /* R */
1844 {chm_nosuch
, 0 }, /* S */
1845 {chm_nosuch
, 0 }, /* T - MODE_NONOTICE */
1846 {chm_nosuch
, 0 }, /* U */
1847 {chm_nosuch
, 0 }, /* V */
1848 {chm_nosuch
, 0 }, /* W */
1849 {chm_nosuch
, 0 }, /* X */
1850 {chm_nosuch
, 0 }, /* Y */
1851 {chm_nosuch
, 0 }, /* Z */
1858 {chm_admin
, 0 }, /* a */
1859 {chm_ban
, CHFL_BAN
}, /* b */
1860 {chm_nosuch
, 0 }, /* c - MODE_NOCOLOR */
1861 {chm_nosuch
, 0 }, /* d */
1862 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1863 {chm_nosuch
, 0 }, /* f - MODE_FORWARD */
1864 {chm_nosuch
, 0 }, /* g - MODE_FREEINVITE */
1865 {chm_halfop
, 0 }, /* h */
1866 {chm_simple
, MODE_INVITEONLY
}, /* i */
1867 {chm_nosuch
, 0 }, /* j - MODE_THROTTLE */
1868 {chm_key
, 0 }, /* k */
1869 {chm_limit
, 0 }, /* l */
1870 {chm_simple
, MODE_MODERATED
}, /* m */
1871 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1872 {chm_op
, 0 }, /* o */
1873 {chm_simple
, MODE_PRIVATE
}, /* p */
1874 {chm_nosuch
, 0 }, /* q - CHFL_QUIET */
1875 {chm_nosuch
, 0 }, /* r - MODE_REGONLY */
1876 {chm_simple
, MODE_SECRET
}, /* s */
1877 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1878 {chm_nosuch
, 0 }, /* u */
1879 {chm_voice
, 0 }, /* v */
1880 {chm_nosuch
, 0 }, /* w */
1881 {chm_nosuch
, 0 }, /* x */
1882 {chm_nosuch
, 0 }, /* y */
1883 {chm_nosuch
, 0 }, /* z - MODE_OPMODERATE */
1885 {chm_nosuch
, 0 }, /* 0x7b */
1886 {chm_nosuch
, 0 }, /* 0x7c */
1887 {chm_nosuch
, 0 }, /* 0x7d */
1888 {chm_nosuch
, 0 }, /* 0x7e */
1889 {chm_nosuch
, 0 }, /* 0x7f */
1891 {chm_nosuch
, 0 }, /* 0x80 */
1892 {chm_nosuch
, 0 }, /* 0x81 */
1893 {chm_nosuch
, 0 }, /* 0x82 */
1894 {chm_nosuch
, 0 }, /* 0x83 */
1895 {chm_nosuch
, 0 }, /* 0x84 */
1896 {chm_nosuch
, 0 }, /* 0x85 */
1897 {chm_nosuch
, 0 }, /* 0x86 */
1898 {chm_nosuch
, 0 }, /* 0x87 */
1899 {chm_nosuch
, 0 }, /* 0x88 */
1900 {chm_nosuch
, 0 }, /* 0x89 */
1901 {chm_nosuch
, 0 }, /* 0x8a */
1902 {chm_nosuch
, 0 }, /* 0x8b */
1903 {chm_nosuch
, 0 }, /* 0x8c */
1904 {chm_nosuch
, 0 }, /* 0x8d */
1905 {chm_nosuch
, 0 }, /* 0x8e */
1906 {chm_nosuch
, 0 }, /* 0x8f */
1908 {chm_nosuch
, 0 }, /* 0x90 */
1909 {chm_nosuch
, 0 }, /* 0x91 */
1910 {chm_nosuch
, 0 }, /* 0x92 */
1911 {chm_nosuch
, 0 }, /* 0x93 */
1912 {chm_nosuch
, 0 }, /* 0x94 */
1913 {chm_nosuch
, 0 }, /* 0x95 */
1914 {chm_nosuch
, 0 }, /* 0x96 */
1915 {chm_nosuch
, 0 }, /* 0x97 */
1916 {chm_nosuch
, 0 }, /* 0x98 */
1917 {chm_nosuch
, 0 }, /* 0x99 */
1918 {chm_nosuch
, 0 }, /* 0x9a */
1919 {chm_nosuch
, 0 }, /* 0x9b */
1920 {chm_nosuch
, 0 }, /* 0x9c */
1921 {chm_nosuch
, 0 }, /* 0x9d */
1922 {chm_nosuch
, 0 }, /* 0x9e */
1923 {chm_nosuch
, 0 }, /* 0x9f */
1925 {chm_nosuch
, 0 }, /* 0xa0 */
1926 {chm_nosuch
, 0 }, /* 0xa1 */
1927 {chm_nosuch
, 0 }, /* 0xa2 */
1928 {chm_nosuch
, 0 }, /* 0xa3 */
1929 {chm_nosuch
, 0 }, /* 0xa4 */
1930 {chm_nosuch
, 0 }, /* 0xa5 */
1931 {chm_nosuch
, 0 }, /* 0xa6 */
1932 {chm_nosuch
, 0 }, /* 0xa7 */
1933 {chm_nosuch
, 0 }, /* 0xa8 */
1934 {chm_nosuch
, 0 }, /* 0xa9 */
1935 {chm_nosuch
, 0 }, /* 0xaa */
1936 {chm_nosuch
, 0 }, /* 0xab */
1937 {chm_nosuch
, 0 }, /* 0xac */
1938 {chm_nosuch
, 0 }, /* 0xad */
1939 {chm_nosuch
, 0 }, /* 0xae */
1940 {chm_nosuch
, 0 }, /* 0xaf */
1942 {chm_nosuch
, 0 }, /* 0xb0 */
1943 {chm_nosuch
, 0 }, /* 0xb1 */
1944 {chm_nosuch
, 0 }, /* 0xb2 */
1945 {chm_nosuch
, 0 }, /* 0xb3 */
1946 {chm_nosuch
, 0 }, /* 0xb4 */
1947 {chm_nosuch
, 0 }, /* 0xb5 */
1948 {chm_nosuch
, 0 }, /* 0xb6 */
1949 {chm_nosuch
, 0 }, /* 0xb7 */
1950 {chm_nosuch
, 0 }, /* 0xb8 */
1951 {chm_nosuch
, 0 }, /* 0xb9 */
1952 {chm_nosuch
, 0 }, /* 0xba */
1953 {chm_nosuch
, 0 }, /* 0xbb */
1954 {chm_nosuch
, 0 }, /* 0xbc */
1955 {chm_nosuch
, 0 }, /* 0xbd */
1956 {chm_nosuch
, 0 }, /* 0xbe */
1957 {chm_nosuch
, 0 }, /* 0xbf */
1959 {chm_nosuch
, 0 }, /* 0xc0 */
1960 {chm_nosuch
, 0 }, /* 0xc1 */
1961 {chm_nosuch
, 0 }, /* 0xc2 */
1962 {chm_nosuch
, 0 }, /* 0xc3 */
1963 {chm_nosuch
, 0 }, /* 0xc4 */
1964 {chm_nosuch
, 0 }, /* 0xc5 */
1965 {chm_nosuch
, 0 }, /* 0xc6 */
1966 {chm_nosuch
, 0 }, /* 0xc7 */
1967 {chm_nosuch
, 0 }, /* 0xc8 */
1968 {chm_nosuch
, 0 }, /* 0xc9 */
1969 {chm_nosuch
, 0 }, /* 0xca */
1970 {chm_nosuch
, 0 }, /* 0xcb */
1971 {chm_nosuch
, 0 }, /* 0xcc */
1972 {chm_nosuch
, 0 }, /* 0xcd */
1973 {chm_nosuch
, 0 }, /* 0xce */
1974 {chm_nosuch
, 0 }, /* 0xcf */
1976 {chm_nosuch
, 0 }, /* 0xd0 */
1977 {chm_nosuch
, 0 }, /* 0xd1 */
1978 {chm_nosuch
, 0 }, /* 0xd2 */
1979 {chm_nosuch
, 0 }, /* 0xd3 */
1980 {chm_nosuch
, 0 }, /* 0xd4 */
1981 {chm_nosuch
, 0 }, /* 0xd5 */
1982 {chm_nosuch
, 0 }, /* 0xd6 */
1983 {chm_nosuch
, 0 }, /* 0xd7 */
1984 {chm_nosuch
, 0 }, /* 0xd8 */
1985 {chm_nosuch
, 0 }, /* 0xd9 */
1986 {chm_nosuch
, 0 }, /* 0xda */
1987 {chm_nosuch
, 0 }, /* 0xdb */
1988 {chm_nosuch
, 0 }, /* 0xdc */
1989 {chm_nosuch
, 0 }, /* 0xdd */
1990 {chm_nosuch
, 0 }, /* 0xde */
1991 {chm_nosuch
, 0 }, /* 0xdf */
1993 {chm_nosuch
, 0 }, /* 0xe0 */
1994 {chm_nosuch
, 0 }, /* 0xe1 */
1995 {chm_nosuch
, 0 }, /* 0xe2 */
1996 {chm_nosuch
, 0 }, /* 0xe3 */
1997 {chm_nosuch
, 0 }, /* 0xe4 */
1998 {chm_nosuch
, 0 }, /* 0xe5 */
1999 {chm_nosuch
, 0 }, /* 0xe6 */
2000 {chm_nosuch
, 0 }, /* 0xe7 */
2001 {chm_nosuch
, 0 }, /* 0xe8 */
2002 {chm_nosuch
, 0 }, /* 0xe9 */
2003 {chm_nosuch
, 0 }, /* 0xea */
2004 {chm_nosuch
, 0 }, /* 0xeb */
2005 {chm_nosuch
, 0 }, /* 0xec */
2006 {chm_nosuch
, 0 }, /* 0xed */
2007 {chm_nosuch
, 0 }, /* 0xee */
2008 {chm_nosuch
, 0 }, /* 0xef */
2010 {chm_nosuch
, 0 }, /* 0xf0 */
2011 {chm_nosuch
, 0 }, /* 0xf1 */
2012 {chm_nosuch
, 0 }, /* 0xf2 */
2013 {chm_nosuch
, 0 }, /* 0xf3 */
2014 {chm_nosuch
, 0 }, /* 0xf4 */
2015 {chm_nosuch
, 0 }, /* 0xf5 */
2016 {chm_nosuch
, 0 }, /* 0xf6 */
2017 {chm_nosuch
, 0 }, /* 0xf7 */
2018 {chm_nosuch
, 0 }, /* 0xf8 */
2019 {chm_nosuch
, 0 }, /* 0xf9 */
2020 {chm_nosuch
, 0 }, /* 0xfa */
2021 {chm_nosuch
, 0 }, /* 0xfb */
2022 {chm_nosuch
, 0 }, /* 0xfc */
2023 {chm_nosuch
, 0 }, /* 0xfd */
2024 {chm_nosuch
, 0 }, /* 0xfe */
2025 {chm_nosuch
, 0 }, /* 0xff */
2030 /* set_channel_mode()
2032 * inputs - client, source, channel, membership pointer, params
2034 * side effects - channel modes/memberships are changed, MODE is issued
2036 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
2039 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
2040 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
2042 static char cmdbuf
[BUFSIZE
];
2043 static char modebuf
[BUFSIZE
];
2044 static char parabuf
[BUFSIZE
];
2047 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
2048 int i
, j
, flags
, override
;
2053 const char *ml
= parv
[0];
2055 struct Client
*fakesource_p
;
2056 int flags_list
[3] = { ALL_MEMBERS
, ONLY_CHANOPS
, ONLY_OPERS
};
2061 mode_limit_simple
= 0;
2063 alevel
= get_channel_access(source_p
, msptr
);
2065 no_override_deop
= 0;
2067 /* Hide connecting server on netburst -- jilles */
2068 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
2071 fakesource_p
= source_p
;
2073 for(; (c
= *ml
) != 0; ml
++)
2087 /* If this mode char is locked, don't allow local users to change it. */
2088 if (MyClient(source_p
) && chptr
->mode_lock
&& strchr(chptr
->mode_lock
, c
))
2090 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
2093 chmode_table
[(unsigned char) c
].mode_type
);
2098 /* bail out if we have nothing to do... */
2102 if(IsServer(source_p
))
2103 rb_sprintf(cmdbuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
2105 rb_sprintf(cmdbuf
, ":%s!%s@%s MODE %s ",
2106 source_p
->name
, source_p
->username
,
2107 source_p
->host
, chptr
->chname
);
2111 for (override
= 0; override
< (IsOverride(source_p
) && alevel
!= CHFL_CHANOP
? 2 : 1); ++override
)
2113 int was_on_chan
= 0;
2120 msptr
->flags
|= CHFL_CHANOP
;
2123 add_user_to_channel(chptr
, source_p
, CHFL_CHANOP
);
2126 for(j
= 0, flags
= flags_list
[0]; j
< 3; j
++, flags
= flags_list
[j
])
2129 mbuf
= modebuf
+ mlen
;
2132 paracount
= paralen
= 0;
2135 for(i
= 0; i
< mode_count
; i
++)
2137 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
2140 if(mode_changes
[i
].override
!= override
)
2143 if(mode_changes
[i
].arg
!= NULL
)
2145 arglen
= strlen(mode_changes
[i
].arg
);
2147 if(arglen
> MODEBUFLEN
- 5)
2153 /* if we're creeping over MAXMODEPARAMSSERV, or over
2154 * bufsize (4 == +/-,modechar,two spaces) send now.
2156 if(mode_changes
[i
].arg
!= NULL
&&
2157 ((paracount
== MAXMODEPARAMSSERV
) ||
2158 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
2164 sendto_channel_local(flags
, chptr
, "%s%s %s",
2165 cmdbuf
, modebuf
, parabuf
);
2168 sendto_wallops_flags(UMODE_WALLOP
, &me
,
2169 "%s is overriding modes on %s: %s %s",
2170 get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2171 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
2172 ":%s WALLOPS :%s is overriding modes on %s: %s %s",
2173 me
.name
, get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2179 paracount
= paralen
= 0;
2181 mbuf
= modebuf
+ mlen
;
2187 if(dir
!= mode_changes
[i
].dir
)
2189 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
2191 dir
= mode_changes
[i
].dir
;
2194 *mbuf
++ = mode_changes
[i
].letter
;
2197 if(mode_changes
[i
].arg
!= NULL
)
2200 len
= rb_sprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
2206 if(paralen
&& parabuf
[paralen
- 1] == ' ')
2207 parabuf
[paralen
- 1] = '\0';
2212 sendto_channel_local(flags
, chptr
, "%s%s %s", cmdbuf
, modebuf
, parabuf
);
2215 sendto_wallops_flags(UMODE_WALLOP
, &me
,
2216 "%s is overriding modes on %s: %s %s",
2217 get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2218 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
2219 ":%s WALLOPS :%s is overriding modes on %s: %s %s",
2220 me
.name
, get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2227 remove_user_from_channel(find_channel_membership(chptr
, source_p
));
2228 else if (!no_override_deop
)
2229 msptr
->flags
&= ~CHFL_CHANOP
;
2233 /* only propagate modes originating locally, or if we're hubbing */
2234 if(MyClient(source_p
) || rb_dlink_list_length(&serv_list
) > 1)
2235 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);
2238 /* set_channel_mlock()
2240 * inputs - client, source, channel, params
2242 * side effects - channel mlock is changed / MLOCK is propagated
2245 set_channel_mlock(struct Client
*client_p
, struct Client
*source_p
,
2246 struct Channel
*chptr
, const char *newmlock
)
2248 rb_free(chptr
->mode_lock
);
2249 chptr
->mode_lock
= rb_strdup(newmlock
);
2251 sendto_server(client_p
, NULL
, CAP_TS6
| CAP_MLOCK
, NOCAPS
, ":%s MLOCK %ld %s %s",
2252 source_p
->id
, (long) chptr
->channelts
, chptr
->chname
, chptr
->mode_lock
);