Blob


1 /*
2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * Please read the file COPYING, README and AUTHORS for more information.
10 *
11 * IRC commands for mode changes (MODE, AWAY, ...)
12 */
15 #include "portab.h"
17 static char UNUSED id[] = "$Id: irc-mode.c,v 1.29 2003/01/08 23:00:12 alex Exp $";
19 #include "imp.h"
20 #include <assert.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
25 #include "conn.h"
26 #include "client.h"
27 #include "channel.h"
28 #include "defines.h"
29 #include "irc-write.h"
30 #include "lists.h"
31 #include "log.h"
32 #include "parse.h"
33 #include "messages.h"
34 #include "resolve.h"
35 #include "conf.h"
37 #include "exp.h"
38 #include "irc-mode.h"
41 LOCAL BOOLEAN Client_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target ));
42 LOCAL BOOLEAN Channel_Mode PARAMS(( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel ));
44 LOCAL BOOLEAN Add_Invite PARAMS(( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, CHAR *Pattern ));
45 LOCAL BOOLEAN Add_Ban PARAMS(( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, CHAR *Pattern ));
47 LOCAL BOOLEAN Del_Invite PARAMS(( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, CHAR *Pattern ));
48 LOCAL BOOLEAN Del_Ban PARAMS(( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, CHAR *Pattern ));
50 LOCAL BOOLEAN Send_ListChange PARAMS(( CHAR *Mode, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, CHAR *Mask ));
53 GLOBAL BOOLEAN
54 IRC_MODE( CLIENT *Client, REQUEST *Req )
55 {
56 CLIENT *cl, *origin;
57 CHANNEL *chan;
59 assert( Client != NULL );
60 assert( Req != NULL );
62 /* No parameters? */
63 if( Req->argc < 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
65 /* Origin for answers */
66 if( Client_Type( Client ) == CLIENT_SERVER )
67 {
68 origin = Client_Search( Req->prefix );
69 if( ! origin ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
70 }
71 else origin = Client;
73 /* Channel or user mode? */
74 cl = chan = NULL;
75 if( Client_IsValidNick( Req->argv[0] )) cl = Client_Search( Req->argv[0] );
76 if( Channel_IsValidName( Req->argv[0] )) chan = Channel_Search( Req->argv[0] );
78 if( cl ) return Client_Mode( Client, Req, origin, cl );
79 if( chan ) return Channel_Mode( Client, Req, origin, chan );
81 /* No target found! */
82 return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[0] );
83 } /* IRC_MODE */
86 LOCAL BOOLEAN
87 Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
88 {
89 /* Handle client mode requests */
91 CHAR the_modes[COMMAND_LEN], x[2], *mode_ptr;
92 BOOLEAN ok, set;
93 INT mode_arg;
95 /* Is the client allowed to request or change the modes? */
96 if( Client_Type( Client ) == CLIENT_USER )
97 {
98 /* Users are only allowed to manipulate their own modes! */
99 if( Target != Client ) return IRC_WriteStrClient( Client, ERR_USERSDONTMATCH_MSG, Client_ID( Client ));
102 /* Mode request: let's answer it :-) */
103 if( Req->argc == 1 ) return IRC_WriteStrClient( Origin, RPL_UMODEIS_MSG, Client_ID( Origin ), Client_Modes( Target ));
105 mode_arg = 1;
106 mode_ptr = Req->argv[mode_arg];
108 /* Initial state: set or unset modes? */
109 if( *mode_ptr == '+' ) set = TRUE;
110 else if( *mode_ptr == '-' ) set = FALSE;
111 else return IRC_WriteStrClient( Origin, ERR_UMODEUNKNOWNFLAG_MSG, Client_ID( Origin ));
113 /* Prepare reply string */
114 if( set ) strcpy( the_modes, "+" );
115 else strcpy( the_modes, "-" );
117 x[1] = '\0';
118 ok = CONNECTED;
119 while( mode_ptr )
121 mode_ptr++;
122 if( ! *mode_ptr )
124 /* Try next argument if there's any */
125 mode_arg++;
126 if( mode_arg < Req->argc ) mode_ptr = Req->argv[mode_arg];
127 else break;
130 switch( *mode_ptr )
132 case '+':
133 case '-':
134 if((( *mode_ptr == '+' ) && ( ! set )) || (( *mode_ptr == '-' ) && ( set )))
136 /* Action modifier ("+"/"-") must be changed ... */
137 if(( the_modes[strlen( the_modes ) - 1] == '+' ) || ( the_modes[strlen( the_modes ) - 1] == '-' ))
139 /* Adjust last action modifier in result */
140 the_modes[strlen( the_modes ) - 1] = *mode_ptr;
142 else
144 /* Append modifier character to result string */
145 x[0] = *mode_ptr;
146 strlcat( the_modes, x, sizeof( the_modes ));
148 if( *mode_ptr == '+' ) set = TRUE;
149 else set = FALSE;
151 continue;
154 /* Validate modes */
155 x[0] = '\0';
156 switch( *mode_ptr )
158 case 'a':
159 /* Away */
160 if( Client_Type( Client ) == CLIENT_SERVER )
162 x[0] = 'a';
163 Client_SetAway( Client, DEFAULT_AWAY_MSG );
165 else ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
166 break;
167 case 'i':
168 /* Invisible */
169 x[0] = 'i';
170 break;
171 case 'o':
172 /* IRC operator (only unsetable!) */
173 if(( ! set ) || ( Client_Type( Client ) == CLIENT_SERVER ))
175 Client_SetOperByMe( Target, FALSE );
176 x[0] = 'o';
178 else ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
179 break;
180 case 'r':
181 /* Restricted (only setable) */
182 if(( set ) || ( Client_Type( Client ) == CLIENT_SERVER )) x[0] = 'r';
183 else ok = IRC_WriteStrClient( Origin, ERR_RESTRICTED_MSG, Client_ID( Origin ));
184 break;
185 case 's':
186 /* Server messages */
187 x[0] = 's';
188 break;
189 default:
190 Log( LOG_DEBUG, "Unknown mode \"%c%c\" from \"%s\"!?", set ? '+' : '-', *mode_ptr, Client_ID( Origin ));
191 if( Client_Type( Client ) != CLIENT_SERVER ) ok = IRC_WriteStrClient( Origin, ERR_UMODEUNKNOWNFLAG2_MSG, Client_ID( Origin ), set ? '+' : '-', *mode_ptr );
192 x[0] = '\0';
193 goto client_exit;
195 if( ! ok ) break;
197 /* Is there a valid mode change? */
198 if( ! x[0] ) continue;
200 if( set )
202 /* Set mode */
203 if( Client_ModeAdd( Target, x[0] )) strlcat( the_modes, x, sizeof( the_modes ));
206 else
208 /* Unset mode */
209 if( Client_ModeDel( Target, x[0] )) strlcat( the_modes, x, sizeof( the_modes ));
212 client_exit:
214 /* Are there changed modes? */
215 if( the_modes[1] )
217 /* Remoce needless action modifier characters */
218 if(( the_modes[strlen( the_modes ) - 1] == '+' ) || ( the_modes[strlen( the_modes ) - 1] == '-' )) the_modes[strlen( the_modes ) - 1] = '\0';
220 if( Client_Type( Client ) == CLIENT_SERVER )
222 /* Forward modes to other servers */
223 IRC_WriteStrServersPrefix( Client, Origin, "MODE %s :%s", Client_ID( Target ), the_modes );
225 else
227 /* Send reply to client and inform other servers */
228 ok = IRC_WriteStrClientPrefix( Client, Origin, "MODE %s %s", Client_ID( Target ), the_modes );
229 IRC_WriteStrServersPrefix( Client, Origin, "MODE %s :%s", Client_ID( Target ), the_modes );
231 Log( LOG_DEBUG, "User \"%s\": Mode change, now \"%s\".", Client_Mask( Target ), Client_Modes( Target ));
234 return ok;
235 } /* Client_Mode */
238 LOCAL BOOLEAN
239 Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel )
241 /* Handle channel and channel-user modes */
243 CHAR the_modes[COMMAND_LEN], the_args[COMMAND_LEN], x[2], argadd[CLIENT_PASS_LEN], *mode_ptr;
244 BOOLEAN ok, set, modeok, skiponce;
245 INT mode_arg, arg_arg;
246 CLIENT *client;
247 LONG l;
249 /* Mode request: let's answer it :-) */
250 if( Req->argc == 1 )
252 /* Member or not? -- That's the question! */
253 if( ! Channel_IsMemberOf( Channel, Origin )) return IRC_WriteStrClient( Origin, RPL_CHANNELMODEIS_MSG, Client_ID( Origin ), Channel_Name( Channel ), Channel_Modes( Channel ));
255 /* The sender is a member: generate extended reply */
256 strlcpy( the_modes, Channel_Modes( Channel ), sizeof( the_modes ));
257 mode_ptr = the_modes;
258 strcpy( the_args, "" );
259 while( *mode_ptr )
261 switch( *mode_ptr )
263 case 'l':
264 snprintf( argadd, sizeof( argadd ), " %ld", Channel_MaxUsers( Channel ));
265 strlcat( the_args, argadd, sizeof( the_args ));
266 break;
267 case 'k':
268 strlcat( the_args, " ", sizeof( the_args ));
269 strlcat( the_args, Channel_Key( Channel ), sizeof( the_args ));
270 break;
272 mode_ptr++;
274 if( the_args[0] ) strlcat( the_modes, the_args, sizeof( the_modes ));
276 return IRC_WriteStrClient( Origin, RPL_CHANNELMODEIS_MSG, Client_ID( Origin ), Channel_Name( Channel ), the_modes );
279 /* Is the user allowed to change modes? */
280 if( Client_Type( Client ) == CLIENT_USER )
282 if( strchr( Channel_UserModes( Channel, Origin ), 'o' )) modeok = TRUE;
283 else modeok = FALSE;
284 if( Conf_OperCanMode )
286 /* auch IRC-Operatoren duerfen MODE verwenden */
287 if( Client_OperByMe( Origin )) modeok = TRUE;
290 else modeok = TRUE;
292 mode_arg = 1;
293 mode_ptr = Req->argv[mode_arg];
294 if( Req->argc > mode_arg + 1 ) arg_arg = mode_arg + 1;
295 else arg_arg = -1;
297 /* Initial state: set or unset modes? */
298 skiponce = FALSE;
299 if( *mode_ptr == '-' ) set = FALSE;
300 else if( *mode_ptr == '+' ) set = TRUE;
301 else set = skiponce = TRUE;
303 /* Prepare reply string */
304 if( set ) strcpy( the_modes, "+" );
305 else strcpy( the_modes, "-" );
306 strcpy( the_args, " " );
308 x[1] = '\0';
309 ok = CONNECTED;
310 while( mode_ptr )
312 if( ! skiponce ) mode_ptr++;
313 if( ! *mode_ptr )
315 /* Try next argument if there's any */
316 if( arg_arg > mode_arg ) mode_arg = arg_arg;
317 else mode_arg++;
318 if( mode_arg < Req->argc ) mode_ptr = Req->argv[mode_arg];
319 else break;
320 if( Req->argc > mode_arg + 1 ) arg_arg = mode_arg + 1;
321 else arg_arg = -1;
323 skiponce = FALSE;
325 switch( *mode_ptr )
327 case '+':
328 case '-':
329 if((( *mode_ptr == '+' ) && ( ! set )) || (( *mode_ptr == '-' ) && ( set )))
331 /* Action modifier ("+"/"-") must be changed ... */
332 if(( the_modes[strlen( the_modes ) - 1] == '+' ) || ( the_modes[strlen( the_modes ) - 1] == '-' ))
334 /* Adjust last action modifier in result */
335 the_modes[strlen( the_modes ) - 1] = *mode_ptr;
337 else
339 /* Append modifier character to result string */
340 x[0] = *mode_ptr;
341 strlcat( the_modes, x, sizeof( the_modes ));
343 if( *mode_ptr == '+' ) set = TRUE;
344 else set = FALSE;
346 continue;
349 /* Are there arguments left? */
350 if( arg_arg >= Req->argc ) arg_arg = -1;
352 /* Validate modes */
353 x[0] = '\0';
354 argadd[0] = '\0';
355 client = NULL;
356 switch( *mode_ptr )
358 /* Channel modes */
359 case 'i':
360 /* Invite-Only */
361 if( modeok ) x[0] = 'i';
362 else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
363 break;
364 case 'm':
365 /* Moderated */
366 if( modeok ) x[0] = 'm';
367 else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
368 break;
369 case 'n':
370 /* kein Schreiben in den Channel von aussen */
371 if( modeok ) x[0] = 'n';
372 else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
373 break;
374 case 't':
375 /* Topic Lock */
376 if( modeok ) x[0] = 't';
377 else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
378 break;
379 case 'P':
380 /* Persistent channel */
381 if( modeok )
383 if( set && ( ! Client_OperByMe( Client )))
385 /* Only IRC operators are allowed to set P mode */
386 ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
388 else x[0] = 'P';
390 else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
391 break;
393 /* Channel user modes */
394 case 'o':
395 /* Channel operator */
396 case 'v':
397 /* Voice */
398 if( arg_arg > mode_arg )
400 if( modeok )
402 client = Client_Search( Req->argv[arg_arg] );
403 if( client ) x[0] = *mode_ptr;
404 else ok = IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[arg_arg] );
406 else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
407 Req->argv[arg_arg][0] = '\0';
408 arg_arg++;
410 else ok = IRC_WriteStrClient( Origin, ERR_NEEDMOREPARAMS_MSG, Client_ID( Origin ), Req->command );
411 break;
412 case 'k':
413 /* Channel key */
414 if( ! set )
416 if( modeok ) x[0] = *mode_ptr;
417 else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
418 break;
420 if( arg_arg > mode_arg )
422 if( modeok )
424 Channel_ModeDel( Channel, 'k' );
425 Channel_SetKey( Channel, Req->argv[arg_arg] );
426 strlcpy( argadd, Channel_Key( Channel ), sizeof( argadd ));
427 x[0] = *mode_ptr;
429 else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
430 Req->argv[arg_arg][0] = '\0';
431 arg_arg++;
433 else ok = IRC_WriteStrClient( Origin, ERR_NEEDMOREPARAMS_MSG, Client_ID( Origin ), Req->command );
434 break;
435 case 'l':
436 /* Member limit */
437 if( ! set )
439 if( modeok ) x[0] = *mode_ptr;
440 else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
441 break;
443 if( arg_arg > mode_arg )
445 if( modeok )
447 l = atol( Req->argv[arg_arg] );
448 if( l > 0 && l < 0xFFFF )
450 Channel_ModeDel( Channel, 'l' );
451 Channel_SetMaxUsers( Channel, l );
452 snprintf( argadd, sizeof( argadd ), "%ld", l );
453 x[0] = *mode_ptr;
456 else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
457 Req->argv[arg_arg][0] = '\0';
458 arg_arg++;
460 else ok = IRC_WriteStrClient( Origin, ERR_NEEDMOREPARAMS_MSG, Client_ID( Origin ), Req->command );
461 break;
463 /* Channel lists */
464 case 'I':
465 /* Invite lists */
466 if( arg_arg > mode_arg )
468 /* modify list */
469 if( modeok )
471 if( set ) Add_Invite( Origin, Client, Channel, Req->argv[arg_arg] );
472 else Del_Invite( Origin, Client, Channel, Req->argv[arg_arg] );
474 else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
475 Req->argv[arg_arg][0] = '\0';
476 arg_arg++;
478 else Lists_ShowInvites( Origin, Channel );
479 break;
480 case 'b':
481 /* Ban lists */
482 if( arg_arg > mode_arg )
484 /* modify list */
485 if( modeok )
487 if( set ) Add_Ban( Origin, Client, Channel, Req->argv[arg_arg] );
488 else Del_Ban( Origin, Client, Channel, Req->argv[arg_arg] );
490 else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
491 Req->argv[arg_arg][0] = '\0';
492 arg_arg++;
494 else Lists_ShowBans( Origin, Channel );
495 break;
497 default:
498 Log( LOG_DEBUG, "Unknown mode \"%c%c\" from \"%s\" on %s!?", set ? '+' : '-', *mode_ptr, Client_ID( Origin ), Channel_Name( Channel ));
499 if( Client_Type( Client ) != CLIENT_SERVER ) ok = IRC_WriteStrClient( Origin, ERR_UMODEUNKNOWNFLAG2_MSG, Client_ID( Origin ), set ? '+' : '-', *mode_ptr );
500 x[0] = '\0';
501 goto chan_exit;
503 if( ! ok ) break;
505 /* Is there a valid mode change? */
506 if( ! x[0] ) continue;
508 if( set )
510 /* Set mode */
511 if( client )
513 /* Channel-User-Mode */
514 if( Channel_UserModeAdd( Channel, client, x[0] ))
516 strlcat( the_args, Client_ID( client ), sizeof( the_args ));
517 strlcat( the_args, " ", sizeof( the_args ));
518 strlcat( the_modes, x, sizeof( the_modes ));
519 Log( LOG_DEBUG, "User \"%s\": Mode change on %s, now \"%s\"", Client_Mask( client ), Channel_Name( Channel ), Channel_UserModes( Channel, client ));
522 else
524 /* Channel-Mode */
525 if( Channel_ModeAdd( Channel, x[0] ))
527 strlcat( the_modes, x, sizeof( the_modes ));
528 Log( LOG_DEBUG, "Channel %s: Mode change, now \"%s\".", Channel_Name( Channel ), Channel_Modes( Channel ));
532 else
534 /* Unset mode */
535 if( client )
537 /* Channel-User-Mode */
538 if( Channel_UserModeDel( Channel, client, x[0] ))
540 strlcat( the_args, Client_ID( client ), sizeof( the_args ));
541 strlcat( the_args, " ", sizeof( the_args ));
542 strlcat( the_modes, x, sizeof( the_modes ));
543 Log( LOG_DEBUG, "User \"%s\": Mode change on %s, now \"%s\"", Client_Mask( client ), Channel_Name( Channel ), Channel_UserModes( Channel, client ));
546 else
548 /* Channel-Mode */
549 if( Channel_ModeDel( Channel, x[0] ))
551 strlcat( the_modes, x, sizeof( the_modes ));
552 Log( LOG_DEBUG, "Channel %s: Mode change, now \"%s\".", Channel_Name( Channel ), Channel_Modes( Channel ));
557 /* Are there additional arguments to add? */
558 if( argadd[0] )
560 if( the_args[strlen( the_args ) - 1] != ' ' ) strlcat( the_args, " ", sizeof( the_args ));
561 strlcat( the_args, argadd, sizeof( the_args ));
564 chan_exit:
566 /* Are there changed modes? */
567 if( the_modes[1] )
569 /* Clean up mode string */
570 if(( the_modes[strlen( the_modes ) - 1] == '+' ) || ( the_modes[strlen( the_modes ) - 1] == '-' )) the_modes[strlen( the_modes ) - 1] = '\0';
572 /* Clean up argument string if there are none */
573 if( ! the_args[1] ) the_args[0] = '\0';
575 if( Client_Type( Client ) == CLIENT_SERVER )
577 /* Forward mode changes to channel users and other servers */
578 IRC_WriteStrServersPrefix( Client, Origin, "MODE %s %s%s", Channel_Name( Channel ), the_modes, the_args );
579 IRC_WriteStrChannelPrefix( Client, Channel, Origin, FALSE, "MODE %s %s%s", Channel_Name( Channel ), the_modes, the_args );
581 else
583 /* Send reply to client and inform other servers and channel users */
584 ok = IRC_WriteStrClientPrefix( Client, Origin, "MODE %s %s%s", Channel_Name( Channel ), the_modes, the_args );
585 IRC_WriteStrServersPrefix( Client, Origin, "MODE %s %s%s", Channel_Name( Channel ), the_modes, the_args );
586 IRC_WriteStrChannelPrefix( Client, Channel, Origin, FALSE, "MODE %s %s%s", Channel_Name( Channel ), the_modes, the_args );
590 return CONNECTED;
591 } /* Channel_Mode */
594 GLOBAL BOOLEAN
595 IRC_AWAY( CLIENT *Client, REQUEST *Req )
597 assert( Client != NULL );
598 assert( Req != NULL );
600 /* Falsche Anzahl Parameter? */
601 if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
603 if(( Req->argc == 1 ) && (Req->argv[0][0] ))
605 /* AWAY setzen */
606 Client_SetAway( Client, Req->argv[0] );
607 Client_ModeAdd( Client, 'a' );
608 IRC_WriteStrServersPrefix( Client, Client, "MODE %s :+a", Client_ID( Client ));
609 return IRC_WriteStrClient( Client, RPL_NOWAWAY_MSG, Client_ID( Client ));
611 else
613 /* AWAY loeschen */
614 Client_ModeDel( Client, 'a' );
615 IRC_WriteStrServersPrefix( Client, Client, "MODE %s :-a", Client_ID( Client ));
616 return IRC_WriteStrClient( Client, RPL_UNAWAY_MSG, Client_ID( Client ));
618 } /* IRC_AWAY */
621 LOCAL BOOLEAN
622 Add_Invite( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, CHAR *Pattern )
624 CHAR *mask;
626 assert( Client != NULL );
627 assert( Channel != NULL );
628 assert( Pattern != NULL );
630 mask = Lists_MakeMask( Pattern );
632 if( ! Lists_AddInvited( Prefix, mask, Channel, FALSE )) return CONNECTED;
633 return Send_ListChange( "+I", Prefix, Client, Channel, mask );
634 } /* Add_Invite */
637 LOCAL BOOLEAN
638 Add_Ban( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, CHAR *Pattern )
640 CHAR *mask;
642 assert( Client != NULL );
643 assert( Channel != NULL );
644 assert( Pattern != NULL );
646 mask = Lists_MakeMask( Pattern );
648 if( ! Lists_AddBanned( Prefix, mask, Channel )) return CONNECTED;
649 return Send_ListChange( "+b", Prefix, Client, Channel, mask );
650 } /* Add_Ban */
653 LOCAL BOOLEAN
654 Del_Invite( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, CHAR *Pattern )
656 CHAR *mask;
658 assert( Client != NULL );
659 assert( Channel != NULL );
660 assert( Pattern != NULL );
662 mask = Lists_MakeMask( Pattern );
663 Lists_DelInvited( mask, Channel );
664 return Send_ListChange( "-I", Prefix, Client, Channel, mask );
665 } /* Del_Invite */
668 LOCAL BOOLEAN
669 Del_Ban( CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, CHAR *Pattern )
671 CHAR *mask;
673 assert( Client != NULL );
674 assert( Channel != NULL );
675 assert( Pattern != NULL );
677 mask = Lists_MakeMask( Pattern );
678 Lists_DelBanned( mask, Channel );
679 return Send_ListChange( "-b", Prefix, Client, Channel, mask );
680 } /* Del_Ban */
683 LOCAL BOOLEAN
684 Send_ListChange( CHAR *Mode, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, CHAR *Mask )
686 /* Bestaetigung an Client schicken & andere Server sowie Channel-User informieren */
688 BOOLEAN ok;
690 if( Client_Type( Client ) == CLIENT_USER )
692 /* Bestaetigung an Client */
693 ok = IRC_WriteStrClientPrefix( Client, Prefix, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask );
695 else ok = TRUE;
697 /* an andere Server */
698 IRC_WriteStrServersPrefix( Client, Prefix, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask );
700 /* und lokale User im Channel */
701 IRC_WriteStrChannelPrefix( Client, Channel, Prefix, FALSE, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask );
703 return ok;
704 } /* Send_ListChange */
707 /* -eof- */