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"
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
;
68 static int orphaned_cflags
= 0;
70 int chmode_flags
[256];
72 find_orphaned_cflags(void)
75 static int prev_chmode_flags
[256];
77 for (i
= 0; i
< 256; i
++)
79 if (prev_chmode_flags
[i
] != 0 && prev_chmode_flags
[i
] != chmode_flags
[i
])
81 if (chmode_flags
[i
] == 0)
83 orphaned_cflags
|= prev_chmode_flags
[i
];
84 sendto_realops_snomask(SNO_DEBUG
, L_ALL
, "Cmode +%c is now orphaned", i
);
88 orphaned_cflags
&= ~prev_chmode_flags
[i
];
89 sendto_realops_snomask(SNO_DEBUG
, L_ALL
, "Orphaned cmode +%c is picked up by module", i
);
91 chmode_flags
[i
] = prev_chmode_flags
[i
];
94 prev_chmode_flags
[i
] = chmode_flags
[i
];
99 construct_noparam_modes(void)
103 for(i
= 0; i
< 256; i
++)
105 if( (chmode_table
[i
].set_func
== chm_simple
) ||
106 (chmode_table
[i
].set_func
== chm_staff
) ||
107 (chmode_table
[i
].set_func
== chm_regonly
))
109 chmode_flags
[i
] = chmode_table
[i
].mode_type
;
117 find_orphaned_cflags();
124 * outputs - an available cflag bitmask or
125 * 0 if no cflags are available
126 * side effects - NONE
129 find_cflag_slot(void)
131 unsigned int all_cflags
= 0, my_cflag
= 0, i
;
133 for (i
= 0; i
< 256; i
++)
134 all_cflags
|= chmode_flags
[i
];
136 for (my_cflag
= 1; my_cflag
&& (all_cflags
& my_cflag
);
143 get_channel_access(struct Client
*source_p
, struct membership
*msptr
)
145 if(!MyClient(source_p
) || is_chanop(msptr
))
153 * inputs - client, channel, id to add, type
154 * outputs - 0 on failure, 1 on success
155 * side effects - given id is added to the appropriate list
158 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
,
159 rb_dlink_list
* list
, long mode_type
)
161 struct Ban
*actualBan
;
162 static char who
[USERHOST_REPLYLEN
];
163 char *realban
= LOCAL_COPY(banid
);
166 /* dont let local clients overflow the banlist, or set redundant
169 if(MyClient(source_p
))
171 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
))
173 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
174 me
.name
, source_p
->name
, chptr
->chname
, realban
);
178 RB_DLINK_FOREACH(ptr
, list
->head
)
180 actualBan
= ptr
->data
;
181 if(mask_match(actualBan
->banstr
, realban
))
185 /* dont let remotes set duplicates */
188 RB_DLINK_FOREACH(ptr
, list
->head
)
190 actualBan
= ptr
->data
;
191 if(!irccmp(actualBan
->banstr
, realban
))
197 if(IsPerson(source_p
))
198 rb_sprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
200 rb_strlcpy(who
, source_p
->name
, sizeof(who
));
202 actualBan
= allocate_ban(realban
, who
);
203 actualBan
->when
= rb_current_time();
205 rb_dlinkAdd(actualBan
, &actualBan
->node
, list
);
207 /* invalidate the can_send() cache */
208 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
216 * inputs - channel, id to remove, type
217 * outputs - 0 on failure, 1 on success
218 * side effects - given id is removed from the appropriate list
221 del_id(struct Channel
*chptr
, const char *banid
, rb_dlink_list
* list
, long mode_type
)
226 if(EmptyString(banid
))
229 RB_DLINK_FOREACH(ptr
, list
->head
)
233 if(irccmp(banid
, banptr
->banstr
) == 0)
235 rb_dlinkDelete(&banptr
->node
, list
);
238 /* invalidate the can_send() cache */
239 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
251 * input - string to check
252 * output - pointer to 'fixed' string, or "*" if empty
253 * side effects - any white space found becomes \0
256 check_string(char *s
)
259 static char splat
[] = "*";
276 * inputs - mask to pretty
277 * outputs - better version of the mask
278 * side effects - mask is chopped to limits, and transformed:
286 pretty_mask(const char *idmask
)
288 static char mask_buf
[BUFSIZE
];
290 char *nick
, *user
, *host
;
293 char ne
= 0, ue
= 0, he
= 0; /* save values at nick[NICKLEN], et all */
296 mask
= LOCAL_COPY(idmask
);
297 mask
= check_string(mask
);
300 nick
= user
= host
= splat
;
302 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
305 old_mask_pos
= mask_pos
;
309 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
310 t
= mask_buf
+ old_mask_pos
+ 1;
316 return mask_buf
+ old_mask_pos
;
320 if((t
= strchr(mask
, '@')) != NULL
)
327 if((t
= strchr(mask
, '!')) != NULL
)
342 else if((t
= strchr(mask
, '!')) != NULL
)
351 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
)
362 /* truncate values to max lengths */
363 if(strlen(nick
) > NICKLEN
- 1)
365 ne
= nick
[NICKLEN
- 1];
366 nick
[NICKLEN
- 1] = '\0';
368 if(strlen(user
) > USERLEN
)
371 user
[USERLEN
] = '\0';
373 if(strlen(host
) > HOSTLEN
)
376 host
[HOSTLEN
] = '\0';
379 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
381 /* restore mask, since we may need to use it again later */
387 nick
[NICKLEN
- 1] = ne
;
393 return mask_buf
+ old_mask_pos
;
399 * output - the same key, fixed
400 * side effects - anything below ascii 13 is discarded, ':' discarded,
401 * high ascii is dropped to lower half of ascii table
408 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
411 if(c
!= ':' && c
!= ',' && c
> ' ')
422 * ouput - the same key, fixed
423 * side effects - high ascii dropped to lower half of table,
424 * CR/LF/':' are dropped
427 fix_key_remote(char *arg
)
431 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
434 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
444 * The handlers for each specific mode.
447 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
448 int alevel
, int parc
, int *parn
,
449 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
451 if(*errors
& SM_ERR_UNKNOWN
)
453 *errors
|= SM_ERR_UNKNOWN
;
454 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
458 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
459 int alevel
, int parc
, int *parn
,
460 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
462 if(alevel
!= CHFL_CHANOP
)
464 if(!(*errors
& SM_ERR_NOOPS
))
465 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
466 me
.name
, source_p
->name
, chptr
->chname
);
467 *errors
|= SM_ERR_NOOPS
;
471 /* flags (possibly upto 32) + 4 with param */
472 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
476 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
478 /* if +f is disabled, ignore an attempt to set +QF locally */
479 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
480 (c
== 'Q' || c
== 'F'))
483 chptr
->mode
.mode
|= mode_type
;
485 mode_changes
[mode_count
].letter
= c
;
486 mode_changes
[mode_count
].dir
= MODE_ADD
;
487 mode_changes
[mode_count
].caps
= 0;
488 mode_changes
[mode_count
].nocaps
= 0;
489 mode_changes
[mode_count
].id
= NULL
;
490 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
491 mode_changes
[mode_count
++].arg
= NULL
;
493 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
495 chptr
->mode
.mode
&= ~mode_type
;
497 mode_changes
[mode_count
].letter
= c
;
498 mode_changes
[mode_count
].dir
= MODE_DEL
;
499 mode_changes
[mode_count
].caps
= 0;
500 mode_changes
[mode_count
].nocaps
= 0;
501 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
502 mode_changes
[mode_count
].id
= NULL
;
503 mode_changes
[mode_count
++].arg
= NULL
;
508 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
509 int alevel
, int parc
, int *parn
,
510 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
512 if(!IsOper(source_p
) && !IsServer(source_p
))
514 if(!(*errors
& SM_ERR_NOPRIVS
))
515 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
516 *errors
|= SM_ERR_NOPRIVS
;
519 if(MyClient(source_p
) && !IsOperResv(source_p
))
521 if(!(*errors
& SM_ERR_NOPRIVS
))
522 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
523 source_p
->name
, "resv");
524 *errors
|= SM_ERR_NOPRIVS
;
528 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
532 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
534 chptr
->mode
.mode
|= mode_type
;
536 mode_changes
[mode_count
].letter
= c
;
537 mode_changes
[mode_count
].dir
= MODE_ADD
;
538 mode_changes
[mode_count
].caps
= 0;
539 mode_changes
[mode_count
].nocaps
= 0;
540 mode_changes
[mode_count
].id
= NULL
;
541 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
542 mode_changes
[mode_count
++].arg
= NULL
;
544 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
546 chptr
->mode
.mode
&= ~mode_type
;
548 mode_changes
[mode_count
].letter
= c
;
549 mode_changes
[mode_count
].dir
= MODE_DEL
;
550 mode_changes
[mode_count
].caps
= 0;
551 mode_changes
[mode_count
].nocaps
= 0;
552 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
553 mode_changes
[mode_count
].id
= NULL
;
554 mode_changes
[mode_count
++].arg
= NULL
;
559 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
560 int alevel
, int parc
, int *parn
,
561 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
564 const char *raw_mask
;
577 list
= &chptr
->banlist
;
578 errorval
= SM_ERR_RPL_B
;
579 rpl_list
= RPL_BANLIST
;
580 rpl_endlist
= RPL_ENDOFBANLIST
;
586 /* if +e is disabled, allow all but +e locally */
587 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
588 ((dir
== MODE_ADD
) && (parc
> *parn
)))
591 list
= &chptr
->exceptlist
;
592 errorval
= SM_ERR_RPL_E
;
593 rpl_list
= RPL_EXCEPTLIST
;
594 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
597 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
604 /* if +I is disabled, allow all but +I locally */
605 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
606 (dir
== MODE_ADD
) && (parc
> *parn
))
609 list
= &chptr
->invexlist
;
610 errorval
= SM_ERR_RPL_I
;
611 rpl_list
= RPL_INVITELIST
;
612 rpl_endlist
= RPL_ENDOFINVITELIST
;
615 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
622 list
= &chptr
->quietlist
;
623 errorval
= SM_ERR_RPL_Q
;
624 rpl_list
= RPL_BANLIST
;
625 rpl_endlist
= RPL_ENDOFBANLIST
;
631 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
636 if(dir
== 0 || parc
<= *parn
)
638 if((*errors
& errorval
) != 0)
642 /* non-ops cant see +eI lists.. */
643 if(alevel
!= CHFL_CHANOP
&& mode_type
!= CHFL_BAN
&&
644 mode_type
!= CHFL_QUIET
)
646 if(!(*errors
& SM_ERR_NOOPS
))
647 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
648 me
.name
, source_p
->name
, chptr
->chname
);
649 *errors
|= SM_ERR_NOOPS
;
653 RB_DLINK_FOREACH(ptr
, list
->head
)
656 sendto_one(source_p
, form_str(rpl_list
),
657 me
.name
, source_p
->name
, chptr
->chname
,
658 banptr
->banstr
, banptr
->who
, banptr
->when
);
660 if (mode_type
== CHFL_QUIET
)
661 sendto_one(source_p
, ":%s %d %s %s :End of Channel Quiet List", me
.name
, rpl_endlist
, source_p
->name
, chptr
->chname
);
663 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
667 if(alevel
!= CHFL_CHANOP
)
669 if(!(*errors
& SM_ERR_NOOPS
))
670 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
671 me
.name
, source_p
->name
, chptr
->chname
);
672 *errors
|= SM_ERR_NOOPS
;
676 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
679 raw_mask
= parv
[(*parn
)];
682 /* empty ban, or starts with ':' which messes up s2s, ignore it */
683 if(EmptyString(raw_mask
) || *raw_mask
== ':')
686 if(!MyClient(source_p
))
688 if(strchr(raw_mask
, ' '))
694 mask
= pretty_mask(raw_mask
);
696 /* we'd have problems parsing this, hyb6 does it too
697 * also make sure it will always fit on a line with channel
700 if(strlen(mask
) > IRCD_MIN(BANLEN
, MODEBUFLEN
- 5))
703 /* if we're adding a NEW id */
706 if (*mask
== '$' && MyClient(source_p
))
708 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
709 /* XXX perhaps return an error message here */
713 /* dont allow local clients to overflow the banlist, dont
714 * let remote servers set duplicate bans
716 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
719 mode_changes
[mode_count
].letter
= c
;
720 mode_changes
[mode_count
].dir
= MODE_ADD
;
721 mode_changes
[mode_count
].caps
= caps
;
722 mode_changes
[mode_count
].nocaps
= 0;
723 mode_changes
[mode_count
].mems
= mems
;
724 mode_changes
[mode_count
].id
= NULL
;
725 mode_changes
[mode_count
++].arg
= mask
;
727 else if(dir
== MODE_DEL
)
729 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
731 /* mask isn't a valid ban, check raw_mask */
732 if(del_id(chptr
, raw_mask
, list
, mode_type
))
736 mode_changes
[mode_count
].letter
= c
;
737 mode_changes
[mode_count
].dir
= MODE_DEL
;
738 mode_changes
[mode_count
].caps
= caps
;
739 mode_changes
[mode_count
].nocaps
= 0;
740 mode_changes
[mode_count
].mems
= mems
;
741 mode_changes
[mode_count
].id
= NULL
;
742 mode_changes
[mode_count
++].arg
= mask
;
747 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
748 int alevel
, int parc
, int *parn
,
749 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
751 struct membership
*mstptr
;
753 struct Client
*targ_p
;
755 if(alevel
!= CHFL_CHANOP
)
757 if(!(*errors
& SM_ERR_NOOPS
))
758 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
759 me
.name
, source_p
->name
, chptr
->chname
);
760 *errors
|= SM_ERR_NOOPS
;
764 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
767 opnick
= parv
[(*parn
)];
771 if(EmptyString(opnick
))
773 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
777 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
782 mstptr
= find_channel_membership(chptr
, targ_p
);
786 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
787 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
788 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
789 *errors
|= SM_ERR_NOTONCHANNEL
;
793 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
798 if(targ_p
== source_p
)
801 mode_changes
[mode_count
].letter
= c
;
802 mode_changes
[mode_count
].dir
= MODE_ADD
;
803 mode_changes
[mode_count
].caps
= 0;
804 mode_changes
[mode_count
].nocaps
= 0;
805 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
806 mode_changes
[mode_count
].id
= targ_p
->id
;
807 mode_changes
[mode_count
].arg
= targ_p
->name
;
808 mode_changes
[mode_count
++].client
= targ_p
;
810 mstptr
->flags
|= CHFL_CHANOP
;
814 if(MyClient(source_p
) && IsService(targ_p
))
816 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
817 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
821 mode_changes
[mode_count
].letter
= c
;
822 mode_changes
[mode_count
].dir
= MODE_DEL
;
823 mode_changes
[mode_count
].caps
= 0;
824 mode_changes
[mode_count
].nocaps
= 0;
825 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
826 mode_changes
[mode_count
].id
= targ_p
->id
;
827 mode_changes
[mode_count
].arg
= targ_p
->name
;
828 mode_changes
[mode_count
++].client
= targ_p
;
830 mstptr
->flags
&= ~CHFL_CHANOP
;
835 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
836 int alevel
, int parc
, int *parn
,
837 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
839 struct membership
*mstptr
;
841 struct Client
*targ_p
;
843 if(alevel
!= CHFL_CHANOP
)
845 if(!(*errors
& SM_ERR_NOOPS
))
846 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
847 me
.name
, source_p
->name
, chptr
->chname
);
848 *errors
|= SM_ERR_NOOPS
;
852 if((dir
== MODE_QUERY
) || parc
<= *parn
)
855 opnick
= parv
[(*parn
)];
859 if(EmptyString(opnick
))
861 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
865 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
870 mstptr
= find_channel_membership(chptr
, targ_p
);
874 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
875 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
876 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
877 *errors
|= SM_ERR_NOTONCHANNEL
;
881 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
886 mode_changes
[mode_count
].letter
= c
;
887 mode_changes
[mode_count
].dir
= MODE_ADD
;
888 mode_changes
[mode_count
].caps
= 0;
889 mode_changes
[mode_count
].nocaps
= 0;
890 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
891 mode_changes
[mode_count
].id
= targ_p
->id
;
892 mode_changes
[mode_count
].arg
= targ_p
->name
;
893 mode_changes
[mode_count
++].client
= targ_p
;
895 mstptr
->flags
|= CHFL_VOICE
;
899 mode_changes
[mode_count
].letter
= 'v';
900 mode_changes
[mode_count
].dir
= MODE_DEL
;
901 mode_changes
[mode_count
].caps
= 0;
902 mode_changes
[mode_count
].nocaps
= 0;
903 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
904 mode_changes
[mode_count
].id
= targ_p
->id
;
905 mode_changes
[mode_count
].arg
= targ_p
->name
;
906 mode_changes
[mode_count
++].client
= targ_p
;
908 mstptr
->flags
&= ~CHFL_VOICE
;
913 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
914 int alevel
, int parc
, int *parn
,
915 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
918 static char limitstr
[30];
921 if(alevel
!= CHFL_CHANOP
)
923 if(!(*errors
& SM_ERR_NOOPS
))
924 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
925 me
.name
, source_p
->name
, chptr
->chname
);
926 *errors
|= SM_ERR_NOOPS
;
930 if(dir
== MODE_QUERY
)
933 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
936 if((dir
== MODE_ADD
) && parc
> *parn
)
938 lstr
= parv
[(*parn
)];
941 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
944 rb_sprintf(limitstr
, "%d", limit
);
946 mode_changes
[mode_count
].letter
= c
;
947 mode_changes
[mode_count
].dir
= MODE_ADD
;
948 mode_changes
[mode_count
].caps
= 0;
949 mode_changes
[mode_count
].nocaps
= 0;
950 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
951 mode_changes
[mode_count
].id
= NULL
;
952 mode_changes
[mode_count
++].arg
= limitstr
;
954 chptr
->mode
.limit
= limit
;
956 else if(dir
== MODE_DEL
)
958 if(!chptr
->mode
.limit
)
961 chptr
->mode
.limit
= 0;
963 mode_changes
[mode_count
].letter
= c
;
964 mode_changes
[mode_count
].dir
= MODE_DEL
;
965 mode_changes
[mode_count
].caps
= 0;
966 mode_changes
[mode_count
].nocaps
= 0;
967 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
968 mode_changes
[mode_count
].id
= NULL
;
969 mode_changes
[mode_count
++].arg
= NULL
;
974 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
975 int alevel
, int parc
, int *parn
,
976 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
978 int joins
= 0, timeslice
= 0;
980 if(alevel
!= CHFL_CHANOP
)
982 if(!(*errors
& SM_ERR_NOOPS
))
983 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
984 me
.name
, source_p
->name
, chptr
->chname
);
985 *errors
|= SM_ERR_NOOPS
;
989 if(dir
== MODE_QUERY
)
992 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
995 if((dir
== MODE_ADD
) && parc
> *parn
)
997 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
999 if(!joins
|| !timeslice
)
1002 mode_changes
[mode_count
].letter
= c
;
1003 mode_changes
[mode_count
].dir
= MODE_ADD
;
1004 mode_changes
[mode_count
].caps
= 0;
1005 mode_changes
[mode_count
].nocaps
= 0;
1006 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1007 mode_changes
[mode_count
].id
= NULL
;
1008 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
1012 chptr
->mode
.join_num
= joins
;
1013 chptr
->mode
.join_time
= timeslice
;
1015 else if(dir
== MODE_DEL
)
1017 if(!chptr
->mode
.join_num
)
1020 chptr
->mode
.join_num
= 0;
1021 chptr
->mode
.join_time
= 0;
1022 chptr
->join_count
= 0;
1023 chptr
->join_delta
= 0;
1025 mode_changes
[mode_count
].letter
= c
;
1026 mode_changes
[mode_count
].dir
= MODE_DEL
;
1027 mode_changes
[mode_count
].caps
= 0;
1028 mode_changes
[mode_count
].nocaps
= 0;
1029 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1030 mode_changes
[mode_count
].id
= NULL
;
1031 mode_changes
[mode_count
++].arg
= NULL
;
1036 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
1037 int alevel
, int parc
, int *parn
,
1038 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1040 struct Channel
*targptr
= NULL
;
1041 struct membership
*msptr
;
1042 const char *forward
;
1044 /* if +f is disabled, ignore local attempts to set it */
1045 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
1046 (dir
== MODE_ADD
) && (parc
> *parn
))
1049 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
1051 if (!(*errors
& SM_ERR_RPL_F
))
1053 if (*chptr
->mode
.forward
== '\0')
1054 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
1056 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
1057 *errors
|= SM_ERR_RPL_F
;
1062 #ifndef FORWARD_OPERONLY
1063 if(alevel
!= CHFL_CHANOP
)
1065 if(!(*errors
& SM_ERR_NOOPS
))
1066 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1067 me
.name
, source_p
->name
, chptr
->chname
);
1068 *errors
|= SM_ERR_NOOPS
;
1072 if(!IsOper(source_p
) && !IsServer(source_p
))
1074 if(!(*errors
& SM_ERR_NOPRIVS
))
1075 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
1076 *errors
|= SM_ERR_NOPRIVS
;
1081 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1084 if(dir
== MODE_ADD
&& parc
> *parn
)
1086 forward
= parv
[(*parn
)];
1089 if(EmptyString(forward
))
1091 if(!check_channel_name(forward
) ||
1092 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1094 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1097 /* don't forward to inconsistent target -- jilles */
1098 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
1100 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
1101 form_str(ERR_BADCHANNAME
), forward
);
1104 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1106 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1107 form_str(ERR_NOSUCHCHANNEL
), forward
);
1110 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1112 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1113 get_channel_access(source_p
, msptr
) != CHFL_CHANOP
)
1115 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1116 me
.name
, source_p
->name
, targptr
->chname
);
1121 rb_strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1123 mode_changes
[mode_count
].letter
= c
;
1124 mode_changes
[mode_count
].dir
= MODE_ADD
;
1125 mode_changes
[mode_count
].caps
= 0;
1126 mode_changes
[mode_count
].nocaps
= 0;
1127 mode_changes
[mode_count
].mems
= ConfigChannel
.use_forward
? ALL_MEMBERS
: ONLY_SERVERS
;
1128 mode_changes
[mode_count
].id
= NULL
;
1129 mode_changes
[mode_count
++].arg
= forward
;
1131 else if(dir
== MODE_DEL
)
1133 if(!(*chptr
->mode
.forward
))
1136 *chptr
->mode
.forward
= '\0';
1138 mode_changes
[mode_count
].letter
= c
;
1139 mode_changes
[mode_count
].dir
= MODE_DEL
;
1140 mode_changes
[mode_count
].caps
= 0;
1141 mode_changes
[mode_count
].nocaps
= 0;
1142 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1143 mode_changes
[mode_count
].id
= NULL
;
1144 mode_changes
[mode_count
++].arg
= NULL
;
1149 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1150 int alevel
, int parc
, int *parn
,
1151 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1155 if(alevel
!= CHFL_CHANOP
)
1157 if(!(*errors
& SM_ERR_NOOPS
))
1158 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1159 me
.name
, source_p
->name
, chptr
->chname
);
1160 *errors
|= SM_ERR_NOOPS
;
1164 if(dir
== MODE_QUERY
)
1167 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1170 if((dir
== MODE_ADD
) && parc
> *parn
)
1172 key
= LOCAL_COPY(parv
[(*parn
)]);
1175 if(MyClient(source_p
))
1178 fix_key_remote(key
);
1180 if(EmptyString(key
))
1183 s_assert(key
[0] != ' ');
1184 rb_strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1186 mode_changes
[mode_count
].letter
= c
;
1187 mode_changes
[mode_count
].dir
= MODE_ADD
;
1188 mode_changes
[mode_count
].caps
= 0;
1189 mode_changes
[mode_count
].nocaps
= 0;
1190 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1191 mode_changes
[mode_count
].id
= NULL
;
1192 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1194 else if(dir
== MODE_DEL
)
1196 static char splat
[] = "*";
1202 if(!(*chptr
->mode
.key
))
1205 /* hack time. when we get a +k-k mode, the +k arg is
1206 * chptr->mode.key, which the -k sets to \0, so hunt for a
1207 * +k when we get a -k, and set the arg to splat. --anfl
1209 for(i
= 0; i
< mode_count
; i
++)
1211 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1212 mode_changes
[i
].arg
= splat
;
1215 *chptr
->mode
.key
= 0;
1217 mode_changes
[mode_count
].letter
= c
;
1218 mode_changes
[mode_count
].dir
= MODE_DEL
;
1219 mode_changes
[mode_count
].caps
= 0;
1220 mode_changes
[mode_count
].nocaps
= 0;
1221 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1222 mode_changes
[mode_count
].id
= NULL
;
1223 mode_changes
[mode_count
++].arg
= "*";
1228 chm_regonly(struct Client
*source_p
, struct Channel
*chptr
,
1229 int alevel
, int parc
, int *parn
,
1230 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1232 if(alevel
!= CHFL_CHANOP
)
1234 if(!(*errors
& SM_ERR_NOOPS
))
1235 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1236 me
.name
, source_p
->name
, chptr
->chname
);
1237 *errors
|= SM_ERR_NOOPS
;
1241 if(dir
== MODE_QUERY
)
1244 if(((dir
== MODE_ADD
) && (chptr
->mode
.mode
& mode_type
)) ||
1245 ((dir
== MODE_DEL
) && !(chptr
->mode
.mode
& mode_type
)))
1248 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1252 chptr
->mode
.mode
|= mode_type
;
1254 chptr
->mode
.mode
&= ~mode_type
;
1256 mode_changes
[mode_count
].letter
= c
;
1257 mode_changes
[mode_count
].dir
= dir
;
1258 mode_changes
[mode_count
].caps
= CAP_SERVICE
;
1259 mode_changes
[mode_count
].nocaps
= 0;
1260 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1261 mode_changes
[mode_count
].id
= NULL
;
1262 mode_changes
[mode_count
++].arg
= NULL
;
1266 struct ChannelMode chmode_table
[256] =
1268 {chm_nosuch
, 0 }, /* 0x00 */
1269 {chm_nosuch
, 0 }, /* 0x01 */
1270 {chm_nosuch
, 0 }, /* 0x02 */
1271 {chm_nosuch
, 0 }, /* 0x03 */
1272 {chm_nosuch
, 0 }, /* 0x04 */
1273 {chm_nosuch
, 0 }, /* 0x05 */
1274 {chm_nosuch
, 0 }, /* 0x06 */
1275 {chm_nosuch
, 0 }, /* 0x07 */
1276 {chm_nosuch
, 0 }, /* 0x08 */
1277 {chm_nosuch
, 0 }, /* 0x09 */
1278 {chm_nosuch
, 0 }, /* 0x0a */
1279 {chm_nosuch
, 0 }, /* 0x0b */
1280 {chm_nosuch
, 0 }, /* 0x0c */
1281 {chm_nosuch
, 0 }, /* 0x0d */
1282 {chm_nosuch
, 0 }, /* 0x0e */
1283 {chm_nosuch
, 0 }, /* 0x0f */
1284 {chm_nosuch
, 0 }, /* 0x10 */
1285 {chm_nosuch
, 0 }, /* 0x11 */
1286 {chm_nosuch
, 0 }, /* 0x12 */
1287 {chm_nosuch
, 0 }, /* 0x13 */
1288 {chm_nosuch
, 0 }, /* 0x14 */
1289 {chm_nosuch
, 0 }, /* 0x15 */
1290 {chm_nosuch
, 0 }, /* 0x16 */
1291 {chm_nosuch
, 0 }, /* 0x17 */
1292 {chm_nosuch
, 0 }, /* 0x18 */
1293 {chm_nosuch
, 0 }, /* 0x19 */
1294 {chm_nosuch
, 0 }, /* 0x1a */
1295 {chm_nosuch
, 0 }, /* 0x1b */
1296 {chm_nosuch
, 0 }, /* 0x1c */
1297 {chm_nosuch
, 0 }, /* 0x1d */
1298 {chm_nosuch
, 0 }, /* 0x1e */
1299 {chm_nosuch
, 0 }, /* 0x1f */
1300 {chm_nosuch
, 0 }, /* 0x20 */
1301 {chm_nosuch
, 0 }, /* 0x21 */
1302 {chm_nosuch
, 0 }, /* 0x22 */
1303 {chm_nosuch
, 0 }, /* 0x23 */
1304 {chm_nosuch
, 0 }, /* 0x24 */
1305 {chm_nosuch
, 0 }, /* 0x25 */
1306 {chm_nosuch
, 0 }, /* 0x26 */
1307 {chm_nosuch
, 0 }, /* 0x27 */
1308 {chm_nosuch
, 0 }, /* 0x28 */
1309 {chm_nosuch
, 0 }, /* 0x29 */
1310 {chm_nosuch
, 0 }, /* 0x2a */
1311 {chm_nosuch
, 0 }, /* 0x2b */
1312 {chm_nosuch
, 0 }, /* 0x2c */
1313 {chm_nosuch
, 0 }, /* 0x2d */
1314 {chm_nosuch
, 0 }, /* 0x2e */
1315 {chm_nosuch
, 0 }, /* 0x2f */
1316 {chm_nosuch
, 0 }, /* 0x30 */
1317 {chm_nosuch
, 0 }, /* 0x31 */
1318 {chm_nosuch
, 0 }, /* 0x32 */
1319 {chm_nosuch
, 0 }, /* 0x33 */
1320 {chm_nosuch
, 0 }, /* 0x34 */
1321 {chm_nosuch
, 0 }, /* 0x35 */
1322 {chm_nosuch
, 0 }, /* 0x36 */
1323 {chm_nosuch
, 0 }, /* 0x37 */
1324 {chm_nosuch
, 0 }, /* 0x38 */
1325 {chm_nosuch
, 0 }, /* 0x39 */
1326 {chm_nosuch
, 0 }, /* 0x3a */
1327 {chm_nosuch
, 0 }, /* 0x3b */
1328 {chm_nosuch
, 0 }, /* 0x3c */
1329 {chm_nosuch
, 0 }, /* 0x3d */
1330 {chm_nosuch
, 0 }, /* 0x3e */
1331 {chm_nosuch
, 0 }, /* 0x3f */
1333 {chm_nosuch
, 0 }, /* @ */
1334 {chm_nosuch
, 0 }, /* A */
1335 {chm_nosuch
, 0 }, /* B */
1336 {chm_nosuch
, 0 }, /* C */
1337 {chm_nosuch
, 0 }, /* D */
1338 {chm_nosuch
, 0 }, /* E */
1339 {chm_simple
, MODE_FREETARGET
}, /* F */
1340 {chm_nosuch
, 0 }, /* G */
1341 {chm_nosuch
, 0 }, /* H */
1342 {chm_ban
, CHFL_INVEX
}, /* I */
1343 {chm_nosuch
, 0 }, /* J */
1344 {chm_nosuch
, 0 }, /* K */
1345 {chm_staff
, MODE_EXLIMIT
}, /* L */
1346 {chm_nosuch
, 0 }, /* M */
1347 {chm_nosuch
, 0 }, /* N */
1348 {chm_nosuch
, 0 }, /* O */
1349 {chm_staff
, MODE_PERMANENT
}, /* P */
1350 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1351 {chm_nosuch
, 0 }, /* R */
1352 {chm_nosuch
, 0 }, /* S */
1353 {chm_nosuch
, 0 }, /* T */
1354 {chm_nosuch
, 0 }, /* U */
1355 {chm_nosuch
, 0 }, /* V */
1356 {chm_nosuch
, 0 }, /* W */
1357 {chm_nosuch
, 0 }, /* X */
1358 {chm_nosuch
, 0 }, /* Y */
1359 {chm_nosuch
, 0 }, /* Z */
1366 {chm_nosuch
, 0 }, /* a */
1367 {chm_ban
, CHFL_BAN
}, /* b */
1368 {chm_simple
, MODE_NOCOLOR
}, /* c */
1369 {chm_nosuch
, 0 }, /* d */
1370 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1371 {chm_forward
, 0 }, /* f */
1372 {chm_simple
, MODE_FREEINVITE
}, /* g */
1373 {chm_nosuch
, 0 }, /* h */
1374 {chm_simple
, MODE_INVITEONLY
}, /* i */
1375 {chm_throttle
, 0 }, /* j */
1376 {chm_key
, 0 }, /* k */
1377 {chm_limit
, 0 }, /* l */
1378 {chm_simple
, MODE_MODERATED
}, /* m */
1379 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1380 {chm_op
, 0 }, /* o */
1381 {chm_simple
, MODE_PRIVATE
}, /* p */
1382 {chm_ban
, CHFL_QUIET
}, /* q */
1383 {chm_regonly
, MODE_REGONLY
}, /* r */
1384 {chm_simple
, MODE_SECRET
}, /* s */
1385 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1386 {chm_nosuch
, 0 }, /* u */
1387 {chm_voice
, 0 }, /* v */
1388 {chm_nosuch
, 0 }, /* w */
1389 {chm_nosuch
, 0 }, /* x */
1390 {chm_nosuch
, 0 }, /* y */
1391 {chm_simple
, MODE_OPMODERATE
}, /* z */
1393 {chm_nosuch
, 0 }, /* 0x7b */
1394 {chm_nosuch
, 0 }, /* 0x7c */
1395 {chm_nosuch
, 0 }, /* 0x7d */
1396 {chm_nosuch
, 0 }, /* 0x7e */
1397 {chm_nosuch
, 0 }, /* 0x7f */
1399 {chm_nosuch
, 0 }, /* 0x80 */
1400 {chm_nosuch
, 0 }, /* 0x81 */
1401 {chm_nosuch
, 0 }, /* 0x82 */
1402 {chm_nosuch
, 0 }, /* 0x83 */
1403 {chm_nosuch
, 0 }, /* 0x84 */
1404 {chm_nosuch
, 0 }, /* 0x85 */
1405 {chm_nosuch
, 0 }, /* 0x86 */
1406 {chm_nosuch
, 0 }, /* 0x87 */
1407 {chm_nosuch
, 0 }, /* 0x88 */
1408 {chm_nosuch
, 0 }, /* 0x89 */
1409 {chm_nosuch
, 0 }, /* 0x8a */
1410 {chm_nosuch
, 0 }, /* 0x8b */
1411 {chm_nosuch
, 0 }, /* 0x8c */
1412 {chm_nosuch
, 0 }, /* 0x8d */
1413 {chm_nosuch
, 0 }, /* 0x8e */
1414 {chm_nosuch
, 0 }, /* 0x8f */
1416 {chm_nosuch
, 0 }, /* 0x90 */
1417 {chm_nosuch
, 0 }, /* 0x91 */
1418 {chm_nosuch
, 0 }, /* 0x92 */
1419 {chm_nosuch
, 0 }, /* 0x93 */
1420 {chm_nosuch
, 0 }, /* 0x94 */
1421 {chm_nosuch
, 0 }, /* 0x95 */
1422 {chm_nosuch
, 0 }, /* 0x96 */
1423 {chm_nosuch
, 0 }, /* 0x97 */
1424 {chm_nosuch
, 0 }, /* 0x98 */
1425 {chm_nosuch
, 0 }, /* 0x99 */
1426 {chm_nosuch
, 0 }, /* 0x9a */
1427 {chm_nosuch
, 0 }, /* 0x9b */
1428 {chm_nosuch
, 0 }, /* 0x9c */
1429 {chm_nosuch
, 0 }, /* 0x9d */
1430 {chm_nosuch
, 0 }, /* 0x9e */
1431 {chm_nosuch
, 0 }, /* 0x9f */
1433 {chm_nosuch
, 0 }, /* 0xa0 */
1434 {chm_nosuch
, 0 }, /* 0xa1 */
1435 {chm_nosuch
, 0 }, /* 0xa2 */
1436 {chm_nosuch
, 0 }, /* 0xa3 */
1437 {chm_nosuch
, 0 }, /* 0xa4 */
1438 {chm_nosuch
, 0 }, /* 0xa5 */
1439 {chm_nosuch
, 0 }, /* 0xa6 */
1440 {chm_nosuch
, 0 }, /* 0xa7 */
1441 {chm_nosuch
, 0 }, /* 0xa8 */
1442 {chm_nosuch
, 0 }, /* 0xa9 */
1443 {chm_nosuch
, 0 }, /* 0xaa */
1444 {chm_nosuch
, 0 }, /* 0xab */
1445 {chm_nosuch
, 0 }, /* 0xac */
1446 {chm_nosuch
, 0 }, /* 0xad */
1447 {chm_nosuch
, 0 }, /* 0xae */
1448 {chm_nosuch
, 0 }, /* 0xaf */
1450 {chm_nosuch
, 0 }, /* 0xb0 */
1451 {chm_nosuch
, 0 }, /* 0xb1 */
1452 {chm_nosuch
, 0 }, /* 0xb2 */
1453 {chm_nosuch
, 0 }, /* 0xb3 */
1454 {chm_nosuch
, 0 }, /* 0xb4 */
1455 {chm_nosuch
, 0 }, /* 0xb5 */
1456 {chm_nosuch
, 0 }, /* 0xb6 */
1457 {chm_nosuch
, 0 }, /* 0xb7 */
1458 {chm_nosuch
, 0 }, /* 0xb8 */
1459 {chm_nosuch
, 0 }, /* 0xb9 */
1460 {chm_nosuch
, 0 }, /* 0xba */
1461 {chm_nosuch
, 0 }, /* 0xbb */
1462 {chm_nosuch
, 0 }, /* 0xbc */
1463 {chm_nosuch
, 0 }, /* 0xbd */
1464 {chm_nosuch
, 0 }, /* 0xbe */
1465 {chm_nosuch
, 0 }, /* 0xbf */
1467 {chm_nosuch
, 0 }, /* 0xc0 */
1468 {chm_nosuch
, 0 }, /* 0xc1 */
1469 {chm_nosuch
, 0 }, /* 0xc2 */
1470 {chm_nosuch
, 0 }, /* 0xc3 */
1471 {chm_nosuch
, 0 }, /* 0xc4 */
1472 {chm_nosuch
, 0 }, /* 0xc5 */
1473 {chm_nosuch
, 0 }, /* 0xc6 */
1474 {chm_nosuch
, 0 }, /* 0xc7 */
1475 {chm_nosuch
, 0 }, /* 0xc8 */
1476 {chm_nosuch
, 0 }, /* 0xc9 */
1477 {chm_nosuch
, 0 }, /* 0xca */
1478 {chm_nosuch
, 0 }, /* 0xcb */
1479 {chm_nosuch
, 0 }, /* 0xcc */
1480 {chm_nosuch
, 0 }, /* 0xcd */
1481 {chm_nosuch
, 0 }, /* 0xce */
1482 {chm_nosuch
, 0 }, /* 0xcf */
1484 {chm_nosuch
, 0 }, /* 0xd0 */
1485 {chm_nosuch
, 0 }, /* 0xd1 */
1486 {chm_nosuch
, 0 }, /* 0xd2 */
1487 {chm_nosuch
, 0 }, /* 0xd3 */
1488 {chm_nosuch
, 0 }, /* 0xd4 */
1489 {chm_nosuch
, 0 }, /* 0xd5 */
1490 {chm_nosuch
, 0 }, /* 0xd6 */
1491 {chm_nosuch
, 0 }, /* 0xd7 */
1492 {chm_nosuch
, 0 }, /* 0xd8 */
1493 {chm_nosuch
, 0 }, /* 0xd9 */
1494 {chm_nosuch
, 0 }, /* 0xda */
1495 {chm_nosuch
, 0 }, /* 0xdb */
1496 {chm_nosuch
, 0 }, /* 0xdc */
1497 {chm_nosuch
, 0 }, /* 0xdd */
1498 {chm_nosuch
, 0 }, /* 0xde */
1499 {chm_nosuch
, 0 }, /* 0xdf */
1501 {chm_nosuch
, 0 }, /* 0xe0 */
1502 {chm_nosuch
, 0 }, /* 0xe1 */
1503 {chm_nosuch
, 0 }, /* 0xe2 */
1504 {chm_nosuch
, 0 }, /* 0xe3 */
1505 {chm_nosuch
, 0 }, /* 0xe4 */
1506 {chm_nosuch
, 0 }, /* 0xe5 */
1507 {chm_nosuch
, 0 }, /* 0xe6 */
1508 {chm_nosuch
, 0 }, /* 0xe7 */
1509 {chm_nosuch
, 0 }, /* 0xe8 */
1510 {chm_nosuch
, 0 }, /* 0xe9 */
1511 {chm_nosuch
, 0 }, /* 0xea */
1512 {chm_nosuch
, 0 }, /* 0xeb */
1513 {chm_nosuch
, 0 }, /* 0xec */
1514 {chm_nosuch
, 0 }, /* 0xed */
1515 {chm_nosuch
, 0 }, /* 0xee */
1516 {chm_nosuch
, 0 }, /* 0xef */
1518 {chm_nosuch
, 0 }, /* 0xf0 */
1519 {chm_nosuch
, 0 }, /* 0xf1 */
1520 {chm_nosuch
, 0 }, /* 0xf2 */
1521 {chm_nosuch
, 0 }, /* 0xf3 */
1522 {chm_nosuch
, 0 }, /* 0xf4 */
1523 {chm_nosuch
, 0 }, /* 0xf5 */
1524 {chm_nosuch
, 0 }, /* 0xf6 */
1525 {chm_nosuch
, 0 }, /* 0xf7 */
1526 {chm_nosuch
, 0 }, /* 0xf8 */
1527 {chm_nosuch
, 0 }, /* 0xf9 */
1528 {chm_nosuch
, 0 }, /* 0xfa */
1529 {chm_nosuch
, 0 }, /* 0xfb */
1530 {chm_nosuch
, 0 }, /* 0xfc */
1531 {chm_nosuch
, 0 }, /* 0xfd */
1532 {chm_nosuch
, 0 }, /* 0xfe */
1533 {chm_nosuch
, 0 }, /* 0xff */
1538 /* set_channel_mode()
1540 * inputs - client, source, channel, membership pointer, params
1542 * side effects - channel modes/memberships are changed, MODE is issued
1544 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
1547 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
1548 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
1550 static char modebuf
[BUFSIZE
];
1551 static char parabuf
[BUFSIZE
];
1554 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
1560 const char *ml
= parv
[0];
1562 struct Client
*fakesource_p
;
1567 mode_limit_simple
= 0;
1569 alevel
= get_channel_access(source_p
, msptr
);
1571 /* Hide connecting server on netburst -- jilles */
1572 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
1575 fakesource_p
= source_p
;
1577 for(; (c
= *ml
) != 0; ml
++)
1591 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
1594 chmode_table
[(unsigned char) c
].mode_type
);
1599 /* bail out if we have nothing to do... */
1603 if(IsServer(source_p
))
1604 mlen
= rb_sprintf(modebuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
1606 mlen
= rb_sprintf(modebuf
, ":%s!%s@%s MODE %s ",
1607 source_p
->name
, source_p
->username
,
1608 source_p
->host
, chptr
->chname
);
1610 for(j
= 0, flags
= ALL_MEMBERS
; j
< 2; j
++, flags
= ONLY_CHANOPS
)
1613 mbuf
= modebuf
+ mlen
;
1616 paracount
= paralen
= 0;
1619 for(i
= 0; i
< mode_count
; i
++)
1621 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
1624 if(mode_changes
[i
].arg
!= NULL
)
1626 arglen
= strlen(mode_changes
[i
].arg
);
1628 if(arglen
> MODEBUFLEN
- 5)
1634 /* if we're creeping over MAXMODEPARAMSSERV, or over
1635 * bufsize (4 == +/-,modechar,two spaces) send now.
1637 if(mode_changes
[i
].arg
!= NULL
&&
1638 ((paracount
== MAXMODEPARAMSSERV
) ||
1639 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
1644 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
,
1649 paracount
= paralen
= 0;
1651 mbuf
= modebuf
+ mlen
;
1657 if(dir
!= mode_changes
[i
].dir
)
1659 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
1661 dir
= mode_changes
[i
].dir
;
1664 *mbuf
++ = mode_changes
[i
].letter
;
1667 if(mode_changes
[i
].arg
!= NULL
)
1670 len
= rb_sprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
1676 if(paralen
&& parabuf
[paralen
- 1] == ' ')
1677 parabuf
[paralen
- 1] = '\0';
1681 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
, parabuf
);
1684 /* only propagate modes originating locally, or if we're hubbing */
1685 if(MyClient(source_p
) || rb_dlink_list_length(&serv_list
) > 1)
1686 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);