From a64e33b317dc18eab1bf8b84fc3831e385234afa Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Sat, 2 Dec 2006 14:21:26 +0000 Subject: [PATCH] cleanups [from HEAD] --- src/ngircd/irc-mode.c | 6 +++--- src/ngircd/irc-op.c | 11 +++++------ src/ngircd/irc-server.c | 29 +++++++++++++++++++++-------- src/ngircd/messages.h | 14 +++++++------- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c index 1bfa9e15..8f4dfae5 100644 --- a/src/ngircd/irc-mode.c +++ b/src/ngircd/irc-mode.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: irc-mode.c,v 1.45 2006/05/10 21:24:01 alex Exp $"; +static char UNUSED id[] = "$Id: irc-mode.c,v 1.45.2.1 2006/12/02 14:21:26 fw Exp $"; #include "imp.h" #include @@ -69,7 +69,7 @@ IRC_MODE( CLIENT *Client, REQUEST *Req ) if( ! origin ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); } else origin = Client; - + /* Channel or user mode? */ cl = NULL; chan = NULL; if (Client_IsValidNick(Req->argv[0])) @@ -268,7 +268,7 @@ Channel_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel ) switch( *mode_ptr ) { case 'l': - snprintf( argadd, sizeof( argadd ), " %ld", Channel_MaxUsers( Channel )); + snprintf( argadd, sizeof( argadd ), " %lu", Channel_MaxUsers( Channel )); strlcat( the_args, argadd, sizeof( the_args )); break; case 'k': diff --git a/src/ngircd/irc-op.c b/src/ngircd/irc-op.c index 587c4c60..f05f91f7 100644 --- a/src/ngircd/irc-op.c +++ b/src/ngircd/irc-op.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: irc-op.c,v 1.15 2005/04/27 07:39:18 alex Exp $"; +static char UNUSED id[] = "$Id: irc-op.c,v 1.15.4.1 2006/12/02 14:21:26 fw Exp $"; #include "imp.h" #include @@ -101,15 +101,14 @@ IRC_INVITE( CLIENT *Client, REQUEST *Req ) /* If the target user is banned on that channel: remember invite */ if( Lists_CheckBanned( target, chan )) remember = true; - if( remember ) - { - /* We must memember this invite */ + if (remember) { + /* We must remember this invite */ if( ! Lists_AddInvited( Client_Mask( target ), chan, true)) return CONNECTED; } } - Log( LOG_DEBUG, "User \"%s\" invites \"%s\" to \"%s\" ...", Client_Mask( from ), Req->argv[0], Req->argv[1] ); - + LogDebug("User \"%s\" invites \"%s\" to \"%s\" ...", Client_Mask(from), Req->argv[0], Req->argv[1]); + /* Inform target client */ IRC_WriteStrClientPrefix( target, from, "INVITE %s %s", Req->argv[0], Req->argv[1] ); diff --git a/src/ngircd/irc-server.c b/src/ngircd/irc-server.c index 2c153064..1da5c2cc 100644 --- a/src/ngircd/irc-server.c +++ b/src/ngircd/irc-server.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: irc-server.c,v 1.39 2006/04/30 21:31:43 alex Exp $"; +static char UNUSED id[] = "$Id: irc-server.c,v 1.39.2.1 2006/12/02 14:21:26 fw Exp $"; #include "imp.h" #include @@ -41,6 +41,10 @@ static char UNUSED id[] = "$Id: irc-server.c,v 1.39 2006/04/30 21:31:43 alex Exp #include "irc-server.h" +/** + * Handler for the IRC command "SERVER". + * See RFC 2813 section 4.1.2. + */ GLOBAL bool IRC_SERVER( CLIENT *Client, REQUEST *Req ) { @@ -55,13 +59,16 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) assert( Client != NULL ); assert( Req != NULL ); - /* Fehler liefern, wenn kein lokaler Client */ - if( Client_Conn( Client ) <= NONE ) return IRC_WriteStrClient( Client, ERR_UNKNOWNCOMMAND_MSG, Client_ID( Client ), Req->command ); + /* Return an error if this is not a local client */ + if (Client_Conn(Client) <= NONE) + return IRC_WriteStrClient(Client, ERR_UNKNOWNCOMMAND_MSG, + Client_ID(Client), Req->command); - if( Client_Type( Client ) == CLIENT_GOTPASSSERVER ) - { - /* Verbindung soll als Server-Server-Verbindung registriert werden */ - Log( LOG_DEBUG, "Connection %d: got SERVER command (new server link) ...", Client_Conn( Client )); + if (Client_Type(Client) == CLIENT_GOTPASSSERVER) { + /* We got a PASS command from the peer, and now a SERVER + * command: the peer tries to register itself as a server. */ + LogDebug("Connection %d: got SERVER command (new server link) ...", + Client_Conn(Client)); /* Falsche Anzahl Parameter? */ if(( Req->argc != 2 ) && ( Req->argc != 3 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); @@ -207,7 +214,13 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) else { /* "CHANINFO + :" */ - if( ! IRC_WriteStrClient( Client, "CHANINFO %s +%s %s %ld :%s", Channel_Name( chan ), modes, strchr( Channel_Modes( chan ), 'k' ) ? Channel_Key( chan ) : "*", strchr( Channel_Modes( chan ), 'l' ) ? Channel_MaxUsers( chan ) : 0L, topic )) return DISCONNECTED; + if( ! IRC_WriteStrClient( Client, "CHANINFO %s +%s %s %lu :%s", + Channel_Name( chan ), modes, + strchr( Channel_Modes( chan ), 'k' ) ? Channel_Key( chan ) : "*", + strchr( Channel_Modes( chan ), 'l' ) ? Channel_MaxUsers( chan ) : 0UL, topic )) + { + return DISCONNECTED; + } } } } diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h index ee1eff67..1d8288d8 100644 --- a/src/ngircd/messages.h +++ b/src/ngircd/messages.h @@ -8,7 +8,7 @@ * (at your option) any later version. * Please read the file COPYING, README and AUTHORS for more information. * - * $Id: messages.h,v 1.67 2005/09/02 12:50:25 alex Exp $ + * $Id: messages.h,v 1.67.2.1 2006/12/02 14:21:26 fw Exp $ * * IRC numerics (Header) */ @@ -32,17 +32,17 @@ #define RPL_ENDOFSTATS_MSG "219 %s %c :End of STATS report" #define RPL_UMODEIS_MSG "221 %s +%s" #define RPL_LUSERCLIENT_MSG "251 %s :There are %ld users and %ld services on %ld servers" -#define RPL_LUSEROP_MSG "252 %s %ld :operator(s) online" -#define RPL_LUSERUNKNOWN_MSG "253 %s %ld :unknown connection(s)" -#define RPL_LUSERCHANNELS_MSG "254 %s %ld :channels formed" -#define RPL_LUSERME_MSG "255 %s :I have %ld users, %ld services and %ld servers" +#define RPL_LUSEROP_MSG "252 %s %lu :operator(s) online" +#define RPL_LUSERUNKNOWN_MSG "253 %s %lu :unknown connection(s)" +#define RPL_LUSERCHANNELS_MSG "254 %s %lu :channels formed" +#define RPL_LUSERME_MSG "255 %s :I have %lu users, %lu services and %lu servers" #define RPL_ADMINME_MSG "256 %s %s :Administrative info" #define RPL_ADMINLOC1_MSG "257 %s :%s" #define RPL_ADMINLOC2_MSG "258 %s :%s" #define RPL_ADMINEMAIL_MSG "259 %s :%s" #define RPL_TRACEEND_MSG "262 %s %s %s-%s.%s :End of TRACE" -#define RPL_LOCALUSERS_MSG "265 %s :Current local users: %ld, Max: %ld" -#define RPL_NETUSERS_MSG "266 %s :Current global users: %ld, Max: %ld" +#define RPL_LOCALUSERS_MSG "265 %s :Current local users: %lu, Max: %lu" +#define RPL_NETUSERS_MSG "266 %s :Current global users: %lu, Max: %lu" #define RPL_AWAY_MSG "301 %s %s :%s" #define RPL_USERHOST_MSG "302 %s :" -- 2.39.2