3 extern int h_get_channel_access
;
5 /* OPTIMIZE ME! -- dwr */
7 construct_cflags_strings(void)
10 char *ptr
= cflagsbuf
;
11 char *ptr2
= cflagsmyinfo
;
16 for(i
= 0; i
< 256; i
++)
18 if( !(chmode_table
[i
].set_func
== chm_ban
) &&
19 !(chmode_table
[i
].set_func
== chm_forward
) &&
20 !(chmode_table
[i
].set_func
== chm_throttle
) &&
21 !(chmode_table
[i
].set_func
== chm_key
) &&
22 !(chmode_table
[i
].set_func
== chm_limit
) &&
23 !(chmode_table
[i
].set_func
== chm_op
) &&
24 !(chmode_table
[i
].set_func
== chm_voice
))
26 chmode_flags
[i
] = chmode_table
[i
].mode_type
;
33 switch (chmode_flags
[i
])
39 if(rb_dlink_list_length(&service_list
))
46 if(chmode_flags
[i
] != 0)
52 /* Should we leave orphaned check here? -- dwr */
53 if(!(chmode_table
[i
].set_func
== chm_nosuch
) && !(chmode_table
[i
].set_func
== chm_orphaned
))
67 * outputs - an available cflag bitmask or
68 * 0 if no cflags are available
74 unsigned int all_cflags
= 0, my_cflag
= 0, i
;
76 for (i
= 0; i
< 256; i
++)
77 all_cflags
|= chmode_flags
[i
];
79 for (my_cflag
= 1; my_cflag
&& (all_cflags
& my_cflag
);
86 cflag_add(char c_
, ChannelModeFunc function
)
88 int c
= (unsigned char)c_
;
90 if (chmode_table
[c
].set_func
!= chm_nosuch
&&
91 chmode_table
[c
].set_func
!= chm_orphaned
)
94 if (chmode_table
[c
].set_func
== chm_nosuch
)
95 chmode_table
[c
].mode_type
= find_cflag_slot();
96 if (chmode_table
[c
].mode_type
== 0)
98 chmode_table
[c
].set_func
= function
;
99 construct_cflags_strings();
100 return chmode_table
[c
].mode_type
;
104 cflag_orphan(char c_
)
106 int c
= (unsigned char)c_
;
108 s_assert(chmode_flags
[c
] != 0);
109 chmode_table
[c
].set_func
= chm_orphaned
;
110 construct_cflags_strings();
114 get_channel_access(struct Client
*source_p
, struct membership
*msptr
)
116 hook_data_channel_approval moduledata
;
118 if(!MyClient(source_p
))
124 moduledata
.client
= source_p
;
125 moduledata
.chptr
= msptr
->chptr
;
126 moduledata
.msptr
= msptr
;
127 moduledata
.target
= NULL
;
128 moduledata
.approved
= is_chanop(msptr
) ? CHFL_CHANOP
: CHFL_PEON
;
130 call_hook(h_get_channel_access
, &moduledata
);
132 return moduledata
.approved
;
137 * inputs - client, channel, id to add, type, forward
138 * outputs - 0 on failure, 1 on success
139 * side effects - given id is added to the appropriate list
142 add_id(struct Client
*source_p
, struct Channel
*chptr
, const char *banid
, const char *forward
,
143 rb_dlink_list
* list
, long mode_type
)
145 struct Ban
*actualBan
;
146 static char who
[USERHOST_REPLYLEN
];
147 char *realban
= LOCAL_COPY(banid
);
150 /* dont let local clients overflow the banlist, or set redundant
153 if(MyClient(source_p
))
155 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
))
157 sendto_one(source_p
, form_str(ERR_BANLISTFULL
),
158 me
.name
, source_p
->name
, chptr
->chname
, realban
);
162 RB_DLINK_FOREACH(ptr
, list
->head
)
164 actualBan
= ptr
->data
;
165 if(mask_match(actualBan
->banstr
, realban
))
169 /* dont let remotes set duplicates */
172 RB_DLINK_FOREACH(ptr
, list
->head
)
174 actualBan
= ptr
->data
;
175 if(!irccmp(actualBan
->banstr
, realban
))
181 if(IsPerson(source_p
))
182 rb_sprintf(who
, "%s!%s@%s", source_p
->name
, source_p
->username
, source_p
->host
);
184 rb_strlcpy(who
, source_p
->name
, sizeof(who
));
186 actualBan
= allocate_ban(realban
, who
, forward
);
187 actualBan
->when
= rb_current_time();
189 rb_dlinkAdd(actualBan
, &actualBan
->node
, list
);
191 /* invalidate the can_send() cache */
192 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
200 * inputs - channel, id to remove, type
201 * outputs - pointer to ban that was removed, if any
202 * side effects - given id is removed from the appropriate list and returned
205 del_id(struct Channel
*chptr
, const char *banid
, rb_dlink_list
* list
, long mode_type
)
210 if(EmptyString(banid
))
213 RB_DLINK_FOREACH(ptr
, list
->head
)
217 if(irccmp(banid
, banptr
->banstr
) == 0)
219 rb_dlinkDelete(&banptr
->node
, list
);
222 /* invalidate the can_send() cache */
223 if(mode_type
== CHFL_BAN
|| mode_type
== CHFL_QUIET
|| mode_type
== CHFL_EXCEPTION
)
235 * input - string to check
236 * output - pointer to 'fixed' string, or "*" if empty
237 * side effects - any white space found becomes \0
240 check_string(char *s
)
243 static char splat
[] = "*";
260 * inputs - mask to pretty
261 * outputs - better version of the mask
262 * side effects - mask is chopped to limits, and transformed:
270 pretty_mask(const char *idmask
)
272 static char mask_buf
[BUFSIZE
];
274 char *nick
, *user
, *host
, *forward
= NULL
;
276 char *t
, *at
, *ex
, *ex2
;
277 char ne
= 0, ue
= 0, he
= 0, fe
= 0; /* save values at nick[NICKLEN], et all */
278 char e2
= 0; /* save value that delimits forward channel */
281 mask
= LOCAL_COPY(idmask
);
282 mask
= check_string(mask
);
285 nick
= user
= host
= splat
;
287 if((size_t) BUFSIZE
- mask_pos
< strlen(mask
) + 5)
290 old_mask_pos
= mask_pos
;
294 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s", mask
) + 1;
295 t
= mask_buf
+ old_mask_pos
+ 1;
301 return mask_buf
+ old_mask_pos
;
304 at
= ex
= ex2
= NULL
;
305 if((t
= strchr(mask
, '@')) != NULL
)
312 if((t
= strchr(mask
, '!')) != NULL
)
327 if((t
= strchr(host
, '!')) != NULL
|| (t
= strchr(host
, '$')) != NULL
)
336 else if((t
= strchr(mask
, '!')) != NULL
)
345 else if(strchr(mask
, '.') != NULL
|| strchr(mask
, ':') != NULL
)
356 /* truncate values to max lengths */
357 if(strlen(nick
) > NICKLEN
- 1)
359 ne
= nick
[NICKLEN
- 1];
360 nick
[NICKLEN
- 1] = '\0';
362 if(strlen(user
) > USERLEN
)
365 user
[USERLEN
] = '\0';
367 if(strlen(host
) > HOSTLEN
)
370 host
[HOSTLEN
] = '\0';
372 if(forward
&& strlen(forward
) > CHANNELLEN
)
374 fe
= forward
[CHANNELLEN
];
375 forward
[CHANNELLEN
] = '\0';
379 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s!%s@%s$%s", nick
, user
, host
, forward
) + 1;
381 mask_pos
+= rb_sprintf(mask_buf
+ mask_pos
, "%s!%s@%s", nick
, user
, host
) + 1;
383 /* restore mask, since we may need to use it again later */
391 nick
[NICKLEN
- 1] = ne
;
397 forward
[CHANNELLEN
] = fe
;
399 return mask_buf
+ old_mask_pos
;
405 * output - the same key, fixed
406 * side effects - anything below ascii 13 is discarded, ':' discarded,
407 * high ascii is dropped to lower half of ascii table
414 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
417 if(c
!= ':' && c
!= ',' && c
> ' ')
428 * ouput - the same key, fixed
429 * side effects - high ascii dropped to lower half of table,
430 * CR/LF/':' are dropped
433 fix_key_remote(char *arg
)
437 for(s
= t
= (u_char
*) arg
; (c
= *s
); s
++)
440 if((c
!= 0x0a) && (c
!= ':') && (c
!= ',') && (c
!= 0x0d) && (c
!= ' '))
450 * The handlers for each specific mode.
453 chm_nosuch(struct Client
*source_p
, struct Channel
*chptr
,
454 int alevel
, int parc
, int *parn
,
455 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
457 if(*errors
& SM_ERR_UNKNOWN
)
459 *errors
|= SM_ERR_UNKNOWN
;
460 sendto_one(source_p
, form_str(ERR_UNKNOWNMODE
), me
.name
, source_p
->name
, c
);
464 chm_simple(struct Client
*source_p
, struct Channel
*chptr
,
465 int alevel
, int parc
, int *parn
,
466 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
468 if(alevel
!= CHFL_CHANOP
)
470 if(!(*errors
& SM_ERR_NOOPS
))
471 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
472 me
.name
, source_p
->name
, chptr
->chname
);
473 *errors
|= SM_ERR_NOOPS
;
477 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
481 if((dir
== MODE_ADD
) && !(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_ADD
;
487 mode_changes
[mode_count
].caps
= 0;
488 mode_changes
[mode_count
].nocaps
= 0;
489 mode_changes
[mode_count
].id
= NULL
;
490 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
491 mode_changes
[mode_count
++].arg
= NULL
;
493 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
495 chptr
->mode
.mode
&= ~mode_type
;
497 mode_changes
[mode_count
].letter
= c
;
498 mode_changes
[mode_count
].dir
= MODE_DEL
;
499 mode_changes
[mode_count
].caps
= 0;
500 mode_changes
[mode_count
].nocaps
= 0;
501 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
502 mode_changes
[mode_count
].id
= NULL
;
503 mode_changes
[mode_count
++].arg
= NULL
;
508 chm_orphaned(struct Client
*source_p
, struct Channel
*chptr
,
509 int alevel
, int parc
, int *parn
,
510 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
512 if(MyClient(source_p
))
515 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
517 chptr
->mode
.mode
|= mode_type
;
519 mode_changes
[mode_count
].letter
= c
;
520 mode_changes
[mode_count
].dir
= MODE_ADD
;
521 mode_changes
[mode_count
].caps
= 0;
522 mode_changes
[mode_count
].nocaps
= 0;
523 mode_changes
[mode_count
].id
= NULL
;
524 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
525 mode_changes
[mode_count
++].arg
= NULL
;
527 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
529 chptr
->mode
.mode
&= ~mode_type
;
531 mode_changes
[mode_count
].letter
= c
;
532 mode_changes
[mode_count
].dir
= MODE_DEL
;
533 mode_changes
[mode_count
].caps
= 0;
534 mode_changes
[mode_count
].nocaps
= 0;
535 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
536 mode_changes
[mode_count
].id
= NULL
;
537 mode_changes
[mode_count
++].arg
= NULL
;
542 chm_staff(struct Client
*source_p
, struct Channel
*chptr
,
543 int alevel
, int parc
, int *parn
,
544 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
546 if(!IsOper(source_p
) && !IsServer(source_p
))
548 if(!(*errors
& SM_ERR_NOPRIVS
))
549 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
550 *errors
|= SM_ERR_NOPRIVS
;
553 if(MyClient(source_p
) && !IsOperResv(source_p
))
555 if(!(*errors
& SM_ERR_NOPRIVS
))
556 sendto_one(source_p
, form_str(ERR_NOPRIVS
), me
.name
,
557 source_p
->name
, "resv");
558 *errors
|= SM_ERR_NOPRIVS
;
562 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
566 if((dir
== MODE_ADD
) && !(chptr
->mode
.mode
& mode_type
))
568 chptr
->mode
.mode
|= mode_type
;
570 mode_changes
[mode_count
].letter
= c
;
571 mode_changes
[mode_count
].dir
= MODE_ADD
;
572 mode_changes
[mode_count
].caps
= 0;
573 mode_changes
[mode_count
].nocaps
= 0;
574 mode_changes
[mode_count
].id
= NULL
;
575 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
576 mode_changes
[mode_count
++].arg
= NULL
;
578 else if((dir
== MODE_DEL
) && (chptr
->mode
.mode
& mode_type
))
580 chptr
->mode
.mode
&= ~mode_type
;
582 mode_changes
[mode_count
].letter
= c
;
583 mode_changes
[mode_count
].dir
= MODE_DEL
;
584 mode_changes
[mode_count
].caps
= 0;
585 mode_changes
[mode_count
].nocaps
= 0;
586 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
587 mode_changes
[mode_count
].id
= NULL
;
588 mode_changes
[mode_count
++].arg
= NULL
;
593 chm_ban(struct Client
*source_p
, struct Channel
*chptr
,
594 int alevel
, int parc
, int *parn
,
595 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
597 char *mask
, *raw_mask
, *forward
;
610 list
= &chptr
->banlist
;
611 errorval
= SM_ERR_RPL_B
;
612 rpl_list
= RPL_BANLIST
;
613 rpl_endlist
= RPL_ENDOFBANLIST
;
619 /* if +e is disabled, allow all but +e locally */
620 if(!ConfigChannel
.use_except
&& MyClient(source_p
) &&
621 ((dir
== MODE_ADD
) && (parc
> *parn
)))
624 list
= &chptr
->exceptlist
;
625 errorval
= SM_ERR_RPL_E
;
626 rpl_list
= RPL_EXCEPTLIST
;
627 rpl_endlist
= RPL_ENDOFEXCEPTLIST
;
630 if(ConfigChannel
.use_except
|| (dir
== MODE_DEL
))
637 /* if +I is disabled, allow all but +I locally */
638 if(!ConfigChannel
.use_invex
&& MyClient(source_p
) &&
639 (dir
== MODE_ADD
) && (parc
> *parn
))
642 list
= &chptr
->invexlist
;
643 errorval
= SM_ERR_RPL_I
;
644 rpl_list
= RPL_INVITELIST
;
645 rpl_endlist
= RPL_ENDOFINVITELIST
;
648 if(ConfigChannel
.use_invex
|| (dir
== MODE_DEL
))
655 list
= &chptr
->quietlist
;
656 errorval
= SM_ERR_RPL_Q
;
657 rpl_list
= RPL_QUIETLIST
;
658 rpl_endlist
= RPL_ENDOFQUIETLIST
;
664 sendto_realops_snomask(SNO_GENERAL
, L_ALL
, "chm_ban() called with unknown type!");
669 if(dir
== 0 || parc
<= *parn
)
671 if((*errors
& errorval
) != 0)
675 /* non-ops cant see +eI lists.. */
676 if(alevel
!= CHFL_CHANOP
&& mode_type
!= CHFL_BAN
&&
677 mode_type
!= CHFL_QUIET
)
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 RB_DLINK_FOREACH(ptr
, list
->head
)
691 rb_snprintf(buf
, sizeof(buf
), "%s$%s", banptr
->banstr
, banptr
->forward
);
693 rb_strlcpy(buf
, banptr
->banstr
, sizeof(buf
));
695 sendto_one(source_p
, form_str(rpl_list
),
696 me
.name
, source_p
->name
, chptr
->chname
,
697 buf
, banptr
->who
, banptr
->when
);
699 sendto_one(source_p
, form_str(rpl_endlist
), me
.name
, source_p
->name
, chptr
->chname
);
703 if(alevel
!= CHFL_CHANOP
)
705 if(!(*errors
& SM_ERR_NOOPS
))
706 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
707 me
.name
, source_p
->name
, chptr
->chname
);
708 *errors
|= SM_ERR_NOOPS
;
712 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
715 raw_mask
= parv
[(*parn
)];
718 /* empty ban, or starts with ':' which messes up s2s, ignore it */
719 if(EmptyString(raw_mask
) || *raw_mask
== ':')
722 if(!MyClient(source_p
))
724 if(strchr(raw_mask
, ' '))
730 mask
= pretty_mask(raw_mask
);
732 /* Look for a $ after the first character.
733 * As the first character, it marks an extban; afterwards
734 * it delimits a forward channel.
736 if ((forward
= strchr(mask
+1, '$')) != NULL
)
739 if (*forward
== '\0')
743 /* we'd have problems parsing this, hyb6 does it too
744 * also make sure it will always fit on a line with channel
747 if(strlen(mask
) > IRCD_MIN(BANLEN
, MODEBUFLEN
- 5))
750 /* if we're adding a NEW id */
753 if (*mask
== '$' && MyClient(source_p
))
755 if (!valid_extban(mask
, source_p
, chptr
, mode_type
))
756 /* XXX perhaps return an error message here */
760 /* dont allow local clients to overflow the banlist, dont
761 * let remote servers set duplicate bans
763 if(!add_id(source_p
, chptr
, mask
, forward
, list
, mode_type
))
769 mode_changes
[mode_count
].letter
= c
;
770 mode_changes
[mode_count
].dir
= MODE_ADD
;
771 mode_changes
[mode_count
].caps
= caps
;
772 mode_changes
[mode_count
].nocaps
= 0;
773 mode_changes
[mode_count
].mems
= mems
;
774 mode_changes
[mode_count
].id
= NULL
;
775 mode_changes
[mode_count
++].arg
= mask
;
777 else if(dir
== MODE_DEL
)
780 static char buf
[BANLEN
* MAXMODEPARAMS
];
781 int old_removed_mask_pos
= removed_mask_pos
;
782 if((removed
= del_id(chptr
, mask
, list
, mode_type
)) == NULL
)
784 /* mask isn't a valid ban, check raw_mask */
785 if((removed
= del_id(chptr
, raw_mask
, list
, mode_type
)) != NULL
)
789 if(removed
&& removed
->forward
)
790 removed_mask_pos
+= rb_snprintf(buf
, sizeof(buf
), "%s$%s", removed
->banstr
, removed
->forward
);
792 removed_mask_pos
+= rb_strlcpy(buf
, mask
, sizeof(buf
));
799 mode_changes
[mode_count
].letter
= c
;
800 mode_changes
[mode_count
].dir
= MODE_DEL
;
801 mode_changes
[mode_count
].caps
= caps
;
802 mode_changes
[mode_count
].nocaps
= 0;
803 mode_changes
[mode_count
].mems
= mems
;
804 mode_changes
[mode_count
].id
= NULL
;
805 mode_changes
[mode_count
++].arg
= buf
+ old_removed_mask_pos
;
810 chm_op(struct Client
*source_p
, struct Channel
*chptr
,
811 int alevel
, int parc
, int *parn
,
812 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
814 struct membership
*mstptr
;
816 struct Client
*targ_p
;
818 if(alevel
!= CHFL_CHANOP
)
820 if(!(*errors
& SM_ERR_NOOPS
))
821 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
822 me
.name
, source_p
->name
, chptr
->chname
);
823 *errors
|= SM_ERR_NOOPS
;
827 if((dir
== MODE_QUERY
) || (parc
<= *parn
))
830 opnick
= parv
[(*parn
)];
834 if(EmptyString(opnick
))
836 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
840 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
845 mstptr
= find_channel_membership(chptr
, targ_p
);
849 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
850 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
851 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
852 *errors
|= SM_ERR_NOTONCHANNEL
;
856 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
861 if(targ_p
== source_p
&& mstptr
->flags
& CHFL_CHANOP
)
864 mode_changes
[mode_count
].letter
= c
;
865 mode_changes
[mode_count
].dir
= MODE_ADD
;
866 mode_changes
[mode_count
].caps
= 0;
867 mode_changes
[mode_count
].nocaps
= 0;
868 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
869 mode_changes
[mode_count
].id
= targ_p
->id
;
870 mode_changes
[mode_count
].arg
= targ_p
->name
;
871 mode_changes
[mode_count
++].client
= targ_p
;
873 mstptr
->flags
|= CHFL_CHANOP
;
877 if(MyClient(source_p
) && IsService(targ_p
))
879 sendto_one(source_p
, form_str(ERR_ISCHANSERVICE
),
880 me
.name
, source_p
->name
, targ_p
->name
, chptr
->chname
);
884 mode_changes
[mode_count
].letter
= c
;
885 mode_changes
[mode_count
].dir
= MODE_DEL
;
886 mode_changes
[mode_count
].caps
= 0;
887 mode_changes
[mode_count
].nocaps
= 0;
888 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
889 mode_changes
[mode_count
].id
= targ_p
->id
;
890 mode_changes
[mode_count
].arg
= targ_p
->name
;
891 mode_changes
[mode_count
++].client
= targ_p
;
893 mstptr
->flags
&= ~CHFL_CHANOP
;
898 chm_voice(struct Client
*source_p
, struct Channel
*chptr
,
899 int alevel
, int parc
, int *parn
,
900 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
902 struct membership
*mstptr
;
904 struct Client
*targ_p
;
906 if(alevel
!= CHFL_CHANOP
)
908 if(!(*errors
& SM_ERR_NOOPS
))
909 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
910 me
.name
, source_p
->name
, chptr
->chname
);
911 *errors
|= SM_ERR_NOOPS
;
915 if((dir
== MODE_QUERY
) || parc
<= *parn
)
918 opnick
= parv
[(*parn
)];
922 if(EmptyString(opnick
))
924 sendto_one_numeric(source_p
, ERR_NOSUCHNICK
, form_str(ERR_NOSUCHNICK
), "*");
928 if((targ_p
= find_chasing(source_p
, opnick
, NULL
)) == NULL
)
933 mstptr
= find_channel_membership(chptr
, targ_p
);
937 if(!(*errors
& SM_ERR_NOTONCHANNEL
) && MyClient(source_p
))
938 sendto_one_numeric(source_p
, ERR_USERNOTINCHANNEL
,
939 form_str(ERR_USERNOTINCHANNEL
), opnick
, chptr
->chname
);
940 *errors
|= SM_ERR_NOTONCHANNEL
;
944 if(MyClient(source_p
) && (++mode_limit
> MAXMODEPARAMS
))
949 mode_changes
[mode_count
].letter
= c
;
950 mode_changes
[mode_count
].dir
= MODE_ADD
;
951 mode_changes
[mode_count
].caps
= 0;
952 mode_changes
[mode_count
].nocaps
= 0;
953 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
954 mode_changes
[mode_count
].id
= targ_p
->id
;
955 mode_changes
[mode_count
].arg
= targ_p
->name
;
956 mode_changes
[mode_count
++].client
= targ_p
;
958 mstptr
->flags
|= CHFL_VOICE
;
962 mode_changes
[mode_count
].letter
= 'v';
963 mode_changes
[mode_count
].dir
= MODE_DEL
;
964 mode_changes
[mode_count
].caps
= 0;
965 mode_changes
[mode_count
].nocaps
= 0;
966 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
967 mode_changes
[mode_count
].id
= targ_p
->id
;
968 mode_changes
[mode_count
].arg
= targ_p
->name
;
969 mode_changes
[mode_count
++].client
= targ_p
;
971 mstptr
->flags
&= ~CHFL_VOICE
;
976 chm_limit(struct Client
*source_p
, struct Channel
*chptr
,
977 int alevel
, int parc
, int *parn
,
978 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
981 static char limitstr
[30];
984 if(alevel
!= CHFL_CHANOP
)
986 if(!(*errors
& SM_ERR_NOOPS
))
987 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
988 me
.name
, source_p
->name
, chptr
->chname
);
989 *errors
|= SM_ERR_NOOPS
;
993 if(dir
== MODE_QUERY
)
996 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
999 if((dir
== MODE_ADD
) && parc
> *parn
)
1001 lstr
= parv
[(*parn
)];
1004 if(EmptyString(lstr
) || (limit
= atoi(lstr
)) <= 0)
1007 rb_sprintf(limitstr
, "%d", limit
);
1009 mode_changes
[mode_count
].letter
= c
;
1010 mode_changes
[mode_count
].dir
= MODE_ADD
;
1011 mode_changes
[mode_count
].caps
= 0;
1012 mode_changes
[mode_count
].nocaps
= 0;
1013 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1014 mode_changes
[mode_count
].id
= NULL
;
1015 mode_changes
[mode_count
++].arg
= limitstr
;
1017 chptr
->mode
.limit
= limit
;
1019 else if(dir
== MODE_DEL
)
1021 if(!chptr
->mode
.limit
)
1024 chptr
->mode
.limit
= 0;
1026 mode_changes
[mode_count
].letter
= c
;
1027 mode_changes
[mode_count
].dir
= MODE_DEL
;
1028 mode_changes
[mode_count
].caps
= 0;
1029 mode_changes
[mode_count
].nocaps
= 0;
1030 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1031 mode_changes
[mode_count
].id
= NULL
;
1032 mode_changes
[mode_count
++].arg
= NULL
;
1037 chm_throttle(struct Client
*source_p
, struct Channel
*chptr
,
1038 int alevel
, int parc
, int *parn
,
1039 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1041 int joins
= 0, timeslice
= 0;
1043 if(alevel
!= CHFL_CHANOP
)
1045 if(!(*errors
& SM_ERR_NOOPS
))
1046 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1047 me
.name
, source_p
->name
, chptr
->chname
);
1048 *errors
|= SM_ERR_NOOPS
;
1052 if(dir
== MODE_QUERY
)
1055 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1058 if((dir
== MODE_ADD
) && parc
> *parn
)
1060 sscanf(parv
[(*parn
)], "%d:%d", &joins
, ×lice
);
1062 if(!joins
|| !timeslice
)
1065 mode_changes
[mode_count
].letter
= c
;
1066 mode_changes
[mode_count
].dir
= MODE_ADD
;
1067 mode_changes
[mode_count
].caps
= 0;
1068 mode_changes
[mode_count
].nocaps
= 0;
1069 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1070 mode_changes
[mode_count
].id
= NULL
;
1071 mode_changes
[mode_count
++].arg
= parv
[(*parn
)];
1075 chptr
->mode
.join_num
= joins
;
1076 chptr
->mode
.join_time
= timeslice
;
1078 else if(dir
== MODE_DEL
)
1080 if(!chptr
->mode
.join_num
)
1083 chptr
->mode
.join_num
= 0;
1084 chptr
->mode
.join_time
= 0;
1085 chptr
->join_count
= 0;
1086 chptr
->join_delta
= 0;
1088 mode_changes
[mode_count
].letter
= c
;
1089 mode_changes
[mode_count
].dir
= MODE_DEL
;
1090 mode_changes
[mode_count
].caps
= 0;
1091 mode_changes
[mode_count
].nocaps
= 0;
1092 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1093 mode_changes
[mode_count
].id
= NULL
;
1094 mode_changes
[mode_count
++].arg
= NULL
;
1099 chm_forward(struct Client
*source_p
, struct Channel
*chptr
,
1100 int alevel
, int parc
, int *parn
,
1101 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1103 struct Channel
*targptr
= NULL
;
1104 struct membership
*msptr
;
1105 const char *forward
;
1107 if(dir
== MODE_QUERY
|| (dir
== MODE_ADD
&& parc
<= *parn
))
1109 if (!(*errors
& SM_ERR_RPL_F
))
1111 if (*chptr
->mode
.forward
== '\0')
1112 sendto_one_notice(source_p
, ":%s has no forward channel", chptr
->chname
);
1114 sendto_one_notice(source_p
, ":%s forward channel is %s", chptr
->chname
, chptr
->mode
.forward
);
1115 *errors
|= SM_ERR_RPL_F
;
1120 #ifndef FORWARD_OPERONLY
1121 if(alevel
!= CHFL_CHANOP
)
1123 if(!(*errors
& SM_ERR_NOOPS
))
1124 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1125 me
.name
, source_p
->name
, chptr
->chname
);
1126 *errors
|= SM_ERR_NOOPS
;
1130 if(!IsOper(source_p
) && !IsServer(source_p
))
1132 if(!(*errors
& SM_ERR_NOPRIVS
))
1133 sendto_one_numeric(source_p
, ERR_NOPRIVILEGES
, form_str(ERR_NOPRIVILEGES
));
1134 *errors
|= SM_ERR_NOPRIVS
;
1139 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1142 if(dir
== MODE_ADD
&& parc
> *parn
)
1144 forward
= parv
[(*parn
)];
1147 if(EmptyString(forward
))
1149 if(!check_channel_name(forward
) ||
1150 (MyClient(source_p
) && (strlen(forward
) > LOC_CHANNELLEN
|| hash_find_resv(forward
))))
1152 sendto_one_numeric(source_p
, ERR_BADCHANNAME
, form_str(ERR_BADCHANNAME
), forward
);
1155 /* don't forward to inconsistent target -- jilles */
1156 if(chptr
->chname
[0] == '#' && forward
[0] == '&')
1158 sendto_one_numeric(source_p
, ERR_BADCHANNAME
,
1159 form_str(ERR_BADCHANNAME
), forward
);
1162 if(MyClient(source_p
) && (targptr
= find_channel(forward
)) == NULL
)
1164 sendto_one_numeric(source_p
, ERR_NOSUCHCHANNEL
,
1165 form_str(ERR_NOSUCHCHANNEL
), forward
);
1168 if(MyClient(source_p
) && !(targptr
->mode
.mode
& MODE_FREETARGET
))
1170 if((msptr
= find_channel_membership(targptr
, source_p
)) == NULL
||
1171 get_channel_access(source_p
, msptr
) != CHFL_CHANOP
)
1173 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1174 me
.name
, source_p
->name
, targptr
->chname
);
1179 rb_strlcpy(chptr
->mode
.forward
, forward
, sizeof(chptr
->mode
.forward
));
1181 mode_changes
[mode_count
].letter
= c
;
1182 mode_changes
[mode_count
].dir
= MODE_ADD
;
1183 mode_changes
[mode_count
].caps
= 0;
1184 mode_changes
[mode_count
].nocaps
= 0;
1185 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1186 mode_changes
[mode_count
].id
= NULL
;
1187 mode_changes
[mode_count
++].arg
= forward
;
1189 else if(dir
== MODE_DEL
)
1191 if(!(*chptr
->mode
.forward
))
1194 *chptr
->mode
.forward
= '\0';
1196 mode_changes
[mode_count
].letter
= c
;
1197 mode_changes
[mode_count
].dir
= MODE_DEL
;
1198 mode_changes
[mode_count
].caps
= 0;
1199 mode_changes
[mode_count
].nocaps
= 0;
1200 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1201 mode_changes
[mode_count
].id
= NULL
;
1202 mode_changes
[mode_count
++].arg
= NULL
;
1207 chm_key(struct Client
*source_p
, struct Channel
*chptr
,
1208 int alevel
, int parc
, int *parn
,
1209 const char **parv
, int *errors
, int dir
, char c
, long mode_type
)
1213 if(alevel
!= CHFL_CHANOP
)
1215 if(!(*errors
& SM_ERR_NOOPS
))
1216 sendto_one(source_p
, form_str(ERR_CHANOPRIVSNEEDED
),
1217 me
.name
, source_p
->name
, chptr
->chname
);
1218 *errors
|= SM_ERR_NOOPS
;
1222 if(dir
== MODE_QUERY
)
1225 if(MyClient(source_p
) && (++mode_limit_simple
> MAXMODES_SIMPLE
))
1228 if((dir
== MODE_ADD
) && parc
> *parn
)
1230 key
= LOCAL_COPY(parv
[(*parn
)]);
1233 if(MyClient(source_p
))
1236 fix_key_remote(key
);
1238 if(EmptyString(key
))
1241 s_assert(key
[0] != ' ');
1242 rb_strlcpy(chptr
->mode
.key
, key
, sizeof(chptr
->mode
.key
));
1244 mode_changes
[mode_count
].letter
= c
;
1245 mode_changes
[mode_count
].dir
= MODE_ADD
;
1246 mode_changes
[mode_count
].caps
= 0;
1247 mode_changes
[mode_count
].nocaps
= 0;
1248 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1249 mode_changes
[mode_count
].id
= NULL
;
1250 mode_changes
[mode_count
++].arg
= chptr
->mode
.key
;
1252 else if(dir
== MODE_DEL
)
1254 static char splat
[] = "*";
1260 if(!(*chptr
->mode
.key
))
1263 /* hack time. when we get a +k-k mode, the +k arg is
1264 * chptr->mode.key, which the -k sets to \0, so hunt for a
1265 * +k when we get a -k, and set the arg to splat. --anfl
1267 for(i
= 0; i
< mode_count
; i
++)
1269 if(mode_changes
[i
].letter
== 'k' && mode_changes
[i
].dir
== MODE_ADD
)
1270 mode_changes
[i
].arg
= splat
;
1273 *chptr
->mode
.key
= 0;
1275 mode_changes
[mode_count
].letter
= c
;
1276 mode_changes
[mode_count
].dir
= MODE_DEL
;
1277 mode_changes
[mode_count
].caps
= 0;
1278 mode_changes
[mode_count
].nocaps
= 0;
1279 mode_changes
[mode_count
].mems
= ALL_MEMBERS
;
1280 mode_changes
[mode_count
].id
= NULL
;
1281 mode_changes
[mode_count
++].arg
= "*";
1286 struct ChannelMode chmode_table
[256] =
1288 {chm_nosuch
, 0 }, /* 0x00 */
1289 {chm_nosuch
, 0 }, /* 0x01 */
1290 {chm_nosuch
, 0 }, /* 0x02 */
1291 {chm_nosuch
, 0 }, /* 0x03 */
1292 {chm_nosuch
, 0 }, /* 0x04 */
1293 {chm_nosuch
, 0 }, /* 0x05 */
1294 {chm_nosuch
, 0 }, /* 0x06 */
1295 {chm_nosuch
, 0 }, /* 0x07 */
1296 {chm_nosuch
, 0 }, /* 0x08 */
1297 {chm_nosuch
, 0 }, /* 0x09 */
1298 {chm_nosuch
, 0 }, /* 0x0a */
1299 {chm_nosuch
, 0 }, /* 0x0b */
1300 {chm_nosuch
, 0 }, /* 0x0c */
1301 {chm_nosuch
, 0 }, /* 0x0d */
1302 {chm_nosuch
, 0 }, /* 0x0e */
1303 {chm_nosuch
, 0 }, /* 0x0f */
1304 {chm_nosuch
, 0 }, /* 0x10 */
1305 {chm_nosuch
, 0 }, /* 0x11 */
1306 {chm_nosuch
, 0 }, /* 0x12 */
1307 {chm_nosuch
, 0 }, /* 0x13 */
1308 {chm_nosuch
, 0 }, /* 0x14 */
1309 {chm_nosuch
, 0 }, /* 0x15 */
1310 {chm_nosuch
, 0 }, /* 0x16 */
1311 {chm_nosuch
, 0 }, /* 0x17 */
1312 {chm_nosuch
, 0 }, /* 0x18 */
1313 {chm_nosuch
, 0 }, /* 0x19 */
1314 {chm_nosuch
, 0 }, /* 0x1a */
1315 {chm_nosuch
, 0 }, /* 0x1b */
1316 {chm_nosuch
, 0 }, /* 0x1c */
1317 {chm_nosuch
, 0 }, /* 0x1d */
1318 {chm_nosuch
, 0 }, /* 0x1e */
1319 {chm_nosuch
, 0 }, /* 0x1f */
1320 {chm_nosuch
, 0 }, /* 0x20 */
1321 {chm_nosuch
, 0 }, /* 0x21 */
1322 {chm_nosuch
, 0 }, /* 0x22 */
1323 {chm_nosuch
, 0 }, /* 0x23 */
1324 {chm_nosuch
, 0 }, /* 0x24 */
1325 {chm_nosuch
, 0 }, /* 0x25 */
1326 {chm_nosuch
, 0 }, /* 0x26 */
1327 {chm_nosuch
, 0 }, /* 0x27 */
1328 {chm_nosuch
, 0 }, /* 0x28 */
1329 {chm_nosuch
, 0 }, /* 0x29 */
1330 {chm_nosuch
, 0 }, /* 0x2a */
1331 {chm_nosuch
, 0 }, /* 0x2b */
1332 {chm_nosuch
, 0 }, /* 0x2c */
1333 {chm_nosuch
, 0 }, /* 0x2d */
1334 {chm_nosuch
, 0 }, /* 0x2e */
1335 {chm_nosuch
, 0 }, /* 0x2f */
1336 {chm_nosuch
, 0 }, /* 0x30 */
1337 {chm_nosuch
, 0 }, /* 0x31 */
1338 {chm_nosuch
, 0 }, /* 0x32 */
1339 {chm_nosuch
, 0 }, /* 0x33 */
1340 {chm_nosuch
, 0 }, /* 0x34 */
1341 {chm_nosuch
, 0 }, /* 0x35 */
1342 {chm_nosuch
, 0 }, /* 0x36 */
1343 {chm_nosuch
, 0 }, /* 0x37 */
1344 {chm_nosuch
, 0 }, /* 0x38 */
1345 {chm_nosuch
, 0 }, /* 0x39 */
1346 {chm_nosuch
, 0 }, /* 0x3a */
1347 {chm_nosuch
, 0 }, /* 0x3b */
1348 {chm_nosuch
, 0 }, /* 0x3c */
1349 {chm_nosuch
, 0 }, /* 0x3d */
1350 {chm_nosuch
, 0 }, /* 0x3e */
1351 {chm_nosuch
, 0 }, /* 0x3f */
1353 {chm_nosuch
, 0 }, /* @ */
1354 {chm_nosuch
, 0 }, /* A */
1355 {chm_nosuch
, 0 }, /* B */
1356 {chm_simple
, MODE_NOCTCP
}, /* C */
1357 {chm_nosuch
, 0 }, /* D */
1358 {chm_nosuch
, 0 }, /* E */
1359 {chm_simple
, MODE_FREETARGET
}, /* F */
1360 {chm_nosuch
, 0 }, /* G */
1361 {chm_nosuch
, 0 }, /* H */
1362 {chm_ban
, CHFL_INVEX
}, /* I */
1363 {chm_nosuch
, 0 }, /* J */
1364 {chm_nosuch
, 0 }, /* K */
1365 {chm_staff
, MODE_EXLIMIT
}, /* L */
1366 {chm_nosuch
, 0 }, /* M */
1367 {chm_nosuch
, 0 }, /* N */
1368 {chm_nosuch
, 0 }, /* O */
1369 {chm_staff
, MODE_PERMANENT
}, /* P */
1370 {chm_simple
, MODE_DISFORWARD
}, /* Q */
1371 {chm_nosuch
, 0 }, /* R */
1372 {chm_nosuch
, 0 }, /* S */
1373 {chm_nosuch
, 0 }, /* T */
1374 {chm_nosuch
, 0 }, /* U */
1375 {chm_nosuch
, 0 }, /* V */
1376 {chm_nosuch
, 0 }, /* W */
1377 {chm_nosuch
, 0 }, /* X */
1378 {chm_nosuch
, 0 }, /* Y */
1379 {chm_nosuch
, 0 }, /* Z */
1386 {chm_nosuch
, 0 }, /* a */
1387 {chm_ban
, CHFL_BAN
}, /* b */
1388 {chm_simple
, MODE_NOCOLOR
}, /* c */
1389 {chm_nosuch
, 0 }, /* d */
1390 {chm_ban
, CHFL_EXCEPTION
}, /* e */
1391 {chm_forward
, 0 }, /* f */
1392 {chm_simple
, MODE_FREEINVITE
}, /* g */
1393 {chm_nosuch
, 0 }, /* h */
1394 {chm_simple
, MODE_INVITEONLY
}, /* i */
1395 {chm_throttle
, 0 }, /* j */
1396 {chm_key
, 0 }, /* k */
1397 {chm_limit
, 0 }, /* l */
1398 {chm_simple
, MODE_MODERATED
}, /* m */
1399 {chm_simple
, MODE_NOPRIVMSGS
}, /* n */
1400 {chm_op
, 0 }, /* o */
1401 {chm_simple
, MODE_PRIVATE
}, /* p */
1402 {chm_ban
, CHFL_QUIET
}, /* q */
1403 {chm_simple
, MODE_REGONLY
}, /* r */
1404 {chm_simple
, MODE_SECRET
}, /* s */
1405 {chm_simple
, MODE_TOPICLIMIT
}, /* t */
1406 {chm_nosuch
, 0 }, /* u */
1407 {chm_voice
, 0 }, /* v */
1408 {chm_nosuch
, 0 }, /* w */
1409 {chm_nosuch
, 0 }, /* x */
1410 {chm_nosuch
, 0 }, /* y */
1411 {chm_simple
, MODE_OPMODERATE
}, /* z */
1413 {chm_nosuch
, 0 }, /* 0x7b */
1414 {chm_nosuch
, 0 }, /* 0x7c */
1415 {chm_nosuch
, 0 }, /* 0x7d */
1416 {chm_nosuch
, 0 }, /* 0x7e */
1417 {chm_nosuch
, 0 }, /* 0x7f */
1419 {chm_nosuch
, 0 }, /* 0x80 */
1420 {chm_nosuch
, 0 }, /* 0x81 */
1421 {chm_nosuch
, 0 }, /* 0x82 */
1422 {chm_nosuch
, 0 }, /* 0x83 */
1423 {chm_nosuch
, 0 }, /* 0x84 */
1424 {chm_nosuch
, 0 }, /* 0x85 */
1425 {chm_nosuch
, 0 }, /* 0x86 */
1426 {chm_nosuch
, 0 }, /* 0x87 */
1427 {chm_nosuch
, 0 }, /* 0x88 */
1428 {chm_nosuch
, 0 }, /* 0x89 */
1429 {chm_nosuch
, 0 }, /* 0x8a */
1430 {chm_nosuch
, 0 }, /* 0x8b */
1431 {chm_nosuch
, 0 }, /* 0x8c */
1432 {chm_nosuch
, 0 }, /* 0x8d */
1433 {chm_nosuch
, 0 }, /* 0x8e */
1434 {chm_nosuch
, 0 }, /* 0x8f */
1436 {chm_nosuch
, 0 }, /* 0x90 */
1437 {chm_nosuch
, 0 }, /* 0x91 */
1438 {chm_nosuch
, 0 }, /* 0x92 */
1439 {chm_nosuch
, 0 }, /* 0x93 */
1440 {chm_nosuch
, 0 }, /* 0x94 */
1441 {chm_nosuch
, 0 }, /* 0x95 */
1442 {chm_nosuch
, 0 }, /* 0x96 */
1443 {chm_nosuch
, 0 }, /* 0x97 */
1444 {chm_nosuch
, 0 }, /* 0x98 */
1445 {chm_nosuch
, 0 }, /* 0x99 */
1446 {chm_nosuch
, 0 }, /* 0x9a */
1447 {chm_nosuch
, 0 }, /* 0x9b */
1448 {chm_nosuch
, 0 }, /* 0x9c */
1449 {chm_nosuch
, 0 }, /* 0x9d */
1450 {chm_nosuch
, 0 }, /* 0x9e */
1451 {chm_nosuch
, 0 }, /* 0x9f */
1453 {chm_nosuch
, 0 }, /* 0xa0 */
1454 {chm_nosuch
, 0 }, /* 0xa1 */
1455 {chm_nosuch
, 0 }, /* 0xa2 */
1456 {chm_nosuch
, 0 }, /* 0xa3 */
1457 {chm_nosuch
, 0 }, /* 0xa4 */
1458 {chm_nosuch
, 0 }, /* 0xa5 */
1459 {chm_nosuch
, 0 }, /* 0xa6 */
1460 {chm_nosuch
, 0 }, /* 0xa7 */
1461 {chm_nosuch
, 0 }, /* 0xa8 */
1462 {chm_nosuch
, 0 }, /* 0xa9 */
1463 {chm_nosuch
, 0 }, /* 0xaa */
1464 {chm_nosuch
, 0 }, /* 0xab */
1465 {chm_nosuch
, 0 }, /* 0xac */
1466 {chm_nosuch
, 0 }, /* 0xad */
1467 {chm_nosuch
, 0 }, /* 0xae */
1468 {chm_nosuch
, 0 }, /* 0xaf */
1470 {chm_nosuch
, 0 }, /* 0xb0 */
1471 {chm_nosuch
, 0 }, /* 0xb1 */
1472 {chm_nosuch
, 0 }, /* 0xb2 */
1473 {chm_nosuch
, 0 }, /* 0xb3 */
1474 {chm_nosuch
, 0 }, /* 0xb4 */
1475 {chm_nosuch
, 0 }, /* 0xb5 */
1476 {chm_nosuch
, 0 }, /* 0xb6 */
1477 {chm_nosuch
, 0 }, /* 0xb7 */
1478 {chm_nosuch
, 0 }, /* 0xb8 */
1479 {chm_nosuch
, 0 }, /* 0xb9 */
1480 {chm_nosuch
, 0 }, /* 0xba */
1481 {chm_nosuch
, 0 }, /* 0xbb */
1482 {chm_nosuch
, 0 }, /* 0xbc */
1483 {chm_nosuch
, 0 }, /* 0xbd */
1484 {chm_nosuch
, 0 }, /* 0xbe */
1485 {chm_nosuch
, 0 }, /* 0xbf */
1487 {chm_nosuch
, 0 }, /* 0xc0 */
1488 {chm_nosuch
, 0 }, /* 0xc1 */
1489 {chm_nosuch
, 0 }, /* 0xc2 */
1490 {chm_nosuch
, 0 }, /* 0xc3 */
1491 {chm_nosuch
, 0 }, /* 0xc4 */
1492 {chm_nosuch
, 0 }, /* 0xc5 */
1493 {chm_nosuch
, 0 }, /* 0xc6 */
1494 {chm_nosuch
, 0 }, /* 0xc7 */
1495 {chm_nosuch
, 0 }, /* 0xc8 */
1496 {chm_nosuch
, 0 }, /* 0xc9 */
1497 {chm_nosuch
, 0 }, /* 0xca */
1498 {chm_nosuch
, 0 }, /* 0xcb */
1499 {chm_nosuch
, 0 }, /* 0xcc */
1500 {chm_nosuch
, 0 }, /* 0xcd */
1501 {chm_nosuch
, 0 }, /* 0xce */
1502 {chm_nosuch
, 0 }, /* 0xcf */
1504 {chm_nosuch
, 0 }, /* 0xd0 */
1505 {chm_nosuch
, 0 }, /* 0xd1 */
1506 {chm_nosuch
, 0 }, /* 0xd2 */
1507 {chm_nosuch
, 0 }, /* 0xd3 */
1508 {chm_nosuch
, 0 }, /* 0xd4 */
1509 {chm_nosuch
, 0 }, /* 0xd5 */
1510 {chm_nosuch
, 0 }, /* 0xd6 */
1511 {chm_nosuch
, 0 }, /* 0xd7 */
1512 {chm_nosuch
, 0 }, /* 0xd8 */
1513 {chm_nosuch
, 0 }, /* 0xd9 */
1514 {chm_nosuch
, 0 }, /* 0xda */
1515 {chm_nosuch
, 0 }, /* 0xdb */
1516 {chm_nosuch
, 0 }, /* 0xdc */
1517 {chm_nosuch
, 0 }, /* 0xdd */
1518 {chm_nosuch
, 0 }, /* 0xde */
1519 {chm_nosuch
, 0 }, /* 0xdf */
1521 {chm_nosuch
, 0 }, /* 0xe0 */
1522 {chm_nosuch
, 0 }, /* 0xe1 */
1523 {chm_nosuch
, 0 }, /* 0xe2 */
1524 {chm_nosuch
, 0 }, /* 0xe3 */
1525 {chm_nosuch
, 0 }, /* 0xe4 */
1526 {chm_nosuch
, 0 }, /* 0xe5 */
1527 {chm_nosuch
, 0 }, /* 0xe6 */
1528 {chm_nosuch
, 0 }, /* 0xe7 */
1529 {chm_nosuch
, 0 }, /* 0xe8 */
1530 {chm_nosuch
, 0 }, /* 0xe9 */
1531 {chm_nosuch
, 0 }, /* 0xea */
1532 {chm_nosuch
, 0 }, /* 0xeb */
1533 {chm_nosuch
, 0 }, /* 0xec */
1534 {chm_nosuch
, 0 }, /* 0xed */
1535 {chm_nosuch
, 0 }, /* 0xee */
1536 {chm_nosuch
, 0 }, /* 0xef */
1538 {chm_nosuch
, 0 }, /* 0xf0 */
1539 {chm_nosuch
, 0 }, /* 0xf1 */
1540 {chm_nosuch
, 0 }, /* 0xf2 */
1541 {chm_nosuch
, 0 }, /* 0xf3 */
1542 {chm_nosuch
, 0 }, /* 0xf4 */
1543 {chm_nosuch
, 0 }, /* 0xf5 */
1544 {chm_nosuch
, 0 }, /* 0xf6 */
1545 {chm_nosuch
, 0 }, /* 0xf7 */
1546 {chm_nosuch
, 0 }, /* 0xf8 */
1547 {chm_nosuch
, 0 }, /* 0xf9 */
1548 {chm_nosuch
, 0 }, /* 0xfa */
1549 {chm_nosuch
, 0 }, /* 0xfb */
1550 {chm_nosuch
, 0 }, /* 0xfc */
1551 {chm_nosuch
, 0 }, /* 0xfd */
1552 {chm_nosuch
, 0 }, /* 0xfe */
1553 {chm_nosuch
, 0 }, /* 0xff */
1558 /* set_channel_mode()
1560 * inputs - client, source, channel, membership pointer, params
1562 * side effects - channel modes/memberships are changed, MODE is issued
1564 * Extensively modified to be hotpluggable, 03/09/06 -- nenolod
1567 set_channel_mode(struct Client
*client_p
, struct Client
*source_p
,
1568 struct Channel
*chptr
, struct membership
*msptr
, int parc
, const char *parv
[])
1570 static char modebuf
[BUFSIZE
];
1571 static char parabuf
[BUFSIZE
];
1574 int cur_len
, mlen
, paralen
, paracount
, arglen
, len
;
1580 const char *ml
= parv
[0];
1582 struct Client
*fakesource_p
;
1585 removed_mask_pos
= 0;
1588 mode_limit_simple
= 0;
1590 alevel
= get_channel_access(source_p
, msptr
);
1592 /* Hide connecting server on netburst -- jilles */
1593 if (ConfigServerHide
.flatten_links
&& IsServer(source_p
) && !has_id(source_p
) && !HasSentEob(source_p
))
1596 fakesource_p
= source_p
;
1598 for(; (c
= *ml
) != 0; ml
++)
1612 /* If this mode char is locked, don't allow local users to change it. */
1613 if (MyClient(source_p
) && chptr
->mode_lock
&& strchr(chptr
->mode_lock
, c
))
1615 if (!(errors
& SM_ERR_MLOCK
))
1616 sendto_one_numeric(source_p
,
1617 ERR_MLOCKRESTRICTED
,
1618 form_str(ERR_MLOCKRESTRICTED
),
1622 errors
|= SM_ERR_MLOCK
;
1625 chmode_table
[(unsigned char) c
].set_func(fakesource_p
, chptr
, alevel
,
1628 chmode_table
[(unsigned char) c
].mode_type
);
1633 /* bail out if we have nothing to do... */
1637 if(IsServer(source_p
))
1638 mlen
= rb_sprintf(modebuf
, ":%s MODE %s ", fakesource_p
->name
, chptr
->chname
);
1640 mlen
= rb_sprintf(modebuf
, ":%s!%s@%s MODE %s ",
1641 source_p
->name
, source_p
->username
,
1642 source_p
->host
, chptr
->chname
);
1644 for(j
= 0, flags
= ALL_MEMBERS
; j
< 2; j
++, flags
= ONLY_CHANOPS
)
1647 mbuf
= modebuf
+ mlen
;
1650 paracount
= paralen
= 0;
1653 for(i
= 0; i
< mode_count
; i
++)
1655 if(mode_changes
[i
].letter
== 0 || mode_changes
[i
].mems
!= flags
)
1658 if(mode_changes
[i
].arg
!= NULL
)
1660 arglen
= strlen(mode_changes
[i
].arg
);
1662 if(arglen
> MODEBUFLEN
- 5)
1668 /* if we're creeping over MAXMODEPARAMSSERV, or over
1669 * bufsize (4 == +/-,modechar,two spaces) send now.
1671 if(mode_changes
[i
].arg
!= NULL
&&
1672 ((paracount
== MAXMODEPARAMSSERV
) ||
1673 ((cur_len
+ paralen
+ arglen
+ 4) > (BUFSIZE
- 3))))
1678 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
,
1683 paracount
= paralen
= 0;
1685 mbuf
= modebuf
+ mlen
;
1691 if(dir
!= mode_changes
[i
].dir
)
1693 *mbuf
++ = (mode_changes
[i
].dir
== MODE_ADD
) ? '+' : '-';
1695 dir
= mode_changes
[i
].dir
;
1698 *mbuf
++ = mode_changes
[i
].letter
;
1701 if(mode_changes
[i
].arg
!= NULL
)
1704 len
= rb_sprintf(pbuf
, "%s ", mode_changes
[i
].arg
);
1710 if(paralen
&& parabuf
[paralen
- 1] == ' ')
1711 parabuf
[paralen
- 1] = '\0';
1715 sendto_channel_local(flags
, chptr
, "%s %s", modebuf
, parabuf
);
1718 /* only propagate modes originating locally, or if we're hubbing */
1719 if(MyClient(source_p
) || rb_dlink_list_length(&serv_list
) > 1)
1720 send_cap_mode_changes(client_p
, source_p
, chptr
, mode_changes
, mode_count
);
1723 /* set_channel_mlock()
1725 * inputs - client, source, channel, params
1727 * side effects - channel mlock is changed / MLOCK is propagated
1730 set_channel_mlock(struct Client
*client_p
, struct Client
*source_p
,
1731 struct Channel
*chptr
, const char *newmlock
, int propagate
)
1733 rb_free(chptr
->mode_lock
);
1734 chptr
->mode_lock
= newmlock
? rb_strdup(newmlock
) : NULL
;
1738 sendto_server(client_p
, NULL
, CAP_TS6
| CAP_MLOCK
, NOCAPS
, ":%s MLOCK %ld %s :%s",
1739 source_p
->id
, (long) chptr
->channelts
, chptr
->chname
,
1740 chptr
->mode_lock
? chptr
->mode_lock
: "");