]> arthur.barton.de Git - ngircd.git/blobdiff - src/ngircd/conf.c
Eliminate some compiler warnings ("unused parameter").
[ngircd.git] / src / ngircd / conf.c
index 276fc81ec838a93043d0f57a9ed7012fa7075cc9..a10d1be0167e06c24908a1996b00dc5228714890 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conf.c,v 1.72 2005/03/19 18:43:48 fw Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.80 2005/07/17 18:58:04 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -97,7 +97,7 @@ Conf_Test( void )
 
        struct passwd *pwd;
        struct group *grp;
-       int i;
+       unsigned int i;
 
        Use_Log = false;
        Set_Defaults( true );
@@ -105,8 +105,9 @@ Conf_Test( void )
        Read_Config( );
        Validate_Config( true );
 
-       /* If stdin is a valid tty wait for a key: */
-       if( isatty( fileno( stdout )))
+       /* If stdin and stdout ("you can read our nice message and we can
+        * read in your keypress") are valid tty's, wait for a key: */
+       if( isatty( fileno( stdin )) && isatty( fileno( stdout )))
        {
                puts( "OK, press enter to see a dump of your service configuration ..." );
                getchar( );
@@ -128,7 +129,7 @@ Conf_Test( void )
        for( i = 0; i < Conf_ListenPorts_Count; i++ )
        {
                if( i != 0 ) printf( ", " );
-               printf( "%u", Conf_ListenPorts[i] );
+               printf( "%u", (unsigned int) Conf_ListenPorts[i] );
        }
        puts( "" );
        printf( "  Listen = %s\n", Conf_ListenAddress );
@@ -345,7 +346,7 @@ Set_Defaults( bool InitServers )
        int i;
 
        strcpy( Conf_ServerName, "" );
-       sprintf( Conf_ServerInfo, "%s %s", PACKAGE_NAME, PACKAGE_VERSION );
+       snprintf( Conf_ServerInfo, sizeof Conf_ServerInfo, "%s %s", PACKAGE_NAME, PACKAGE_VERSION );
        strcpy( Conf_ServerPwd, "" );
 
        strcpy( Conf_ServerAdmin1, "" );
@@ -803,38 +804,47 @@ Handle_GLOBAL( int Line, char *Var, char *Arg )
 LOCAL void
 Handle_OPERATOR( int Line, char *Var, char *Arg )
 {
-       unsigned int len;
+       unsigned int opercount;
+       size_t len;
        assert( Line > 0 );
        assert( Var != NULL );
        assert( Arg != NULL );
        assert( Conf_Oper_Count > 0 );
 
-       if( strcasecmp( Var, "Name" ) == 0 )
-       {
+       if ( Conf_Oper_Count == 0 )
+               return;
+
+       opercount = Conf_Oper_Count - 1;
+
+       if( strcasecmp( Var, "Name" ) == 0 ) {
                /* Name of IRC operator */
-               if( strlcpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, sizeof( Conf_Oper[Conf_Oper_Count - 1].name )) >= sizeof( Conf_Oper[Conf_Oper_Count - 1].name )) Config_Error_TooLong( Line, Var );
+               len = strlcpy( Conf_Oper[opercount].name, Arg, sizeof( Conf_Oper[opercount].name ));
+               if (len >= sizeof( Conf_Oper[opercount].name ))
+                               Config_Error_TooLong( Line, Var );
+
                return;
        }
-       if( strcasecmp( Var, "Password" ) == 0 )
-       {
+       if( strcasecmp( Var, "Password" ) == 0 ) {
                /* Password of IRC operator */
-               if( strlcpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, sizeof( Conf_Oper[Conf_Oper_Count - 1].pwd )) >= sizeof( Conf_Oper[Conf_Oper_Count - 1].pwd )) Config_Error_TooLong( Line, Var );
+               len = strlcpy( Conf_Oper[opercount].pwd, Arg, sizeof( Conf_Oper[opercount].pwd ));
+               if (len >= sizeof( Conf_Oper[opercount].pwd ))
+                               Config_Error_TooLong( Line, Var );
                return;
        }
-       if( strcasecmp( Var, "Mask" ) == 0 )
-       {
-               if (Conf_Oper[Conf_Oper_Count - 1].mask) return; /* Hostname already configured */
-               len = strlen( Arg ) + 1;
-               Conf_Oper[Conf_Oper_Count - 1].mask = malloc( len );
-               if (! Conf_Oper[Conf_Oper_Count - 1].mask) {
-                       Config_Error( LOG_ERR, "%s, line %d: Cannot allocate memory for operator mask: %s", NGIRCd_ConfFile, Line, strerror(errno) );
+       if( strcasecmp( Var, "Mask" ) == 0 ) {
+               if (Conf_Oper[opercount].mask) return; /* Hostname already configured */
+
+               Conf_Oper[opercount].mask = strdup( Arg );
+               if (! Conf_Oper[opercount].mask) {
+                       Config_Error( LOG_ERR, "%s, line %d: Cannot allocate memory for operator mask: %s",
+                                                               NGIRCd_ConfFile, Line, strerror(errno) );
                        return;
                }
 
-               strlcpy( Conf_Oper[Conf_Oper_Count - 1].mask, Arg, len);
                return;
        }
-       Config_Error( LOG_ERR, "%s, line %d (section \"Operator\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
+       Config_Error( LOG_ERR, "%s, line %d (section \"Operator\"): Unknown variable \"%s\"!",
+                                                               NGIRCd_ConfFile, Line, Var );
 } /* Handle_OPERATOR */
 
 
@@ -983,16 +993,6 @@ Validate_Config( bool Configtest )
                /* No administrative information configured! */
                Config_Error( LOG_WARNING, "No administrative information configured but required by RFC!" );
        }
-#ifdef FD_SETSIZE      
-       if(( Conf_MaxConnections > (long)FD_SETSIZE ) || ( Conf_MaxConnections < 1 ))
-       {
-               Conf_MaxConnections = (long)FD_SETSIZE;
-               Config_Error( LOG_ERR, "Setting MaxConnections to %ld, select() can't handle more file descriptors!", Conf_MaxConnections );
-       }
-#else
-       Config_Error( LOG_WARN, "Don't know how many file descriptors select() can handle on this system, don't set MaxConnections too high!" );
-#endif
-
 #ifdef DEBUG
        servers = servers_once = 0;
        for( i = 0; i < MAX_SERVERS; i++ )