]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/ngircd.c
Implement IRC commands SERVICE, SERVLIST, and SQUERY as dummy functions
[ngircd-alex.git] / src / ngircd / ngircd.c
index 57d1f76fdfcb6cfad9ffdc0a595c7290b9ec93c9..626b8b235245b21f43bf17749cb22d2b9182e5d1 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2005 by Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2008 Alexander Barton (alex@barton.de).
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -12,8 +12,6 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: ngircd.c,v 1.111 2005/11/21 16:31:30 alex Exp $";
-
 /**
  * @file
  * The main program, including the C function main() which is called
@@ -42,7 +40,6 @@ static char UNUSED id[] = "$Id: ngircd.c,v 1.111 2005/11/21 16:31:30 alex Exp $"
 #include "client.h"
 #include "channel.h"
 #include "conf.h"
-#include "cvs-version.h"
 #include "lists.h"
 #include "log.h"
 #include "parse.h"
@@ -62,7 +59,7 @@ static void Signal_Handler PARAMS(( int Signal ));
 static void Show_Version PARAMS(( void ));
 static void Show_Help PARAMS(( void ));
 
-static void Pidfile_Create PARAMS(( long ));
+static void Pidfile_Create PARAMS(( pid_t pid ));
 static void Pidfile_Delete PARAMS(( void ));
 
 static void Fill_Version PARAMS(( void ));
@@ -271,7 +268,6 @@ main( int argc, const char *argv[] )
 
                /* Initialize modules, part II: these functions are eventually
                 * called with already dropped privileges ... */
-               Lists_Init( );
                Channel_Init( );
                Client_Init( );
 #ifdef ZEROCONF
@@ -328,7 +324,6 @@ main( int argc, const char *argv[] )
 #endif
                Client_Exit( );
                Channel_Exit( );
-               Lists_Exit( );
                Log_Exit( );
        }
        Pidfile_Delete( );
@@ -399,7 +394,12 @@ Fill_Version( void )
 
        strlcat( NGIRCd_VersionAddition, "IRCPLUS", sizeof NGIRCd_VersionAddition );
 #endif
+#ifdef WANT_IPV6
+       if (NGIRCd_VersionAddition[0])
+               strlcat(NGIRCd_VersionAddition, "+", sizeof(NGIRCd_VersionAddition));
 
+       strlcat(NGIRCd_VersionAddition, "IPv6", sizeof(NGIRCd_VersionAddition));
+#endif
        if( NGIRCd_VersionAddition[0] )
                strlcat( NGIRCd_VersionAddition, "-", sizeof( NGIRCd_VersionAddition ));
 
@@ -409,12 +409,9 @@ Fill_Version( void )
        strlcat( NGIRCd_VersionAddition, "/", sizeof( NGIRCd_VersionAddition ));
        strlcat( NGIRCd_VersionAddition, TARGET_OS, sizeof( NGIRCd_VersionAddition ));
 
-#ifdef CVSDATE
-       snprintf( NGIRCd_Version, sizeof NGIRCd_Version,"%s %s(%s)-%s", PACKAGE_NAME, PACKAGE_VERSION, CVSDATE, NGIRCd_VersionAddition);
-#else
-       snprintf( NGIRCd_Version, sizeof NGIRCd_Version, "%s %s-%s", PACKAGE_NAME, PACKAGE_VERSION, NGIRCd_VersionAddition);
-#endif
-} /* Fill_Version */
+       snprintf(NGIRCd_Version, sizeof NGIRCd_Version, "%s %s-%s",
+                PACKAGE_NAME, PACKAGE_VERSION, NGIRCd_VersionAddition);
+       } /* Fill_Version */
 
 
 /**
@@ -424,24 +421,31 @@ GLOBAL void
 NGIRCd_Rehash( void )
 {
        char old_name[CLIENT_ID_LEN];
+       unsigned old_nicklen;
 
        Log( LOG_NOTICE|LOG_snotice, "Re-reading configuration NOW!" );
        NGIRCd_SignalRehash = false;
 
-       /* Close down all listening sockets */
-       Conn_ExitListeners( );
-
-       /* Remember old server name */
+       /* Remember old server name and nick name length */
        strlcpy( old_name, Conf_ServerName, sizeof old_name );
+       old_nicklen = Conf_MaxNickLength;
 
        /* Re-read configuration ... */
-       Conf_Rehash( );
+       if (!Conf_Rehash( ))
+               return;
 
-       /* Recover old server name: it can't be changed during run-time */
-       if( strcmp( old_name, Conf_ServerName ) != 0 )
-       {
-               strlcpy( Conf_ServerName, old_name, sizeof Conf_ServerName );
-               Log( LOG_ERR, "Can't change \"ServerName\" on runtime! Ignored new name." );
+       /* Close down all listening sockets */
+       Conn_ExitListeners( );
+
+       /* Recover old server name and nick name length: these values can't
+        * be changed during run-time */
+       if (strcmp(old_name, Conf_ServerName) != 0 ) {
+               strlcpy(Conf_ServerName, old_name, sizeof Conf_ServerName);
+               Log(LOG_ERR, "Can't change \"ServerName\" on runtime! Ignored new name.");
+       }
+       if (old_nicklen != Conf_MaxNickLength) {
+               Conf_MaxNickLength = old_nicklen;
+               Log(LOG_ERR, "Can't change \"MaxNickLength\" on runtime! Ignored new value.");
        }
 
        /* Create new pre-defined channels */
@@ -548,7 +552,7 @@ static void
 Show_Version( void )
 {
        puts( NGIRCd_Version );
-       puts( "Copyright (c)2001-2005 Alexander Barton (<alex@barton.de>) and Contributors." );
+       puts( "Copyright (c)2001-2008 Alexander Barton (<alex@barton.de>) and Contributors." );
        puts( "Homepage: <http://ngircd.barton.de/>\n" );
        puts( "This is free software; see the source for copying conditions. There is NO" );
        puts( "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." );
@@ -601,7 +605,7 @@ Pidfile_Delete( void )
  * @param pid The process ID to be stored in this file.
  */
 static void
-Pidfile_Create( long pid )
+Pidfile_Create(pid_t pid)
 {
        int pidfd;
        char pidbuf[64];
@@ -620,13 +624,13 @@ Pidfile_Create( long pid )
                return;
        }
 
-       len = snprintf( pidbuf, sizeof pidbuf, "%ld\n", pid );
-       if (len < 0|| len < (int)sizeof pid) {
+       len = snprintf(pidbuf, sizeof pidbuf, "%ld\n", (long)pid);
+       if (len < 0 || len >= (int)sizeof pidbuf) {
                Log( LOG_ERR, "Error converting pid");
                return;
        }
        
-       if( write( pidfd, pidbuf, len) != len)
+       if (write(pidfd, pidbuf, (size_t)len) != (ssize_t)len)
                Log( LOG_ERR, "Can't write PID file (%s): %s", Conf_PidFile, strerror( errno ));
 
        if( close(pidfd) != 0 )
@@ -663,7 +667,7 @@ Setup_FDStreams( void )
 
 
 static bool
-NGIRCd_getNobodyID(unsigned int *uid, unsigned int *gid )
+NGIRCd_getNobodyID(uid_t *uid, gid_t *gid )
 {
        struct passwd *pwd;
 
@@ -689,7 +693,7 @@ NGIRCd_Init( bool NGIRCd_NoDaemon )
        struct passwd *pwd;
        struct group *grp;
        int real_errno;
-       long pid;
+       pid_t pid;
 
        if (initialized)
                return true;
@@ -749,7 +753,7 @@ NGIRCd_Init( bool NGIRCd_NoDaemon )
         * connected to ther controlling terminal. Use "--nodaemon"
         * to disable this "daemon mode" (useful for debugging). */
        if ( ! NGIRCd_NoDaemon ) {
-               pid = (long)fork( );
+               pid = fork( );
                if( pid > 0 ) {
                        /* "Old" process: exit. */
                        exit( 0 );
@@ -799,7 +803,7 @@ NGIRCd_Init( bool NGIRCd_NoDaemon )
                        if( chdir( pwd->pw_dir ) == 0 ) 
                                Log( LOG_DEBUG, "Changed working directory to \"%s\" ...", pwd->pw_dir );
                        else 
-                               Log( LOG_ERR, "Can't change working directory to \"%s\": %s",
+                               Log( LOG_INFO, "Notice: Can't change working directory to \"%s\": %s",
                                                                pwd->pw_dir, strerror( errno ));
                }
        } else {