repo: ngircd action: commit revision: path_from: revision_from: 574ae82ca411afb56bb1688ce3c17f254f57522f: path_to: revision_to:
commit 574ae82ca411afb56bb1688ce3c17f254f57522f Author: Alexander BartonDate: Wed Dec 26 22:48:53 2001 +0000 - MOTD-Datei ist nun konfigurierbar und wird gelesen. diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -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".
*
@@ -35,10 +38,23 @@
#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- */
diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h
--- a/src/ngircd/conf.h +++ b/src/ngircd/conf.h @@ -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". * @@ -29,8 +32,15 @@ #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 ); diff --git a/src/ngircd/irc.c b/src/ngircd/irc.c
--- a/src/ngircd/irc.c +++ b/src/ngircd/irc.c @@ -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". * @@ -52,11 +55,13 @@ #include#include +#include #include #include #include #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 */ diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h
--- a/src/ngircd/messages.h +++ b/src/ngircd/messages.h @@ -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"
-----END OF PAGE-----