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 $
35 #include "irc_string.h"
36 #include "sprintf_irc.h"
39 #include "s_serv.h" /* captab */
43 #include "s_conf.h" /* ConfigFileEntry, ConfigChannel */
44 #include "s_newconf.h"
50 /* bitmasks for error returns, so we send once per call */
51 #define SM_ERR_NOTS 0x00000001 /* No TS on channel */
52 #define SM_ERR_NOOPS 0x00000002 /* No chan ops */
53 #define SM_ERR_UNKNOWN 0x00000004
54 #define SM_ERR_RPL_C 0x00000008
55 #define SM_ERR_RPL_B 0x00000010
56 #define SM_ERR_RPL_E 0x00000020
57 #define SM_ERR_NOTONCHANNEL 0x00000040 /* Not on channel */
58 #define SM_ERR_RPL_I 0x00000100
59 #define SM_ERR_RPL_D 0x00000200
60 #define SM_ERR_NOPRIVS 0x00000400
61 #define SM_ERR_RPL_Q 0x00000800
62 #define SM_ERR_RPL_F 0x00001000
64 void set_channel_mode(struct Client
*, struct Client
*,
65 struct Channel
*, struct membership
*, int, const char **);
67 int add_id(struct Client
*source_p
, struct Channel
*chptr
,
68 const char *banid
, dlink_list
* list
, long mode_type
);
70 static struct ChModeChange mode_changes
[BUFSIZE
];
71 static int mode_count
;
72 static int mode_limit
;
76 get_channel_access(struct Client
*source_p
, struct membership
*msptr
)
78 if(!MyClient(source_p
) || is_chanop(msptr
))
86 * inputs - client, channel, id to add, type
87 * outputs - 0 on failure, 1 on success
88 * side effects - given id is added to the appropriate list
91 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
,
92 dlink_list
* list
, long mode_type
)
94 struct Ban
*actualBan
;
95 static char who
[USERHOST_REPLYLEN
];
96 char *realban
= LOCAL_COPY(banid
);
99 /* dont let local clients overflow the banlist, or set redundant
102 if(MyClient(source_p
))
104 if((dlink_list_length(&chptr
->banlist
) + dlink_list_length(&chptr
->exceptlist
) + dlink_list_length(&chptr
->invexlist
) + dlink_list_length(&chptr
->quietlist
)) >= (chptr
->mode
.mode
& MODE_EXLIMIT
? ConfigChannel
.max_bans_large
: ConfigChannel
.max_bans
))
106 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
107 me
.name
, source_p
->name
, chptr
->chname
, realban
);
111 DLINK_FOREACH(ptr
, list
->head
)
113 actualBan
= ptr
->data
;
114 if(mask_match(actualBan
->banstr
, realban
))
118 /* dont let remotes set duplicates */
121 DLINK_FOREACH(ptr
, list
->head
)
123 actualBan
= ptr
->data
;
124 if(!irccmp(actualBan
->banstr
, realban
))
130 if(IsPerson(source_p
))
131 ircsprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
133 strlcpy(who
, source_p
->name
, sizeof(who
));
135 actualBan
= allocate_ban(realban
, who
);
136 actualBan
->when
= CurrentTime
;
138 dlinkAdd(actualBan
, &actualBan
->node
, list
);
140 /* invalidate the can_send() cache */
141 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
149 * inputs - channel, id to remove, type
150 * outputs - 0 on failure, 1 on success
151 * side effects - given id is removed from the appropriate list
154 del_id(struct Channel
*chptr
, const char *banid
, dlink_list
* list
, long mode_type
)
159 if(EmptyString(banid
))
162 DLINK_FOREACH(ptr
, list
->head
)
166 if(irccmp(banid
, banptr
->banstr
) == 0)
168 dlinkDelete(&banptr
->node
, list
);
171 /* invalidate the can_send() cache */
172 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
184 * input - string to check
185 * output - pointer to 'fixed' string, or "*" if empty
186 * side effects - any white space found becomes \0
189 check_string(char *s
)
192 static char splat
[] = "*";
209 * inputs - mask to pretty
210 * outputs - better version of the mask
211 * side effects - mask is chopped to limits, and transformed:
219 pretty_mask(const char *idmask
)
221 static char mask_buf
[BUFSIZE
];
223 char *nick
, *user
, *host
;
226 char ne
= 0, ue
= 0, he
= 0; /* save values at nick[NICKLEN], et all */
229 mask
= LOCAL_COPY(idmask
);
230 mask
= check_string(mask
);
233 nick
= user
= host
= splat
;
235 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
238 old_mask_pos
= mask_pos
;
242 mask_pos
+= ircsprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
243 t
= mask_buf
+ old_mask_pos
+ 1;
249 return mask_buf
+ old_mask_pos
;
253 if((t
= strchr(mask
, '@')) != NULL
)
260 if((t
= strchr(mask
, '!')) != NULL
)
275 else if((t
= strchr(mask
, '!')) != NULL
)
284 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
)
295 /* truncate values to max lengths */
296 if(strlen(nick
) > NICKLEN
- 1)
298 ne
= nick
[NICKLEN
- 1];
299 nick
[NICKLEN
- 1] = '\0';
301 if(strlen(user
) > USERLEN
)
304 user
[USERLEN
] = '\0';
306 if(strlen(host
) > HOSTLEN
)
309 host
[HOSTLEN
] = '\0';
312 mask_pos
+= ircsprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
314 /* restore mask, since we may need to use it again later */
320 nick
[NICKLEN
- 1] = ne
;
326 return mask_buf
+ old_mask_pos
;
332 * output - the same key, fixed
333 * side effects - anything below ascii 13 is discarded, ':' discarded,
334 * high ascii is dropped to lower half of ascii table
341 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
344 if(c
!= ':' && c
!= ',' && c
> ' ')
355 * ouput - the same key, fixed
356 * side effects - high ascii dropped to lower half of table,
357 * CR/LF/':' are dropped
360 fix_key_remote(char *arg
)
364 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
367 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
377 * The handlers for each specific mode.
380 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
381 int alevel
, int parc
, int *parn
,
382 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
384 if(*errors
& SM_ERR_UNKNOWN
)
386 *errors
|= SM_ERR_UNKNOWN
;
387 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
391 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
392 int alevel
, int parc
, int *parn
,
393 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
395 if(alevel
!= CHFL_CHANOP
)
397 if(!(*errors
& SM_ERR_NOOPS
))
398 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
399 me
.name
, source_p
->name
, chptr
->chname
);
400 *errors
|= SM_ERR_NOOPS
;
404 /* +ntspmaikl == 9 + MAXMODEPARAMS (4 * +o) */
405 if(MyClient(source_p
) && (++mode_limit
> (9 + MAXMODEPARAMS
)))
409 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
411 /* if +f is disabled, ignore an attempt to set +QF locally */
412 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
413 (c
== 'Q' || c
== 'F'))
416 chptr
->mode
.mode
|= mode_type
;
418 mode_changes
[mode_count
].letter
= c
;
419 mode_changes
[mode_count
].dir
= MODE_ADD
;
420 mode_changes
[mode_count
].caps
= 0;
421 mode_changes
[mode_count
].nocaps
= 0;
422 mode_changes
[mode_count
].id
= NULL
;
423 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
424 mode_changes
[mode_count
++].arg
= NULL
;
426 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
428 chptr
->mode
.mode
&= ~mode_type
;
430 mode_changes
[mode_count
].letter
= c
;
431 mode_changes
[mode_count
].dir
= MODE_DEL
;
432 mode_changes
[mode_count
].caps
= 0;
433 mode_changes
[mode_count
].nocaps
= 0;
434 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
435 mode_changes
[mode_count
].id
= NULL
;
436 mode_changes
[mode_count
++].arg
= NULL
;
441 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
442 int alevel
, int parc
, int *parn
,
443 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
445 if(!IsOper(source_p
) && !IsServer(source_p
))
447 if(!(*errors
& SM_ERR_NOPRIVS
))
448 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
449 *errors
|= SM_ERR_NOPRIVS
;
452 if(MyClient(source_p
) && !IsOperResv(source_p
))
454 if(!(*errors
& SM_ERR_NOPRIVS
))
455 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
456 source_p
->name
, "resv");
457 *errors
|= SM_ERR_NOPRIVS
;
462 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
464 chptr
->mode
.mode
|= mode_type
;
466 mode_changes
[mode_count
].letter
= c
;
467 mode_changes
[mode_count
].dir
= MODE_ADD
;
468 mode_changes
[mode_count
].caps
= 0;
469 mode_changes
[mode_count
].nocaps
= 0;
470 mode_changes
[mode_count
].id
= NULL
;
471 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
472 mode_changes
[mode_count
++].arg
= NULL
;
474 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
476 chptr
->mode
.mode
&= ~mode_type
;
478 mode_changes
[mode_count
].letter
= c
;
479 mode_changes
[mode_count
].dir
= MODE_DEL
;
480 mode_changes
[mode_count
].caps
= 0;
481 mode_changes
[mode_count
].nocaps
= 0;
482 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
483 mode_changes
[mode_count
].id
= NULL
;
484 mode_changes
[mode_count
++].arg
= NULL
;
489 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
490 int alevel
, int parc
, int *parn
,
491 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
494 const char *raw_mask
;
507 list
= &chptr
->banlist
;
508 errorval
= SM_ERR_RPL_B
;
509 rpl_list
= RPL_BANLIST
;
510 rpl_endlist
= RPL_ENDOFBANLIST
;
516 /* if +e is disabled, allow all but +e locally */
517 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
518 ((dir
== MODE_ADD
) && (parc
> *parn
)))
521 list
= &chptr
->exceptlist
;
522 errorval
= SM_ERR_RPL_E
;
523 rpl_list
= RPL_EXCEPTLIST
;
524 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
527 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
534 /* if +I is disabled, allow all but +I locally */
535 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
536 (dir
== MODE_ADD
) && (parc
> *parn
))
539 list
= &chptr
->invexlist
;
540 errorval
= SM_ERR_RPL_I
;
541 rpl_list
= RPL_INVITELIST
;
542 rpl_endlist
= RPL_ENDOFINVITELIST
;
545 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
552 list
= &chptr
->quietlist
;
553 errorval
= SM_ERR_RPL_Q
;
554 rpl_list
= RPL_BANLIST
;
555 rpl_endlist
= RPL_ENDOFBANLIST
;
561 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
566 if(dir
== 0 || parc
<= *parn
)
568 if((*errors
& errorval
) != 0)
572 /* non-ops cant see +eI lists.. */
573 if(alevel
!= CHFL_CHANOP
&& mode_type
!= CHFL_BAN
&&
574 mode_type
!= CHFL_QUIET
)
576 if(!(*errors
& SM_ERR_NOOPS
))
577 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
578 me
.name
, source_p
->name
, chptr
->chname
);
579 *errors
|= SM_ERR_NOOPS
;
583 DLINK_FOREACH(ptr
, list
->head
)
586 sendto_one(source_p
, form_str(rpl_list
),
587 me
.name
, source_p
->name
, chptr
->chname
,
588 banptr
->banstr
, banptr
->who
, banptr
->when
);
590 if (mode_type
== CHFL_QUIET
)
591 sendto_one(source_p
, ":%s %d %s %s :End of Channel Quiet List", me
.name
, rpl_endlist
, source_p
->name
, chptr
->chname
);
593 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
597 if(alevel
!= CHFL_CHANOP
)
599 if(!(*errors
& SM_ERR_NOOPS
))
600 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
601 me
.name
, source_p
->name
, chptr
->chname
);
602 *errors
|= SM_ERR_NOOPS
;
606 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
609 raw_mask
= parv
[(*parn
)];
612 /* empty ban, or starts with ':' which messes up s2s, ignore it */
613 if(EmptyString(raw_mask
) || *raw_mask
== ':')
616 if(!MyClient(source_p
))
618 if(strchr(raw_mask
, ' '))
624 mask
= pretty_mask(raw_mask
);
626 /* we'd have problems parsing this, hyb6 does it too
627 * also make sure it will always fit on a line with channel
630 if(strlen(mask
) > IRCD_MIN(BANLEN
, MODEBUFLEN
- 5))
633 /* if we're adding a NEW id */
636 if (*mask
== '$' && MyClient(source_p
))
638 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
639 /* XXX perhaps return an error message here */
643 /* dont allow local clients to overflow the banlist, dont
644 * let remote servers set duplicate bans
646 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
649 mode_changes
[mode_count
].letter
= c
;
650 mode_changes
[mode_count
].dir
= MODE_ADD
;
651 mode_changes
[mode_count
].caps
= caps
;
652 mode_changes
[mode_count
].nocaps
= 0;
653 mode_changes
[mode_count
].mems
= mems
;
654 mode_changes
[mode_count
].id
= NULL
;
655 mode_changes
[mode_count
++].arg
= mask
;
657 else if(dir
== MODE_DEL
)
659 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
661 /* mask isn't a valid ban, check raw_mask */
662 if(del_id(chptr
, raw_mask
, list
, mode_type
))
666 mode_changes
[mode_count
].letter
= c
;
667 mode_changes
[mode_count
].dir
= MODE_DEL
;
668 mode_changes
[mode_count
].caps
= caps
;
669 mode_changes
[mode_count
].nocaps
= 0;
670 mode_changes
[mode_count
].mems
= mems
;
671 mode_changes
[mode_count
].id
= NULL
;
672 mode_changes
[mode_count
++].arg
= mask
;
677 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
678 int alevel
, int parc
, int *parn
,
679 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
681 struct membership
*mstptr
;
683 struct Client
*targ_p
;
685 if(alevel
!= CHFL_CHANOP
)
687 if(!(*errors
& SM_ERR_NOOPS
))
688 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
689 me
.name
, source_p
->name
, chptr
->chname
);
690 *errors
|= SM_ERR_NOOPS
;
694 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
697 opnick
= parv
[(*parn
)];
701 if(EmptyString(opnick
))
703 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
707 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
712 mstptr
= find_channel_membership(chptr
, targ_p
);
716 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
717 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
718 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
719 *errors
|= SM_ERR_NOTONCHANNEL
;
723 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
728 if(targ_p
== source_p
)
731 mode_changes
[mode_count
].letter
= c
;
732 mode_changes
[mode_count
].dir
= MODE_ADD
;
733 mode_changes
[mode_count
].caps
= 0;
734 mode_changes
[mode_count
].nocaps
= 0;
735 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
736 mode_changes
[mode_count
].id
= targ_p
->id
;
737 mode_changes
[mode_count
].arg
= targ_p
->name
;
738 mode_changes
[mode_count
++].client
= targ_p
;
740 mstptr
->flags
|= CHFL_CHANOP
;
741 mstptr
->flags
&= ~CHFL_DEOPPED
;
745 if(MyClient(source_p
) && IsService(targ_p
))
747 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
748 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
752 mode_changes
[mode_count
].letter
= c
;
753 mode_changes
[mode_count
].dir
= MODE_DEL
;
754 mode_changes
[mode_count
].caps
= 0;
755 mode_changes
[mode_count
].nocaps
= 0;
756 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
757 mode_changes
[mode_count
].id
= targ_p
->id
;
758 mode_changes
[mode_count
].arg
= targ_p
->name
;
759 mode_changes
[mode_count
++].client
= targ_p
;
761 mstptr
->flags
&= ~CHFL_CHANOP
;
766 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
767 int alevel
, int parc
, int *parn
,
768 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
770 struct membership
*mstptr
;
772 struct Client
*targ_p
;
774 if(alevel
!= CHFL_CHANOP
)
776 if(!(*errors
& SM_ERR_NOOPS
))
777 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
778 me
.name
, source_p
->name
, chptr
->chname
);
779 *errors
|= SM_ERR_NOOPS
;
783 if((dir
== MODE_QUERY
) || parc
<= *parn
)
786 opnick
= parv
[(*parn
)];
790 if(EmptyString(opnick
))
792 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
796 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
801 mstptr
= find_channel_membership(chptr
, targ_p
);
805 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
806 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
807 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
808 *errors
|= SM_ERR_NOTONCHANNEL
;
812 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
817 mode_changes
[mode_count
].letter
= c
;
818 mode_changes
[mode_count
].dir
= MODE_ADD
;
819 mode_changes
[mode_count
].caps
= 0;
820 mode_changes
[mode_count
].nocaps
= 0;
821 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
822 mode_changes
[mode_count
].id
= targ_p
->id
;
823 mode_changes
[mode_count
].arg
= targ_p
->name
;
824 mode_changes
[mode_count
++].client
= targ_p
;
826 mstptr
->flags
|= CHFL_VOICE
;
830 mode_changes
[mode_count
].letter
= 'v';
831 mode_changes
[mode_count
].dir
= MODE_DEL
;
832 mode_changes
[mode_count
].caps
= 0;
833 mode_changes
[mode_count
].nocaps
= 0;
834 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
835 mode_changes
[mode_count
].id
= targ_p
->id
;
836 mode_changes
[mode_count
].arg
= targ_p
->name
;
837 mode_changes
[mode_count
++].client
= targ_p
;
839 mstptr
->flags
&= ~CHFL_VOICE
;
844 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
845 int alevel
, int parc
, int *parn
,
846 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
849 static char limitstr
[30];
852 if(alevel
!= CHFL_CHANOP
)
854 if(!(*errors
& SM_ERR_NOOPS
))
855 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
856 me
.name
, source_p
->name
, chptr
->chname
);
857 *errors
|= SM_ERR_NOOPS
;
861 if(dir
== MODE_QUERY
)
864 if((dir
== MODE_ADD
) && parc
> *parn
)
866 lstr
= parv
[(*parn
)];
869 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
872 ircsprintf(limitstr
, "%d", limit
);
874 mode_changes
[mode_count
].letter
= c
;
875 mode_changes
[mode_count
].dir
= MODE_ADD
;
876 mode_changes
[mode_count
].caps
= 0;
877 mode_changes
[mode_count
].nocaps
= 0;
878 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
879 mode_changes
[mode_count
].id
= NULL
;
880 mode_changes
[mode_count
++].arg
= limitstr
;
882 chptr
->mode
.limit
= limit
;
884 else if(dir
== MODE_DEL
)
886 if(!chptr
->mode
.limit
)
889 chptr
->mode
.limit
= 0;
891 mode_changes
[mode_count
].letter
= c
;
892 mode_changes
[mode_count
].dir
= MODE_DEL
;
893 mode_changes
[mode_count
].caps
= 0;
894 mode_changes
[mode_count
].nocaps
= 0;
895 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
896 mode_changes
[mode_count
].id
= NULL
;
897 mode_changes
[mode_count
++].arg
= NULL
;
902 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
903 int alevel
, int parc
, int *parn
,
904 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
906 int joins
= 0, timeslice
= 0;
908 if(alevel
!= CHFL_CHANOP
)
910 if(!(*errors
& SM_ERR_NOOPS
))
911 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
912 me
.name
, source_p
->name
, chptr
->chname
);
913 *errors
|= SM_ERR_NOOPS
;
917 if(dir
== MODE_QUERY
)
920 if((dir
== MODE_ADD
) && parc
> *parn
)
922 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
924 if(!joins
|| !timeslice
)
927 mode_changes
[mode_count
].letter
= c
;
928 mode_changes
[mode_count
].dir
= MODE_ADD
;
929 mode_changes
[mode_count
].caps
= 0;
930 mode_changes
[mode_count
].nocaps
= 0;
931 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
932 mode_changes
[mode_count
].id
= NULL
;
933 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
937 chptr
->mode
.join_num
= joins
;
938 chptr
->mode
.join_time
= timeslice
;
940 else if(dir
== MODE_DEL
)
942 if(!chptr
->mode
.join_num
)
945 chptr
->mode
.join_num
= 0;
946 chptr
->mode
.join_time
= 0;
947 chptr
->join_count
= 0;
948 chptr
->join_delta
= 0;
950 mode_changes
[mode_count
].letter
= c
;
951 mode_changes
[mode_count
].dir
= MODE_DEL
;
952 mode_changes
[mode_count
].caps
= 0;
953 mode_changes
[mode_count
].nocaps
= 0;
954 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
955 mode_changes
[mode_count
].id
= NULL
;
956 mode_changes
[mode_count
++].arg
= NULL
;
961 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
962 int alevel
, int parc
, int *parn
,
963 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
965 struct Channel
*targptr
= NULL
;
966 struct membership
*msptr
;
969 /* if +f is disabled, ignore local attempts to set it */
970 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
971 (dir
== MODE_ADD
) && (parc
> *parn
))
974 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
976 if (!(*errors
& SM_ERR_RPL_F
))
978 if (*chptr
->mode
.forward
== '\0')
979 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
981 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
982 *errors
|= SM_ERR_RPL_F
;
987 #ifndef FORWARD_OPERONLY
988 if(alevel
!= CHFL_CHANOP
)
990 if(!(*errors
& SM_ERR_NOOPS
))
991 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
992 me
.name
, source_p
->name
, chptr
->chname
);
993 *errors
|= SM_ERR_NOOPS
;
997 if(!IsOper(source_p
) && !IsServer(source_p
))
999 if(!(*errors
& SM_ERR_NOPRIVS
))
1000 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
1001 *errors
|= SM_ERR_NOPRIVS
;
1006 if(dir
== MODE_ADD
&& parc
> *parn
)
1008 forward
= parv
[(*parn
)];
1011 if(EmptyString(forward
))
1013 if(!check_channel_name(forward
) ||
1014 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1016 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1019 /* don't forward to inconsistent target -- jilles */
1020 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
1022 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
1023 form_str(ERR_BADCHANNAME
), forward
);
1026 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1028 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1029 form_str(ERR_NOSUCHCHANNEL
), forward
);
1032 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1034 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1035 get_channel_access(source_p
, msptr
) != CHFL_CHANOP
)
1037 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1038 me
.name
, source_p
->name
, targptr
->chname
);
1043 strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1045 mode_changes
[mode_count
].letter
= c
;
1046 mode_changes
[mode_count
].dir
= MODE_ADD
;
1047 mode_changes
[mode_count
].caps
= 0;
1048 mode_changes
[mode_count
].nocaps
= 0;
1049 mode_changes
[mode_count
].mems
= ConfigChannel
.use_forward
? ALL_MEMBERS
: ONLY_SERVERS
;
1050 mode_changes
[mode_count
].id
= NULL
;
1051 mode_changes
[mode_count
++].arg
= forward
;
1053 else if(dir
== MODE_DEL
)
1055 if(!(*chptr
->mode
.forward
))
1058 *chptr
->mode
.forward
= '\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_key(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
)
1077 if(alevel
!= CHFL_CHANOP
)
1079 if(!(*errors
& SM_ERR_NOOPS
))
1080 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1081 me
.name
, source_p
->name
, chptr
->chname
);
1082 *errors
|= SM_ERR_NOOPS
;
1086 if(dir
== MODE_QUERY
)
1089 if((dir
== MODE_ADD
) && parc
> *parn
)
1091 key
= LOCAL_COPY(parv
[(*parn
)]);
1094 if(MyClient(source_p
))
1097 fix_key_remote(key
);
1099 if(EmptyString(key
))
1102 s_assert(key
[0] != ' ');
1103 strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1105 mode_changes
[mode_count
].letter
= c
;
1106 mode_changes
[mode_count
].dir
= MODE_ADD
;
1107 mode_changes
[mode_count
].caps
= 0;
1108 mode_changes
[mode_count
].nocaps
= 0;
1109 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1110 mode_changes
[mode_count
].id
= NULL
;
1111 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1113 else if(dir
== MODE_DEL
)
1115 static char splat
[] = "*";
1121 if(!(*chptr
->mode
.key
))
1124 /* hack time. when we get a +k-k mode, the +k arg is
1125 * chptr->mode.key, which the -k sets to \0, so hunt for a
1126 * +k when we get a -k, and set the arg to splat. --anfl
1128 for(i
= 0; i
< mode_count
; i
++)
1130 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1131 mode_changes
[i
].arg
= splat
;
1134 *chptr
->mode
.key
= 0;
1136 mode_changes
[mode_count
].letter
= c
;
1137 mode_changes
[mode_count
].dir
= MODE_DEL
;
1138 mode_changes
[mode_count
].caps
= 0;
1139 mode_changes
[mode_count
].nocaps
= 0;
1140 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1141 mode_changes
[mode_count
].id
= NULL
;
1142 mode_changes
[mode_count
++].arg
= "*";
1147 chm_regonly(struct Client
*source_p
, struct Channel
*chptr
,
1148 int alevel
, int parc
, int *parn
,
1149 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1151 if(alevel
!= CHFL_CHANOP
)
1153 if(!(*errors
& SM_ERR_NOOPS
))
1154 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1155 me
.name
, source_p
->name
, chptr
->chname
);
1156 *errors
|= SM_ERR_NOOPS
;
1160 if(dir
== MODE_QUERY
)
1163 if(((dir
== MODE_ADD
) && (chptr
->mode
.mode
& MODE_REGONLY
)) ||
1164 ((dir
== MODE_DEL
) && !(chptr
->mode
.mode
& MODE_REGONLY
)))
1168 chptr
->mode
.mode
|= MODE_REGONLY
;
1170 chptr
->mode
.mode
&= ~MODE_REGONLY
;
1172 mode_changes
[mode_count
].letter
= c
;
1173 mode_changes
[mode_count
].dir
= dir
;
1174 mode_changes
[mode_count
].caps
= CAP_SERVICE
;
1175 mode_changes
[mode_count
].nocaps
= 0;
1176 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1177 mode_changes
[mode_count
].id
= NULL
;
1178 mode_changes
[mode_count
++].arg
= NULL
;
1182 struct ChannelMode chmode_table
[256] =
1184 {chm_nosuch
, 0 }, /* 0x00 */
1185 {chm_nosuch
, 0 }, /* 0x01 */
1186 {chm_nosuch
, 0 }, /* 0x02 */
1187 {chm_nosuch
, 0 }, /* 0x03 */
1188 {chm_nosuch
, 0 }, /* 0x04 */
1189 {chm_nosuch
, 0 }, /* 0x05 */
1190 {chm_nosuch
, 0 }, /* 0x06 */
1191 {chm_nosuch
, 0 }, /* 0x07 */
1192 {chm_nosuch
, 0 }, /* 0x08 */
1193 {chm_nosuch
, 0 }, /* 0x09 */
1194 {chm_nosuch
, 0 }, /* 0x0a */
1195 {chm_nosuch
, 0 }, /* 0x0b */
1196 {chm_nosuch
, 0 }, /* 0x0c */
1197 {chm_nosuch
, 0 }, /* 0x0d */
1198 {chm_nosuch
, 0 }, /* 0x0e */
1199 {chm_nosuch
, 0 }, /* 0x0f */
1200 {chm_nosuch
, 0 }, /* 0x10 */
1201 {chm_nosuch
, 0 }, /* 0x11 */
1202 {chm_nosuch
, 0 }, /* 0x12 */
1203 {chm_nosuch
, 0 }, /* 0x13 */
1204 {chm_nosuch
, 0 }, /* 0x14 */
1205 {chm_nosuch
, 0 }, /* 0x15 */
1206 {chm_nosuch
, 0 }, /* 0x16 */
1207 {chm_nosuch
, 0 }, /* 0x17 */
1208 {chm_nosuch
, 0 }, /* 0x18 */
1209 {chm_nosuch
, 0 }, /* 0x19 */
1210 {chm_nosuch
, 0 }, /* 0x1a */
1211 {chm_nosuch
, 0 }, /* 0x1b */
1212 {chm_nosuch
, 0 }, /* 0x1c */
1213 {chm_nosuch
, 0 }, /* 0x1d */
1214 {chm_nosuch
, 0 }, /* 0x1e */
1215 {chm_nosuch
, 0 }, /* 0x1f */
1216 {chm_nosuch
, 0 }, /* 0x20 */
1217 {chm_nosuch
, 0 }, /* 0x21 */
1218 {chm_nosuch
, 0 }, /* 0x22 */
1219 {chm_nosuch
, 0 }, /* 0x23 */
1220 {chm_nosuch
, 0 }, /* 0x24 */
1221 {chm_nosuch
, 0 }, /* 0x25 */
1222 {chm_nosuch
, 0 }, /* 0x26 */
1223 {chm_nosuch
, 0 }, /* 0x27 */
1224 {chm_nosuch
, 0 }, /* 0x28 */
1225 {chm_nosuch
, 0 }, /* 0x29 */
1226 {chm_nosuch
, 0 }, /* 0x2a */
1227 {chm_nosuch
, 0 }, /* 0x2b */
1228 {chm_nosuch
, 0 }, /* 0x2c */
1229 {chm_nosuch
, 0 }, /* 0x2d */
1230 {chm_nosuch
, 0 }, /* 0x2e */
1231 {chm_nosuch
, 0 }, /* 0x2f */
1232 {chm_nosuch
, 0 }, /* 0x30 */
1233 {chm_nosuch
, 0 }, /* 0x31 */
1234 {chm_nosuch
, 0 }, /* 0x32 */
1235 {chm_nosuch
, 0 }, /* 0x33 */
1236 {chm_nosuch
, 0 }, /* 0x34 */
1237 {chm_nosuch
, 0 }, /* 0x35 */
1238 {chm_nosuch
, 0 }, /* 0x36 */
1239 {chm_nosuch
, 0 }, /* 0x37 */
1240 {chm_nosuch
, 0 }, /* 0x38 */
1241 {chm_nosuch
, 0 }, /* 0x39 */
1242 {chm_nosuch
, 0 }, /* 0x3a */
1243 {chm_nosuch
, 0 }, /* 0x3b */
1244 {chm_nosuch
, 0 }, /* 0x3c */
1245 {chm_nosuch
, 0 }, /* 0x3d */
1246 {chm_nosuch
, 0 }, /* 0x3e */
1247 {chm_nosuch
, 0 }, /* 0x3f */
1249 {chm_nosuch
, 0 }, /* @ */
1250 {chm_nosuch
, 0 }, /* A */
1251 {chm_nosuch
, 0 }, /* B */
1252 {chm_nosuch
, 0 }, /* C */
1253 {chm_nosuch
, 0 }, /* D */
1254 {chm_nosuch
, 0 }, /* E */
1255 {chm_simple
, MODE_FREETARGET
}, /* F */
1256 {chm_nosuch
, 0 }, /* G */
1257 {chm_nosuch
, 0 }, /* H */
1258 {chm_ban
, CHFL_INVEX
}, /* I */
1259 {chm_nosuch
, 0 }, /* J */
1260 {chm_nosuch
, 0 }, /* K */
1261 {chm_staff
, MODE_EXLIMIT
}, /* L */
1262 {chm_nosuch
, 0 }, /* M */
1263 {chm_nosuch
, 0 }, /* N */
1264 {chm_nosuch
, 0 }, /* O */
1265 {chm_staff
, MODE_PERMANENT
}, /* P */
1266 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1267 {chm_nosuch
, 0 }, /* R */
1268 {chm_nosuch
, 0 }, /* S */
1269 {chm_nosuch
, 0 }, /* T */
1270 {chm_nosuch
, 0 }, /* U */
1271 {chm_nosuch
, 0 }, /* V */
1272 {chm_nosuch
, 0 }, /* W */
1273 {chm_nosuch
, 0 }, /* X */
1274 {chm_nosuch
, 0 }, /* Y */
1275 {chm_nosuch
, 0 }, /* Z */
1282 {chm_nosuch
, 0 }, /* a */
1283 {chm_ban
, CHFL_BAN
}, /* b */
1284 {chm_simple
, MODE_NOCOLOR
}, /* c */
1285 {chm_nosuch
, 0 }, /* d */
1286 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1287 {chm_forward
, 0 }, /* f */
1288 {chm_simple
, MODE_FREEINVITE
}, /* g */
1289 {chm_nosuch
, 0 }, /* h */
1290 {chm_simple
, MODE_INVITEONLY
}, /* i */
1291 {chm_throttle
, 0 }, /* j */
1292 {chm_key
, 0 }, /* k */
1293 {chm_limit
, 0 }, /* l */
1294 {chm_simple
, MODE_MODERATED
}, /* m */
1295 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1296 {chm_op
, 0 }, /* o */
1297 {chm_simple
, MODE_PRIVATE
}, /* p */
1298 {chm_ban
, CHFL_QUIET
}, /* q */
1299 {chm_regonly
, 0 }, /* r */
1300 {chm_simple
, MODE_SECRET
}, /* s */
1301 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1302 {chm_nosuch
, 0 }, /* u */
1303 {chm_voice
, 0 }, /* v */
1304 {chm_nosuch
, 0 }, /* w */
1305 {chm_nosuch
, 0 }, /* x */
1306 {chm_nosuch
, 0 }, /* y */
1307 {chm_simple
, MODE_OPMODERATE
}, /* z */
1309 {chm_nosuch
, 0 }, /* 0x7b */
1310 {chm_nosuch
, 0 }, /* 0x7c */
1311 {chm_nosuch
, 0 }, /* 0x7d */
1312 {chm_nosuch
, 0 }, /* 0x7e */
1313 {chm_nosuch
, 0 }, /* 0x7f */
1315 {chm_nosuch
, 0 }, /* 0x80 */
1316 {chm_nosuch
, 0 }, /* 0x81 */
1317 {chm_nosuch
, 0 }, /* 0x82 */
1318 {chm_nosuch
, 0 }, /* 0x83 */
1319 {chm_nosuch
, 0 }, /* 0x84 */
1320 {chm_nosuch
, 0 }, /* 0x85 */
1321 {chm_nosuch
, 0 }, /* 0x86 */
1322 {chm_nosuch
, 0 }, /* 0x87 */
1323 {chm_nosuch
, 0 }, /* 0x88 */
1324 {chm_nosuch
, 0 }, /* 0x89 */
1325 {chm_nosuch
, 0 }, /* 0x8a */
1326 {chm_nosuch
, 0 }, /* 0x8b */
1327 {chm_nosuch
, 0 }, /* 0x8c */
1328 {chm_nosuch
, 0 }, /* 0x8d */
1329 {chm_nosuch
, 0 }, /* 0x8e */
1330 {chm_nosuch
, 0 }, /* 0x8f */
1332 {chm_nosuch
, 0 }, /* 0x90 */
1333 {chm_nosuch
, 0 }, /* 0x91 */
1334 {chm_nosuch
, 0 }, /* 0x92 */
1335 {chm_nosuch
, 0 }, /* 0x93 */
1336 {chm_nosuch
, 0 }, /* 0x94 */
1337 {chm_nosuch
, 0 }, /* 0x95 */
1338 {chm_nosuch
, 0 }, /* 0x96 */
1339 {chm_nosuch
, 0 }, /* 0x97 */
1340 {chm_nosuch
, 0 }, /* 0x98 */
1341 {chm_nosuch
, 0 }, /* 0x99 */
1342 {chm_nosuch
, 0 }, /* 0x9a */
1343 {chm_nosuch
, 0 }, /* 0x9b */
1344 {chm_nosuch
, 0 }, /* 0x9c */
1345 {chm_nosuch
, 0 }, /* 0x9d */
1346 {chm_nosuch
, 0 }, /* 0x9e */
1347 {chm_nosuch
, 0 }, /* 0x9f */
1349 {chm_nosuch
, 0 }, /* 0xa0 */
1350 {chm_nosuch
, 0 }, /* 0xa1 */
1351 {chm_nosuch
, 0 }, /* 0xa2 */
1352 {chm_nosuch
, 0 }, /* 0xa3 */
1353 {chm_nosuch
, 0 }, /* 0xa4 */
1354 {chm_nosuch
, 0 }, /* 0xa5 */
1355 {chm_nosuch
, 0 }, /* 0xa6 */
1356 {chm_nosuch
, 0 }, /* 0xa7 */
1357 {chm_nosuch
, 0 }, /* 0xa8 */
1358 {chm_nosuch
, 0 }, /* 0xa9 */
1359 {chm_nosuch
, 0 }, /* 0xaa */
1360 {chm_nosuch
, 0 }, /* 0xab */
1361 {chm_nosuch
, 0 }, /* 0xac */
1362 {chm_nosuch
, 0 }, /* 0xad */
1363 {chm_nosuch
, 0 }, /* 0xae */
1364 {chm_nosuch
, 0 }, /* 0xaf */
1366 {chm_nosuch
, 0 }, /* 0xb0 */
1367 {chm_nosuch
, 0 }, /* 0xb1 */
1368 {chm_nosuch
, 0 }, /* 0xb2 */
1369 {chm_nosuch
, 0 }, /* 0xb3 */
1370 {chm_nosuch
, 0 }, /* 0xb4 */
1371 {chm_nosuch
, 0 }, /* 0xb5 */
1372 {chm_nosuch
, 0 }, /* 0xb6 */
1373 {chm_nosuch
, 0 }, /* 0xb7 */
1374 {chm_nosuch
, 0 }, /* 0xb8 */
1375 {chm_nosuch
, 0 }, /* 0xb9 */
1376 {chm_nosuch
, 0 }, /* 0xba */
1377 {chm_nosuch
, 0 }, /* 0xbb */
1378 {chm_nosuch
, 0 }, /* 0xbc */
1379 {chm_nosuch
, 0 }, /* 0xbd */
1380 {chm_nosuch
, 0 }, /* 0xbe */
1381 {chm_nosuch
, 0 }, /* 0xbf */
1383 {chm_nosuch
, 0 }, /* 0xc0 */
1384 {chm_nosuch
, 0 }, /* 0xc1 */
1385 {chm_nosuch
, 0 }, /* 0xc2 */
1386 {chm_nosuch
, 0 }, /* 0xc3 */
1387 {chm_nosuch
, 0 }, /* 0xc4 */
1388 {chm_nosuch
, 0 }, /* 0xc5 */
1389 {chm_nosuch
, 0 }, /* 0xc6 */
1390 {chm_nosuch
, 0 }, /* 0xc7 */
1391 {chm_nosuch
, 0 }, /* 0xc8 */
1392 {chm_nosuch
, 0 }, /* 0xc9 */
1393 {chm_nosuch
, 0 }, /* 0xca */
1394 {chm_nosuch
, 0 }, /* 0xcb */
1395 {chm_nosuch
, 0 }, /* 0xcc */
1396 {chm_nosuch
, 0 }, /* 0xcd */
1397 {chm_nosuch
, 0 }, /* 0xce */
1398 {chm_nosuch
, 0 }, /* 0xcf */
1400 {chm_nosuch
, 0 }, /* 0xd0 */
1401 {chm_nosuch
, 0 }, /* 0xd1 */
1402 {chm_nosuch
, 0 }, /* 0xd2 */
1403 {chm_nosuch
, 0 }, /* 0xd3 */
1404 {chm_nosuch
, 0 }, /* 0xd4 */
1405 {chm_nosuch
, 0 }, /* 0xd5 */
1406 {chm_nosuch
, 0 }, /* 0xd6 */
1407 {chm_nosuch
, 0 }, /* 0xd7 */
1408 {chm_nosuch
, 0 }, /* 0xd8 */
1409 {chm_nosuch
, 0 }, /* 0xd9 */
1410 {chm_nosuch
, 0 }, /* 0xda */
1411 {chm_nosuch
, 0 }, /* 0xdb */
1412 {chm_nosuch
, 0 }, /* 0xdc */
1413 {chm_nosuch
, 0 }, /* 0xdd */
1414 {chm_nosuch
, 0 }, /* 0xde */
1415 {chm_nosuch
, 0 }, /* 0xdf */
1417 {chm_nosuch
, 0 }, /* 0xe0 */
1418 {chm_nosuch
, 0 }, /* 0xe1 */
1419 {chm_nosuch
, 0 }, /* 0xe2 */
1420 {chm_nosuch
, 0 }, /* 0xe3 */
1421 {chm_nosuch
, 0 }, /* 0xe4 */
1422 {chm_nosuch
, 0 }, /* 0xe5 */
1423 {chm_nosuch
, 0 }, /* 0xe6 */
1424 {chm_nosuch
, 0 }, /* 0xe7 */
1425 {chm_nosuch
, 0 }, /* 0xe8 */
1426 {chm_nosuch
, 0 }, /* 0xe9 */
1427 {chm_nosuch
, 0 }, /* 0xea */
1428 {chm_nosuch
, 0 }, /* 0xeb */
1429 {chm_nosuch
, 0 }, /* 0xec */
1430 {chm_nosuch
, 0 }, /* 0xed */
1431 {chm_nosuch
, 0 }, /* 0xee */
1432 {chm_nosuch
, 0 }, /* 0xef */
1434 {chm_nosuch
, 0 }, /* 0xf0 */
1435 {chm_nosuch
, 0 }, /* 0xf1 */
1436 {chm_nosuch
, 0 }, /* 0xf2 */
1437 {chm_nosuch
, 0 }, /* 0xf3 */
1438 {chm_nosuch
, 0 }, /* 0xf4 */
1439 {chm_nosuch
, 0 }, /* 0xf5 */
1440 {chm_nosuch
, 0 }, /* 0xf6 */
1441 {chm_nosuch
, 0 }, /* 0xf7 */
1442 {chm_nosuch
, 0 }, /* 0xf8 */
1443 {chm_nosuch
, 0 }, /* 0xf9 */
1444 {chm_nosuch
, 0 }, /* 0xfa */
1445 {chm_nosuch
, 0 }, /* 0xfb */
1446 {chm_nosuch
, 0 }, /* 0xfc */
1447 {chm_nosuch
, 0 }, /* 0xfd */
1448 {chm_nosuch
, 0 }, /* 0xfe */
1449 {chm_nosuch
, 0 }, /* 0xff */
1454 /* set_channel_mode()
1456 * inputs - client, source, channel, membership pointer, params
1458 * side effects - channel modes/memberships are changed, MODE is issued
1460 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
1463 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
1464 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
1466 static char modebuf
[BUFSIZE
];
1467 static char parabuf
[BUFSIZE
];
1470 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
1476 const char *ml
= parv
[0];
1478 struct Client
*fakesource_p
;
1484 alevel
= get_channel_access(source_p
, msptr
);
1486 /* Hide connecting server on netburst -- jilles */
1487 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
1490 fakesource_p
= source_p
;
1492 for(; (c
= *ml
) != 0; ml
++)
1506 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
1509 chmode_table
[(unsigned char) c
].mode_type
);
1514 /* bail out if we have nothing to do... */
1518 if(IsServer(source_p
))
1519 mlen
= ircsprintf(modebuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
1521 mlen
= ircsprintf(modebuf
, ":%s!%s@%s MODE %s ",
1522 source_p
->name
, source_p
->username
,
1523 source_p
->host
, chptr
->chname
);
1525 for(j
= 0, flags
= ALL_MEMBERS
; j
< 2; j
++, flags
= ONLY_CHANOPS
)
1528 mbuf
= modebuf
+ mlen
;
1531 paracount
= paralen
= 0;
1534 for(i
= 0; i
< mode_count
; i
++)
1536 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
1539 if(mode_changes
[i
].arg
!= NULL
)
1541 arglen
= strlen(mode_changes
[i
].arg
);
1543 if(arglen
> MODEBUFLEN
- 5)
1549 /* if we're creeping over MAXMODEPARAMSSERV, or over
1550 * bufsize (4 == +/-,modechar,two spaces) send now.
1552 if(mode_changes
[i
].arg
!= NULL
&&
1553 ((paracount
== MAXMODEPARAMSSERV
) ||
1554 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
1559 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
,
1564 paracount
= paralen
= 0;
1566 mbuf
= modebuf
+ mlen
;
1572 if(dir
!= mode_changes
[i
].dir
)
1574 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
1576 dir
= mode_changes
[i
].dir
;
1579 *mbuf
++ = mode_changes
[i
].letter
;
1582 if(mode_changes
[i
].arg
!= NULL
)
1585 len
= ircsprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
1591 if(paralen
&& parabuf
[paralen
- 1] == ' ')
1592 parabuf
[paralen
- 1] = '\0';
1596 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
, parabuf
);
1599 /* only propagate modes originating locally, or if we're hubbing */
1600 if(MyClient(source_p
) || dlink_list_length(&serv_list
) > 1)
1601 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);