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 int chmode_flags
[256];
70 find_orphaned_cflags(void)
73 static int prev_chmode_flags
[256];
75 for (i
= 0; i
< 256; i
++)
77 if (prev_chmode_flags
[i
] != 0 && prev_chmode_flags
[i
] != chmode_flags
[i
])
79 if (chmode_flags
[i
] == 0)
81 chmode_table
[i
].set_func
= chm_orphaned
;
82 sendto_realops_snomask(SNO_DEBUG
, L_ALL
, "Cmode +%c is now orphaned", 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_ban
) &&
103 !(chmode_table
[i
].set_func
== chm_forward
) &&
104 !(chmode_table
[i
].set_func
== chm_throttle
) &&
105 !(chmode_table
[i
].set_func
== chm_key
) &&
106 !(chmode_table
[i
].set_func
== chm_limit
) &&
107 !(chmode_table
[i
].set_func
== chm_op
) &&
108 !(chmode_table
[i
].set_func
== chm_voice
))
110 chmode_flags
[i
] = chmode_table
[i
].mode_type
;
118 find_orphaned_cflags();
125 * outputs - an available cflag bitmask or
126 * 0 if no cflags are available
127 * side effects - NONE
130 find_cflag_slot(void)
132 unsigned int all_cflags
= 0, my_cflag
= 0, i
;
134 for (i
= 0; i
< 256; i
++)
135 all_cflags
|= chmode_flags
[i
];
137 for (my_cflag
= 1; my_cflag
&& (all_cflags
& my_cflag
);
144 get_channel_access(struct Client
*source_p
, struct membership
*msptr
)
146 if(!MyClient(source_p
) || is_chanop(msptr
))
154 * inputs - client, channel, id to add, type
155 * outputs - 0 on failure, 1 on success
156 * side effects - given id is added to the appropriate list
159 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
,
160 rb_dlink_list
* list
, long mode_type
)
162 struct Ban
*actualBan
;
163 static char who
[USERHOST_REPLYLEN
];
164 char *realban
= LOCAL_COPY(banid
);
167 /* dont let local clients overflow the banlist, or set redundant
170 if(MyClient(source_p
))
172 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
))
174 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
175 me
.name
, source_p
->name
, chptr
->chname
, realban
);
179 RB_DLINK_FOREACH(ptr
, list
->head
)
181 actualBan
= ptr
->data
;
182 if(mask_match(actualBan
->banstr
, realban
))
186 /* dont let remotes set duplicates */
189 RB_DLINK_FOREACH(ptr
, list
->head
)
191 actualBan
= ptr
->data
;
192 if(!irccmp(actualBan
->banstr
, realban
))
198 if(IsPerson(source_p
))
199 rb_sprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
201 rb_strlcpy(who
, source_p
->name
, sizeof(who
));
203 actualBan
= allocate_ban(realban
, who
);
204 actualBan
->when
= rb_current_time();
206 rb_dlinkAdd(actualBan
, &actualBan
->node
, list
);
208 /* invalidate the can_send() cache */
209 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
217 * inputs - channel, id to remove, type
218 * outputs - 0 on failure, 1 on success
219 * side effects - given id is removed from the appropriate list
222 del_id(struct Channel
*chptr
, const char *banid
, rb_dlink_list
* list
, long mode_type
)
227 if(EmptyString(banid
))
230 RB_DLINK_FOREACH(ptr
, list
->head
)
234 if(irccmp(banid
, banptr
->banstr
) == 0)
236 rb_dlinkDelete(&banptr
->node
, list
);
239 /* invalidate the can_send() cache */
240 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
252 * input - string to check
253 * output - pointer to 'fixed' string, or "*" if empty
254 * side effects - any white space found becomes \0
257 check_string(char *s
)
260 static char splat
[] = "*";
277 * inputs - mask to pretty
278 * outputs - better version of the mask
279 * side effects - mask is chopped to limits, and transformed:
287 pretty_mask(const char *idmask
)
289 static char mask_buf
[BUFSIZE
];
291 char *nick
, *user
, *host
;
294 char ne
= 0, ue
= 0, he
= 0; /* save values at nick[NICKLEN], et all */
297 mask
= LOCAL_COPY(idmask
);
298 mask
= check_string(mask
);
301 nick
= user
= host
= splat
;
303 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
306 old_mask_pos
= mask_pos
;
310 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
311 t
= mask_buf
+ old_mask_pos
+ 1;
317 return mask_buf
+ old_mask_pos
;
321 if((t
= strchr(mask
, '@')) != NULL
)
328 if((t
= strchr(mask
, '!')) != NULL
)
343 else if((t
= strchr(mask
, '!')) != NULL
)
352 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
)
363 /* truncate values to max lengths */
364 if(strlen(nick
) > NICKLEN
- 1)
366 ne
= nick
[NICKLEN
- 1];
367 nick
[NICKLEN
- 1] = '\0';
369 if(strlen(user
) > USERLEN
)
372 user
[USERLEN
] = '\0';
374 if(strlen(host
) > HOSTLEN
)
377 host
[HOSTLEN
] = '\0';
380 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
382 /* restore mask, since we may need to use it again later */
388 nick
[NICKLEN
- 1] = ne
;
394 return mask_buf
+ old_mask_pos
;
400 * output - the same key, fixed
401 * side effects - anything below ascii 13 is discarded, ':' discarded,
402 * high ascii is dropped to lower half of ascii table
409 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
412 if(c
!= ':' && c
!= ',' && c
> ' ')
423 * ouput - the same key, fixed
424 * side effects - high ascii dropped to lower half of table,
425 * CR/LF/':' are dropped
428 fix_key_remote(char *arg
)
432 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
435 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
445 * The handlers for each specific mode.
448 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
449 int alevel
, int parc
, int *parn
,
450 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
452 if(*errors
& SM_ERR_UNKNOWN
)
454 *errors
|= SM_ERR_UNKNOWN
;
455 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
459 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
460 int alevel
, int parc
, int *parn
,
461 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
463 if(alevel
!= CHFL_CHANOP
)
465 if(!(*errors
& SM_ERR_NOOPS
))
466 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
467 me
.name
, source_p
->name
, chptr
->chname
);
468 *errors
|= SM_ERR_NOOPS
;
472 /* flags (possibly upto 32) + 4 with param */
473 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
477 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
479 /* if +f is disabled, ignore an attempt to set +QF locally */
480 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
481 (c
== 'Q' || c
== 'F'))
484 chptr
->mode
.mode
|= mode_type
;
486 mode_changes
[mode_count
].letter
= c
;
487 mode_changes
[mode_count
].dir
= MODE_ADD
;
488 mode_changes
[mode_count
].caps
= 0;
489 mode_changes
[mode_count
].nocaps
= 0;
490 mode_changes
[mode_count
].id
= NULL
;
491 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
492 mode_changes
[mode_count
++].arg
= NULL
;
494 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
496 chptr
->mode
.mode
&= ~mode_type
;
498 mode_changes
[mode_count
].letter
= c
;
499 mode_changes
[mode_count
].dir
= MODE_DEL
;
500 mode_changes
[mode_count
].caps
= 0;
501 mode_changes
[mode_count
].nocaps
= 0;
502 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
503 mode_changes
[mode_count
].id
= NULL
;
504 mode_changes
[mode_count
++].arg
= NULL
;
509 chm_orphaned(struct Client
*source_p
, struct Channel
*chptr
,
510 int alevel
, int parc
, int *parn
,
511 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
513 if(MyClient(source_p
))
516 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
518 chptr
->mode
.mode
|= mode_type
;
520 mode_changes
[mode_count
].letter
= c
;
521 mode_changes
[mode_count
].dir
= MODE_ADD
;
522 mode_changes
[mode_count
].caps
= 0;
523 mode_changes
[mode_count
].nocaps
= 0;
524 mode_changes
[mode_count
].id
= NULL
;
525 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
526 mode_changes
[mode_count
++].arg
= NULL
;
528 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
530 chptr
->mode
.mode
&= ~mode_type
;
532 mode_changes
[mode_count
].letter
= c
;
533 mode_changes
[mode_count
].dir
= MODE_DEL
;
534 mode_changes
[mode_count
].caps
= 0;
535 mode_changes
[mode_count
].nocaps
= 0;
536 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
537 mode_changes
[mode_count
].id
= NULL
;
538 mode_changes
[mode_count
++].arg
= NULL
;
543 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
544 int alevel
, int parc
, int *parn
,
545 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
547 if(!IsOper(source_p
) && !IsServer(source_p
))
549 if(!(*errors
& SM_ERR_NOPRIVS
))
550 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
551 *errors
|= SM_ERR_NOPRIVS
;
554 if(MyClient(source_p
) && !IsOperResv(source_p
))
556 if(!(*errors
& SM_ERR_NOPRIVS
))
557 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
558 source_p
->name
, "resv");
559 *errors
|= SM_ERR_NOPRIVS
;
563 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
567 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
569 chptr
->mode
.mode
|= mode_type
;
571 mode_changes
[mode_count
].letter
= c
;
572 mode_changes
[mode_count
].dir
= MODE_ADD
;
573 mode_changes
[mode_count
].caps
= 0;
574 mode_changes
[mode_count
].nocaps
= 0;
575 mode_changes
[mode_count
].id
= NULL
;
576 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
577 mode_changes
[mode_count
++].arg
= NULL
;
579 else if((dir
== MODE_DEL
) && (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_DEL
;
585 mode_changes
[mode_count
].caps
= 0;
586 mode_changes
[mode_count
].nocaps
= 0;
587 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
588 mode_changes
[mode_count
].id
= NULL
;
589 mode_changes
[mode_count
++].arg
= NULL
;
594 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
595 int alevel
, int parc
, int *parn
,
596 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
599 const char *raw_mask
;
612 list
= &chptr
->banlist
;
613 errorval
= SM_ERR_RPL_B
;
614 rpl_list
= RPL_BANLIST
;
615 rpl_endlist
= RPL_ENDOFBANLIST
;
621 /* if +e is disabled, allow all but +e locally */
622 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
623 ((dir
== MODE_ADD
) && (parc
> *parn
)))
626 list
= &chptr
->exceptlist
;
627 errorval
= SM_ERR_RPL_E
;
628 rpl_list
= RPL_EXCEPTLIST
;
629 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
632 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
639 /* if +I is disabled, allow all but +I locally */
640 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
641 (dir
== MODE_ADD
) && (parc
> *parn
))
644 list
= &chptr
->invexlist
;
645 errorval
= SM_ERR_RPL_I
;
646 rpl_list
= RPL_INVITELIST
;
647 rpl_endlist
= RPL_ENDOFINVITELIST
;
650 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
657 list
= &chptr
->quietlist
;
658 errorval
= SM_ERR_RPL_Q
;
659 rpl_list
= RPL_BANLIST
;
660 rpl_endlist
= RPL_ENDOFBANLIST
;
666 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
671 if(dir
== 0 || parc
<= *parn
)
673 if((*errors
& errorval
) != 0)
677 /* non-ops cant see +eI lists.. */
678 if(alevel
!= CHFL_CHANOP
&& mode_type
!= CHFL_BAN
&&
679 mode_type
!= CHFL_QUIET
)
681 if(!(*errors
& SM_ERR_NOOPS
))
682 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
683 me
.name
, source_p
->name
, chptr
->chname
);
684 *errors
|= SM_ERR_NOOPS
;
688 RB_DLINK_FOREACH(ptr
, list
->head
)
691 sendto_one(source_p
, form_str(rpl_list
),
692 me
.name
, source_p
->name
, chptr
->chname
,
693 banptr
->banstr
, banptr
->who
, banptr
->when
);
695 if (mode_type
== CHFL_QUIET
)
696 sendto_one(source_p
, ":%s %d %s %s :End of Channel Quiet List", me
.name
, rpl_endlist
, source_p
->name
, chptr
->chname
);
698 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
702 if(alevel
!= CHFL_CHANOP
)
704 if(!(*errors
& SM_ERR_NOOPS
))
705 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
706 me
.name
, source_p
->name
, chptr
->chname
);
707 *errors
|= SM_ERR_NOOPS
;
711 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
714 raw_mask
= parv
[(*parn
)];
717 /* empty ban, or starts with ':' which messes up s2s, ignore it */
718 if(EmptyString(raw_mask
) || *raw_mask
== ':')
721 if(!MyClient(source_p
))
723 if(strchr(raw_mask
, ' '))
729 mask
= pretty_mask(raw_mask
);
731 /* we'd have problems parsing this, hyb6 does it too
732 * also make sure it will always fit on a line with channel
735 if(strlen(mask
) > IRCD_MIN(BANLEN
, MODEBUFLEN
- 5))
738 /* if we're adding a NEW id */
741 if (*mask
== '$' && MyClient(source_p
))
743 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
744 /* XXX perhaps return an error message here */
748 /* dont allow local clients to overflow the banlist, dont
749 * let remote servers set duplicate bans
751 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
754 mode_changes
[mode_count
].letter
= c
;
755 mode_changes
[mode_count
].dir
= MODE_ADD
;
756 mode_changes
[mode_count
].caps
= caps
;
757 mode_changes
[mode_count
].nocaps
= 0;
758 mode_changes
[mode_count
].mems
= mems
;
759 mode_changes
[mode_count
].id
= NULL
;
760 mode_changes
[mode_count
++].arg
= mask
;
762 else if(dir
== MODE_DEL
)
764 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
766 /* mask isn't a valid ban, check raw_mask */
767 if(del_id(chptr
, raw_mask
, list
, mode_type
))
771 mode_changes
[mode_count
].letter
= c
;
772 mode_changes
[mode_count
].dir
= MODE_DEL
;
773 mode_changes
[mode_count
].caps
= caps
;
774 mode_changes
[mode_count
].nocaps
= 0;
775 mode_changes
[mode_count
].mems
= mems
;
776 mode_changes
[mode_count
].id
= NULL
;
777 mode_changes
[mode_count
++].arg
= mask
;
782 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
783 int alevel
, int parc
, int *parn
,
784 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
786 struct membership
*mstptr
;
788 struct Client
*targ_p
;
790 if(alevel
!= CHFL_CHANOP
)
792 if(!(*errors
& SM_ERR_NOOPS
))
793 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
794 me
.name
, source_p
->name
, chptr
->chname
);
795 *errors
|= SM_ERR_NOOPS
;
799 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
802 opnick
= parv
[(*parn
)];
806 if(EmptyString(opnick
))
808 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
812 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
817 mstptr
= find_channel_membership(chptr
, targ_p
);
821 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
822 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
823 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
824 *errors
|= SM_ERR_NOTONCHANNEL
;
828 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
833 if(targ_p
== source_p
)
836 mode_changes
[mode_count
].letter
= c
;
837 mode_changes
[mode_count
].dir
= MODE_ADD
;
838 mode_changes
[mode_count
].caps
= 0;
839 mode_changes
[mode_count
].nocaps
= 0;
840 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
841 mode_changes
[mode_count
].id
= targ_p
->id
;
842 mode_changes
[mode_count
].arg
= targ_p
->name
;
843 mode_changes
[mode_count
++].client
= targ_p
;
845 mstptr
->flags
|= CHFL_CHANOP
;
849 if(MyClient(source_p
) && IsService(targ_p
))
851 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
852 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
856 mode_changes
[mode_count
].letter
= c
;
857 mode_changes
[mode_count
].dir
= MODE_DEL
;
858 mode_changes
[mode_count
].caps
= 0;
859 mode_changes
[mode_count
].nocaps
= 0;
860 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
861 mode_changes
[mode_count
].id
= targ_p
->id
;
862 mode_changes
[mode_count
].arg
= targ_p
->name
;
863 mode_changes
[mode_count
++].client
= targ_p
;
865 mstptr
->flags
&= ~CHFL_CHANOP
;
870 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
871 int alevel
, int parc
, int *parn
,
872 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
874 struct membership
*mstptr
;
876 struct Client
*targ_p
;
878 if(alevel
!= CHFL_CHANOP
)
880 if(!(*errors
& SM_ERR_NOOPS
))
881 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
882 me
.name
, source_p
->name
, chptr
->chname
);
883 *errors
|= SM_ERR_NOOPS
;
887 if((dir
== MODE_QUERY
) || parc
<= *parn
)
890 opnick
= parv
[(*parn
)];
894 if(EmptyString(opnick
))
896 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
900 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
905 mstptr
= find_channel_membership(chptr
, targ_p
);
909 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
910 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
911 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
912 *errors
|= SM_ERR_NOTONCHANNEL
;
916 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
921 mode_changes
[mode_count
].letter
= c
;
922 mode_changes
[mode_count
].dir
= MODE_ADD
;
923 mode_changes
[mode_count
].caps
= 0;
924 mode_changes
[mode_count
].nocaps
= 0;
925 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
926 mode_changes
[mode_count
].id
= targ_p
->id
;
927 mode_changes
[mode_count
].arg
= targ_p
->name
;
928 mode_changes
[mode_count
++].client
= targ_p
;
930 mstptr
->flags
|= CHFL_VOICE
;
934 mode_changes
[mode_count
].letter
= 'v';
935 mode_changes
[mode_count
].dir
= MODE_DEL
;
936 mode_changes
[mode_count
].caps
= 0;
937 mode_changes
[mode_count
].nocaps
= 0;
938 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
939 mode_changes
[mode_count
].id
= targ_p
->id
;
940 mode_changes
[mode_count
].arg
= targ_p
->name
;
941 mode_changes
[mode_count
++].client
= targ_p
;
943 mstptr
->flags
&= ~CHFL_VOICE
;
948 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
949 int alevel
, int parc
, int *parn
,
950 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
953 static char limitstr
[30];
956 if(alevel
!= CHFL_CHANOP
)
958 if(!(*errors
& SM_ERR_NOOPS
))
959 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
960 me
.name
, source_p
->name
, chptr
->chname
);
961 *errors
|= SM_ERR_NOOPS
;
965 if(dir
== MODE_QUERY
)
968 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
971 if((dir
== MODE_ADD
) && parc
> *parn
)
973 lstr
= parv
[(*parn
)];
976 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
979 rb_sprintf(limitstr
, "%d", limit
);
981 mode_changes
[mode_count
].letter
= c
;
982 mode_changes
[mode_count
].dir
= MODE_ADD
;
983 mode_changes
[mode_count
].caps
= 0;
984 mode_changes
[mode_count
].nocaps
= 0;
985 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
986 mode_changes
[mode_count
].id
= NULL
;
987 mode_changes
[mode_count
++].arg
= limitstr
;
989 chptr
->mode
.limit
= limit
;
991 else if(dir
== MODE_DEL
)
993 if(!chptr
->mode
.limit
)
996 chptr
->mode
.limit
= 0;
998 mode_changes
[mode_count
].letter
= c
;
999 mode_changes
[mode_count
].dir
= MODE_DEL
;
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
= NULL
;
1004 mode_changes
[mode_count
++].arg
= NULL
;
1009 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
1010 int alevel
, int parc
, int *parn
,
1011 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1013 int joins
= 0, timeslice
= 0;
1015 if(alevel
!= CHFL_CHANOP
)
1017 if(!(*errors
& SM_ERR_NOOPS
))
1018 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1019 me
.name
, source_p
->name
, chptr
->chname
);
1020 *errors
|= SM_ERR_NOOPS
;
1024 if(dir
== MODE_QUERY
)
1027 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1030 if((dir
== MODE_ADD
) && parc
> *parn
)
1032 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
1034 if(!joins
|| !timeslice
)
1037 mode_changes
[mode_count
].letter
= c
;
1038 mode_changes
[mode_count
].dir
= MODE_ADD
;
1039 mode_changes
[mode_count
].caps
= 0;
1040 mode_changes
[mode_count
].nocaps
= 0;
1041 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1042 mode_changes
[mode_count
].id
= NULL
;
1043 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
1047 chptr
->mode
.join_num
= joins
;
1048 chptr
->mode
.join_time
= timeslice
;
1050 else if(dir
== MODE_DEL
)
1052 if(!chptr
->mode
.join_num
)
1055 chptr
->mode
.join_num
= 0;
1056 chptr
->mode
.join_time
= 0;
1057 chptr
->join_count
= 0;
1058 chptr
->join_delta
= 0;
1060 mode_changes
[mode_count
].letter
= c
;
1061 mode_changes
[mode_count
].dir
= MODE_DEL
;
1062 mode_changes
[mode_count
].caps
= 0;
1063 mode_changes
[mode_count
].nocaps
= 0;
1064 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1065 mode_changes
[mode_count
].id
= NULL
;
1066 mode_changes
[mode_count
++].arg
= NULL
;
1071 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
1072 int alevel
, int parc
, int *parn
,
1073 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1075 struct Channel
*targptr
= NULL
;
1076 struct membership
*msptr
;
1077 const char *forward
;
1079 /* if +f is disabled, ignore local attempts to set it */
1080 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
1081 (dir
== MODE_ADD
) && (parc
> *parn
))
1084 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
1086 if (!(*errors
& SM_ERR_RPL_F
))
1088 if (*chptr
->mode
.forward
== '\0')
1089 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
1091 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
1092 *errors
|= SM_ERR_RPL_F
;
1097 #ifndef FORWARD_OPERONLY
1098 if(alevel
!= CHFL_CHANOP
)
1100 if(!(*errors
& SM_ERR_NOOPS
))
1101 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1102 me
.name
, source_p
->name
, chptr
->chname
);
1103 *errors
|= SM_ERR_NOOPS
;
1107 if(!IsOper(source_p
) && !IsServer(source_p
))
1109 if(!(*errors
& SM_ERR_NOPRIVS
))
1110 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
1111 *errors
|= SM_ERR_NOPRIVS
;
1116 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1119 if(dir
== MODE_ADD
&& parc
> *parn
)
1121 forward
= parv
[(*parn
)];
1124 if(EmptyString(forward
))
1126 if(!check_channel_name(forward
) ||
1127 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1129 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1132 /* don't forward to inconsistent target -- jilles */
1133 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
1135 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
1136 form_str(ERR_BADCHANNAME
), forward
);
1139 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1141 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1142 form_str(ERR_NOSUCHCHANNEL
), forward
);
1145 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1147 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1148 get_channel_access(source_p
, msptr
) != CHFL_CHANOP
)
1150 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1151 me
.name
, source_p
->name
, targptr
->chname
);
1156 rb_strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1158 mode_changes
[mode_count
].letter
= c
;
1159 mode_changes
[mode_count
].dir
= MODE_ADD
;
1160 mode_changes
[mode_count
].caps
= 0;
1161 mode_changes
[mode_count
].nocaps
= 0;
1162 mode_changes
[mode_count
].mems
= ConfigChannel
.use_forward
? ALL_MEMBERS
: ONLY_SERVERS
;
1163 mode_changes
[mode_count
].id
= NULL
;
1164 mode_changes
[mode_count
++].arg
= forward
;
1166 else if(dir
== MODE_DEL
)
1168 if(!(*chptr
->mode
.forward
))
1171 *chptr
->mode
.forward
= '\0';
1173 mode_changes
[mode_count
].letter
= c
;
1174 mode_changes
[mode_count
].dir
= MODE_DEL
;
1175 mode_changes
[mode_count
].caps
= 0;
1176 mode_changes
[mode_count
].nocaps
= 0;
1177 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1178 mode_changes
[mode_count
].id
= NULL
;
1179 mode_changes
[mode_count
++].arg
= NULL
;
1184 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1185 int alevel
, int parc
, int *parn
,
1186 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1190 if(alevel
!= CHFL_CHANOP
)
1192 if(!(*errors
& SM_ERR_NOOPS
))
1193 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1194 me
.name
, source_p
->name
, chptr
->chname
);
1195 *errors
|= SM_ERR_NOOPS
;
1199 if(dir
== MODE_QUERY
)
1202 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1205 if((dir
== MODE_ADD
) && parc
> *parn
)
1207 key
= LOCAL_COPY(parv
[(*parn
)]);
1210 if(MyClient(source_p
))
1213 fix_key_remote(key
);
1215 if(EmptyString(key
))
1218 s_assert(key
[0] != ' ');
1219 rb_strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1221 mode_changes
[mode_count
].letter
= c
;
1222 mode_changes
[mode_count
].dir
= MODE_ADD
;
1223 mode_changes
[mode_count
].caps
= 0;
1224 mode_changes
[mode_count
].nocaps
= 0;
1225 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1226 mode_changes
[mode_count
].id
= NULL
;
1227 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1229 else if(dir
== MODE_DEL
)
1231 static char splat
[] = "*";
1237 if(!(*chptr
->mode
.key
))
1240 /* hack time. when we get a +k-k mode, the +k arg is
1241 * chptr->mode.key, which the -k sets to \0, so hunt for a
1242 * +k when we get a -k, and set the arg to splat. --anfl
1244 for(i
= 0; i
< mode_count
; i
++)
1246 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1247 mode_changes
[i
].arg
= splat
;
1250 *chptr
->mode
.key
= 0;
1252 mode_changes
[mode_count
].letter
= c
;
1253 mode_changes
[mode_count
].dir
= MODE_DEL
;
1254 mode_changes
[mode_count
].caps
= 0;
1255 mode_changes
[mode_count
].nocaps
= 0;
1256 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1257 mode_changes
[mode_count
].id
= NULL
;
1258 mode_changes
[mode_count
++].arg
= "*";
1263 chm_regonly(struct Client
*source_p
, struct Channel
*chptr
,
1264 int alevel
, int parc
, int *parn
,
1265 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1267 if(alevel
!= CHFL_CHANOP
)
1269 if(!(*errors
& SM_ERR_NOOPS
))
1270 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1271 me
.name
, source_p
->name
, chptr
->chname
);
1272 *errors
|= SM_ERR_NOOPS
;
1276 if(dir
== MODE_QUERY
)
1279 if(((dir
== MODE_ADD
) && (chptr
->mode
.mode
& mode_type
)) ||
1280 ((dir
== MODE_DEL
) && !(chptr
->mode
.mode
& mode_type
)))
1283 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1287 chptr
->mode
.mode
|= mode_type
;
1289 chptr
->mode
.mode
&= ~mode_type
;
1291 mode_changes
[mode_count
].letter
= c
;
1292 mode_changes
[mode_count
].dir
= dir
;
1293 mode_changes
[mode_count
].caps
= CAP_SERVICE
;
1294 mode_changes
[mode_count
].nocaps
= 0;
1295 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1296 mode_changes
[mode_count
].id
= NULL
;
1297 mode_changes
[mode_count
++].arg
= NULL
;
1301 struct ChannelMode chmode_table
[256] =
1303 {chm_nosuch
, 0 }, /* 0x00 */
1304 {chm_nosuch
, 0 }, /* 0x01 */
1305 {chm_nosuch
, 0 }, /* 0x02 */
1306 {chm_nosuch
, 0 }, /* 0x03 */
1307 {chm_nosuch
, 0 }, /* 0x04 */
1308 {chm_nosuch
, 0 }, /* 0x05 */
1309 {chm_nosuch
, 0 }, /* 0x06 */
1310 {chm_nosuch
, 0 }, /* 0x07 */
1311 {chm_nosuch
, 0 }, /* 0x08 */
1312 {chm_nosuch
, 0 }, /* 0x09 */
1313 {chm_nosuch
, 0 }, /* 0x0a */
1314 {chm_nosuch
, 0 }, /* 0x0b */
1315 {chm_nosuch
, 0 }, /* 0x0c */
1316 {chm_nosuch
, 0 }, /* 0x0d */
1317 {chm_nosuch
, 0 }, /* 0x0e */
1318 {chm_nosuch
, 0 }, /* 0x0f */
1319 {chm_nosuch
, 0 }, /* 0x10 */
1320 {chm_nosuch
, 0 }, /* 0x11 */
1321 {chm_nosuch
, 0 }, /* 0x12 */
1322 {chm_nosuch
, 0 }, /* 0x13 */
1323 {chm_nosuch
, 0 }, /* 0x14 */
1324 {chm_nosuch
, 0 }, /* 0x15 */
1325 {chm_nosuch
, 0 }, /* 0x16 */
1326 {chm_nosuch
, 0 }, /* 0x17 */
1327 {chm_nosuch
, 0 }, /* 0x18 */
1328 {chm_nosuch
, 0 }, /* 0x19 */
1329 {chm_nosuch
, 0 }, /* 0x1a */
1330 {chm_nosuch
, 0 }, /* 0x1b */
1331 {chm_nosuch
, 0 }, /* 0x1c */
1332 {chm_nosuch
, 0 }, /* 0x1d */
1333 {chm_nosuch
, 0 }, /* 0x1e */
1334 {chm_nosuch
, 0 }, /* 0x1f */
1335 {chm_nosuch
, 0 }, /* 0x20 */
1336 {chm_nosuch
, 0 }, /* 0x21 */
1337 {chm_nosuch
, 0 }, /* 0x22 */
1338 {chm_nosuch
, 0 }, /* 0x23 */
1339 {chm_nosuch
, 0 }, /* 0x24 */
1340 {chm_nosuch
, 0 }, /* 0x25 */
1341 {chm_nosuch
, 0 }, /* 0x26 */
1342 {chm_nosuch
, 0 }, /* 0x27 */
1343 {chm_nosuch
, 0 }, /* 0x28 */
1344 {chm_nosuch
, 0 }, /* 0x29 */
1345 {chm_nosuch
, 0 }, /* 0x2a */
1346 {chm_nosuch
, 0 }, /* 0x2b */
1347 {chm_nosuch
, 0 }, /* 0x2c */
1348 {chm_nosuch
, 0 }, /* 0x2d */
1349 {chm_nosuch
, 0 }, /* 0x2e */
1350 {chm_nosuch
, 0 }, /* 0x2f */
1351 {chm_nosuch
, 0 }, /* 0x30 */
1352 {chm_nosuch
, 0 }, /* 0x31 */
1353 {chm_nosuch
, 0 }, /* 0x32 */
1354 {chm_nosuch
, 0 }, /* 0x33 */
1355 {chm_nosuch
, 0 }, /* 0x34 */
1356 {chm_nosuch
, 0 }, /* 0x35 */
1357 {chm_nosuch
, 0 }, /* 0x36 */
1358 {chm_nosuch
, 0 }, /* 0x37 */
1359 {chm_nosuch
, 0 }, /* 0x38 */
1360 {chm_nosuch
, 0 }, /* 0x39 */
1361 {chm_nosuch
, 0 }, /* 0x3a */
1362 {chm_nosuch
, 0 }, /* 0x3b */
1363 {chm_nosuch
, 0 }, /* 0x3c */
1364 {chm_nosuch
, 0 }, /* 0x3d */
1365 {chm_nosuch
, 0 }, /* 0x3e */
1366 {chm_nosuch
, 0 }, /* 0x3f */
1368 {chm_nosuch
, 0 }, /* @ */
1369 {chm_nosuch
, 0 }, /* A */
1370 {chm_nosuch
, 0 }, /* B */
1371 {chm_nosuch
, 0 }, /* C */
1372 {chm_nosuch
, 0 }, /* D */
1373 {chm_nosuch
, 0 }, /* E */
1374 {chm_simple
, MODE_FREETARGET
}, /* F */
1375 {chm_nosuch
, 0 }, /* G */
1376 {chm_nosuch
, 0 }, /* H */
1377 {chm_ban
, CHFL_INVEX
}, /* I */
1378 {chm_nosuch
, 0 }, /* J */
1379 {chm_nosuch
, 0 }, /* K */
1380 {chm_staff
, MODE_EXLIMIT
}, /* L */
1381 {chm_nosuch
, 0 }, /* M */
1382 {chm_nosuch
, 0 }, /* N */
1383 {chm_nosuch
, 0 }, /* O */
1384 {chm_staff
, MODE_PERMANENT
}, /* P */
1385 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1386 {chm_nosuch
, 0 }, /* R */
1387 {chm_nosuch
, 0 }, /* S */
1388 {chm_nosuch
, 0 }, /* T */
1389 {chm_nosuch
, 0 }, /* U */
1390 {chm_nosuch
, 0 }, /* V */
1391 {chm_nosuch
, 0 }, /* W */
1392 {chm_nosuch
, 0 }, /* X */
1393 {chm_nosuch
, 0 }, /* Y */
1394 {chm_nosuch
, 0 }, /* Z */
1401 {chm_nosuch
, 0 }, /* a */
1402 {chm_ban
, CHFL_BAN
}, /* b */
1403 {chm_simple
, MODE_NOCOLOR
}, /* c */
1404 {chm_nosuch
, 0 }, /* d */
1405 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1406 {chm_forward
, 0 }, /* f */
1407 {chm_simple
, MODE_FREEINVITE
}, /* g */
1408 {chm_nosuch
, 0 }, /* h */
1409 {chm_simple
, MODE_INVITEONLY
}, /* i */
1410 {chm_throttle
, 0 }, /* j */
1411 {chm_key
, 0 }, /* k */
1412 {chm_limit
, 0 }, /* l */
1413 {chm_simple
, MODE_MODERATED
}, /* m */
1414 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1415 {chm_op
, 0 }, /* o */
1416 {chm_simple
, MODE_PRIVATE
}, /* p */
1417 {chm_ban
, CHFL_QUIET
}, /* q */
1418 {chm_regonly
, MODE_REGONLY
}, /* r */
1419 {chm_simple
, MODE_SECRET
}, /* s */
1420 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1421 {chm_nosuch
, 0 }, /* u */
1422 {chm_voice
, 0 }, /* v */
1423 {chm_nosuch
, 0 }, /* w */
1424 {chm_nosuch
, 0 }, /* x */
1425 {chm_nosuch
, 0 }, /* y */
1426 {chm_simple
, MODE_OPMODERATE
}, /* z */
1428 {chm_nosuch
, 0 }, /* 0x7b */
1429 {chm_nosuch
, 0 }, /* 0x7c */
1430 {chm_nosuch
, 0 }, /* 0x7d */
1431 {chm_nosuch
, 0 }, /* 0x7e */
1432 {chm_nosuch
, 0 }, /* 0x7f */
1434 {chm_nosuch
, 0 }, /* 0x80 */
1435 {chm_nosuch
, 0 }, /* 0x81 */
1436 {chm_nosuch
, 0 }, /* 0x82 */
1437 {chm_nosuch
, 0 }, /* 0x83 */
1438 {chm_nosuch
, 0 }, /* 0x84 */
1439 {chm_nosuch
, 0 }, /* 0x85 */
1440 {chm_nosuch
, 0 }, /* 0x86 */
1441 {chm_nosuch
, 0 }, /* 0x87 */
1442 {chm_nosuch
, 0 }, /* 0x88 */
1443 {chm_nosuch
, 0 }, /* 0x89 */
1444 {chm_nosuch
, 0 }, /* 0x8a */
1445 {chm_nosuch
, 0 }, /* 0x8b */
1446 {chm_nosuch
, 0 }, /* 0x8c */
1447 {chm_nosuch
, 0 }, /* 0x8d */
1448 {chm_nosuch
, 0 }, /* 0x8e */
1449 {chm_nosuch
, 0 }, /* 0x8f */
1451 {chm_nosuch
, 0 }, /* 0x90 */
1452 {chm_nosuch
, 0 }, /* 0x91 */
1453 {chm_nosuch
, 0 }, /* 0x92 */
1454 {chm_nosuch
, 0 }, /* 0x93 */
1455 {chm_nosuch
, 0 }, /* 0x94 */
1456 {chm_nosuch
, 0 }, /* 0x95 */
1457 {chm_nosuch
, 0 }, /* 0x96 */
1458 {chm_nosuch
, 0 }, /* 0x97 */
1459 {chm_nosuch
, 0 }, /* 0x98 */
1460 {chm_nosuch
, 0 }, /* 0x99 */
1461 {chm_nosuch
, 0 }, /* 0x9a */
1462 {chm_nosuch
, 0 }, /* 0x9b */
1463 {chm_nosuch
, 0 }, /* 0x9c */
1464 {chm_nosuch
, 0 }, /* 0x9d */
1465 {chm_nosuch
, 0 }, /* 0x9e */
1466 {chm_nosuch
, 0 }, /* 0x9f */
1468 {chm_nosuch
, 0 }, /* 0xa0 */
1469 {chm_nosuch
, 0 }, /* 0xa1 */
1470 {chm_nosuch
, 0 }, /* 0xa2 */
1471 {chm_nosuch
, 0 }, /* 0xa3 */
1472 {chm_nosuch
, 0 }, /* 0xa4 */
1473 {chm_nosuch
, 0 }, /* 0xa5 */
1474 {chm_nosuch
, 0 }, /* 0xa6 */
1475 {chm_nosuch
, 0 }, /* 0xa7 */
1476 {chm_nosuch
, 0 }, /* 0xa8 */
1477 {chm_nosuch
, 0 }, /* 0xa9 */
1478 {chm_nosuch
, 0 }, /* 0xaa */
1479 {chm_nosuch
, 0 }, /* 0xab */
1480 {chm_nosuch
, 0 }, /* 0xac */
1481 {chm_nosuch
, 0 }, /* 0xad */
1482 {chm_nosuch
, 0 }, /* 0xae */
1483 {chm_nosuch
, 0 }, /* 0xaf */
1485 {chm_nosuch
, 0 }, /* 0xb0 */
1486 {chm_nosuch
, 0 }, /* 0xb1 */
1487 {chm_nosuch
, 0 }, /* 0xb2 */
1488 {chm_nosuch
, 0 }, /* 0xb3 */
1489 {chm_nosuch
, 0 }, /* 0xb4 */
1490 {chm_nosuch
, 0 }, /* 0xb5 */
1491 {chm_nosuch
, 0 }, /* 0xb6 */
1492 {chm_nosuch
, 0 }, /* 0xb7 */
1493 {chm_nosuch
, 0 }, /* 0xb8 */
1494 {chm_nosuch
, 0 }, /* 0xb9 */
1495 {chm_nosuch
, 0 }, /* 0xba */
1496 {chm_nosuch
, 0 }, /* 0xbb */
1497 {chm_nosuch
, 0 }, /* 0xbc */
1498 {chm_nosuch
, 0 }, /* 0xbd */
1499 {chm_nosuch
, 0 }, /* 0xbe */
1500 {chm_nosuch
, 0 }, /* 0xbf */
1502 {chm_nosuch
, 0 }, /* 0xc0 */
1503 {chm_nosuch
, 0 }, /* 0xc1 */
1504 {chm_nosuch
, 0 }, /* 0xc2 */
1505 {chm_nosuch
, 0 }, /* 0xc3 */
1506 {chm_nosuch
, 0 }, /* 0xc4 */
1507 {chm_nosuch
, 0 }, /* 0xc5 */
1508 {chm_nosuch
, 0 }, /* 0xc6 */
1509 {chm_nosuch
, 0 }, /* 0xc7 */
1510 {chm_nosuch
, 0 }, /* 0xc8 */
1511 {chm_nosuch
, 0 }, /* 0xc9 */
1512 {chm_nosuch
, 0 }, /* 0xca */
1513 {chm_nosuch
, 0 }, /* 0xcb */
1514 {chm_nosuch
, 0 }, /* 0xcc */
1515 {chm_nosuch
, 0 }, /* 0xcd */
1516 {chm_nosuch
, 0 }, /* 0xce */
1517 {chm_nosuch
, 0 }, /* 0xcf */
1519 {chm_nosuch
, 0 }, /* 0xd0 */
1520 {chm_nosuch
, 0 }, /* 0xd1 */
1521 {chm_nosuch
, 0 }, /* 0xd2 */
1522 {chm_nosuch
, 0 }, /* 0xd3 */
1523 {chm_nosuch
, 0 }, /* 0xd4 */
1524 {chm_nosuch
, 0 }, /* 0xd5 */
1525 {chm_nosuch
, 0 }, /* 0xd6 */
1526 {chm_nosuch
, 0 }, /* 0xd7 */
1527 {chm_nosuch
, 0 }, /* 0xd8 */
1528 {chm_nosuch
, 0 }, /* 0xd9 */
1529 {chm_nosuch
, 0 }, /* 0xda */
1530 {chm_nosuch
, 0 }, /* 0xdb */
1531 {chm_nosuch
, 0 }, /* 0xdc */
1532 {chm_nosuch
, 0 }, /* 0xdd */
1533 {chm_nosuch
, 0 }, /* 0xde */
1534 {chm_nosuch
, 0 }, /* 0xdf */
1536 {chm_nosuch
, 0 }, /* 0xe0 */
1537 {chm_nosuch
, 0 }, /* 0xe1 */
1538 {chm_nosuch
, 0 }, /* 0xe2 */
1539 {chm_nosuch
, 0 }, /* 0xe3 */
1540 {chm_nosuch
, 0 }, /* 0xe4 */
1541 {chm_nosuch
, 0 }, /* 0xe5 */
1542 {chm_nosuch
, 0 }, /* 0xe6 */
1543 {chm_nosuch
, 0 }, /* 0xe7 */
1544 {chm_nosuch
, 0 }, /* 0xe8 */
1545 {chm_nosuch
, 0 }, /* 0xe9 */
1546 {chm_nosuch
, 0 }, /* 0xea */
1547 {chm_nosuch
, 0 }, /* 0xeb */
1548 {chm_nosuch
, 0 }, /* 0xec */
1549 {chm_nosuch
, 0 }, /* 0xed */
1550 {chm_nosuch
, 0 }, /* 0xee */
1551 {chm_nosuch
, 0 }, /* 0xef */
1553 {chm_nosuch
, 0 }, /* 0xf0 */
1554 {chm_nosuch
, 0 }, /* 0xf1 */
1555 {chm_nosuch
, 0 }, /* 0xf2 */
1556 {chm_nosuch
, 0 }, /* 0xf3 */
1557 {chm_nosuch
, 0 }, /* 0xf4 */
1558 {chm_nosuch
, 0 }, /* 0xf5 */
1559 {chm_nosuch
, 0 }, /* 0xf6 */
1560 {chm_nosuch
, 0 }, /* 0xf7 */
1561 {chm_nosuch
, 0 }, /* 0xf8 */
1562 {chm_nosuch
, 0 }, /* 0xf9 */
1563 {chm_nosuch
, 0 }, /* 0xfa */
1564 {chm_nosuch
, 0 }, /* 0xfb */
1565 {chm_nosuch
, 0 }, /* 0xfc */
1566 {chm_nosuch
, 0 }, /* 0xfd */
1567 {chm_nosuch
, 0 }, /* 0xfe */
1568 {chm_nosuch
, 0 }, /* 0xff */
1573 /* set_channel_mode()
1575 * inputs - client, source, channel, membership pointer, params
1577 * side effects - channel modes/memberships are changed, MODE is issued
1579 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
1582 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
1583 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
1585 static char modebuf
[BUFSIZE
];
1586 static char parabuf
[BUFSIZE
];
1589 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
1595 const char *ml
= parv
[0];
1597 struct Client
*fakesource_p
;
1602 mode_limit_simple
= 0;
1604 alevel
= get_channel_access(source_p
, msptr
);
1606 /* Hide connecting server on netburst -- jilles */
1607 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
1610 fakesource_p
= source_p
;
1612 for(; (c
= *ml
) != 0; ml
++)
1626 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
1629 chmode_table
[(unsigned char) c
].mode_type
);
1634 /* bail out if we have nothing to do... */
1638 if(IsServer(source_p
))
1639 mlen
= rb_sprintf(modebuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
1641 mlen
= rb_sprintf(modebuf
, ":%s!%s@%s MODE %s ",
1642 source_p
->name
, source_p
->username
,
1643 source_p
->host
, chptr
->chname
);
1645 for(j
= 0, flags
= ALL_MEMBERS
; j
< 2; j
++, flags
= ONLY_CHANOPS
)
1648 mbuf
= modebuf
+ mlen
;
1651 paracount
= paralen
= 0;
1654 for(i
= 0; i
< mode_count
; i
++)
1656 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
1659 if(mode_changes
[i
].arg
!= NULL
)
1661 arglen
= strlen(mode_changes
[i
].arg
);
1663 if(arglen
> MODEBUFLEN
- 5)
1669 /* if we're creeping over MAXMODEPARAMSSERV, or over
1670 * bufsize (4 == +/-,modechar,two spaces) send now.
1672 if(mode_changes
[i
].arg
!= NULL
&&
1673 ((paracount
== MAXMODEPARAMSSERV
) ||
1674 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
1679 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
,
1684 paracount
= paralen
= 0;
1686 mbuf
= modebuf
+ mlen
;
1692 if(dir
!= mode_changes
[i
].dir
)
1694 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
1696 dir
= mode_changes
[i
].dir
;
1699 *mbuf
++ = mode_changes
[i
].letter
;
1702 if(mode_changes
[i
].arg
!= NULL
)
1705 len
= rb_sprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
1711 if(paralen
&& parabuf
[paralen
- 1] == ' ')
1712 parabuf
[paralen
- 1] = '\0';
1716 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
, parabuf
);
1719 /* only propagate modes originating locally, or if we're hubbing */
1720 if(MyClient(source_p
) || rb_dlink_list_length(&serv_list
) > 1)
1721 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);