X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Firc-server.c;h=80bb6a6141169fe0b03b18063496a2b9d0494800;hp=7770be856cb0840aee2464633d1bd60344fb5e16;hb=08f9d31d60220e8a389a2d24f42625be7749f090;hpb=139f5961a078dfd23a469d98c3942f42595854aa diff --git a/src/ngircd/irc-server.c b/src/ngircd/irc-server.c index 7770be85..80bb6a61 100644 --- a/src/ngircd/irc-server.c +++ b/src/ngircd/irc-server.c @@ -62,7 +62,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) /* 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 || @@ -73,7 +73,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) 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); @@ -183,37 +183,56 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) { /* 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 */ @@ -235,8 +254,6 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req ) 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, "" ); @@ -326,8 +343,6 @@ IRC_SQUIT(CLIENT * Client, REQUEST * Req) && !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 @@ -336,7 +351,7 @@ IRC_SQUIT(CLIENT * Client, REQUEST * Req) } 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)