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
33 #include "irc_string.h"
34 #include "sprintf_irc.h"
37 #include "s_serv.h" /* captab */
41 #include "s_conf.h" /* ConfigFileEntry, ConfigChannel */
42 #include "s_newconf.h"
48 /* bitmasks for error returns, so we send once per call */
49 #define SM_ERR_NOTS 0x00000001 /* No TS on channel */
50 #define SM_ERR_NOOPS 0x00000002 /* No chan ops */
51 #define SM_ERR_UNKNOWN 0x00000004
52 #define SM_ERR_RPL_C 0x00000008
53 #define SM_ERR_RPL_B 0x00000010
54 #define SM_ERR_RPL_E 0x00000020
55 #define SM_ERR_NOTONCHANNEL 0x00000040 /* Not on channel */
56 #define SM_ERR_RPL_I 0x00000100
57 #define SM_ERR_RPL_D 0x00000200
58 #define SM_ERR_NOPRIVS 0x00000400
59 #define SM_ERR_RPL_Q 0x00000800
60 #define SM_ERR_RPL_F 0x00001000
62 void set_channel_mode(struct Client
*, struct Client
*,
63 struct Channel
*, struct membership
*, int, const char **);
65 int add_id(struct Client
*source_p
, struct Channel
*chptr
,
66 const char *banid
, dlink_list
* list
, long mode_type
);
68 static struct ChModeChange mode_changes
[BUFSIZE
];
69 static int mode_count
;
70 static int mode_limit
;
74 get_channel_access(struct Client
*source_p
, struct membership
*msptr
)
76 if(!MyClient(source_p
) || is_chanop(msptr
))
84 * inputs - client, channel, id to add, type
85 * outputs - 0 on failure, 1 on success
86 * side effects - given id is added to the appropriate list
89 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
,
90 dlink_list
* list
, long mode_type
)
92 struct Ban
*actualBan
;
93 static char who
[BANLEN
];
94 char *realban
= LOCAL_COPY(banid
);
97 /* dont let local clients overflow the banlist, or set redundant
100 if(MyClient(source_p
))
102 if(chptr
->num_mask
>= (chptr
->mode
.banlimit
> 0 ? chptr
->mode
.banlimit
: ConfigChannel
.max_bans
))
104 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
105 me
.name
, source_p
->name
, chptr
->chname
, realban
);
111 DLINK_FOREACH(ptr
, list
->head
)
113 actualBan
= ptr
->data
;
114 if(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
);
141 /* invalidate the can_send() cache */
142 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
150 * inputs - channel, id to remove, type
151 * outputs - 0 on failure, 1 on success
152 * side effects - given id is removed from the appropriate list
155 del_id(struct Channel
*chptr
, const char *banid
, dlink_list
* list
, long mode_type
)
160 if(EmptyString(banid
))
163 DLINK_FOREACH(ptr
, list
->head
)
167 if(irccmp(banid
, banptr
->banstr
) == 0)
169 dlinkDelete(&banptr
->node
, list
);
172 /* num_mask should never be < 0 */
173 if(chptr
->num_mask
> 0)
178 /* invalidate the can_send() cache */
179 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
191 * input - string to check
192 * output - pointer to 'fixed' string, or "*" if empty
193 * side effects - any white space found becomes \0
196 check_string(char *s
)
199 static char splat
[] = "*";
216 * inputs - mask to pretty
217 * outputs - better version of the mask
218 * side effects - mask is chopped to limits, and transformed:
226 pretty_mask(const char *idmask
)
228 static char mask_buf
[BUFSIZE
];
230 char *nick
, *user
, *host
;
233 char ne
= 0, ue
= 0, he
= 0; /* save values at nick[NICKLEN], et all */
236 mask
= LOCAL_COPY(idmask
);
237 mask
= check_string(mask
);
240 nick
= user
= host
= splat
;
242 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
245 old_mask_pos
= mask_pos
;
249 mask_pos
+= ircsprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
250 t
= mask_buf
+ old_mask_pos
+ 1;
256 return mask_buf
+ old_mask_pos
;
260 if((t
= strchr(mask
, '@')) != NULL
)
267 if((t
= strchr(mask
, '!')) != NULL
)
282 else if((t
= strchr(mask
, '!')) != NULL
)
291 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
)
302 /* truncate values to max lengths */
303 if(strlen(nick
) > NICKLEN
- 1)
305 ne
= nick
[NICKLEN
- 1];
306 nick
[NICKLEN
- 1] = '\0';
308 if(strlen(user
) > USERLEN
)
311 user
[USERLEN
] = '\0';
313 if(strlen(host
) > HOSTLEN
)
316 host
[HOSTLEN
] = '\0';
319 mask_pos
+= ircsprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
321 /* restore mask, since we may need to use it again later */
327 nick
[NICKLEN
- 1] = ne
;
333 return mask_buf
+ old_mask_pos
;
339 * output - the same key, fixed
340 * side effects - anything below ascii 13 is discarded, ':' discarded,
341 * high ascii is dropped to lower half of ascii table
348 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
351 if(c
!= ':' && c
!= ',' && c
> ' ')
362 * ouput - the same key, fixed
363 * side effects - high ascii dropped to lower half of table,
364 * CR/LF/':' are dropped
367 fix_key_remote(char *arg
)
371 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
374 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
384 * The handlers for each specific mode.
387 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
388 int alevel
, int parc
, int *parn
,
389 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
391 if(*errors
& SM_ERR_UNKNOWN
)
393 *errors
|= SM_ERR_UNKNOWN
;
394 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
398 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
399 int alevel
, int parc
, int *parn
,
400 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
402 if(alevel
!= CHFL_CHANOP
)
404 if(!(*errors
& SM_ERR_NOOPS
))
405 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
406 me
.name
, source_p
->name
, chptr
->chname
);
407 *errors
|= SM_ERR_NOOPS
;
412 * XXX: This needs 'fixing'; hard coding magic numbers like this is fucking
416 /* +ntspmaikl == 9 + MAXMODEPARAMS (4 * +o) */
417 if(MyClient(source_p
) && (++mode_limit
> (9 + MAXMODEPARAMS
)))
421 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
423 chptr
->mode
.mode
|= mode_type
;
425 mode_changes
[mode_count
].letter
= c
;
426 mode_changes
[mode_count
].dir
= MODE_ADD
;
427 mode_changes
[mode_count
].caps
= 0;
428 mode_changes
[mode_count
].nocaps
= 0;
429 mode_changes
[mode_count
].id
= NULL
;
430 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
431 mode_changes
[mode_count
++].arg
= NULL
;
433 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
435 chptr
->mode
.mode
&= ~mode_type
;
437 mode_changes
[mode_count
].letter
= c
;
438 mode_changes
[mode_count
].dir
= MODE_DEL
;
439 mode_changes
[mode_count
].caps
= 0;
440 mode_changes
[mode_count
].nocaps
= 0;
441 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
442 mode_changes
[mode_count
].id
= NULL
;
443 mode_changes
[mode_count
++].arg
= NULL
;
448 chm_staff(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(!IsServer(source_p
) && MyClient(source_p
) && !IsOperCModes(source_p
))
454 if(!(*errors
& SM_ERR_NOPRIVS
))
457 sendto_one(source_p
, form_str(ERR_NOPRIVS
),
458 me
.name
, source_p
->name
, "set_cmode");
460 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
462 *errors
|= SM_ERR_NOPRIVS
;
467 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
469 chptr
->mode
.mode
|= mode_type
;
471 mode_changes
[mode_count
].letter
= c
;
472 mode_changes
[mode_count
].dir
= MODE_ADD
;
473 mode_changes
[mode_count
].caps
= 0;
474 mode_changes
[mode_count
].nocaps
= 0;
475 mode_changes
[mode_count
].id
= NULL
;
476 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
477 mode_changes
[mode_count
++].arg
= NULL
;
479 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
481 chptr
->mode
.mode
&= ~mode_type
;
483 mode_changes
[mode_count
].letter
= c
;
484 mode_changes
[mode_count
].dir
= MODE_DEL
;
485 mode_changes
[mode_count
].caps
= 0;
486 mode_changes
[mode_count
].nocaps
= 0;
487 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
488 mode_changes
[mode_count
].id
= NULL
;
489 mode_changes
[mode_count
++].arg
= NULL
;
494 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
495 int alevel
, int parc
, int *parn
,
496 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
499 const char *raw_mask
;
512 list
= &chptr
->banlist
;
513 errorval
= SM_ERR_RPL_B
;
514 rpl_list
= RPL_BANLIST
;
515 rpl_endlist
= RPL_ENDOFBANLIST
;
521 /* if +e is disabled, allow all but +e locally */
522 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
523 ((dir
== MODE_ADD
) && (parc
> *parn
)))
526 list
= &chptr
->exceptlist
;
527 errorval
= SM_ERR_RPL_E
;
528 rpl_list
= RPL_EXCEPTLIST
;
529 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
532 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
539 /* if +I is disabled, allow all but +I locally */
540 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
541 (dir
== MODE_ADD
) && (parc
> *parn
))
544 list
= &chptr
->invexlist
;
545 errorval
= SM_ERR_RPL_I
;
546 rpl_list
= RPL_INVITELIST
;
547 rpl_endlist
= RPL_ENDOFINVITELIST
;
550 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
557 list
= &chptr
->quietlist
;
558 errorval
= SM_ERR_RPL_Q
;
559 rpl_list
= RPL_BANLIST
;
560 rpl_endlist
= RPL_ENDOFBANLIST
;
566 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
571 if(dir
== 0 || parc
<= *parn
)
573 if((*errors
& errorval
) != 0)
577 /* non-ops cant see +eI lists.. */
578 if(alevel
!= CHFL_CHANOP
&& mode_type
!= CHFL_BAN
&&
579 mode_type
!= CHFL_QUIET
)
581 if(!(*errors
& SM_ERR_NOOPS
))
582 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
583 me
.name
, source_p
->name
, chptr
->chname
);
584 *errors
|= SM_ERR_NOOPS
;
588 DLINK_FOREACH(ptr
, list
->head
)
591 sendto_one(source_p
, form_str(rpl_list
),
592 me
.name
, source_p
->name
, chptr
->chname
,
593 banptr
->banstr
, banptr
->who
, banptr
->when
);
595 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
599 if(alevel
!= CHFL_CHANOP
)
601 if(!(*errors
& SM_ERR_NOOPS
))
602 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
603 me
.name
, source_p
->name
, chptr
->chname
);
604 *errors
|= SM_ERR_NOOPS
;
608 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
611 raw_mask
= parv
[(*parn
)];
614 /* empty ban, or starts with ':' which messes up s2s, ignore it */
615 if(EmptyString(raw_mask
) || *raw_mask
== ':')
618 if(!MyClient(source_p
))
620 if(strchr(raw_mask
, ' '))
626 mask
= pretty_mask(raw_mask
);
628 /* we'd have problems parsing this, hyb6 does it too */
629 if(strlen(mask
) > (MODEBUFLEN
- 2))
632 /* if we're adding a NEW id */
635 if (*mask
== '$' && MyClient(source_p
))
637 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
638 /* XXX perhaps return an error message here */
642 /* dont allow local clients to overflow the banlist, dont
643 * let remote servers set duplicate bans
645 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
648 mode_changes
[mode_count
].letter
= c
;
649 mode_changes
[mode_count
].dir
= MODE_ADD
;
650 mode_changes
[mode_count
].caps
= caps
;
651 mode_changes
[mode_count
].nocaps
= 0;
652 mode_changes
[mode_count
].mems
= mems
;
653 mode_changes
[mode_count
].id
= NULL
;
654 mode_changes
[mode_count
++].arg
= mask
;
656 else if(dir
== MODE_DEL
)
658 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
660 /* mask isn't a valid ban, check raw_mask */
661 if(del_id(chptr
, raw_mask
, list
, mode_type
))
665 mode_changes
[mode_count
].letter
= c
;
666 mode_changes
[mode_count
].dir
= MODE_DEL
;
667 mode_changes
[mode_count
].caps
= caps
;
668 mode_changes
[mode_count
].nocaps
= 0;
669 mode_changes
[mode_count
].mems
= mems
;
670 mode_changes
[mode_count
].id
= NULL
;
671 mode_changes
[mode_count
++].arg
= mask
;
676 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
677 int alevel
, int parc
, int *parn
,
678 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
680 struct membership
*mstptr
;
682 struct Client
*targ_p
;
684 if(alevel
!= CHFL_CHANOP
)
686 if(!(*errors
& SM_ERR_NOOPS
))
687 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
688 me
.name
, source_p
->name
, chptr
->chname
);
689 *errors
|= SM_ERR_NOOPS
;
693 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
696 opnick
= parv
[(*parn
)];
700 if(EmptyString(opnick
))
702 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
706 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
711 mstptr
= find_channel_membership(chptr
, targ_p
);
715 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
716 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
717 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
718 *errors
|= SM_ERR_NOTONCHANNEL
;
722 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
728 * This breaks oper-override users opping themselves.
729 * Presumably a reason though?
730 if(targ_p == source_p)
734 mode_changes
[mode_count
].letter
= c
;
735 mode_changes
[mode_count
].dir
= MODE_ADD
;
736 mode_changes
[mode_count
].caps
= 0;
737 mode_changes
[mode_count
].nocaps
= 0;
738 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
739 mode_changes
[mode_count
].id
= targ_p
->id
;
740 mode_changes
[mode_count
].arg
= targ_p
->name
;
741 mode_changes
[mode_count
++].client
= targ_p
;
743 mstptr
->flags
|= CHFL_CHANOP
;
744 mstptr
->flags
&= ~CHFL_DEOPPED
;
748 if(MyClient(source_p
) && IsService(targ_p
))
750 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
751 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
755 mode_changes
[mode_count
].letter
= c
;
756 mode_changes
[mode_count
].dir
= MODE_DEL
;
757 mode_changes
[mode_count
].caps
= 0;
758 mode_changes
[mode_count
].nocaps
= 0;
759 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
760 mode_changes
[mode_count
].id
= targ_p
->id
;
761 mode_changes
[mode_count
].arg
= targ_p
->name
;
762 mode_changes
[mode_count
++].client
= targ_p
;
764 mstptr
->flags
&= ~CHFL_CHANOP
;
769 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
770 int alevel
, int parc
, int *parn
,
771 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
773 struct membership
*mstptr
;
775 struct Client
*targ_p
;
777 if(alevel
!= CHFL_CHANOP
)
779 if(!(*errors
& SM_ERR_NOOPS
))
780 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
781 me
.name
, source_p
->name
, chptr
->chname
);
782 *errors
|= SM_ERR_NOOPS
;
786 if((dir
== MODE_QUERY
) || parc
<= *parn
)
789 opnick
= parv
[(*parn
)];
793 if(EmptyString(opnick
))
795 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
799 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
804 mstptr
= find_channel_membership(chptr
, targ_p
);
808 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
809 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
810 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
811 *errors
|= SM_ERR_NOTONCHANNEL
;
815 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
820 mode_changes
[mode_count
].letter
= c
;
821 mode_changes
[mode_count
].dir
= MODE_ADD
;
822 mode_changes
[mode_count
].caps
= 0;
823 mode_changes
[mode_count
].nocaps
= 0;
824 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
825 mode_changes
[mode_count
].id
= targ_p
->id
;
826 mode_changes
[mode_count
].arg
= targ_p
->name
;
827 mode_changes
[mode_count
++].client
= targ_p
;
829 mstptr
->flags
|= CHFL_VOICE
;
833 mode_changes
[mode_count
].letter
= 'v';
834 mode_changes
[mode_count
].dir
= MODE_DEL
;
835 mode_changes
[mode_count
].caps
= 0;
836 mode_changes
[mode_count
].nocaps
= 0;
837 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
838 mode_changes
[mode_count
].id
= targ_p
->id
;
839 mode_changes
[mode_count
].arg
= targ_p
->name
;
840 mode_changes
[mode_count
++].client
= targ_p
;
842 mstptr
->flags
&= ~CHFL_VOICE
;
847 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
848 int alevel
, int parc
, int *parn
,
849 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
852 static char limitstr
[30];
855 if(alevel
!= CHFL_CHANOP
)
857 if(!(*errors
& SM_ERR_NOOPS
))
858 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
859 me
.name
, source_p
->name
, chptr
->chname
);
860 *errors
|= SM_ERR_NOOPS
;
864 if(dir
== MODE_QUERY
)
867 if((dir
== MODE_ADD
) && parc
> *parn
)
869 lstr
= parv
[(*parn
)];
872 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
875 ircsprintf(limitstr
, "%d", limit
);
877 mode_changes
[mode_count
].letter
= c
;
878 mode_changes
[mode_count
].dir
= MODE_ADD
;
879 mode_changes
[mode_count
].caps
= 0;
880 mode_changes
[mode_count
].nocaps
= 0;
881 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
882 mode_changes
[mode_count
].id
= NULL
;
883 mode_changes
[mode_count
++].arg
= limitstr
;
885 chptr
->mode
.limit
= limit
;
887 else if(dir
== MODE_DEL
)
889 if(!chptr
->mode
.limit
)
892 chptr
->mode
.limit
= 0;
894 mode_changes
[mode_count
].letter
= c
;
895 mode_changes
[mode_count
].dir
= MODE_DEL
;
896 mode_changes
[mode_count
].caps
= 0;
897 mode_changes
[mode_count
].nocaps
= 0;
898 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
899 mode_changes
[mode_count
].id
= NULL
;
900 mode_changes
[mode_count
++].arg
= NULL
;
905 chm_banlimit(struct Client
*source_p
, struct Channel
*chptr
,
906 int alevel
, int parc
, int *parn
,
907 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
910 static char limitstr
[30];
913 if(!IsServer(source_p
) && MyClient(source_p
) && !IsOperCModes(source_p
))
915 if(!(*errors
& SM_ERR_NOPRIVS
))
918 sendto_one(source_p
, form_str(ERR_NOPRIVS
),
919 me
.name
, source_p
->name
, "set_cmode");
921 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
923 *errors
|= SM_ERR_NOPRIVS
;
927 if(dir
== MODE_QUERY
)
930 if((dir
== MODE_ADD
) && parc
> *parn
)
932 lstr
= parv
[(*parn
)];
935 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
938 ircsprintf(limitstr
, "%d", limit
);
940 mode_changes
[mode_count
].letter
= c
;
941 mode_changes
[mode_count
].dir
= MODE_ADD
;
942 mode_changes
[mode_count
].caps
= 0;
943 mode_changes
[mode_count
].nocaps
= 0;
944 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
945 mode_changes
[mode_count
].id
= NULL
;
946 mode_changes
[mode_count
++].arg
= limitstr
;
948 chptr
->mode
.banlimit
= limit
;
950 else if(dir
== MODE_DEL
)
952 if(!chptr
->mode
.banlimit
)
955 chptr
->mode
.banlimit
= 0;
957 mode_changes
[mode_count
].letter
= c
;
958 mode_changes
[mode_count
].dir
= MODE_DEL
;
959 mode_changes
[mode_count
].caps
= 0;
960 mode_changes
[mode_count
].nocaps
= 0;
961 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
962 mode_changes
[mode_count
].id
= NULL
;
963 mode_changes
[mode_count
++].arg
= NULL
;
968 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
969 int alevel
, int parc
, int *parn
,
970 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
972 int joins
= 0, timeslice
= 0;
974 if(alevel
!= CHFL_CHANOP
)
976 if(!(*errors
& SM_ERR_NOOPS
))
977 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
978 me
.name
, source_p
->name
, chptr
->chname
);
979 *errors
|= SM_ERR_NOOPS
;
983 if(dir
== MODE_QUERY
)
986 if((dir
== MODE_ADD
) && parc
> *parn
)
988 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
990 if(!joins
|| !timeslice
)
993 mode_changes
[mode_count
].letter
= c
;
994 mode_changes
[mode_count
].dir
= MODE_ADD
;
995 mode_changes
[mode_count
].caps
= 0;
996 mode_changes
[mode_count
].nocaps
= 0;
997 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
998 mode_changes
[mode_count
].id
= NULL
;
999 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
1003 chptr
->mode
.join_num
= joins
;
1004 chptr
->mode
.join_time
= timeslice
;
1006 else if(dir
== MODE_DEL
)
1008 if(!chptr
->mode
.join_num
)
1011 chptr
->mode
.join_num
= 0;
1012 chptr
->mode
.join_time
= 0;
1013 chptr
->join_count
= 0;
1014 chptr
->join_delta
= 0;
1016 mode_changes
[mode_count
].letter
= c
;
1017 mode_changes
[mode_count
].dir
= MODE_DEL
;
1018 mode_changes
[mode_count
].caps
= 0;
1019 mode_changes
[mode_count
].nocaps
= 0;
1020 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1021 mode_changes
[mode_count
].id
= NULL
;
1022 mode_changes
[mode_count
++].arg
= NULL
;
1027 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
1028 int alevel
, int parc
, int *parn
,
1029 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1031 struct Channel
*targptr
= NULL
;
1032 struct membership
*msptr
;
1033 const char *forward
;
1035 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
1037 if (!(*errors
& SM_ERR_RPL_F
))
1039 if (*chptr
->mode
.forward
== '\0')
1040 sendto_one(source_p
, ":%s NOTICE %s :%s has no forward channel", me
.name
, source_p
->name
, chptr
->chname
);
1042 sendto_one(source_p
, ":%s NOTICE %s :%s forward channel is %s", me
.name
, source_p
->name
, chptr
->chname
, chptr
->mode
.forward
);
1043 *errors
|= SM_ERR_RPL_F
;
1048 #ifndef FORWARD_OPERONLY
1049 if(alevel
!= CHFL_CHANOP
)
1051 if(!(*errors
& SM_ERR_NOOPS
))
1052 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1053 me
.name
, source_p
->name
, chptr
->chname
);
1054 *errors
|= SM_ERR_NOOPS
;
1058 if(!IsOperCModes(source_p
) && !IsServer(source_p
))
1060 if(!(*errors
& SM_ERR_NOPRIVS
))
1061 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
1062 *errors
|= SM_ERR_NOPRIVS
;
1067 if(dir
== MODE_ADD
&& parc
> *parn
)
1069 forward
= parv
[(*parn
)];
1072 if(EmptyString(forward
))
1074 if(!check_channel_name(forward
) ||
1075 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1077 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1080 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1082 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1083 form_str(ERR_NOSUCHCHANNEL
), forward
);
1086 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1088 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1089 get_channel_access(source_p
, msptr
) != CHFL_CHANOP
)
1091 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1092 me
.name
, source_p
->name
, targptr
->chname
);
1097 strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1099 mode_changes
[mode_count
].letter
= c
;
1100 mode_changes
[mode_count
].dir
= MODE_ADD
;
1101 mode_changes
[mode_count
].caps
= 0;
1102 mode_changes
[mode_count
].nocaps
= 0;
1103 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1104 mode_changes
[mode_count
].id
= NULL
;
1105 mode_changes
[mode_count
++].arg
= forward
;
1107 else if(dir
== MODE_DEL
)
1109 if(!(*chptr
->mode
.forward
))
1112 *chptr
->mode
.forward
= '\0';
1114 mode_changes
[mode_count
].letter
= c
;
1115 mode_changes
[mode_count
].dir
= MODE_DEL
;
1116 mode_changes
[mode_count
].caps
= 0;
1117 mode_changes
[mode_count
].nocaps
= 0;
1118 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1119 mode_changes
[mode_count
].id
= NULL
;
1120 mode_changes
[mode_count
++].arg
= NULL
;
1125 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1126 int alevel
, int parc
, int *parn
,
1127 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1131 if(alevel
!= CHFL_CHANOP
)
1133 if(!(*errors
& SM_ERR_NOOPS
))
1134 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1135 me
.name
, source_p
->name
, chptr
->chname
);
1136 *errors
|= SM_ERR_NOOPS
;
1140 if(dir
== MODE_QUERY
)
1143 if((dir
== MODE_ADD
) && parc
> *parn
)
1145 key
= LOCAL_COPY(parv
[(*parn
)]);
1148 if(MyClient(source_p
))
1151 fix_key_remote(key
);
1153 if(EmptyString(key
))
1156 s_assert(key
[0] != ' ');
1157 strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1159 mode_changes
[mode_count
].letter
= c
;
1160 mode_changes
[mode_count
].dir
= MODE_ADD
;
1161 mode_changes
[mode_count
].caps
= 0;
1162 mode_changes
[mode_count
].nocaps
= 0;
1163 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1164 mode_changes
[mode_count
].id
= NULL
;
1165 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1167 else if(dir
== MODE_DEL
)
1169 static char splat
[] = "*";
1175 if(!(*chptr
->mode
.key
))
1178 /* hack time. when we get a +k-k mode, the +k arg is
1179 * chptr->mode.key, which the -k sets to \0, so hunt for a
1180 * +k when we get a -k, and set the arg to splat. --anfl
1182 for(i
= 0; i
< mode_count
; i
++)
1184 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1185 mode_changes
[i
].arg
= splat
;
1188 *chptr
->mode
.key
= 0;
1190 mode_changes
[mode_count
].letter
= c
;
1191 mode_changes
[mode_count
].dir
= MODE_DEL
;
1192 mode_changes
[mode_count
].caps
= 0;
1193 mode_changes
[mode_count
].nocaps
= 0;
1194 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1195 mode_changes
[mode_count
].id
= NULL
;
1196 mode_changes
[mode_count
++].arg
= "*";
1201 chm_regonly(struct Client
*source_p
, struct Channel
*chptr
,
1202 int alevel
, int parc
, int *parn
,
1203 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1205 if(alevel
!= CHFL_CHANOP
)
1207 if(!(*errors
& SM_ERR_NOOPS
))
1208 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1209 me
.name
, source_p
->name
, chptr
->chname
);
1210 *errors
|= SM_ERR_NOOPS
;
1214 if(dir
== MODE_QUERY
)
1217 if(((dir
== MODE_ADD
) && (chptr
->mode
.mode
& mode_type
)) ||
1218 ((dir
== MODE_DEL
) && !(chptr
->mode
.mode
& mode_type
)))
1222 chptr
->mode
.mode
|= mode_type
;
1224 chptr
->mode
.mode
&= ~mode_type
;
1226 mode_changes
[mode_count
].letter
= c
;
1227 mode_changes
[mode_count
].dir
= dir
;
1228 mode_changes
[mode_count
].caps
= CAP_SERVICE
;
1229 mode_changes
[mode_count
].nocaps
= 0;
1230 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1231 mode_changes
[mode_count
].id
= NULL
;
1232 mode_changes
[mode_count
++].arg
= NULL
;
1236 struct ChannelMode chmode_table
[256] =
1238 {chm_nosuch
, 0 }, /* 0x00 */
1239 {chm_nosuch
, 0 }, /* 0x01 */
1240 {chm_nosuch
, 0 }, /* 0x02 */
1241 {chm_nosuch
, 0 }, /* 0x03 */
1242 {chm_nosuch
, 0 }, /* 0x04 */
1243 {chm_nosuch
, 0 }, /* 0x05 */
1244 {chm_nosuch
, 0 }, /* 0x06 */
1245 {chm_nosuch
, 0 }, /* 0x07 */
1246 {chm_nosuch
, 0 }, /* 0x08 */
1247 {chm_nosuch
, 0 }, /* 0x09 */
1248 {chm_nosuch
, 0 }, /* 0x0a */
1249 {chm_nosuch
, 0 }, /* 0x0b */
1250 {chm_nosuch
, 0 }, /* 0x0c */
1251 {chm_nosuch
, 0 }, /* 0x0d */
1252 {chm_nosuch
, 0 }, /* 0x0e */
1253 {chm_nosuch
, 0 }, /* 0x0f */
1254 {chm_nosuch
, 0 }, /* 0x10 */
1255 {chm_nosuch
, 0 }, /* 0x11 */
1256 {chm_nosuch
, 0 }, /* 0x12 */
1257 {chm_nosuch
, 0 }, /* 0x13 */
1258 {chm_nosuch
, 0 }, /* 0x14 */
1259 {chm_nosuch
, 0 }, /* 0x15 */
1260 {chm_nosuch
, 0 }, /* 0x16 */
1261 {chm_nosuch
, 0 }, /* 0x17 */
1262 {chm_nosuch
, 0 }, /* 0x18 */
1263 {chm_nosuch
, 0 }, /* 0x19 */
1264 {chm_nosuch
, 0 }, /* 0x1a */
1265 {chm_nosuch
, 0 }, /* 0x1b */
1266 {chm_nosuch
, 0 }, /* 0x1c */
1267 {chm_nosuch
, 0 }, /* 0x1d */
1268 {chm_nosuch
, 0 }, /* 0x1e */
1269 {chm_nosuch
, 0 }, /* 0x1f */
1270 {chm_nosuch
, 0 }, /* 0x20 */
1271 {chm_nosuch
, 0 }, /* 0x21 */
1272 {chm_nosuch
, 0 }, /* 0x22 */
1273 {chm_nosuch
, 0 }, /* 0x23 */
1274 {chm_nosuch
, 0 }, /* 0x24 */
1275 {chm_nosuch
, 0 }, /* 0x25 */
1276 {chm_nosuch
, 0 }, /* 0x26 */
1277 {chm_nosuch
, 0 }, /* 0x27 */
1278 {chm_nosuch
, 0 }, /* 0x28 */
1279 {chm_nosuch
, 0 }, /* 0x29 */
1280 {chm_nosuch
, 0 }, /* 0x2a */
1281 {chm_nosuch
, 0 }, /* 0x2b */
1282 {chm_nosuch
, 0 }, /* 0x2c */
1283 {chm_nosuch
, 0 }, /* 0x2d */
1284 {chm_nosuch
, 0 }, /* 0x2e */
1285 {chm_nosuch
, 0 }, /* 0x2f */
1286 {chm_nosuch
, 0 }, /* 0x30 */
1287 {chm_nosuch
, 0 }, /* 0x31 */
1288 {chm_nosuch
, 0 }, /* 0x32 */
1289 {chm_nosuch
, 0 }, /* 0x33 */
1290 {chm_nosuch
, 0 }, /* 0x34 */
1291 {chm_nosuch
, 0 }, /* 0x35 */
1292 {chm_nosuch
, 0 }, /* 0x36 */
1293 {chm_nosuch
, 0 }, /* 0x37 */
1294 {chm_nosuch
, 0 }, /* 0x38 */
1295 {chm_nosuch
, 0 }, /* 0x39 */
1296 {chm_nosuch
, 0 }, /* 0x3a */
1297 {chm_nosuch
, 0 }, /* 0x3b */
1298 {chm_nosuch
, 0 }, /* 0x3c */
1299 {chm_nosuch
, 0 }, /* 0x3d */
1300 {chm_nosuch
, 0 }, /* 0x3e */
1301 {chm_nosuch
, 0 }, /* 0x3f */
1303 {chm_nosuch
, 0 }, /* @ */
1304 {chm_nosuch
, 0 }, /* A */
1305 {chm_nosuch
, 0 }, /* B */
1306 {chm_nosuch
, 0 }, /* C */
1307 {chm_nosuch
, 0 }, /* D */
1308 {chm_nosuch
, 0 }, /* E */
1309 {chm_simple
, MODE_FREETARGET
}, /* F */
1310 {chm_nosuch
, 0 }, /* G */
1311 {chm_nosuch
, 0 }, /* H */
1312 {chm_ban
, CHFL_INVEX
}, /* I */
1313 {chm_nosuch
, 0 }, /* J */
1314 {chm_nosuch
, 0 }, /* K */
1315 {chm_banlimit
,0 }, /* L */
1316 {chm_nosuch
, 0 }, /* M */
1317 {chm_nosuch
, 0 }, /* N */
1318 {chm_nosuch
, 0 }, /* O */
1319 {chm_staff
, MODE_PERMANENT
}, /* P */
1320 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1321 {chm_simple
, MODE_QUIETUNID
}, /* R */
1322 {chm_nosuch
, 0 }, /* S */
1323 {chm_nosuch
, 0 }, /* T */
1324 {chm_nosuch
, 0 }, /* U */
1325 {chm_nosuch
, 0 }, /* V */
1326 {chm_nosuch
, 0 }, /* W */
1327 {chm_nosuch
, 0 }, /* X */
1328 {chm_nosuch
, 0 }, /* Y */
1329 {chm_nosuch
, 0 }, /* Z */
1336 {chm_nosuch
, 0 }, /* a */
1337 {chm_ban
, CHFL_BAN
}, /* b */
1338 {chm_simple
, MODE_NOCOLOR
}, /* c */
1339 {chm_nosuch
, 0 }, /* d */
1340 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1341 {chm_forward
, 0 }, /* f */
1342 {chm_simple
, MODE_FREEINVITE
}, /* g */
1343 {chm_nosuch
, 0 }, /* h */
1344 {chm_simple
, MODE_INVITEONLY
}, /* i */
1345 {chm_throttle
, 0 }, /* j */
1346 {chm_key
, 0 }, /* k */
1347 {chm_limit
, 0 }, /* l */
1348 {chm_simple
, MODE_MODERATED
}, /* m */
1349 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1350 {chm_op
, 0 }, /* o */
1351 {chm_simple
, MODE_PRIVATE
}, /* p */
1352 {chm_ban
, CHFL_QUIET
}, /* q */
1353 {chm_regonly
, MODE_REGONLY
}, /* r */
1354 {chm_simple
, MODE_SECRET
}, /* s */
1355 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1356 {chm_nosuch
, 0 }, /* u */
1357 {chm_voice
, 0 }, /* v */
1358 {chm_nosuch
, 0 }, /* w */
1359 {chm_nosuch
, 0 }, /* x */
1360 {chm_nosuch
, 0 }, /* y */
1361 {chm_simple
, MODE_OPMODERATE
}, /* z */
1363 {chm_nosuch
, 0 }, /* 0x7b */
1364 {chm_nosuch
, 0 }, /* 0x7c */
1365 {chm_nosuch
, 0 }, /* 0x7d */
1366 {chm_nosuch
, 0 }, /* 0x7e */
1367 {chm_nosuch
, 0 }, /* 0x7f */
1369 {chm_nosuch
, 0 }, /* 0x80 */
1370 {chm_nosuch
, 0 }, /* 0x81 */
1371 {chm_nosuch
, 0 }, /* 0x82 */
1372 {chm_nosuch
, 0 }, /* 0x83 */
1373 {chm_nosuch
, 0 }, /* 0x84 */
1374 {chm_nosuch
, 0 }, /* 0x85 */
1375 {chm_nosuch
, 0 }, /* 0x86 */
1376 {chm_nosuch
, 0 }, /* 0x87 */
1377 {chm_nosuch
, 0 }, /* 0x88 */
1378 {chm_nosuch
, 0 }, /* 0x89 */
1379 {chm_nosuch
, 0 }, /* 0x8a */
1380 {chm_nosuch
, 0 }, /* 0x8b */
1381 {chm_nosuch
, 0 }, /* 0x8c */
1382 {chm_nosuch
, 0 }, /* 0x8d */
1383 {chm_nosuch
, 0 }, /* 0x8e */
1384 {chm_nosuch
, 0 }, /* 0x8f */
1386 {chm_nosuch
, 0 }, /* 0x90 */
1387 {chm_nosuch
, 0 }, /* 0x91 */
1388 {chm_nosuch
, 0 }, /* 0x92 */
1389 {chm_nosuch
, 0 }, /* 0x93 */
1390 {chm_nosuch
, 0 }, /* 0x94 */
1391 {chm_nosuch
, 0 }, /* 0x95 */
1392 {chm_nosuch
, 0 }, /* 0x96 */
1393 {chm_nosuch
, 0 }, /* 0x97 */
1394 {chm_nosuch
, 0 }, /* 0x98 */
1395 {chm_nosuch
, 0 }, /* 0x99 */
1396 {chm_nosuch
, 0 }, /* 0x9a */
1397 {chm_nosuch
, 0 }, /* 0x9b */
1398 {chm_nosuch
, 0 }, /* 0x9c */
1399 {chm_nosuch
, 0 }, /* 0x9d */
1400 {chm_nosuch
, 0 }, /* 0x9e */
1401 {chm_nosuch
, 0 }, /* 0x9f */
1403 {chm_nosuch
, 0 }, /* 0xa0 */
1404 {chm_nosuch
, 0 }, /* 0xa1 */
1405 {chm_nosuch
, 0 }, /* 0xa2 */
1406 {chm_nosuch
, 0 }, /* 0xa3 */
1407 {chm_nosuch
, 0 }, /* 0xa4 */
1408 {chm_nosuch
, 0 }, /* 0xa5 */
1409 {chm_nosuch
, 0 }, /* 0xa6 */
1410 {chm_nosuch
, 0 }, /* 0xa7 */
1411 {chm_nosuch
, 0 }, /* 0xa8 */
1412 {chm_nosuch
, 0 }, /* 0xa9 */
1413 {chm_nosuch
, 0 }, /* 0xaa */
1414 {chm_nosuch
, 0 }, /* 0xab */
1415 {chm_nosuch
, 0 }, /* 0xac */
1416 {chm_nosuch
, 0 }, /* 0xad */
1417 {chm_nosuch
, 0 }, /* 0xae */
1418 {chm_nosuch
, 0 }, /* 0xaf */
1420 {chm_nosuch
, 0 }, /* 0xb0 */
1421 {chm_nosuch
, 0 }, /* 0xb1 */
1422 {chm_nosuch
, 0 }, /* 0xb2 */
1423 {chm_nosuch
, 0 }, /* 0xb3 */
1424 {chm_nosuch
, 0 }, /* 0xb4 */
1425 {chm_nosuch
, 0 }, /* 0xb5 */
1426 {chm_nosuch
, 0 }, /* 0xb6 */
1427 {chm_nosuch
, 0 }, /* 0xb7 */
1428 {chm_nosuch
, 0 }, /* 0xb8 */
1429 {chm_nosuch
, 0 }, /* 0xb9 */
1430 {chm_nosuch
, 0 }, /* 0xba */
1431 {chm_nosuch
, 0 }, /* 0xbb */
1432 {chm_nosuch
, 0 }, /* 0xbc */
1433 {chm_nosuch
, 0 }, /* 0xbd */
1434 {chm_nosuch
, 0 }, /* 0xbe */
1435 {chm_nosuch
, 0 }, /* 0xbf */
1437 {chm_nosuch
, 0 }, /* 0xc0 */
1438 {chm_nosuch
, 0 }, /* 0xc1 */
1439 {chm_nosuch
, 0 }, /* 0xc2 */
1440 {chm_nosuch
, 0 }, /* 0xc3 */
1441 {chm_nosuch
, 0 }, /* 0xc4 */
1442 {chm_nosuch
, 0 }, /* 0xc5 */
1443 {chm_nosuch
, 0 }, /* 0xc6 */
1444 {chm_nosuch
, 0 }, /* 0xc7 */
1445 {chm_nosuch
, 0 }, /* 0xc8 */
1446 {chm_nosuch
, 0 }, /* 0xc9 */
1447 {chm_nosuch
, 0 }, /* 0xca */
1448 {chm_nosuch
, 0 }, /* 0xcb */
1449 {chm_nosuch
, 0 }, /* 0xcc */
1450 {chm_nosuch
, 0 }, /* 0xcd */
1451 {chm_nosuch
, 0 }, /* 0xce */
1452 {chm_nosuch
, 0 }, /* 0xcf */
1454 {chm_nosuch
, 0 }, /* 0xd0 */
1455 {chm_nosuch
, 0 }, /* 0xd1 */
1456 {chm_nosuch
, 0 }, /* 0xd2 */
1457 {chm_nosuch
, 0 }, /* 0xd3 */
1458 {chm_nosuch
, 0 }, /* 0xd4 */
1459 {chm_nosuch
, 0 }, /* 0xd5 */
1460 {chm_nosuch
, 0 }, /* 0xd6 */
1461 {chm_nosuch
, 0 }, /* 0xd7 */
1462 {chm_nosuch
, 0 }, /* 0xd8 */
1463 {chm_nosuch
, 0 }, /* 0xd9 */
1464 {chm_nosuch
, 0 }, /* 0xda */
1465 {chm_nosuch
, 0 }, /* 0xdb */
1466 {chm_nosuch
, 0 }, /* 0xdc */
1467 {chm_nosuch
, 0 }, /* 0xdd */
1468 {chm_nosuch
, 0 }, /* 0xde */
1469 {chm_nosuch
, 0 }, /* 0xdf */
1471 {chm_nosuch
, 0 }, /* 0xe0 */
1472 {chm_nosuch
, 0 }, /* 0xe1 */
1473 {chm_nosuch
, 0 }, /* 0xe2 */
1474 {chm_nosuch
, 0 }, /* 0xe3 */
1475 {chm_nosuch
, 0 }, /* 0xe4 */
1476 {chm_nosuch
, 0 }, /* 0xe5 */
1477 {chm_nosuch
, 0 }, /* 0xe6 */
1478 {chm_nosuch
, 0 }, /* 0xe7 */
1479 {chm_nosuch
, 0 }, /* 0xe8 */
1480 {chm_nosuch
, 0 }, /* 0xe9 */
1481 {chm_nosuch
, 0 }, /* 0xea */
1482 {chm_nosuch
, 0 }, /* 0xeb */
1483 {chm_nosuch
, 0 }, /* 0xec */
1484 {chm_nosuch
, 0 }, /* 0xed */
1485 {chm_nosuch
, 0 }, /* 0xee */
1486 {chm_nosuch
, 0 }, /* 0xef */
1488 {chm_nosuch
, 0 }, /* 0xf0 */
1489 {chm_nosuch
, 0 }, /* 0xf1 */
1490 {chm_nosuch
, 0 }, /* 0xf2 */
1491 {chm_nosuch
, 0 }, /* 0xf3 */
1492 {chm_nosuch
, 0 }, /* 0xf4 */
1493 {chm_nosuch
, 0 }, /* 0xf5 */
1494 {chm_nosuch
, 0 }, /* 0xf6 */
1495 {chm_nosuch
, 0 }, /* 0xf7 */
1496 {chm_nosuch
, 0 }, /* 0xf8 */
1497 {chm_nosuch
, 0 }, /* 0xf9 */
1498 {chm_nosuch
, 0 }, /* 0xfa */
1499 {chm_nosuch
, 0 }, /* 0xfb */
1500 {chm_nosuch
, 0 }, /* 0xfc */
1501 {chm_nosuch
, 0 }, /* 0xfd */
1502 {chm_nosuch
, 0 }, /* 0xfe */
1503 {chm_nosuch
, 0 }, /* 0xff */
1508 /* set_channel_mode()
1510 * inputs - client, source, channel, membership pointer, params
1512 * side effects - channel modes/memberships are changed, MODE is issued
1514 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
1517 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
1518 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
1520 static char modebuf
[BUFSIZE
];
1521 static char parabuf
[BUFSIZE
];
1524 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
1530 const char *ml
= parv
[0];
1532 struct Client
*fakesource_p
;
1538 alevel
= get_channel_access(source_p
, msptr
);
1540 /* Hide connecting server on netburst -- jilles */
1541 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
1544 fakesource_p
= source_p
;
1546 for(; (c
= *ml
) != 0; ml
++)
1560 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
1563 chmode_table
[(unsigned char) c
].mode_type
);
1568 /* bail out if we have nothing to do... */
1572 if(IsServer(source_p
))
1573 mlen
= ircsprintf(modebuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
1575 mlen
= ircsprintf(modebuf
, ":%s!%s@%s MODE %s ",
1576 source_p
->name
, source_p
->username
,
1577 source_p
->host
, chptr
->chname
);
1579 for(j
= 0, flags
= ALL_MEMBERS
; j
< 2; j
++, flags
= ONLY_CHANOPS
)
1582 mbuf
= modebuf
+ mlen
;
1585 paracount
= paralen
= 0;
1588 for(i
= 0; i
< mode_count
; i
++)
1590 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
1593 if(mode_changes
[i
].arg
!= NULL
)
1595 arglen
= strlen(mode_changes
[i
].arg
);
1597 if(arglen
> MODEBUFLEN
- 5)
1603 /* if we're creeping over MAXMODEPARAMSSERV, or over
1604 * bufsize (4 == +/-,modechar,two spaces) send now.
1606 if(mode_changes
[i
].arg
!= NULL
&&
1607 ((paracount
== MAXMODEPARAMSSERV
) ||
1608 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
1613 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
,
1618 paracount
= paralen
= 0;
1620 mbuf
= modebuf
+ mlen
;
1626 if(dir
!= mode_changes
[i
].dir
)
1628 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
1630 dir
= mode_changes
[i
].dir
;
1633 *mbuf
++ = mode_changes
[i
].letter
;
1636 if(mode_changes
[i
].arg
!= NULL
)
1639 len
= ircsprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
1645 if(paralen
&& parabuf
[paralen
- 1] == ' ')
1646 parabuf
[paralen
- 1] = '\0';
1650 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
, parabuf
);
1653 /* only propagate modes originating locally, or if we're hubbing */
1654 if(MyClient(source_p
) || dlink_list_length(&serv_list
) > 1)
1655 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);