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 $
34 #include "irc_string.h"
35 #include "sprintf_irc.h"
38 #include "s_serv.h" /* captab */
42 #include "s_conf.h" /* ConfigFileEntry, ConfigChannel */
43 #include "s_newconf.h"
47 /* bitmasks for error returns, so we send once per call */
48 #define SM_ERR_NOTS 0x00000001 /* No TS on channel */
49 #define SM_ERR_NOOPS 0x00000002 /* No chan ops */
50 #define SM_ERR_UNKNOWN 0x00000004
51 #define SM_ERR_RPL_C 0x00000008
52 #define SM_ERR_RPL_B 0x00000010
53 #define SM_ERR_RPL_E 0x00000020
54 #define SM_ERR_NOTONCHANNEL 0x00000040 /* Not on channel */
55 #define SM_ERR_RPL_I 0x00000100
56 #define SM_ERR_RPL_D 0x00000200
57 #define SM_ERR_NOPRIVS 0x00000400
58 #define SM_ERR_RPL_Q 0x00000800
59 #define SM_ERR_RPL_F 0x00001000
61 void set_channel_mode(struct Client
*, struct Client
*,
62 struct Channel
*, struct membership
*, int, const char **);
64 int add_id(struct Client
*source_p
, struct Channel
*chptr
,
65 const char *banid
, rb_dlink_list
* list
, long mode_type
);
67 static struct ChModeChange mode_changes
[BUFSIZE
];
68 static int mode_count
;
69 static int mode_limit
;
73 get_channel_access(struct Client
*source_p
, struct membership
*msptr
)
75 if(!MyClient(source_p
) || is_chanop(msptr
))
83 * inputs - client, channel, id to add, type
84 * outputs - 0 on failure, 1 on success
85 * side effects - given id is added to the appropriate list
88 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
,
89 rb_dlink_list
* list
, long mode_type
)
91 struct Ban
*actualBan
;
92 static char who
[USERHOST_REPLYLEN
];
93 char *realban
= LOCAL_COPY(banid
);
96 /* dont let local clients overflow the banlist, or set redundant
99 if(MyClient(source_p
))
101 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
))
103 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
104 me
.name
, source_p
->name
, chptr
->chname
, realban
);
108 RB_DLINK_FOREACH(ptr
, list
->head
)
110 actualBan
= ptr
->data
;
111 if(mask_match(actualBan
->banstr
, realban
))
115 /* dont let remotes set duplicates */
118 RB_DLINK_FOREACH(ptr
, list
->head
)
120 actualBan
= ptr
->data
;
121 if(!irccmp(actualBan
->banstr
, realban
))
127 if(IsPerson(source_p
))
128 rb_sprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
130 strlcpy(who
, source_p
->name
, sizeof(who
));
132 actualBan
= allocate_ban(realban
, who
);
133 actualBan
->when
= rb_current_time();
135 rb_dlinkAdd(actualBan
, &actualBan
->node
, list
);
137 /* invalidate the can_send() cache */
138 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
146 * inputs - channel, id to remove, type
147 * outputs - 0 on failure, 1 on success
148 * side effects - given id is removed from the appropriate list
151 del_id(struct Channel
*chptr
, const char *banid
, rb_dlink_list
* list
, long mode_type
)
156 if(EmptyString(banid
))
159 RB_DLINK_FOREACH(ptr
, list
->head
)
163 if(irccmp(banid
, banptr
->banstr
) == 0)
165 rb_dlinkDelete(&banptr
->node
, list
);
168 /* invalidate the can_send() cache */
169 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
181 * input - string to check
182 * output - pointer to 'fixed' string, or "*" if empty
183 * side effects - any white space found becomes \0
186 check_string(char *s
)
189 static char splat
[] = "*";
206 * inputs - mask to pretty
207 * outputs - better version of the mask
208 * side effects - mask is chopped to limits, and transformed:
216 pretty_mask(const char *idmask
)
218 static char mask_buf
[BUFSIZE
];
220 char *nick
, *user
, *host
;
223 char ne
= 0, ue
= 0, he
= 0; /* save values at nick[NICKLEN], et all */
226 mask
= LOCAL_COPY(idmask
);
227 mask
= check_string(mask
);
230 nick
= user
= host
= splat
;
232 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
235 old_mask_pos
= mask_pos
;
239 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
240 t
= mask_buf
+ old_mask_pos
+ 1;
246 return mask_buf
+ old_mask_pos
;
250 if((t
= strchr(mask
, '@')) != NULL
)
257 if((t
= strchr(mask
, '!')) != NULL
)
272 else if((t
= strchr(mask
, '!')) != NULL
)
281 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
)
292 /* truncate values to max lengths */
293 if(strlen(nick
) > NICKLEN
- 1)
295 ne
= nick
[NICKLEN
- 1];
296 nick
[NICKLEN
- 1] = '\0';
298 if(strlen(user
) > USERLEN
)
301 user
[USERLEN
] = '\0';
303 if(strlen(host
) > HOSTLEN
)
306 host
[HOSTLEN
] = '\0';
309 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
311 /* restore mask, since we may need to use it again later */
317 nick
[NICKLEN
- 1] = ne
;
323 return mask_buf
+ old_mask_pos
;
329 * output - the same key, fixed
330 * side effects - anything below ascii 13 is discarded, ':' discarded,
331 * high ascii is dropped to lower half of ascii table
338 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
341 if(c
!= ':' && c
!= ',' && c
> ' ')
352 * ouput - the same key, fixed
353 * side effects - high ascii dropped to lower half of table,
354 * CR/LF/':' are dropped
357 fix_key_remote(char *arg
)
361 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
364 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
374 * The handlers for each specific mode.
377 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
378 int alevel
, int parc
, int *parn
,
379 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
381 if(*errors
& SM_ERR_UNKNOWN
)
383 *errors
|= SM_ERR_UNKNOWN
;
384 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
388 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
389 int alevel
, int parc
, int *parn
,
390 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
392 if(alevel
!= CHFL_CHANOP
)
394 if(!(*errors
& SM_ERR_NOOPS
))
395 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
396 me
.name
, source_p
->name
, chptr
->chname
);
397 *errors
|= SM_ERR_NOOPS
;
401 /* +ntspmaikl == 9 + MAXMODEPARAMS (4 * +o) */
402 if(MyClient(source_p
) && (++mode_limit
> (9 + MAXMODEPARAMS
)))
406 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
408 /* if +f is disabled, ignore an attempt to set +QF locally */
409 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
410 (c
== 'Q' || c
== 'F'))
413 chptr
->mode
.mode
|= mode_type
;
415 mode_changes
[mode_count
].letter
= c
;
416 mode_changes
[mode_count
].dir
= MODE_ADD
;
417 mode_changes
[mode_count
].caps
= 0;
418 mode_changes
[mode_count
].nocaps
= 0;
419 mode_changes
[mode_count
].id
= NULL
;
420 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
421 mode_changes
[mode_count
++].arg
= NULL
;
423 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
425 chptr
->mode
.mode
&= ~mode_type
;
427 mode_changes
[mode_count
].letter
= c
;
428 mode_changes
[mode_count
].dir
= MODE_DEL
;
429 mode_changes
[mode_count
].caps
= 0;
430 mode_changes
[mode_count
].nocaps
= 0;
431 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
432 mode_changes
[mode_count
].id
= NULL
;
433 mode_changes
[mode_count
++].arg
= NULL
;
438 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
439 int alevel
, int parc
, int *parn
,
440 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
442 if(!IsOper(source_p
) && !IsServer(source_p
))
444 if(!(*errors
& SM_ERR_NOPRIVS
))
445 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
446 *errors
|= SM_ERR_NOPRIVS
;
449 if(MyClient(source_p
) && !IsOperResv(source_p
))
451 if(!(*errors
& SM_ERR_NOPRIVS
))
452 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
453 source_p
->name
, "resv");
454 *errors
|= SM_ERR_NOPRIVS
;
459 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
461 chptr
->mode
.mode
|= mode_type
;
463 mode_changes
[mode_count
].letter
= c
;
464 mode_changes
[mode_count
].dir
= MODE_ADD
;
465 mode_changes
[mode_count
].caps
= 0;
466 mode_changes
[mode_count
].nocaps
= 0;
467 mode_changes
[mode_count
].id
= NULL
;
468 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
469 mode_changes
[mode_count
++].arg
= NULL
;
471 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
473 chptr
->mode
.mode
&= ~mode_type
;
475 mode_changes
[mode_count
].letter
= c
;
476 mode_changes
[mode_count
].dir
= MODE_DEL
;
477 mode_changes
[mode_count
].caps
= 0;
478 mode_changes
[mode_count
].nocaps
= 0;
479 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
480 mode_changes
[mode_count
].id
= NULL
;
481 mode_changes
[mode_count
++].arg
= NULL
;
486 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
487 int alevel
, int parc
, int *parn
,
488 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
491 const char *raw_mask
;
504 list
= &chptr
->banlist
;
505 errorval
= SM_ERR_RPL_B
;
506 rpl_list
= RPL_BANLIST
;
507 rpl_endlist
= RPL_ENDOFBANLIST
;
513 /* if +e is disabled, allow all but +e locally */
514 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
515 ((dir
== MODE_ADD
) && (parc
> *parn
)))
518 list
= &chptr
->exceptlist
;
519 errorval
= SM_ERR_RPL_E
;
520 rpl_list
= RPL_EXCEPTLIST
;
521 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
524 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
531 /* if +I is disabled, allow all but +I locally */
532 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
533 (dir
== MODE_ADD
) && (parc
> *parn
))
536 list
= &chptr
->invexlist
;
537 errorval
= SM_ERR_RPL_I
;
538 rpl_list
= RPL_INVITELIST
;
539 rpl_endlist
= RPL_ENDOFINVITELIST
;
542 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
549 list
= &chptr
->quietlist
;
550 errorval
= SM_ERR_RPL_Q
;
551 rpl_list
= RPL_BANLIST
;
552 rpl_endlist
= RPL_ENDOFBANLIST
;
558 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
563 if(dir
== 0 || parc
<= *parn
)
565 if((*errors
& errorval
) != 0)
569 /* non-ops cant see +eI lists.. */
570 if(alevel
!= CHFL_CHANOP
&& mode_type
!= CHFL_BAN
&&
571 mode_type
!= CHFL_QUIET
)
573 if(!(*errors
& SM_ERR_NOOPS
))
574 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
575 me
.name
, source_p
->name
, chptr
->chname
);
576 *errors
|= SM_ERR_NOOPS
;
580 RB_DLINK_FOREACH(ptr
, list
->head
)
583 sendto_one(source_p
, form_str(rpl_list
),
584 me
.name
, source_p
->name
, chptr
->chname
,
585 banptr
->banstr
, banptr
->who
, banptr
->when
);
587 if (mode_type
== CHFL_QUIET
)
588 sendto_one(source_p
, ":%s %d %s %s :End of Channel Quiet List", me
.name
, rpl_endlist
, source_p
->name
, chptr
->chname
);
590 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
594 if(alevel
!= CHFL_CHANOP
)
596 if(!(*errors
& SM_ERR_NOOPS
))
597 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
598 me
.name
, source_p
->name
, chptr
->chname
);
599 *errors
|= SM_ERR_NOOPS
;
603 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
606 raw_mask
= parv
[(*parn
)];
609 /* empty ban, or starts with ':' which messes up s2s, ignore it */
610 if(EmptyString(raw_mask
) || *raw_mask
== ':')
613 if(!MyClient(source_p
))
615 if(strchr(raw_mask
, ' '))
621 mask
= pretty_mask(raw_mask
);
623 /* we'd have problems parsing this, hyb6 does it too
624 * also make sure it will always fit on a line with channel
627 if(strlen(mask
) > IRCD_MIN(BANLEN
, MODEBUFLEN
- 5))
630 /* if we're adding a NEW id */
633 if (*mask
== '$' && MyClient(source_p
))
635 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
636 /* XXX perhaps return an error message here */
640 /* dont allow local clients to overflow the banlist, dont
641 * let remote servers set duplicate bans
643 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
646 mode_changes
[mode_count
].letter
= c
;
647 mode_changes
[mode_count
].dir
= MODE_ADD
;
648 mode_changes
[mode_count
].caps
= caps
;
649 mode_changes
[mode_count
].nocaps
= 0;
650 mode_changes
[mode_count
].mems
= mems
;
651 mode_changes
[mode_count
].id
= NULL
;
652 mode_changes
[mode_count
++].arg
= mask
;
654 else if(dir
== MODE_DEL
)
656 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
658 /* mask isn't a valid ban, check raw_mask */
659 if(del_id(chptr
, raw_mask
, list
, mode_type
))
663 mode_changes
[mode_count
].letter
= c
;
664 mode_changes
[mode_count
].dir
= MODE_DEL
;
665 mode_changes
[mode_count
].caps
= caps
;
666 mode_changes
[mode_count
].nocaps
= 0;
667 mode_changes
[mode_count
].mems
= mems
;
668 mode_changes
[mode_count
].id
= NULL
;
669 mode_changes
[mode_count
++].arg
= mask
;
674 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
675 int alevel
, int parc
, int *parn
,
676 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
678 struct membership
*mstptr
;
680 struct Client
*targ_p
;
682 if(alevel
!= CHFL_CHANOP
)
684 if(!(*errors
& SM_ERR_NOOPS
))
685 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
686 me
.name
, source_p
->name
, chptr
->chname
);
687 *errors
|= SM_ERR_NOOPS
;
691 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
694 opnick
= parv
[(*parn
)];
698 if(EmptyString(opnick
))
700 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
704 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
709 mstptr
= find_channel_membership(chptr
, targ_p
);
713 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
714 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
715 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
716 *errors
|= SM_ERR_NOTONCHANNEL
;
720 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
725 if(targ_p
== source_p
)
728 mode_changes
[mode_count
].letter
= c
;
729 mode_changes
[mode_count
].dir
= MODE_ADD
;
730 mode_changes
[mode_count
].caps
= 0;
731 mode_changes
[mode_count
].nocaps
= 0;
732 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
733 mode_changes
[mode_count
].id
= targ_p
->id
;
734 mode_changes
[mode_count
].arg
= targ_p
->name
;
735 mode_changes
[mode_count
++].client
= targ_p
;
737 mstptr
->flags
|= CHFL_CHANOP
;
741 if(MyClient(source_p
) && IsService(targ_p
))
743 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
744 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
748 mode_changes
[mode_count
].letter
= c
;
749 mode_changes
[mode_count
].dir
= MODE_DEL
;
750 mode_changes
[mode_count
].caps
= 0;
751 mode_changes
[mode_count
].nocaps
= 0;
752 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
753 mode_changes
[mode_count
].id
= targ_p
->id
;
754 mode_changes
[mode_count
].arg
= targ_p
->name
;
755 mode_changes
[mode_count
++].client
= targ_p
;
757 mstptr
->flags
&= ~CHFL_CHANOP
;
762 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
763 int alevel
, int parc
, int *parn
,
764 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
766 struct membership
*mstptr
;
768 struct Client
*targ_p
;
770 if(alevel
!= CHFL_CHANOP
)
772 if(!(*errors
& SM_ERR_NOOPS
))
773 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
774 me
.name
, source_p
->name
, chptr
->chname
);
775 *errors
|= SM_ERR_NOOPS
;
779 if((dir
== MODE_QUERY
) || parc
<= *parn
)
782 opnick
= parv
[(*parn
)];
786 if(EmptyString(opnick
))
788 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
792 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
797 mstptr
= find_channel_membership(chptr
, targ_p
);
801 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
802 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
803 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
804 *errors
|= SM_ERR_NOTONCHANNEL
;
808 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
813 mode_changes
[mode_count
].letter
= c
;
814 mode_changes
[mode_count
].dir
= MODE_ADD
;
815 mode_changes
[mode_count
].caps
= 0;
816 mode_changes
[mode_count
].nocaps
= 0;
817 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
818 mode_changes
[mode_count
].id
= targ_p
->id
;
819 mode_changes
[mode_count
].arg
= targ_p
->name
;
820 mode_changes
[mode_count
++].client
= targ_p
;
822 mstptr
->flags
|= CHFL_VOICE
;
826 mode_changes
[mode_count
].letter
= 'v';
827 mode_changes
[mode_count
].dir
= MODE_DEL
;
828 mode_changes
[mode_count
].caps
= 0;
829 mode_changes
[mode_count
].nocaps
= 0;
830 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
831 mode_changes
[mode_count
].id
= targ_p
->id
;
832 mode_changes
[mode_count
].arg
= targ_p
->name
;
833 mode_changes
[mode_count
++].client
= targ_p
;
835 mstptr
->flags
&= ~CHFL_VOICE
;
840 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
841 int alevel
, int parc
, int *parn
,
842 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
845 static char limitstr
[30];
848 if(alevel
!= CHFL_CHANOP
)
850 if(!(*errors
& SM_ERR_NOOPS
))
851 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
852 me
.name
, source_p
->name
, chptr
->chname
);
853 *errors
|= SM_ERR_NOOPS
;
857 if(dir
== MODE_QUERY
)
860 if((dir
== MODE_ADD
) && parc
> *parn
)
862 lstr
= parv
[(*parn
)];
865 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
868 rb_sprintf(limitstr
, "%d", limit
);
870 mode_changes
[mode_count
].letter
= c
;
871 mode_changes
[mode_count
].dir
= MODE_ADD
;
872 mode_changes
[mode_count
].caps
= 0;
873 mode_changes
[mode_count
].nocaps
= 0;
874 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
875 mode_changes
[mode_count
].id
= NULL
;
876 mode_changes
[mode_count
++].arg
= limitstr
;
878 chptr
->mode
.limit
= limit
;
880 else if(dir
== MODE_DEL
)
882 if(!chptr
->mode
.limit
)
885 chptr
->mode
.limit
= 0;
887 mode_changes
[mode_count
].letter
= c
;
888 mode_changes
[mode_count
].dir
= MODE_DEL
;
889 mode_changes
[mode_count
].caps
= 0;
890 mode_changes
[mode_count
].nocaps
= 0;
891 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
892 mode_changes
[mode_count
].id
= NULL
;
893 mode_changes
[mode_count
++].arg
= NULL
;
898 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
899 int alevel
, int parc
, int *parn
,
900 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
902 int joins
= 0, timeslice
= 0;
904 if(alevel
!= CHFL_CHANOP
)
906 if(!(*errors
& SM_ERR_NOOPS
))
907 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
908 me
.name
, source_p
->name
, chptr
->chname
);
909 *errors
|= SM_ERR_NOOPS
;
913 if(dir
== MODE_QUERY
)
916 if((dir
== MODE_ADD
) && parc
> *parn
)
918 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
920 if(!joins
|| !timeslice
)
923 mode_changes
[mode_count
].letter
= c
;
924 mode_changes
[mode_count
].dir
= MODE_ADD
;
925 mode_changes
[mode_count
].caps
= 0;
926 mode_changes
[mode_count
].nocaps
= 0;
927 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
928 mode_changes
[mode_count
].id
= NULL
;
929 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
933 chptr
->mode
.join_num
= joins
;
934 chptr
->mode
.join_time
= timeslice
;
936 else if(dir
== MODE_DEL
)
938 if(!chptr
->mode
.join_num
)
941 chptr
->mode
.join_num
= 0;
942 chptr
->mode
.join_time
= 0;
943 chptr
->join_count
= 0;
944 chptr
->join_delta
= 0;
946 mode_changes
[mode_count
].letter
= c
;
947 mode_changes
[mode_count
].dir
= MODE_DEL
;
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
= NULL
;
957 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
958 int alevel
, int parc
, int *parn
,
959 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
961 struct Channel
*targptr
= NULL
;
962 struct membership
*msptr
;
965 /* if +f is disabled, ignore local attempts to set it */
966 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
967 (dir
== MODE_ADD
) && (parc
> *parn
))
970 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
972 if (!(*errors
& SM_ERR_RPL_F
))
974 if (*chptr
->mode
.forward
== '\0')
975 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
977 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
978 *errors
|= SM_ERR_RPL_F
;
983 #ifndef FORWARD_OPERONLY
984 if(alevel
!= CHFL_CHANOP
)
986 if(!(*errors
& SM_ERR_NOOPS
))
987 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
988 me
.name
, source_p
->name
, chptr
->chname
);
989 *errors
|= SM_ERR_NOOPS
;
993 if(!IsOper(source_p
) && !IsServer(source_p
))
995 if(!(*errors
& SM_ERR_NOPRIVS
))
996 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
997 *errors
|= SM_ERR_NOPRIVS
;
1002 if(dir
== MODE_ADD
&& parc
> *parn
)
1004 forward
= parv
[(*parn
)];
1007 if(EmptyString(forward
))
1009 if(!check_channel_name(forward
) ||
1010 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1012 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1015 /* don't forward to inconsistent target -- jilles */
1016 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
1018 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
1019 form_str(ERR_BADCHANNAME
), forward
);
1022 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1024 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1025 form_str(ERR_NOSUCHCHANNEL
), forward
);
1028 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1030 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1031 get_channel_access(source_p
, msptr
) != CHFL_CHANOP
)
1033 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1034 me
.name
, source_p
->name
, targptr
->chname
);
1039 strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1041 mode_changes
[mode_count
].letter
= c
;
1042 mode_changes
[mode_count
].dir
= MODE_ADD
;
1043 mode_changes
[mode_count
].caps
= 0;
1044 mode_changes
[mode_count
].nocaps
= 0;
1045 mode_changes
[mode_count
].mems
= ConfigChannel
.use_forward
? ALL_MEMBERS
: ONLY_SERVERS
;
1046 mode_changes
[mode_count
].id
= NULL
;
1047 mode_changes
[mode_count
++].arg
= forward
;
1049 else if(dir
== MODE_DEL
)
1051 if(!(*chptr
->mode
.forward
))
1054 *chptr
->mode
.forward
= '\0';
1056 mode_changes
[mode_count
].letter
= c
;
1057 mode_changes
[mode_count
].dir
= MODE_DEL
;
1058 mode_changes
[mode_count
].caps
= 0;
1059 mode_changes
[mode_count
].nocaps
= 0;
1060 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1061 mode_changes
[mode_count
].id
= NULL
;
1062 mode_changes
[mode_count
++].arg
= NULL
;
1067 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1068 int alevel
, int parc
, int *parn
,
1069 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1073 if(alevel
!= CHFL_CHANOP
)
1075 if(!(*errors
& SM_ERR_NOOPS
))
1076 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1077 me
.name
, source_p
->name
, chptr
->chname
);
1078 *errors
|= SM_ERR_NOOPS
;
1082 if(dir
== MODE_QUERY
)
1085 if((dir
== MODE_ADD
) && parc
> *parn
)
1087 key
= LOCAL_COPY(parv
[(*parn
)]);
1090 if(MyClient(source_p
))
1093 fix_key_remote(key
);
1095 if(EmptyString(key
))
1098 s_assert(key
[0] != ' ');
1099 strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1101 mode_changes
[mode_count
].letter
= c
;
1102 mode_changes
[mode_count
].dir
= MODE_ADD
;
1103 mode_changes
[mode_count
].caps
= 0;
1104 mode_changes
[mode_count
].nocaps
= 0;
1105 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1106 mode_changes
[mode_count
].id
= NULL
;
1107 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1109 else if(dir
== MODE_DEL
)
1111 static char splat
[] = "*";
1117 if(!(*chptr
->mode
.key
))
1120 /* hack time. when we get a +k-k mode, the +k arg is
1121 * chptr->mode.key, which the -k sets to \0, so hunt for a
1122 * +k when we get a -k, and set the arg to splat. --anfl
1124 for(i
= 0; i
< mode_count
; i
++)
1126 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1127 mode_changes
[i
].arg
= splat
;
1130 *chptr
->mode
.key
= 0;
1132 mode_changes
[mode_count
].letter
= c
;
1133 mode_changes
[mode_count
].dir
= MODE_DEL
;
1134 mode_changes
[mode_count
].caps
= 0;
1135 mode_changes
[mode_count
].nocaps
= 0;
1136 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1137 mode_changes
[mode_count
].id
= NULL
;
1138 mode_changes
[mode_count
++].arg
= "*";
1143 chm_regonly(struct Client
*source_p
, struct Channel
*chptr
,
1144 int alevel
, int parc
, int *parn
,
1145 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1147 if(alevel
!= CHFL_CHANOP
)
1149 if(!(*errors
& SM_ERR_NOOPS
))
1150 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1151 me
.name
, source_p
->name
, chptr
->chname
);
1152 *errors
|= SM_ERR_NOOPS
;
1156 if(dir
== MODE_QUERY
)
1159 if(((dir
== MODE_ADD
) && (chptr
->mode
.mode
& MODE_REGONLY
)) ||
1160 ((dir
== MODE_DEL
) && !(chptr
->mode
.mode
& MODE_REGONLY
)))
1164 chptr
->mode
.mode
|= MODE_REGONLY
;
1166 chptr
->mode
.mode
&= ~MODE_REGONLY
;
1168 mode_changes
[mode_count
].letter
= c
;
1169 mode_changes
[mode_count
].dir
= dir
;
1170 mode_changes
[mode_count
].caps
= CAP_SERVICE
;
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
= NULL
;
1178 struct ChannelMode chmode_table
[256] =
1180 {chm_nosuch
, 0 }, /* 0x00 */
1181 {chm_nosuch
, 0 }, /* 0x01 */
1182 {chm_nosuch
, 0 }, /* 0x02 */
1183 {chm_nosuch
, 0 }, /* 0x03 */
1184 {chm_nosuch
, 0 }, /* 0x04 */
1185 {chm_nosuch
, 0 }, /* 0x05 */
1186 {chm_nosuch
, 0 }, /* 0x06 */
1187 {chm_nosuch
, 0 }, /* 0x07 */
1188 {chm_nosuch
, 0 }, /* 0x08 */
1189 {chm_nosuch
, 0 }, /* 0x09 */
1190 {chm_nosuch
, 0 }, /* 0x0a */
1191 {chm_nosuch
, 0 }, /* 0x0b */
1192 {chm_nosuch
, 0 }, /* 0x0c */
1193 {chm_nosuch
, 0 }, /* 0x0d */
1194 {chm_nosuch
, 0 }, /* 0x0e */
1195 {chm_nosuch
, 0 }, /* 0x0f */
1196 {chm_nosuch
, 0 }, /* 0x10 */
1197 {chm_nosuch
, 0 }, /* 0x11 */
1198 {chm_nosuch
, 0 }, /* 0x12 */
1199 {chm_nosuch
, 0 }, /* 0x13 */
1200 {chm_nosuch
, 0 }, /* 0x14 */
1201 {chm_nosuch
, 0 }, /* 0x15 */
1202 {chm_nosuch
, 0 }, /* 0x16 */
1203 {chm_nosuch
, 0 }, /* 0x17 */
1204 {chm_nosuch
, 0 }, /* 0x18 */
1205 {chm_nosuch
, 0 }, /* 0x19 */
1206 {chm_nosuch
, 0 }, /* 0x1a */
1207 {chm_nosuch
, 0 }, /* 0x1b */
1208 {chm_nosuch
, 0 }, /* 0x1c */
1209 {chm_nosuch
, 0 }, /* 0x1d */
1210 {chm_nosuch
, 0 }, /* 0x1e */
1211 {chm_nosuch
, 0 }, /* 0x1f */
1212 {chm_nosuch
, 0 }, /* 0x20 */
1213 {chm_nosuch
, 0 }, /* 0x21 */
1214 {chm_nosuch
, 0 }, /* 0x22 */
1215 {chm_nosuch
, 0 }, /* 0x23 */
1216 {chm_nosuch
, 0 }, /* 0x24 */
1217 {chm_nosuch
, 0 }, /* 0x25 */
1218 {chm_nosuch
, 0 }, /* 0x26 */
1219 {chm_nosuch
, 0 }, /* 0x27 */
1220 {chm_nosuch
, 0 }, /* 0x28 */
1221 {chm_nosuch
, 0 }, /* 0x29 */
1222 {chm_nosuch
, 0 }, /* 0x2a */
1223 {chm_nosuch
, 0 }, /* 0x2b */
1224 {chm_nosuch
, 0 }, /* 0x2c */
1225 {chm_nosuch
, 0 }, /* 0x2d */
1226 {chm_nosuch
, 0 }, /* 0x2e */
1227 {chm_nosuch
, 0 }, /* 0x2f */
1228 {chm_nosuch
, 0 }, /* 0x30 */
1229 {chm_nosuch
, 0 }, /* 0x31 */
1230 {chm_nosuch
, 0 }, /* 0x32 */
1231 {chm_nosuch
, 0 }, /* 0x33 */
1232 {chm_nosuch
, 0 }, /* 0x34 */
1233 {chm_nosuch
, 0 }, /* 0x35 */
1234 {chm_nosuch
, 0 }, /* 0x36 */
1235 {chm_nosuch
, 0 }, /* 0x37 */
1236 {chm_nosuch
, 0 }, /* 0x38 */
1237 {chm_nosuch
, 0 }, /* 0x39 */
1238 {chm_nosuch
, 0 }, /* 0x3a */
1239 {chm_nosuch
, 0 }, /* 0x3b */
1240 {chm_nosuch
, 0 }, /* 0x3c */
1241 {chm_nosuch
, 0 }, /* 0x3d */
1242 {chm_nosuch
, 0 }, /* 0x3e */
1243 {chm_nosuch
, 0 }, /* 0x3f */
1245 {chm_nosuch
, 0 }, /* @ */
1246 {chm_nosuch
, 0 }, /* A */
1247 {chm_nosuch
, 0 }, /* B */
1248 {chm_nosuch
, 0 }, /* C */
1249 {chm_nosuch
, 0 }, /* D */
1250 {chm_nosuch
, 0 }, /* E */
1251 {chm_simple
, MODE_FREETARGET
}, /* F */
1252 {chm_nosuch
, 0 }, /* G */
1253 {chm_nosuch
, 0 }, /* H */
1254 {chm_ban
, CHFL_INVEX
}, /* I */
1255 {chm_nosuch
, 0 }, /* J */
1256 {chm_nosuch
, 0 }, /* K */
1257 {chm_staff
, MODE_EXLIMIT
}, /* L */
1258 {chm_nosuch
, 0 }, /* M */
1259 {chm_nosuch
, 0 }, /* N */
1260 {chm_nosuch
, 0 }, /* O */
1261 {chm_staff
, MODE_PERMANENT
}, /* P */
1262 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1263 {chm_nosuch
, 0 }, /* R */
1264 {chm_nosuch
, 0 }, /* S */
1265 {chm_nosuch
, 0 }, /* T */
1266 {chm_nosuch
, 0 }, /* U */
1267 {chm_nosuch
, 0 }, /* V */
1268 {chm_nosuch
, 0 }, /* W */
1269 {chm_nosuch
, 0 }, /* X */
1270 {chm_nosuch
, 0 }, /* Y */
1271 {chm_nosuch
, 0 }, /* Z */
1278 {chm_nosuch
, 0 }, /* a */
1279 {chm_ban
, CHFL_BAN
}, /* b */
1280 {chm_simple
, MODE_NOCOLOR
}, /* c */
1281 {chm_nosuch
, 0 }, /* d */
1282 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1283 {chm_forward
, 0 }, /* f */
1284 {chm_simple
, MODE_FREEINVITE
}, /* g */
1285 {chm_nosuch
, 0 }, /* h */
1286 {chm_simple
, MODE_INVITEONLY
}, /* i */
1287 {chm_throttle
, 0 }, /* j */
1288 {chm_key
, 0 }, /* k */
1289 {chm_limit
, 0 }, /* l */
1290 {chm_simple
, MODE_MODERATED
}, /* m */
1291 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1292 {chm_op
, 0 }, /* o */
1293 {chm_simple
, MODE_PRIVATE
}, /* p */
1294 {chm_ban
, CHFL_QUIET
}, /* q */
1295 {chm_regonly
, 0 }, /* r */
1296 {chm_simple
, MODE_SECRET
}, /* s */
1297 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1298 {chm_nosuch
, 0 }, /* u */
1299 {chm_voice
, 0 }, /* v */
1300 {chm_nosuch
, 0 }, /* w */
1301 {chm_nosuch
, 0 }, /* x */
1302 {chm_nosuch
, 0 }, /* y */
1303 {chm_simple
, MODE_OPMODERATE
}, /* z */
1305 {chm_nosuch
, 0 }, /* 0x7b */
1306 {chm_nosuch
, 0 }, /* 0x7c */
1307 {chm_nosuch
, 0 }, /* 0x7d */
1308 {chm_nosuch
, 0 }, /* 0x7e */
1309 {chm_nosuch
, 0 }, /* 0x7f */
1311 {chm_nosuch
, 0 }, /* 0x80 */
1312 {chm_nosuch
, 0 }, /* 0x81 */
1313 {chm_nosuch
, 0 }, /* 0x82 */
1314 {chm_nosuch
, 0 }, /* 0x83 */
1315 {chm_nosuch
, 0 }, /* 0x84 */
1316 {chm_nosuch
, 0 }, /* 0x85 */
1317 {chm_nosuch
, 0 }, /* 0x86 */
1318 {chm_nosuch
, 0 }, /* 0x87 */
1319 {chm_nosuch
, 0 }, /* 0x88 */
1320 {chm_nosuch
, 0 }, /* 0x89 */
1321 {chm_nosuch
, 0 }, /* 0x8a */
1322 {chm_nosuch
, 0 }, /* 0x8b */
1323 {chm_nosuch
, 0 }, /* 0x8c */
1324 {chm_nosuch
, 0 }, /* 0x8d */
1325 {chm_nosuch
, 0 }, /* 0x8e */
1326 {chm_nosuch
, 0 }, /* 0x8f */
1328 {chm_nosuch
, 0 }, /* 0x90 */
1329 {chm_nosuch
, 0 }, /* 0x91 */
1330 {chm_nosuch
, 0 }, /* 0x92 */
1331 {chm_nosuch
, 0 }, /* 0x93 */
1332 {chm_nosuch
, 0 }, /* 0x94 */
1333 {chm_nosuch
, 0 }, /* 0x95 */
1334 {chm_nosuch
, 0 }, /* 0x96 */
1335 {chm_nosuch
, 0 }, /* 0x97 */
1336 {chm_nosuch
, 0 }, /* 0x98 */
1337 {chm_nosuch
, 0 }, /* 0x99 */
1338 {chm_nosuch
, 0 }, /* 0x9a */
1339 {chm_nosuch
, 0 }, /* 0x9b */
1340 {chm_nosuch
, 0 }, /* 0x9c */
1341 {chm_nosuch
, 0 }, /* 0x9d */
1342 {chm_nosuch
, 0 }, /* 0x9e */
1343 {chm_nosuch
, 0 }, /* 0x9f */
1345 {chm_nosuch
, 0 }, /* 0xa0 */
1346 {chm_nosuch
, 0 }, /* 0xa1 */
1347 {chm_nosuch
, 0 }, /* 0xa2 */
1348 {chm_nosuch
, 0 }, /* 0xa3 */
1349 {chm_nosuch
, 0 }, /* 0xa4 */
1350 {chm_nosuch
, 0 }, /* 0xa5 */
1351 {chm_nosuch
, 0 }, /* 0xa6 */
1352 {chm_nosuch
, 0 }, /* 0xa7 */
1353 {chm_nosuch
, 0 }, /* 0xa8 */
1354 {chm_nosuch
, 0 }, /* 0xa9 */
1355 {chm_nosuch
, 0 }, /* 0xaa */
1356 {chm_nosuch
, 0 }, /* 0xab */
1357 {chm_nosuch
, 0 }, /* 0xac */
1358 {chm_nosuch
, 0 }, /* 0xad */
1359 {chm_nosuch
, 0 }, /* 0xae */
1360 {chm_nosuch
, 0 }, /* 0xaf */
1362 {chm_nosuch
, 0 }, /* 0xb0 */
1363 {chm_nosuch
, 0 }, /* 0xb1 */
1364 {chm_nosuch
, 0 }, /* 0xb2 */
1365 {chm_nosuch
, 0 }, /* 0xb3 */
1366 {chm_nosuch
, 0 }, /* 0xb4 */
1367 {chm_nosuch
, 0 }, /* 0xb5 */
1368 {chm_nosuch
, 0 }, /* 0xb6 */
1369 {chm_nosuch
, 0 }, /* 0xb7 */
1370 {chm_nosuch
, 0 }, /* 0xb8 */
1371 {chm_nosuch
, 0 }, /* 0xb9 */
1372 {chm_nosuch
, 0 }, /* 0xba */
1373 {chm_nosuch
, 0 }, /* 0xbb */
1374 {chm_nosuch
, 0 }, /* 0xbc */
1375 {chm_nosuch
, 0 }, /* 0xbd */
1376 {chm_nosuch
, 0 }, /* 0xbe */
1377 {chm_nosuch
, 0 }, /* 0xbf */
1379 {chm_nosuch
, 0 }, /* 0xc0 */
1380 {chm_nosuch
, 0 }, /* 0xc1 */
1381 {chm_nosuch
, 0 }, /* 0xc2 */
1382 {chm_nosuch
, 0 }, /* 0xc3 */
1383 {chm_nosuch
, 0 }, /* 0xc4 */
1384 {chm_nosuch
, 0 }, /* 0xc5 */
1385 {chm_nosuch
, 0 }, /* 0xc6 */
1386 {chm_nosuch
, 0 }, /* 0xc7 */
1387 {chm_nosuch
, 0 }, /* 0xc8 */
1388 {chm_nosuch
, 0 }, /* 0xc9 */
1389 {chm_nosuch
, 0 }, /* 0xca */
1390 {chm_nosuch
, 0 }, /* 0xcb */
1391 {chm_nosuch
, 0 }, /* 0xcc */
1392 {chm_nosuch
, 0 }, /* 0xcd */
1393 {chm_nosuch
, 0 }, /* 0xce */
1394 {chm_nosuch
, 0 }, /* 0xcf */
1396 {chm_nosuch
, 0 }, /* 0xd0 */
1397 {chm_nosuch
, 0 }, /* 0xd1 */
1398 {chm_nosuch
, 0 }, /* 0xd2 */
1399 {chm_nosuch
, 0 }, /* 0xd3 */
1400 {chm_nosuch
, 0 }, /* 0xd4 */
1401 {chm_nosuch
, 0 }, /* 0xd5 */
1402 {chm_nosuch
, 0 }, /* 0xd6 */
1403 {chm_nosuch
, 0 }, /* 0xd7 */
1404 {chm_nosuch
, 0 }, /* 0xd8 */
1405 {chm_nosuch
, 0 }, /* 0xd9 */
1406 {chm_nosuch
, 0 }, /* 0xda */
1407 {chm_nosuch
, 0 }, /* 0xdb */
1408 {chm_nosuch
, 0 }, /* 0xdc */
1409 {chm_nosuch
, 0 }, /* 0xdd */
1410 {chm_nosuch
, 0 }, /* 0xde */
1411 {chm_nosuch
, 0 }, /* 0xdf */
1413 {chm_nosuch
, 0 }, /* 0xe0 */
1414 {chm_nosuch
, 0 }, /* 0xe1 */
1415 {chm_nosuch
, 0 }, /* 0xe2 */
1416 {chm_nosuch
, 0 }, /* 0xe3 */
1417 {chm_nosuch
, 0 }, /* 0xe4 */
1418 {chm_nosuch
, 0 }, /* 0xe5 */
1419 {chm_nosuch
, 0 }, /* 0xe6 */
1420 {chm_nosuch
, 0 }, /* 0xe7 */
1421 {chm_nosuch
, 0 }, /* 0xe8 */
1422 {chm_nosuch
, 0 }, /* 0xe9 */
1423 {chm_nosuch
, 0 }, /* 0xea */
1424 {chm_nosuch
, 0 }, /* 0xeb */
1425 {chm_nosuch
, 0 }, /* 0xec */
1426 {chm_nosuch
, 0 }, /* 0xed */
1427 {chm_nosuch
, 0 }, /* 0xee */
1428 {chm_nosuch
, 0 }, /* 0xef */
1430 {chm_nosuch
, 0 }, /* 0xf0 */
1431 {chm_nosuch
, 0 }, /* 0xf1 */
1432 {chm_nosuch
, 0 }, /* 0xf2 */
1433 {chm_nosuch
, 0 }, /* 0xf3 */
1434 {chm_nosuch
, 0 }, /* 0xf4 */
1435 {chm_nosuch
, 0 }, /* 0xf5 */
1436 {chm_nosuch
, 0 }, /* 0xf6 */
1437 {chm_nosuch
, 0 }, /* 0xf7 */
1438 {chm_nosuch
, 0 }, /* 0xf8 */
1439 {chm_nosuch
, 0 }, /* 0xf9 */
1440 {chm_nosuch
, 0 }, /* 0xfa */
1441 {chm_nosuch
, 0 }, /* 0xfb */
1442 {chm_nosuch
, 0 }, /* 0xfc */
1443 {chm_nosuch
, 0 }, /* 0xfd */
1444 {chm_nosuch
, 0 }, /* 0xfe */
1445 {chm_nosuch
, 0 }, /* 0xff */
1450 /* set_channel_mode()
1452 * inputs - client, source, channel, membership pointer, params
1454 * side effects - channel modes/memberships are changed, MODE is issued
1456 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
1459 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
1460 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
1462 static char modebuf
[BUFSIZE
];
1463 static char parabuf
[BUFSIZE
];
1466 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
1472 const char *ml
= parv
[0];
1474 struct Client
*fakesource_p
;
1480 alevel
= get_channel_access(source_p
, msptr
);
1482 /* Hide connecting server on netburst -- jilles */
1483 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
1486 fakesource_p
= source_p
;
1488 for(; (c
= *ml
) != 0; ml
++)
1502 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
1505 chmode_table
[(unsigned char) c
].mode_type
);
1510 /* bail out if we have nothing to do... */
1514 if(IsServer(source_p
))
1515 mlen
= rb_sprintf(modebuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
1517 mlen
= rb_sprintf(modebuf
, ":%s!%s@%s MODE %s ",
1518 source_p
->name
, source_p
->username
,
1519 source_p
->host
, chptr
->chname
);
1521 for(j
= 0, flags
= ALL_MEMBERS
; j
< 2; j
++, flags
= ONLY_CHANOPS
)
1524 mbuf
= modebuf
+ mlen
;
1527 paracount
= paralen
= 0;
1530 for(i
= 0; i
< mode_count
; i
++)
1532 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
1535 if(mode_changes
[i
].arg
!= NULL
)
1537 arglen
= strlen(mode_changes
[i
].arg
);
1539 if(arglen
> MODEBUFLEN
- 5)
1545 /* if we're creeping over MAXMODEPARAMSSERV, or over
1546 * bufsize (4 == +/-,modechar,two spaces) send now.
1548 if(mode_changes
[i
].arg
!= NULL
&&
1549 ((paracount
== MAXMODEPARAMSSERV
) ||
1550 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
1555 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
,
1560 paracount
= paralen
= 0;
1562 mbuf
= modebuf
+ mlen
;
1568 if(dir
!= mode_changes
[i
].dir
)
1570 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
1572 dir
= mode_changes
[i
].dir
;
1575 *mbuf
++ = mode_changes
[i
].letter
;
1578 if(mode_changes
[i
].arg
!= NULL
)
1581 len
= rb_sprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
1587 if(paralen
&& parabuf
[paralen
- 1] == ' ')
1588 parabuf
[paralen
- 1] = '\0';
1592 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
, parabuf
);
1595 /* only propagate modes originating locally, or if we're hubbing */
1596 if(MyClient(source_p
) || rb_dlink_list_length(&serv_list
) > 1)
1597 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);