]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/conf.c
- in ServerUID und ServerGID kann nun jeweils auch der Name (und nicht nur
[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.36 2002/11/08 23:09:26 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         printf( "Using \"%s\" as configuration file ...\n", NGIRCd_ConfFile );
81         Read_Config( );
82
83         /* Wenn stdin ein ein TTY ist: auf Taste warten */
84         if( isatty( fileno( stdout )))
85         {
86                 puts( "OK, press enter to see a dump of your service configuration ..." );
87                 getchar( );
88         }
89         else puts( "Ok, dump of your server configuration follows:\n" );
90
91         puts( "[GLOBAL]" );
92         printf( "  ServerName = %s\n", Conf_ServerName );
93         printf( "  ServerInfo = %s\n", Conf_ServerInfo );
94         printf( "  ServerPwd = %s\n", Conf_ServerPwd );
95         printf( "  AdminInfo1 = %s\n", Conf_ServerAdmin1 );
96         printf( "  AdminInfo2 = %s\n", Conf_ServerAdmin2 );
97         printf( "  AdminEMail = %s\n", Conf_ServerAdminMail );
98         printf( "  MotdFile = %s\n", Conf_MotdFile );
99         printf( "  ListenPorts = " );
100         for( i = 0; i < Conf_ListenPorts_Count; i++ )
101         {
102                 if( i != 0 ) printf( ", " );
103                 printf( "%u", Conf_ListenPorts[i] );
104         }
105         puts( "" );
106         pwd = getpwuid( Conf_UID );
107         if( pwd ) printf( "  ServerUID = %s\n", pwd->pw_name );
108         else printf( "  ServerUID = %ld\n", (LONG)Conf_UID );
109         grp = getgrgid( Conf_GID );
110         if( grp ) printf( "  ServerGID = %s\n", grp->gr_name );
111         else printf( "  ServerGID = %ld\n", (LONG)Conf_GID );
112         printf( "  PingTimeout = %d\n", Conf_PingTimeout );
113         printf( "  PongTimeout = %d\n", Conf_PongTimeout );
114         printf( "  ConnectRetry = %d\n", Conf_ConnectRetry );
115         printf( "  OperCanUseMode = %s\n", Conf_OperCanMode == TRUE ? "yes" : "no" );
116         if( Conf_MaxConnections > 0 ) printf( "  MaxConnections = %ld\n", Conf_MaxConnections );
117         else printf( "  MaxConnections = -1\n" );
118         puts( "" );
119
120         for( i = 0; i < Conf_Oper_Count; i++ )
121         {
122                 if( ! Conf_Oper[i].name[0] ) continue;
123                 
124                 /* gueltiger Operator-Block: ausgeben */
125                 puts( "[OPERATOR]" );
126                 printf( "  Name = %s\n", Conf_Oper[i].name );
127                 printf( "  Password = %s\n", Conf_Oper[i].pwd );
128                 puts( "" );
129         }
130
131         for( i = 0; i < Conf_Server_Count; i++ )
132         {
133                 if( ! Conf_Server[i].name[0] ) continue;
134                 if( ! Conf_Server[i].host[0] ) continue;
135                 
136                 /* gueltiger Server-Block: ausgeben */
137                 puts( "[SERVER]" );
138                 printf( "  Name = %s\n", Conf_Server[i].name );
139                 printf( "  Host = %s\n", Conf_Server[i].host );
140                 printf( "  Port = %d\n", Conf_Server[i].port );
141                 printf( "  Password = %s\n", Conf_Server[i].pwd );
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         line = 0;
215         strcpy( section, "" );
216         while( TRUE )
217         {
218                 if( ! fgets( str, LINE_LEN, fd )) break;
219                 ngt_TrimStr( str );
220                 line++;
221
222                 /* Kommentarzeilen und leere Zeilen ueberspringen */
223                 if( str[0] == ';' || str[0] == '#' || str[0] == '\0' ) continue;
224
225                 /* Anfang eines Abschnittes? */
226                 if(( str[0] == '[' ) && ( str[strlen( str ) - 1] == ']' ))
227                 {
228                         strcpy( section, str );
229                         if( strcasecmp( section, "[GLOBAL]" ) == 0 ) continue;
230                         if( strcasecmp( section, "[OPERATOR]" ) == 0 )
231                         {
232                                 if( Conf_Oper_Count + 1 > MAX_OPERATORS ) Config_Error( LOG_ERR, "Too many operators configured." );
233                                 else
234                                 {
235                                         /* neuen Operator initialisieren */
236                                         strcpy( Conf_Oper[Conf_Oper_Count].name, "" );
237                                         strcpy( Conf_Oper[Conf_Oper_Count].pwd, "" );
238                                         Conf_Oper_Count++;
239                                 }
240                                 continue;
241                         }
242                         if( strcasecmp( section, "[SERVER]" ) == 0 )
243                         {
244                                 if( Conf_Server_Count + 1 > MAX_SERVERS ) Config_Error( LOG_ERR, "Too many servers configured." );
245                                 else
246                                 {
247                                         /* neuen Server ("Peer") initialisieren */
248                                         strcpy( Conf_Server[Conf_Server_Count].host, "" );
249                                         strcpy( Conf_Server[Conf_Server_Count].ip, "" );
250                                         strcpy( Conf_Server[Conf_Server_Count].name, "" );
251                                         strcpy( Conf_Server[Conf_Server_Count].pwd, "" );
252                                         Conf_Server[Conf_Server_Count].port = 0;
253                                         Conf_Server[Conf_Server_Count].group = -1;
254                                         Conf_Server[Conf_Server_Count].lasttry = time( NULL ) - Conf_ConnectRetry + STARTUP_DELAY;
255                                         Conf_Server[Conf_Server_Count].res_stat = NULL;
256                                         Conf_Server_Count++;
257                                 }
258                                 continue;
259                         }
260                         if( strcasecmp( section, "[CHANNEL]" ) == 0 )
261                         {
262                                 if( Conf_Channel_Count + 1 > MAX_DEFCHANNELS ) Config_Error( LOG_ERR, "Too many pre-defined channels configured." );
263                                 else
264                                 {
265                                         /* neuen vordefinierten Channel initialisieren */
266                                         strcpy( Conf_Channel[Conf_Channel_Count].name, "" );
267                                         strcpy( Conf_Channel[Conf_Channel_Count].modes, "" );
268                                         strcpy( Conf_Channel[Conf_Channel_Count].topic, "" );
269                                         Conf_Channel_Count++;
270                                 }
271                                 continue;
272                         }
273                         Config_Error( LOG_ERR, "%s, line %d: Unknown section \"%s\"!", NGIRCd_ConfFile, line, section );
274                         section[0] = 0x1;
275                 }
276                 if( section[0] == 0x1 ) continue;
277
278                 /* In Variable und Argument zerlegen */
279                 ptr = strchr( str, '=' );
280                 if( ! ptr )
281                 {
282                         Config_Error( LOG_ERR, "%s, line %d: Syntax error!", NGIRCd_ConfFile, line );
283                         continue;
284                 }
285                 *ptr = '\0';
286                 var = str; ngt_TrimStr( var );
287                 arg = ptr + 1; ngt_TrimStr( arg );
288
289                 if( strcasecmp( section, "[GLOBAL]" ) == 0 ) Handle_GLOBAL( line, var, arg );
290                 else if( strcasecmp( section, "[OPERATOR]" ) == 0 ) Handle_OPERATOR( line, var, arg );
291                 else if( strcasecmp( section, "[SERVER]" ) == 0 ) Handle_SERVER( line, var, arg );
292                 else if( strcasecmp( section, "[CHANNEL]" ) == 0 ) Handle_CHANNEL( line, var, arg );
293                 else Config_Error( LOG_ERR, "%s, line %d: Variable \"%s\" outside section!", NGIRCd_ConfFile, line, var );
294         }
295         
296         fclose( fd );
297         
298         /* Wenn kein Port definiert wurde, Port 6667 als Default benutzen */
299         if( Conf_ListenPorts_Count < 1 )
300         {
301                 Conf_ListenPorts_Count = 1;
302                 Conf_ListenPorts[0] = 6667;
303         }
304 } /* Read_Config */
305
306
307 LOCAL VOID
308 Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
309 {
310         struct passwd *pwd;
311         struct group *grp;
312         CHAR *ptr;
313         LONG port;
314         
315         assert( Line > 0 );
316         assert( Var != NULL );
317         assert( Arg != NULL );
318         
319         if( strcasecmp( Var, "Name" ) == 0 )
320         {
321                 /* Der Server-Name */
322                 strncpy( Conf_ServerName, Arg, CLIENT_ID_LEN - 1 );
323                 Conf_ServerName[CLIENT_ID_LEN - 1] = '\0';
324                 return;
325         }
326         if( strcasecmp( Var, "Info" ) == 0 )
327         {
328                 /* Server-Info-Text */
329                 strncpy( Conf_ServerInfo, Arg, CLIENT_INFO_LEN - 1 );
330                 Conf_ServerInfo[CLIENT_INFO_LEN - 1] = '\0';
331                 return;
332         }
333         if( strcasecmp( Var, "Password" ) == 0 )
334         {
335                 /* Server-Passwort */
336                 strncpy( Conf_ServerPwd, Arg, CLIENT_PASS_LEN - 1 );
337                 Conf_ServerPwd[CLIENT_PASS_LEN - 1] = '\0';
338                 return;
339         }
340         if( strcasecmp( Var, "AdminInfo1" ) == 0 )
341         {
342                 /* Server-Info-Text */
343                 strncpy( Conf_ServerAdmin1, Arg, CLIENT_INFO_LEN - 1 );
344                 Conf_ServerAdmin1[CLIENT_INFO_LEN - 1] = '\0';
345                 return;
346         }
347         if( strcasecmp( Var, "AdminInfo2" ) == 0 )
348         {
349                 /* Server-Info-Text */
350                 strncpy( Conf_ServerAdmin2, Arg, CLIENT_INFO_LEN - 1 );
351                 Conf_ServerAdmin2[CLIENT_INFO_LEN - 1] = '\0';
352                 return;
353         }
354         if( strcasecmp( Var, "AdminEMail" ) == 0 )
355         {
356                 /* Server-Info-Text */
357                 strncpy( Conf_ServerAdminMail, Arg, CLIENT_INFO_LEN - 1 );
358                 Conf_ServerAdminMail[CLIENT_INFO_LEN - 1] = '\0';
359                 return;
360         }
361         if( strcasecmp( Var, "Ports" ) == 0 )
362         {
363                 /* Ports, durch "," getrennt, auf denen der Server
364                 * Verbindungen annehmen soll */
365                 ptr = strtok( Arg, "," );
366                 while( ptr )
367                 {
368                         ngt_TrimStr( ptr );
369                         port = atol( ptr );
370                         if( Conf_ListenPorts_Count + 1 > MAX_LISTEN_PORTS ) Config_Error( LOG_ERR, "Too many listen ports configured. Port %ld ignored.", port );
371                         else
372                         {
373                                 if( port > 0 && port < 0xFFFF ) Conf_ListenPorts[Conf_ListenPorts_Count++] = (UINT)port;
374                                 else Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Illegal port number %ld!", NGIRCd_ConfFile, Line, port );
375                         }
376                         ptr = strtok( NULL, "," );
377                 }
378                 return;
379         }
380         if( strcasecmp( Var, "MotdFile" ) == 0 )
381         {
382                 /* Datei mit der "message of the day" (MOTD) */
383                 strncpy( Conf_MotdFile, Arg, FNAME_LEN - 1 );
384                 Conf_MotdFile[FNAME_LEN - 1] = '\0';
385                 return;
386         }
387         if( strcasecmp( Var, "ServerUID" ) == 0 )
388         {
389                 /* UID, mit der der Daemon laufen soll */
390                 pwd = getpwnam( Arg );
391                 if( pwd ) Conf_UID = pwd->pw_uid;
392                 else Conf_UID = (UINT)atoi( Arg );
393                 return;
394         }
395         if( strcasecmp( Var, "ServerGID" ) == 0 )
396         {
397                 /* GID, mit der der Daemon laufen soll */
398                 grp = getgrnam( Arg );
399                 if( grp ) Conf_GID = grp->gr_gid;
400                 else Conf_GID = (UINT)atoi( Arg );
401                 return;
402         }
403         if( strcasecmp( Var, "PingTimeout" ) == 0 )
404         {
405                 /* PING-Timeout */
406                 Conf_PingTimeout = atoi( Arg );
407                 if(( Conf_PingTimeout ) < 5 ) Conf_PingTimeout = 5;
408                 return;
409         }
410         if( strcasecmp( Var, "PongTimeout" ) == 0 )
411         {
412                 /* PONG-Timeout */
413                 Conf_PongTimeout = atoi( Arg );
414                 if(( Conf_PongTimeout ) < 5 ) Conf_PongTimeout = 5;
415                 return;
416         }
417         if( strcasecmp( Var, "ConnectRetry" ) == 0 )
418         {
419                 /* Sekunden zwischen Verbindungsversuchen zu anderen Servern */
420                 Conf_ConnectRetry = atoi( Arg );
421                 if(( Conf_ConnectRetry ) < 5 ) Conf_ConnectRetry = 5;
422                 return;
423         }
424         if( strcasecmp( Var, "OperCanUseMode" ) == 0 )
425         {
426                 /* Koennen IRC-Operatoren immer MODE benutzen? */
427                 if( strcasecmp( Arg, "yes" ) == 0 ) Conf_OperCanMode = TRUE;
428                 else if( strcasecmp( Arg, "true" ) == 0 ) Conf_OperCanMode = TRUE;
429                 else if( atoi( Arg ) != 0 ) Conf_OperCanMode = TRUE;
430                 else Conf_OperCanMode = FALSE;
431                 return;
432         }
433         if( strcasecmp( Var, "MaxConnections" ) == 0 )
434         {
435                 /* Maximale Anzahl von Verbindungen. Werte <= 0 stehen
436                  * fuer "kein Limit". */
437                 Conf_MaxConnections = atol( Arg );
438                 return;
439         }
440                 
441         Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
442 } /* Handle_GLOBAL */
443
444
445 LOCAL VOID
446 Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg )
447 {
448         assert( Line > 0 );
449         assert( Var != NULL );
450         assert( Arg != NULL );
451         assert( Conf_Oper_Count > 0 );
452
453         if( strcasecmp( Var, "Name" ) == 0 )
454         {
455                 /* Name des IRC Operator */
456                 strncpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, CLIENT_PASS_LEN - 1 );
457                 Conf_Oper[Conf_Oper_Count - 1].name[CLIENT_PASS_LEN - 1] = '\0';
458                 return;
459         }
460         if( strcasecmp( Var, "Password" ) == 0 )
461         {
462                 /* Passwort des IRC Operator */
463                 strncpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, CLIENT_PASS_LEN - 1 );
464                 Conf_Oper[Conf_Oper_Count - 1].pwd[CLIENT_PASS_LEN - 1] = '\0';
465                 return;
466         }
467         
468         Config_Error( LOG_ERR, "%s, line %d (section \"Operator\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
469 } /* Handle_OPERATOR */
470
471
472 LOCAL VOID
473 Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg )
474 {
475         LONG port;
476         
477         assert( Line > 0 );
478         assert( Var != NULL );
479         assert( Arg != NULL );
480
481         if( strcasecmp( Var, "Host" ) == 0 )
482         {
483                 /* Hostname des Servers */
484                 strncpy( Conf_Server[Conf_Server_Count - 1].host, Arg, HOST_LEN - 1 );
485                 Conf_Server[Conf_Server_Count - 1].host[HOST_LEN - 1] = '\0';
486                 return;
487         }
488         if( strcasecmp( Var, "Name" ) == 0 )
489         {
490                 /* Name des Servers ("Nick") */
491                 strncpy( Conf_Server[Conf_Server_Count - 1].name, Arg, CLIENT_ID_LEN - 1 );
492                 Conf_Server[Conf_Server_Count - 1].name[CLIENT_ID_LEN - 1] = '\0';
493                 return;
494         }
495         if( strcasecmp( Var, "Password" ) == 0 )
496         {
497                 /* Passwort des Servers */
498                 strncpy( Conf_Server[Conf_Server_Count - 1].pwd, Arg, CLIENT_PASS_LEN - 1 );
499                 Conf_Server[Conf_Server_Count - 1].pwd[CLIENT_PASS_LEN - 1] = '\0';
500                 return;
501         }
502         if( strcasecmp( Var, "Port" ) == 0 )
503         {
504                 /* Port, zu dem Verbunden werden soll */
505                 port = atol( Arg );
506                 if( port > 0 && port < 0xFFFF ) Conf_Server[Conf_Server_Count - 1].port = (INT)port;
507                 else Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Illegal port number %ld!", NGIRCd_ConfFile, Line, port );
508                 return;
509         }
510         if( strcasecmp( Var, "Group" ) == 0 )
511         {
512                 /* Server-Gruppe */
513                 Conf_Server[Conf_Server_Count - 1].group = atoi( Arg );
514                 return;
515         }
516         
517         Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
518 } /* Handle_SERVER */
519
520
521 LOCAL VOID
522 Handle_CHANNEL( INT Line, CHAR *Var, CHAR *Arg )
523 {
524         assert( Line > 0 );
525         assert( Var != NULL );
526         assert( Arg != NULL );
527
528         if( strcasecmp( Var, "Name" ) == 0 )
529         {
530                 /* Hostname des Servers */
531                 strncpy( Conf_Channel[Conf_Channel_Count - 1].name, Arg, CHANNEL_NAME_LEN - 1 );
532                 Conf_Channel[Conf_Channel_Count - 1].name[CHANNEL_NAME_LEN - 1] = '\0';
533                 return;
534         }
535         if( strcasecmp( Var, "Modes" ) == 0 )
536         {
537                 /* Name des Servers ("Nick") */
538                 strncpy( Conf_Channel[Conf_Channel_Count - 1].modes, Arg, CHANNEL_MODE_LEN - 1 );
539                 Conf_Channel[Conf_Channel_Count - 1].modes[CHANNEL_MODE_LEN - 1] = '\0';
540                 return;
541         }
542         if( strcasecmp( Var, "Topic" ) == 0 )
543         {
544                 /* Passwort des Servers */
545                 strncpy( Conf_Channel[Conf_Channel_Count - 1].topic, Arg, CHANNEL_TOPIC_LEN - 1 );
546                 Conf_Channel[Conf_Channel_Count - 1].topic[CHANNEL_TOPIC_LEN - 1] = '\0';
547                 return;
548         }
549
550         Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
551 } /* Handle_CHANNEL */
552
553
554 LOCAL VOID
555 Validate_Config( VOID )
556 {
557         /* Konfiguration ueberpruefen */
558         
559         if( ! Conf_ServerName[0] )
560         {
561                 /* Kein Servername konfiguriert */
562                 Config_Error( LOG_ALERT, "No server name configured in \"%s\" ('ServerName')!", NGIRCd_ConfFile );
563                 Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
564                 exit( 1 );
565         }
566
567 #ifdef STRICT_RFC
568         if( ! Conf_ServerAdminMail[0] )
569         {
570                 /* Keine Server-Information konfiguriert */
571                 Config_Error( LOG_ALERT, "No administrator email address configured in \"%s\" ('AdminEMail')!", NGIRCd_ConfFile );
572                 Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
573                 exit( 1 );
574         }
575 #endif
576
577         if( ! Conf_ServerAdmin1[0] && ! Conf_ServerAdmin2[0] && ! Conf_ServerAdminMail[0] )
578         {
579                 /* Keine Server-Information konfiguriert */
580                 Log( LOG_WARNING, "No server information configured but required by RFC!" );
581         }
582 } /* Validate_Config */
583
584
585 #ifdef PROTOTYPES
586 LOCAL VOID Config_Error( CONST INT Level, CONST CHAR *Format, ... )
587 #else
588 LOCAL VOID Config_Error( Level, Format, va_alist )
589 CONST INT Level;
590 CONST CHAR *Format;
591 va_dcl
592 #endif
593 {
594         /* Fehler! Auf Console und/oder ins Log schreiben */
595
596         CHAR msg[MAX_LOG_MSG_LEN];
597         va_list ap;
598
599         assert( Format != NULL );
600
601         /* String mit variablen Argumenten zusammenbauen ... */
602 #ifdef PROTOTYPES
603         va_start( ap, Format );
604 #else
605         va_start( ap );
606 #endif
607         vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap );
608         va_end( ap );
609
610         /* Im "normalen Betrieb" soll der Log-Mechanismus des ngIRCd verwendet
611          * werden, beim Testen der Konfiguration jedoch nicht, hier sollen alle
612          * Meldungen direkt auf die Konsole ausgegeben werden: */
613         if( Use_Log ) Log( Level, "%s", msg );
614         else puts( msg );
615 } /* Config_Error */
616
617
618 /* -eof- */