]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc-info.c
Fixed a typo in variable name ...
[ngircd-alex.git] / src / ngircd / irc-info.c
index e4d1c7fcc3fbcd93dd4dacff65aac44242b737dc..b0aec128abd0ef80cae946fb78e6448f0b439d6f 100644 (file)
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-info.c,v 1.18 2003/11/05 23:24:48 alex Exp $";
+static char UNUSED id[] = "$Id: irc-info.c,v 1.24 2005/01/24 14:19:04 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
+#include <strings.h>
 
 #include "ngircd.h"
 #include "cvs-version.h"
@@ -379,7 +380,7 @@ IRC_STATS( CLIENT *Client, REQUEST *Req )
                                if( cl && (( Client_Type( cl ) == CLIENT_SERVER ) || ( cl == Client )))
                                {
                                        /* Server link or our own connection */
-#ifdef USE_ZLIB
+#ifdef ZLIB
                                        if( Conn_Options( con ) & CONN_ZIP )
                                        {
                                                if( ! IRC_WriteStrClient( from, RPL_STATSLINKINFOZIP_MSG, Client_ID( from ), Client_Mask( cl ), Conn_SendQ( con ), Conn_SendMsg( con ), Zip_SendBytes( con ), Conn_SendBytes( con ), Conn_RecvMsg( con ), Zip_RecvBytes( con ), Conn_RecvBytes( con ), (LONG)( time( NULL ) - Conn_StartTime( con )))) return DISCONNECTED;
@@ -494,7 +495,7 @@ IRC_VERSION( CLIENT *Client, REQUEST *Req )
 {
        CLIENT *target, *prefix;
 #ifdef CVSDATE
-       CHAR ver[12];
+       CHAR ver[12], vertxt[30];
 #endif
 
        assert( Client != NULL );
@@ -528,7 +529,8 @@ IRC_VERSION( CLIENT *Client, REQUEST *Req )
        strlcpy( ver, CVSDATE, sizeof( ver ));
        strncpy( ver + 4, ver + 5, 2 );
        strncpy( ver + 6, ver + 8, 3 );
-       return IRC_WriteStrClient( Client, RPL_VERSION_MSG, Client_ID( prefix ), PACKAGE_NAME, ver, NGIRCd_DebugLevel, Conf_ServerName, NGIRCd_VersionAddition( ));
+       snprintf( vertxt, sizeof( vertxt ), "%s(%s)", PACKAGE_VERSION, ver );
+       return IRC_WriteStrClient( Client, RPL_VERSION_MSG, Client_ID( prefix ), PACKAGE_NAME, vertxt, NGIRCd_DebugLevel, Conf_ServerName, NGIRCd_VersionAddition( ));
 #else
        return IRC_WriteStrClient( Client, RPL_VERSION_MSG, Client_ID( prefix ), PACKAGE_NAME, PACKAGE_VERSION, NGIRCd_DebugLevel, Conf_ServerName, NGIRCd_VersionAddition( ));
 #endif
@@ -768,9 +770,17 @@ IRC_Show_MOTD( CLIENT *Client )
        BOOLEAN ok;
        CHAR line[127];
        FILE *fd;
+       UINT line_len;
 
        assert( Client != NULL );
 
+       if( Conf_MotdPhrase[0] )
+       {
+               if( ! IRC_WriteStrClient( Client, RPL_MOTDSTART_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )))) return DISCONNECTED;
+               if( ! IRC_WriteStrClient( Client, RPL_MOTD_MSG, Client_ID( Client ), Conf_MotdPhrase )) return DISCONNECTED;
+               return IRC_WriteStrClient( Client, RPL_ENDOFMOTD_MSG, Client_ID( Client ));
+       }
+
        fd = fopen( Conf_MotdFile, "r" );
        if( ! fd )
        {
@@ -778,11 +788,15 @@ IRC_Show_MOTD( CLIENT *Client )
                return IRC_WriteStrClient( Client, ERR_NOMOTD_MSG, Client_ID( Client ) );
        }
 
-       IRC_WriteStrClient( Client, RPL_MOTDSTART_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )));
+       if( ! IRC_WriteStrClient( Client, RPL_MOTDSTART_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )))) return DISCONNECTED;
        while( TRUE )
        {
-               if( ! fgets( line, 126, fd )) break;
-               if( line[strlen( line ) - 1] == '\n' ) line[strlen( line ) - 1] = '\0';
+               if( ! fgets( line, sizeof( line ), fd )) break;
+
+               line_len = strlen( line );
+               if( line_len > 0 ) line_len--;
+               if( line[line_len] == '\n' ) line[line_len] = '\0';
+
                if( ! IRC_WriteStrClient( Client, RPL_MOTD_MSG, Client_ID( Client ), line ))
                {
                        fclose( fd );