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
;
454 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
456 chptr
->mode
.mode
|= mode_type
;
458 mode_changes
[mode_count
].letter
= c
;
459 mode_changes
[mode_count
].dir
= MODE_ADD
;
460 mode_changes
[mode_count
].caps
= 0;
461 mode_changes
[mode_count
].nocaps
= 0;
462 mode_changes
[mode_count
].id
= NULL
;
463 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
464 mode_changes
[mode_count
++].arg
= NULL
;
466 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
468 chptr
->mode
.mode
&= ~mode_type
;
470 mode_changes
[mode_count
].letter
= c
;
471 mode_changes
[mode_count
].dir
= MODE_DEL
;
472 mode_changes
[mode_count
].caps
= 0;
473 mode_changes
[mode_count
].nocaps
= 0;
474 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
475 mode_changes
[mode_count
].id
= NULL
;
476 mode_changes
[mode_count
++].arg
= NULL
;
481 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
482 int alevel
, int parc
, int *parn
,
483 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
486 const char *raw_mask
;
499 list
= &chptr
->banlist
;
500 errorval
= SM_ERR_RPL_B
;
501 rpl_list
= RPL_BANLIST
;
502 rpl_endlist
= RPL_ENDOFBANLIST
;
508 /* if +e is disabled, allow all but +e locally */
509 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
510 ((dir
== MODE_ADD
) && (parc
> *parn
)))
513 list
= &chptr
->exceptlist
;
514 errorval
= SM_ERR_RPL_E
;
515 rpl_list
= RPL_EXCEPTLIST
;
516 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
519 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
526 /* if +I is disabled, allow all but +I locally */
527 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
528 (dir
== MODE_ADD
) && (parc
> *parn
))
531 list
= &chptr
->invexlist
;
532 errorval
= SM_ERR_RPL_I
;
533 rpl_list
= RPL_INVITELIST
;
534 rpl_endlist
= RPL_ENDOFINVITELIST
;
537 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
544 list
= &chptr
->quietlist
;
545 errorval
= SM_ERR_RPL_Q
;
546 rpl_list
= RPL_BANLIST
;
547 rpl_endlist
= RPL_ENDOFBANLIST
;
553 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
558 if(dir
== 0 || parc
<= *parn
)
560 if((*errors
& errorval
) != 0)
564 /* non-ops cant see +eI lists.. */
565 if(alevel
!= CHFL_CHANOP
&& mode_type
!= CHFL_BAN
&&
566 mode_type
!= CHFL_QUIET
)
568 if(!(*errors
& SM_ERR_NOOPS
))
569 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
570 me
.name
, source_p
->name
, chptr
->chname
);
571 *errors
|= SM_ERR_NOOPS
;
575 DLINK_FOREACH(ptr
, list
->head
)
578 sendto_one(source_p
, form_str(rpl_list
),
579 me
.name
, source_p
->name
, chptr
->chname
,
580 banptr
->banstr
, banptr
->who
, banptr
->when
);
582 if (mode_type
== CHFL_QUIET
)
583 sendto_one(source_p
, ":%s %d %s %s :End of Channel Quiet List", me
.name
, rpl_endlist
, source_p
->name
, chptr
->chname
);
585 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
589 if(alevel
!= CHFL_CHANOP
)
591 if(!(*errors
& SM_ERR_NOOPS
))
592 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
593 me
.name
, source_p
->name
, chptr
->chname
);
594 *errors
|= SM_ERR_NOOPS
;
598 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
601 raw_mask
= parv
[(*parn
)];
604 /* empty ban, or starts with ':' which messes up s2s, ignore it */
605 if(EmptyString(raw_mask
) || *raw_mask
== ':')
608 if(!MyClient(source_p
))
610 if(strchr(raw_mask
, ' '))
616 mask
= pretty_mask(raw_mask
);
618 /* we'd have problems parsing this, hyb6 does it too
619 * also make sure it will always fit on a line with channel
622 if(strlen(mask
) > IRCD_MIN(BANLEN
, MODEBUFLEN
- 5))
625 /* if we're adding a NEW id */
628 if (*mask
== '$' && MyClient(source_p
))
630 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
631 /* XXX perhaps return an error message here */
635 /* dont allow local clients to overflow the banlist, dont
636 * let remote servers set duplicate bans
638 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
641 mode_changes
[mode_count
].letter
= c
;
642 mode_changes
[mode_count
].dir
= MODE_ADD
;
643 mode_changes
[mode_count
].caps
= caps
;
644 mode_changes
[mode_count
].nocaps
= 0;
645 mode_changes
[mode_count
].mems
= mems
;
646 mode_changes
[mode_count
].id
= NULL
;
647 mode_changes
[mode_count
++].arg
= mask
;
649 else if(dir
== MODE_DEL
)
651 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
653 /* mask isn't a valid ban, check raw_mask */
654 if(del_id(chptr
, raw_mask
, list
, mode_type
))
658 mode_changes
[mode_count
].letter
= c
;
659 mode_changes
[mode_count
].dir
= MODE_DEL
;
660 mode_changes
[mode_count
].caps
= caps
;
661 mode_changes
[mode_count
].nocaps
= 0;
662 mode_changes
[mode_count
].mems
= mems
;
663 mode_changes
[mode_count
].id
= NULL
;
664 mode_changes
[mode_count
++].arg
= mask
;
669 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
670 int alevel
, int parc
, int *parn
,
671 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
673 struct membership
*mstptr
;
675 struct Client
*targ_p
;
677 if(alevel
!= CHFL_CHANOP
)
679 if(!(*errors
& SM_ERR_NOOPS
))
680 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
681 me
.name
, source_p
->name
, chptr
->chname
);
682 *errors
|= SM_ERR_NOOPS
;
686 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
689 opnick
= parv
[(*parn
)];
693 if(EmptyString(opnick
))
695 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
699 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
704 mstptr
= find_channel_membership(chptr
, targ_p
);
708 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
709 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
710 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
711 *errors
|= SM_ERR_NOTONCHANNEL
;
715 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
720 if(targ_p
== source_p
)
723 mode_changes
[mode_count
].letter
= c
;
724 mode_changes
[mode_count
].dir
= MODE_ADD
;
725 mode_changes
[mode_count
].caps
= 0;
726 mode_changes
[mode_count
].nocaps
= 0;
727 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
728 mode_changes
[mode_count
].id
= targ_p
->id
;
729 mode_changes
[mode_count
].arg
= targ_p
->name
;
730 mode_changes
[mode_count
++].client
= targ_p
;
732 mstptr
->flags
|= CHFL_CHANOP
;
733 mstptr
->flags
&= ~CHFL_DEOPPED
;
737 if(MyClient(source_p
) && IsService(targ_p
))
739 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
740 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
744 mode_changes
[mode_count
].letter
= c
;
745 mode_changes
[mode_count
].dir
= MODE_DEL
;
746 mode_changes
[mode_count
].caps
= 0;
747 mode_changes
[mode_count
].nocaps
= 0;
748 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
749 mode_changes
[mode_count
].id
= targ_p
->id
;
750 mode_changes
[mode_count
].arg
= targ_p
->name
;
751 mode_changes
[mode_count
++].client
= targ_p
;
753 mstptr
->flags
&= ~CHFL_CHANOP
;
758 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
759 int alevel
, int parc
, int *parn
,
760 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
762 struct membership
*mstptr
;
764 struct Client
*targ_p
;
766 if(alevel
!= CHFL_CHANOP
)
768 if(!(*errors
& SM_ERR_NOOPS
))
769 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
770 me
.name
, source_p
->name
, chptr
->chname
);
771 *errors
|= SM_ERR_NOOPS
;
775 if((dir
== MODE_QUERY
) || parc
<= *parn
)
778 opnick
= parv
[(*parn
)];
782 if(EmptyString(opnick
))
784 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
788 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
793 mstptr
= find_channel_membership(chptr
, targ_p
);
797 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
798 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
799 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
800 *errors
|= SM_ERR_NOTONCHANNEL
;
804 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
809 mode_changes
[mode_count
].letter
= c
;
810 mode_changes
[mode_count
].dir
= MODE_ADD
;
811 mode_changes
[mode_count
].caps
= 0;
812 mode_changes
[mode_count
].nocaps
= 0;
813 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
814 mode_changes
[mode_count
].id
= targ_p
->id
;
815 mode_changes
[mode_count
].arg
= targ_p
->name
;
816 mode_changes
[mode_count
++].client
= targ_p
;
818 mstptr
->flags
|= CHFL_VOICE
;
822 mode_changes
[mode_count
].letter
= 'v';
823 mode_changes
[mode_count
].dir
= MODE_DEL
;
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
;
836 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
837 int alevel
, int parc
, int *parn
,
838 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
841 static char limitstr
[30];
844 if(alevel
!= CHFL_CHANOP
)
846 if(!(*errors
& SM_ERR_NOOPS
))
847 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
848 me
.name
, source_p
->name
, chptr
->chname
);
849 *errors
|= SM_ERR_NOOPS
;
853 if(dir
== MODE_QUERY
)
856 if((dir
== MODE_ADD
) && parc
> *parn
)
858 lstr
= parv
[(*parn
)];
861 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
864 ircsprintf(limitstr
, "%d", limit
);
866 mode_changes
[mode_count
].letter
= c
;
867 mode_changes
[mode_count
].dir
= MODE_ADD
;
868 mode_changes
[mode_count
].caps
= 0;
869 mode_changes
[mode_count
].nocaps
= 0;
870 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
871 mode_changes
[mode_count
].id
= NULL
;
872 mode_changes
[mode_count
++].arg
= limitstr
;
874 chptr
->mode
.limit
= limit
;
876 else if(dir
== MODE_DEL
)
878 if(!chptr
->mode
.limit
)
881 chptr
->mode
.limit
= 0;
883 mode_changes
[mode_count
].letter
= c
;
884 mode_changes
[mode_count
].dir
= MODE_DEL
;
885 mode_changes
[mode_count
].caps
= 0;
886 mode_changes
[mode_count
].nocaps
= 0;
887 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
888 mode_changes
[mode_count
].id
= NULL
;
889 mode_changes
[mode_count
++].arg
= NULL
;
894 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
895 int alevel
, int parc
, int *parn
,
896 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
898 int joins
= 0, timeslice
= 0;
900 if(alevel
!= CHFL_CHANOP
)
902 if(!(*errors
& SM_ERR_NOOPS
))
903 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
904 me
.name
, source_p
->name
, chptr
->chname
);
905 *errors
|= SM_ERR_NOOPS
;
909 if(dir
== MODE_QUERY
)
912 if((dir
== MODE_ADD
) && parc
> *parn
)
914 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
916 if(!joins
|| !timeslice
)
919 mode_changes
[mode_count
].letter
= c
;
920 mode_changes
[mode_count
].dir
= MODE_ADD
;
921 mode_changes
[mode_count
].caps
= 0;
922 mode_changes
[mode_count
].nocaps
= 0;
923 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
924 mode_changes
[mode_count
].id
= NULL
;
925 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
929 chptr
->mode
.join_num
= joins
;
930 chptr
->mode
.join_time
= timeslice
;
932 else if(dir
== MODE_DEL
)
934 if(!chptr
->mode
.join_num
)
937 chptr
->mode
.join_num
= 0;
938 chptr
->mode
.join_time
= 0;
939 chptr
->join_count
= 0;
940 chptr
->join_delta
= 0;
942 mode_changes
[mode_count
].letter
= c
;
943 mode_changes
[mode_count
].dir
= MODE_DEL
;
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
= NULL
;
953 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
954 int alevel
, int parc
, int *parn
,
955 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
957 struct Channel
*targptr
= NULL
;
958 struct membership
*msptr
;
961 /* if +f is disabled, ignore local attempts to set it */
962 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
963 (dir
== MODE_ADD
) && (parc
> *parn
))
966 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
968 if (!(*errors
& SM_ERR_RPL_F
))
970 if (*chptr
->mode
.forward
== '\0')
971 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
973 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
974 *errors
|= SM_ERR_RPL_F
;
979 #ifndef FORWARD_OPERONLY
980 if(alevel
!= CHFL_CHANOP
)
982 if(!(*errors
& SM_ERR_NOOPS
))
983 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
984 me
.name
, source_p
->name
, chptr
->chname
);
985 *errors
|= SM_ERR_NOOPS
;
989 if(!IsOper(source_p
) && !IsServer(source_p
))
991 if(!(*errors
& SM_ERR_NOPRIVS
))
992 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
993 *errors
|= SM_ERR_NOPRIVS
;
998 if(dir
== MODE_ADD
&& parc
> *parn
)
1000 forward
= parv
[(*parn
)];
1003 if(EmptyString(forward
))
1005 if(!check_channel_name(forward
) ||
1006 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1008 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1011 /* don't forward to inconsistent target -- jilles */
1012 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
1014 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
1015 form_str(ERR_BADCHANNAME
), forward
);
1018 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1020 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1021 form_str(ERR_NOSUCHCHANNEL
), forward
);
1024 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1026 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1027 get_channel_access(source_p
, msptr
) != CHFL_CHANOP
)
1029 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1030 me
.name
, source_p
->name
, targptr
->chname
);
1035 strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1037 mode_changes
[mode_count
].letter
= c
;
1038 mode_changes
[mode_count
].dir
= MODE_ADD
;
1039 mode_changes
[mode_count
].caps
= 0;
1040 mode_changes
[mode_count
].nocaps
= 0;
1041 mode_changes
[mode_count
].mems
= ConfigChannel
.use_forward
? ALL_MEMBERS
: ONLY_SERVERS
;
1042 mode_changes
[mode_count
].id
= NULL
;
1043 mode_changes
[mode_count
++].arg
= forward
;
1045 else if(dir
== MODE_DEL
)
1047 if(!(*chptr
->mode
.forward
))
1050 *chptr
->mode
.forward
= '\0';
1052 mode_changes
[mode_count
].letter
= c
;
1053 mode_changes
[mode_count
].dir
= MODE_DEL
;
1054 mode_changes
[mode_count
].caps
= 0;
1055 mode_changes
[mode_count
].nocaps
= 0;
1056 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1057 mode_changes
[mode_count
].id
= NULL
;
1058 mode_changes
[mode_count
++].arg
= NULL
;
1063 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1064 int alevel
, int parc
, int *parn
,
1065 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1069 if(alevel
!= CHFL_CHANOP
)
1071 if(!(*errors
& SM_ERR_NOOPS
))
1072 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1073 me
.name
, source_p
->name
, chptr
->chname
);
1074 *errors
|= SM_ERR_NOOPS
;
1078 if(dir
== MODE_QUERY
)
1081 if((dir
== MODE_ADD
) && parc
> *parn
)
1083 key
= LOCAL_COPY(parv
[(*parn
)]);
1086 if(MyClient(source_p
))
1089 fix_key_remote(key
);
1091 if(EmptyString(key
))
1094 s_assert(key
[0] != ' ');
1095 strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1097 mode_changes
[mode_count
].letter
= c
;
1098 mode_changes
[mode_count
].dir
= MODE_ADD
;
1099 mode_changes
[mode_count
].caps
= 0;
1100 mode_changes
[mode_count
].nocaps
= 0;
1101 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1102 mode_changes
[mode_count
].id
= NULL
;
1103 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1105 else if(dir
== MODE_DEL
)
1107 static char splat
[] = "*";
1113 if(!(*chptr
->mode
.key
))
1116 /* hack time. when we get a +k-k mode, the +k arg is
1117 * chptr->mode.key, which the -k sets to \0, so hunt for a
1118 * +k when we get a -k, and set the arg to splat. --anfl
1120 for(i
= 0; i
< mode_count
; i
++)
1122 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1123 mode_changes
[i
].arg
= splat
;
1126 *chptr
->mode
.key
= 0;
1128 mode_changes
[mode_count
].letter
= c
;
1129 mode_changes
[mode_count
].dir
= MODE_DEL
;
1130 mode_changes
[mode_count
].caps
= 0;
1131 mode_changes
[mode_count
].nocaps
= 0;
1132 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1133 mode_changes
[mode_count
].id
= NULL
;
1134 mode_changes
[mode_count
++].arg
= "*";
1139 chm_regonly(struct Client
*source_p
, struct Channel
*chptr
,
1140 int alevel
, int parc
, int *parn
,
1141 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1143 if(alevel
!= CHFL_CHANOP
)
1145 if(!(*errors
& SM_ERR_NOOPS
))
1146 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1147 me
.name
, source_p
->name
, chptr
->chname
);
1148 *errors
|= SM_ERR_NOOPS
;
1152 if(dir
== MODE_QUERY
)
1155 if(((dir
== MODE_ADD
) && (chptr
->mode
.mode
& MODE_REGONLY
)) ||
1156 ((dir
== MODE_DEL
) && !(chptr
->mode
.mode
& MODE_REGONLY
)))
1160 chptr
->mode
.mode
|= MODE_REGONLY
;
1162 chptr
->mode
.mode
&= ~MODE_REGONLY
;
1164 mode_changes
[mode_count
].letter
= c
;
1165 mode_changes
[mode_count
].dir
= dir
;
1166 mode_changes
[mode_count
].caps
= CAP_SERVICE
;
1167 mode_changes
[mode_count
].nocaps
= 0;
1168 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1169 mode_changes
[mode_count
].id
= NULL
;
1170 mode_changes
[mode_count
++].arg
= NULL
;
1174 struct ChannelMode chmode_table
[256] =
1176 {chm_nosuch
, 0 }, /* 0x00 */
1177 {chm_nosuch
, 0 }, /* 0x01 */
1178 {chm_nosuch
, 0 }, /* 0x02 */
1179 {chm_nosuch
, 0 }, /* 0x03 */
1180 {chm_nosuch
, 0 }, /* 0x04 */
1181 {chm_nosuch
, 0 }, /* 0x05 */
1182 {chm_nosuch
, 0 }, /* 0x06 */
1183 {chm_nosuch
, 0 }, /* 0x07 */
1184 {chm_nosuch
, 0 }, /* 0x08 */
1185 {chm_nosuch
, 0 }, /* 0x09 */
1186 {chm_nosuch
, 0 }, /* 0x0a */
1187 {chm_nosuch
, 0 }, /* 0x0b */
1188 {chm_nosuch
, 0 }, /* 0x0c */
1189 {chm_nosuch
, 0 }, /* 0x0d */
1190 {chm_nosuch
, 0 }, /* 0x0e */
1191 {chm_nosuch
, 0 }, /* 0x0f */
1192 {chm_nosuch
, 0 }, /* 0x10 */
1193 {chm_nosuch
, 0 }, /* 0x11 */
1194 {chm_nosuch
, 0 }, /* 0x12 */
1195 {chm_nosuch
, 0 }, /* 0x13 */
1196 {chm_nosuch
, 0 }, /* 0x14 */
1197 {chm_nosuch
, 0 }, /* 0x15 */
1198 {chm_nosuch
, 0 }, /* 0x16 */
1199 {chm_nosuch
, 0 }, /* 0x17 */
1200 {chm_nosuch
, 0 }, /* 0x18 */
1201 {chm_nosuch
, 0 }, /* 0x19 */
1202 {chm_nosuch
, 0 }, /* 0x1a */
1203 {chm_nosuch
, 0 }, /* 0x1b */
1204 {chm_nosuch
, 0 }, /* 0x1c */
1205 {chm_nosuch
, 0 }, /* 0x1d */
1206 {chm_nosuch
, 0 }, /* 0x1e */
1207 {chm_nosuch
, 0 }, /* 0x1f */
1208 {chm_nosuch
, 0 }, /* 0x20 */
1209 {chm_nosuch
, 0 }, /* 0x21 */
1210 {chm_nosuch
, 0 }, /* 0x22 */
1211 {chm_nosuch
, 0 }, /* 0x23 */
1212 {chm_nosuch
, 0 }, /* 0x24 */
1213 {chm_nosuch
, 0 }, /* 0x25 */
1214 {chm_nosuch
, 0 }, /* 0x26 */
1215 {chm_nosuch
, 0 }, /* 0x27 */
1216 {chm_nosuch
, 0 }, /* 0x28 */
1217 {chm_nosuch
, 0 }, /* 0x29 */
1218 {chm_nosuch
, 0 }, /* 0x2a */
1219 {chm_nosuch
, 0 }, /* 0x2b */
1220 {chm_nosuch
, 0 }, /* 0x2c */
1221 {chm_nosuch
, 0 }, /* 0x2d */
1222 {chm_nosuch
, 0 }, /* 0x2e */
1223 {chm_nosuch
, 0 }, /* 0x2f */
1224 {chm_nosuch
, 0 }, /* 0x30 */
1225 {chm_nosuch
, 0 }, /* 0x31 */
1226 {chm_nosuch
, 0 }, /* 0x32 */
1227 {chm_nosuch
, 0 }, /* 0x33 */
1228 {chm_nosuch
, 0 }, /* 0x34 */
1229 {chm_nosuch
, 0 }, /* 0x35 */
1230 {chm_nosuch
, 0 }, /* 0x36 */
1231 {chm_nosuch
, 0 }, /* 0x37 */
1232 {chm_nosuch
, 0 }, /* 0x38 */
1233 {chm_nosuch
, 0 }, /* 0x39 */
1234 {chm_nosuch
, 0 }, /* 0x3a */
1235 {chm_nosuch
, 0 }, /* 0x3b */
1236 {chm_nosuch
, 0 }, /* 0x3c */
1237 {chm_nosuch
, 0 }, /* 0x3d */
1238 {chm_nosuch
, 0 }, /* 0x3e */
1239 {chm_nosuch
, 0 }, /* 0x3f */
1241 {chm_nosuch
, 0 }, /* @ */
1242 {chm_nosuch
, 0 }, /* A */
1243 {chm_nosuch
, 0 }, /* B */
1244 {chm_nosuch
, 0 }, /* C */
1245 {chm_nosuch
, 0 }, /* D */
1246 {chm_nosuch
, 0 }, /* E */
1247 {chm_simple
, MODE_FREETARGET
}, /* F */
1248 {chm_nosuch
, 0 }, /* G */
1249 {chm_nosuch
, 0 }, /* H */
1250 {chm_ban
, CHFL_INVEX
}, /* I */
1251 {chm_nosuch
, 0 }, /* J */
1252 {chm_nosuch
, 0 }, /* K */
1253 {chm_staff
, MODE_EXLIMIT
}, /* L */
1254 {chm_nosuch
, 0 }, /* M */
1255 {chm_nosuch
, 0 }, /* N */
1256 {chm_nosuch
, 0 }, /* O */
1257 {chm_staff
, MODE_PERMANENT
}, /* P */
1258 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1259 {chm_nosuch
, 0 }, /* R */
1260 {chm_nosuch
, 0 }, /* S */
1261 {chm_nosuch
, 0 }, /* T */
1262 {chm_nosuch
, 0 }, /* U */
1263 {chm_nosuch
, 0 }, /* V */
1264 {chm_nosuch
, 0 }, /* W */
1265 {chm_nosuch
, 0 }, /* X */
1266 {chm_nosuch
, 0 }, /* Y */
1267 {chm_nosuch
, 0 }, /* Z */
1274 {chm_nosuch
, 0 }, /* a */
1275 {chm_ban
, CHFL_BAN
}, /* b */
1276 {chm_simple
, MODE_NOCOLOR
}, /* c */
1277 {chm_nosuch
, 0 }, /* d */
1278 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1279 {chm_forward
, 0 }, /* f */
1280 {chm_simple
, MODE_FREEINVITE
}, /* g */
1281 {chm_nosuch
, 0 }, /* h */
1282 {chm_simple
, MODE_INVITEONLY
}, /* i */
1283 {chm_throttle
, 0 }, /* j */
1284 {chm_key
, 0 }, /* k */
1285 {chm_limit
, 0 }, /* l */
1286 {chm_simple
, MODE_MODERATED
}, /* m */
1287 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1288 {chm_op
, 0 }, /* o */
1289 {chm_simple
, MODE_PRIVATE
}, /* p */
1290 {chm_ban
, CHFL_QUIET
}, /* q */
1291 {chm_regonly
, 0 }, /* r */
1292 {chm_simple
, MODE_SECRET
}, /* s */
1293 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1294 {chm_nosuch
, 0 }, /* u */
1295 {chm_voice
, 0 }, /* v */
1296 {chm_nosuch
, 0 }, /* w */
1297 {chm_nosuch
, 0 }, /* x */
1298 {chm_nosuch
, 0 }, /* y */
1299 {chm_simple
, MODE_OPMODERATE
}, /* z */
1301 {chm_nosuch
, 0 }, /* 0x7b */
1302 {chm_nosuch
, 0 }, /* 0x7c */
1303 {chm_nosuch
, 0 }, /* 0x7d */
1304 {chm_nosuch
, 0 }, /* 0x7e */
1305 {chm_nosuch
, 0 }, /* 0x7f */
1307 {chm_nosuch
, 0 }, /* 0x80 */
1308 {chm_nosuch
, 0 }, /* 0x81 */
1309 {chm_nosuch
, 0 }, /* 0x82 */
1310 {chm_nosuch
, 0 }, /* 0x83 */
1311 {chm_nosuch
, 0 }, /* 0x84 */
1312 {chm_nosuch
, 0 }, /* 0x85 */
1313 {chm_nosuch
, 0 }, /* 0x86 */
1314 {chm_nosuch
, 0 }, /* 0x87 */
1315 {chm_nosuch
, 0 }, /* 0x88 */
1316 {chm_nosuch
, 0 }, /* 0x89 */
1317 {chm_nosuch
, 0 }, /* 0x8a */
1318 {chm_nosuch
, 0 }, /* 0x8b */
1319 {chm_nosuch
, 0 }, /* 0x8c */
1320 {chm_nosuch
, 0 }, /* 0x8d */
1321 {chm_nosuch
, 0 }, /* 0x8e */
1322 {chm_nosuch
, 0 }, /* 0x8f */
1324 {chm_nosuch
, 0 }, /* 0x90 */
1325 {chm_nosuch
, 0 }, /* 0x91 */
1326 {chm_nosuch
, 0 }, /* 0x92 */
1327 {chm_nosuch
, 0 }, /* 0x93 */
1328 {chm_nosuch
, 0 }, /* 0x94 */
1329 {chm_nosuch
, 0 }, /* 0x95 */
1330 {chm_nosuch
, 0 }, /* 0x96 */
1331 {chm_nosuch
, 0 }, /* 0x97 */
1332 {chm_nosuch
, 0 }, /* 0x98 */
1333 {chm_nosuch
, 0 }, /* 0x99 */
1334 {chm_nosuch
, 0 }, /* 0x9a */
1335 {chm_nosuch
, 0 }, /* 0x9b */
1336 {chm_nosuch
, 0 }, /* 0x9c */
1337 {chm_nosuch
, 0 }, /* 0x9d */
1338 {chm_nosuch
, 0 }, /* 0x9e */
1339 {chm_nosuch
, 0 }, /* 0x9f */
1341 {chm_nosuch
, 0 }, /* 0xa0 */
1342 {chm_nosuch
, 0 }, /* 0xa1 */
1343 {chm_nosuch
, 0 }, /* 0xa2 */
1344 {chm_nosuch
, 0 }, /* 0xa3 */
1345 {chm_nosuch
, 0 }, /* 0xa4 */
1346 {chm_nosuch
, 0 }, /* 0xa5 */
1347 {chm_nosuch
, 0 }, /* 0xa6 */
1348 {chm_nosuch
, 0 }, /* 0xa7 */
1349 {chm_nosuch
, 0 }, /* 0xa8 */
1350 {chm_nosuch
, 0 }, /* 0xa9 */
1351 {chm_nosuch
, 0 }, /* 0xaa */
1352 {chm_nosuch
, 0 }, /* 0xab */
1353 {chm_nosuch
, 0 }, /* 0xac */
1354 {chm_nosuch
, 0 }, /* 0xad */
1355 {chm_nosuch
, 0 }, /* 0xae */
1356 {chm_nosuch
, 0 }, /* 0xaf */
1358 {chm_nosuch
, 0 }, /* 0xb0 */
1359 {chm_nosuch
, 0 }, /* 0xb1 */
1360 {chm_nosuch
, 0 }, /* 0xb2 */
1361 {chm_nosuch
, 0 }, /* 0xb3 */
1362 {chm_nosuch
, 0 }, /* 0xb4 */
1363 {chm_nosuch
, 0 }, /* 0xb5 */
1364 {chm_nosuch
, 0 }, /* 0xb6 */
1365 {chm_nosuch
, 0 }, /* 0xb7 */
1366 {chm_nosuch
, 0 }, /* 0xb8 */
1367 {chm_nosuch
, 0 }, /* 0xb9 */
1368 {chm_nosuch
, 0 }, /* 0xba */
1369 {chm_nosuch
, 0 }, /* 0xbb */
1370 {chm_nosuch
, 0 }, /* 0xbc */
1371 {chm_nosuch
, 0 }, /* 0xbd */
1372 {chm_nosuch
, 0 }, /* 0xbe */
1373 {chm_nosuch
, 0 }, /* 0xbf */
1375 {chm_nosuch
, 0 }, /* 0xc0 */
1376 {chm_nosuch
, 0 }, /* 0xc1 */
1377 {chm_nosuch
, 0 }, /* 0xc2 */
1378 {chm_nosuch
, 0 }, /* 0xc3 */
1379 {chm_nosuch
, 0 }, /* 0xc4 */
1380 {chm_nosuch
, 0 }, /* 0xc5 */
1381 {chm_nosuch
, 0 }, /* 0xc6 */
1382 {chm_nosuch
, 0 }, /* 0xc7 */
1383 {chm_nosuch
, 0 }, /* 0xc8 */
1384 {chm_nosuch
, 0 }, /* 0xc9 */
1385 {chm_nosuch
, 0 }, /* 0xca */
1386 {chm_nosuch
, 0 }, /* 0xcb */
1387 {chm_nosuch
, 0 }, /* 0xcc */
1388 {chm_nosuch
, 0 }, /* 0xcd */
1389 {chm_nosuch
, 0 }, /* 0xce */
1390 {chm_nosuch
, 0 }, /* 0xcf */
1392 {chm_nosuch
, 0 }, /* 0xd0 */
1393 {chm_nosuch
, 0 }, /* 0xd1 */
1394 {chm_nosuch
, 0 }, /* 0xd2 */
1395 {chm_nosuch
, 0 }, /* 0xd3 */
1396 {chm_nosuch
, 0 }, /* 0xd4 */
1397 {chm_nosuch
, 0 }, /* 0xd5 */
1398 {chm_nosuch
, 0 }, /* 0xd6 */
1399 {chm_nosuch
, 0 }, /* 0xd7 */
1400 {chm_nosuch
, 0 }, /* 0xd8 */
1401 {chm_nosuch
, 0 }, /* 0xd9 */
1402 {chm_nosuch
, 0 }, /* 0xda */
1403 {chm_nosuch
, 0 }, /* 0xdb */
1404 {chm_nosuch
, 0 }, /* 0xdc */
1405 {chm_nosuch
, 0 }, /* 0xdd */
1406 {chm_nosuch
, 0 }, /* 0xde */
1407 {chm_nosuch
, 0 }, /* 0xdf */
1409 {chm_nosuch
, 0 }, /* 0xe0 */
1410 {chm_nosuch
, 0 }, /* 0xe1 */
1411 {chm_nosuch
, 0 }, /* 0xe2 */
1412 {chm_nosuch
, 0 }, /* 0xe3 */
1413 {chm_nosuch
, 0 }, /* 0xe4 */
1414 {chm_nosuch
, 0 }, /* 0xe5 */
1415 {chm_nosuch
, 0 }, /* 0xe6 */
1416 {chm_nosuch
, 0 }, /* 0xe7 */
1417 {chm_nosuch
, 0 }, /* 0xe8 */
1418 {chm_nosuch
, 0 }, /* 0xe9 */
1419 {chm_nosuch
, 0 }, /* 0xea */
1420 {chm_nosuch
, 0 }, /* 0xeb */
1421 {chm_nosuch
, 0 }, /* 0xec */
1422 {chm_nosuch
, 0 }, /* 0xed */
1423 {chm_nosuch
, 0 }, /* 0xee */
1424 {chm_nosuch
, 0 }, /* 0xef */
1426 {chm_nosuch
, 0 }, /* 0xf0 */
1427 {chm_nosuch
, 0 }, /* 0xf1 */
1428 {chm_nosuch
, 0 }, /* 0xf2 */
1429 {chm_nosuch
, 0 }, /* 0xf3 */
1430 {chm_nosuch
, 0 }, /* 0xf4 */
1431 {chm_nosuch
, 0 }, /* 0xf5 */
1432 {chm_nosuch
, 0 }, /* 0xf6 */
1433 {chm_nosuch
, 0 }, /* 0xf7 */
1434 {chm_nosuch
, 0 }, /* 0xf8 */
1435 {chm_nosuch
, 0 }, /* 0xf9 */
1436 {chm_nosuch
, 0 }, /* 0xfa */
1437 {chm_nosuch
, 0 }, /* 0xfb */
1438 {chm_nosuch
, 0 }, /* 0xfc */
1439 {chm_nosuch
, 0 }, /* 0xfd */
1440 {chm_nosuch
, 0 }, /* 0xfe */
1441 {chm_nosuch
, 0 }, /* 0xff */
1446 /* set_channel_mode()
1448 * inputs - client, source, channel, membership pointer, params
1450 * side effects - channel modes/memberships are changed, MODE is issued
1452 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
1455 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
1456 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
1458 static char modebuf
[BUFSIZE
];
1459 static char parabuf
[BUFSIZE
];
1462 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
1468 const char *ml
= parv
[0];
1470 struct Client
*fakesource_p
;
1476 alevel
= get_channel_access(source_p
, msptr
);
1478 /* Hide connecting server on netburst -- jilles */
1479 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
1482 fakesource_p
= source_p
;
1484 for(; (c
= *ml
) != 0; ml
++)
1498 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
1501 chmode_table
[(unsigned char) c
].mode_type
);
1506 /* bail out if we have nothing to do... */
1510 if(IsServer(source_p
))
1511 mlen
= ircsprintf(modebuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
1513 mlen
= ircsprintf(modebuf
, ":%s!%s@%s MODE %s ",
1514 source_p
->name
, source_p
->username
,
1515 source_p
->host
, chptr
->chname
);
1517 for(j
= 0, flags
= ALL_MEMBERS
; j
< 2; j
++, flags
= ONLY_CHANOPS
)
1520 mbuf
= modebuf
+ mlen
;
1523 paracount
= paralen
= 0;
1526 for(i
= 0; i
< mode_count
; i
++)
1528 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
1531 if(mode_changes
[i
].arg
!= NULL
)
1533 arglen
= strlen(mode_changes
[i
].arg
);
1535 if(arglen
> MODEBUFLEN
- 5)
1541 /* if we're creeping over MAXMODEPARAMSSERV, or over
1542 * bufsize (4 == +/-,modechar,two spaces) send now.
1544 if(mode_changes
[i
].arg
!= NULL
&&
1545 ((paracount
== MAXMODEPARAMSSERV
) ||
1546 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
1551 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
,
1556 paracount
= paralen
= 0;
1558 mbuf
= modebuf
+ mlen
;
1564 if(dir
!= mode_changes
[i
].dir
)
1566 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
1568 dir
= mode_changes
[i
].dir
;
1571 *mbuf
++ = mode_changes
[i
].letter
;
1574 if(mode_changes
[i
].arg
!= NULL
)
1577 len
= ircsprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
1583 if(paralen
&& parabuf
[paralen
- 1] == ' ')
1584 parabuf
[paralen
- 1] = '\0';
1588 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
, parabuf
);
1591 /* only propagate modes originating locally, or if we're hubbing */
1592 if(MyClient(source_p
) || dlink_list_length(&serv_list
) > 1)
1593 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);