* IRC commands for server links
*/
-#include "imp.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
-#include "defines.h"
-#include "conn.h"
#include "conn-func.h"
#include "conn-zip.h"
#include "conf.h"
#include "channel.h"
-#include "lists.h"
#include "log.h"
#include "messages.h"
#include "parse.h"
#include "numeric.h"
#include "ngircd.h"
#include "irc-info.h"
-#include "irc-macros.h"
#include "irc-write.h"
#include "op.h"
-#include "exp.h"
-#include "irc-server.h"
-
/**
* Handler for the IRC "SERVER" command.
*
GLOBAL bool
IRC_SERVER( CLIENT *Client, REQUEST *Req )
{
- char str[LINE_LEN];
+ char str[100];
CLIENT *from, *c;
int i;
/* Return an error if this is not a local client */
if (Client_Conn(Client) <= NONE)
- return IRC_WriteStrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
+ return IRC_WriteErrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
Client_ID(Client), Req->command);
if (Client_Type(Client) == CLIENT_GOTPASS ||
Client_Conn(Client));
if (Req->argc != 2 && Req->argc != 3)
- return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+ return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client),
Req->command);
if (strcasecmp(Req->argv[0], Conf_Server[i].name) == 0)
break;
- /* Makre sure the remote server is configured here */
+ /* Make sure the remote server is configured here */
if (i >= MAX_SERVERS) {
Log(LOG_ERR,
"Connection %d: Server \"%s\" not configured here!",
Client_SetType(Client, CLIENT_UNKNOWNSERVER);
#ifdef ZLIB
- if (strchr(Client_Flags(Client), 'Z')
+ if (Client_HasFlag(Client, 'Z')
&& !Zip_InitConn(Client_Conn(Client))) {
Conn_Close(Client_Conn(Client),
- "Can't inizialize compression (zlib)!",
+ "Can't initialize compression (zlib)!",
NULL, false );
return DISCONNECTED;
}
#endif
#ifdef IRCPLUS
- if (strchr(Client_Flags(Client), 'H')) {
+ if (Client_HasFlag(Client, 'H')) {
LogDebug("Peer supports IRC+ extended server handshake ...");
if (!IRC_Send_ISUPPORT(Client))
return DISCONNECTED;
{
/* New server is being introduced to the network */
- if( Req->argc != 4 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+ if (Req->argc != 4)
+ return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+ Client_ID(Client), Req->command);
/* check for existing server with same ID */
- if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
+ if (!Client_CheckID(Client, Req->argv[0]))
+ return DISCONNECTED;
from = Client_Search( Req->prefix );
- if( ! from )
- {
+ if (! from) {
/* Uh, Server, that introduced the new server is unknown?! */
- Log( LOG_ALERT, "Unknown ID in prefix of SERVER: \"%s\"! (on connection %d)", Req->prefix, Client_Conn( Client ));
- Conn_Close( Client_Conn( Client ), NULL, "Unknown ID in prefix of SERVER", true);
+ Log(LOG_ALERT,
+ "Unknown ID in prefix of SERVER: \"%s\"! (on connection %d)",
+ Req->prefix, Client_Conn(Client));
+ Conn_Close(Client_Conn(Client), NULL,
+ "Unknown ID in prefix of SERVER", true);
return DISCONNECTED;
}
- c = Client_NewRemoteServer(Client, Req->argv[0], from, atoi(Req->argv[1]), atoi(Req->argv[2]), Req->argv[3], true);
+ c = Client_NewRemoteServer(Client, Req->argv[0], from,
+ atoi(Req->argv[1]), atoi(Req->argv[2]),
+ Req->argv[3], true);
if (!c) {
- Log( LOG_ALERT, "Can't create client structure for server! (on connection %d)", Client_Conn( Client ));
- Conn_Close( Client_Conn( Client ), NULL, "Can't allocate client structure for remote server", true);
+ Log(LOG_ALERT,
+ "Can't create client structure for server! (on connection %d)",
+ Client_Conn(Client));
+ Conn_Close(Client_Conn(Client), NULL,
+ "Can't allocate client structure for remote server",
+ true);
return DISCONNECTED;
}
- if(( Client_Hops( c ) > 1 ) && ( Req->prefix[0] )) snprintf( str, sizeof( str ), "connected to %s, ", Client_ID( from ));
- else strcpy( str, "" );
- Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" registered (via %s, %s%d hop%s).", Client_ID( c ), Client_ID( Client ), str, Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
+ if (Client_Hops(c) > 1 && Req->prefix[0])
+ snprintf(str, sizeof(str), "connected to %s, ",
+ Client_ID(from));
+ else
+ strcpy(str, "");
+ Log(LOG_NOTICE|LOG_snotice,
+ "Server \"%s\" registered (via %s, %s%d hop%s).",
+ Client_ID(c), Client_ID(Client), str, Client_Hops(c),
+ Client_Hops(c) > 1 ? "s": "" );
/* notify other servers */
- IRC_WriteStrServersPrefix( Client, from, "SERVER %s %d %d :%s", Client_ID( c ), Client_Hops( c ) + 1, Client_MyToken( c ), Client_Info( c ));
+ IRC_WriteStrServersPrefix(Client, from, "SERVER %s %d %d :%s",
+ Client_ID(c), Client_Hops(c) + 1,
+ Client_MyToken(c), Client_Info(c));
return CONNECTED;
} else
- return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+ return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
} /* IRC_SERVER */
assert( Client != NULL );
assert( Req != NULL );
- _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2)
-
strlcpy( nick_in, Req->argv[1], sizeof( nick_in ));
strcpy( nick_out, "" );
&& !Client_HasMode(Client, 'o'))
return Op_NoPrivileges(Client, Req);
- _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2)
-
if (Client_Type(Client) == CLIENT_SERVER && Req->prefix) {
from = Client_Search(Req->prefix);
if (Client_Type(from) != CLIENT_SERVER
} else
from = Client;
if (!from)
- return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
+ return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->prefix);
if (Client_Type(Client) == CLIENT_USER)