commit - 3da942e2374449248b1359222564db8f9997b090
commit + 8579b2a1e514b2c25d81f439f277c9fb39fc1e9f
blob - 69820d1d28d5da4e725039427d16d68eecf8e199
blob + bbecca98c3901e56aa224647936dc9b80be0e62d
--- src/ngircd/irc-mode.c
+++ src/ngircd/irc-mode.c
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2005 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "portab.h"
-static char UNUSED id[] = "$Id: irc-mode.c,v 1.35 2004/04/25 15:42:05 alex Exp $";
+static char UNUSED id[] = "$Id: irc-mode.c,v 1.36 2005/02/27 20:09:44 alex Exp $";
#include "imp.h"
#include <assert.h>
x[0] = '\0';
switch( *mode_ptr )
{
- case 'a':
- /* Away */
+ case 'i': /* Invisible */
+ case 's': /* Server messages */
+ x[0] = *mode_ptr;
+ break;
+
+ case 'a': /* Away */
if( Client_Type( Client ) == CLIENT_SERVER )
{
x[0] = 'a';
}
else ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
break;
- case 'i':
- /* Invisible */
- x[0] = 'i';
- break;
- case 'o':
- /* IRC operator (only unsetable!) */
+
+ case 'o': /* IRC operator (only unsettable!) */
if(( ! set ) || ( Client_Type( Client ) == CLIENT_SERVER ))
{
Client_SetOperByMe( Target, FALSE );
}
else ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
break;
- case 'r':
- /* Restricted (only setable) */
+
+ case 'r': /* Restricted (only settable) */
if(( set ) || ( Client_Type( Client ) == CLIENT_SERVER )) x[0] = 'r';
else ok = IRC_WriteStrClient( Origin, ERR_RESTRICTED_MSG, Client_ID( Origin ));
break;
- case 's':
- /* Server messages */
- x[0] = 's';
- break;
+
default:
Log( LOG_DEBUG, "Unknown mode \"%c%c\" from \"%s\"!?", set ? '+' : '-', *mode_ptr, Client_ID( Origin ));
if( Client_Type( Client ) != CLIENT_SERVER ) ok = IRC_WriteStrClient( Origin, ERR_UMODEUNKNOWNFLAG2_MSG, Client_ID( Origin ), set ? '+' : '-', *mode_ptr );
client = NULL;
switch( *mode_ptr )
{
- /* Channel modes */
- case 'i':
- /* Invite-Only */
- if( modeok ) x[0] = 'i';
- else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
- break;
- case 'm':
- /* Moderated */
- if( modeok ) x[0] = 'm';
- else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
- break;
- case 'n':
- /* kein Schreiben in den Channel von aussen */
- if( modeok ) x[0] = 'n';
- else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
- break;
- case 't':
- /* Topic Lock */
- if( modeok ) x[0] = 't';
- else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
- break;
- case 'P':
- /* Persistent channel */
- if( modeok )
- {
- if( set && ( ! Client_OperByMe( Client )))
- {
- /* Only IRC operators are allowed to set P mode */
- ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
- }
- else x[0] = 'P';
- }
+ /* --- Channel modes --- */
+
+ case 'i': /* Invite only */
+ case 'm': /* Moderated */
+ case 'n': /* Only members can write */
+ case 't': /* Topic locked */
+ if( modeok ) x[0] = *mode_ptr;
else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
break;
- /* Channel user modes */
- case 'o':
- /* Channel operator */
- case 'v':
- /* Voice */
- if( arg_arg > mode_arg )
- {
- if( modeok )
- {
- client = Client_Search( Req->argv[arg_arg] );
- if( client ) x[0] = *mode_ptr;
- else ok = IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[arg_arg] );
- }
- else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
- Req->argv[arg_arg][0] = '\0';
- arg_arg++;
- }
- else ok = IRC_WriteStrClient( Origin, ERR_NEEDMOREPARAMS_MSG, Client_ID( Origin ), Req->command );
- break;
- case 'k':
- /* Channel key */
+ case 'k': /* Channel key */
if( ! set )
{
if( modeok ) x[0] = *mode_ptr;
}
else ok = IRC_WriteStrClient( Origin, ERR_NEEDMOREPARAMS_MSG, Client_ID( Origin ), Req->command );
break;
- case 'l':
- /* Member limit */
+
+ case 'l': /* Member limit */
if( ! set )
{
if( modeok ) x[0] = *mode_ptr;
else ok = IRC_WriteStrClient( Origin, ERR_NEEDMOREPARAMS_MSG, Client_ID( Origin ), Req->command );
break;
- /* Channel lists */
- case 'I':
- /* Invite lists */
+ case 'P': /* Persistent channel */
+ if( modeok )
+ {
+ if( set && ( ! Client_OperByMe( Client )))
+ {
+ /* Only IRC operators are allowed to set P mode */
+ ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
+ }
+ else x[0] = 'P';
+ }
+ else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
+ break;
+
+ /* --- Channel user modes --- */
+
+ case 'o': /* Channel operator */
+ case 'v': /* Voice */
if( arg_arg > mode_arg )
{
+ if( modeok )
+ {
+ client = Client_Search( Req->argv[arg_arg] );
+ if( client ) x[0] = *mode_ptr;
+ else ok = IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[arg_arg] );
+ }
+ else ok = IRC_WriteStrClient( Origin, ERR_CHANOPRIVSNEEDED_MSG, Client_ID( Origin ), Channel_Name( Channel ));
+ Req->argv[arg_arg][0] = '\0';
+ arg_arg++;
+ }
+ else ok = IRC_WriteStrClient( Origin, ERR_NEEDMOREPARAMS_MSG, Client_ID( Origin ), Req->command );
+ break;
+
+ /* --- Channel lists --- */
+
+ case 'I': /* Invite lists */
+ if( arg_arg > mode_arg )
+ {
/* modify list */
if( modeok )
{
}
else Lists_ShowInvites( Origin, Channel );
break;
- case 'b':
- /* Ban lists */
+
+ case 'b': /* Ban lists */
if( arg_arg > mode_arg )
{
/* modify list */