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 $
37 #include "s_serv.h" /* captab */
41 #include "s_conf.h" /* ConfigFileEntry, ConfigChannel */
42 #include "s_newconf.h"
46 /* bitmasks for error returns, so we send once per call */
47 #define SM_ERR_NOTS 0x00000001 /* No TS on channel */
48 #define SM_ERR_NOOPS 0x00000002 /* No chan ops */
49 #define SM_ERR_UNKNOWN 0x00000004
50 #define SM_ERR_RPL_C 0x00000008
51 #define SM_ERR_RPL_B 0x00000010
52 #define SM_ERR_RPL_E 0x00000020
53 #define SM_ERR_NOTONCHANNEL 0x00000040 /* Not on channel */
54 #define SM_ERR_RPL_I 0x00000100
55 #define SM_ERR_RPL_D 0x00000200
56 #define SM_ERR_NOPRIVS 0x00000400
57 #define SM_ERR_RPL_Q 0x00000800
58 #define SM_ERR_RPL_F 0x00001000
60 #define MAXMODES_SIMPLE 46 /* a-zA-Z except bqeIov */
62 static struct ChModeChange mode_changes
[BUFSIZE
];
63 static int mode_count
;
64 static int mode_limit
;
65 static int mode_limit_simple
;
69 char cflagsmyinfo
[256];
71 int chmode_flags
[256];
73 /* OPTIMIZE ME! -- dwr */
75 construct_noparam_modes(void)
78 char *ptr
= cflagsbuf
;
79 char *ptr2
= cflagsmyinfo
;
80 static int prev_chmode_flags
[256];
85 for(i
= 0; i
< 256; i
++)
87 if( !(chmode_table
[i
].set_func
== chm_ban
) &&
88 !(chmode_table
[i
].set_func
== chm_forward
) &&
89 !(chmode_table
[i
].set_func
== chm_throttle
) &&
90 !(chmode_table
[i
].set_func
== chm_key
) &&
91 !(chmode_table
[i
].set_func
== chm_limit
) &&
92 !(chmode_table
[i
].set_func
== chm_op
) &&
93 !(chmode_table
[i
].set_func
== chm_voice
))
95 chmode_flags
[i
] = chmode_table
[i
].mode_type
;
102 if (prev_chmode_flags
[i
] != 0 && prev_chmode_flags
[i
] != chmode_flags
[i
])
104 if (chmode_flags
[i
] == 0)
106 chmode_table
[i
].set_func
= chm_orphaned
;
107 sendto_realops_snomask(SNO_DEBUG
, L_ALL
, "Cmode +%c is now orphaned", i
);
111 sendto_realops_snomask(SNO_DEBUG
, L_ALL
, "Orphaned cmode +%c is picked up by module", i
);
113 chmode_flags
[i
] = prev_chmode_flags
[i
];
116 prev_chmode_flags
[i
] = chmode_flags
[i
];
118 switch (chmode_flags
[i
])
121 case MODE_DISFORWARD
:
122 if(ConfigChannel
.use_forward
)
129 if(rb_dlink_list_length(&service_list
))
136 if(chmode_flags
[i
] != 0)
142 /* Should we leave orphaned check here? -- dwr */
143 if(!(chmode_table
[i
].set_func
== chm_nosuch
) && !(chmode_table
[i
].set_func
== chm_orphaned
))
157 * outputs - an available cflag bitmask or
158 * 0 if no cflags are available
159 * side effects - NONE
162 find_cflag_slot(void)
164 unsigned int all_cflags
= 0, my_cflag
= 0, i
;
166 for (i
= 0; i
< 256; i
++)
167 all_cflags
|= chmode_flags
[i
];
169 for (my_cflag
= 1; my_cflag
&& (all_cflags
& my_cflag
);
176 get_channel_access(struct Client
*source_p
, struct membership
*msptr
)
178 if(!MyClient(source_p
) || is_chanop(msptr
))
186 * inputs - client, channel, id to add, type
187 * outputs - 0 on failure, 1 on success
188 * side effects - given id is added to the appropriate list
191 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
,
192 rb_dlink_list
* list
, long mode_type
)
194 struct Ban
*actualBan
;
195 static char who
[USERHOST_REPLYLEN
];
196 char *realban
= LOCAL_COPY(banid
);
199 /* dont let local clients overflow the banlist, or set redundant
202 if(MyClient(source_p
))
204 if((rb_dlink_list_length(&chptr
->banlist
) + rb_dlink_list_length(&chptr
->exceptlist
) + rb_dlink_list_length(&chptr
->invexlist
) + rb_dlink_list_length(&chptr
->quietlist
)) >= (chptr
->mode
.mode
& MODE_EXLIMIT
? ConfigChannel
.max_bans_large
: ConfigChannel
.max_bans
))
206 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
207 me
.name
, source_p
->name
, chptr
->chname
, realban
);
211 RB_DLINK_FOREACH(ptr
, list
->head
)
213 actualBan
= ptr
->data
;
214 if(mask_match(actualBan
->banstr
, realban
))
218 /* dont let remotes set duplicates */
221 RB_DLINK_FOREACH(ptr
, list
->head
)
223 actualBan
= ptr
->data
;
224 if(!irccmp(actualBan
->banstr
, realban
))
230 if(IsPerson(source_p
))
231 rb_sprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
233 rb_strlcpy(who
, source_p
->name
, sizeof(who
));
235 actualBan
= allocate_ban(realban
, who
);
236 actualBan
->when
= rb_current_time();
238 rb_dlinkAdd(actualBan
, &actualBan
->node
, list
);
240 /* invalidate the can_send() cache */
241 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
249 * inputs - channel, id to remove, type
250 * outputs - 0 on failure, 1 on success
251 * side effects - given id is removed from the appropriate list
254 del_id(struct Channel
*chptr
, const char *banid
, rb_dlink_list
* list
, long mode_type
)
259 if(EmptyString(banid
))
262 RB_DLINK_FOREACH(ptr
, list
->head
)
266 if(irccmp(banid
, banptr
->banstr
) == 0)
268 rb_dlinkDelete(&banptr
->node
, list
);
271 /* invalidate the can_send() cache */
272 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
284 * input - string to check
285 * output - pointer to 'fixed' string, or "*" if empty
286 * side effects - any white space found becomes \0
289 check_string(char *s
)
292 static char splat
[] = "*";
309 * inputs - mask to pretty
310 * outputs - better version of the mask
311 * side effects - mask is chopped to limits, and transformed:
319 pretty_mask(const char *idmask
)
321 static char mask_buf
[BUFSIZE
];
323 char *nick
, *user
, *host
;
326 char ne
= 0, ue
= 0, he
= 0; /* save values at nick[NICKLEN], et all */
329 mask
= LOCAL_COPY(idmask
);
330 mask
= check_string(mask
);
333 nick
= user
= host
= splat
;
335 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
338 old_mask_pos
= mask_pos
;
342 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
343 t
= mask_buf
+ old_mask_pos
+ 1;
349 return mask_buf
+ old_mask_pos
;
353 if((t
= strchr(mask
, '@')) != NULL
)
360 if((t
= strchr(mask
, '!')) != NULL
)
375 else if((t
= strchr(mask
, '!')) != NULL
)
384 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
)
395 /* truncate values to max lengths */
396 if(strlen(nick
) > NICKLEN
- 1)
398 ne
= nick
[NICKLEN
- 1];
399 nick
[NICKLEN
- 1] = '\0';
401 if(strlen(user
) > USERLEN
)
404 user
[USERLEN
] = '\0';
406 if(strlen(host
) > HOSTLEN
)
409 host
[HOSTLEN
] = '\0';
412 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
414 /* restore mask, since we may need to use it again later */
420 nick
[NICKLEN
- 1] = ne
;
426 return mask_buf
+ old_mask_pos
;
432 * output - the same key, fixed
433 * side effects - anything below ascii 13 is discarded, ':' discarded,
434 * high ascii is dropped to lower half of ascii table
441 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
444 if(c
!= ':' && c
!= ',' && c
> ' ')
455 * ouput - the same key, fixed
456 * side effects - high ascii dropped to lower half of table,
457 * CR/LF/':' are dropped
460 fix_key_remote(char *arg
)
464 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
467 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
477 * The handlers for each specific mode.
480 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
481 int alevel
, int parc
, int *parn
,
482 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
484 if(*errors
& SM_ERR_UNKNOWN
)
486 *errors
|= SM_ERR_UNKNOWN
;
487 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
491 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
492 int alevel
, int parc
, int *parn
,
493 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
495 if(alevel
!= CHFL_CHANOP
)
497 if(!(*errors
& SM_ERR_NOOPS
))
498 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
499 me
.name
, source_p
->name
, chptr
->chname
);
500 *errors
|= SM_ERR_NOOPS
;
504 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
508 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
510 /* if +f is disabled, ignore an attempt to set +QF locally */
511 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
512 (c
== 'Q' || c
== 'F'))
515 chptr
->mode
.mode
|= mode_type
;
517 mode_changes
[mode_count
].letter
= c
;
518 mode_changes
[mode_count
].dir
= MODE_ADD
;
519 mode_changes
[mode_count
].caps
= 0;
520 mode_changes
[mode_count
].nocaps
= 0;
521 mode_changes
[mode_count
].id
= NULL
;
522 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
523 mode_changes
[mode_count
++].arg
= NULL
;
525 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
527 chptr
->mode
.mode
&= ~mode_type
;
529 mode_changes
[mode_count
].letter
= c
;
530 mode_changes
[mode_count
].dir
= MODE_DEL
;
531 mode_changes
[mode_count
].caps
= 0;
532 mode_changes
[mode_count
].nocaps
= 0;
533 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
534 mode_changes
[mode_count
].id
= NULL
;
535 mode_changes
[mode_count
++].arg
= NULL
;
540 chm_orphaned(struct Client
*source_p
, struct Channel
*chptr
,
541 int alevel
, int parc
, int *parn
,
542 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
544 if(MyClient(source_p
))
547 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
549 chptr
->mode
.mode
|= mode_type
;
551 mode_changes
[mode_count
].letter
= c
;
552 mode_changes
[mode_count
].dir
= MODE_ADD
;
553 mode_changes
[mode_count
].caps
= 0;
554 mode_changes
[mode_count
].nocaps
= 0;
555 mode_changes
[mode_count
].id
= NULL
;
556 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
557 mode_changes
[mode_count
++].arg
= NULL
;
559 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
561 chptr
->mode
.mode
&= ~mode_type
;
563 mode_changes
[mode_count
].letter
= c
;
564 mode_changes
[mode_count
].dir
= MODE_DEL
;
565 mode_changes
[mode_count
].caps
= 0;
566 mode_changes
[mode_count
].nocaps
= 0;
567 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
568 mode_changes
[mode_count
].id
= NULL
;
569 mode_changes
[mode_count
++].arg
= NULL
;
574 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
575 int alevel
, int parc
, int *parn
,
576 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
578 if(!IsOper(source_p
) && !IsServer(source_p
))
580 if(!(*errors
& SM_ERR_NOPRIVS
))
581 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
582 *errors
|= SM_ERR_NOPRIVS
;
585 if(MyClient(source_p
) && !IsOperResv(source_p
))
587 if(!(*errors
& SM_ERR_NOPRIVS
))
588 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
589 source_p
->name
, "resv");
590 *errors
|= SM_ERR_NOPRIVS
;
594 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
598 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
600 chptr
->mode
.mode
|= mode_type
;
602 mode_changes
[mode_count
].letter
= c
;
603 mode_changes
[mode_count
].dir
= MODE_ADD
;
604 mode_changes
[mode_count
].caps
= 0;
605 mode_changes
[mode_count
].nocaps
= 0;
606 mode_changes
[mode_count
].id
= NULL
;
607 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
608 mode_changes
[mode_count
++].arg
= NULL
;
610 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
612 chptr
->mode
.mode
&= ~mode_type
;
614 mode_changes
[mode_count
].letter
= c
;
615 mode_changes
[mode_count
].dir
= MODE_DEL
;
616 mode_changes
[mode_count
].caps
= 0;
617 mode_changes
[mode_count
].nocaps
= 0;
618 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
619 mode_changes
[mode_count
].id
= NULL
;
620 mode_changes
[mode_count
++].arg
= NULL
;
625 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
626 int alevel
, int parc
, int *parn
,
627 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
630 const char *raw_mask
;
643 list
= &chptr
->banlist
;
644 errorval
= SM_ERR_RPL_B
;
645 rpl_list
= RPL_BANLIST
;
646 rpl_endlist
= RPL_ENDOFBANLIST
;
652 /* if +e is disabled, allow all but +e locally */
653 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
654 ((dir
== MODE_ADD
) && (parc
> *parn
)))
657 list
= &chptr
->exceptlist
;
658 errorval
= SM_ERR_RPL_E
;
659 rpl_list
= RPL_EXCEPTLIST
;
660 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
663 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
670 /* if +I is disabled, allow all but +I locally */
671 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
672 (dir
== MODE_ADD
) && (parc
> *parn
))
675 list
= &chptr
->invexlist
;
676 errorval
= SM_ERR_RPL_I
;
677 rpl_list
= RPL_INVITELIST
;
678 rpl_endlist
= RPL_ENDOFINVITELIST
;
681 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
688 list
= &chptr
->quietlist
;
689 errorval
= SM_ERR_RPL_Q
;
690 rpl_list
= RPL_BANLIST
;
691 rpl_endlist
= RPL_ENDOFBANLIST
;
697 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
702 if(dir
== 0 || parc
<= *parn
)
704 if((*errors
& errorval
) != 0)
708 /* non-ops cant see +eI lists.. */
709 if(alevel
!= CHFL_CHANOP
&& mode_type
!= CHFL_BAN
&&
710 mode_type
!= CHFL_QUIET
)
712 if(!(*errors
& SM_ERR_NOOPS
))
713 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
714 me
.name
, source_p
->name
, chptr
->chname
);
715 *errors
|= SM_ERR_NOOPS
;
719 RB_DLINK_FOREACH(ptr
, list
->head
)
722 sendto_one(source_p
, form_str(rpl_list
),
723 me
.name
, source_p
->name
, chptr
->chname
,
724 banptr
->banstr
, banptr
->who
, banptr
->when
);
726 if (mode_type
== CHFL_QUIET
)
727 sendto_one(source_p
, ":%s %d %s %s :End of Channel Quiet List", me
.name
, rpl_endlist
, source_p
->name
, chptr
->chname
);
729 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
733 if(alevel
!= CHFL_CHANOP
)
735 if(!(*errors
& SM_ERR_NOOPS
))
736 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
737 me
.name
, source_p
->name
, chptr
->chname
);
738 *errors
|= SM_ERR_NOOPS
;
742 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
745 raw_mask
= parv
[(*parn
)];
748 /* empty ban, or starts with ':' which messes up s2s, ignore it */
749 if(EmptyString(raw_mask
) || *raw_mask
== ':')
752 if(!MyClient(source_p
))
754 if(strchr(raw_mask
, ' '))
760 mask
= pretty_mask(raw_mask
);
762 /* we'd have problems parsing this, hyb6 does it too
763 * also make sure it will always fit on a line with channel
766 if(strlen(mask
) > IRCD_MIN(BANLEN
, MODEBUFLEN
- 5))
769 /* if we're adding a NEW id */
772 if (*mask
== '$' && MyClient(source_p
))
774 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
775 /* XXX perhaps return an error message here */
779 /* dont allow local clients to overflow the banlist, dont
780 * let remote servers set duplicate bans
782 if(!add_id(source_p
, chptr
, mask
, list
, mode_type
))
785 mode_changes
[mode_count
].letter
= c
;
786 mode_changes
[mode_count
].dir
= MODE_ADD
;
787 mode_changes
[mode_count
].caps
= caps
;
788 mode_changes
[mode_count
].nocaps
= 0;
789 mode_changes
[mode_count
].mems
= mems
;
790 mode_changes
[mode_count
].id
= NULL
;
791 mode_changes
[mode_count
++].arg
= mask
;
793 else if(dir
== MODE_DEL
)
795 if(del_id(chptr
, mask
, list
, mode_type
) == 0)
797 /* mask isn't a valid ban, check raw_mask */
798 if(del_id(chptr
, raw_mask
, list
, mode_type
))
802 mode_changes
[mode_count
].letter
= c
;
803 mode_changes
[mode_count
].dir
= MODE_DEL
;
804 mode_changes
[mode_count
].caps
= caps
;
805 mode_changes
[mode_count
].nocaps
= 0;
806 mode_changes
[mode_count
].mems
= mems
;
807 mode_changes
[mode_count
].id
= NULL
;
808 mode_changes
[mode_count
++].arg
= mask
;
813 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
814 int alevel
, int parc
, int *parn
,
815 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
817 struct membership
*mstptr
;
819 struct Client
*targ_p
;
821 if(alevel
!= CHFL_CHANOP
)
823 if(!(*errors
& SM_ERR_NOOPS
))
824 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
825 me
.name
, source_p
->name
, chptr
->chname
);
826 *errors
|= SM_ERR_NOOPS
;
830 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
833 opnick
= parv
[(*parn
)];
837 if(EmptyString(opnick
))
839 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
843 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
848 mstptr
= find_channel_membership(chptr
, targ_p
);
852 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
853 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
854 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
855 *errors
|= SM_ERR_NOTONCHANNEL
;
859 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
864 if(targ_p
== source_p
)
867 mode_changes
[mode_count
].letter
= c
;
868 mode_changes
[mode_count
].dir
= MODE_ADD
;
869 mode_changes
[mode_count
].caps
= 0;
870 mode_changes
[mode_count
].nocaps
= 0;
871 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
872 mode_changes
[mode_count
].id
= targ_p
->id
;
873 mode_changes
[mode_count
].arg
= targ_p
->name
;
874 mode_changes
[mode_count
++].client
= targ_p
;
876 mstptr
->flags
|= CHFL_CHANOP
;
880 if(MyClient(source_p
) && IsService(targ_p
))
882 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
883 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
887 mode_changes
[mode_count
].letter
= c
;
888 mode_changes
[mode_count
].dir
= MODE_DEL
;
889 mode_changes
[mode_count
].caps
= 0;
890 mode_changes
[mode_count
].nocaps
= 0;
891 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
892 mode_changes
[mode_count
].id
= targ_p
->id
;
893 mode_changes
[mode_count
].arg
= targ_p
->name
;
894 mode_changes
[mode_count
++].client
= targ_p
;
896 mstptr
->flags
&= ~CHFL_CHANOP
;
901 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
902 int alevel
, int parc
, int *parn
,
903 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
905 struct membership
*mstptr
;
907 struct Client
*targ_p
;
909 if(alevel
!= CHFL_CHANOP
)
911 if(!(*errors
& SM_ERR_NOOPS
))
912 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
913 me
.name
, source_p
->name
, chptr
->chname
);
914 *errors
|= SM_ERR_NOOPS
;
918 if((dir
== MODE_QUERY
) || parc
<= *parn
)
921 opnick
= parv
[(*parn
)];
925 if(EmptyString(opnick
))
927 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
931 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
936 mstptr
= find_channel_membership(chptr
, targ_p
);
940 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
941 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
942 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
943 *errors
|= SM_ERR_NOTONCHANNEL
;
947 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
952 mode_changes
[mode_count
].letter
= c
;
953 mode_changes
[mode_count
].dir
= MODE_ADD
;
954 mode_changes
[mode_count
].caps
= 0;
955 mode_changes
[mode_count
].nocaps
= 0;
956 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
957 mode_changes
[mode_count
].id
= targ_p
->id
;
958 mode_changes
[mode_count
].arg
= targ_p
->name
;
959 mode_changes
[mode_count
++].client
= targ_p
;
961 mstptr
->flags
|= CHFL_VOICE
;
965 mode_changes
[mode_count
].letter
= 'v';
966 mode_changes
[mode_count
].dir
= MODE_DEL
;
967 mode_changes
[mode_count
].caps
= 0;
968 mode_changes
[mode_count
].nocaps
= 0;
969 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
970 mode_changes
[mode_count
].id
= targ_p
->id
;
971 mode_changes
[mode_count
].arg
= targ_p
->name
;
972 mode_changes
[mode_count
++].client
= targ_p
;
974 mstptr
->flags
&= ~CHFL_VOICE
;
979 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
980 int alevel
, int parc
, int *parn
,
981 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
984 static char limitstr
[30];
987 if(alevel
!= CHFL_CHANOP
)
989 if(!(*errors
& SM_ERR_NOOPS
))
990 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
991 me
.name
, source_p
->name
, chptr
->chname
);
992 *errors
|= SM_ERR_NOOPS
;
996 if(dir
== MODE_QUERY
)
999 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1002 if((dir
== MODE_ADD
) && parc
> *parn
)
1004 lstr
= parv
[(*parn
)];
1007 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
1010 rb_sprintf(limitstr
, "%d", limit
);
1012 mode_changes
[mode_count
].letter
= c
;
1013 mode_changes
[mode_count
].dir
= MODE_ADD
;
1014 mode_changes
[mode_count
].caps
= 0;
1015 mode_changes
[mode_count
].nocaps
= 0;
1016 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1017 mode_changes
[mode_count
].id
= NULL
;
1018 mode_changes
[mode_count
++].arg
= limitstr
;
1020 chptr
->mode
.limit
= limit
;
1022 else if(dir
== MODE_DEL
)
1024 if(!chptr
->mode
.limit
)
1027 chptr
->mode
.limit
= 0;
1029 mode_changes
[mode_count
].letter
= c
;
1030 mode_changes
[mode_count
].dir
= MODE_DEL
;
1031 mode_changes
[mode_count
].caps
= 0;
1032 mode_changes
[mode_count
].nocaps
= 0;
1033 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1034 mode_changes
[mode_count
].id
= NULL
;
1035 mode_changes
[mode_count
++].arg
= NULL
;
1040 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
1041 int alevel
, int parc
, int *parn
,
1042 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1044 int joins
= 0, timeslice
= 0;
1046 if(alevel
!= CHFL_CHANOP
)
1048 if(!(*errors
& SM_ERR_NOOPS
))
1049 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1050 me
.name
, source_p
->name
, chptr
->chname
);
1051 *errors
|= SM_ERR_NOOPS
;
1055 if(dir
== MODE_QUERY
)
1058 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1061 if((dir
== MODE_ADD
) && parc
> *parn
)
1063 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
1065 if(!joins
|| !timeslice
)
1068 mode_changes
[mode_count
].letter
= c
;
1069 mode_changes
[mode_count
].dir
= MODE_ADD
;
1070 mode_changes
[mode_count
].caps
= 0;
1071 mode_changes
[mode_count
].nocaps
= 0;
1072 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1073 mode_changes
[mode_count
].id
= NULL
;
1074 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
1078 chptr
->mode
.join_num
= joins
;
1079 chptr
->mode
.join_time
= timeslice
;
1081 else if(dir
== MODE_DEL
)
1083 if(!chptr
->mode
.join_num
)
1086 chptr
->mode
.join_num
= 0;
1087 chptr
->mode
.join_time
= 0;
1088 chptr
->join_count
= 0;
1089 chptr
->join_delta
= 0;
1091 mode_changes
[mode_count
].letter
= c
;
1092 mode_changes
[mode_count
].dir
= MODE_DEL
;
1093 mode_changes
[mode_count
].caps
= 0;
1094 mode_changes
[mode_count
].nocaps
= 0;
1095 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1096 mode_changes
[mode_count
].id
= NULL
;
1097 mode_changes
[mode_count
++].arg
= NULL
;
1102 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
1103 int alevel
, int parc
, int *parn
,
1104 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1106 struct Channel
*targptr
= NULL
;
1107 struct membership
*msptr
;
1108 const char *forward
;
1110 /* if +f is disabled, ignore local attempts to set it */
1111 if(!ConfigChannel
.use_forward
&& MyClient(source_p
) &&
1112 (dir
== MODE_ADD
) && (parc
> *parn
))
1115 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
1117 if (!(*errors
& SM_ERR_RPL_F
))
1119 if (*chptr
->mode
.forward
== '\0')
1120 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
1122 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
1123 *errors
|= SM_ERR_RPL_F
;
1128 #ifndef FORWARD_OPERONLY
1129 if(alevel
!= CHFL_CHANOP
)
1131 if(!(*errors
& SM_ERR_NOOPS
))
1132 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1133 me
.name
, source_p
->name
, chptr
->chname
);
1134 *errors
|= SM_ERR_NOOPS
;
1138 if(!IsOper(source_p
) && !IsServer(source_p
))
1140 if(!(*errors
& SM_ERR_NOPRIVS
))
1141 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
1142 *errors
|= SM_ERR_NOPRIVS
;
1147 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1150 if(dir
== MODE_ADD
&& parc
> *parn
)
1152 forward
= parv
[(*parn
)];
1155 if(EmptyString(forward
))
1157 if(!check_channel_name(forward
) ||
1158 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1160 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1163 /* don't forward to inconsistent target -- jilles */
1164 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
1166 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
1167 form_str(ERR_BADCHANNAME
), forward
);
1170 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1172 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1173 form_str(ERR_NOSUCHCHANNEL
), forward
);
1176 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1178 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1179 get_channel_access(source_p
, msptr
) != CHFL_CHANOP
)
1181 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1182 me
.name
, source_p
->name
, targptr
->chname
);
1187 rb_strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1189 mode_changes
[mode_count
].letter
= c
;
1190 mode_changes
[mode_count
].dir
= MODE_ADD
;
1191 mode_changes
[mode_count
].caps
= 0;
1192 mode_changes
[mode_count
].nocaps
= 0;
1193 mode_changes
[mode_count
].mems
= ConfigChannel
.use_forward
? ALL_MEMBERS
: ONLY_SERVERS
;
1194 mode_changes
[mode_count
].id
= NULL
;
1195 mode_changes
[mode_count
++].arg
= forward
;
1197 else if(dir
== MODE_DEL
)
1199 if(!(*chptr
->mode
.forward
))
1202 *chptr
->mode
.forward
= '\0';
1204 mode_changes
[mode_count
].letter
= c
;
1205 mode_changes
[mode_count
].dir
= MODE_DEL
;
1206 mode_changes
[mode_count
].caps
= 0;
1207 mode_changes
[mode_count
].nocaps
= 0;
1208 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1209 mode_changes
[mode_count
].id
= NULL
;
1210 mode_changes
[mode_count
++].arg
= NULL
;
1215 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1216 int alevel
, int parc
, int *parn
,
1217 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1221 if(alevel
!= CHFL_CHANOP
)
1223 if(!(*errors
& SM_ERR_NOOPS
))
1224 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1225 me
.name
, source_p
->name
, chptr
->chname
);
1226 *errors
|= SM_ERR_NOOPS
;
1230 if(dir
== MODE_QUERY
)
1233 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1236 if((dir
== MODE_ADD
) && parc
> *parn
)
1238 key
= LOCAL_COPY(parv
[(*parn
)]);
1241 if(MyClient(source_p
))
1244 fix_key_remote(key
);
1246 if(EmptyString(key
))
1249 s_assert(key
[0] != ' ');
1250 rb_strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1252 mode_changes
[mode_count
].letter
= c
;
1253 mode_changes
[mode_count
].dir
= MODE_ADD
;
1254 mode_changes
[mode_count
].caps
= 0;
1255 mode_changes
[mode_count
].nocaps
= 0;
1256 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1257 mode_changes
[mode_count
].id
= NULL
;
1258 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1260 else if(dir
== MODE_DEL
)
1262 static char splat
[] = "*";
1268 if(!(*chptr
->mode
.key
))
1271 /* hack time. when we get a +k-k mode, the +k arg is
1272 * chptr->mode.key, which the -k sets to \0, so hunt for a
1273 * +k when we get a -k, and set the arg to splat. --anfl
1275 for(i
= 0; i
< mode_count
; i
++)
1277 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1278 mode_changes
[i
].arg
= splat
;
1281 *chptr
->mode
.key
= 0;
1283 mode_changes
[mode_count
].letter
= c
;
1284 mode_changes
[mode_count
].dir
= MODE_DEL
;
1285 mode_changes
[mode_count
].caps
= 0;
1286 mode_changes
[mode_count
].nocaps
= 0;
1287 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1288 mode_changes
[mode_count
].id
= NULL
;
1289 mode_changes
[mode_count
++].arg
= "*";
1294 chm_regonly(struct Client
*source_p
, struct Channel
*chptr
,
1295 int alevel
, int parc
, int *parn
,
1296 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1298 if(alevel
!= CHFL_CHANOP
)
1300 if(!(*errors
& SM_ERR_NOOPS
))
1301 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1302 me
.name
, source_p
->name
, chptr
->chname
);
1303 *errors
|= SM_ERR_NOOPS
;
1307 if(dir
== MODE_QUERY
)
1310 if(((dir
== MODE_ADD
) && (chptr
->mode
.mode
& mode_type
)) ||
1311 ((dir
== MODE_DEL
) && !(chptr
->mode
.mode
& mode_type
)))
1314 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1318 chptr
->mode
.mode
|= mode_type
;
1320 chptr
->mode
.mode
&= ~mode_type
;
1322 mode_changes
[mode_count
].letter
= c
;
1323 mode_changes
[mode_count
].dir
= dir
;
1324 mode_changes
[mode_count
].caps
= CAP_SERVICE
;
1325 mode_changes
[mode_count
].nocaps
= 0;
1326 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1327 mode_changes
[mode_count
].id
= NULL
;
1328 mode_changes
[mode_count
++].arg
= NULL
;
1332 struct ChannelMode chmode_table
[256] =
1334 {chm_nosuch
, 0 }, /* 0x00 */
1335 {chm_nosuch
, 0 }, /* 0x01 */
1336 {chm_nosuch
, 0 }, /* 0x02 */
1337 {chm_nosuch
, 0 }, /* 0x03 */
1338 {chm_nosuch
, 0 }, /* 0x04 */
1339 {chm_nosuch
, 0 }, /* 0x05 */
1340 {chm_nosuch
, 0 }, /* 0x06 */
1341 {chm_nosuch
, 0 }, /* 0x07 */
1342 {chm_nosuch
, 0 }, /* 0x08 */
1343 {chm_nosuch
, 0 }, /* 0x09 */
1344 {chm_nosuch
, 0 }, /* 0x0a */
1345 {chm_nosuch
, 0 }, /* 0x0b */
1346 {chm_nosuch
, 0 }, /* 0x0c */
1347 {chm_nosuch
, 0 }, /* 0x0d */
1348 {chm_nosuch
, 0 }, /* 0x0e */
1349 {chm_nosuch
, 0 }, /* 0x0f */
1350 {chm_nosuch
, 0 }, /* 0x10 */
1351 {chm_nosuch
, 0 }, /* 0x11 */
1352 {chm_nosuch
, 0 }, /* 0x12 */
1353 {chm_nosuch
, 0 }, /* 0x13 */
1354 {chm_nosuch
, 0 }, /* 0x14 */
1355 {chm_nosuch
, 0 }, /* 0x15 */
1356 {chm_nosuch
, 0 }, /* 0x16 */
1357 {chm_nosuch
, 0 }, /* 0x17 */
1358 {chm_nosuch
, 0 }, /* 0x18 */
1359 {chm_nosuch
, 0 }, /* 0x19 */
1360 {chm_nosuch
, 0 }, /* 0x1a */
1361 {chm_nosuch
, 0 }, /* 0x1b */
1362 {chm_nosuch
, 0 }, /* 0x1c */
1363 {chm_nosuch
, 0 }, /* 0x1d */
1364 {chm_nosuch
, 0 }, /* 0x1e */
1365 {chm_nosuch
, 0 }, /* 0x1f */
1366 {chm_nosuch
, 0 }, /* 0x20 */
1367 {chm_nosuch
, 0 }, /* 0x21 */
1368 {chm_nosuch
, 0 }, /* 0x22 */
1369 {chm_nosuch
, 0 }, /* 0x23 */
1370 {chm_nosuch
, 0 }, /* 0x24 */
1371 {chm_nosuch
, 0 }, /* 0x25 */
1372 {chm_nosuch
, 0 }, /* 0x26 */
1373 {chm_nosuch
, 0 }, /* 0x27 */
1374 {chm_nosuch
, 0 }, /* 0x28 */
1375 {chm_nosuch
, 0 }, /* 0x29 */
1376 {chm_nosuch
, 0 }, /* 0x2a */
1377 {chm_nosuch
, 0 }, /* 0x2b */
1378 {chm_nosuch
, 0 }, /* 0x2c */
1379 {chm_nosuch
, 0 }, /* 0x2d */
1380 {chm_nosuch
, 0 }, /* 0x2e */
1381 {chm_nosuch
, 0 }, /* 0x2f */
1382 {chm_nosuch
, 0 }, /* 0x30 */
1383 {chm_nosuch
, 0 }, /* 0x31 */
1384 {chm_nosuch
, 0 }, /* 0x32 */
1385 {chm_nosuch
, 0 }, /* 0x33 */
1386 {chm_nosuch
, 0 }, /* 0x34 */
1387 {chm_nosuch
, 0 }, /* 0x35 */
1388 {chm_nosuch
, 0 }, /* 0x36 */
1389 {chm_nosuch
, 0 }, /* 0x37 */
1390 {chm_nosuch
, 0 }, /* 0x38 */
1391 {chm_nosuch
, 0 }, /* 0x39 */
1392 {chm_nosuch
, 0 }, /* 0x3a */
1393 {chm_nosuch
, 0 }, /* 0x3b */
1394 {chm_nosuch
, 0 }, /* 0x3c */
1395 {chm_nosuch
, 0 }, /* 0x3d */
1396 {chm_nosuch
, 0 }, /* 0x3e */
1397 {chm_nosuch
, 0 }, /* 0x3f */
1399 {chm_nosuch
, 0 }, /* @ */
1400 {chm_nosuch
, 0 }, /* A */
1401 {chm_nosuch
, 0 }, /* B */
1402 {chm_nosuch
, 0 }, /* C */
1403 {chm_nosuch
, 0 }, /* D */
1404 {chm_nosuch
, 0 }, /* E */
1405 {chm_simple
, MODE_FREETARGET
}, /* F */
1406 {chm_nosuch
, 0 }, /* G */
1407 {chm_nosuch
, 0 }, /* H */
1408 {chm_ban
, CHFL_INVEX
}, /* I */
1409 {chm_nosuch
, 0 }, /* J */
1410 {chm_nosuch
, 0 }, /* K */
1411 {chm_staff
, MODE_EXLIMIT
}, /* L */
1412 {chm_nosuch
, 0 }, /* M */
1413 {chm_nosuch
, 0 }, /* N */
1414 {chm_nosuch
, 0 }, /* O */
1415 {chm_staff
, MODE_PERMANENT
}, /* P */
1416 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1417 {chm_nosuch
, 0 }, /* R */
1418 {chm_nosuch
, 0 }, /* S */
1419 {chm_nosuch
, 0 }, /* T */
1420 {chm_nosuch
, 0 }, /* U */
1421 {chm_nosuch
, 0 }, /* V */
1422 {chm_nosuch
, 0 }, /* W */
1423 {chm_nosuch
, 0 }, /* X */
1424 {chm_nosuch
, 0 }, /* Y */
1425 {chm_nosuch
, 0 }, /* Z */
1432 {chm_nosuch
, 0 }, /* a */
1433 {chm_ban
, CHFL_BAN
}, /* b */
1434 {chm_simple
, MODE_NOCOLOR
}, /* c */
1435 {chm_nosuch
, 0 }, /* d */
1436 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1437 {chm_forward
, 0 }, /* f */
1438 {chm_simple
, MODE_FREEINVITE
}, /* g */
1439 {chm_nosuch
, 0 }, /* h */
1440 {chm_simple
, MODE_INVITEONLY
}, /* i */
1441 {chm_throttle
, 0 }, /* j */
1442 {chm_key
, 0 }, /* k */
1443 {chm_limit
, 0 }, /* l */
1444 {chm_simple
, MODE_MODERATED
}, /* m */
1445 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1446 {chm_op
, 0 }, /* o */
1447 {chm_simple
, MODE_PRIVATE
}, /* p */
1448 {chm_ban
, CHFL_QUIET
}, /* q */
1449 {chm_regonly
, MODE_REGONLY
}, /* r */
1450 {chm_simple
, MODE_SECRET
}, /* s */
1451 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1452 {chm_nosuch
, 0 }, /* u */
1453 {chm_voice
, 0 }, /* v */
1454 {chm_nosuch
, 0 }, /* w */
1455 {chm_nosuch
, 0 }, /* x */
1456 {chm_nosuch
, 0 }, /* y */
1457 {chm_simple
, MODE_OPMODERATE
}, /* z */
1459 {chm_nosuch
, 0 }, /* 0x7b */
1460 {chm_nosuch
, 0 }, /* 0x7c */
1461 {chm_nosuch
, 0 }, /* 0x7d */
1462 {chm_nosuch
, 0 }, /* 0x7e */
1463 {chm_nosuch
, 0 }, /* 0x7f */
1465 {chm_nosuch
, 0 }, /* 0x80 */
1466 {chm_nosuch
, 0 }, /* 0x81 */
1467 {chm_nosuch
, 0 }, /* 0x82 */
1468 {chm_nosuch
, 0 }, /* 0x83 */
1469 {chm_nosuch
, 0 }, /* 0x84 */
1470 {chm_nosuch
, 0 }, /* 0x85 */
1471 {chm_nosuch
, 0 }, /* 0x86 */
1472 {chm_nosuch
, 0 }, /* 0x87 */
1473 {chm_nosuch
, 0 }, /* 0x88 */
1474 {chm_nosuch
, 0 }, /* 0x89 */
1475 {chm_nosuch
, 0 }, /* 0x8a */
1476 {chm_nosuch
, 0 }, /* 0x8b */
1477 {chm_nosuch
, 0 }, /* 0x8c */
1478 {chm_nosuch
, 0 }, /* 0x8d */
1479 {chm_nosuch
, 0 }, /* 0x8e */
1480 {chm_nosuch
, 0 }, /* 0x8f */
1482 {chm_nosuch
, 0 }, /* 0x90 */
1483 {chm_nosuch
, 0 }, /* 0x91 */
1484 {chm_nosuch
, 0 }, /* 0x92 */
1485 {chm_nosuch
, 0 }, /* 0x93 */
1486 {chm_nosuch
, 0 }, /* 0x94 */
1487 {chm_nosuch
, 0 }, /* 0x95 */
1488 {chm_nosuch
, 0 }, /* 0x96 */
1489 {chm_nosuch
, 0 }, /* 0x97 */
1490 {chm_nosuch
, 0 }, /* 0x98 */
1491 {chm_nosuch
, 0 }, /* 0x99 */
1492 {chm_nosuch
, 0 }, /* 0x9a */
1493 {chm_nosuch
, 0 }, /* 0x9b */
1494 {chm_nosuch
, 0 }, /* 0x9c */
1495 {chm_nosuch
, 0 }, /* 0x9d */
1496 {chm_nosuch
, 0 }, /* 0x9e */
1497 {chm_nosuch
, 0 }, /* 0x9f */
1499 {chm_nosuch
, 0 }, /* 0xa0 */
1500 {chm_nosuch
, 0 }, /* 0xa1 */
1501 {chm_nosuch
, 0 }, /* 0xa2 */
1502 {chm_nosuch
, 0 }, /* 0xa3 */
1503 {chm_nosuch
, 0 }, /* 0xa4 */
1504 {chm_nosuch
, 0 }, /* 0xa5 */
1505 {chm_nosuch
, 0 }, /* 0xa6 */
1506 {chm_nosuch
, 0 }, /* 0xa7 */
1507 {chm_nosuch
, 0 }, /* 0xa8 */
1508 {chm_nosuch
, 0 }, /* 0xa9 */
1509 {chm_nosuch
, 0 }, /* 0xaa */
1510 {chm_nosuch
, 0 }, /* 0xab */
1511 {chm_nosuch
, 0 }, /* 0xac */
1512 {chm_nosuch
, 0 }, /* 0xad */
1513 {chm_nosuch
, 0 }, /* 0xae */
1514 {chm_nosuch
, 0 }, /* 0xaf */
1516 {chm_nosuch
, 0 }, /* 0xb0 */
1517 {chm_nosuch
, 0 }, /* 0xb1 */
1518 {chm_nosuch
, 0 }, /* 0xb2 */
1519 {chm_nosuch
, 0 }, /* 0xb3 */
1520 {chm_nosuch
, 0 }, /* 0xb4 */
1521 {chm_nosuch
, 0 }, /* 0xb5 */
1522 {chm_nosuch
, 0 }, /* 0xb6 */
1523 {chm_nosuch
, 0 }, /* 0xb7 */
1524 {chm_nosuch
, 0 }, /* 0xb8 */
1525 {chm_nosuch
, 0 }, /* 0xb9 */
1526 {chm_nosuch
, 0 }, /* 0xba */
1527 {chm_nosuch
, 0 }, /* 0xbb */
1528 {chm_nosuch
, 0 }, /* 0xbc */
1529 {chm_nosuch
, 0 }, /* 0xbd */
1530 {chm_nosuch
, 0 }, /* 0xbe */
1531 {chm_nosuch
, 0 }, /* 0xbf */
1533 {chm_nosuch
, 0 }, /* 0xc0 */
1534 {chm_nosuch
, 0 }, /* 0xc1 */
1535 {chm_nosuch
, 0 }, /* 0xc2 */
1536 {chm_nosuch
, 0 }, /* 0xc3 */
1537 {chm_nosuch
, 0 }, /* 0xc4 */
1538 {chm_nosuch
, 0 }, /* 0xc5 */
1539 {chm_nosuch
, 0 }, /* 0xc6 */
1540 {chm_nosuch
, 0 }, /* 0xc7 */
1541 {chm_nosuch
, 0 }, /* 0xc8 */
1542 {chm_nosuch
, 0 }, /* 0xc9 */
1543 {chm_nosuch
, 0 }, /* 0xca */
1544 {chm_nosuch
, 0 }, /* 0xcb */
1545 {chm_nosuch
, 0 }, /* 0xcc */
1546 {chm_nosuch
, 0 }, /* 0xcd */
1547 {chm_nosuch
, 0 }, /* 0xce */
1548 {chm_nosuch
, 0 }, /* 0xcf */
1550 {chm_nosuch
, 0 }, /* 0xd0 */
1551 {chm_nosuch
, 0 }, /* 0xd1 */
1552 {chm_nosuch
, 0 }, /* 0xd2 */
1553 {chm_nosuch
, 0 }, /* 0xd3 */
1554 {chm_nosuch
, 0 }, /* 0xd4 */
1555 {chm_nosuch
, 0 }, /* 0xd5 */
1556 {chm_nosuch
, 0 }, /* 0xd6 */
1557 {chm_nosuch
, 0 }, /* 0xd7 */
1558 {chm_nosuch
, 0 }, /* 0xd8 */
1559 {chm_nosuch
, 0 }, /* 0xd9 */
1560 {chm_nosuch
, 0 }, /* 0xda */
1561 {chm_nosuch
, 0 }, /* 0xdb */
1562 {chm_nosuch
, 0 }, /* 0xdc */
1563 {chm_nosuch
, 0 }, /* 0xdd */
1564 {chm_nosuch
, 0 }, /* 0xde */
1565 {chm_nosuch
, 0 }, /* 0xdf */
1567 {chm_nosuch
, 0 }, /* 0xe0 */
1568 {chm_nosuch
, 0 }, /* 0xe1 */
1569 {chm_nosuch
, 0 }, /* 0xe2 */
1570 {chm_nosuch
, 0 }, /* 0xe3 */
1571 {chm_nosuch
, 0 }, /* 0xe4 */
1572 {chm_nosuch
, 0 }, /* 0xe5 */
1573 {chm_nosuch
, 0 }, /* 0xe6 */
1574 {chm_nosuch
, 0 }, /* 0xe7 */
1575 {chm_nosuch
, 0 }, /* 0xe8 */
1576 {chm_nosuch
, 0 }, /* 0xe9 */
1577 {chm_nosuch
, 0 }, /* 0xea */
1578 {chm_nosuch
, 0 }, /* 0xeb */
1579 {chm_nosuch
, 0 }, /* 0xec */
1580 {chm_nosuch
, 0 }, /* 0xed */
1581 {chm_nosuch
, 0 }, /* 0xee */
1582 {chm_nosuch
, 0 }, /* 0xef */
1584 {chm_nosuch
, 0 }, /* 0xf0 */
1585 {chm_nosuch
, 0 }, /* 0xf1 */
1586 {chm_nosuch
, 0 }, /* 0xf2 */
1587 {chm_nosuch
, 0 }, /* 0xf3 */
1588 {chm_nosuch
, 0 }, /* 0xf4 */
1589 {chm_nosuch
, 0 }, /* 0xf5 */
1590 {chm_nosuch
, 0 }, /* 0xf6 */
1591 {chm_nosuch
, 0 }, /* 0xf7 */
1592 {chm_nosuch
, 0 }, /* 0xf8 */
1593 {chm_nosuch
, 0 }, /* 0xf9 */
1594 {chm_nosuch
, 0 }, /* 0xfa */
1595 {chm_nosuch
, 0 }, /* 0xfb */
1596 {chm_nosuch
, 0 }, /* 0xfc */
1597 {chm_nosuch
, 0 }, /* 0xfd */
1598 {chm_nosuch
, 0 }, /* 0xfe */
1599 {chm_nosuch
, 0 }, /* 0xff */
1604 /* set_channel_mode()
1606 * inputs - client, source, channel, membership pointer, params
1608 * side effects - channel modes/memberships are changed, MODE is issued
1610 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
1613 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
1614 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
1616 static char modebuf
[BUFSIZE
];
1617 static char parabuf
[BUFSIZE
];
1620 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
1626 const char *ml
= parv
[0];
1628 struct Client
*fakesource_p
;
1633 mode_limit_simple
= 0;
1635 alevel
= get_channel_access(source_p
, msptr
);
1637 /* Hide connecting server on netburst -- jilles */
1638 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
1641 fakesource_p
= source_p
;
1643 for(; (c
= *ml
) != 0; ml
++)
1657 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
1660 chmode_table
[(unsigned char) c
].mode_type
);
1665 /* bail out if we have nothing to do... */
1669 if(IsServer(source_p
))
1670 mlen
= rb_sprintf(modebuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
1672 mlen
= rb_sprintf(modebuf
, ":%s!%s@%s MODE %s ",
1673 source_p
->name
, source_p
->username
,
1674 source_p
->host
, chptr
->chname
);
1676 for(j
= 0, flags
= ALL_MEMBERS
; j
< 2; j
++, flags
= ONLY_CHANOPS
)
1679 mbuf
= modebuf
+ mlen
;
1682 paracount
= paralen
= 0;
1685 for(i
= 0; i
< mode_count
; i
++)
1687 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
1690 if(mode_changes
[i
].arg
!= NULL
)
1692 arglen
= strlen(mode_changes
[i
].arg
);
1694 if(arglen
> MODEBUFLEN
- 5)
1700 /* if we're creeping over MAXMODEPARAMSSERV, or over
1701 * bufsize (4 == +/-,modechar,two spaces) send now.
1703 if(mode_changes
[i
].arg
!= NULL
&&
1704 ((paracount
== MAXMODEPARAMSSERV
) ||
1705 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
1710 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
,
1715 paracount
= paralen
= 0;
1717 mbuf
= modebuf
+ mlen
;
1723 if(dir
!= mode_changes
[i
].dir
)
1725 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
1727 dir
= mode_changes
[i
].dir
;
1730 *mbuf
++ = mode_changes
[i
].letter
;
1733 if(mode_changes
[i
].arg
!= NULL
)
1736 len
= rb_sprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
1742 if(paralen
&& parabuf
[paralen
- 1] == ' ')
1743 parabuf
[paralen
- 1] = '\0';
1747 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
, parabuf
);
1750 /* only propagate modes originating locally, or if we're hubbing */
1751 if(MyClient(source_p
) || rb_dlink_list_length(&serv_list
) > 1)
1752 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);