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 static struct ChModeChange mode_changes
[BUFSIZE
];
61 static int mode_count
;
62 static int mode_limit
;
65 static int orphaned_cflags
= 0;
67 int chmode_flags
[256];
69 find_orphaned_cflags(void)
72 static int prev_chmode_flags
[256];
74 for (i
= 0; i
< 256; i
++)
76 if (prev_chmode_flags
[i
] != 0 && prev_chmode_flags
[i
] != chmode_flags
[i
])
78 if (chmode_flags
[i
] == 0)
80 orphaned_cflags
|= prev_chmode_flags
[i
];
81 sendto_realops_snomask(SNO_DEBUG
, L_ALL
, "Cmode +%c is now orphaned", i
);
85 orphaned_cflags
&= ~prev_chmode_flags
[i
];
86 sendto_realops_snomask(SNO_DEBUG
, L_ALL
, "Orphaned cmode +%c is picked up by module", i
);
88 chmode_flags
[i
] = prev_chmode_flags
[i
];
91 prev_chmode_flags
[i
] = chmode_flags
[i
];
96 construct_noparam_modes(void)
100 for(i
= 0; i
< 256; i
++)
102 if( (chmode_table
[i
].set_func
== chm_simple
) ||
103 (chmode_table
[i
].set_func
== chm_staff
) ||
104 (chmode_table
[i
].set_func
== chm_regonly
))
106 chmode_flags
[i
] = chmode_table
[i
].mode_type
;
114 find_orphaned_cflags();
121 * outputs - an available cflag bitmask or
122 * 0 if no cflags are available
123 * side effects - NONE
126 find_cflag_slot(void)
128 unsigned int all_cflags
= 0, my_cflag
= 0, i
;
130 for (i
= 0; i
< 256; i
++)
131 all_cflags
|= chmode_flags
[i
];
133 for (my_cflag
= 1; my_cflag
&& (all_cflags
& my_cflag
);
140 get_channel_access(struct Client
*source_p
, struct membership
*msptr
)
142 if(!MyClient(source_p
) || is_chanop(msptr
))
150 * inputs - client, channel, id to add, type
151 * outputs - 0 on failure, 1 on success
152 * side effects - given id is added to the appropriate list
155 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
,
156 rb_dlink_list
* list
, long mode_type
)
158 struct Ban
*actualBan
;
159 static char who
[USERHOST_REPLYLEN
];
160 char *realban
= LOCAL_COPY(banid
);
163 /* dont let local clients overflow the banlist, or set redundant
166 if(MyClient(source_p
))
168 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
))
170 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
171 me
.name
, source_p
->name
, chptr
->chname
, realban
);
175 RB_DLINK_FOREACH(ptr
, list
->head
)
177 actualBan
= ptr
->data
;
178 if(mask_match(actualBan
->banstr
, realban
))
182 /* dont let remotes set duplicates */
185 RB_DLINK_FOREACH(ptr
, list
->head
)
187 actualBan
= ptr
->data
;
188 if(!irccmp(actualBan
->banstr
, realban
))
194 if(IsPerson(source_p
))
195 rb_sprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
197 rb_strlcpy(who
, source_p
->name
, sizeof(who
));
199 actualBan
= allocate_ban(realban
, who
);
200 actualBan
->when
= rb_current_time();
202 rb_dlinkAdd(actualBan
, &actualBan
->node
, list
);
204 /* invalidate the can_send() cache */
205 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
213 * inputs - channel, id to remove, type
214 * outputs - 0 on failure, 1 on success
215 * side effects - given id is removed from the appropriate list
218 del_id(struct Channel
*chptr
, const char *banid
, rb_dlink_list
* list
, long mode_type
)
223 if(EmptyString(banid
))
226 RB_DLINK_FOREACH(ptr
, list
->head
)
230 if(irccmp(banid
, banptr
->banstr
) == 0)
232 rb_dlinkDelete(&banptr
->node
, list
);
235 /* invalidate the can_send() cache */
236 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
248 * input - string to check
249 * output - pointer to 'fixed' string, or "*" if empty
250 * side effects - any white space found becomes \0
253 check_string(char *s
)
256 static char splat
[] = "*";
273 * inputs - mask to pretty
274 * outputs - better version of the mask
275 * side effects - mask is chopped to limits, and transformed:
283 pretty_mask(const char *idmask
)
285 static char mask_buf
[BUFSIZE
];
287 char *nick
, *user
, *host
;
290 char ne
= 0, ue
= 0, he
= 0; /* save values at nick[NICKLEN], et all */
293 mask
= LOCAL_COPY(idmask
);
294 mask
= check_string(mask
);
297 nick
= user
= host
= splat
;
299 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
302 old_mask_pos
= mask_pos
;
306 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
307 t
= mask_buf
+ old_mask_pos
+ 1;
313 return mask_buf
+ old_mask_pos
;
317 if((t
= strchr(mask
, '@')) != NULL
)
324 if((t
= strchr(mask
, '!')) != NULL
)
339 else if((t
= strchr(mask
, '!')) != NULL
)
348 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
)
359 /* truncate values to max lengths */
360 if(strlen(nick
) > NICKLEN
- 1)
362 ne
= nick
[NICKLEN
- 1];
363 nick
[NICKLEN
- 1] = '\0';
365 if(strlen(user
) > USERLEN
)
368 user
[USERLEN
] = '\0';
370 if(strlen(host
) > HOSTLEN
)
373 host
[HOSTLEN
] = '\0';
376 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
378 /* restore mask, since we may need to use it again later */
384 nick
[NICKLEN
- 1] = ne
;
390 return mask_buf
+ old_mask_pos
;
396 * output - the same key, fixed
397 * side effects - anything below ascii 13 is discarded, ':' discarded,
398 * high ascii is dropped to lower half of ascii table
405 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
408 if(c
!= ':' && c
!= ',' && c
> ' ')
419 * ouput - the same key, fixed
420 * side effects - high ascii dropped to lower half of table,
421 * CR/LF/':' are dropped
424 fix_key_remote(char *arg
)
428 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
431 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
441 * The handlers for each specific mode.
444 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
445 int alevel
, int parc
, int *parn
,
446 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
448 if(*errors
& SM_ERR_UNKNOWN
)
450 *errors
|= SM_ERR_UNKNOWN
;
451 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
455 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
456 int alevel
, int parc
, int *parn
,
457 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
459 if(alevel
!= CHFL_CHANOP
)
461 if(!(*errors
& SM_ERR_NOOPS
))
462 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
463 me
.name
, source_p
->name
, chptr
->chname
);
464 *errors
|= SM_ERR_NOOPS
;
468 /* +ntspmaikl == 9 + MAXMODEPARAMS (4 * +o) */
469 if(MyClient(source_p
) && (++mode_limit
> (9 + MAXMODEPARAMS
)))
473 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
475 /* if +f is disabled, ignore an attempt to set +QF locally */
476 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
477 (c
== 'Q' || c
== 'F'))
480 chptr
->mode
.mode
|= mode_type
;
482 mode_changes
[mode_count
].letter
= c
;
483 mode_changes
[mode_count
].dir
= MODE_ADD
;
484 mode_changes
[mode_count
].caps
= 0;
485 mode_changes
[mode_count
].nocaps
= 0;
486 mode_changes
[mode_count
].id
= NULL
;
487 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
488 mode_changes
[mode_count
++].arg
= NULL
;
490 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
492 chptr
->mode
.mode
&= ~mode_type
;
494 mode_changes
[mode_count
].letter
= c
;
495 mode_changes
[mode_count
].dir
= MODE_DEL
;
496 mode_changes
[mode_count
].caps
= 0;
497 mode_changes
[mode_count
].nocaps
= 0;
498 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
499 mode_changes
[mode_count
].id
= NULL
;
500 mode_changes
[mode_count
++].arg
= NULL
;
505 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
506 int alevel
, int parc
, int *parn
,
507 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
509 if(!IsOper(source_p
) && !IsServer(source_p
))
511 if(!(*errors
& SM_ERR_NOPRIVS
))
512 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
513 *errors
|= SM_ERR_NOPRIVS
;
516 if(MyClient(source_p
) && !IsOperResv(source_p
))
518 if(!(*errors
& SM_ERR_NOPRIVS
))
519 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
520 source_p
->name
, "resv");
521 *errors
|= SM_ERR_NOPRIVS
;
526 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
528 chptr
->mode
.mode
|= mode_type
;
530 mode_changes
[mode_count
].letter
= c
;
531 mode_changes
[mode_count
].dir
= MODE_ADD
;
532 mode_changes
[mode_count
].caps
= 0;
533 mode_changes
[mode_count
].nocaps
= 0;
534 mode_changes
[mode_count
].id
= NULL
;
535 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
536 mode_changes
[mode_count
++].arg
= NULL
;
538 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
540 chptr
->mode
.mode
&= ~mode_type
;
542 mode_changes
[mode_count
].letter
= c
;
543 mode_changes
[mode_count
].dir
= MODE_DEL
;
544 mode_changes
[mode_count
].caps
= 0;
545 mode_changes
[mode_count
].nocaps
= 0;
546 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
547 mode_changes
[mode_count
].id
= NULL
;
548 mode_changes
[mode_count
++].arg
= NULL
;
553 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
554 int alevel
, int parc
, int *parn
,
555 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
558 const char *raw_mask
;
571 list
= &chptr
->banlist
;
572 errorval
= SM_ERR_RPL_B
;
573 rpl_list
= RPL_BANLIST
;
574 rpl_endlist
= RPL_ENDOFBANLIST
;
580 /* if +e is disabled, allow all but +e locally */
581 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
582 ((dir
== MODE_ADD
) && (parc
> *parn
)))
585 list
= &chptr
->exceptlist
;
586 errorval
= SM_ERR_RPL_E
;
587 rpl_list
= RPL_EXCEPTLIST
;
588 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
591 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
598 /* if +I is disabled, allow all but +I locally */
599 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
600 (dir
== MODE_ADD
) && (parc
> *parn
))
603 list
= &chptr
->invexlist
;
604 errorval
= SM_ERR_RPL_I
;
605 rpl_list
= RPL_INVITELIST
;
606 rpl_endlist
= RPL_ENDOFINVITELIST
;
609 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
616 list
= &chptr
->quietlist
;
617 errorval
= SM_ERR_RPL_Q
;
618 rpl_list
= RPL_BANLIST
;
619 rpl_endlist
= RPL_ENDOFBANLIST
;
625 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
630 if(dir
== 0 || parc
<= *parn
)
632 if((*errors
& errorval
) != 0)
636 /* non-ops cant see +eI lists.. */
637 if(alevel
!= CHFL_CHANOP
&& mode_type
!= CHFL_BAN
&&
638 mode_type
!= CHFL_QUIET
)
640 if(!(*errors
& SM_ERR_NOOPS
))
641 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
642 me
.name
, source_p
->name
, chptr
->chname
);
643 *errors
|= SM_ERR_NOOPS
;
647 RB_DLINK_FOREACH(ptr
, list
->head
)
650 sendto_one(source_p
, form_str(rpl_list
),
651 me
.name
, source_p
->name
, chptr
->chname
,
652 banptr
->banstr
, banptr
->who
, banptr
->when
);
654 if (mode_type
== CHFL_QUIET
)
655 sendto_one(source_p
, ":%s %d %s %s :End of Channel Quiet List", me
.name
, rpl_endlist
, source_p
->name
, chptr
->chname
);
657 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
661 if(alevel
!= CHFL_CHANOP
)
663 if(!(*errors
& SM_ERR_NOOPS
))
664 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
665 me
.name
, source_p
->name
, chptr
->chname
);
666 *errors
|= SM_ERR_NOOPS
;
670 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
673 raw_mask
= parv
[(*parn
)];
676 /* empty ban, or starts with ':' which messes up s2s, ignore it */
677 if(EmptyString(raw_mask
) || *raw_mask
== ':')
680 if(!MyClient(source_p
))
682 if(strchr(raw_mask
, ' '))
688 mask
= pretty_mask(raw_mask
);
690 /* we'd have problems parsing this, hyb6 does it too
691 * also make sure it will always fit on a line with channel
694 if(strlen(mask
) > IRCD_MIN(BANLEN
, MODEBUFLEN
- 5))
697 /* if we're adding a NEW id */
700 if (*mask
== '$' && MyClient(source_p
))
702 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
703 /* XXX perhaps return an error message here */
707 /* dont allow local clients to overflow the banlist, dont
708 * let remote servers set duplicate bans
710 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
713 mode_changes
[mode_count
].letter
= c
;
714 mode_changes
[mode_count
].dir
= MODE_ADD
;
715 mode_changes
[mode_count
].caps
= caps
;
716 mode_changes
[mode_count
].nocaps
= 0;
717 mode_changes
[mode_count
].mems
= mems
;
718 mode_changes
[mode_count
].id
= NULL
;
719 mode_changes
[mode_count
++].arg
= mask
;
721 else if(dir
== MODE_DEL
)
723 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
725 /* mask isn't a valid ban, check raw_mask */
726 if(del_id(chptr
, raw_mask
, list
, mode_type
))
730 mode_changes
[mode_count
].letter
= c
;
731 mode_changes
[mode_count
].dir
= MODE_DEL
;
732 mode_changes
[mode_count
].caps
= caps
;
733 mode_changes
[mode_count
].nocaps
= 0;
734 mode_changes
[mode_count
].mems
= mems
;
735 mode_changes
[mode_count
].id
= NULL
;
736 mode_changes
[mode_count
++].arg
= mask
;
741 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
742 int alevel
, int parc
, int *parn
,
743 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
745 struct membership
*mstptr
;
747 struct Client
*targ_p
;
749 if(alevel
!= CHFL_CHANOP
)
751 if(!(*errors
& SM_ERR_NOOPS
))
752 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
753 me
.name
, source_p
->name
, chptr
->chname
);
754 *errors
|= SM_ERR_NOOPS
;
758 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
761 opnick
= parv
[(*parn
)];
765 if(EmptyString(opnick
))
767 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
771 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
776 mstptr
= find_channel_membership(chptr
, targ_p
);
780 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
781 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
782 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
783 *errors
|= SM_ERR_NOTONCHANNEL
;
787 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
792 if(targ_p
== source_p
)
795 mode_changes
[mode_count
].letter
= c
;
796 mode_changes
[mode_count
].dir
= MODE_ADD
;
797 mode_changes
[mode_count
].caps
= 0;
798 mode_changes
[mode_count
].nocaps
= 0;
799 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
800 mode_changes
[mode_count
].id
= targ_p
->id
;
801 mode_changes
[mode_count
].arg
= targ_p
->name
;
802 mode_changes
[mode_count
++].client
= targ_p
;
804 mstptr
->flags
|= CHFL_CHANOP
;
808 if(MyClient(source_p
) && IsService(targ_p
))
810 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
811 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
815 mode_changes
[mode_count
].letter
= c
;
816 mode_changes
[mode_count
].dir
= MODE_DEL
;
817 mode_changes
[mode_count
].caps
= 0;
818 mode_changes
[mode_count
].nocaps
= 0;
819 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
820 mode_changes
[mode_count
].id
= targ_p
->id
;
821 mode_changes
[mode_count
].arg
= targ_p
->name
;
822 mode_changes
[mode_count
++].client
= targ_p
;
824 mstptr
->flags
&= ~CHFL_CHANOP
;
829 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
830 int alevel
, int parc
, int *parn
,
831 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
833 struct membership
*mstptr
;
835 struct Client
*targ_p
;
837 if(alevel
!= CHFL_CHANOP
)
839 if(!(*errors
& SM_ERR_NOOPS
))
840 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
841 me
.name
, source_p
->name
, chptr
->chname
);
842 *errors
|= SM_ERR_NOOPS
;
846 if((dir
== MODE_QUERY
) || parc
<= *parn
)
849 opnick
= parv
[(*parn
)];
853 if(EmptyString(opnick
))
855 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
859 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
864 mstptr
= find_channel_membership(chptr
, targ_p
);
868 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
869 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
870 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
871 *errors
|= SM_ERR_NOTONCHANNEL
;
875 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
880 mode_changes
[mode_count
].letter
= c
;
881 mode_changes
[mode_count
].dir
= MODE_ADD
;
882 mode_changes
[mode_count
].caps
= 0;
883 mode_changes
[mode_count
].nocaps
= 0;
884 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
885 mode_changes
[mode_count
].id
= targ_p
->id
;
886 mode_changes
[mode_count
].arg
= targ_p
->name
;
887 mode_changes
[mode_count
++].client
= targ_p
;
889 mstptr
->flags
|= CHFL_VOICE
;
893 mode_changes
[mode_count
].letter
= 'v';
894 mode_changes
[mode_count
].dir
= MODE_DEL
;
895 mode_changes
[mode_count
].caps
= 0;
896 mode_changes
[mode_count
].nocaps
= 0;
897 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
898 mode_changes
[mode_count
].id
= targ_p
->id
;
899 mode_changes
[mode_count
].arg
= targ_p
->name
;
900 mode_changes
[mode_count
++].client
= targ_p
;
902 mstptr
->flags
&= ~CHFL_VOICE
;
907 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
908 int alevel
, int parc
, int *parn
,
909 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
912 static char limitstr
[30];
915 if(alevel
!= CHFL_CHANOP
)
917 if(!(*errors
& SM_ERR_NOOPS
))
918 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
919 me
.name
, source_p
->name
, chptr
->chname
);
920 *errors
|= SM_ERR_NOOPS
;
924 if(dir
== MODE_QUERY
)
927 if((dir
== MODE_ADD
) && parc
> *parn
)
929 lstr
= parv
[(*parn
)];
932 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
935 rb_sprintf(limitstr
, "%d", limit
);
937 mode_changes
[mode_count
].letter
= c
;
938 mode_changes
[mode_count
].dir
= MODE_ADD
;
939 mode_changes
[mode_count
].caps
= 0;
940 mode_changes
[mode_count
].nocaps
= 0;
941 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
942 mode_changes
[mode_count
].id
= NULL
;
943 mode_changes
[mode_count
++].arg
= limitstr
;
945 chptr
->mode
.limit
= limit
;
947 else if(dir
== MODE_DEL
)
949 if(!chptr
->mode
.limit
)
952 chptr
->mode
.limit
= 0;
954 mode_changes
[mode_count
].letter
= c
;
955 mode_changes
[mode_count
].dir
= MODE_DEL
;
956 mode_changes
[mode_count
].caps
= 0;
957 mode_changes
[mode_count
].nocaps
= 0;
958 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
959 mode_changes
[mode_count
].id
= NULL
;
960 mode_changes
[mode_count
++].arg
= NULL
;
965 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
966 int alevel
, int parc
, int *parn
,
967 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
969 int joins
= 0, timeslice
= 0;
971 if(alevel
!= CHFL_CHANOP
)
973 if(!(*errors
& SM_ERR_NOOPS
))
974 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
975 me
.name
, source_p
->name
, chptr
->chname
);
976 *errors
|= SM_ERR_NOOPS
;
980 if(dir
== MODE_QUERY
)
983 if((dir
== MODE_ADD
) && parc
> *parn
)
985 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
987 if(!joins
|| !timeslice
)
990 mode_changes
[mode_count
].letter
= c
;
991 mode_changes
[mode_count
].dir
= MODE_ADD
;
992 mode_changes
[mode_count
].caps
= 0;
993 mode_changes
[mode_count
].nocaps
= 0;
994 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
995 mode_changes
[mode_count
].id
= NULL
;
996 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
1000 chptr
->mode
.join_num
= joins
;
1001 chptr
->mode
.join_time
= timeslice
;
1003 else if(dir
== MODE_DEL
)
1005 if(!chptr
->mode
.join_num
)
1008 chptr
->mode
.join_num
= 0;
1009 chptr
->mode
.join_time
= 0;
1010 chptr
->join_count
= 0;
1011 chptr
->join_delta
= 0;
1013 mode_changes
[mode_count
].letter
= c
;
1014 mode_changes
[mode_count
].dir
= MODE_DEL
;
1015 mode_changes
[mode_count
].caps
= 0;
1016 mode_changes
[mode_count
].nocaps
= 0;
1017 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1018 mode_changes
[mode_count
].id
= NULL
;
1019 mode_changes
[mode_count
++].arg
= NULL
;
1024 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
1025 int alevel
, int parc
, int *parn
,
1026 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1028 struct Channel
*targptr
= NULL
;
1029 struct membership
*msptr
;
1030 const char *forward
;
1032 /* if +f is disabled, ignore local attempts to set it */
1033 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
1034 (dir
== MODE_ADD
) && (parc
> *parn
))
1037 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
1039 if (!(*errors
& SM_ERR_RPL_F
))
1041 if (*chptr
->mode
.forward
== '\0')
1042 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
1044 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
1045 *errors
|= SM_ERR_RPL_F
;
1050 #ifndef FORWARD_OPERONLY
1051 if(alevel
!= CHFL_CHANOP
)
1053 if(!(*errors
& SM_ERR_NOOPS
))
1054 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1055 me
.name
, source_p
->name
, chptr
->chname
);
1056 *errors
|= SM_ERR_NOOPS
;
1060 if(!IsOper(source_p
) && !IsServer(source_p
))
1062 if(!(*errors
& SM_ERR_NOPRIVS
))
1063 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
1064 *errors
|= SM_ERR_NOPRIVS
;
1069 if(dir
== MODE_ADD
&& parc
> *parn
)
1071 forward
= parv
[(*parn
)];
1074 if(EmptyString(forward
))
1076 if(!check_channel_name(forward
) ||
1077 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1079 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1082 /* don't forward to inconsistent target -- jilles */
1083 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
1085 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
1086 form_str(ERR_BADCHANNAME
), forward
);
1089 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1091 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1092 form_str(ERR_NOSUCHCHANNEL
), forward
);
1095 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1097 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1098 get_channel_access(source_p
, msptr
) != CHFL_CHANOP
)
1100 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1101 me
.name
, source_p
->name
, targptr
->chname
);
1106 rb_strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1108 mode_changes
[mode_count
].letter
= c
;
1109 mode_changes
[mode_count
].dir
= MODE_ADD
;
1110 mode_changes
[mode_count
].caps
= 0;
1111 mode_changes
[mode_count
].nocaps
= 0;
1112 mode_changes
[mode_count
].mems
= ConfigChannel
.use_forward
? ALL_MEMBERS
: ONLY_SERVERS
;
1113 mode_changes
[mode_count
].id
= NULL
;
1114 mode_changes
[mode_count
++].arg
= forward
;
1116 else if(dir
== MODE_DEL
)
1118 if(!(*chptr
->mode
.forward
))
1121 *chptr
->mode
.forward
= '\0';
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
= NULL
;
1129 mode_changes
[mode_count
++].arg
= NULL
;
1134 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1135 int alevel
, int parc
, int *parn
,
1136 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1140 if(alevel
!= CHFL_CHANOP
)
1142 if(!(*errors
& SM_ERR_NOOPS
))
1143 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1144 me
.name
, source_p
->name
, chptr
->chname
);
1145 *errors
|= SM_ERR_NOOPS
;
1149 if(dir
== MODE_QUERY
)
1152 if((dir
== MODE_ADD
) && parc
> *parn
)
1154 key
= LOCAL_COPY(parv
[(*parn
)]);
1157 if(MyClient(source_p
))
1160 fix_key_remote(key
);
1162 if(EmptyString(key
))
1165 s_assert(key
[0] != ' ');
1166 rb_strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1168 mode_changes
[mode_count
].letter
= c
;
1169 mode_changes
[mode_count
].dir
= MODE_ADD
;
1170 mode_changes
[mode_count
].caps
= 0;
1171 mode_changes
[mode_count
].nocaps
= 0;
1172 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1173 mode_changes
[mode_count
].id
= NULL
;
1174 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1176 else if(dir
== MODE_DEL
)
1178 static char splat
[] = "*";
1184 if(!(*chptr
->mode
.key
))
1187 /* hack time. when we get a +k-k mode, the +k arg is
1188 * chptr->mode.key, which the -k sets to \0, so hunt for a
1189 * +k when we get a -k, and set the arg to splat. --anfl
1191 for(i
= 0; i
< mode_count
; i
++)
1193 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1194 mode_changes
[i
].arg
= splat
;
1197 *chptr
->mode
.key
= 0;
1199 mode_changes
[mode_count
].letter
= c
;
1200 mode_changes
[mode_count
].dir
= MODE_DEL
;
1201 mode_changes
[mode_count
].caps
= 0;
1202 mode_changes
[mode_count
].nocaps
= 0;
1203 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1204 mode_changes
[mode_count
].id
= NULL
;
1205 mode_changes
[mode_count
++].arg
= "*";
1210 chm_regonly(struct Client
*source_p
, struct Channel
*chptr
,
1211 int alevel
, int parc
, int *parn
,
1212 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1214 if(alevel
!= CHFL_CHANOP
)
1216 if(!(*errors
& SM_ERR_NOOPS
))
1217 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1218 me
.name
, source_p
->name
, chptr
->chname
);
1219 *errors
|= SM_ERR_NOOPS
;
1223 if(dir
== MODE_QUERY
)
1226 if(((dir
== MODE_ADD
) && (chptr
->mode
.mode
& MODE_REGONLY
)) ||
1227 ((dir
== MODE_DEL
) && !(chptr
->mode
.mode
& MODE_REGONLY
)))
1231 chptr
->mode
.mode
|= MODE_REGONLY
;
1233 chptr
->mode
.mode
&= ~MODE_REGONLY
;
1235 mode_changes
[mode_count
].letter
= c
;
1236 mode_changes
[mode_count
].dir
= dir
;
1237 mode_changes
[mode_count
].caps
= CAP_SERVICE
;
1238 mode_changes
[mode_count
].nocaps
= 0;
1239 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1240 mode_changes
[mode_count
].id
= NULL
;
1241 mode_changes
[mode_count
++].arg
= NULL
;
1245 struct ChannelMode chmode_table
[256] =
1247 {chm_nosuch
, 0 }, /* 0x00 */
1248 {chm_nosuch
, 0 }, /* 0x01 */
1249 {chm_nosuch
, 0 }, /* 0x02 */
1250 {chm_nosuch
, 0 }, /* 0x03 */
1251 {chm_nosuch
, 0 }, /* 0x04 */
1252 {chm_nosuch
, 0 }, /* 0x05 */
1253 {chm_nosuch
, 0 }, /* 0x06 */
1254 {chm_nosuch
, 0 }, /* 0x07 */
1255 {chm_nosuch
, 0 }, /* 0x08 */
1256 {chm_nosuch
, 0 }, /* 0x09 */
1257 {chm_nosuch
, 0 }, /* 0x0a */
1258 {chm_nosuch
, 0 }, /* 0x0b */
1259 {chm_nosuch
, 0 }, /* 0x0c */
1260 {chm_nosuch
, 0 }, /* 0x0d */
1261 {chm_nosuch
, 0 }, /* 0x0e */
1262 {chm_nosuch
, 0 }, /* 0x0f */
1263 {chm_nosuch
, 0 }, /* 0x10 */
1264 {chm_nosuch
, 0 }, /* 0x11 */
1265 {chm_nosuch
, 0 }, /* 0x12 */
1266 {chm_nosuch
, 0 }, /* 0x13 */
1267 {chm_nosuch
, 0 }, /* 0x14 */
1268 {chm_nosuch
, 0 }, /* 0x15 */
1269 {chm_nosuch
, 0 }, /* 0x16 */
1270 {chm_nosuch
, 0 }, /* 0x17 */
1271 {chm_nosuch
, 0 }, /* 0x18 */
1272 {chm_nosuch
, 0 }, /* 0x19 */
1273 {chm_nosuch
, 0 }, /* 0x1a */
1274 {chm_nosuch
, 0 }, /* 0x1b */
1275 {chm_nosuch
, 0 }, /* 0x1c */
1276 {chm_nosuch
, 0 }, /* 0x1d */
1277 {chm_nosuch
, 0 }, /* 0x1e */
1278 {chm_nosuch
, 0 }, /* 0x1f */
1279 {chm_nosuch
, 0 }, /* 0x20 */
1280 {chm_nosuch
, 0 }, /* 0x21 */
1281 {chm_nosuch
, 0 }, /* 0x22 */
1282 {chm_nosuch
, 0 }, /* 0x23 */
1283 {chm_nosuch
, 0 }, /* 0x24 */
1284 {chm_nosuch
, 0 }, /* 0x25 */
1285 {chm_nosuch
, 0 }, /* 0x26 */
1286 {chm_nosuch
, 0 }, /* 0x27 */
1287 {chm_nosuch
, 0 }, /* 0x28 */
1288 {chm_nosuch
, 0 }, /* 0x29 */
1289 {chm_nosuch
, 0 }, /* 0x2a */
1290 {chm_nosuch
, 0 }, /* 0x2b */
1291 {chm_nosuch
, 0 }, /* 0x2c */
1292 {chm_nosuch
, 0 }, /* 0x2d */
1293 {chm_nosuch
, 0 }, /* 0x2e */
1294 {chm_nosuch
, 0 }, /* 0x2f */
1295 {chm_nosuch
, 0 }, /* 0x30 */
1296 {chm_nosuch
, 0 }, /* 0x31 */
1297 {chm_nosuch
, 0 }, /* 0x32 */
1298 {chm_nosuch
, 0 }, /* 0x33 */
1299 {chm_nosuch
, 0 }, /* 0x34 */
1300 {chm_nosuch
, 0 }, /* 0x35 */
1301 {chm_nosuch
, 0 }, /* 0x36 */
1302 {chm_nosuch
, 0 }, /* 0x37 */
1303 {chm_nosuch
, 0 }, /* 0x38 */
1304 {chm_nosuch
, 0 }, /* 0x39 */
1305 {chm_nosuch
, 0 }, /* 0x3a */
1306 {chm_nosuch
, 0 }, /* 0x3b */
1307 {chm_nosuch
, 0 }, /* 0x3c */
1308 {chm_nosuch
, 0 }, /* 0x3d */
1309 {chm_nosuch
, 0 }, /* 0x3e */
1310 {chm_nosuch
, 0 }, /* 0x3f */
1312 {chm_nosuch
, 0 }, /* @ */
1313 {chm_nosuch
, 0 }, /* A */
1314 {chm_nosuch
, 0 }, /* B */
1315 {chm_nosuch
, 0 }, /* C */
1316 {chm_nosuch
, 0 }, /* D */
1317 {chm_nosuch
, 0 }, /* E */
1318 {chm_simple
, MODE_FREETARGET
}, /* F */
1319 {chm_nosuch
, 0 }, /* G */
1320 {chm_nosuch
, 0 }, /* H */
1321 {chm_ban
, CHFL_INVEX
}, /* I */
1322 {chm_nosuch
, 0 }, /* J */
1323 {chm_nosuch
, 0 }, /* K */
1324 {chm_staff
, MODE_EXLIMIT
}, /* L */
1325 {chm_nosuch
, 0 }, /* M */
1326 {chm_nosuch
, 0 }, /* N */
1327 {chm_nosuch
, 0 }, /* O */
1328 {chm_staff
, MODE_PERMANENT
}, /* P */
1329 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1330 {chm_nosuch
, 0 }, /* R */
1331 {chm_nosuch
, 0 }, /* S */
1332 {chm_nosuch
, 0 }, /* T */
1333 {chm_nosuch
, 0 }, /* U */
1334 {chm_nosuch
, 0 }, /* V */
1335 {chm_nosuch
, 0 }, /* W */
1336 {chm_nosuch
, 0 }, /* X */
1337 {chm_nosuch
, 0 }, /* Y */
1338 {chm_nosuch
, 0 }, /* Z */
1345 {chm_nosuch
, 0 }, /* a */
1346 {chm_ban
, CHFL_BAN
}, /* b */
1347 {chm_simple
, MODE_NOCOLOR
}, /* c */
1348 {chm_nosuch
, 0 }, /* d */
1349 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1350 {chm_forward
, 0 }, /* f */
1351 {chm_simple
, MODE_FREEINVITE
}, /* g */
1352 {chm_nosuch
, 0 }, /* h */
1353 {chm_simple
, MODE_INVITEONLY
}, /* i */
1354 {chm_throttle
, 0 }, /* j */
1355 {chm_key
, 0 }, /* k */
1356 {chm_limit
, 0 }, /* l */
1357 {chm_simple
, MODE_MODERATED
}, /* m */
1358 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1359 {chm_op
, 0 }, /* o */
1360 {chm_simple
, MODE_PRIVATE
}, /* p */
1361 {chm_ban
, CHFL_QUIET
}, /* q */
1362 {chm_regonly
, 0 }, /* r */
1363 {chm_simple
, MODE_SECRET
}, /* s */
1364 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1365 {chm_nosuch
, 0 }, /* u */
1366 {chm_voice
, 0 }, /* v */
1367 {chm_nosuch
, 0 }, /* w */
1368 {chm_nosuch
, 0 }, /* x */
1369 {chm_nosuch
, 0 }, /* y */
1370 {chm_simple
, MODE_OPMODERATE
}, /* z */
1372 {chm_nosuch
, 0 }, /* 0x7b */
1373 {chm_nosuch
, 0 }, /* 0x7c */
1374 {chm_nosuch
, 0 }, /* 0x7d */
1375 {chm_nosuch
, 0 }, /* 0x7e */
1376 {chm_nosuch
, 0 }, /* 0x7f */
1378 {chm_nosuch
, 0 }, /* 0x80 */
1379 {chm_nosuch
, 0 }, /* 0x81 */
1380 {chm_nosuch
, 0 }, /* 0x82 */
1381 {chm_nosuch
, 0 }, /* 0x83 */
1382 {chm_nosuch
, 0 }, /* 0x84 */
1383 {chm_nosuch
, 0 }, /* 0x85 */
1384 {chm_nosuch
, 0 }, /* 0x86 */
1385 {chm_nosuch
, 0 }, /* 0x87 */
1386 {chm_nosuch
, 0 }, /* 0x88 */
1387 {chm_nosuch
, 0 }, /* 0x89 */
1388 {chm_nosuch
, 0 }, /* 0x8a */
1389 {chm_nosuch
, 0 }, /* 0x8b */
1390 {chm_nosuch
, 0 }, /* 0x8c */
1391 {chm_nosuch
, 0 }, /* 0x8d */
1392 {chm_nosuch
, 0 }, /* 0x8e */
1393 {chm_nosuch
, 0 }, /* 0x8f */
1395 {chm_nosuch
, 0 }, /* 0x90 */
1396 {chm_nosuch
, 0 }, /* 0x91 */
1397 {chm_nosuch
, 0 }, /* 0x92 */
1398 {chm_nosuch
, 0 }, /* 0x93 */
1399 {chm_nosuch
, 0 }, /* 0x94 */
1400 {chm_nosuch
, 0 }, /* 0x95 */
1401 {chm_nosuch
, 0 }, /* 0x96 */
1402 {chm_nosuch
, 0 }, /* 0x97 */
1403 {chm_nosuch
, 0 }, /* 0x98 */
1404 {chm_nosuch
, 0 }, /* 0x99 */
1405 {chm_nosuch
, 0 }, /* 0x9a */
1406 {chm_nosuch
, 0 }, /* 0x9b */
1407 {chm_nosuch
, 0 }, /* 0x9c */
1408 {chm_nosuch
, 0 }, /* 0x9d */
1409 {chm_nosuch
, 0 }, /* 0x9e */
1410 {chm_nosuch
, 0 }, /* 0x9f */
1412 {chm_nosuch
, 0 }, /* 0xa0 */
1413 {chm_nosuch
, 0 }, /* 0xa1 */
1414 {chm_nosuch
, 0 }, /* 0xa2 */
1415 {chm_nosuch
, 0 }, /* 0xa3 */
1416 {chm_nosuch
, 0 }, /* 0xa4 */
1417 {chm_nosuch
, 0 }, /* 0xa5 */
1418 {chm_nosuch
, 0 }, /* 0xa6 */
1419 {chm_nosuch
, 0 }, /* 0xa7 */
1420 {chm_nosuch
, 0 }, /* 0xa8 */
1421 {chm_nosuch
, 0 }, /* 0xa9 */
1422 {chm_nosuch
, 0 }, /* 0xaa */
1423 {chm_nosuch
, 0 }, /* 0xab */
1424 {chm_nosuch
, 0 }, /* 0xac */
1425 {chm_nosuch
, 0 }, /* 0xad */
1426 {chm_nosuch
, 0 }, /* 0xae */
1427 {chm_nosuch
, 0 }, /* 0xaf */
1429 {chm_nosuch
, 0 }, /* 0xb0 */
1430 {chm_nosuch
, 0 }, /* 0xb1 */
1431 {chm_nosuch
, 0 }, /* 0xb2 */
1432 {chm_nosuch
, 0 }, /* 0xb3 */
1433 {chm_nosuch
, 0 }, /* 0xb4 */
1434 {chm_nosuch
, 0 }, /* 0xb5 */
1435 {chm_nosuch
, 0 }, /* 0xb6 */
1436 {chm_nosuch
, 0 }, /* 0xb7 */
1437 {chm_nosuch
, 0 }, /* 0xb8 */
1438 {chm_nosuch
, 0 }, /* 0xb9 */
1439 {chm_nosuch
, 0 }, /* 0xba */
1440 {chm_nosuch
, 0 }, /* 0xbb */
1441 {chm_nosuch
, 0 }, /* 0xbc */
1442 {chm_nosuch
, 0 }, /* 0xbd */
1443 {chm_nosuch
, 0 }, /* 0xbe */
1444 {chm_nosuch
, 0 }, /* 0xbf */
1446 {chm_nosuch
, 0 }, /* 0xc0 */
1447 {chm_nosuch
, 0 }, /* 0xc1 */
1448 {chm_nosuch
, 0 }, /* 0xc2 */
1449 {chm_nosuch
, 0 }, /* 0xc3 */
1450 {chm_nosuch
, 0 }, /* 0xc4 */
1451 {chm_nosuch
, 0 }, /* 0xc5 */
1452 {chm_nosuch
, 0 }, /* 0xc6 */
1453 {chm_nosuch
, 0 }, /* 0xc7 */
1454 {chm_nosuch
, 0 }, /* 0xc8 */
1455 {chm_nosuch
, 0 }, /* 0xc9 */
1456 {chm_nosuch
, 0 }, /* 0xca */
1457 {chm_nosuch
, 0 }, /* 0xcb */
1458 {chm_nosuch
, 0 }, /* 0xcc */
1459 {chm_nosuch
, 0 }, /* 0xcd */
1460 {chm_nosuch
, 0 }, /* 0xce */
1461 {chm_nosuch
, 0 }, /* 0xcf */
1463 {chm_nosuch
, 0 }, /* 0xd0 */
1464 {chm_nosuch
, 0 }, /* 0xd1 */
1465 {chm_nosuch
, 0 }, /* 0xd2 */
1466 {chm_nosuch
, 0 }, /* 0xd3 */
1467 {chm_nosuch
, 0 }, /* 0xd4 */
1468 {chm_nosuch
, 0 }, /* 0xd5 */
1469 {chm_nosuch
, 0 }, /* 0xd6 */
1470 {chm_nosuch
, 0 }, /* 0xd7 */
1471 {chm_nosuch
, 0 }, /* 0xd8 */
1472 {chm_nosuch
, 0 }, /* 0xd9 */
1473 {chm_nosuch
, 0 }, /* 0xda */
1474 {chm_nosuch
, 0 }, /* 0xdb */
1475 {chm_nosuch
, 0 }, /* 0xdc */
1476 {chm_nosuch
, 0 }, /* 0xdd */
1477 {chm_nosuch
, 0 }, /* 0xde */
1478 {chm_nosuch
, 0 }, /* 0xdf */
1480 {chm_nosuch
, 0 }, /* 0xe0 */
1481 {chm_nosuch
, 0 }, /* 0xe1 */
1482 {chm_nosuch
, 0 }, /* 0xe2 */
1483 {chm_nosuch
, 0 }, /* 0xe3 */
1484 {chm_nosuch
, 0 }, /* 0xe4 */
1485 {chm_nosuch
, 0 }, /* 0xe5 */
1486 {chm_nosuch
, 0 }, /* 0xe6 */
1487 {chm_nosuch
, 0 }, /* 0xe7 */
1488 {chm_nosuch
, 0 }, /* 0xe8 */
1489 {chm_nosuch
, 0 }, /* 0xe9 */
1490 {chm_nosuch
, 0 }, /* 0xea */
1491 {chm_nosuch
, 0 }, /* 0xeb */
1492 {chm_nosuch
, 0 }, /* 0xec */
1493 {chm_nosuch
, 0 }, /* 0xed */
1494 {chm_nosuch
, 0 }, /* 0xee */
1495 {chm_nosuch
, 0 }, /* 0xef */
1497 {chm_nosuch
, 0 }, /* 0xf0 */
1498 {chm_nosuch
, 0 }, /* 0xf1 */
1499 {chm_nosuch
, 0 }, /* 0xf2 */
1500 {chm_nosuch
, 0 }, /* 0xf3 */
1501 {chm_nosuch
, 0 }, /* 0xf4 */
1502 {chm_nosuch
, 0 }, /* 0xf5 */
1503 {chm_nosuch
, 0 }, /* 0xf6 */
1504 {chm_nosuch
, 0 }, /* 0xf7 */
1505 {chm_nosuch
, 0 }, /* 0xf8 */
1506 {chm_nosuch
, 0 }, /* 0xf9 */
1507 {chm_nosuch
, 0 }, /* 0xfa */
1508 {chm_nosuch
, 0 }, /* 0xfb */
1509 {chm_nosuch
, 0 }, /* 0xfc */
1510 {chm_nosuch
, 0 }, /* 0xfd */
1511 {chm_nosuch
, 0 }, /* 0xfe */
1512 {chm_nosuch
, 0 }, /* 0xff */
1517 /* set_channel_mode()
1519 * inputs - client, source, channel, membership pointer, params
1521 * side effects - channel modes/memberships are changed, MODE is issued
1523 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
1526 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
1527 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
1529 static char modebuf
[BUFSIZE
];
1530 static char parabuf
[BUFSIZE
];
1533 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
1539 const char *ml
= parv
[0];
1541 struct Client
*fakesource_p
;
1547 alevel
= get_channel_access(source_p
, msptr
);
1549 /* Hide connecting server on netburst -- jilles */
1550 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
1553 fakesource_p
= source_p
;
1555 for(; (c
= *ml
) != 0; ml
++)
1569 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
1572 chmode_table
[(unsigned char) c
].mode_type
);
1577 /* bail out if we have nothing to do... */
1581 if(IsServer(source_p
))
1582 mlen
= rb_sprintf(modebuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
1584 mlen
= rb_sprintf(modebuf
, ":%s!%s@%s MODE %s ",
1585 source_p
->name
, source_p
->username
,
1586 source_p
->host
, chptr
->chname
);
1588 for(j
= 0, flags
= ALL_MEMBERS
; j
< 2; j
++, flags
= ONLY_CHANOPS
)
1591 mbuf
= modebuf
+ mlen
;
1594 paracount
= paralen
= 0;
1597 for(i
= 0; i
< mode_count
; i
++)
1599 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
1602 if(mode_changes
[i
].arg
!= NULL
)
1604 arglen
= strlen(mode_changes
[i
].arg
);
1606 if(arglen
> MODEBUFLEN
- 5)
1612 /* if we're creeping over MAXMODEPARAMSSERV, or over
1613 * bufsize (4 == +/-,modechar,two spaces) send now.
1615 if(mode_changes
[i
].arg
!= NULL
&&
1616 ((paracount
== MAXMODEPARAMSSERV
) ||
1617 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
1622 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
,
1627 paracount
= paralen
= 0;
1629 mbuf
= modebuf
+ mlen
;
1635 if(dir
!= mode_changes
[i
].dir
)
1637 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
1639 dir
= mode_changes
[i
].dir
;
1642 *mbuf
++ = mode_changes
[i
].letter
;
1645 if(mode_changes
[i
].arg
!= NULL
)
1648 len
= rb_sprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
1654 if(paralen
&& parabuf
[paralen
- 1] == ' ')
1655 parabuf
[paralen
- 1] = '\0';
1659 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
, parabuf
);
1662 /* only propagate modes originating locally, or if we're hubbing */
1663 if(MyClient(source_p
) || rb_dlink_list_length(&serv_list
) > 1)
1664 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);