2 * Solanum: a slightly advanced 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
34 #include "s_serv.h" /* captab */
38 #include "s_conf.h" /* ConfigFileEntry, ConfigChannel */
39 #include "s_newconf.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
59 #define SM_ERR_MLOCK 0x00002000
61 #define MAXMODES_SIMPLE 46 /* a-zA-Z except bqeIov */
63 static struct ChModeChange mode_changes
[BUFSIZE
];
64 static int mode_count
;
65 static int mode_limit
;
66 static int mode_limit_simple
;
68 static int removed_mask_pos
;
71 char cflagsmyinfo
[256];
73 int chmode_flags
[256];
75 extern int h_get_channel_access
;
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_op
&&
96 chmode_table
[i
].set_func
!= chm_voice
)
98 chmode_flags
[i
] = chmode_table
[i
].mode_type
;
105 switch (chmode_flags
[i
])
107 case MODE_FREETARGET
:
108 case MODE_DISFORWARD
:
109 if(ConfigChannel
.use_forward
)
113 if(chmode_flags
[i
] != 0)
119 /* Should we leave orphaned check here? -- dwr */
120 if (chmode_table
[i
].set_func
!= NULL
&&
121 chmode_table
[i
].set_func
!= chm_nosuch
&&
122 chmode_table
[i
].set_func
!= chm_orphaned
)
136 * outputs - an available cflag bitmask or
137 * 0 if no cflags are available
138 * side effects - NONE
141 find_cflag_slot(void)
143 unsigned int all_cflags
= 0, my_cflag
= 0, i
;
145 for (i
= 0; i
< 256; i
++)
146 all_cflags
|= chmode_flags
[i
];
148 for (my_cflag
= 1; my_cflag
&& (all_cflags
& my_cflag
);
155 cflag_add(char c_
, ChannelModeFunc function
)
157 int c
= (unsigned char)c_
;
159 if (chmode_table
[c
].set_func
!= NULL
&&
160 chmode_table
[c
].set_func
!= chm_nosuch
&&
161 chmode_table
[c
].set_func
!= chm_orphaned
)
164 if (chmode_table
[c
].set_func
== NULL
|| chmode_table
[c
].set_func
== chm_nosuch
)
165 chmode_table
[c
].mode_type
= find_cflag_slot();
166 if (chmode_table
[c
].mode_type
== 0)
168 chmode_table
[c
].set_func
= function
;
169 construct_cflags_strings();
170 return chmode_table
[c
].mode_type
;
174 cflag_orphan(char c_
)
176 int c
= (unsigned char)c_
;
178 s_assert(chmode_flags
[c
] != 0);
179 chmode_table
[c
].set_func
= chm_orphaned
;
180 construct_cflags_strings();
184 get_channel_access(struct Client
*source_p
, struct Channel
*chptr
, struct membership
*msptr
, int dir
, const char *modestr
)
186 hook_data_channel_approval moduledata
;
188 if(!MyClient(source_p
))
191 moduledata
.client
= source_p
;
192 moduledata
.chptr
= chptr
;
193 moduledata
.msptr
= msptr
;
194 moduledata
.target
= NULL
;
195 moduledata
.approved
= (msptr
!= NULL
&& is_chanop(msptr
)) ? CHFL_CHANOP
: CHFL_PEON
;
196 moduledata
.dir
= dir
;
197 moduledata
.modestr
= modestr
;
199 call_hook(h_get_channel_access
, &moduledata
);
201 return moduledata
.approved
;
204 /* allow_mode_change()
206 * Checks if mlock and chanops permit a mode change.
208 * inputs - client, channel, access level, errors pointer, mode char
209 * outputs - false on failure, true on success
210 * side effects - error message sent on failure
213 allow_mode_change(struct Client
*source_p
, struct Channel
*chptr
, int alevel
,
216 /* If this mode char is locked, don't allow local users to change it. */
217 if (MyClient(source_p
) && chptr
->mode_lock
&& strchr(chptr
->mode_lock
, c
))
219 if (!(*errors
& SM_ERR_MLOCK
))
220 sendto_one_numeric(source_p
,
222 form_str(ERR_MLOCKRESTRICTED
),
226 *errors
|= SM_ERR_MLOCK
;
229 if(alevel
< CHFL_CHANOP
)
231 if(!(*errors
& SM_ERR_NOOPS
))
232 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
233 me
.name
, source_p
->name
, chptr
->chname
);
234 *errors
|= SM_ERR_NOOPS
;
242 * inputs - client, channel, id to add, type, forward
243 * outputs - false on failure, true on success
244 * side effects - given id is added to the appropriate list
247 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
, const char *forward
,
248 rb_dlink_list
* list
, long mode_type
)
250 struct Ban
*actualBan
;
251 static char who
[USERHOST_REPLYLEN
];
252 char *realban
= LOCAL_COPY(banid
);
255 /* dont let local clients overflow the banlist, or set redundant
258 if(MyClient(source_p
))
260 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
)) >= (unsigned long)((chptr
->mode
.mode
& MODE_EXLIMIT
) ? ConfigChannel
.max_bans_large
: ConfigChannel
.max_bans
))
262 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
263 me
.name
, source_p
->name
, chptr
->chname
, realban
);
267 RB_DLINK_FOREACH(ptr
, list
->head
)
269 actualBan
= ptr
->data
;
270 if(mask_match(actualBan
->banstr
, realban
))
274 /* dont let remotes set duplicates */
277 RB_DLINK_FOREACH(ptr
, list
->head
)
279 actualBan
= ptr
->data
;
280 if(!irccmp(actualBan
->banstr
, realban
))
286 if(IsPerson(source_p
))
287 sprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
289 rb_strlcpy(who
, source_p
->name
, sizeof(who
));
291 actualBan
= allocate_ban(realban
, who
, forward
);
292 actualBan
->when
= rb_current_time();
294 rb_dlinkAdd(actualBan
, &actualBan
->node
, list
);
296 /* invalidate the can_send() cache */
297 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
298 chptr
->bants
= rb_current_time();
305 * inputs - channel, id to remove, type
306 * outputs - pointer to ban that was removed, if any
307 * side effects - given id is removed from the appropriate list and returned
310 del_id(struct Channel
*chptr
, const char *banid
, rb_dlink_list
* list
, long mode_type
)
315 if(EmptyString(banid
))
318 RB_DLINK_FOREACH(ptr
, list
->head
)
322 if(irccmp(banid
, banptr
->banstr
) == 0)
324 rb_dlinkDelete(&banptr
->node
, list
);
326 /* invalidate the can_send() cache */
327 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
328 chptr
->bants
= rb_current_time();
339 * input - string to check
340 * output - pointer to 'fixed' string, or "*" if empty
341 * side effects - any white space found becomes \0
344 check_string(char *s
)
347 static char splat
[] = "*";
364 * inputs - mask to pretty
365 * outputs - better version of the mask
366 * side effects - mask is chopped to limits, and transformed:
374 pretty_mask(const char *idmask
)
376 static char mask_buf
[BUFSIZE
];
378 const char *nick
, *user
, *host
, *forward
= NULL
;
384 mask
= LOCAL_COPY(idmask
);
385 mask
= check_string(mask
);
387 masklen
= strlen(mask
);
389 nick
= user
= host
= "*";
393 if((size_t) BUFSIZE
- mask_pos
< masklen
+ 5)
396 old_mask_pos
= mask_pos
;
400 memcpy(mask_buf
+ mask_pos
, mask
, masklen
+ 1);
401 mask_pos
+= masklen
+ 1;
402 t
= mask_buf
+ old_mask_pos
+ 1;
408 return mask_buf
+ old_mask_pos
;
412 if((t
= memchr(mask
, '@', masklen
)) != NULL
)
417 host
= t
, hl
= strlen(t
);
419 if((t
= memchr(mask
, '!', at
- mask
)) != NULL
)
424 user
= t
, ul
= at
- t
;
426 nick
= mask
, nl
= ex
- mask
;
431 user
= mask
, ul
= at
- mask
;
434 if((t
= memchr(host
, '!', hl
)) != NULL
||
435 (t
= memchr(host
, '$', hl
)) != NULL
)
439 forward
= t
, fl
= host
+ hl
- t
;
443 else if((t
= memchr(mask
, '!', masklen
)) != NULL
)
448 nick
= mask
, nl
= ex
- mask
;
450 user
= t
, ul
= strlen(t
);
452 else if(memchr(mask
, '.', masklen
) != NULL
||
453 memchr(mask
, ':', masklen
) != NULL
)
455 host
= mask
, hl
= masklen
;
460 nick
= mask
, nl
= masklen
;
463 /* truncate values to max lengths */
473 memcpy(mask_buf
+ mask_pos
, nick
, nl
), mask_pos
+= nl
;
474 mask_buf
[mask_pos
++] = '!';
475 memcpy(mask_buf
+ mask_pos
, user
, ul
), mask_pos
+= ul
;
476 mask_buf
[mask_pos
++] = '@';
477 memcpy(mask_buf
+ mask_pos
, host
, hl
), mask_pos
+= hl
;
479 mask_buf
[mask_pos
++] = '$';
480 memcpy(mask_buf
+ mask_pos
, forward
, fl
), mask_pos
+= fl
;
482 mask_buf
[mask_pos
++] = '\0';
484 return mask_buf
+ old_mask_pos
;
489 * input - client, channel to set mode on, target channel name
490 * output - true if forwarding should be allowed
491 * side effects - numeric sent if not allowed
494 check_forward(struct Client
*source_p
, struct Channel
*chptr
,
497 struct Channel
*targptr
= NULL
;
498 struct membership
*msptr
;
500 if(!check_channel_name(forward
) ||
501 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
503 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
506 /* don't forward to inconsistent target -- jilles */
507 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
509 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
510 form_str(ERR_BADCHANNAME
), forward
);
513 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
515 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
516 form_str(ERR_NOSUCHCHANNEL
), forward
);
519 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
521 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
522 get_channel_access(source_p
, targptr
, msptr
, MODE_QUERY
, NULL
) < CHFL_CHANOP
)
524 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
525 me
.name
, source_p
->name
, targptr
->chname
);
535 * output - the same key, fixed
536 * side effects - anything below ascii 13 is discarded, ':' discarded,
537 * high ascii is dropped to lower half of ascii table
542 unsigned char *s
, *t
, c
;
544 for(s
= t
= (unsigned char *) arg
; (c
= *s
); s
++)
547 if(c
!= ':' && c
!= ',' && c
> ' ')
558 * ouput - the same key, fixed
559 * side effects - high ascii dropped to lower half of table,
560 * CR/LF/':' are dropped
563 fix_key_remote(char *arg
)
565 unsigned char *s
, *t
, c
;
567 for(s
= t
= (unsigned char *) arg
; (c
= *s
); s
++)
570 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
580 * The handlers for each specific mode.
583 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
584 int alevel
, const char *arg
, int *errors
, int dir
, char c
, long mode_type
)
586 if(*errors
& SM_ERR_UNKNOWN
)
588 *errors
|= SM_ERR_UNKNOWN
;
589 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
593 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
594 int alevel
, const char *arg
, int *errors
, int dir
, char c
, long mode_type
)
596 if(!allow_mode_change(source_p
, chptr
, alevel
, errors
, c
))
599 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
603 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
605 /* if +f is disabled, ignore an attempt to set +QF locally */
606 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
607 (c
== 'Q' || c
== 'F'))
610 chptr
->mode
.mode
|= mode_type
;
612 mode_changes
[mode_count
].letter
= c
;
613 mode_changes
[mode_count
].dir
= MODE_ADD
;
614 mode_changes
[mode_count
].id
= NULL
;
615 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
616 mode_changes
[mode_count
++].arg
= NULL
;
618 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
620 chptr
->mode
.mode
&= ~mode_type
;
622 mode_changes
[mode_count
].letter
= c
;
623 mode_changes
[mode_count
].dir
= MODE_DEL
;
624 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
625 mode_changes
[mode_count
].id
= NULL
;
626 mode_changes
[mode_count
++].arg
= NULL
;
631 chm_orphaned(struct Client
*source_p
, struct Channel
*chptr
,
632 int alevel
, const char *arg
, int *errors
, int dir
, char c
, long mode_type
)
634 if(MyClient(source_p
))
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
].id
= NULL
;
644 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
645 mode_changes
[mode_count
++].arg
= NULL
;
647 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
649 chptr
->mode
.mode
&= ~mode_type
;
651 mode_changes
[mode_count
].letter
= c
;
652 mode_changes
[mode_count
].dir
= MODE_DEL
;
653 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
654 mode_changes
[mode_count
].id
= NULL
;
655 mode_changes
[mode_count
++].arg
= NULL
;
660 chm_hidden(struct Client
*source_p
, struct Channel
*chptr
,
661 int alevel
, const char *arg
, int *errors
, int dir
, char c
, long mode_type
)
663 if(MyClient(source_p
) && !IsOperGeneral(source_p
))
665 if(!(*errors
& SM_ERR_NOPRIVS
))
666 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
667 *errors
|= SM_ERR_NOPRIVS
;
670 if(MyClient(source_p
) && !IsOperAdmin(source_p
))
672 if(!(*errors
& SM_ERR_NOPRIVS
))
673 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
674 source_p
->name
, "admin");
675 *errors
|= SM_ERR_NOPRIVS
;
679 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
683 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
685 chptr
->mode
.mode
|= mode_type
;
687 mode_changes
[mode_count
].letter
= c
;
688 mode_changes
[mode_count
].dir
= MODE_ADD
;
689 mode_changes
[mode_count
].id
= NULL
;
690 mode_changes
[mode_count
].mems
= ONLY_OPERS
;
691 mode_changes
[mode_count
++].arg
= NULL
;
693 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
695 chptr
->mode
.mode
&= ~mode_type
;
697 mode_changes
[mode_count
].letter
= c
;
698 mode_changes
[mode_count
].dir
= MODE_DEL
;
699 mode_changes
[mode_count
].mems
= ONLY_OPERS
;
700 mode_changes
[mode_count
].id
= NULL
;
701 mode_changes
[mode_count
++].arg
= NULL
;
706 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
707 int alevel
, const char *arg
, int *errors
, int dir
, char c
, long mode_type
)
709 if(MyClient(source_p
) && !IsOper(source_p
))
711 if(!(*errors
& SM_ERR_NOPRIVS
))
712 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
713 *errors
|= SM_ERR_NOPRIVS
;
716 if(MyClient(source_p
) && !HasPrivilege(source_p
, "oper:cmodes"))
718 if(!(*errors
& SM_ERR_NOPRIVS
))
719 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
720 source_p
->name
, "cmodes");
721 *errors
|= SM_ERR_NOPRIVS
;
725 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
729 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
731 chptr
->mode
.mode
|= mode_type
;
733 mode_changes
[mode_count
].letter
= c
;
734 mode_changes
[mode_count
].dir
= MODE_ADD
;
735 mode_changes
[mode_count
].id
= NULL
;
736 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
737 mode_changes
[mode_count
++].arg
= NULL
;
739 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
741 chptr
->mode
.mode
&= ~mode_type
;
743 mode_changes
[mode_count
].letter
= c
;
744 mode_changes
[mode_count
].dir
= MODE_DEL
;
745 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
746 mode_changes
[mode_count
].id
= NULL
;
747 mode_changes
[mode_count
++].arg
= NULL
;
752 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
753 int alevel
, const char *arg
, int *errors
, int dir
, char c
, long mode_type
)
761 const char *rpl_list_p
;
762 const char *rpl_endlist_p
;
768 list
= &chptr
->banlist
;
769 errorval
= SM_ERR_RPL_B
;
770 rpl_list_p
= form_str(RPL_BANLIST
);
771 rpl_endlist_p
= form_str(RPL_ENDOFBANLIST
);
776 /* if +e is disabled, allow all but +e locally */
777 if (!ConfigChannel
.use_except
&& MyClient(source_p
) && dir
== MODE_ADD
)
780 list
= &chptr
->exceptlist
;
781 errorval
= SM_ERR_RPL_E
;
782 rpl_list_p
= form_str(RPL_EXCEPTLIST
);
783 rpl_endlist_p
= form_str(RPL_ENDOFEXCEPTLIST
);
785 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
792 /* if +I is disabled, allow all but +I locally */
793 if (!ConfigChannel
.use_invex
&& MyClient(source_p
) && dir
== MODE_ADD
)
796 list
= &chptr
->invexlist
;
797 errorval
= SM_ERR_RPL_I
;
798 rpl_list_p
= form_str(RPL_INVITELIST
);
799 rpl_endlist_p
= form_str(RPL_ENDOFINVITELIST
);
801 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
808 list
= &chptr
->quietlist
;
809 errorval
= SM_ERR_RPL_Q
;
810 rpl_list_p
= form_str(RPL_QUIETLIST
);
811 rpl_endlist_p
= form_str(RPL_ENDOFQUIETLIST
);
816 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
820 if (dir
== MODE_QUERY
)
822 if((*errors
& errorval
) != 0)
826 /* non-ops cant see +eI lists.. */
827 /* note that this is still permitted if +e/+I are mlocked. */
828 if(alevel
< CHFL_CHANOP
&& mode_type
!= CHFL_BAN
&&
829 mode_type
!= CHFL_QUIET
)
831 if(!(*errors
& SM_ERR_NOOPS
))
832 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
833 me
.name
, source_p
->name
, chptr
->chname
);
834 *errors
|= SM_ERR_NOOPS
;
838 RB_DLINK_FOREACH(ptr
, list
->head
)
843 snprintf(buf
, sizeof(buf
), "%s$%s", banptr
->banstr
, banptr
->forward
);
845 rb_strlcpy(buf
, banptr
->banstr
, sizeof(buf
));
847 sendto_one(source_p
, rpl_list_p
,
848 me
.name
, source_p
->name
, chptr
->chname
,
849 buf
, banptr
->who
, banptr
->when
);
851 sendto_one(source_p
, rpl_endlist_p
, me
.name
, source_p
->name
, chptr
->chname
);
855 if (!allow_mode_change(source_p
, chptr
, alevel
, errors
, c
))
859 if (MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
862 /* empty ban, or starts with ':' which messes up s2s, ignore it */
863 if (EmptyString(arg
) || *arg
== ':')
866 if (!MyClient(source_p
))
868 if (strchr(arg
, ' '))
874 mask
= pretty_mask(arg
);
876 /* we'd have problems parsing this, hyb6 does it too
877 * also make sure it will always fit on a line with channel
880 if(strlen(mask
) > MIN(BANLEN
, MODEBUFLEN
- 5))
882 sendto_one_numeric(source_p
, ERR_INVALIDBAN
,
883 form_str(ERR_INVALIDBAN
),
884 chptr
->chname
, c
, arg
);
888 /* Look for a $ after the first character.
889 * As the first character, it marks an extban; afterwards
890 * it delimits a forward channel.
892 if ((forward
= strchr(mask
+1, '$')) != NULL
)
895 if (*forward
== '\0')
899 /* if we're adding a NEW id */
902 if (*mask
== '$' && MyClient(source_p
))
904 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
906 sendto_one_numeric(source_p
, ERR_INVALIDBAN
,
907 form_str(ERR_INVALIDBAN
),
908 chptr
->chname
, c
, arg
);
913 /* For compatibility, only check the forward channel from
914 * local clients. Accept any forward channel from servers.
916 if (forward
!= NULL
&& MyClient(source_p
))
918 /* For simplicity and future flexibility, do not
919 * allow '$' in forwarding targets.
921 if (!ConfigChannel
.use_forward
||
922 strchr(forward
, '$') != NULL
)
924 sendto_one_numeric(source_p
, ERR_INVALIDBAN
,
925 form_str(ERR_INVALIDBAN
),
926 chptr
->chname
, c
, arg
);
929 /* check_forward() sends its own error message */
930 if (!check_forward(source_p
, chptr
, forward
))
932 /* Forwards only make sense for bans. */
933 if (mode_type
!= CHFL_BAN
)
935 sendto_one_numeric(source_p
, ERR_INVALIDBAN
,
936 form_str(ERR_INVALIDBAN
),
937 chptr
->chname
, c
, arg
);
942 /* dont allow local clients to overflow the banlist, dont
943 * let remote servers set duplicate bans
945 if (!add_id(source_p
, chptr
, mask
, forward
, list
, mode_type
))
951 mode_changes
[mode_count
].letter
= c
;
952 mode_changes
[mode_count
].dir
= MODE_ADD
;
953 mode_changes
[mode_count
].mems
= mems
;
954 mode_changes
[mode_count
].id
= NULL
;
955 mode_changes
[mode_count
++].arg
= mask
;
957 else if (dir
== MODE_DEL
)
960 static char buf
[BANLEN
* MAXMODEPARAMS
];
961 int old_removed_mask_pos
= removed_mask_pos
;
962 if ((removed
= del_id(chptr
, mask
, list
, mode_type
)) == NULL
)
964 /* mask isn't a valid ban, check arg */
965 if ((removed
= del_id(chptr
, arg
, list
, mode_type
)) != NULL
)
969 if (removed
&& removed
->forward
)
970 removed_mask_pos
+= snprintf(buf
+ old_removed_mask_pos
, sizeof(buf
), "%s$%s", removed
->banstr
, removed
->forward
) + 1;
972 removed_mask_pos
+= rb_strlcpy(buf
+ old_removed_mask_pos
, mask
, sizeof(buf
)) + 1;
979 mode_changes
[mode_count
].letter
= c
;
980 mode_changes
[mode_count
].dir
= MODE_DEL
;
981 mode_changes
[mode_count
].mems
= mems
;
982 mode_changes
[mode_count
].id
= NULL
;
983 mode_changes
[mode_count
++].arg
= buf
+ old_removed_mask_pos
;
988 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
989 int alevel
, const char *arg
, int *errors
, int dir
, char c
, long mode_type
)
991 struct membership
*mstptr
;
992 struct Client
*targ_p
;
994 if(!allow_mode_change(source_p
, chptr
, alevel
, errors
, c
))
1000 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1004 if((targ_p
= find_chasing(source_p
, arg
, NULL
)) == NULL
)
1009 mstptr
= find_channel_membership(chptr
, targ_p
);
1013 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1014 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1015 form_str(ERR_USERNOTINCHANNEL
), arg
, chptr
->chname
);
1016 *errors
|= SM_ERR_NOTONCHANNEL
;
1020 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1025 if(targ_p
== source_p
&& mstptr
->flags
& CHFL_CHANOP
)
1028 mode_changes
[mode_count
].letter
= c
;
1029 mode_changes
[mode_count
].dir
= MODE_ADD
;
1030 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1031 mode_changes
[mode_count
].id
= targ_p
->id
;
1032 mode_changes
[mode_count
++].arg
= targ_p
->name
;
1034 mstptr
->flags
|= CHFL_CHANOP
;
1038 if(MyClient(source_p
) && IsService(targ_p
))
1040 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1041 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1045 mode_changes
[mode_count
].letter
= c
;
1046 mode_changes
[mode_count
].dir
= MODE_DEL
;
1047 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1048 mode_changes
[mode_count
].id
= targ_p
->id
;
1049 mode_changes
[mode_count
++].arg
= targ_p
->name
;
1051 mstptr
->flags
&= ~CHFL_CHANOP
;
1056 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
1057 int alevel
, const char *arg
, int *errors
, int dir
, char c
, long mode_type
)
1059 struct membership
*mstptr
;
1060 struct Client
*targ_p
;
1062 if(!allow_mode_change(source_p
, chptr
, alevel
, errors
, c
))
1066 if(EmptyString(arg
))
1068 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1072 if((targ_p
= find_chasing(source_p
, arg
, NULL
)) == NULL
)
1077 mstptr
= find_channel_membership(chptr
, targ_p
);
1081 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1082 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1083 form_str(ERR_USERNOTINCHANNEL
), arg
, chptr
->chname
);
1084 *errors
|= SM_ERR_NOTONCHANNEL
;
1088 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1093 mode_changes
[mode_count
].letter
= c
;
1094 mode_changes
[mode_count
].dir
= MODE_ADD
;
1095 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1096 mode_changes
[mode_count
].id
= targ_p
->id
;
1097 mode_changes
[mode_count
++].arg
= targ_p
->name
;
1099 mstptr
->flags
|= CHFL_VOICE
;
1103 mode_changes
[mode_count
].letter
= 'v';
1104 mode_changes
[mode_count
].dir
= MODE_DEL
;
1105 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1106 mode_changes
[mode_count
].id
= targ_p
->id
;
1107 mode_changes
[mode_count
++].arg
= targ_p
->name
;
1109 mstptr
->flags
&= ~CHFL_VOICE
;
1114 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
1115 int alevel
, const char *arg
, int *errors
, int dir
, char c
, long mode_type
)
1117 static char limitstr
[30];
1120 if (!allow_mode_change(source_p
, chptr
, alevel
, errors
, c
))
1123 if (MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1126 if (dir
== MODE_ADD
)
1128 if (EmptyString(arg
) || (limit
= atoi(arg
)) <= 0)
1131 sprintf(limitstr
, "%d", limit
);
1133 mode_changes
[mode_count
].letter
= c
;
1134 mode_changes
[mode_count
].dir
= MODE_ADD
;
1135 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1136 mode_changes
[mode_count
].id
= NULL
;
1137 mode_changes
[mode_count
++].arg
= limitstr
;
1139 chptr
->mode
.limit
= limit
;
1141 else if (dir
== MODE_DEL
)
1143 if(!chptr
->mode
.limit
)
1146 chptr
->mode
.limit
= 0;
1148 mode_changes
[mode_count
].letter
= c
;
1149 mode_changes
[mode_count
].dir
= MODE_DEL
;
1150 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1151 mode_changes
[mode_count
].id
= NULL
;
1152 mode_changes
[mode_count
++].arg
= NULL
;
1157 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
1158 int alevel
, const char *arg
, int *errors
, int dir
, char c
, long mode_type
)
1160 int joins
= 0, timeslice
= 0;
1162 if (!allow_mode_change(source_p
, chptr
, alevel
, errors
, c
))
1165 if (MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1168 if (dir
== MODE_ADD
)
1170 if (sscanf(arg
, "%d:%d", &joins
, ×lice
) < 2)
1173 if(joins
<= 0 || timeslice
<= 0)
1176 mode_changes
[mode_count
].letter
= c
;
1177 mode_changes
[mode_count
].dir
= MODE_ADD
;
1178 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1179 mode_changes
[mode_count
].id
= NULL
;
1180 mode_changes
[mode_count
++].arg
= arg
;
1182 chptr
->mode
.join_num
= joins
;
1183 chptr
->mode
.join_time
= timeslice
;
1185 else if(dir
== MODE_DEL
)
1187 if(!chptr
->mode
.join_num
)
1190 chptr
->mode
.join_num
= 0;
1191 chptr
->mode
.join_time
= 0;
1192 chptr
->join_count
= 0;
1193 chptr
->join_delta
= 0;
1195 mode_changes
[mode_count
].letter
= c
;
1196 mode_changes
[mode_count
].dir
= MODE_DEL
;
1197 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1198 mode_changes
[mode_count
].id
= NULL
;
1199 mode_changes
[mode_count
++].arg
= NULL
;
1204 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
1205 int alevel
, const char *arg
, int *errors
, int dir
, char c
, long mode_type
)
1207 /* if +f is disabled, ignore local attempts to set it */
1208 if (!ConfigChannel
.use_forward
&& MyClient(source_p
) && dir
== MODE_ADD
)
1211 if (dir
== MODE_QUERY
)
1213 if (!(*errors
& SM_ERR_RPL_F
))
1215 if (*chptr
->mode
.forward
== '\0')
1216 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
1218 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
1219 *errors
|= SM_ERR_RPL_F
;
1224 #ifndef FORWARD_OPERONLY
1225 if (!allow_mode_change(source_p
, chptr
, alevel
, errors
, c
))
1228 if (!IsOperGeneral(source_p
) && !IsServer(source_p
))
1230 if(!(*errors
& SM_ERR_NOPRIVS
))
1231 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
1232 *errors
|= SM_ERR_NOPRIVS
;
1237 if (MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1240 if (dir
== MODE_ADD
)
1242 if(EmptyString(arg
))
1245 if(!check_forward(source_p
, chptr
, arg
))
1248 rb_strlcpy(chptr
->mode
.forward
, arg
, sizeof(chptr
->mode
.forward
));
1250 mode_changes
[mode_count
].letter
= c
;
1251 mode_changes
[mode_count
].dir
= MODE_ADD
;
1252 mode_changes
[mode_count
].mems
=
1253 ConfigChannel
.use_forward
? ALL_MEMBERS
: ONLY_SERVERS
;
1254 mode_changes
[mode_count
].id
= NULL
;
1255 mode_changes
[mode_count
++].arg
= arg
;
1257 else if(dir
== MODE_DEL
)
1259 if(!(*chptr
->mode
.forward
))
1262 *chptr
->mode
.forward
= '\0';
1264 mode_changes
[mode_count
].letter
= c
;
1265 mode_changes
[mode_count
].dir
= MODE_DEL
;
1266 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1267 mode_changes
[mode_count
].id
= NULL
;
1268 mode_changes
[mode_count
++].arg
= NULL
;
1273 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1274 int alevel
, const char *arg
, int *errors
, int dir
, char c
, long mode_type
)
1278 if (!allow_mode_change(source_p
, chptr
, alevel
, errors
, c
))
1281 if (MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1284 if (dir
== MODE_ADD
)
1286 key
= LOCAL_COPY(arg
);
1288 if(MyClient(source_p
))
1291 fix_key_remote(key
);
1293 if(EmptyString(key
))
1296 s_assert(key
[0] != ' ');
1297 rb_strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1299 mode_changes
[mode_count
].letter
= c
;
1300 mode_changes
[mode_count
].dir
= MODE_ADD
;
1301 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1302 mode_changes
[mode_count
].id
= NULL
;
1303 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1305 else if(dir
== MODE_DEL
)
1307 static char splat
[] = "*";
1310 if(!(*chptr
->mode
.key
))
1313 /* hack time. when we get a +k-k mode, the +k arg is
1314 * chptr->mode.key, which the -k sets to \0, so hunt for a
1315 * +k when we get a -k, and set the arg to splat. --anfl
1317 for(i
= 0; i
< mode_count
; i
++)
1319 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1320 mode_changes
[i
].arg
= splat
;
1323 *chptr
->mode
.key
= 0;
1325 mode_changes
[mode_count
].letter
= c
;
1326 mode_changes
[mode_count
].dir
= MODE_DEL
;
1327 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1328 mode_changes
[mode_count
].id
= NULL
;
1329 mode_changes
[mode_count
++].arg
= "*";
1334 struct ChannelMode chmode_table
[256] =
1336 ['F'] = {chm_simple
, MODE_FREETARGET
, 0 },
1337 ['I'] = {chm_ban
, CHFL_INVEX
, CHM_QUERYABLE
| CHM_OPS_QUERY
},
1338 ['L'] = {chm_staff
, MODE_EXLIMIT
, 0 },
1339 ['P'] = {chm_staff
, MODE_PERMANENT
, 0 },
1340 ['Q'] = {chm_simple
, MODE_DISFORWARD
, 0 },
1341 ['b'] = {chm_ban
, CHFL_BAN
, CHM_QUERYABLE
},
1342 ['e'] = {chm_ban
, CHFL_EXCEPTION
, CHM_QUERYABLE
| CHM_OPS_QUERY
},
1343 ['f'] = {chm_forward
, 0, CHM_ARG_SET
| CHM_CAN_QUERY
}, /* weird because it's nonstandard and violates isupport */
1344 ['g'] = {chm_simple
, MODE_FREEINVITE
, 0 },
1345 ['i'] = {chm_simple
, MODE_INVITEONLY
, 0 },
1346 ['j'] = {chm_throttle
, 0, CHM_ARG_SET
},
1347 ['k'] = {chm_key
, 0, CHM_QUERYABLE
},
1348 ['l'] = {chm_limit
, 0, CHM_ARG_SET
},
1349 ['m'] = {chm_simple
, MODE_MODERATED
, 0 },
1350 ['n'] = {chm_simple
, MODE_NOPRIVMSGS
, 0 },
1351 ['o'] = {chm_op
, 0, CHM_ARGS
},
1352 ['p'] = {chm_simple
, MODE_PRIVATE
, 0 },
1353 ['q'] = {chm_ban
, CHFL_QUIET
, CHM_QUERYABLE
},
1354 ['r'] = {chm_simple
, MODE_REGONLY
, 0 },
1355 ['s'] = {chm_simple
, MODE_SECRET
, 0 },
1356 ['t'] = {chm_simple
, MODE_TOPICLIMIT
, 0 },
1357 ['v'] = {chm_voice
, 0, CHM_ARGS
},
1358 ['z'] = {chm_simple
, MODE_OPMODERATE
, 0 },
1363 /* set_channel_mode()
1365 * inputs - client, source, channel, membership pointer, params
1367 * side effects - channel modes/memberships are changed, MODE is issued
1369 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
1372 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
1373 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
1375 static char modebuf
[BUFSIZE
* 2]; /* paranoid case: 2 canonical chars per input char */
1376 static char parabuf
[BUFSIZE
];
1379 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
1382 int access_dir
= MODE_QUERY
;
1386 const char *ml
= parv
[0];
1388 struct Client
*fakesource_p
;
1389 int flags_list
[3] = { ALL_MEMBERS
, ONLY_CHANOPS
, ONLY_OPERS
};
1392 removed_mask_pos
= 0;
1395 mode_limit_simple
= 0;
1397 /* Hide connecting server on netburst -- jilles */
1398 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
1401 fakesource_p
= source_p
;
1404 const struct ChannelMode
*cm
;
1410 static struct modeset modesets
[MAXPARA
];
1411 struct modeset
*ms
= modesets
, *mend
;
1412 char canon_op
= '\0';
1416 for (ml
= parv
[0]; *ml
!= 0; ml
++)
1432 int effective_dir
= dir
;
1433 const struct ChannelMode
*cm
= &chmode_table
[(unsigned char) c
];
1434 bool use_arg
= dir
== MODE_ADD
? cm
->flags
& CHM_ARG_SET
:
1435 dir
== MODE_DEL
? cm
->flags
& CHM_ARG_DEL
:
1437 if (cm
->set_func
== NULL
|| cm
->set_func
== chm_nosuch
)
1439 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
1442 if (use_arg
&& parn
>= parc
)
1444 if (!(cm
->flags
& CHM_CAN_QUERY
))
1446 sendto_one(source_p
, form_str(ERR_NEEDMOREPARAMS
), me
.name
, source_p
->name
, "MODE");
1449 effective_dir
= MODE_QUERY
;
1453 if (effective_dir
== MODE_QUERY
&& !(cm
->flags
& CHM_CAN_QUERY
))
1455 /* XXX this currently replicates traditional behaviour and just
1456 * does nothing for a query on a mode with no query. would it be
1457 * good to send an error here?
1462 char op
= effective_dir
== MODE_ADD
? '+' :
1463 effective_dir
== MODE_DEL
? '-' :
1467 *mbuf
++ = canon_op
= op
;
1471 if (effective_dir
!= MODE_QUERY
&& access_dir
== MODE_QUERY
)
1472 access_dir
= effective_dir
;
1473 if (effective_dir
== MODE_QUERY
&& cm
->flags
& CHM_OPS_QUERY
)
1474 access_dir
= MODE_OP_QUERY
;
1477 ms
->dir
= effective_dir
;
1479 ms
->arg
= parv
[parn
++];
1488 /* this will happen on something like MODE +-=++-.
1489 * we'd have caught that with the if !mode_count
1490 * later on, but this saves an override notice
1497 /* XXX we could reject excess params here */
1505 rb_strlcat(modebuf
, reconstruct_parv(parn
- 1, parv
+ 1), sizeof modebuf
);
1511 alevel
= get_channel_access(source_p
, chptr
, msptr
, access_dir
, modebuf
);
1513 for (ms
= modesets
; ms
< mend
; ms
++)
1515 ChannelModeFunc
*set_func
= ms
->cm
->set_func
;
1516 if (set_func
== NULL
)
1517 set_func
= chm_nosuch
;
1518 set_func(fakesource_p
, chptr
, alevel
, ms
->arg
, &errors
, ms
->dir
, ms
->mode
, ms
->cm
->mode_type
);
1521 /* bail out if we have nothing to do... */
1525 if (IsServer(source_p
))
1526 mlen
= sprintf(modebuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
1528 mlen
= sprintf(modebuf
, ":%s!%s@%s MODE %s ",
1529 source_p
->name
, source_p
->username
,
1530 source_p
->host
, chptr
->chname
);
1532 for(j
= 0; j
< 3; j
++)
1534 int send_flags
= flags
= flags_list
[j
];
1535 const char *priv
= NULL
;
1536 if (flags
== ONLY_OPERS
)
1538 send_flags
= ALL_MEMBERS
;
1539 priv
= "auspex:cmodes";
1542 mbuf
= modebuf
+ mlen
;
1545 paracount
= paralen
= 0;
1548 for(i
= 0; i
< mode_count
; i
++)
1550 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
1553 if(mode_changes
[i
].arg
!= NULL
)
1555 arglen
= strlen(mode_changes
[i
].arg
);
1557 if(arglen
> MODEBUFLEN
- 5)
1563 /* if we're creeping over MAXMODEPARAMSSERV, or over
1564 * bufsize (4 == +/-,modechar,two spaces) send now.
1566 if(mode_changes
[i
].arg
!= NULL
&&
1567 ((paracount
== MAXMODEPARAMSSERV
) ||
1568 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
1573 sendto_channel_local_priv(IsServer(source_p
) ? fakesource_p
: source_p
,
1574 send_flags
, priv
, chptr
, "%s %s", modebuf
, parabuf
);
1578 paracount
= paralen
= 0;
1580 mbuf
= modebuf
+ mlen
;
1586 if(dir
!= mode_changes
[i
].dir
)
1588 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
1590 dir
= mode_changes
[i
].dir
;
1593 *mbuf
++ = mode_changes
[i
].letter
;
1596 if(mode_changes
[i
].arg
!= NULL
)
1599 len
= sprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
1605 if(paralen
&& parabuf
[paralen
- 1] == ' ')
1606 parabuf
[paralen
- 1] = '\0';
1610 sendto_channel_local_priv(IsServer(source_p
) ? fakesource_p
: source_p
,
1611 send_flags
, priv
, chptr
, "%s %s", modebuf
, parabuf
);
1614 /* only propagate modes originating locally, or if we're hubbing */
1615 if(MyClient(source_p
) || rb_dlink_list_length(&serv_list
) > 1)
1616 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);
1619 /* set_channel_mlock()
1621 * inputs - client, source, channel, params
1623 * side effects - channel mlock is changed / MLOCK is propagated
1626 set_channel_mlock(struct Client
*client_p
, struct Client
*source_p
,
1627 struct Channel
*chptr
, const char *newmlock
, bool propagate
)
1629 rb_free(chptr
->mode_lock
);
1630 chptr
->mode_lock
= newmlock
? rb_strdup(newmlock
) : NULL
;
1634 sendto_server(client_p
, NULL
, CAP_TS6
| CAP_MLOCK
, NOCAPS
, ":%s MLOCK %ld %s :%s",
1635 source_p
->id
, (long) chptr
->channelts
, chptr
->chname
,
1636 chptr
->mode_lock
? chptr
->mode_lock
: "");