]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/conf.c
- nun ueberfluessige Meldung entfernt.
[ngircd-alex.git] / src / ngircd / conf.c
1 /*
2  * ngIRCd -- The Next Generation IRC Daemon
3  * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
4  *
5  * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
6  * der GNU General Public License (GPL), wie von der Free Software Foundation
7  * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
8  * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
9  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
10  * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
11  *
12  * $Id: conf.c,v 1.40 2002/11/25 01:01:59 alex Exp $
13  *
14  * conf.h: Konfiguration des ngircd
15  */
16
17
18 #include "portab.h"
19
20 #include "imp.h"
21 #include <assert.h>
22 #include <errno.h>
23 #include <stdarg.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <unistd.h>
28 #include <pwd.h>
29 #include <grp.h>
30 #include <sys/types.h>
31
32 #include "ngircd.h"
33 #include "conn.h"
34 #include "client.h"
35 #include "defines.h"
36 #include "log.h"
37 #include "resolve.h"
38 #include "tool.h"
39
40 #include "exp.h"
41 #include "conf.h"
42
43
44 LOCAL BOOLEAN Use_Log = TRUE;
45
46
47 LOCAL VOID Set_Defaults PARAMS(( VOID ));
48 LOCAL VOID Read_Config PARAMS(( VOID ));
49 LOCAL VOID Validate_Config PARAMS(( VOID ));
50
51 LOCAL VOID Handle_GLOBAL PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
52 LOCAL VOID Handle_OPERATOR PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
53 LOCAL VOID Handle_SERVER PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
54 LOCAL VOID Handle_CHANNEL PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
55
56 LOCAL VOID Config_Error PARAMS(( CONST INT Level, CONST CHAR *Format, ... ));
57
58
59 GLOBAL VOID
60 Conf_Init( VOID )
61 {
62         Set_Defaults( );
63         Read_Config( );
64         Validate_Config( );
65 } /* Config_Init */
66
67
68 GLOBAL INT
69 Conf_Test( VOID )
70 {
71         /* Konfiguration einlesen, ueberpruefen und ausgeben. */
72
73         struct passwd *pwd;
74         struct group *grp;
75         INT i;
76
77         Use_Log = FALSE;
78         Set_Defaults( );
79
80         Read_Config( );
81
82         /* Wenn stdin ein ein TTY ist: auf Taste warten */
83         if( isatty( fileno( stdout )))
84         {
85                 puts( "OK, press enter to see a dump of your service configuration ..." );
86                 getchar( );
87         }
88         else puts( "Ok, dump of your server configuration follows:\n" );
89
90         puts( "[GLOBAL]" );
91         printf( "  ServerName = %s\n", Conf_ServerName );
92         printf( "  ServerInfo = %s\n", Conf_ServerInfo );
93         printf( "  ServerPwd = %s\n", Conf_ServerPwd );
94         printf( "  AdminInfo1 = %s\n", Conf_ServerAdmin1 );
95         printf( "  AdminInfo2 = %s\n", Conf_ServerAdmin2 );
96         printf( "  AdminEMail = %s\n", Conf_ServerAdminMail );
97         printf( "  MotdFile = %s\n", Conf_MotdFile );
98         printf( "  Ports = " );
99         for( i = 0; i < Conf_ListenPorts_Count; i++ )
100         {
101                 if( i != 0 ) printf( ", " );
102                 printf( "%u", Conf_ListenPorts[i] );
103         }
104         puts( "" );
105         pwd = getpwuid( Conf_UID );
106         if( pwd ) printf( "  ServerUID = %s\n", pwd->pw_name );
107         else printf( "  ServerUID = %ld\n", (LONG)Conf_UID );
108         grp = getgrgid( Conf_GID );
109         if( grp ) printf( "  ServerGID = %s\n", grp->gr_name );
110         else printf( "  ServerGID = %ld\n", (LONG)Conf_GID );
111         printf( "  PingTimeout = %d\n", Conf_PingTimeout );
112         printf( "  PongTimeout = %d\n", Conf_PongTimeout );
113         printf( "  ConnectRetry = %d\n", Conf_ConnectRetry );
114         printf( "  OperCanUseMode = %s\n", Conf_OperCanMode == TRUE ? "yes" : "no" );
115         if( Conf_MaxConnections > 0 ) printf( "  MaxConnections = %ld\n", Conf_MaxConnections );
116         else printf( "  MaxConnections = -1\n" );
117         puts( "" );
118
119         for( i = 0; i < Conf_Oper_Count; i++ )
120         {
121                 if( ! Conf_Oper[i].name[0] ) continue;
122                 
123                 /* gueltiger Operator-Block: ausgeben */
124                 puts( "[OPERATOR]" );
125                 printf( "  Name = %s\n", Conf_Oper[i].name );
126                 printf( "  Password = %s\n", Conf_Oper[i].pwd );
127                 puts( "" );
128         }
129
130         for( i = 0; i < Conf_Server_Count; i++ )
131         {
132                 if( ! Conf_Server[i].name[0] ) continue;
133                 if( ! Conf_Server[i].host[0] ) continue;
134                 
135                 /* gueltiger Server-Block: ausgeben */
136                 puts( "[SERVER]" );
137                 printf( "  Name = %s\n", Conf_Server[i].name );
138                 printf( "  Host = %s\n", Conf_Server[i].host );
139                 printf( "  Port = %d\n", Conf_Server[i].port );
140                 printf( "  MyPassword = %s\n", Conf_Server[i].pwd_in );
141                 printf( "  PeerPassword = %s\n", Conf_Server[i].pwd_out );
142                 printf( "  Group = %d\n", Conf_Server[i].group );
143                 puts( "" );
144         }
145
146         for( i = 0; i < Conf_Channel_Count; i++ )
147         {
148                 if( ! Conf_Channel[i].name[0] ) continue;
149                 
150                 /* gueltiger Channel-Block: ausgeben */
151                 puts( "[CHANNEL]" );
152                 printf( "  Name = %s\n", Conf_Channel[i].name );
153                 printf( "  Modes = %s\n", Conf_Channel[i].modes );
154                 printf( "  Topic = %s\n", Conf_Channel[i].topic );
155                 puts( "" );
156         }
157         
158         return 0;
159 } /* Conf_Test */
160
161
162 LOCAL VOID
163 Set_Defaults( VOID )
164 {
165         /* Konfigurationsvariablen initialisieren, d.h. auf Default-Werte setzen. */
166
167         strcpy( Conf_ServerName, "" );
168         sprintf( Conf_ServerInfo, "%s %s", PACKAGE, VERSION );
169         strcpy( Conf_ServerPwd, "" );
170
171         strcpy( Conf_ServerAdmin1, "" );
172         strcpy( Conf_ServerAdmin2, "" );
173         strcpy( Conf_ServerAdminMail, "" );
174
175         strcpy( Conf_MotdFile, MOTD_FILE );
176
177         Conf_ListenPorts_Count = 0;
178
179         Conf_UID = Conf_GID = 0;
180         
181         Conf_PingTimeout = 120;
182         Conf_PongTimeout = 20;
183
184         Conf_ConnectRetry = 60;
185
186         Conf_Oper_Count = 0;
187         Conf_Server_Count = 0;
188         Conf_Channel_Count = 0;
189
190         Conf_OperCanMode = FALSE;
191         
192         Conf_MaxConnections = 0;
193 } /* Set_Defaults */
194
195
196 LOCAL VOID
197 Read_Config( VOID )
198 {
199         /* Konfigurationsdatei einlesen. */
200
201         CHAR section[LINE_LEN], str[LINE_LEN], *var, *arg, *ptr;
202         INT line;
203         FILE *fd;
204
205         fd = fopen( NGIRCd_ConfFile, "r" );
206         if( ! fd )
207         {
208                 /* Keine Konfigurationsdatei gefunden */
209                 Config_Error( LOG_ALERT, "Can't read configuration \"%s\": %s", NGIRCd_ConfFile, strerror( errno ));
210                 Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
211                 exit( 1 );
212         }
213
214         Config_Error( LOG_INFO, "Reading configuration from \"%s\" ...", NGIRCd_ConfFile );
215
216         line = 0;
217         strcpy( section, "" );
218         while( TRUE )
219         {
220                 if( ! fgets( str, LINE_LEN, fd )) break;
221                 ngt_TrimStr( str );
222                 line++;
223
224                 /* Kommentarzeilen und leere Zeilen ueberspringen */
225                 if( str[0] == ';' || str[0] == '#' || str[0] == '\0' ) continue;
226
227                 /* Anfang eines Abschnittes? */
228                 if(( str[0] == '[' ) && ( str[strlen( str ) - 1] == ']' ))
229                 {
230                         strcpy( section, str );
231                         if( strcasecmp( section, "[GLOBAL]" ) == 0 ) continue;
232                         if( strcasecmp( section, "[OPERATOR]" ) == 0 )
233                         {
234                                 if( Conf_Oper_Count + 1 > MAX_OPERATORS ) Config_Error( LOG_ERR, "Too many operators configured." );
235                                 else
236                                 {
237                                         /* neuen Operator initialisieren */
238                                         strcpy( Conf_Oper[Conf_Oper_Count].name, "" );
239                                         strcpy( Conf_Oper[Conf_Oper_Count].pwd, "" );
240                                         Conf_Oper_Count++;
241                                 }
242                                 continue;
243                         }
244                         if( strcasecmp( section, "[SERVER]" ) == 0 )
245                         {
246                                 if( Conf_Server_Count + 1 > MAX_SERVERS ) Config_Error( LOG_ERR, "Too many servers configured." );
247                                 else
248                                 {
249                                         /* neuen Server ("Peer") initialisieren */
250                                         strcpy( Conf_Server[Conf_Server_Count].host, "" );
251                                         strcpy( Conf_Server[Conf_Server_Count].ip, "" );
252                                         strcpy( Conf_Server[Conf_Server_Count].name, "" );
253                                         strcpy( Conf_Server[Conf_Server_Count].pwd_in, "" );
254                                         strcpy( Conf_Server[Conf_Server_Count].pwd_out, "" );
255                                         Conf_Server[Conf_Server_Count].port = 0;
256                                         Conf_Server[Conf_Server_Count].group = -1;
257                                         Conf_Server[Conf_Server_Count].lasttry = time( NULL ) - Conf_ConnectRetry + STARTUP_DELAY;
258                                         Conf_Server[Conf_Server_Count].res_stat = NULL;
259                                         Conf_Server_Count++;
260                                 }
261                                 continue;
262                         }
263                         if( strcasecmp( section, "[CHANNEL]" ) == 0 )
264                         {
265                                 if( Conf_Channel_Count + 1 > MAX_DEFCHANNELS ) Config_Error( LOG_ERR, "Too many pre-defined channels configured." );
266                                 else
267                                 {
268                                         /* neuen vordefinierten Channel initialisieren */
269                                         strcpy( Conf_Channel[Conf_Channel_Count].name, "" );
270                                         strcpy( Conf_Channel[Conf_Channel_Count].modes, "" );
271                                         strcpy( Conf_Channel[Conf_Channel_Count].topic, "" );
272                                         Conf_Channel_Count++;
273                                 }
274                                 continue;
275                         }
276                         Config_Error( LOG_ERR, "%s, line %d: Unknown section \"%s\"!", NGIRCd_ConfFile, line, section );
277                         section[0] = 0x1;
278                 }
279                 if( section[0] == 0x1 ) continue;
280
281                 /* In Variable und Argument zerlegen */
282                 ptr = strchr( str, '=' );
283                 if( ! ptr )
284                 {
285                         Config_Error( LOG_ERR, "%s, line %d: Syntax error!", NGIRCd_ConfFile, line );
286                         continue;
287                 }
288                 *ptr = '\0';
289                 var = str; ngt_TrimStr( var );
290                 arg = ptr + 1; ngt_TrimStr( arg );
291
292                 if( strcasecmp( section, "[GLOBAL]" ) == 0 ) Handle_GLOBAL( line, var, arg );
293                 else if( strcasecmp( section, "[OPERATOR]" ) == 0 ) Handle_OPERATOR( line, var, arg );
294                 else if( strcasecmp( section, "[SERVER]" ) == 0 ) Handle_SERVER( line, var, arg );
295                 else if( strcasecmp( section, "[CHANNEL]" ) == 0 ) Handle_CHANNEL( line, var, arg );
296                 else Config_Error( LOG_ERR, "%s, line %d: Variable \"%s\" outside section!", NGIRCd_ConfFile, line, var );
297         }
298         
299         fclose( fd );
300         
301         /* Wenn kein Port definiert wurde, Port 6667 als Default benutzen */
302         if( Conf_ListenPorts_Count < 1 )
303         {
304                 Conf_ListenPorts_Count = 1;
305                 Conf_ListenPorts[0] = 6667;
306         }
307 } /* Read_Config */
308
309
310 LOCAL VOID
311 Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
312 {
313         struct passwd *pwd;
314         struct group *grp;
315         CHAR *ptr;
316         LONG port;
317         
318         assert( Line > 0 );
319         assert( Var != NULL );
320         assert( Arg != NULL );
321         
322         if( strcasecmp( Var, "Name" ) == 0 )
323         {
324                 /* Der Server-Name */
325                 strncpy( Conf_ServerName, Arg, CLIENT_ID_LEN - 1 );
326                 Conf_ServerName[CLIENT_ID_LEN - 1] = '\0';
327                 return;
328         }
329         if( strcasecmp( Var, "Info" ) == 0 )
330         {
331                 /* Server-Info-Text */
332                 strncpy( Conf_ServerInfo, Arg, CLIENT_INFO_LEN - 1 );
333                 Conf_ServerInfo[CLIENT_INFO_LEN - 1] = '\0';
334                 return;
335         }
336         if( strcasecmp( Var, "Password" ) == 0 )
337         {
338                 /* Server-Passwort */
339                 strncpy( Conf_ServerPwd, Arg, CLIENT_PASS_LEN - 1 );
340                 Conf_ServerPwd[CLIENT_PASS_LEN - 1] = '\0';
341                 return;
342         }
343         if( strcasecmp( Var, "AdminInfo1" ) == 0 )
344         {
345                 /* Server-Info-Text */
346                 strncpy( Conf_ServerAdmin1, Arg, CLIENT_INFO_LEN - 1 );
347                 Conf_ServerAdmin1[CLIENT_INFO_LEN - 1] = '\0';
348                 return;
349         }
350         if( strcasecmp( Var, "AdminInfo2" ) == 0 )
351         {
352                 /* Server-Info-Text */
353                 strncpy( Conf_ServerAdmin2, Arg, CLIENT_INFO_LEN - 1 );
354                 Conf_ServerAdmin2[CLIENT_INFO_LEN - 1] = '\0';
355                 return;
356         }
357         if( strcasecmp( Var, "AdminEMail" ) == 0 )
358         {
359                 /* Server-Info-Text */
360                 strncpy( Conf_ServerAdminMail, Arg, CLIENT_INFO_LEN - 1 );
361                 Conf_ServerAdminMail[CLIENT_INFO_LEN - 1] = '\0';
362                 return;
363         }
364         if( strcasecmp( Var, "Ports" ) == 0 )
365         {
366                 /* Ports, durch "," getrennt, auf denen der Server
367                 * Verbindungen annehmen soll */
368                 ptr = strtok( Arg, "," );
369                 while( ptr )
370                 {
371                         ngt_TrimStr( ptr );
372                         port = atol( ptr );
373                         if( Conf_ListenPorts_Count + 1 > MAX_LISTEN_PORTS ) Config_Error( LOG_ERR, "Too many listen ports configured. Port %ld ignored.", port );
374                         else
375                         {
376                                 if( port > 0 && port < 0xFFFF ) Conf_ListenPorts[Conf_ListenPorts_Count++] = (UINT)port;
377                                 else Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Illegal port number %ld!", NGIRCd_ConfFile, Line, port );
378                         }
379                         ptr = strtok( NULL, "," );
380                 }
381                 return;
382         }
383         if( strcasecmp( Var, "MotdFile" ) == 0 )
384         {
385                 /* Datei mit der "message of the day" (MOTD) */
386                 strncpy( Conf_MotdFile, Arg, FNAME_LEN - 1 );
387                 Conf_MotdFile[FNAME_LEN - 1] = '\0';
388                 return;
389         }
390         if( strcasecmp( Var, "ServerUID" ) == 0 )
391         {
392                 /* UID, mit der der Daemon laufen soll */
393                 pwd = getpwnam( Arg );
394                 if( pwd ) Conf_UID = pwd->pw_uid;
395                 else Conf_UID = (UINT)atoi( Arg );
396                 return;
397         }
398         if( strcasecmp( Var, "ServerGID" ) == 0 )
399         {
400                 /* GID, mit der der Daemon laufen soll */
401                 grp = getgrnam( Arg );
402                 if( grp ) Conf_GID = grp->gr_gid;
403                 else Conf_GID = (UINT)atoi( Arg );
404                 return;
405         }
406         if( strcasecmp( Var, "PingTimeout" ) == 0 )
407         {
408                 /* PING-Timeout */
409                 Conf_PingTimeout = atoi( Arg );
410                 if(( Conf_PingTimeout ) < 5 ) Conf_PingTimeout = 5;
411                 return;
412         }
413         if( strcasecmp( Var, "PongTimeout" ) == 0 )
414         {
415                 /* PONG-Timeout */
416                 Conf_PongTimeout = atoi( Arg );
417                 if(( Conf_PongTimeout ) < 5 ) Conf_PongTimeout = 5;
418                 return;
419         }
420         if( strcasecmp( Var, "ConnectRetry" ) == 0 )
421         {
422                 /* Sekunden zwischen Verbindungsversuchen zu anderen Servern */
423                 Conf_ConnectRetry = atoi( Arg );
424                 if(( Conf_ConnectRetry ) < 5 ) Conf_ConnectRetry = 5;
425                 return;
426         }
427         if( strcasecmp( Var, "OperCanUseMode" ) == 0 )
428         {
429                 /* Koennen IRC-Operatoren immer MODE benutzen? */
430                 if( strcasecmp( Arg, "yes" ) == 0 ) Conf_OperCanMode = TRUE;
431                 else if( strcasecmp( Arg, "true" ) == 0 ) Conf_OperCanMode = TRUE;
432                 else if( atoi( Arg ) != 0 ) Conf_OperCanMode = TRUE;
433                 else Conf_OperCanMode = FALSE;
434                 return;
435         }
436         if( strcasecmp( Var, "MaxConnections" ) == 0 )
437         {
438                 /* Maximale Anzahl von Verbindungen. Werte <= 0 stehen
439                  * fuer "kein Limit". */
440                 Conf_MaxConnections = atol( Arg );
441                 return;
442         }
443                 
444         Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
445 } /* Handle_GLOBAL */
446
447
448 LOCAL VOID
449 Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg )
450 {
451         assert( Line > 0 );
452         assert( Var != NULL );
453         assert( Arg != NULL );
454         assert( Conf_Oper_Count > 0 );
455
456         if( strcasecmp( Var, "Name" ) == 0 )
457         {
458                 /* Name des IRC Operator */
459                 strncpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, CLIENT_PASS_LEN - 1 );
460                 Conf_Oper[Conf_Oper_Count - 1].name[CLIENT_PASS_LEN - 1] = '\0';
461                 return;
462         }
463         if( strcasecmp( Var, "Password" ) == 0 )
464         {
465                 /* Passwort des IRC Operator */
466                 strncpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, CLIENT_PASS_LEN - 1 );
467                 Conf_Oper[Conf_Oper_Count - 1].pwd[CLIENT_PASS_LEN - 1] = '\0';
468                 return;
469         }
470         
471         Config_Error( LOG_ERR, "%s, line %d (section \"Operator\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
472 } /* Handle_OPERATOR */
473
474
475 LOCAL VOID
476 Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg )
477 {
478         LONG port;
479         
480         assert( Line > 0 );
481         assert( Var != NULL );
482         assert( Arg != NULL );
483
484         if( strcasecmp( Var, "Host" ) == 0 )
485         {
486                 /* Hostname des Servers */
487                 strncpy( Conf_Server[Conf_Server_Count - 1].host, Arg, HOST_LEN - 1 );
488                 Conf_Server[Conf_Server_Count - 1].host[HOST_LEN - 1] = '\0';
489                 return;
490         }
491         if( strcasecmp( Var, "Name" ) == 0 )
492         {
493                 /* Name des Servers ("Nick") */
494                 strncpy( Conf_Server[Conf_Server_Count - 1].name, Arg, CLIENT_ID_LEN - 1 );
495                 Conf_Server[Conf_Server_Count - 1].name[CLIENT_ID_LEN - 1] = '\0';
496                 return;
497         }
498         if( strcasecmp( Var, "MyPassword" ) == 0 )
499         {
500                 /* Passwort dieses Servers, welches empfangen werden muss */
501                 strncpy( Conf_Server[Conf_Server_Count - 1].pwd_in, Arg, CLIENT_PASS_LEN - 1 );
502                 Conf_Server[Conf_Server_Count - 1].pwd_in[CLIENT_PASS_LEN - 1] = '\0';
503                 return;
504         }
505         if( strcasecmp( Var, "PeerPassword" ) == 0 )
506         {
507                 /* Passwort des anderen Servers, welches gesendet werden muss */
508                 strncpy( Conf_Server[Conf_Server_Count - 1].pwd_out, Arg, CLIENT_PASS_LEN - 1 );
509                 Conf_Server[Conf_Server_Count - 1].pwd_out[CLIENT_PASS_LEN - 1] = '\0';
510                 return;
511         }
512         if( strcasecmp( Var, "Port" ) == 0 )
513         {
514                 /* Port, zu dem Verbunden werden soll */
515                 port = atol( Arg );
516                 if( port > 0 && port < 0xFFFF ) Conf_Server[Conf_Server_Count - 1].port = (INT)port;
517                 else Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Illegal port number %ld!", NGIRCd_ConfFile, Line, port );
518                 return;
519         }
520         if( strcasecmp( Var, "Group" ) == 0 )
521         {
522                 /* Server-Gruppe */
523                 Conf_Server[Conf_Server_Count - 1].group = atoi( Arg );
524                 return;
525         }
526         
527         Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
528 } /* Handle_SERVER */
529
530
531 LOCAL VOID
532 Handle_CHANNEL( INT Line, CHAR *Var, CHAR *Arg )
533 {
534         assert( Line > 0 );
535         assert( Var != NULL );
536         assert( Arg != NULL );
537
538         if( strcasecmp( Var, "Name" ) == 0 )
539         {
540                 /* Hostname des Servers */
541                 strncpy( Conf_Channel[Conf_Channel_Count - 1].name, Arg, CHANNEL_NAME_LEN - 1 );
542                 Conf_Channel[Conf_Channel_Count - 1].name[CHANNEL_NAME_LEN - 1] = '\0';
543                 return;
544         }
545         if( strcasecmp( Var, "Modes" ) == 0 )
546         {
547                 /* Name des Servers ("Nick") */
548                 strncpy( Conf_Channel[Conf_Channel_Count - 1].modes, Arg, CHANNEL_MODE_LEN - 1 );
549                 Conf_Channel[Conf_Channel_Count - 1].modes[CHANNEL_MODE_LEN - 1] = '\0';
550                 return;
551         }
552         if( strcasecmp( Var, "Topic" ) == 0 )
553         {
554                 /* Passwort des Servers */
555                 strncpy( Conf_Channel[Conf_Channel_Count - 1].topic, Arg, CHANNEL_TOPIC_LEN - 1 );
556                 Conf_Channel[Conf_Channel_Count - 1].topic[CHANNEL_TOPIC_LEN - 1] = '\0';
557                 return;
558         }
559
560         Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
561 } /* Handle_CHANNEL */
562
563
564 LOCAL VOID
565 Validate_Config( VOID )
566 {
567         /* Konfiguration ueberpruefen */
568         
569         if( ! Conf_ServerName[0] )
570         {
571                 /* Kein Servername konfiguriert */
572                 Config_Error( LOG_ALERT, "No server name configured in \"%s\" ('ServerName')!", NGIRCd_ConfFile );
573                 Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
574                 exit( 1 );
575         }
576
577 #ifdef STRICT_RFC
578         if( ! Conf_ServerAdminMail[0] )
579         {
580                 /* Keine Server-Information konfiguriert */
581                 Config_Error( LOG_ALERT, "No administrator email address configured in \"%s\" ('AdminEMail')!", NGIRCd_ConfFile );
582                 Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
583                 exit( 1 );
584         }
585 #endif
586
587         if( ! Conf_ServerAdmin1[0] && ! Conf_ServerAdmin2[0] && ! Conf_ServerAdminMail[0] )
588         {
589                 /* Keine Server-Information konfiguriert */
590                 Log( LOG_WARNING, "No administrative information configured but required by RFC!" );
591         }
592 } /* Validate_Config */
593
594
595 #ifdef PROTOTYPES
596 LOCAL VOID Config_Error( CONST INT Level, CONST CHAR *Format, ... )
597 #else
598 LOCAL VOID Config_Error( Level, Format, va_alist )
599 CONST INT Level;
600 CONST CHAR *Format;
601 va_dcl
602 #endif
603 {
604         /* Fehler! Auf Console und/oder ins Log schreiben */
605
606         CHAR msg[MAX_LOG_MSG_LEN];
607         va_list ap;
608
609         assert( Format != NULL );
610
611         /* String mit variablen Argumenten zusammenbauen ... */
612 #ifdef PROTOTYPES
613         va_start( ap, Format );
614 #else
615         va_start( ap );
616 #endif
617         vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap );
618         va_end( ap );
619
620         /* Im "normalen Betrieb" soll der Log-Mechanismus des ngIRCd verwendet
621          * werden, beim Testen der Konfiguration jedoch nicht, hier sollen alle
622          * Meldungen direkt auf die Konsole ausgegeben werden: */
623         if( Use_Log ) Log( Level, "%s", msg );
624         else puts( msg );
625 } /* Config_Error */
626
627
628 /* -eof- */