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 146 2006-11-13 10:45:22Z spb $
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
[BANLEN
];
96 char *realban
= LOCAL_COPY(banid
);
99 /* dont let local clients overflow the banlist, or set redundant
102 if(MyClient(source_p
))
104 if(chptr
->num_mask
>= (chptr
->mode
.banlimit
> 0 ? chptr
->mode
.banlimit
: ConfigChannel
.max_bans
))
106 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
107 me
.name
, source_p
->name
, chptr
->chname
, realban
);
113 DLINK_FOREACH(ptr
, list
->head
)
115 actualBan
= ptr
->data
;
116 if(match(actualBan
->banstr
, realban
))
120 /* dont let remotes set duplicates */
123 DLINK_FOREACH(ptr
, list
->head
)
125 actualBan
= ptr
->data
;
126 if(!irccmp(actualBan
->banstr
, realban
))
132 if(IsPerson(source_p
))
133 ircsprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
135 strlcpy(who
, source_p
->name
, sizeof(who
));
137 actualBan
= allocate_ban(realban
, who
);
138 actualBan
->when
= CurrentTime
;
140 dlinkAdd(actualBan
, &actualBan
->node
, list
);
143 /* invalidate the can_send() cache */
144 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
152 * inputs - channel, id to remove, type
153 * outputs - 0 on failure, 1 on success
154 * side effects - given id is removed from the appropriate list
157 del_id(struct Channel
*chptr
, const char *banid
, dlink_list
* list
, long mode_type
)
162 if(EmptyString(banid
))
165 DLINK_FOREACH(ptr
, list
->head
)
169 if(irccmp(banid
, banptr
->banstr
) == 0)
171 dlinkDelete(&banptr
->node
, list
);
174 /* num_mask should never be < 0 */
175 if(chptr
->num_mask
> 0)
180 /* invalidate the can_send() cache */
181 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
193 * input - string to check
194 * output - pointer to 'fixed' string, or "*" if empty
195 * side effects - any white space found becomes \0
198 check_string(char *s
)
201 static char splat
[] = "*";
218 * inputs - mask to pretty
219 * outputs - better version of the mask
220 * side effects - mask is chopped to limits, and transformed:
228 pretty_mask(const char *idmask
)
230 static char mask_buf
[BUFSIZE
];
232 char *nick
, *user
, *host
;
235 char ne
= 0, ue
= 0, he
= 0; /* save values at nick[NICKLEN], et all */
238 mask
= LOCAL_COPY(idmask
);
239 mask
= check_string(mask
);
242 nick
= user
= host
= splat
;
244 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
247 old_mask_pos
= mask_pos
;
251 mask_pos
+= ircsprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
252 t
= mask_buf
+ old_mask_pos
+ 1;
258 return mask_buf
+ old_mask_pos
;
262 if((t
= strchr(mask
, '@')) != NULL
)
269 if((t
= strchr(mask
, '!')) != NULL
)
284 else if((t
= strchr(mask
, '!')) != NULL
)
293 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
)
304 /* truncate values to max lengths */
305 if(strlen(nick
) > NICKLEN
- 1)
307 ne
= nick
[NICKLEN
- 1];
308 nick
[NICKLEN
- 1] = '\0';
310 if(strlen(user
) > USERLEN
)
313 user
[USERLEN
] = '\0';
315 if(strlen(host
) > HOSTLEN
)
318 host
[HOSTLEN
] = '\0';
321 mask_pos
+= ircsprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
323 /* restore mask, since we may need to use it again later */
329 nick
[NICKLEN
- 1] = ne
;
335 return mask_buf
+ old_mask_pos
;
341 * output - the same key, fixed
342 * side effects - anything below ascii 13 is discarded, ':' discarded,
343 * high ascii is dropped to lower half of ascii table
350 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
353 if(c
!= ':' && c
!= ',' && c
> ' ')
364 * ouput - the same key, fixed
365 * side effects - high ascii dropped to lower half of table,
366 * CR/LF/':' are dropped
369 fix_key_remote(char *arg
)
373 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
376 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
386 * The handlers for each specific mode.
389 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
390 int alevel
, int parc
, int *parn
,
391 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
393 if(*errors
& SM_ERR_UNKNOWN
)
395 *errors
|= SM_ERR_UNKNOWN
;
396 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
400 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
401 int alevel
, int parc
, int *parn
,
402 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
404 if(alevel
!= CHFL_CHANOP
)
406 if(!(*errors
& SM_ERR_NOOPS
))
407 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
408 me
.name
, source_p
->name
, chptr
->chname
);
409 *errors
|= SM_ERR_NOOPS
;
414 * XXX: This needs 'fixing'; hard coding magic numbers like this is fucking
418 /* +ntspmaikl == 9 + MAXMODEPARAMS (4 * +o) */
419 if(MyClient(source_p
) && (++mode_limit
> (9 + MAXMODEPARAMS
)))
423 if((dir
== MODE_ADD
) && !(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_ADD
;
429 mode_changes
[mode_count
].caps
= 0;
430 mode_changes
[mode_count
].nocaps
= 0;
431 mode_changes
[mode_count
].id
= NULL
;
432 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
433 mode_changes
[mode_count
++].arg
= NULL
;
435 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
437 chptr
->mode
.mode
&= ~mode_type
;
439 mode_changes
[mode_count
].letter
= c
;
440 mode_changes
[mode_count
].dir
= MODE_DEL
;
441 mode_changes
[mode_count
].caps
= 0;
442 mode_changes
[mode_count
].nocaps
= 0;
443 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
444 mode_changes
[mode_count
].id
= NULL
;
445 mode_changes
[mode_count
++].arg
= NULL
;
450 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
451 int alevel
, int parc
, int *parn
,
452 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
454 if(!IsServer(source_p
) && MyClient(source_p
) && !IsOperCModes(source_p
))
456 if(!(*errors
& SM_ERR_NOPRIVS
))
459 sendto_one(source_p
, form_str(ERR_NOPRIVS
),
460 me
.name
, source_p
->name
, "set_cmode");
462 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
464 *errors
|= SM_ERR_NOPRIVS
;
469 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
471 chptr
->mode
.mode
|= mode_type
;
473 mode_changes
[mode_count
].letter
= c
;
474 mode_changes
[mode_count
].dir
= MODE_ADD
;
475 mode_changes
[mode_count
].caps
= 0;
476 mode_changes
[mode_count
].nocaps
= 0;
477 mode_changes
[mode_count
].id
= NULL
;
478 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
479 mode_changes
[mode_count
++].arg
= NULL
;
481 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
483 chptr
->mode
.mode
&= ~mode_type
;
485 mode_changes
[mode_count
].letter
= c
;
486 mode_changes
[mode_count
].dir
= MODE_DEL
;
487 mode_changes
[mode_count
].caps
= 0;
488 mode_changes
[mode_count
].nocaps
= 0;
489 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
490 mode_changes
[mode_count
].id
= NULL
;
491 mode_changes
[mode_count
++].arg
= NULL
;
496 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
497 int alevel
, int parc
, int *parn
,
498 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
501 const char *raw_mask
;
514 list
= &chptr
->banlist
;
515 errorval
= SM_ERR_RPL_B
;
516 rpl_list
= RPL_BANLIST
;
517 rpl_endlist
= RPL_ENDOFBANLIST
;
523 /* if +e is disabled, allow all but +e locally */
524 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
525 ((dir
== MODE_ADD
) && (parc
> *parn
)))
528 list
= &chptr
->exceptlist
;
529 errorval
= SM_ERR_RPL_E
;
530 rpl_list
= RPL_EXCEPTLIST
;
531 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
534 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
541 /* if +I is disabled, allow all but +I locally */
542 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
543 (dir
== MODE_ADD
) && (parc
> *parn
))
546 list
= &chptr
->invexlist
;
547 errorval
= SM_ERR_RPL_I
;
548 rpl_list
= RPL_INVITELIST
;
549 rpl_endlist
= RPL_ENDOFINVITELIST
;
552 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
559 list
= &chptr
->quietlist
;
560 errorval
= SM_ERR_RPL_Q
;
561 rpl_list
= RPL_BANLIST
;
562 rpl_endlist
= RPL_ENDOFBANLIST
;
568 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
573 if(dir
== 0 || parc
<= *parn
)
575 if((*errors
& errorval
) != 0)
579 /* non-ops cant see +eI lists.. */
580 if(alevel
!= CHFL_CHANOP
&& mode_type
!= CHFL_BAN
&&
581 mode_type
!= CHFL_QUIET
)
583 if(!(*errors
& SM_ERR_NOOPS
))
584 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
585 me
.name
, source_p
->name
, chptr
->chname
);
586 *errors
|= SM_ERR_NOOPS
;
590 DLINK_FOREACH(ptr
, list
->head
)
593 sendto_one(source_p
, form_str(rpl_list
),
594 me
.name
, source_p
->name
, chptr
->chname
,
595 banptr
->banstr
, banptr
->who
, banptr
->when
);
597 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
601 if(alevel
!= CHFL_CHANOP
)
603 if(!(*errors
& SM_ERR_NOOPS
))
604 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
605 me
.name
, source_p
->name
, chptr
->chname
);
606 *errors
|= SM_ERR_NOOPS
;
610 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
613 raw_mask
= parv
[(*parn
)];
616 /* empty ban, or starts with ':' which messes up s2s, ignore it */
617 if(EmptyString(raw_mask
) || *raw_mask
== ':')
620 if(!MyClient(source_p
))
622 if(strchr(raw_mask
, ' '))
628 mask
= pretty_mask(raw_mask
);
630 /* we'd have problems parsing this, hyb6 does it too */
631 if(strlen(mask
) > (MODEBUFLEN
- 2))
634 /* if we're adding a NEW id */
637 if (*mask
== '$' && MyClient(source_p
))
639 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
640 /* XXX perhaps return an error message here */
644 /* dont allow local clients to overflow the banlist, dont
645 * let remote servers set duplicate bans
647 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
650 mode_changes
[mode_count
].letter
= c
;
651 mode_changes
[mode_count
].dir
= MODE_ADD
;
652 mode_changes
[mode_count
].caps
= caps
;
653 mode_changes
[mode_count
].nocaps
= 0;
654 mode_changes
[mode_count
].mems
= mems
;
655 mode_changes
[mode_count
].id
= NULL
;
656 mode_changes
[mode_count
++].arg
= mask
;
658 else if(dir
== MODE_DEL
)
660 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
662 /* mask isn't a valid ban, check raw_mask */
663 if(del_id(chptr
, raw_mask
, list
, mode_type
))
667 mode_changes
[mode_count
].letter
= c
;
668 mode_changes
[mode_count
].dir
= MODE_DEL
;
669 mode_changes
[mode_count
].caps
= caps
;
670 mode_changes
[mode_count
].nocaps
= 0;
671 mode_changes
[mode_count
].mems
= mems
;
672 mode_changes
[mode_count
].id
= NULL
;
673 mode_changes
[mode_count
++].arg
= mask
;
678 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
679 int alevel
, int parc
, int *parn
,
680 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
682 struct membership
*mstptr
;
684 struct Client
*targ_p
;
686 if(alevel
!= CHFL_CHANOP
)
688 if(!(*errors
& SM_ERR_NOOPS
))
689 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
690 me
.name
, source_p
->name
, chptr
->chname
);
691 *errors
|= SM_ERR_NOOPS
;
695 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
698 opnick
= parv
[(*parn
)];
702 if(EmptyString(opnick
))
704 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
708 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
713 mstptr
= find_channel_membership(chptr
, targ_p
);
717 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
718 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
719 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
720 *errors
|= SM_ERR_NOTONCHANNEL
;
724 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
730 * This breaks oper-override users opping themselves.
731 * Presumably a reason though?
732 if(targ_p == source_p)
736 mode_changes
[mode_count
].letter
= c
;
737 mode_changes
[mode_count
].dir
= MODE_ADD
;
738 mode_changes
[mode_count
].caps
= 0;
739 mode_changes
[mode_count
].nocaps
= 0;
740 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
741 mode_changes
[mode_count
].id
= targ_p
->id
;
742 mode_changes
[mode_count
].arg
= targ_p
->name
;
743 mode_changes
[mode_count
++].client
= targ_p
;
745 mstptr
->flags
|= CHFL_CHANOP
;
746 mstptr
->flags
&= ~CHFL_DEOPPED
;
750 if(MyClient(source_p
) && IsService(targ_p
))
752 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
753 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
757 mode_changes
[mode_count
].letter
= c
;
758 mode_changes
[mode_count
].dir
= MODE_DEL
;
759 mode_changes
[mode_count
].caps
= 0;
760 mode_changes
[mode_count
].nocaps
= 0;
761 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
762 mode_changes
[mode_count
].id
= targ_p
->id
;
763 mode_changes
[mode_count
].arg
= targ_p
->name
;
764 mode_changes
[mode_count
++].client
= targ_p
;
766 mstptr
->flags
&= ~CHFL_CHANOP
;
771 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
772 int alevel
, int parc
, int *parn
,
773 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
775 struct membership
*mstptr
;
777 struct Client
*targ_p
;
779 if(alevel
!= CHFL_CHANOP
)
781 if(!(*errors
& SM_ERR_NOOPS
))
782 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
783 me
.name
, source_p
->name
, chptr
->chname
);
784 *errors
|= SM_ERR_NOOPS
;
788 if((dir
== MODE_QUERY
) || parc
<= *parn
)
791 opnick
= parv
[(*parn
)];
795 if(EmptyString(opnick
))
797 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
801 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
806 mstptr
= find_channel_membership(chptr
, targ_p
);
810 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
811 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
812 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
813 *errors
|= SM_ERR_NOTONCHANNEL
;
817 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
822 mode_changes
[mode_count
].letter
= c
;
823 mode_changes
[mode_count
].dir
= MODE_ADD
;
824 mode_changes
[mode_count
].caps
= 0;
825 mode_changes
[mode_count
].nocaps
= 0;
826 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
827 mode_changes
[mode_count
].id
= targ_p
->id
;
828 mode_changes
[mode_count
].arg
= targ_p
->name
;
829 mode_changes
[mode_count
++].client
= targ_p
;
831 mstptr
->flags
|= CHFL_VOICE
;
835 mode_changes
[mode_count
].letter
= 'v';
836 mode_changes
[mode_count
].dir
= MODE_DEL
;
837 mode_changes
[mode_count
].caps
= 0;
838 mode_changes
[mode_count
].nocaps
= 0;
839 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
840 mode_changes
[mode_count
].id
= targ_p
->id
;
841 mode_changes
[mode_count
].arg
= targ_p
->name
;
842 mode_changes
[mode_count
++].client
= targ_p
;
844 mstptr
->flags
&= ~CHFL_VOICE
;
849 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
850 int alevel
, int parc
, int *parn
,
851 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
854 static char limitstr
[30];
857 if(alevel
!= CHFL_CHANOP
)
859 if(!(*errors
& SM_ERR_NOOPS
))
860 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
861 me
.name
, source_p
->name
, chptr
->chname
);
862 *errors
|= SM_ERR_NOOPS
;
866 if(dir
== MODE_QUERY
)
869 if((dir
== MODE_ADD
) && parc
> *parn
)
871 lstr
= parv
[(*parn
)];
874 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
877 ircsprintf(limitstr
, "%d", limit
);
879 mode_changes
[mode_count
].letter
= c
;
880 mode_changes
[mode_count
].dir
= MODE_ADD
;
881 mode_changes
[mode_count
].caps
= 0;
882 mode_changes
[mode_count
].nocaps
= 0;
883 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
884 mode_changes
[mode_count
].id
= NULL
;
885 mode_changes
[mode_count
++].arg
= limitstr
;
887 chptr
->mode
.limit
= limit
;
889 else if(dir
== MODE_DEL
)
891 if(!chptr
->mode
.limit
)
894 chptr
->mode
.limit
= 0;
896 mode_changes
[mode_count
].letter
= c
;
897 mode_changes
[mode_count
].dir
= MODE_DEL
;
898 mode_changes
[mode_count
].caps
= 0;
899 mode_changes
[mode_count
].nocaps
= 0;
900 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
901 mode_changes
[mode_count
].id
= NULL
;
902 mode_changes
[mode_count
++].arg
= NULL
;
907 chm_banlimit(struct Client
*source_p
, struct Channel
*chptr
,
908 int alevel
, int parc
, int *parn
,
909 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
912 static char limitstr
[30];
915 if(!IsServer(source_p
) && MyClient(source_p
) && !IsOperCModes(source_p
))
917 if(!(*errors
& SM_ERR_NOPRIVS
))
920 sendto_one(source_p
, form_str(ERR_NOPRIVS
),
921 me
.name
, source_p
->name
, "set_cmode");
923 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
925 *errors
|= SM_ERR_NOPRIVS
;
929 if(dir
== MODE_QUERY
)
932 if((dir
== MODE_ADD
) && parc
> *parn
)
934 lstr
= parv
[(*parn
)];
937 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
940 ircsprintf(limitstr
, "%d", limit
);
942 mode_changes
[mode_count
].letter
= c
;
943 mode_changes
[mode_count
].dir
= MODE_ADD
;
944 mode_changes
[mode_count
].caps
= 0;
945 mode_changes
[mode_count
].nocaps
= 0;
946 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
947 mode_changes
[mode_count
].id
= NULL
;
948 mode_changes
[mode_count
++].arg
= limitstr
;
950 chptr
->mode
.banlimit
= limit
;
952 else if(dir
== MODE_DEL
)
954 if(!chptr
->mode
.banlimit
)
957 chptr
->mode
.banlimit
= 0;
959 mode_changes
[mode_count
].letter
= c
;
960 mode_changes
[mode_count
].dir
= MODE_DEL
;
961 mode_changes
[mode_count
].caps
= 0;
962 mode_changes
[mode_count
].nocaps
= 0;
963 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
964 mode_changes
[mode_count
].id
= NULL
;
965 mode_changes
[mode_count
++].arg
= NULL
;
970 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
971 int alevel
, int parc
, int *parn
,
972 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
974 int joins
= 0, timeslice
= 0;
976 if(alevel
!= CHFL_CHANOP
)
978 if(!(*errors
& SM_ERR_NOOPS
))
979 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
980 me
.name
, source_p
->name
, chptr
->chname
);
981 *errors
|= SM_ERR_NOOPS
;
985 if(dir
== MODE_QUERY
)
988 if((dir
== MODE_ADD
) && parc
> *parn
)
990 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
992 if(!joins
|| !timeslice
)
995 mode_changes
[mode_count
].letter
= c
;
996 mode_changes
[mode_count
].dir
= MODE_ADD
;
997 mode_changes
[mode_count
].caps
= 0;
998 mode_changes
[mode_count
].nocaps
= 0;
999 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1000 mode_changes
[mode_count
].id
= NULL
;
1001 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
1005 chptr
->mode
.join_num
= joins
;
1006 chptr
->mode
.join_time
= timeslice
;
1008 else if(dir
== MODE_DEL
)
1010 if(!chptr
->mode
.join_num
)
1013 chptr
->mode
.join_num
= 0;
1014 chptr
->mode
.join_time
= 0;
1015 chptr
->join_count
= 0;
1016 chptr
->join_delta
= 0;
1018 mode_changes
[mode_count
].letter
= c
;
1019 mode_changes
[mode_count
].dir
= MODE_DEL
;
1020 mode_changes
[mode_count
].caps
= 0;
1021 mode_changes
[mode_count
].nocaps
= 0;
1022 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1023 mode_changes
[mode_count
].id
= NULL
;
1024 mode_changes
[mode_count
++].arg
= NULL
;
1029 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
1030 int alevel
, int parc
, int *parn
,
1031 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1033 struct Channel
*targptr
= NULL
;
1034 struct membership
*msptr
;
1035 const char *forward
;
1037 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
1039 if (!(*errors
& SM_ERR_RPL_F
))
1041 if (*chptr
->mode
.forward
== '\0')
1042 sendto_one(source_p
, ":%s NOTICE %s :%s has no forward channel", me
.name
, source_p
->name
, chptr
->chname
);
1044 sendto_one(source_p
, ":%s NOTICE %s :%s forward channel is %s", me
.name
, source_p
->name
, chptr
->chname
, chptr
->mode
.forward
);
1045 *errors
|= SM_ERR_RPL_F
;
1050 #ifndef FORWARD_OPERONLY
1051 if(alevel
!= CHFL_CHANOP
)
1053 if(!(*errors
& SM_ERR_NOOPS
))
1054 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1055 me
.name
, source_p
->name
, chptr
->chname
);
1056 *errors
|= SM_ERR_NOOPS
;
1060 if(!IsOperCModes(source_p
) && !IsServer(source_p
))
1062 if(!(*errors
& SM_ERR_NOPRIVS
))
1063 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
1064 *errors
|= SM_ERR_NOPRIVS
;
1069 if(dir
== MODE_ADD
&& parc
> *parn
)
1071 forward
= parv
[(*parn
)];
1074 if(EmptyString(forward
))
1076 if(!check_channel_name(forward
) ||
1077 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1079 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1082 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1084 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1085 form_str(ERR_NOSUCHCHANNEL
), forward
);
1088 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1090 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1091 get_channel_access(source_p
, msptr
) != CHFL_CHANOP
)
1093 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1094 me
.name
, source_p
->name
, targptr
->chname
);
1099 strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
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
= forward
;
1109 else if(dir
== MODE_DEL
)
1111 if(!(*chptr
->mode
.forward
))
1114 *chptr
->mode
.forward
= '\0';
1116 mode_changes
[mode_count
].letter
= c
;
1117 mode_changes
[mode_count
].dir
= MODE_DEL
;
1118 mode_changes
[mode_count
].caps
= 0;
1119 mode_changes
[mode_count
].nocaps
= 0;
1120 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1121 mode_changes
[mode_count
].id
= NULL
;
1122 mode_changes
[mode_count
++].arg
= NULL
;
1127 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1128 int alevel
, int parc
, int *parn
,
1129 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1133 if(alevel
!= CHFL_CHANOP
)
1135 if(!(*errors
& SM_ERR_NOOPS
))
1136 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1137 me
.name
, source_p
->name
, chptr
->chname
);
1138 *errors
|= SM_ERR_NOOPS
;
1142 if(dir
== MODE_QUERY
)
1145 if((dir
== MODE_ADD
) && parc
> *parn
)
1147 key
= LOCAL_COPY(parv
[(*parn
)]);
1150 if(MyClient(source_p
))
1153 fix_key_remote(key
);
1155 if(EmptyString(key
))
1158 s_assert(key
[0] != ' ');
1159 strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1161 mode_changes
[mode_count
].letter
= c
;
1162 mode_changes
[mode_count
].dir
= MODE_ADD
;
1163 mode_changes
[mode_count
].caps
= 0;
1164 mode_changes
[mode_count
].nocaps
= 0;
1165 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1166 mode_changes
[mode_count
].id
= NULL
;
1167 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1169 else if(dir
== MODE_DEL
)
1171 static char splat
[] = "*";
1177 if(!(*chptr
->mode
.key
))
1180 /* hack time. when we get a +k-k mode, the +k arg is
1181 * chptr->mode.key, which the -k sets to \0, so hunt for a
1182 * +k when we get a -k, and set the arg to splat. --anfl
1184 for(i
= 0; i
< mode_count
; i
++)
1186 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1187 mode_changes
[i
].arg
= splat
;
1190 *chptr
->mode
.key
= 0;
1192 mode_changes
[mode_count
].letter
= c
;
1193 mode_changes
[mode_count
].dir
= MODE_DEL
;
1194 mode_changes
[mode_count
].caps
= 0;
1195 mode_changes
[mode_count
].nocaps
= 0;
1196 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1197 mode_changes
[mode_count
].id
= NULL
;
1198 mode_changes
[mode_count
++].arg
= "*";
1203 chm_regonly(struct Client
*source_p
, struct Channel
*chptr
,
1204 int alevel
, int parc
, int *parn
,
1205 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1207 if(alevel
!= CHFL_CHANOP
)
1209 if(!(*errors
& SM_ERR_NOOPS
))
1210 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1211 me
.name
, source_p
->name
, chptr
->chname
);
1212 *errors
|= SM_ERR_NOOPS
;
1216 if(dir
== MODE_QUERY
)
1219 if(((dir
== MODE_ADD
) && (chptr
->mode
.mode
& mode_type
)) ||
1220 ((dir
== MODE_DEL
) && !(chptr
->mode
.mode
& mode_type
)))
1224 chptr
->mode
.mode
|= mode_type
;
1226 chptr
->mode
.mode
&= ~mode_type
;
1228 mode_changes
[mode_count
].letter
= c
;
1229 mode_changes
[mode_count
].dir
= dir
;
1230 mode_changes
[mode_count
].caps
= CAP_SERVICE
;
1231 mode_changes
[mode_count
].nocaps
= 0;
1232 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1233 mode_changes
[mode_count
].id
= NULL
;
1234 mode_changes
[mode_count
++].arg
= NULL
;
1238 struct ChannelMode chmode_table
[256] =
1240 {chm_nosuch
, 0 }, /* 0x00 */
1241 {chm_nosuch
, 0 }, /* 0x01 */
1242 {chm_nosuch
, 0 }, /* 0x02 */
1243 {chm_nosuch
, 0 }, /* 0x03 */
1244 {chm_nosuch
, 0 }, /* 0x04 */
1245 {chm_nosuch
, 0 }, /* 0x05 */
1246 {chm_nosuch
, 0 }, /* 0x06 */
1247 {chm_nosuch
, 0 }, /* 0x07 */
1248 {chm_nosuch
, 0 }, /* 0x08 */
1249 {chm_nosuch
, 0 }, /* 0x09 */
1250 {chm_nosuch
, 0 }, /* 0x0a */
1251 {chm_nosuch
, 0 }, /* 0x0b */
1252 {chm_nosuch
, 0 }, /* 0x0c */
1253 {chm_nosuch
, 0 }, /* 0x0d */
1254 {chm_nosuch
, 0 }, /* 0x0e */
1255 {chm_nosuch
, 0 }, /* 0x0f */
1256 {chm_nosuch
, 0 }, /* 0x10 */
1257 {chm_nosuch
, 0 }, /* 0x11 */
1258 {chm_nosuch
, 0 }, /* 0x12 */
1259 {chm_nosuch
, 0 }, /* 0x13 */
1260 {chm_nosuch
, 0 }, /* 0x14 */
1261 {chm_nosuch
, 0 }, /* 0x15 */
1262 {chm_nosuch
, 0 }, /* 0x16 */
1263 {chm_nosuch
, 0 }, /* 0x17 */
1264 {chm_nosuch
, 0 }, /* 0x18 */
1265 {chm_nosuch
, 0 }, /* 0x19 */
1266 {chm_nosuch
, 0 }, /* 0x1a */
1267 {chm_nosuch
, 0 }, /* 0x1b */
1268 {chm_nosuch
, 0 }, /* 0x1c */
1269 {chm_nosuch
, 0 }, /* 0x1d */
1270 {chm_nosuch
, 0 }, /* 0x1e */
1271 {chm_nosuch
, 0 }, /* 0x1f */
1272 {chm_nosuch
, 0 }, /* 0x20 */
1273 {chm_nosuch
, 0 }, /* 0x21 */
1274 {chm_nosuch
, 0 }, /* 0x22 */
1275 {chm_nosuch
, 0 }, /* 0x23 */
1276 {chm_nosuch
, 0 }, /* 0x24 */
1277 {chm_nosuch
, 0 }, /* 0x25 */
1278 {chm_nosuch
, 0 }, /* 0x26 */
1279 {chm_nosuch
, 0 }, /* 0x27 */
1280 {chm_nosuch
, 0 }, /* 0x28 */
1281 {chm_nosuch
, 0 }, /* 0x29 */
1282 {chm_nosuch
, 0 }, /* 0x2a */
1283 {chm_nosuch
, 0 }, /* 0x2b */
1284 {chm_nosuch
, 0 }, /* 0x2c */
1285 {chm_nosuch
, 0 }, /* 0x2d */
1286 {chm_nosuch
, 0 }, /* 0x2e */
1287 {chm_nosuch
, 0 }, /* 0x2f */
1288 {chm_nosuch
, 0 }, /* 0x30 */
1289 {chm_nosuch
, 0 }, /* 0x31 */
1290 {chm_nosuch
, 0 }, /* 0x32 */
1291 {chm_nosuch
, 0 }, /* 0x33 */
1292 {chm_nosuch
, 0 }, /* 0x34 */
1293 {chm_nosuch
, 0 }, /* 0x35 */
1294 {chm_nosuch
, 0 }, /* 0x36 */
1295 {chm_nosuch
, 0 }, /* 0x37 */
1296 {chm_nosuch
, 0 }, /* 0x38 */
1297 {chm_nosuch
, 0 }, /* 0x39 */
1298 {chm_nosuch
, 0 }, /* 0x3a */
1299 {chm_nosuch
, 0 }, /* 0x3b */
1300 {chm_nosuch
, 0 }, /* 0x3c */
1301 {chm_nosuch
, 0 }, /* 0x3d */
1302 {chm_nosuch
, 0 }, /* 0x3e */
1303 {chm_nosuch
, 0 }, /* 0x3f */
1305 {chm_nosuch
, 0 }, /* @ */
1306 {chm_nosuch
, 0 }, /* A */
1307 {chm_nosuch
, 0 }, /* B */
1308 {chm_nosuch
, 0 }, /* C */
1309 {chm_nosuch
, 0 }, /* D */
1310 {chm_nosuch
, 0 }, /* E */
1311 {chm_simple
, MODE_FREETARGET
}, /* F */
1312 {chm_nosuch
, 0 }, /* G */
1313 {chm_nosuch
, 0 }, /* H */
1314 {chm_ban
, CHFL_INVEX
}, /* I */
1315 {chm_nosuch
, 0 }, /* J */
1316 {chm_nosuch
, 0 }, /* K */
1317 {chm_banlimit
,0 }, /* L */
1318 {chm_nosuch
, 0 }, /* M */
1319 {chm_nosuch
, 0 }, /* N */
1320 {chm_nosuch
, 0 }, /* O */
1321 {chm_staff
, MODE_PERMANENT
}, /* P */
1322 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1323 {chm_simple
, MODE_QUIETUNID
}, /* R */
1324 {chm_nosuch
, 0 }, /* S */
1325 {chm_nosuch
, 0 }, /* T */
1326 {chm_nosuch
, 0 }, /* U */
1327 {chm_nosuch
, 0 }, /* V */
1328 {chm_nosuch
, 0 }, /* W */
1329 {chm_nosuch
, 0 }, /* X */
1330 {chm_nosuch
, 0 }, /* Y */
1331 {chm_nosuch
, 0 }, /* Z */
1338 {chm_nosuch
, 0 }, /* a */
1339 {chm_ban
, CHFL_BAN
}, /* b */
1340 {chm_simple
, MODE_NOCOLOR
}, /* c */
1341 {chm_nosuch
, 0 }, /* d */
1342 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1343 {chm_forward
, 0 }, /* f */
1344 {chm_simple
, MODE_FREEINVITE
}, /* g */
1345 {chm_nosuch
, 0 }, /* h */
1346 {chm_simple
, MODE_INVITEONLY
}, /* i */
1347 {chm_throttle
, 0 }, /* j */
1348 {chm_key
, 0 }, /* k */
1349 {chm_limit
, 0 }, /* l */
1350 {chm_simple
, MODE_MODERATED
}, /* m */
1351 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1352 {chm_op
, 0 }, /* o */
1353 {chm_simple
, MODE_PRIVATE
}, /* p */
1354 {chm_ban
, CHFL_QUIET
}, /* q */
1355 {chm_regonly
, MODE_REGONLY
}, /* r */
1356 {chm_simple
, MODE_SECRET
}, /* s */
1357 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1358 {chm_nosuch
, 0 }, /* u */
1359 {chm_voice
, 0 }, /* v */
1360 {chm_nosuch
, 0 }, /* w */
1361 {chm_nosuch
, 0 }, /* x */
1362 {chm_nosuch
, 0 }, /* y */
1363 {chm_simple
, MODE_OPMODERATE
}, /* z */
1365 {chm_nosuch
, 0 }, /* 0x7b */
1366 {chm_nosuch
, 0 }, /* 0x7c */
1367 {chm_nosuch
, 0 }, /* 0x7d */
1368 {chm_nosuch
, 0 }, /* 0x7e */
1369 {chm_nosuch
, 0 }, /* 0x7f */
1371 {chm_nosuch
, 0 }, /* 0x80 */
1372 {chm_nosuch
, 0 }, /* 0x81 */
1373 {chm_nosuch
, 0 }, /* 0x82 */
1374 {chm_nosuch
, 0 }, /* 0x83 */
1375 {chm_nosuch
, 0 }, /* 0x84 */
1376 {chm_nosuch
, 0 }, /* 0x85 */
1377 {chm_nosuch
, 0 }, /* 0x86 */
1378 {chm_nosuch
, 0 }, /* 0x87 */
1379 {chm_nosuch
, 0 }, /* 0x88 */
1380 {chm_nosuch
, 0 }, /* 0x89 */
1381 {chm_nosuch
, 0 }, /* 0x8a */
1382 {chm_nosuch
, 0 }, /* 0x8b */
1383 {chm_nosuch
, 0 }, /* 0x8c */
1384 {chm_nosuch
, 0 }, /* 0x8d */
1385 {chm_nosuch
, 0 }, /* 0x8e */
1386 {chm_nosuch
, 0 }, /* 0x8f */
1388 {chm_nosuch
, 0 }, /* 0x90 */
1389 {chm_nosuch
, 0 }, /* 0x91 */
1390 {chm_nosuch
, 0 }, /* 0x92 */
1391 {chm_nosuch
, 0 }, /* 0x93 */
1392 {chm_nosuch
, 0 }, /* 0x94 */
1393 {chm_nosuch
, 0 }, /* 0x95 */
1394 {chm_nosuch
, 0 }, /* 0x96 */
1395 {chm_nosuch
, 0 }, /* 0x97 */
1396 {chm_nosuch
, 0 }, /* 0x98 */
1397 {chm_nosuch
, 0 }, /* 0x99 */
1398 {chm_nosuch
, 0 }, /* 0x9a */
1399 {chm_nosuch
, 0 }, /* 0x9b */
1400 {chm_nosuch
, 0 }, /* 0x9c */
1401 {chm_nosuch
, 0 }, /* 0x9d */
1402 {chm_nosuch
, 0 }, /* 0x9e */
1403 {chm_nosuch
, 0 }, /* 0x9f */
1405 {chm_nosuch
, 0 }, /* 0xa0 */
1406 {chm_nosuch
, 0 }, /* 0xa1 */
1407 {chm_nosuch
, 0 }, /* 0xa2 */
1408 {chm_nosuch
, 0 }, /* 0xa3 */
1409 {chm_nosuch
, 0 }, /* 0xa4 */
1410 {chm_nosuch
, 0 }, /* 0xa5 */
1411 {chm_nosuch
, 0 }, /* 0xa6 */
1412 {chm_nosuch
, 0 }, /* 0xa7 */
1413 {chm_nosuch
, 0 }, /* 0xa8 */
1414 {chm_nosuch
, 0 }, /* 0xa9 */
1415 {chm_nosuch
, 0 }, /* 0xaa */
1416 {chm_nosuch
, 0 }, /* 0xab */
1417 {chm_nosuch
, 0 }, /* 0xac */
1418 {chm_nosuch
, 0 }, /* 0xad */
1419 {chm_nosuch
, 0 }, /* 0xae */
1420 {chm_nosuch
, 0 }, /* 0xaf */
1422 {chm_nosuch
, 0 }, /* 0xb0 */
1423 {chm_nosuch
, 0 }, /* 0xb1 */
1424 {chm_nosuch
, 0 }, /* 0xb2 */
1425 {chm_nosuch
, 0 }, /* 0xb3 */
1426 {chm_nosuch
, 0 }, /* 0xb4 */
1427 {chm_nosuch
, 0 }, /* 0xb5 */
1428 {chm_nosuch
, 0 }, /* 0xb6 */
1429 {chm_nosuch
, 0 }, /* 0xb7 */
1430 {chm_nosuch
, 0 }, /* 0xb8 */
1431 {chm_nosuch
, 0 }, /* 0xb9 */
1432 {chm_nosuch
, 0 }, /* 0xba */
1433 {chm_nosuch
, 0 }, /* 0xbb */
1434 {chm_nosuch
, 0 }, /* 0xbc */
1435 {chm_nosuch
, 0 }, /* 0xbd */
1436 {chm_nosuch
, 0 }, /* 0xbe */
1437 {chm_nosuch
, 0 }, /* 0xbf */
1439 {chm_nosuch
, 0 }, /* 0xc0 */
1440 {chm_nosuch
, 0 }, /* 0xc1 */
1441 {chm_nosuch
, 0 }, /* 0xc2 */
1442 {chm_nosuch
, 0 }, /* 0xc3 */
1443 {chm_nosuch
, 0 }, /* 0xc4 */
1444 {chm_nosuch
, 0 }, /* 0xc5 */
1445 {chm_nosuch
, 0 }, /* 0xc6 */
1446 {chm_nosuch
, 0 }, /* 0xc7 */
1447 {chm_nosuch
, 0 }, /* 0xc8 */
1448 {chm_nosuch
, 0 }, /* 0xc9 */
1449 {chm_nosuch
, 0 }, /* 0xca */
1450 {chm_nosuch
, 0 }, /* 0xcb */
1451 {chm_nosuch
, 0 }, /* 0xcc */
1452 {chm_nosuch
, 0 }, /* 0xcd */
1453 {chm_nosuch
, 0 }, /* 0xce */
1454 {chm_nosuch
, 0 }, /* 0xcf */
1456 {chm_nosuch
, 0 }, /* 0xd0 */
1457 {chm_nosuch
, 0 }, /* 0xd1 */
1458 {chm_nosuch
, 0 }, /* 0xd2 */
1459 {chm_nosuch
, 0 }, /* 0xd3 */
1460 {chm_nosuch
, 0 }, /* 0xd4 */
1461 {chm_nosuch
, 0 }, /* 0xd5 */
1462 {chm_nosuch
, 0 }, /* 0xd6 */
1463 {chm_nosuch
, 0 }, /* 0xd7 */
1464 {chm_nosuch
, 0 }, /* 0xd8 */
1465 {chm_nosuch
, 0 }, /* 0xd9 */
1466 {chm_nosuch
, 0 }, /* 0xda */
1467 {chm_nosuch
, 0 }, /* 0xdb */
1468 {chm_nosuch
, 0 }, /* 0xdc */
1469 {chm_nosuch
, 0 }, /* 0xdd */
1470 {chm_nosuch
, 0 }, /* 0xde */
1471 {chm_nosuch
, 0 }, /* 0xdf */
1473 {chm_nosuch
, 0 }, /* 0xe0 */
1474 {chm_nosuch
, 0 }, /* 0xe1 */
1475 {chm_nosuch
, 0 }, /* 0xe2 */
1476 {chm_nosuch
, 0 }, /* 0xe3 */
1477 {chm_nosuch
, 0 }, /* 0xe4 */
1478 {chm_nosuch
, 0 }, /* 0xe5 */
1479 {chm_nosuch
, 0 }, /* 0xe6 */
1480 {chm_nosuch
, 0 }, /* 0xe7 */
1481 {chm_nosuch
, 0 }, /* 0xe8 */
1482 {chm_nosuch
, 0 }, /* 0xe9 */
1483 {chm_nosuch
, 0 }, /* 0xea */
1484 {chm_nosuch
, 0 }, /* 0xeb */
1485 {chm_nosuch
, 0 }, /* 0xec */
1486 {chm_nosuch
, 0 }, /* 0xed */
1487 {chm_nosuch
, 0 }, /* 0xee */
1488 {chm_nosuch
, 0 }, /* 0xef */
1490 {chm_nosuch
, 0 }, /* 0xf0 */
1491 {chm_nosuch
, 0 }, /* 0xf1 */
1492 {chm_nosuch
, 0 }, /* 0xf2 */
1493 {chm_nosuch
, 0 }, /* 0xf3 */
1494 {chm_nosuch
, 0 }, /* 0xf4 */
1495 {chm_nosuch
, 0 }, /* 0xf5 */
1496 {chm_nosuch
, 0 }, /* 0xf6 */
1497 {chm_nosuch
, 0 }, /* 0xf7 */
1498 {chm_nosuch
, 0 }, /* 0xf8 */
1499 {chm_nosuch
, 0 }, /* 0xf9 */
1500 {chm_nosuch
, 0 }, /* 0xfa */
1501 {chm_nosuch
, 0 }, /* 0xfb */
1502 {chm_nosuch
, 0 }, /* 0xfc */
1503 {chm_nosuch
, 0 }, /* 0xfd */
1504 {chm_nosuch
, 0 }, /* 0xfe */
1505 {chm_nosuch
, 0 }, /* 0xff */
1510 /* set_channel_mode()
1512 * inputs - client, source, channel, membership pointer, params
1514 * side effects - channel modes/memberships are changed, MODE is issued
1516 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
1519 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
1520 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
1522 static char modebuf
[BUFSIZE
];
1523 static char parabuf
[BUFSIZE
];
1526 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
1532 const char *ml
= parv
[0];
1534 struct Client
*fakesource_p
;
1540 alevel
= get_channel_access(source_p
, msptr
);
1542 /* Hide connecting server on netburst -- jilles */
1543 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
1546 fakesource_p
= source_p
;
1548 for(; (c
= *ml
) != 0; ml
++)
1562 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
1565 chmode_table
[(unsigned char) c
].mode_type
);
1570 /* bail out if we have nothing to do... */
1574 if(IsServer(source_p
))
1575 mlen
= ircsprintf(modebuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
1577 mlen
= ircsprintf(modebuf
, ":%s!%s@%s MODE %s ",
1578 source_p
->name
, source_p
->username
,
1579 source_p
->host
, chptr
->chname
);
1581 for(j
= 0, flags
= ALL_MEMBERS
; j
< 2; j
++, flags
= ONLY_CHANOPS
)
1584 mbuf
= modebuf
+ mlen
;
1587 paracount
= paralen
= 0;
1590 for(i
= 0; i
< mode_count
; i
++)
1592 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
1595 if(mode_changes
[i
].arg
!= NULL
)
1597 arglen
= strlen(mode_changes
[i
].arg
);
1599 if(arglen
> MODEBUFLEN
- 5)
1605 /* if we're creeping over MAXMODEPARAMSSERV, or over
1606 * bufsize (4 == +/-,modechar,two spaces) send now.
1608 if(mode_changes
[i
].arg
!= NULL
&&
1609 ((paracount
== MAXMODEPARAMSSERV
) ||
1610 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
1615 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
,
1620 paracount
= paralen
= 0;
1622 mbuf
= modebuf
+ mlen
;
1628 if(dir
!= mode_changes
[i
].dir
)
1630 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
1632 dir
= mode_changes
[i
].dir
;
1635 *mbuf
++ = mode_changes
[i
].letter
;
1638 if(mode_changes
[i
].arg
!= NULL
)
1641 len
= ircsprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
1647 if(paralen
&& parabuf
[paralen
- 1] == ' ')
1648 parabuf
[paralen
- 1] = '\0';
1652 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
, parabuf
);
1655 /* only propagate modes originating locally, or if we're hubbing */
1656 if(MyClient(source_p
) || dlink_list_length(&serv_list
) > 1)
1657 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);