2 * charybdis: A slightly useful ircd.
3 * chmode.c: channel mode management
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
8 * Copyright (C) 2005-2006 charybdis development team
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 * $Id: chmode.c 3580 2007-11-07 23:45:14Z jilles $
37 #include "s_serv.h" /* captab */
41 #include "s_conf.h" /* ConfigFileEntry, ConfigChannel */
42 #include "s_newconf.h"
45 #include "irc_dictionary.h"
47 /* bitmasks for error returns, so we send once per call */
48 #define SM_ERR_NOTS 0x00000001 /* No TS on channel */
49 #define SM_ERR_NOOPS 0x00000002 /* No chan ops */
50 #define SM_ERR_UNKNOWN 0x00000004
51 #define SM_ERR_RPL_C 0x00000008
52 #define SM_ERR_RPL_B 0x00000010
53 #define SM_ERR_RPL_E 0x00000020
54 #define SM_ERR_NOTONCHANNEL 0x00000040 /* Not on channel */
55 #define SM_ERR_RPL_I 0x00000100
56 #define SM_ERR_RPL_D 0x00000200
57 #define SM_ERR_NOPRIVS 0x00000400
58 #define SM_ERR_RPL_Q 0x00000800
59 #define SM_ERR_RPL_F 0x00001000
61 #define MAXMODES_SIMPLE 46 /* a-zA-Z except bqeIov */
63 static struct ChModeChange mode_changes
[BUFSIZE
];
64 static int mode_count
;
65 static int mode_limit
;
66 static int mode_limit_simple
;
68 static int no_override_deop
;
71 char cflagsmyinfo
[256];
73 int chmode_flags
[256];
75 /* OPTIMIZE ME! -- dwr */
77 construct_noparam_modes(void)
80 char *ptr
= cflagsbuf
;
81 char *ptr2
= cflagsmyinfo
;
82 static int prev_chmode_flags
[256];
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 (prev_chmode_flags
[i
] != 0 && prev_chmode_flags
[i
] != chmode_flags
[i
])
108 if (chmode_flags
[i
] == 0)
110 chmode_table
[i
].set_func
= chm_orphaned
;
111 sendto_realops_snomask(SNO_DEBUG
, L_ALL
, "Cmode +%c is now orphaned", i
);
115 sendto_realops_snomask(SNO_DEBUG
, L_ALL
, "Orphaned cmode +%c is picked up by module", i
);
117 chmode_flags
[i
] = prev_chmode_flags
[i
];
120 prev_chmode_flags
[i
] = chmode_flags
[i
];
122 switch (chmode_flags
[i
])
125 case MODE_DISFORWARD
:
126 if(ConfigChannel
.use_forward
)
133 if(rb_dlink_list_length(&service_list
))
140 if(chmode_flags
[i
] != 0)
146 /* Should we leave orphaned check here? -- dwr */
147 if(!(chmode_table
[i
].set_func
== chm_nosuch
) && !(chmode_table
[i
].set_func
== chm_orphaned
))
161 * outputs - an available cflag bitmask or
162 * 0 if no cflags are available
163 * side effects - NONE
166 find_cflag_slot(void)
168 unsigned int all_cflags
= 0, my_cflag
= 0, i
;
170 for (i
= 0; i
< 256; i
++)
171 all_cflags
|= chmode_flags
[i
];
173 for (my_cflag
= 1; my_cflag
&& (all_cflags
& my_cflag
);
180 get_channel_access(struct Client
*source_p
, struct membership
*msptr
)
182 if(!MyClient(source_p
) || is_admin(msptr
))
184 else if(is_chanop(msptr
))
186 else if(is_halfop(msptr
))
194 * inputs - client, channel, id to add, type
195 * outputs - 0 on failure, 1 on success
196 * side effects - given id is added to the appropriate list
199 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
,
200 rb_dlink_list
* list
, long mode_type
)
202 struct Ban
*actualBan
;
203 static char who
[USERHOST_REPLYLEN
];
204 char *realban
= LOCAL_COPY(banid
);
207 /* dont let local clients overflow the banlist, or set redundant
210 if(MyClient(source_p
))
212 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
))
214 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
215 me
.name
, source_p
->name
, chptr
->chname
, realban
);
219 RB_DLINK_FOREACH(ptr
, list
->head
)
221 actualBan
= ptr
->data
;
222 if(mask_match(actualBan
->banstr
, realban
))
226 /* dont let remotes set duplicates */
229 RB_DLINK_FOREACH(ptr
, list
->head
)
231 actualBan
= ptr
->data
;
232 if(!irccmp(actualBan
->banstr
, realban
))
238 if(IsPerson(source_p
))
239 rb_sprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
241 rb_strlcpy(who
, source_p
->name
, sizeof(who
));
243 actualBan
= allocate_ban(realban
, who
);
244 actualBan
->when
= rb_current_time();
246 rb_dlinkAdd(actualBan
, &actualBan
->node
, list
);
248 /* invalidate the can_send() cache */
249 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
257 * inputs - channel, id to remove, type
258 * outputs - 0 on failure, 1 on success
259 * side effects - given id is removed from the appropriate list
262 del_id(struct Channel
*chptr
, const char *banid
, rb_dlink_list
* list
, long mode_type
)
267 if(EmptyString(banid
))
270 RB_DLINK_FOREACH(ptr
, list
->head
)
274 if(irccmp(banid
, banptr
->banstr
) == 0)
276 rb_dlinkDelete(&banptr
->node
, list
);
279 /* invalidate the can_send() cache */
280 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
292 * input - string to check
293 * output - pointer to 'fixed' string, or "*" if empty
294 * side effects - any white space found becomes \0
297 check_string(char *s
)
300 static char splat
[] = "*";
317 * inputs - mask to pretty
318 * outputs - better version of the mask
319 * side effects - mask is chopped to limits, and transformed:
327 pretty_mask(const char *idmask
)
329 static char mask_buf
[BUFSIZE
];
331 char *nick
, *user
, *host
;
334 char ne
= 0, ue
= 0, he
= 0; /* save values at nick[NICKLEN], et all */
337 mask
= LOCAL_COPY(idmask
);
338 mask
= check_string(mask
);
341 nick
= user
= host
= splat
;
343 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
346 old_mask_pos
= mask_pos
;
350 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
351 t
= mask_buf
+ old_mask_pos
+ 1;
357 return mask_buf
+ old_mask_pos
;
361 if((t
= strchr(mask
, '@')) != NULL
)
368 if((t
= strchr(mask
, '!')) != NULL
)
383 else if((t
= strchr(mask
, '!')) != NULL
)
392 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
|| strchr(mask
, '/') != NULL
)
403 /* truncate values to max lengths */
404 if(strlen(nick
) > NICKLEN
- 1)
406 ne
= nick
[NICKLEN
- 1];
407 nick
[NICKLEN
- 1] = '\0';
409 if(strlen(user
) > USERLEN
)
412 user
[USERLEN
] = '\0';
414 if(strlen(host
) > HOSTLEN
)
417 host
[HOSTLEN
] = '\0';
420 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
422 /* restore mask, since we may need to use it again later */
428 nick
[NICKLEN
- 1] = ne
;
434 return mask_buf
+ old_mask_pos
;
440 * output - the same key, fixed
441 * side effects - anything below ascii 13 is discarded, ':' discarded,
442 * high ascii is dropped to lower half of ascii table
449 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
452 if(c
!= ':' && c
!= ',' && c
> ' ')
463 * ouput - the same key, fixed
464 * side effects - high ascii dropped to lower half of table,
465 * CR/LF/':' are dropped
468 fix_key_remote(char *arg
)
472 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
475 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
485 * The handlers for each specific mode.
488 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
489 int alevel
, int parc
, int *parn
,
490 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
492 if(*errors
& SM_ERR_UNKNOWN
)
494 *errors
|= SM_ERR_UNKNOWN
;
495 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
499 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
500 int alevel
, int parc
, int *parn
,
501 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
506 struct DictionaryIter iter
;
508 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
510 if (IsOverride(source_p
))
514 if(!(*errors
& SM_ERR_NOOPS
))
515 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
516 me
.name
, source_p
->name
, chptr
->chname
);
517 *errors
|= SM_ERR_NOOPS
;
522 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
526 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
528 /* if +f is disabled, ignore an attempt to set +QF locally */
529 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
530 (c
== 'Q' || c
== 'F'))
533 chptr
->mode
.mode
|= mode_type
;
535 mode_changes
[mode_count
].letter
= c
;
536 mode_changes
[mode_count
].dir
= MODE_ADD
;
537 mode_changes
[mode_count
].caps
= 0;
538 mode_changes
[mode_count
].nocaps
= 0;
539 mode_changes
[mode_count
].id
= NULL
;
540 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
541 mode_changes
[mode_count
].override
= override
;
542 mode_changes
[mode_count
++].arg
= NULL
;
544 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
546 /* cleanup metadata when the related mode is removed */
549 DICTIONARY_FOREACH(md
, &iter
, chptr
->metadata
)
551 if(!strcmp(md
->value
, "KICKNOREJOIN"))
552 channel_metadata_delete(chptr
, md
->name
, 0);
556 channel_metadata_delete(chptr
, "NOREPEAT", 0);
558 chptr
->mode
.mode
&= ~mode_type
;
560 mode_changes
[mode_count
].letter
= c
;
561 mode_changes
[mode_count
].dir
= MODE_DEL
;
562 mode_changes
[mode_count
].caps
= 0;
563 mode_changes
[mode_count
].nocaps
= 0;
564 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
565 mode_changes
[mode_count
].id
= NULL
;
566 mode_changes
[mode_count
].override
= override
;
567 mode_changes
[mode_count
++].arg
= NULL
;
572 chm_orphaned(struct Client
*source_p
, struct Channel
*chptr
,
573 int alevel
, int parc
, int *parn
,
574 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
576 if(MyClient(source_p
))
579 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
581 chptr
->mode
.mode
|= mode_type
;
583 mode_changes
[mode_count
].letter
= c
;
584 mode_changes
[mode_count
].dir
= MODE_ADD
;
585 mode_changes
[mode_count
].caps
= 0;
586 mode_changes
[mode_count
].nocaps
= 0;
587 mode_changes
[mode_count
].id
= NULL
;
588 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
589 mode_changes
[mode_count
++].arg
= NULL
;
591 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
593 chptr
->mode
.mode
&= ~mode_type
;
595 mode_changes
[mode_count
].letter
= c
;
596 mode_changes
[mode_count
].dir
= MODE_DEL
;
597 mode_changes
[mode_count
].caps
= 0;
598 mode_changes
[mode_count
].nocaps
= 0;
599 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
600 mode_changes
[mode_count
].id
= NULL
;
601 mode_changes
[mode_count
++].arg
= NULL
;
606 chm_hidden(struct Client
*source_p
, struct Channel
*chptr
,
607 int alevel
, int parc
, int *parn
,
608 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
610 if(!IsOper(source_p
) && !IsServer(source_p
))
612 if(!(*errors
& SM_ERR_NOPRIVS
))
613 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
614 *errors
|= SM_ERR_NOPRIVS
;
617 if(MyClient(source_p
) && !IsOperAdmin(source_p
))
619 if(!(*errors
& SM_ERR_NOPRIVS
))
620 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
621 source_p
->name
, "cmodes");
622 *errors
|= SM_ERR_NOPRIVS
;
626 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
630 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
632 chptr
->mode
.mode
|= mode_type
;
634 mode_changes
[mode_count
].letter
= c
;
635 mode_changes
[mode_count
].dir
= MODE_ADD
;
636 mode_changes
[mode_count
].caps
= 0;
637 mode_changes
[mode_count
].nocaps
= 0;
638 mode_changes
[mode_count
].id
= NULL
;
639 mode_changes
[mode_count
].mems
= ONLY_OPERS
;
640 mode_changes
[mode_count
].override
= 0;
641 mode_changes
[mode_count
++].arg
= NULL
;
643 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
645 chptr
->mode
.mode
&= ~mode_type
;
647 mode_changes
[mode_count
].letter
= c
;
648 mode_changes
[mode_count
].dir
= MODE_DEL
;
649 mode_changes
[mode_count
].caps
= 0;
650 mode_changes
[mode_count
].nocaps
= 0;
651 mode_changes
[mode_count
].mems
= ONLY_OPERS
;
652 mode_changes
[mode_count
].id
= NULL
;
653 mode_changes
[mode_count
].override
= 0;
654 mode_changes
[mode_count
++].arg
= NULL
;
659 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
660 int alevel
, int parc
, int *parn
,
661 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
663 if(!IsOper(source_p
) && !IsServer(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
) && !IsOperResv(source_p
))
672 if(!(*errors
& SM_ERR_NOPRIVS
))
673 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
674 source_p
->name
, "resv");
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
].caps
= 0;
690 mode_changes
[mode_count
].nocaps
= 0;
691 mode_changes
[mode_count
].id
= NULL
;
692 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
693 mode_changes
[mode_count
].override
= 0;
694 mode_changes
[mode_count
++].arg
= NULL
;
696 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
698 chptr
->mode
.mode
&= ~mode_type
;
700 mode_changes
[mode_count
].letter
= c
;
701 mode_changes
[mode_count
].dir
= MODE_DEL
;
702 mode_changes
[mode_count
].caps
= 0;
703 mode_changes
[mode_count
].nocaps
= 0;
704 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
705 mode_changes
[mode_count
].override
= 0;
706 mode_changes
[mode_count
].id
= NULL
;
707 mode_changes
[mode_count
++].arg
= NULL
;
712 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
713 int alevel
, int parc
, int *parn
,
714 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
717 const char *raw_mask
;
731 list
= &chptr
->banlist
;
732 errorval
= SM_ERR_RPL_B
;
733 rpl_list
= RPL_BANLIST
;
734 rpl_endlist
= RPL_ENDOFBANLIST
;
740 /* if +e is disabled, allow all but +e locally */
741 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
742 ((dir
== MODE_ADD
) && (parc
> *parn
)))
745 list
= &chptr
->exceptlist
;
746 errorval
= SM_ERR_RPL_E
;
747 rpl_list
= RPL_EXCEPTLIST
;
748 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
751 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
758 /* if +I is disabled, allow all but +I locally */
759 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
760 (dir
== MODE_ADD
) && (parc
> *parn
))
763 list
= &chptr
->invexlist
;
764 errorval
= SM_ERR_RPL_I
;
765 rpl_list
= RPL_INVITELIST
;
766 rpl_endlist
= RPL_ENDOFINVITELIST
;
769 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
776 list
= &chptr
->quietlist
;
777 errorval
= SM_ERR_RPL_Q
;
778 rpl_list
= RPL_BANLIST
;
779 rpl_endlist
= RPL_ENDOFBANLIST
;
785 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
790 if(dir
== 0 || parc
<= *parn
)
792 if((*errors
& errorval
) != 0)
796 /* non-ops cant see +eI lists.. */
797 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
&& mode_type
!= CHFL_BAN
&&
798 mode_type
!= CHFL_QUIET
)
800 if(IsOverride(source_p
))
802 sendto_wallops_flags(UMODE_WALLOP
, &me
,
803 "%s is overriding modes on %s: (%s list)",
804 get_oper_name(source_p
), chptr
->chname
, mode_type
== CHFL_INVEX
? "invex" : "exempt");
805 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
806 ":%s WALLOPS :%s is overriding modes on %s: (%s list)",
807 me
.name
, get_oper_name(source_p
), chptr
->chname
, mode_type
== CHFL_INVEX
? "invex" : "exempt");
812 if(!(*errors
& SM_ERR_NOOPS
))
813 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
814 me
.name
, source_p
->name
, chptr
->chname
);
815 *errors
|= SM_ERR_NOOPS
;
820 RB_DLINK_FOREACH(ptr
, list
->head
)
823 sendto_one(source_p
, form_str(rpl_list
),
824 me
.name
, source_p
->name
, chptr
->chname
,
825 banptr
->banstr
, banptr
->who
, banptr
->when
);
827 if (mode_type
== CHFL_QUIET
)
828 sendto_one(source_p
, ":%s %d %s %s :End of Channel Quiet List", me
.name
, rpl_endlist
, source_p
->name
, chptr
->chname
);
830 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
834 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
836 if(IsOverride(source_p
))
841 if(!(*errors
& SM_ERR_NOOPS
))
842 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
843 me
.name
, source_p
->name
, chptr
->chname
);
844 *errors
|= SM_ERR_NOOPS
;
849 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
852 raw_mask
= parv
[(*parn
)];
855 /* empty ban, or starts with ':' which messes up s2s, ignore it */
856 if(EmptyString(raw_mask
) || *raw_mask
== ':')
859 if(!MyClient(source_p
))
861 if(strchr(raw_mask
, ' '))
867 mask
= pretty_mask(raw_mask
);
869 /* we'd have problems parsing this, hyb6 does it too
870 * also make sure it will always fit on a line with channel
873 if(strlen(mask
) > IRCD_MIN(BANLEN
, MODEBUFLEN
- 5))
876 /* if we're adding a NEW id */
879 if (*mask
== '$' && MyClient(source_p
))
881 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
882 /* XXX perhaps return an error message here */
886 /* dont allow local clients to overflow the banlist, dont
887 * let remote servers set duplicate bans
889 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
892 mode_changes
[mode_count
].letter
= c
;
893 mode_changes
[mode_count
].dir
= MODE_ADD
;
894 mode_changes
[mode_count
].caps
= caps
;
895 mode_changes
[mode_count
].nocaps
= 0;
896 mode_changes
[mode_count
].mems
= mems
;
897 mode_changes
[mode_count
].id
= NULL
;
898 mode_changes
[mode_count
].override
= override
;
899 mode_changes
[mode_count
++].arg
= mask
;
901 else if(dir
== MODE_DEL
)
903 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
905 /* mask isn't a valid ban, check raw_mask */
906 if(del_id(chptr
, raw_mask
, list
, mode_type
))
910 mode_changes
[mode_count
].letter
= c
;
911 mode_changes
[mode_count
].dir
= MODE_DEL
;
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
;
922 chm_admin(struct Client
*source_p
, struct Channel
*chptr
,
923 int alevel
, int parc
, int *parn
,
924 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
926 struct membership
*mstptr
;
927 const char *adminnick
;
928 struct Client
*targ_p
;
931 if(!ConfigChannel
.use_admin
)
933 if(*errors
& SM_ERR_UNKNOWN
)
935 *errors
|= SM_ERR_UNKNOWN
;
936 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
940 if(alevel
!= CHFL_ADMIN
)
942 if(IsOverride(source_p
))
947 if(!(*errors
& SM_ERR_NOOPS
))
948 sendto_one(source_p
, ":%s 482 %s %s :You're not a channel administrator", me
.name
, source_p
->name
, chptr
->chname
);
949 *errors
|= SM_ERR_NOOPS
;
954 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
957 adminnick
= parv
[(*parn
)];
961 if(EmptyString(adminnick
))
963 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
967 if((targ_p
= find_chasing(source_p
, adminnick
, NULL
)) == NULL
)
972 mstptr
= find_channel_membership(chptr
, targ_p
);
976 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
977 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
978 form_str(ERR_USERNOTINCHANNEL
), adminnick
, chptr
->chname
);
979 *errors
|= SM_ERR_NOTONCHANNEL
;
983 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
988 if(targ_p
== source_p
)
990 no_override_deop
= 1;
991 /* Don't reject modes from remote. It desyncs, and this is perfectly
992 * legitimate from a remote override oper.
998 mode_changes
[mode_count
].letter
= c
;
999 mode_changes
[mode_count
].dir
= MODE_ADD
;
1000 mode_changes
[mode_count
].caps
= 0;
1001 mode_changes
[mode_count
].nocaps
= 0;
1002 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1003 mode_changes
[mode_count
].id
= targ_p
->id
;
1004 mode_changes
[mode_count
].arg
= targ_p
->name
;
1005 mode_changes
[mode_count
].override
= override
;
1006 mode_changes
[mode_count
++].client
= targ_p
;
1008 mstptr
->flags
|= CHFL_ADMIN
;
1012 if(MyClient(source_p
) && IsService(targ_p
))
1014 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1015 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1019 mode_changes
[mode_count
].letter
= c
;
1020 mode_changes
[mode_count
].dir
= MODE_DEL
;
1021 mode_changes
[mode_count
].caps
= 0;
1022 mode_changes
[mode_count
].nocaps
= 0;
1023 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1024 mode_changes
[mode_count
].id
= targ_p
->id
;
1025 mode_changes
[mode_count
].arg
= targ_p
->name
;
1026 mode_changes
[mode_count
].override
= override
;
1027 mode_changes
[mode_count
++].client
= targ_p
;
1029 mstptr
->flags
&= ~CHFL_ADMIN
;
1034 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
1035 int alevel
, int parc
, int *parn
,
1036 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1038 struct membership
*mstptr
;
1040 struct Client
*targ_p
;
1043 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
)
1045 if(IsOverride(source_p
))
1050 if(!(*errors
& SM_ERR_NOOPS
))
1051 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1052 me
.name
, source_p
->name
, chptr
->chname
);
1053 *errors
|= SM_ERR_NOOPS
;
1058 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
1061 opnick
= parv
[(*parn
)];
1065 if(EmptyString(opnick
))
1067 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1071 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
1076 mstptr
= find_channel_membership(chptr
, targ_p
);
1080 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1081 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1082 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
1083 *errors
|= SM_ERR_NOTONCHANNEL
;
1087 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1092 if(targ_p
== source_p
)
1094 no_override_deop
= 1;
1095 /* Don't reject modes from remote. It desyncs, and this is perfectly
1096 * legitimate from a remote override oper.
1102 mode_changes
[mode_count
].letter
= c
;
1103 mode_changes
[mode_count
].dir
= MODE_ADD
;
1104 mode_changes
[mode_count
].caps
= 0;
1105 mode_changes
[mode_count
].nocaps
= 0;
1106 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1107 mode_changes
[mode_count
].id
= targ_p
->id
;
1108 mode_changes
[mode_count
].arg
= targ_p
->name
;
1109 mode_changes
[mode_count
].override
= override
;
1110 mode_changes
[mode_count
++].client
= targ_p
;
1112 mstptr
->flags
|= CHFL_CHANOP
;
1116 if(MyClient(source_p
) && IsService(targ_p
))
1118 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1119 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1123 mode_changes
[mode_count
].letter
= c
;
1124 mode_changes
[mode_count
].dir
= MODE_DEL
;
1125 mode_changes
[mode_count
].caps
= 0;
1126 mode_changes
[mode_count
].nocaps
= 0;
1127 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1128 mode_changes
[mode_count
].id
= targ_p
->id
;
1129 mode_changes
[mode_count
].arg
= targ_p
->name
;
1130 mode_changes
[mode_count
].override
= override
;
1131 mode_changes
[mode_count
++].client
= targ_p
;
1133 mstptr
->flags
&= ~CHFL_CHANOP
;
1138 chm_halfop(struct Client
*source_p
, struct Channel
*chptr
,
1139 int alevel
, int parc
, int *parn
,
1140 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1142 struct membership
*mstptr
;
1143 const char *halfopnick
;
1144 struct Client
*targ_p
;
1147 if(!ConfigChannel
.use_halfop
)
1149 if(*errors
& SM_ERR_UNKNOWN
)
1151 *errors
|= SM_ERR_UNKNOWN
;
1152 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
1156 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
)
1158 if(IsOverride(source_p
))
1163 if(!(*errors
& SM_ERR_NOOPS
))
1164 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1165 me
.name
, source_p
->name
, chptr
->chname
);
1166 *errors
|= SM_ERR_NOOPS
;
1171 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
1174 halfopnick
= parv
[(*parn
)];
1178 if(EmptyString(halfopnick
))
1180 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1184 if((targ_p
= find_chasing(source_p
, halfopnick
, NULL
)) == NULL
)
1189 mstptr
= find_channel_membership(chptr
, targ_p
);
1193 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1194 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1195 form_str(ERR_USERNOTINCHANNEL
), halfopnick
, chptr
->chname
);
1196 *errors
|= SM_ERR_NOTONCHANNEL
;
1200 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1205 if(targ_p
== source_p
)
1207 no_override_deop
= 1;
1208 /* Don't reject modes from remote. It desyncs, and this is perfectly
1209 * legitimate from a remote override oper.
1215 mode_changes
[mode_count
].letter
= c
;
1216 mode_changes
[mode_count
].dir
= MODE_ADD
;
1217 mode_changes
[mode_count
].caps
= 0;
1218 mode_changes
[mode_count
].nocaps
= 0;
1219 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1220 mode_changes
[mode_count
].id
= targ_p
->id
;
1221 mode_changes
[mode_count
].arg
= targ_p
->name
;
1222 mode_changes
[mode_count
].override
= override
;
1223 mode_changes
[mode_count
++].client
= targ_p
;
1225 mstptr
->flags
|= CHFL_HALFOP
;
1229 if(MyClient(source_p
) && IsService(targ_p
))
1231 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
1232 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
1236 mode_changes
[mode_count
].letter
= c
;
1237 mode_changes
[mode_count
].dir
= MODE_DEL
;
1238 mode_changes
[mode_count
].caps
= 0;
1239 mode_changes
[mode_count
].nocaps
= 0;
1240 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1241 mode_changes
[mode_count
].id
= targ_p
->id
;
1242 mode_changes
[mode_count
].arg
= targ_p
->name
;
1243 mode_changes
[mode_count
].override
= override
;
1244 mode_changes
[mode_count
++].client
= targ_p
;
1246 mstptr
->flags
&= ~CHFL_HALFOP
;
1251 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
1252 int alevel
, int parc
, int *parn
,
1253 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1255 struct membership
*mstptr
;
1257 struct Client
*targ_p
;
1260 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1262 if(IsOverride(source_p
))
1267 if(!(*errors
& SM_ERR_NOOPS
))
1268 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1269 me
.name
, source_p
->name
, chptr
->chname
);
1270 *errors
|= SM_ERR_NOOPS
;
1275 if((dir
== MODE_QUERY
) || parc
<= *parn
)
1278 opnick
= parv
[(*parn
)];
1282 if(EmptyString(opnick
))
1284 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
1288 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
1293 mstptr
= find_channel_membership(chptr
, targ_p
);
1297 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
1298 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
1299 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
1300 *errors
|= SM_ERR_NOTONCHANNEL
;
1304 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
1309 mode_changes
[mode_count
].letter
= c
;
1310 mode_changes
[mode_count
].dir
= MODE_ADD
;
1311 mode_changes
[mode_count
].caps
= 0;
1312 mode_changes
[mode_count
].nocaps
= 0;
1313 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1314 mode_changes
[mode_count
].id
= targ_p
->id
;
1315 mode_changes
[mode_count
].arg
= targ_p
->name
;
1316 mode_changes
[mode_count
].override
= override
;
1317 mode_changes
[mode_count
++].client
= targ_p
;
1319 mstptr
->flags
|= CHFL_VOICE
;
1323 mode_changes
[mode_count
].letter
= 'v';
1324 mode_changes
[mode_count
].dir
= MODE_DEL
;
1325 mode_changes
[mode_count
].caps
= 0;
1326 mode_changes
[mode_count
].nocaps
= 0;
1327 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1328 mode_changes
[mode_count
].id
= targ_p
->id
;
1329 mode_changes
[mode_count
].arg
= targ_p
->name
;
1330 mode_changes
[mode_count
].override
= override
;
1331 mode_changes
[mode_count
++].client
= targ_p
;
1333 mstptr
->flags
&= ~CHFL_VOICE
;
1338 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
1339 int alevel
, int parc
, int *parn
,
1340 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1343 static char limitstr
[30];
1347 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1349 if(IsOverride(source_p
))
1353 if(!(*errors
& SM_ERR_NOOPS
))
1354 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1355 me
.name
, source_p
->name
, chptr
->chname
);
1356 *errors
|= SM_ERR_NOOPS
;
1361 if(dir
== MODE_QUERY
)
1364 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1367 if((dir
== MODE_ADD
) && parc
> *parn
)
1369 lstr
= parv
[(*parn
)];
1372 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
1375 rb_sprintf(limitstr
, "%d", limit
);
1377 mode_changes
[mode_count
].letter
= c
;
1378 mode_changes
[mode_count
].dir
= MODE_ADD
;
1379 mode_changes
[mode_count
].caps
= 0;
1380 mode_changes
[mode_count
].nocaps
= 0;
1381 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1382 mode_changes
[mode_count
].id
= NULL
;
1383 mode_changes
[mode_count
].override
= override
;
1384 mode_changes
[mode_count
++].arg
= limitstr
;
1386 chptr
->mode
.limit
= limit
;
1388 else if(dir
== MODE_DEL
)
1390 if(!chptr
->mode
.limit
)
1393 chptr
->mode
.limit
= 0;
1395 mode_changes
[mode_count
].letter
= c
;
1396 mode_changes
[mode_count
].dir
= MODE_DEL
;
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
= NULL
;
1407 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
1408 int alevel
, int parc
, int *parn
,
1409 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1411 int joins
= 0, timeslice
= 0;
1414 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1416 if(IsOverride(source_p
))
1421 if(!(*errors
& SM_ERR_NOOPS
))
1422 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1423 me
.name
, source_p
->name
, chptr
->chname
);
1424 *errors
|= SM_ERR_NOOPS
;
1429 if(dir
== MODE_QUERY
)
1432 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1435 if((dir
== MODE_ADD
) && parc
> *parn
)
1437 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
1439 if(!joins
|| !timeslice
)
1442 mode_changes
[mode_count
].letter
= c
;
1443 mode_changes
[mode_count
].dir
= MODE_ADD
;
1444 mode_changes
[mode_count
].caps
= 0;
1445 mode_changes
[mode_count
].nocaps
= 0;
1446 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1447 mode_changes
[mode_count
].id
= NULL
;
1448 mode_changes
[mode_count
].override
= override
;
1449 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
1453 chptr
->mode
.join_num
= joins
;
1454 chptr
->mode
.join_time
= timeslice
;
1456 else if(dir
== MODE_DEL
)
1458 if(!chptr
->mode
.join_num
)
1461 chptr
->mode
.join_num
= 0;
1462 chptr
->mode
.join_time
= 0;
1463 chptr
->join_count
= 0;
1464 chptr
->join_delta
= 0;
1466 mode_changes
[mode_count
].letter
= c
;
1467 mode_changes
[mode_count
].dir
= MODE_DEL
;
1468 mode_changes
[mode_count
].caps
= 0;
1469 mode_changes
[mode_count
].nocaps
= 0;
1470 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1471 mode_changes
[mode_count
].id
= NULL
;
1472 mode_changes
[mode_count
].override
= override
;
1473 mode_changes
[mode_count
++].arg
= NULL
;
1478 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
1479 int alevel
, int parc
, int *parn
,
1480 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1482 struct Channel
*targptr
= NULL
;
1483 struct membership
*msptr
;
1484 const char *forward
;
1487 /* if +f is disabled, ignore local attempts to set it */
1488 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
1489 (dir
== MODE_ADD
) && (parc
> *parn
))
1492 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
1494 if (!(*errors
& SM_ERR_RPL_F
))
1496 if (*chptr
->mode
.forward
== '\0')
1497 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
1499 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
1500 *errors
|= SM_ERR_RPL_F
;
1505 #ifndef FORWARD_OPERONLY
1506 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1508 if(IsOverride(source_p
))
1512 if(!(*errors
& SM_ERR_NOOPS
))
1513 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1514 me
.name
, source_p
->name
, chptr
->chname
);
1515 *errors
|= SM_ERR_NOOPS
;
1520 if(!IsOper(source_p
) && !IsServer(source_p
))
1522 if(!(*errors
& SM_ERR_NOPRIVS
))
1523 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
1524 *errors
|= SM_ERR_NOPRIVS
;
1529 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1532 if(dir
== MODE_ADD
&& parc
> *parn
)
1534 forward
= parv
[(*parn
)];
1537 if(EmptyString(forward
))
1539 if(!check_channel_name(forward
) ||
1540 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1542 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1545 /* don't forward to inconsistent target -- jilles */
1546 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
1548 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
1549 form_str(ERR_BADCHANNAME
), forward
);
1552 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1554 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1555 form_str(ERR_NOSUCHCHANNEL
), forward
);
1558 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1560 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1563 if(IsOverride(source_p
))
1567 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1568 me
.name
, source_p
->name
, targptr
->chname
);
1574 rb_strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1576 mode_changes
[mode_count
].letter
= c
;
1577 mode_changes
[mode_count
].dir
= MODE_ADD
;
1578 mode_changes
[mode_count
].caps
= 0;
1579 mode_changes
[mode_count
].nocaps
= 0;
1580 mode_changes
[mode_count
].mems
= ConfigChannel
.use_forward
? ALL_MEMBERS
: ONLY_SERVERS
;
1581 mode_changes
[mode_count
].id
= NULL
;
1582 mode_changes
[mode_count
].override
= override
;
1583 mode_changes
[mode_count
++].arg
= forward
;
1585 else if(dir
== MODE_DEL
)
1587 if(!(*chptr
->mode
.forward
))
1590 *chptr
->mode
.forward
= '\0';
1592 mode_changes
[mode_count
].letter
= c
;
1593 mode_changes
[mode_count
].dir
= MODE_DEL
;
1594 mode_changes
[mode_count
].caps
= 0;
1595 mode_changes
[mode_count
].nocaps
= 0;
1596 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1597 mode_changes
[mode_count
].id
= NULL
;
1598 mode_changes
[mode_count
].override
= override
;
1599 mode_changes
[mode_count
++].arg
= NULL
;
1604 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1605 int alevel
, int parc
, int *parn
,
1606 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1611 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1613 if(IsOverride(source_p
))
1617 if(!(*errors
& SM_ERR_NOOPS
))
1618 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1619 me
.name
, source_p
->name
, chptr
->chname
);
1620 *errors
|= SM_ERR_NOOPS
;
1625 if(dir
== MODE_QUERY
)
1628 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1631 if((dir
== MODE_ADD
) && parc
> *parn
)
1633 key
= LOCAL_COPY(parv
[(*parn
)]);
1636 if(MyClient(source_p
))
1639 fix_key_remote(key
);
1641 if(EmptyString(key
))
1644 s_assert(key
[0] != ' ');
1645 rb_strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1647 mode_changes
[mode_count
].letter
= c
;
1648 mode_changes
[mode_count
].dir
= MODE_ADD
;
1649 mode_changes
[mode_count
].caps
= 0;
1650 mode_changes
[mode_count
].nocaps
= 0;
1651 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1652 mode_changes
[mode_count
].id
= NULL
;
1653 mode_changes
[mode_count
].override
= override
;
1654 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1656 else if(dir
== MODE_DEL
)
1658 static char splat
[] = "*";
1664 if(!(*chptr
->mode
.key
))
1667 /* hack time. when we get a +k-k mode, the +k arg is
1668 * chptr->mode.key, which the -k sets to \0, so hunt for a
1669 * +k when we get a -k, and set the arg to splat. --anfl
1671 for(i
= 0; i
< mode_count
; i
++)
1673 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1674 mode_changes
[i
].arg
= splat
;
1677 *chptr
->mode
.key
= 0;
1679 mode_changes
[mode_count
].letter
= c
;
1680 mode_changes
[mode_count
].dir
= MODE_DEL
;
1681 mode_changes
[mode_count
].caps
= 0;
1682 mode_changes
[mode_count
].nocaps
= 0;
1683 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1684 mode_changes
[mode_count
].id
= NULL
;
1685 mode_changes
[mode_count
].override
= override
;
1686 mode_changes
[mode_count
++].arg
= "*";
1691 chm_regonly(struct Client
*source_p
, struct Channel
*chptr
,
1692 int alevel
, int parc
, int *parn
,
1693 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1697 if(alevel
!= CHFL_CHANOP
&& alevel
!= CHFL_ADMIN
&& alevel
!= CHFL_HALFOP
)
1699 if(IsOverride(source_p
))
1703 if(!(*errors
& SM_ERR_NOOPS
))
1704 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1705 me
.name
, source_p
->name
, chptr
->chname
);
1706 *errors
|= SM_ERR_NOOPS
;
1711 if(dir
== MODE_QUERY
)
1714 if(((dir
== MODE_ADD
) && (chptr
->mode
.mode
& mode_type
)) ||
1715 ((dir
== MODE_DEL
) && !(chptr
->mode
.mode
& mode_type
)))
1718 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1722 chptr
->mode
.mode
|= mode_type
;
1724 chptr
->mode
.mode
&= ~mode_type
;
1726 mode_changes
[mode_count
].letter
= c
;
1727 mode_changes
[mode_count
].dir
= dir
;
1728 mode_changes
[mode_count
].caps
= CAP_SERVICE
;
1729 mode_changes
[mode_count
].nocaps
= 0;
1730 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1731 mode_changes
[mode_count
].id
= NULL
;
1732 mode_changes
[mode_count
].override
= override
;
1733 mode_changes
[mode_count
++].arg
= NULL
;
1737 struct ChannelMode chmode_table
[256] =
1739 {chm_nosuch
, 0 }, /* 0x00 */
1740 {chm_nosuch
, 0 }, /* 0x01 */
1741 {chm_nosuch
, 0 }, /* 0x02 */
1742 {chm_nosuch
, 0 }, /* 0x03 */
1743 {chm_nosuch
, 0 }, /* 0x04 */
1744 {chm_nosuch
, 0 }, /* 0x05 */
1745 {chm_nosuch
, 0 }, /* 0x06 */
1746 {chm_nosuch
, 0 }, /* 0x07 */
1747 {chm_nosuch
, 0 }, /* 0x08 */
1748 {chm_nosuch
, 0 }, /* 0x09 */
1749 {chm_nosuch
, 0 }, /* 0x0a */
1750 {chm_nosuch
, 0 }, /* 0x0b */
1751 {chm_nosuch
, 0 }, /* 0x0c */
1752 {chm_nosuch
, 0 }, /* 0x0d */
1753 {chm_nosuch
, 0 }, /* 0x0e */
1754 {chm_nosuch
, 0 }, /* 0x0f */
1755 {chm_nosuch
, 0 }, /* 0x10 */
1756 {chm_nosuch
, 0 }, /* 0x11 */
1757 {chm_nosuch
, 0 }, /* 0x12 */
1758 {chm_nosuch
, 0 }, /* 0x13 */
1759 {chm_nosuch
, 0 }, /* 0x14 */
1760 {chm_nosuch
, 0 }, /* 0x15 */
1761 {chm_nosuch
, 0 }, /* 0x16 */
1762 {chm_nosuch
, 0 }, /* 0x17 */
1763 {chm_nosuch
, 0 }, /* 0x18 */
1764 {chm_nosuch
, 0 }, /* 0x19 */
1765 {chm_nosuch
, 0 }, /* 0x1a */
1766 {chm_nosuch
, 0 }, /* 0x1b */
1767 {chm_nosuch
, 0 }, /* 0x1c */
1768 {chm_nosuch
, 0 }, /* 0x1d */
1769 {chm_nosuch
, 0 }, /* 0x1e */
1770 {chm_nosuch
, 0 }, /* 0x1f */
1771 {chm_nosuch
, 0 }, /* 0x20 */
1772 {chm_nosuch
, 0 }, /* 0x21 */
1773 {chm_nosuch
, 0 }, /* 0x22 */
1774 {chm_nosuch
, 0 }, /* 0x23 */
1775 {chm_nosuch
, 0 }, /* 0x24 */
1776 {chm_nosuch
, 0 }, /* 0x25 */
1777 {chm_nosuch
, 0 }, /* 0x26 */
1778 {chm_nosuch
, 0 }, /* 0x27 */
1779 {chm_nosuch
, 0 }, /* 0x28 */
1780 {chm_nosuch
, 0 }, /* 0x29 */
1781 {chm_nosuch
, 0 }, /* 0x2a */
1782 {chm_nosuch
, 0 }, /* 0x2b */
1783 {chm_nosuch
, 0 }, /* 0x2c */
1784 {chm_nosuch
, 0 }, /* 0x2d */
1785 {chm_nosuch
, 0 }, /* 0x2e */
1786 {chm_nosuch
, 0 }, /* 0x2f */
1787 {chm_nosuch
, 0 }, /* 0x30 */
1788 {chm_nosuch
, 0 }, /* 0x31 */
1789 {chm_nosuch
, 0 }, /* 0x32 */
1790 {chm_nosuch
, 0 }, /* 0x33 */
1791 {chm_nosuch
, 0 }, /* 0x34 */
1792 {chm_nosuch
, 0 }, /* 0x35 */
1793 {chm_nosuch
, 0 }, /* 0x36 */
1794 {chm_nosuch
, 0 }, /* 0x37 */
1795 {chm_nosuch
, 0 }, /* 0x38 */
1796 {chm_nosuch
, 0 }, /* 0x39 */
1797 {chm_nosuch
, 0 }, /* 0x3a */
1798 {chm_nosuch
, 0 }, /* 0x3b */
1799 {chm_nosuch
, 0 }, /* 0x3c */
1800 {chm_nosuch
, 0 }, /* 0x3d */
1801 {chm_nosuch
, 0 }, /* 0x3e */
1802 {chm_nosuch
, 0 }, /* 0x3f */
1804 {chm_nosuch
, 0 }, /* @ */
1805 {chm_nosuch
, 0 }, /* A */
1806 {chm_nosuch
, 0 }, /* B */
1807 {chm_simple
, MODE_NOCTCP
}, /* C */
1808 {chm_simple
, MODE_NOACTION
}, /* D */
1809 {chm_simple
, MODE_NOKICK
}, /* E */
1810 {chm_simple
, MODE_FREETARGET
}, /* F */
1811 {chm_simple
, MODE_NOCAPS
}, /* G */
1812 {chm_nosuch
, 0 }, /* H */
1813 {chm_ban
, CHFL_INVEX
}, /* I */
1814 {chm_simple
, MODE_NOREJOIN
}, /* J */
1815 {chm_simple
, MODE_NOREPEAT
}, /* K */
1816 {chm_staff
, MODE_EXLIMIT
}, /* L */
1817 {chm_hidden
, MODE_NOOPERKICK
}, /* M */
1818 {chm_simple
, MODE_NONICK
}, /* N */
1819 {chm_nosuch
, 0 }, /* O */
1820 {chm_staff
, MODE_PERMANENT
}, /* P */
1821 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1822 {chm_nosuch
, 0 }, /* R */
1823 {chm_nosuch
, 0 }, /* S */
1824 {chm_simple
, MODE_NONOTICE
}, /* T */
1825 {chm_nosuch
, 0 }, /* U */
1826 {chm_nosuch
, 0 }, /* V */
1827 {chm_nosuch
, 0 }, /* W */
1828 {chm_nosuch
, 0 }, /* X */
1829 {chm_nosuch
, 0 }, /* Y */
1830 {chm_nosuch
, 0 }, /* Z */
1837 {chm_admin
, 0 }, /* a */
1838 {chm_ban
, CHFL_BAN
}, /* b */
1839 {chm_simple
, MODE_NOCOLOR
}, /* c */
1840 {chm_nosuch
, 0 }, /* d */
1841 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1842 {chm_forward
, 0 }, /* f */
1843 {chm_simple
, MODE_FREEINVITE
}, /* g */
1844 {chm_halfop
, 0 }, /* h */
1845 {chm_simple
, MODE_INVITEONLY
}, /* i */
1846 {chm_throttle
, 0 }, /* j */
1847 {chm_key
, 0 }, /* k */
1848 {chm_limit
, 0 }, /* l */
1849 {chm_simple
, MODE_MODERATED
}, /* m */
1850 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1851 {chm_op
, 0 }, /* o */
1852 {chm_simple
, MODE_PRIVATE
}, /* p */
1853 {chm_ban
, CHFL_QUIET
}, /* q */
1854 {chm_regonly
, MODE_REGONLY
}, /* r */
1855 {chm_simple
, MODE_SECRET
}, /* s */
1856 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1857 {chm_nosuch
, 0 }, /* u */
1858 {chm_voice
, 0 }, /* v */
1859 {chm_nosuch
, 0 }, /* w */
1860 {chm_nosuch
, 0 }, /* x */
1861 {chm_nosuch
, 0 }, /* y */
1862 {chm_simple
, MODE_OPMODERATE
}, /* z */
1864 {chm_nosuch
, 0 }, /* 0x7b */
1865 {chm_nosuch
, 0 }, /* 0x7c */
1866 {chm_nosuch
, 0 }, /* 0x7d */
1867 {chm_nosuch
, 0 }, /* 0x7e */
1868 {chm_nosuch
, 0 }, /* 0x7f */
1870 {chm_nosuch
, 0 }, /* 0x80 */
1871 {chm_nosuch
, 0 }, /* 0x81 */
1872 {chm_nosuch
, 0 }, /* 0x82 */
1873 {chm_nosuch
, 0 }, /* 0x83 */
1874 {chm_nosuch
, 0 }, /* 0x84 */
1875 {chm_nosuch
, 0 }, /* 0x85 */
1876 {chm_nosuch
, 0 }, /* 0x86 */
1877 {chm_nosuch
, 0 }, /* 0x87 */
1878 {chm_nosuch
, 0 }, /* 0x88 */
1879 {chm_nosuch
, 0 }, /* 0x89 */
1880 {chm_nosuch
, 0 }, /* 0x8a */
1881 {chm_nosuch
, 0 }, /* 0x8b */
1882 {chm_nosuch
, 0 }, /* 0x8c */
1883 {chm_nosuch
, 0 }, /* 0x8d */
1884 {chm_nosuch
, 0 }, /* 0x8e */
1885 {chm_nosuch
, 0 }, /* 0x8f */
1887 {chm_nosuch
, 0 }, /* 0x90 */
1888 {chm_nosuch
, 0 }, /* 0x91 */
1889 {chm_nosuch
, 0 }, /* 0x92 */
1890 {chm_nosuch
, 0 }, /* 0x93 */
1891 {chm_nosuch
, 0 }, /* 0x94 */
1892 {chm_nosuch
, 0 }, /* 0x95 */
1893 {chm_nosuch
, 0 }, /* 0x96 */
1894 {chm_nosuch
, 0 }, /* 0x97 */
1895 {chm_nosuch
, 0 }, /* 0x98 */
1896 {chm_nosuch
, 0 }, /* 0x99 */
1897 {chm_nosuch
, 0 }, /* 0x9a */
1898 {chm_nosuch
, 0 }, /* 0x9b */
1899 {chm_nosuch
, 0 }, /* 0x9c */
1900 {chm_nosuch
, 0 }, /* 0x9d */
1901 {chm_nosuch
, 0 }, /* 0x9e */
1902 {chm_nosuch
, 0 }, /* 0x9f */
1904 {chm_nosuch
, 0 }, /* 0xa0 */
1905 {chm_nosuch
, 0 }, /* 0xa1 */
1906 {chm_nosuch
, 0 }, /* 0xa2 */
1907 {chm_nosuch
, 0 }, /* 0xa3 */
1908 {chm_nosuch
, 0 }, /* 0xa4 */
1909 {chm_nosuch
, 0 }, /* 0xa5 */
1910 {chm_nosuch
, 0 }, /* 0xa6 */
1911 {chm_nosuch
, 0 }, /* 0xa7 */
1912 {chm_nosuch
, 0 }, /* 0xa8 */
1913 {chm_nosuch
, 0 }, /* 0xa9 */
1914 {chm_nosuch
, 0 }, /* 0xaa */
1915 {chm_nosuch
, 0 }, /* 0xab */
1916 {chm_nosuch
, 0 }, /* 0xac */
1917 {chm_nosuch
, 0 }, /* 0xad */
1918 {chm_nosuch
, 0 }, /* 0xae */
1919 {chm_nosuch
, 0 }, /* 0xaf */
1921 {chm_nosuch
, 0 }, /* 0xb0 */
1922 {chm_nosuch
, 0 }, /* 0xb1 */
1923 {chm_nosuch
, 0 }, /* 0xb2 */
1924 {chm_nosuch
, 0 }, /* 0xb3 */
1925 {chm_nosuch
, 0 }, /* 0xb4 */
1926 {chm_nosuch
, 0 }, /* 0xb5 */
1927 {chm_nosuch
, 0 }, /* 0xb6 */
1928 {chm_nosuch
, 0 }, /* 0xb7 */
1929 {chm_nosuch
, 0 }, /* 0xb8 */
1930 {chm_nosuch
, 0 }, /* 0xb9 */
1931 {chm_nosuch
, 0 }, /* 0xba */
1932 {chm_nosuch
, 0 }, /* 0xbb */
1933 {chm_nosuch
, 0 }, /* 0xbc */
1934 {chm_nosuch
, 0 }, /* 0xbd */
1935 {chm_nosuch
, 0 }, /* 0xbe */
1936 {chm_nosuch
, 0 }, /* 0xbf */
1938 {chm_nosuch
, 0 }, /* 0xc0 */
1939 {chm_nosuch
, 0 }, /* 0xc1 */
1940 {chm_nosuch
, 0 }, /* 0xc2 */
1941 {chm_nosuch
, 0 }, /* 0xc3 */
1942 {chm_nosuch
, 0 }, /* 0xc4 */
1943 {chm_nosuch
, 0 }, /* 0xc5 */
1944 {chm_nosuch
, 0 }, /* 0xc6 */
1945 {chm_nosuch
, 0 }, /* 0xc7 */
1946 {chm_nosuch
, 0 }, /* 0xc8 */
1947 {chm_nosuch
, 0 }, /* 0xc9 */
1948 {chm_nosuch
, 0 }, /* 0xca */
1949 {chm_nosuch
, 0 }, /* 0xcb */
1950 {chm_nosuch
, 0 }, /* 0xcc */
1951 {chm_nosuch
, 0 }, /* 0xcd */
1952 {chm_nosuch
, 0 }, /* 0xce */
1953 {chm_nosuch
, 0 }, /* 0xcf */
1955 {chm_nosuch
, 0 }, /* 0xd0 */
1956 {chm_nosuch
, 0 }, /* 0xd1 */
1957 {chm_nosuch
, 0 }, /* 0xd2 */
1958 {chm_nosuch
, 0 }, /* 0xd3 */
1959 {chm_nosuch
, 0 }, /* 0xd4 */
1960 {chm_nosuch
, 0 }, /* 0xd5 */
1961 {chm_nosuch
, 0 }, /* 0xd6 */
1962 {chm_nosuch
, 0 }, /* 0xd7 */
1963 {chm_nosuch
, 0 }, /* 0xd8 */
1964 {chm_nosuch
, 0 }, /* 0xd9 */
1965 {chm_nosuch
, 0 }, /* 0xda */
1966 {chm_nosuch
, 0 }, /* 0xdb */
1967 {chm_nosuch
, 0 }, /* 0xdc */
1968 {chm_nosuch
, 0 }, /* 0xdd */
1969 {chm_nosuch
, 0 }, /* 0xde */
1970 {chm_nosuch
, 0 }, /* 0xdf */
1972 {chm_nosuch
, 0 }, /* 0xe0 */
1973 {chm_nosuch
, 0 }, /* 0xe1 */
1974 {chm_nosuch
, 0 }, /* 0xe2 */
1975 {chm_nosuch
, 0 }, /* 0xe3 */
1976 {chm_nosuch
, 0 }, /* 0xe4 */
1977 {chm_nosuch
, 0 }, /* 0xe5 */
1978 {chm_nosuch
, 0 }, /* 0xe6 */
1979 {chm_nosuch
, 0 }, /* 0xe7 */
1980 {chm_nosuch
, 0 }, /* 0xe8 */
1981 {chm_nosuch
, 0 }, /* 0xe9 */
1982 {chm_nosuch
, 0 }, /* 0xea */
1983 {chm_nosuch
, 0 }, /* 0xeb */
1984 {chm_nosuch
, 0 }, /* 0xec */
1985 {chm_nosuch
, 0 }, /* 0xed */
1986 {chm_nosuch
, 0 }, /* 0xee */
1987 {chm_nosuch
, 0 }, /* 0xef */
1989 {chm_nosuch
, 0 }, /* 0xf0 */
1990 {chm_nosuch
, 0 }, /* 0xf1 */
1991 {chm_nosuch
, 0 }, /* 0xf2 */
1992 {chm_nosuch
, 0 }, /* 0xf3 */
1993 {chm_nosuch
, 0 }, /* 0xf4 */
1994 {chm_nosuch
, 0 }, /* 0xf5 */
1995 {chm_nosuch
, 0 }, /* 0xf6 */
1996 {chm_nosuch
, 0 }, /* 0xf7 */
1997 {chm_nosuch
, 0 }, /* 0xf8 */
1998 {chm_nosuch
, 0 }, /* 0xf9 */
1999 {chm_nosuch
, 0 }, /* 0xfa */
2000 {chm_nosuch
, 0 }, /* 0xfb */
2001 {chm_nosuch
, 0 }, /* 0xfc */
2002 {chm_nosuch
, 0 }, /* 0xfd */
2003 {chm_nosuch
, 0 }, /* 0xfe */
2004 {chm_nosuch
, 0 }, /* 0xff */
2009 /* set_channel_mode()
2011 * inputs - client, source, channel, membership pointer, params
2013 * side effects - channel modes/memberships are changed, MODE is issued
2015 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
2018 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
2019 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
2021 static char cmdbuf
[BUFSIZE
];
2022 static char modebuf
[BUFSIZE
];
2023 static char parabuf
[BUFSIZE
];
2026 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
2027 int i
, j
, flags
, override
;
2032 const char *ml
= parv
[0];
2034 struct Client
*fakesource_p
;
2035 int flags_list
[3] = { ALL_MEMBERS
, ONLY_CHANOPS
, ONLY_OPERS
};
2040 mode_limit_simple
= 0;
2042 alevel
= get_channel_access(source_p
, msptr
);
2044 no_override_deop
= 0;
2046 /* Hide connecting server on netburst -- jilles */
2047 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
2050 fakesource_p
= source_p
;
2052 for(; (c
= *ml
) != 0; ml
++)
2066 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
2069 chmode_table
[(unsigned char) c
].mode_type
);
2074 /* bail out if we have nothing to do... */
2078 if(IsServer(source_p
))
2079 rb_sprintf(cmdbuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
2081 rb_sprintf(cmdbuf
, ":%s!%s@%s MODE %s ",
2082 source_p
->name
, source_p
->username
,
2083 source_p
->host
, chptr
->chname
);
2087 for (override
= 0; override
< (IsOverride(source_p
) && alevel
!= CHFL_CHANOP
? 2 : 1); ++override
)
2089 int was_on_chan
= 0;
2096 msptr
->flags
|= CHFL_CHANOP
;
2099 add_user_to_channel(chptr
, source_p
, CHFL_CHANOP
);
2102 for(j
= 0, flags
= flags_list
[0]; j
< 3; j
++, flags
= flags_list
[j
])
2105 mbuf
= modebuf
+ mlen
;
2108 paracount
= paralen
= 0;
2111 for(i
= 0; i
< mode_count
; i
++)
2113 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
2116 if(mode_changes
[i
].override
!= override
)
2119 if(mode_changes
[i
].arg
!= NULL
)
2121 arglen
= strlen(mode_changes
[i
].arg
);
2123 if(arglen
> MODEBUFLEN
- 5)
2129 /* if we're creeping over MAXMODEPARAMSSERV, or over
2130 * bufsize (4 == +/-,modechar,two spaces) send now.
2132 if(mode_changes
[i
].arg
!= NULL
&&
2133 ((paracount
== MAXMODEPARAMSSERV
) ||
2134 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
2140 sendto_channel_local(flags
, chptr
, "%s%s %s",
2141 cmdbuf
, modebuf
, parabuf
);
2144 sendto_wallops_flags(UMODE_WALLOP
, &me
,
2145 "%s is overriding modes on %s: %s %s",
2146 get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2147 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
2148 ":%s WALLOPS :%s is overriding modes on %s: %s %s",
2149 me
.name
, get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2155 paracount
= paralen
= 0;
2157 mbuf
= modebuf
+ mlen
;
2163 if(dir
!= mode_changes
[i
].dir
)
2165 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
2167 dir
= mode_changes
[i
].dir
;
2170 *mbuf
++ = mode_changes
[i
].letter
;
2173 if(mode_changes
[i
].arg
!= NULL
)
2176 len
= rb_sprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
2182 if(paralen
&& parabuf
[paralen
- 1] == ' ')
2183 parabuf
[paralen
- 1] = '\0';
2188 sendto_channel_local(flags
, chptr
, "%s%s %s", cmdbuf
, modebuf
, parabuf
);
2191 sendto_wallops_flags(UMODE_WALLOP
, &me
,
2192 "%s is overriding modes on %s: %s %s",
2193 get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2194 sendto_server(NULL
, chptr
, NOCAPS
, NOCAPS
,
2195 ":%s WALLOPS :%s is overriding modes on %s: %s %s",
2196 me
.name
, get_oper_name(source_p
), chptr
->chname
, modebuf
, parabuf
);
2203 remove_user_from_channel(find_channel_membership(chptr
, source_p
));
2204 else if (!no_override_deop
)
2205 msptr
->flags
&= ~CHFL_CHANOP
;
2209 /* only propagate modes originating locally, or if we're hubbing */
2210 if(MyClient(source_p
) || rb_dlink_list_length(&serv_list
) > 1)
2211 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);