]> arthur.barton.de Git - ngircd-alex.git/commitdiff
- MOTD-Datei ist nun konfigurierbar und wird gelesen.
authorAlexander Barton <alex@barton.de>
Wed, 26 Dec 2001 22:48:53 +0000 (22:48 +0000)
committerAlexander Barton <alex@barton.de>
Wed, 26 Dec 2001 22:48:53 +0000 (22:48 +0000)
src/ngircd/conf.c
src/ngircd/conf.h
src/ngircd/irc.c
src/ngircd/messages.h

index f7b22a5b9adc1504098a1db318f58d3d3c783487..8a2085a75f85831f3073e08dd05d0e0e2d43d880 100644 (file)
@@ -9,11 +9,14 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an comBase beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: conf.c,v 1.3 2001/12/26 14:45:37 alex Exp $
+ * $Id: conf.c,v 1.4 2001/12/26 22:48:53 alex Exp $
  *
  * conf.h: Konfiguration des ngircd
  *
  * $Log: conf.c,v $
+ * Revision 1.4  2001/12/26 22:48:53  alex
+ * - MOTD-Datei ist nun konfigurierbar und wird gelesen.
+ *
  * Revision 1.3  2001/12/26 14:45:37  alex
  * - "Code Cleanups".
  *
 #include "conf.h"
 
 
+LOCAL VOID Read_Config( VOID );
+
+
 GLOBAL VOID Conf_Init( VOID )
 {
+       /* Konfigurationsvariablen initialisieren: zunaechst Default-
+        * Werte setzen, dann Konfigurationsdtaei einlesen. */
+       
+       strcpy( Conf_File, "/usr/local/etc/ngircd.conf" );
+       
        Conf_PingTimeout = 120;
        Conf_PongTimeout = 10;
+
+       strcpy( Conf_MotdFile, "/usr/local/etc/ngircd.motd" );
+
+       /* Konfigurationsdatei einlesen */
+       Read_Config( );
 } /* Config_Init */
 
 
@@ -48,4 +64,12 @@ GLOBAL VOID Conf_Exit( VOID )
 } /* Config_Exit */
 
 
+LOCAL VOID Read_Config( VOID )
+{
+       /* Konfigurationsdatei einlesen. */
+       
+       /* ... */
+} /* Read_Config */
+
+
 /* -eof- */
index 5d360ab3c8dd1f0a00a05ae9b5ed18e38ee791d4..07ed1eda5f229889493610ed13dea9bf7e1f0f96 100644 (file)
@@ -9,11 +9,14 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an comBase beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: conf.h,v 1.3 2001/12/26 14:45:37 alex Exp $
+ * $Id: conf.h,v 1.4 2001/12/26 22:48:53 alex Exp $
  *
  * conf.h: Konfiguration des ngircd (Header)
  *
  * $Log: conf.h,v $
+ * Revision 1.4  2001/12/26 22:48:53  alex
+ * - MOTD-Datei ist nun konfigurierbar und wird gelesen.
+ *
  * Revision 1.3  2001/12/26 14:45:37  alex
  * - "Code Cleanups".
  *
 #define __conf_h__
 
 
-GLOBAL INT Conf_PingTimeout;
-GLOBAL INT Conf_PongTimeout;
+#define FNAME_LEN 256
+
+
+GLOBAL CHAR Conf_File[FNAME_LEN];      /* Konfigurationsdatei */
+
+GLOBAL INT Conf_PingTimeout;           /* Ping Timeout */
+GLOBAL INT Conf_PongTimeout;           /* Pong Timeout */
+
+GLOBAL CHAR Conf_MotdFile[FNAME_LEN];  /* Datei mit MOTD-Text */
 
 
 GLOBAL VOID Conf_Init( VOID );
index fb3ed53a35e1fa38312209ea1a7cf3487190914f..2ede2e69d86726b2186eb4982c8bf2eb64e3992f 100644 (file)
@@ -9,11 +9,14 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an comBase beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: irc.c,v 1.9 2001/12/26 14:45:37 alex Exp $
+ * $Id: irc.c,v 1.10 2001/12/26 22:48:53 alex Exp $
  *
  * irc.c: IRC-Befehle
  *
  * $Log: irc.c,v $
+ * Revision 1.10  2001/12/26 22:48:53  alex
+ * - MOTD-Datei ist nun konfigurierbar und wird gelesen.
+ *
  * Revision 1.9  2001/12/26 14:45:37  alex
  * - "Code Cleanups".
  *
 
 #include <imp.h>
 #include <assert.h>
+#include <errno.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
 
 #include "client.h"
+#include "conf.h"
 #include "log.h"
 #include "messages.h"
 #include "parse.h"
@@ -279,12 +284,32 @@ LOCAL BOOLEAN Hello_User( CLIENT *Client )
 
 LOCAL BOOLEAN Show_MOTD( CLIENT *Client )
 {
+       BOOLEAN ok;
+       CHAR line[127];
+       FILE *fd;
+       
        assert( Client != NULL );
        assert( Client->nick[0] );
+
+       fd = fopen( Conf_MotdFile, "r" );
+       if( ! fd )
+       {
+               Log( LOG_WARNING, "Can't read MOTD file \"%s\": %s", Conf_MotdFile, strerror( errno ));
+               return IRC_WriteStrClient( Client, This_Server, ERR_NOMOTD_MSG, Client->nick );
+       }
        
        IRC_WriteStrClient( Client, This_Server, RPL_MOTDSTART_MSG, Client->nick, This_Server->host );
-       IRC_WriteStrClient( Client, This_Server, RPL_MOTD_MSG, Client->nick, "Some cool IRC server welcome message ;-)" );
-       return IRC_WriteStrClient( Client, This_Server, RPL_ENDOFMOTD_MSG, Client->nick );
+       while( TRUE )
+       {
+               if( ! fgets( line, 126, fd )) break;
+               if( line[strlen( line ) - 1] == '\n' ) line[strlen( line ) - 1] = '\0';
+               IRC_WriteStrClient( Client, This_Server, RPL_MOTD_MSG, Client->nick, line );
+       }
+       ok = IRC_WriteStrClient( Client, This_Server, RPL_ENDOFMOTD_MSG, Client->nick );
+
+       fclose( fd );
+       
+       return ok;
 } /* Show_MOTD */
 
 
index 8aba41b1481d3f4d0385f52dc11565451dff2cff..93ae6bf3f7638a1704249d1544974da7b1cd1828 100644 (file)
@@ -9,11 +9,14 @@
  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
  * der an comBase beteiligten Autoren finden Sie in der Datei AUTHORS.
  *
- * $Id: messages.h,v 1.5 2001/12/26 03:51:13 alex Exp $
+ * $Id: messages.h,v 1.6 2001/12/26 22:48:53 alex Exp $
  *
  * irc.h: IRC-Befehle (Header)
  *
  * $Log: messages.h,v $
+ * Revision 1.6  2001/12/26 22:48:53  alex
+ * - MOTD-Datei ist nun konfigurierbar und wird gelesen.
+ *
  * Revision 1.5  2001/12/26 03:51:13  alex
  * - in ERR_NOTREGISTERED_MSG fehlte ein "%s" - jetzt steht auch hier der Nick.
  *
@@ -66,6 +69,9 @@
 #define ERR_UNKNOWNCOMMAND             "421"
 #define ERR_UNKNOWNCOMMAND_MSG         ERR_UNKNOWNCOMMAND" %s %s :Unknown command"
 
+#define ERR_NOMOTD                     "422"
+#define ERR_NOMOTD_MSG                 ERR_NOMOTD" %s :MOTD file is missing"
+
 #define ERR_ERRONEUSNICKNAME           "432"
 #define ERR_ERRONEUSNICKNAME_MSG       ERR_ERRONEUSNICKNAME" %s %s :Erroneous nickname"