diff options
| author | Alexander Barton <alex@barton.de> | 2001-12-26 22:48:53 +0000 |
|---|---|---|
| committer | Alexander Barton <alex@barton.de> | 2001-12-26 22:48:53 +0000 |
| commit | 574ae82ca411afb56bb1688ce3c17f254f57522f (patch) | |
| tree | 7eae26e245a7f928f8e87954e58bed5320b03f78 | |
| parent | 08cf560734765afe70140753db1e881be647e540 (diff) | |
| download | ngircd-574ae82ca411afb56bb1688ce3c17f254f57522f.tar.gz ngircd-574ae82ca411afb56bb1688ce3c17f254f57522f.zip | |
- MOTD-Datei ist nun konfigurierbar und wird gelesen.
| -rw-r--r-- | src/ngircd/conf.c | 26 | ||||
| -rw-r--r-- | src/ngircd/conf.h | 16 | ||||
| -rw-r--r-- | src/ngircd/irc.c | 31 | ||||
| -rw-r--r-- | src/ngircd/messages.h | 8 |
4 files changed, 73 insertions, 8 deletions
diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index f7b22a5b..8a2085a7 100644 --- 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 index 5d360ab3..07ed1eda 100644 --- 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 index fb3ed53a..2ede2e69 100644 --- 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 <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 */ diff --git a/src/ngircd/messages.h b/src/ngircd/messages.h index 8aba41b1..93ae6bf3 100644 --- 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" |