/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2008 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-login.c,v 1.53 2006/10/03 10:28:38 alex Exp $";
-
#include "imp.h"
#include <assert.h>
#include <stdio.h>
#include "irc.h"
#include "irc-info.h"
#include "irc-write.h"
-#include "cvs-version.h"
#include "exp.h"
#include "irc-login.h"
else
{
/* Nickname change */
- if( Client_Conn( target ) > NONE )
- {
+ if (Client_Conn(target) > NONE) {
/* Local client */
- Log( LOG_INFO,
- "User \"%s\" changed nick (connection %d): \"%s\" -> \"%s\".",
- Client_Mask( target ), Client_Conn( target ),
- Client_ID( target ), Req->argv[0] );
+ Log(LOG_INFO,
+ "User \"%s\" changed nick (connection %d): \"%s\" -> \"%s\".",
+ Client_Mask(target), Client_Conn(target),
+ Client_ID(target), Req->argv[0]);
+ Conn_UpdateIdle(Client_Conn(target));
}
else
{
} /* IRC_USER */
+/**
+ * Service registration.
+ * ngIRCd does not support services at the moment, so this function is a
+ * dummy that returns ERR_ERRONEUSNICKNAME on each call.
+ */
+GLOBAL bool
+IRC_SERVICE(CLIENT *Client, REQUEST *Req)
+{
+ assert(Client != NULL);
+ assert(Req != NULL);
+
+ if (Client_Type(Client) != CLIENT_GOTPASS)
+ return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
+ Client_ID(Client));
+
+ if (Req->argc != 6)
+ return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+ Client_ID(Client), Req->command);
+
+ return IRC_WriteStrClient(Client, ERR_ERRONEUSNICKNAME_MSG,
+ Client_ID(Client), Req->argv[0]);
+} /* IRC_SERVICE */
+
+
GLOBAL bool
IRC_QUIT( CLIENT *Client, REQUEST *Req )
{
Client_ID(from), Client_ID(Client));
#else
/* Some clients depend on the argument being returned in the PONG
- * reply (not mentioned in any RFC, though) */
+ * reply (not mentioned in any RFC, though) */
return IRC_WriteStrClient(Client, "PONG %s :%s",
Client_ID(from), Req->argv[0]);
#endif
static bool
-Hello_User( CLIENT *Client )
+Hello_User(CLIENT * Client)
{
-#ifdef CVSDATE
- char ver[12], vertxt[30];
-#endif
-
- assert( Client != NULL );
+ assert(Client != NULL);
/* Check password ... */
- if( strcmp( Client_Password( Client ), Conf_ServerPwd ) != 0 )
- {
+ if (strcmp(Client_Password(Client), Conf_ServerPwd) != 0) {
/* Bad password! */
- Log( LOG_ERR, "User \"%s\" rejected (connection %d): Bad password!", Client_Mask( Client ), Client_Conn( Client ));
- Conn_Close( Client_Conn( Client ), NULL, "Bad password", true);
+ Log(LOG_ERR,
+ "User \"%s\" rejected (connection %d): Bad password!",
+ Client_Mask(Client), Client_Conn(Client));
+ Conn_Close(Client_Conn(Client), NULL, "Bad password", true);
return DISCONNECTED;
}
- Log( LOG_NOTICE, "User \"%s\" registered (connection %d).", Client_Mask( Client ), Client_Conn( Client ));
+ Log(LOG_NOTICE, "User \"%s\" registered (connection %d).",
+ Client_Mask(Client), Client_Conn(Client));
/* Inform other servers */
- IRC_WriteStrServers( NULL, "NICK %s 1 %s %s 1 +%s :%s", Client_ID( Client ), Client_User( Client ), Client_Hostname( Client ), Client_Modes( Client ), Client_Info( Client ));
-
- /* Welcome :-) */
- if( ! IRC_WriteStrClient( Client, RPL_WELCOME_MSG, Client_ID( Client ), Client_Mask( Client ))) return false;
-
- /* Version and system type */
-#ifdef CVSDATE
- strlcpy( ver, CVSDATE, sizeof( ver ));
- strncpy( ver + 4, ver + 5, 2 );
- strncpy( ver + 6, ver + 8, 3 );
- snprintf( vertxt, sizeof( vertxt ), "%s(%s)", PACKAGE_VERSION, ver );
- if( ! IRC_WriteStrClient( Client, RPL_YOURHOST_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), vertxt, TARGET_CPU, TARGET_VENDOR, TARGET_OS )) return false;
-#else
- if( ! IRC_WriteStrClient( Client, RPL_YOURHOST_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), PACKAGE_VERSION, TARGET_CPU, TARGET_VENDOR, TARGET_OS )) return false;
-#endif
-
- if( ! IRC_WriteStrClient( Client, RPL_CREATED_MSG, Client_ID( Client ), NGIRCd_StartStr )) return false;
-#ifdef CVSDATE
- if( ! IRC_WriteStrClient( Client, RPL_MYINFO_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), vertxt, USERMODES, CHANMODES )) return false;
-#else
- if( ! IRC_WriteStrClient( Client, RPL_MYINFO_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), PACKAGE_VERSION, USERMODES, CHANMODES )) return false;
-#endif
+ IRC_WriteStrServers(NULL, "NICK %s 1 %s %s 1 +%s :%s",
+ Client_ID(Client), Client_User(Client),
+ Client_Hostname(Client), Client_Modes(Client),
+ Client_Info(Client));
+
+ if (!IRC_WriteStrClient
+ (Client, RPL_WELCOME_MSG, Client_ID(Client), Client_Mask(Client)))
+ return false;
+ if (!IRC_WriteStrClient
+ (Client, RPL_YOURHOST_MSG, Client_ID(Client),
+ Client_ID(Client_ThisServer()), PACKAGE_VERSION, TARGET_CPU,
+ TARGET_VENDOR, TARGET_OS))
+ return false;
+ if (!IRC_WriteStrClient
+ (Client, RPL_CREATED_MSG, Client_ID(Client), NGIRCd_StartStr))
+ return false;
+ if (!IRC_WriteStrClient
+ (Client, RPL_MYINFO_MSG, Client_ID(Client),
+ Client_ID(Client_ThisServer()), PACKAGE_VERSION, USERMODES,
+ CHANMODES))
+ return false;
/* Features supported by this server (005 numeric, ISUPPORT),
* see <http://www.irc.org/tech_docs/005.html> for details. */
- if (! IRC_WriteStrClient(Client, RPL_ISUPPORT1_MSG, Client_ID(Client),
- Conf_MaxJoins))
- return DISCONNECTED;
- if (! IRC_WriteStrClient(Client, RPL_ISUPPORT2_MSG, Client_ID(Client),
- CHANNEL_NAME_LEN-1, CLIENT_NICK_LEN-1, COMMAND_LEN-23,
- CLIENT_AWAY_LEN-1, COMMAND_LEN-113))
+ if (!IRC_Send_ISUPPORT(Client))
return DISCONNECTED;
- Client_SetType( Client, CLIENT_USER );
+ Client_SetType(Client, CLIENT_USER);
- if( ! IRC_Send_LUSERS( Client )) return DISCONNECTED;
- if( ! IRC_Show_MOTD( Client )) return DISCONNECTED;
+ if (!IRC_Send_LUSERS(Client))
+ return DISCONNECTED;
+ if (!IRC_Show_MOTD(Client))
+ return DISCONNECTED;
/* Suspend the client for a second ... */
- IRC_SetPenalty( Client, 1 );
+ IRC_SetPenalty(Client, 1);
return CONNECTED;
} /* Hello_User */