Blame


1 f4ade537 2001-12-11 alex /*
2 f4ade537 2001-12-11 alex * ngIRCd -- The Next Generation IRC Daemon
3 03d971d9 2002-01-02 alex * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
4 f4ade537 2001-12-11 alex *
5 f4ade537 2001-12-11 alex * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
6 f4ade537 2001-12-11 alex * der GNU General Public License (GPL), wie von der Free Software Foundation
7 f4ade537 2001-12-11 alex * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
8 f4ade537 2001-12-11 alex * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
9 f4ade537 2001-12-11 alex * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
10 804b1ec4 2001-12-31 alex * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
11 f4ade537 2001-12-11 alex *
12 95a4b1b1 2002-03-25 alex * $Id: ngircd.c,v 1.35 2002/03/25 19:11:01 alex Exp $
13 f4ade537 2001-12-11 alex *
14 f4ade537 2001-12-11 alex * ngircd.c: Hier beginnt alles ;-)
15 f4ade537 2001-12-11 alex */
16 f4ade537 2001-12-11 alex
17 f4ade537 2001-12-11 alex
18 ca33cbda 2002-03-12 alex #include "portab.h"
19 f4ade537 2001-12-11 alex
20 ca33cbda 2002-03-12 alex #include "imp.h"
21 f4ade537 2001-12-11 alex #include <assert.h>
22 22cf0c5d 2002-01-12 alex #include <errno.h>
23 f4ade537 2001-12-11 alex #include <stdio.h>
24 418add93 2001-12-12 alex #include <signal.h>
25 52424b49 2002-01-11 alex #include <string.h>
26 22cf0c5d 2002-01-12 alex #include <unistd.h>
27 03d971d9 2002-01-02 alex #include <sys/types.h>
28 03d971d9 2002-01-02 alex #include <sys/wait.h>
29 ac9da09e 2001-12-30 alex #include <time.h>
30 b61b8c4d 2001-12-12 alex
31 58c6c8f3 2001-12-14 alex #include "channel.h"
32 58c6c8f3 2001-12-14 alex #include "client.h"
33 418add93 2001-12-12 alex #include "conf.h"
34 418add93 2001-12-12 alex #include "conn.h"
35 ca33cbda 2002-03-12 alex #include "defines.h"
36 58c6c8f3 2001-12-14 alex #include "irc.h"
37 f4ade537 2001-12-11 alex #include "log.h"
38 1751c869 2001-12-21 alex #include "parse.h"
39 f4ade537 2001-12-11 alex
40 ca33cbda 2002-03-12 alex #include "exp.h"
41 f4ade537 2001-12-11 alex #include "ngircd.h"
42 f4ade537 2001-12-11 alex
43 f4ade537 2001-12-11 alex
44 418add93 2001-12-12 alex LOCAL VOID Initialize_Signal_Handler( VOID );
45 f4ade537 2001-12-11 alex LOCAL VOID Signal_Handler( INT Signal );
46 f4ade537 2001-12-11 alex
47 9856253d 2001-12-30 alex LOCAL VOID Initialize_Listen_Ports( VOID );
48 f4ade537 2001-12-11 alex
49 52424b49 2002-01-11 alex LOCAL VOID Show_Version( VOID );
50 52424b49 2002-01-11 alex LOCAL VOID Show_Help( VOID );
51 9856253d 2001-12-30 alex
52 52424b49 2002-01-11 alex
53 95a4b1b1 2002-03-25 alex GLOBAL int main( int argc, const char *argv[] )
54 f4ade537 2001-12-11 alex {
55 52424b49 2002-01-11 alex BOOLEAN ok;
56 95a4b1b1 2002-03-25 alex INT32 pid, n;
57 95a4b1b1 2002-03-25 alex INT i;
58 52424b49 2002-01-11 alex
59 52424b49 2002-01-11 alex NGIRCd_Restart = FALSE;
60 52424b49 2002-01-11 alex NGIRCd_Quit = FALSE;
61 52424b49 2002-01-11 alex NGIRCd_NoDaemon = FALSE;
62 eea1a88b 2002-02-19 alex NGIRCd_Passive = FALSE;
63 52424b49 2002-01-11 alex #ifdef DEBUG
64 52424b49 2002-01-11 alex NGIRCd_Debug = FALSE;
65 52424b49 2002-01-11 alex #endif
66 d79a7d28 2002-01-18 alex #ifdef SNIFFER
67 d79a7d28 2002-01-18 alex NGIRCd_Sniffer = FALSE;
68 d79a7d28 2002-01-18 alex #endif
69 52424b49 2002-01-11 alex
70 52424b49 2002-01-11 alex /* Kommandozeile parsen */
71 52424b49 2002-01-11 alex for( i = 1; i < argc; i++ )
72 52424b49 2002-01-11 alex {
73 52424b49 2002-01-11 alex ok = FALSE;
74 52424b49 2002-01-11 alex if(( argv[i][0] == '-' ) && ( argv[i][1] == '-' ))
75 52424b49 2002-01-11 alex {
76 52424b49 2002-01-11 alex /* Lange Option */
77 52424b49 2002-01-11 alex
78 eea1a88b 2002-02-19 alex #ifdef DEBUG
79 eea1a88b 2002-02-19 alex if( strcmp( argv[i], "--debug" ) == 0 )
80 eea1a88b 2002-02-19 alex {
81 eea1a88b 2002-02-19 alex NGIRCd_Debug = TRUE;
82 eea1a88b 2002-02-19 alex ok = TRUE;
83 eea1a88b 2002-02-19 alex }
84 eea1a88b 2002-02-19 alex #endif
85 52424b49 2002-01-11 alex if( strcmp( argv[i], "--help" ) == 0 )
86 52424b49 2002-01-11 alex {
87 52424b49 2002-01-11 alex Show_Version( ); puts( "" );
88 52424b49 2002-01-11 alex Show_Help( ); puts( "" );
89 52424b49 2002-01-11 alex exit( 1 );
90 52424b49 2002-01-11 alex }
91 eea1a88b 2002-02-19 alex if( strcmp( argv[i], "--nodaemon" ) == 0 )
92 52424b49 2002-01-11 alex {
93 eea1a88b 2002-02-19 alex NGIRCd_NoDaemon = TRUE;
94 eea1a88b 2002-02-19 alex ok = TRUE;
95 52424b49 2002-01-11 alex }
96 eea1a88b 2002-02-19 alex if( strcmp( argv[i], "--passive" ) == 0 )
97 52424b49 2002-01-11 alex {
98 eea1a88b 2002-02-19 alex NGIRCd_Passive = TRUE;
99 d79a7d28 2002-01-18 alex ok = TRUE;
100 d79a7d28 2002-01-18 alex }
101 d79a7d28 2002-01-18 alex #ifdef SNIFFER
102 d79a7d28 2002-01-18 alex if( strcmp( argv[i], "--sniffer" ) == 0 )
103 d79a7d28 2002-01-18 alex {
104 d79a7d28 2002-01-18 alex NGIRCd_Sniffer = TRUE;
105 52424b49 2002-01-11 alex ok = TRUE;
106 52424b49 2002-01-11 alex }
107 52424b49 2002-01-11 alex #endif
108 eea1a88b 2002-02-19 alex if( strcmp( argv[i], "--version" ) == 0 )
109 52424b49 2002-01-11 alex {
110 d67d94ea 2002-03-10 alex Show_Version( );
111 eea1a88b 2002-02-19 alex exit( 1 );
112 52424b49 2002-01-11 alex }
113 52424b49 2002-01-11 alex }
114 52424b49 2002-01-11 alex else if(( argv[i][0] == '-' ) && ( argv[i][1] != '-' ))
115 52424b49 2002-01-11 alex {
116 52424b49 2002-01-11 alex /* Kurze Option */
117 52424b49 2002-01-11 alex
118 95a4b1b1 2002-03-25 alex for( n = 1; n < (INT32)strlen( argv[i] ); n++ )
119 52424b49 2002-01-11 alex {
120 52424b49 2002-01-11 alex ok = FALSE;
121 52424b49 2002-01-11 alex #ifdef DEBUG
122 52424b49 2002-01-11 alex if( argv[i][n] == 'd' )
123 52424b49 2002-01-11 alex {
124 52424b49 2002-01-11 alex NGIRCd_Debug = TRUE;
125 52424b49 2002-01-11 alex ok = TRUE;
126 52424b49 2002-01-11 alex }
127 52424b49 2002-01-11 alex #endif
128 eea1a88b 2002-02-19 alex if( argv[i][n] == 'n' )
129 eea1a88b 2002-02-19 alex {
130 eea1a88b 2002-02-19 alex NGIRCd_NoDaemon = TRUE;
131 eea1a88b 2002-02-19 alex ok = TRUE;
132 eea1a88b 2002-02-19 alex }
133 eea1a88b 2002-02-19 alex if( argv[i][n] == 'p' )
134 eea1a88b 2002-02-19 alex {
135 eea1a88b 2002-02-19 alex NGIRCd_Passive = TRUE;
136 eea1a88b 2002-02-19 alex ok = TRUE;
137 eea1a88b 2002-02-19 alex }
138 d79a7d28 2002-01-18 alex #ifdef SNIFFER
139 d79a7d28 2002-01-18 alex if( argv[i][n] == 's' )
140 d79a7d28 2002-01-18 alex {
141 d79a7d28 2002-01-18 alex NGIRCd_Sniffer = TRUE;
142 d79a7d28 2002-01-18 alex ok = TRUE;
143 d79a7d28 2002-01-18 alex }
144 d79a7d28 2002-01-18 alex #endif
145 52424b49 2002-01-11 alex
146 52424b49 2002-01-11 alex if( ! ok )
147 52424b49 2002-01-11 alex {
148 52424b49 2002-01-11 alex printf( PACKAGE": invalid option \"-%c\"!\n", argv[i][n] );
149 52424b49 2002-01-11 alex puts( "Try \""PACKAGE" --help\" for more information." );
150 52424b49 2002-01-11 alex exit( 1 );
151 52424b49 2002-01-11 alex }
152 52424b49 2002-01-11 alex }
153 f4ade537 2001-12-11 alex
154 52424b49 2002-01-11 alex }
155 52424b49 2002-01-11 alex if( ! ok )
156 52424b49 2002-01-11 alex {
157 52424b49 2002-01-11 alex printf( PACKAGE": invalid option \"%s\"!\n", argv[i] );
158 52424b49 2002-01-11 alex puts( "Try \""PACKAGE" --help\" for more information." );
159 52424b49 2002-01-11 alex exit( 1 );
160 52424b49 2002-01-11 alex }
161 52424b49 2002-01-11 alex }
162 52424b49 2002-01-11 alex
163 eea1a88b 2002-02-19 alex /* Debug-Level (fuer IRC-Befehl "VERSION") ermitteln */
164 eea1a88b 2002-02-19 alex strcpy( NGIRCd_DebugLevel, "" );
165 eea1a88b 2002-02-19 alex #ifdef DEBUG
166 eea1a88b 2002-02-19 alex if( NGIRCd_Debug ) strcpy( NGIRCd_DebugLevel, "1" );
167 eea1a88b 2002-02-19 alex #endif
168 eea1a88b 2002-02-19 alex #ifdef SNIFFER
169 eea1a88b 2002-02-19 alex if( NGIRCd_Sniffer ) strcpy( NGIRCd_DebugLevel, "2" );
170 eea1a88b 2002-02-19 alex #endif
171 eea1a88b 2002-02-19 alex
172 804b1ec4 2001-12-31 alex while( ! NGIRCd_Quit )
173 804b1ec4 2001-12-31 alex {
174 22cf0c5d 2002-01-12 alex /* In der Regel wird ein Sub-Prozess ge-fork()'t, der
175 22cf0c5d 2002-01-12 alex * nicht mehr mit dem Terminal verbunden ist. Mit der
176 22cf0c5d 2002-01-12 alex * Option "--nodaemon" kann dies (z.B. zum Debuggen)
177 22cf0c5d 2002-01-12 alex * verhindert werden. */
178 22cf0c5d 2002-01-12 alex if( ! NGIRCd_NoDaemon )
179 22cf0c5d 2002-01-12 alex {
180 22cf0c5d 2002-01-12 alex /* Daemon im Hintergrund erzeugen */
181 95a4b1b1 2002-03-25 alex pid = (INT32)fork( );
182 22cf0c5d 2002-01-12 alex if( pid > 0 )
183 22cf0c5d 2002-01-12 alex {
184 22cf0c5d 2002-01-12 alex /* "alter" Prozess */
185 22cf0c5d 2002-01-12 alex exit( 0 );
186 22cf0c5d 2002-01-12 alex }
187 22cf0c5d 2002-01-12 alex if( pid < 0 )
188 22cf0c5d 2002-01-12 alex {
189 22cf0c5d 2002-01-12 alex /* Fehler */
190 22cf0c5d 2002-01-12 alex printf( PACKAGE": Can't fork: %s!\nFatal error, exiting now ...", strerror( errno ));
191 22cf0c5d 2002-01-12 alex exit( 1 );
192 22cf0c5d 2002-01-12 alex }
193 fe2bc90e 2002-03-06 alex
194 fe2bc90e 2002-03-06 alex /* Child-Prozess initialisieren */
195 95a4b1b1 2002-03-25 alex (VOID)setsid( );
196 22cf0c5d 2002-01-12 alex chdir( "/" );
197 22cf0c5d 2002-01-12 alex }
198 22cf0c5d 2002-01-12 alex
199 804b1ec4 2001-12-31 alex /* Globale Variablen initialisieren */
200 804b1ec4 2001-12-31 alex NGIRCd_Start = time( NULL );
201 95a4b1b1 2002-03-25 alex (VOID)strftime( NGIRCd_StartStr, 64, "%a %b %d %Y at %H:%M:%S (%Z)", localtime( &NGIRCd_Start ));
202 804b1ec4 2001-12-31 alex NGIRCd_Restart = FALSE;
203 804b1ec4 2001-12-31 alex NGIRCd_Quit = FALSE;
204 ff280ce4 2001-12-12 alex
205 804b1ec4 2001-12-31 alex /* Module initialisieren */
206 804b1ec4 2001-12-31 alex Log_Init( );
207 804b1ec4 2001-12-31 alex Conf_Init( );
208 804b1ec4 2001-12-31 alex Channel_Init( );
209 804b1ec4 2001-12-31 alex Client_Init( );
210 804b1ec4 2001-12-31 alex Conn_Init( );
211 f4ade537 2001-12-11 alex
212 804b1ec4 2001-12-31 alex /* Signal-Handler initialisieren */
213 804b1ec4 2001-12-31 alex Initialize_Signal_Handler( );
214 9856253d 2001-12-30 alex
215 804b1ec4 2001-12-31 alex /* Listen-Ports initialisieren */
216 804b1ec4 2001-12-31 alex Initialize_Listen_Ports( );
217 804b1ec4 2001-12-31 alex
218 804b1ec4 2001-12-31 alex /* Hauptschleife */
219 804b1ec4 2001-12-31 alex while( TRUE )
220 804b1ec4 2001-12-31 alex {
221 804b1ec4 2001-12-31 alex if( NGIRCd_Quit || NGIRCd_Restart ) break;
222 804b1ec4 2001-12-31 alex Conn_Handler( 5 );
223 804b1ec4 2001-12-31 alex }
224 804b1ec4 2001-12-31 alex
225 804b1ec4 2001-12-31 alex /* Alles abmelden */
226 804b1ec4 2001-12-31 alex Conn_Exit( );
227 804b1ec4 2001-12-31 alex Client_Exit( );
228 804b1ec4 2001-12-31 alex Channel_Exit( );
229 804b1ec4 2001-12-31 alex Conf_Exit( );
230 804b1ec4 2001-12-31 alex Log_Exit( );
231 804b1ec4 2001-12-31 alex }
232 fe2bc90e 2002-03-06 alex
233 fe2bc90e 2002-03-06 alex #ifndef DEBUG
234 fe2bc90e 2002-03-06 alex /* aufraeumen */
235 fe2bc90e 2002-03-06 alex if( unlink( ERROR_FILE ) != 0 ) Log( LOG_ERR, "Can't delete \""ERROR_FILE"\": %s", strerror( errno ));
236 fe2bc90e 2002-03-06 alex #endif
237 fe2bc90e 2002-03-06 alex
238 f4ade537 2001-12-11 alex return 0;
239 f4ade537 2001-12-11 alex } /* main */
240 f4ade537 2001-12-11 alex
241 f4ade537 2001-12-11 alex
242 52424b49 2002-01-11 alex GLOBAL CHAR *NGIRCd_Version( VOID )
243 52424b49 2002-01-11 alex {
244 52424b49 2002-01-11 alex STATIC CHAR version[126];
245 52424b49 2002-01-11 alex
246 3fbbfe44 2002-02-17 alex sprintf( version, PACKAGE" version "VERSION"-%s", NGIRCd_VersionAddition( ));
247 3fbbfe44 2002-02-17 alex return version;
248 3fbbfe44 2002-02-17 alex } /* NGIRCd_Version */
249 3fbbfe44 2002-02-17 alex
250 3fbbfe44 2002-02-17 alex
251 3fbbfe44 2002-02-17 alex GLOBAL CHAR *NGIRCd_VersionAddition( VOID )
252 3fbbfe44 2002-02-17 alex {
253 3fbbfe44 2002-02-17 alex STATIC CHAR txt[64];
254 3fbbfe44 2002-02-17 alex
255 52424b49 2002-01-11 alex strcpy( txt, "" );
256 52424b49 2002-01-11 alex
257 52424b49 2002-01-11 alex #ifdef USE_SYSLOG
258 52424b49 2002-01-11 alex if( txt[0] ) strcat( txt, "+" );
259 52424b49 2002-01-11 alex strcat( txt, "SYSLOG" );
260 52424b49 2002-01-11 alex #endif
261 52424b49 2002-01-11 alex #ifdef STRICT_RFC
262 52424b49 2002-01-11 alex if( txt[0] ) strcat( txt, "+" );
263 52424b49 2002-01-11 alex strcat( txt, "RFC" );
264 52424b49 2002-01-11 alex #endif
265 52424b49 2002-01-11 alex #ifdef DEBUG
266 52424b49 2002-01-11 alex if( txt[0] ) strcat( txt, "+" );
267 52424b49 2002-01-11 alex strcat( txt, "DEBUG" );
268 52424b49 2002-01-11 alex #endif
269 52424b49 2002-01-11 alex #ifdef SNIFFER
270 52424b49 2002-01-11 alex if( txt[0] ) strcat( txt, "+" );
271 52424b49 2002-01-11 alex strcat( txt, "SNIFFER" );
272 52424b49 2002-01-11 alex #endif
273 52424b49 2002-01-11 alex
274 3fbbfe44 2002-02-17 alex if( txt[0] ) strcat( txt, "-" );
275 882c9128 2002-03-12 alex strcat( txt, TARGET_CPU"/"TARGET_VENDOR"/"TARGET_OS );
276 52424b49 2002-01-11 alex
277 3fbbfe44 2002-02-17 alex return txt;
278 3fbbfe44 2002-02-17 alex } /* NGIRCd_VersionAddition */
279 52424b49 2002-01-11 alex
280 3fbbfe44 2002-02-17 alex
281 418add93 2001-12-12 alex LOCAL VOID Initialize_Signal_Handler( VOID )
282 418add93 2001-12-12 alex {
283 08cf5607 2001-12-26 alex /* Signal-Handler initialisieren: einige Signale
284 08cf5607 2001-12-26 alex * werden ignoriert, andere speziell behandelt. */
285 418add93 2001-12-12 alex
286 62266a8d 2002-02-25 alex #ifdef HAVE_SIGACTION
287 62266a8d 2002-02-25 alex /* sigaction() ist vorhanden */
288 62266a8d 2002-02-25 alex
289 418add93 2001-12-12 alex struct sigaction saction;
290 418add93 2001-12-12 alex
291 418add93 2001-12-12 alex /* Signal-Struktur initialisieren */
292 418add93 2001-12-12 alex memset( &saction, 0, sizeof( saction ));
293 23253edb 2002-01-22 alex saction.sa_handler = Signal_Handler;
294 9919f38d 2002-02-19 alex #ifdef SA_RESTART
295 6f955d2a 2002-02-23 alex saction.sa_flags |= SA_RESTART;
296 9919f38d 2002-02-19 alex #endif
297 6f955d2a 2002-02-23 alex #ifdef SA_NOCLDWAIT
298 6f955d2a 2002-02-23 alex saction.sa_flags |= SA_NOCLDWAIT;
299 6f955d2a 2002-02-23 alex #endif
300 418add93 2001-12-12 alex
301 418add93 2001-12-12 alex /* Signal-Handler einhaengen */
302 418add93 2001-12-12 alex sigaction( SIGINT, &saction, NULL );
303 418add93 2001-12-12 alex sigaction( SIGQUIT, &saction, NULL );
304 418add93 2001-12-12 alex sigaction( SIGTERM, &saction, NULL);
305 3fbbfe44 2002-02-17 alex sigaction( SIGHUP, &saction, NULL);
306 03d971d9 2002-01-02 alex sigaction( SIGCHLD, &saction, NULL);
307 eb952e35 2001-12-24 alex
308 eb952e35 2001-12-24 alex /* einige Signale ignorieren */
309 eb952e35 2001-12-24 alex saction.sa_handler = SIG_IGN;
310 eb952e35 2001-12-24 alex sigaction( SIGPIPE, &saction, NULL );
311 62266a8d 2002-02-25 alex #else
312 62266a8d 2002-02-25 alex /* kein sigaction() vorhanden */
313 62266a8d 2002-02-25 alex
314 62266a8d 2002-02-25 alex /* Signal-Handler einhaengen */
315 62266a8d 2002-02-25 alex signal( SIGINT, Signal_Handler );
316 62266a8d 2002-02-25 alex signal( SIGQUIT, Signal_Handler );
317 62266a8d 2002-02-25 alex signal( SIGTERM, Signal_Handler );
318 62266a8d 2002-02-25 alex signal( SIGHUP, Signal_Handler );
319 62266a8d 2002-02-25 alex signal( SIGCHLD, Signal_Handler );
320 62266a8d 2002-02-25 alex
321 62266a8d 2002-02-25 alex /* einige Signale ignorieren */
322 62266a8d 2002-02-25 alex signal( SIGPIPE, SIG_IGN );
323 62266a8d 2002-02-25 alex #endif
324 418add93 2001-12-12 alex } /* Initialize_Signal_Handler */
325 418add93 2001-12-12 alex
326 418add93 2001-12-12 alex
327 f4ade537 2001-12-11 alex LOCAL VOID Signal_Handler( INT Signal )
328 f4ade537 2001-12-11 alex {
329 418add93 2001-12-12 alex /* Signal-Handler. Dieser wird aufgerufen, wenn eines der Signale eintrifft,
330 418add93 2001-12-12 alex * fuer das wir uns registriert haben (vgl. Initialize_Signal_Handler). Die
331 418add93 2001-12-12 alex * Nummer des eingetroffenen Signals wird der Funktion uebergeben. */
332 418add93 2001-12-12 alex
333 f4ade537 2001-12-11 alex switch( Signal )
334 f4ade537 2001-12-11 alex {
335 f4ade537 2001-12-11 alex case SIGTERM:
336 b61b8c4d 2001-12-12 alex case SIGINT:
337 b61b8c4d 2001-12-12 alex case SIGQUIT:
338 418add93 2001-12-12 alex /* wir soll(t)en uns wohl beenden ... */
339 3fbbfe44 2002-02-17 alex if( Signal == SIGTERM ) Log( LOG_WARNING, "Got TERM signal, terminating now ..." );
340 3fbbfe44 2002-02-17 alex else if( Signal == SIGINT ) Log( LOG_WARNING, "Got INT signal, terminating now ..." );
341 3fbbfe44 2002-02-17 alex else if( Signal == SIGQUIT ) Log( LOG_WARNING, "Got QUIT signal, terminating now ..." );
342 ff280ce4 2001-12-12 alex NGIRCd_Quit = TRUE;
343 f4ade537 2001-12-11 alex break;
344 3fbbfe44 2002-02-17 alex case SIGHUP:
345 3fbbfe44 2002-02-17 alex /* neu starten */
346 3fbbfe44 2002-02-17 alex Log( LOG_WARNING, "Got HUP signal, restarting now ..." );
347 3fbbfe44 2002-02-17 alex NGIRCd_Restart = TRUE;
348 3fbbfe44 2002-02-17 alex break;
349 03d971d9 2002-01-02 alex case SIGCHLD:
350 03d971d9 2002-01-02 alex /* Child-Prozess wurde beendet. Zombies vermeiden: */
351 03d971d9 2002-01-02 alex while( waitpid( -1, NULL, WNOHANG ) > 0);
352 03d971d9 2002-01-02 alex break;
353 f4ade537 2001-12-11 alex default:
354 418add93 2001-12-12 alex /* unbekanntes bzw. unbehandeltes Signal */
355 ff280ce4 2001-12-12 alex Log( LOG_NOTICE, "Got signal %d! Ignored.", Signal );
356 f4ade537 2001-12-11 alex }
357 f4ade537 2001-12-11 alex } /* Signal_Handler */
358 f4ade537 2001-12-11 alex
359 f4ade537 2001-12-11 alex
360 9856253d 2001-12-30 alex LOCAL VOID Initialize_Listen_Ports( VOID )
361 9856253d 2001-12-30 alex {
362 9856253d 2001-12-30 alex /* Ports, auf denen der Server Verbindungen entgegennehmen
363 9856253d 2001-12-30 alex * soll, initialisieren */
364 9856253d 2001-12-30 alex
365 9856253d 2001-12-30 alex INT created, i;
366 9856253d 2001-12-30 alex
367 9856253d 2001-12-30 alex created = 0;
368 9856253d 2001-12-30 alex for( i = 0; i < Conf_ListenPorts_Count; i++ )
369 9856253d 2001-12-30 alex {
370 9856253d 2001-12-30 alex if( Conn_NewListener( Conf_ListenPorts[i] )) created++;
371 9856253d 2001-12-30 alex else Log( LOG_ERR, "Can't listen on port %d!", Conf_ListenPorts[i] );
372 9856253d 2001-12-30 alex }
373 9856253d 2001-12-30 alex
374 9856253d 2001-12-30 alex if( created < 1 )
375 9856253d 2001-12-30 alex {
376 9856253d 2001-12-30 alex Log( LOG_ALERT, "Server isn't listening on a single port!" );
377 9856253d 2001-12-30 alex Log( LOG_ALERT, PACKAGE" exiting due to fatal errors!" );
378 9856253d 2001-12-30 alex exit( 1 );
379 9856253d 2001-12-30 alex }
380 9856253d 2001-12-30 alex } /* Initialize_Listen_Ports */
381 9856253d 2001-12-30 alex
382 52424b49 2002-01-11 alex
383 52424b49 2002-01-11 alex LOCAL VOID Show_Version( VOID )
384 52424b49 2002-01-11 alex {
385 52424b49 2002-01-11 alex puts( NGIRCd_Version( ));
386 52424b49 2002-01-11 alex puts( "Copyright (c)2001,2002 by Alexander Barton (alex@barton.de).\n" );
387 52424b49 2002-01-11 alex puts( "This is free software; see the source for copying conditions. There is NO" );
388 52424b49 2002-01-11 alex puts( "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." );
389 52424b49 2002-01-11 alex } /* Show_Version */
390 52424b49 2002-01-11 alex
391 52424b49 2002-01-11 alex
392 52424b49 2002-01-11 alex LOCAL VOID Show_Help( VOID )
393 52424b49 2002-01-11 alex {
394 d67d94ea 2002-03-10 alex puts( "Compile-time defaults:\n" );
395 d67d94ea 2002-03-10 alex puts( " - configuration: "CONFIG_FILE );
396 d67d94ea 2002-03-10 alex puts( " - MOTD file: "MOTD_FILE );
397 d67d94ea 2002-03-10 alex puts( " - server error log: "ERROR_FILE"\n" );
398 d67d94ea 2002-03-10 alex puts( "Run-time options:\n" );
399 52424b49 2002-01-11 alex #ifdef DEBUG
400 52424b49 2002-01-11 alex puts( " -d, --debug log extra debug messages" );
401 52424b49 2002-01-11 alex #endif
402 52424b49 2002-01-11 alex puts( " -n, --nodaemon don't fork and don't detatch from controlling terminal" );
403 eea1a88b 2002-02-19 alex puts( " -p, --passive disable automatic connections to other servers" );
404 9951e135 2002-01-21 alex #ifdef SNIFFER
405 9951e135 2002-01-21 alex puts( " -s, --sniffer enable network sniffer and display all IRC traffic" );
406 9951e135 2002-01-21 alex #endif
407 9951e135 2002-01-21 alex puts( " --version output version information and exit" );
408 9951e135 2002-01-21 alex puts( " --help display this help and exit" );
409 52424b49 2002-01-11 alex } /* Show_Help */
410 52424b49 2002-01-11 alex
411 52424b49 2002-01-11 alex
412 f4ade537 2001-12-11 alex /* -eof- */