]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/irc.c
- IRC_WriteStrXXX()-Funktionen eingefuehrt, groessere Anpassungen daran.
[ngircd-alex.git] / src / ngircd / irc.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: irc.c,v 1.24 2002/01/04 17:58:44 alex Exp $
13  *
14  * irc.c: IRC-Befehle
15  *
16  * $Log: irc.c,v $
17  * Revision 1.24  2002/01/04 17:58:44  alex
18  * - IRC_WriteStrXXX()-Funktionen eingefuehrt, groessere Anpassungen daran.
19  * - neuer Befehl SQUIT, QUIT an Server-Links angepasst.
20  *
21  * Revision 1.23  2002/01/04 01:36:40  alex
22  * - Loglevel ein wenig angepasst.
23  *
24  * Revision 1.22  2002/01/04 01:21:47  alex
25  * - Client-Strukruren werden nur noch ueber Funktionen angesprochen.
26  * - Weitere Anpassungen und Erweiterungen der Server-Links.
27  *
28  * Revision 1.21  2002/01/03 02:26:51  alex
29  * - neue Befehle SERVER und NJOIN begonnen,
30  * - begonnen, diverse IRC-Befehle an Server-Links anzupassen.
31  *
32  * Revision 1.20  2002/01/02 12:46:41  alex
33  * - die Gross- und Kleinschreibung des Nicks kann mit NICK nun geaendert werden.
34  *
35  * Revision 1.19  2002/01/02 02:51:39  alex
36  * - Copyright-Texte angepasst.
37  * - neuer Befehl "ERROR".
38  *
39  * Revision 1.17  2001/12/31 15:33:13  alex
40  * - neuer Befehl NAMES, kleinere Bugfixes.
41  * - Bug bei PING behoben: war zu restriktiv implementiert :-)
42  *
43  * Revision 1.16  2001/12/31 02:18:51  alex
44  * - viele neue Befehle (WHOIS, ISON, OPER, DIE, RESTART),
45  * - neuen Header "defines.h" mit (fast) allen Konstanten.
46  * - Code Cleanups und viele "kleine" Aenderungen & Bugfixes.
47  *
48  * Revision 1.15  2001/12/30 19:26:11  alex
49  * - Unterstuetzung fuer die Konfigurationsdatei eingebaut.
50  *
51  * Revision 1.14  2001/12/30 11:42:00  alex
52  * - der Server meldet nun eine ordentliche "Start-Zeit".
53  *
54  * Revision 1.13  2001/12/29 03:10:06  alex
55  * - Neue Funktion IRC_MODE() implementiert, div. Aenderungen.
56  * - neue configure-Optione "--enable-strict-rfc".
57  *
58  * Revision 1.12  2001/12/27 19:17:26  alex
59  * - neue Befehle PRIVMSG, NOTICE, PING.
60  *
61  * Revision 1.11  2001/12/27 16:55:41  alex
62  * - neu: IRC_WriteStrRelated(), Aenderungen auch in IRC_WriteStrClient().
63  *
64  * Revision 1.10  2001/12/26 22:48:53  alex
65  * - MOTD-Datei ist nun konfigurierbar und wird gelesen.
66  *
67  * Revision 1.9  2001/12/26 14:45:37  alex
68  * - "Code Cleanups".
69  *
70  * Revision 1.8  2001/12/26 03:21:46  alex
71  * - PING/PONG-Befehle implementiert,
72  * - Meldungen ueberarbeitet: enthalten nun (fast) immer den Nick.
73  *
74  * Revision 1.7  2001/12/25 23:25:18  alex
75  * - und nochmal Aenderungen am Logging ;-)
76  *
77  * Revision 1.6  2001/12/25 23:13:33  alex
78  * - Debug-Meldungen angepasst.
79  *
80  * Revision 1.5  2001/12/25 22:02:42  alex
81  * - neuer IRC-Befehl "/QUIT". Verbessertes Logging & Debug-Ausgaben.
82  *
83  * Revision 1.4  2001/12/25 19:19:30  alex
84  * - bessere Fehler-Abfragen, diverse Bugfixes.
85  * - Nicks werden nur einmal vergeben :-)
86  * - /MOTD wird unterstuetzt.
87  *
88  * Revision 1.3  2001/12/24 01:34:06  alex
89  * - USER und NICK wird nun in beliebiger Reihenfolge akzeptiert (wg. BitchX)
90  * - MOTD-Ausgabe begonnen zu implementieren.
91  *
92  * Revision 1.2  2001/12/23 21:57:16  alex
93  * - erste IRC-Befehle zu implementieren begonnen.
94  *
95  * Revision 1.1  2001/12/14 08:13:43  alex
96  * - neues Modul begonnen :-)
97  */
98
99
100 #include <portab.h>
101 #include "global.h"
102
103 #include <imp.h>
104 #include <assert.h>
105 #include <errno.h>
106 #include <stdarg.h>
107 #include <stdio.h>
108 #include <stdlib.h>
109 #include <string.h>
110
111 #include "ngircd.h"
112 #include "client.h"
113 #include "conf.h"
114 #include "conn.h"
115 #include "log.h"
116 #include "messages.h"
117 #include "parse.h"
118 #include "tool.h"
119
120 #include <exp.h>
121 #include "irc.h"
122
123
124 #define CONNECTED TRUE
125 #define DISCONNECTED FALSE
126
127
128 LOCAL BOOLEAN Hello_User( CLIENT *Client );
129 LOCAL BOOLEAN Show_MOTD( CLIENT *Client );
130
131 LOCAL VOID Kill_Nick( CHAR *Nick );
132
133
134 GLOBAL VOID IRC_Init( VOID )
135 {
136 } /* IRC_Init */
137
138
139 GLOBAL VOID IRC_Exit( VOID )
140 {
141 } /* IRC_Exit */
142
143
144 GLOBAL BOOLEAN IRC_WriteStrClient( CLIENT *Client, CHAR *Format, ... )
145 {
146         CHAR buffer[1000];
147         BOOLEAN ok = CONNECTED;
148         va_list ap;
149
150         assert( Client != NULL );
151         assert( Format != NULL );
152
153         va_start( ap, Format );
154         vsnprintf( buffer, 1000, Format, ap );
155         va_end( ap );
156
157         /* an den Client selber */
158         ok = IRC_WriteStrClientPrefix( Client, Client_ThisServer( ), buffer );
159
160         return ok;
161 } /* IRC_WriteStrClient */
162
163
164 GLOBAL BOOLEAN IRC_WriteStrClientPrefix( CLIENT *Client, CLIENT *Prefix, CHAR *Format, ... )
165 {
166         /* Text an Clients, lokal bzw. remote, senden. */
167
168         CHAR buffer[1000];
169         BOOLEAN ok = CONNECTED;
170         CONN_ID send_to;
171         va_list ap;
172
173         assert( Client != NULL );
174         assert( Format != NULL );
175
176         va_start( ap, Format );
177         vsnprintf( buffer, 1000, Format, ap );
178         va_end( ap );
179
180         if( Client_Conn( Client ) != NONE ) send_to = Client_Conn( Client );
181         else send_to = Client_Conn( Client_Introducer( Client ));
182
183         if( Prefix ) ok = Conn_WriteStr( send_to, ":%s %s", Client_Mask( Prefix ), buffer );
184         else ok = Conn_WriteStr( send_to, buffer );
185
186         return ok;
187 } /* IRC_WriteStrClientPrefix */
188
189
190 GLOBAL BOOLEAN IRC_WriteStrRelated( CLIENT *Client, CHAR *Format, ... )
191 {
192         CHAR buffer[1000];
193         BOOLEAN ok = CONNECTED;
194         va_list ap;
195
196         assert( Client != NULL );
197         assert( Format != NULL );
198
199         va_start( ap, Format );
200         vsnprintf( buffer, 1000, Format, ap );
201         va_end( ap );
202
203         /* an den Client selber */
204         ok = IRC_WriteStrClient( Client, buffer );
205
206         return ok;
207 } /* IRC_WriteStrRelated */
208
209
210 GLOBAL BOOLEAN IRC_PASS( CLIENT *Client, REQUEST *Req )
211 {
212         assert( Client != NULL );
213         assert( Req != NULL );
214
215         /* Fehler liefern, wenn kein lokaler Client */
216         if( Client_Conn( Client ) <= NONE ) return IRC_WriteStrClient( Client, ERR_UNKNOWNCOMMAND_MSG, Client_ID( Client ), Req->command );
217         
218         if(( Client_Type( Client ) == CLIENT_UNKNOWN ) && ( Req->argc == 1))
219         {
220                 /* noch nicht registrierte unbekannte Verbindung */
221                 Log( LOG_DEBUG, "Connection %d: got PASS command ...", Client_Conn( Client ));
222
223                 /* Passwort speichern */
224                 Client_SetPassword( Client, Req->argv[0] );
225
226                 Client_SetType( Client, CLIENT_GOTPASS );
227                 return CONNECTED;
228         }
229         else if((( Client_Type( Client ) == CLIENT_UNKNOWN ) || ( Client_Type( Client ) == CLIENT_UNKNOWNSERVER )) && (( Req->argc == 3 ) || ( Req->argc == 4 )))
230         {
231                 /* noch nicht registrierte Server-Verbindung */
232                 Log( LOG_DEBUG, "Connection %d: got PASS command (new server link) ...", Client_Conn( Client ));
233
234                 /* Passwort speichern */
235                 Client_SetPassword( Client, Req->argv[0] );
236
237                 Client_SetType( Client, CLIENT_GOTPASSSERVER );
238                 return CONNECTED;
239         }
240         else if(( Client_Type( Client ) == CLIENT_UNKNOWN  ) || ( Client_Type( Client ) == CLIENT_UNKNOWNSERVER ))
241         {
242                 /* Falsche Anzahl Parameter? */
243                 return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
244         }
245         else return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
246 } /* IRC_PASS */
247
248
249 GLOBAL BOOLEAN IRC_SERVER( CLIENT *Client, REQUEST *Req )
250 {
251         CHAR str[LINE_LEN], *ptr;
252         CLIENT *c;
253         
254         assert( Client != NULL );
255         assert( Req != NULL );
256
257         /* Fehler liefern, wenn kein lokaler Client */
258         if( Client_Conn( Client ) <= NONE ) return IRC_WriteStrClient( Client, ERR_UNKNOWNCOMMAND_MSG, Client_ID( Client ), Req->command );
259
260         if( Client_Type( Client ) == CLIENT_GOTPASSSERVER )
261         {
262                 /* Verbindung soll als Server-Server-Verbindung registriert werden */
263                 Log( LOG_DEBUG, "Connection %d: got SERVER command (new server link) ...", Client_Conn( Client ));
264
265                 /* Falsche Anzahl Parameter? */
266                 if( Req->argc != 3 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
267
268                 /* Ist ein Server mit dieser ID bereits registriert? */
269                 if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
270
271                 /* Server-Strukturen fuellen ;-) */
272                 Client_SetID( Client, Req->argv[0] );
273                 Client_SetToken( Client, atoi( Req->argv[1] ));
274                 Client_SetInfo( Client, Req->argv[2] );
275                 Client_SetHops( Client, 1 );
276
277                 Log( LOG_NOTICE, "Server \"%s\" registered (connection %d, 1 hop - direct link).", Client_ID( Client ), Client_Conn( Client ));
278
279                 Client_SetType( Client, CLIENT_SERVER );
280                 return CONNECTED;
281         }
282         else if( Client_Type( Client ) == CLIENT_SERVER )
283         {
284                 /* Neuer Server wird im Netz angekuendigt */
285
286                 /* Falsche Anzahl Parameter? */
287                 if( Req->argc != 4 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
288
289                 /* Ist ein Server mit dieser ID bereits registriert? */
290                 if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
291
292                 /* Ueberfluessige Hostnamen aus Info-Text entfernen */
293                 ptr = strchr( Req->argv[3] + 2, '[' );
294                 if( ! ptr ) ptr = Req->argv[3];
295
296                 /* Neue Client-Struktur anlegen */
297                 c = Client_NewRemoteServer( Client, Req->argv[0], atoi( Req->argv[1] ), atoi( Req->argv[2] ), ptr );
298                 if( ! c )
299                 {
300                         /* Neue Client-Struktur konnte nicht angelegt werden */
301                         Log( LOG_ALERT, "Can't allocate client structure for server! (on connection %d)", Client_Conn( Client ));
302                         Conn_Close( Client_Conn( Client ), "Can't allocate client structure for remote server!" );
303                         return DISCONNECTED;
304                 }
305
306                 /* Log-Meldung zusammenbauen und ausgeben */
307                 if(( Client_Hops( c ) > 1 ) && ( Req->prefix[0] )) sprintf( str, "connected to %s, ", Req->prefix );
308                 else strcpy( str, "" );
309                 Log( LOG_NOTICE, "Server \"%s\" registered (via %s, %s%d hop%s).", Client_ID( c ), Client_ID( Client ), str, Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
310                 
311                 return CONNECTED;
312         }
313         else return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
314 } /* IRC_SERVER */
315
316
317 GLOBAL BOOLEAN IRC_NJOIN( CLIENT *Client, REQUEST *Req )
318 {
319         assert( Client != NULL );
320         assert( Req != NULL );
321
322         if( Client_Type( Client ) != CLIENT_SERVER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTEREDSERVER_MSG, Client_ID( Client ));
323
324         return CONNECTED;
325 } /* IRC_NJOIN */
326
327
328 GLOBAL BOOLEAN IRC_NICK( CLIENT *Client, REQUEST *Req )
329 {
330         CLIENT *intr_c, *c;
331
332         assert( Client != NULL );
333         assert( Req != NULL );
334
335         /* Zumindest BitchX sendet NICK-USER in der falschen Reihenfolge. */
336 #ifndef STRICT_RFC
337         if( Client_Type( Client ) == CLIENT_UNKNOWN || Client_Type( Client ) == CLIENT_GOTPASS || Client_Type( Client ) == CLIENT_GOTNICK || Client_Type( Client ) == CLIENT_GOTUSER || Client_Type( Client ) == CLIENT_USER )
338 #else
339         if( Client_Type( Client ) == CLIENT_UNKNOWN || Client_Type( Client ) == CLIENT_GOTPASS || Client_Type( Client ) == CLIENT_GOTNICK || Client_Type( Client ) == CLIENT_USER  )
340 #endif
341         {
342                 /* User-Registrierung bzw. Nick-Aenderung */
343
344                 /* Falsche Anzahl Parameter? */
345                 if( Req->argc != 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
346
347                 /* Ist der Client "restricted"? */
348                 if( Client_HasMode( Client, 'r' )) return IRC_WriteStrClient( Client, ERR_RESTRICTED_MSG, Client_ID( Client ));
349
350                 /* Wenn der Client zu seinem eigenen Nick wechseln will, so machen
351                  * wir nichts. So macht es das Original und mind. Snak hat probleme,
352                  * wenn wir es nicht so machen. Ob es so okay ist? Hm ... */
353 #ifndef STRICT_RFC
354                 if( strcmp( Client_ID( Client ), Req->argv[0] ) == 0 ) return CONNECTED;
355 #endif
356                 
357                 /* pruefen, ob Nick bereits vergeben. Speziallfall: der Client
358                  * will nur die Gross- und Kleinschreibung aendern. Das darf
359                  * er natuerlich machen :-) */
360                 if( strcasecmp( Client_ID( Client ), Req->argv[0] ) != 0 )
361                 {
362                         if( ! Client_CheckNick( Client, Req->argv[0] )) return CONNECTED;
363                 }
364
365                 if( Client_Type( Client ) == CLIENT_USER )
366                 {
367                         /* Nick-Aenderung: allen mitteilen! */
368                         Log( LOG_INFO, "User \"%s\" changed nick: \"%s\" -> \"%s\".", Client_Mask( Client ), Client_ID( Client ), Req->argv[0] );
369                         IRC_WriteStrRelated( Client, "NICK :%s", Req->argv[0] );
370                 }
371                 
372                 /* Client-Nick registrieren */
373                 Client_SetID( Client, Req->argv[0] );
374
375                 if( Client_Type( Client ) != CLIENT_USER )
376                 {
377                         /* Neuer Client */
378                         Log( LOG_DEBUG, "Connection %d: got NICK command ...", Client_Conn( Client ));
379                         if( Client_Type( Client ) == CLIENT_GOTUSER ) return Hello_User( Client );
380                         else Client_SetType( Client, CLIENT_GOTNICK );
381                 }
382                 return CONNECTED;
383         }
384         else if( Client_Type( Client ) == CLIENT_SERVER )
385         {
386                 /* Server fuehrt neuen Client ein */
387
388                 /* Falsche Anzahl Parameter? */
389                 if( Req->argc != 7 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
390
391                 /* Nick ueberpruefen */
392                 c = Client_GetFromID( Req->argv[0] );
393                 if( c )
394                 {
395                         /* Der neue Nick ist auf diesem Server bereits registriert:
396                          * sowohl der neue, als auch der alte Client muessen nun
397                          * disconnectiert werden. */
398                         Log( LOG_ALERT, "Server %s introduces already registered nick %s!", Client_ID( Client ), Req->argv[0] );
399                         Kill_Nick( Req->argv[0] );
400                         return CONNECTED;
401                 }
402
403                 /* Server, zu dem der Client connectiert ist, suchen */
404                 intr_c = Client_GetFromToken( Client, atoi( Req->argv[4] ));
405                 if( ! intr_c )
406                 {
407                         Log( LOG_ALERT, "Server %s introduces nick %s with unknown host server!?", Client_ID( Client ), Req->argv[0] );
408                         Kill_Nick( Req->argv[0] );
409                         return CONNECTED;
410                 }
411
412                 /* Neue Client-Struktur anlegen */
413                 c = Client_NewRemoteUser( intr_c, Req->argv[0], atoi( Req->argv[1] ), Req->argv[2], Req->argv[3], atoi( Req->argv[4] ), Req->argv[5], Req->argv[6] );
414                 if( ! c )
415                 {
416                         /* Eine neue Client-Struktur konnte nicht angelegt werden.
417                          * Der Client muss disconnectiert werden, damit der Netz-
418                          * status konsistent bleibt. */
419                         Log( LOG_ALERT, "Can't allocate client structure! (on connection %d)", Client_Conn( Client ));
420                         Kill_Nick( Req->argv[0] );
421                         return CONNECTED;
422                 }
423
424                 Log( LOG_DEBUG, "User \"%s\" registered (via %s, on %s, %d hop%s).", Client_ID( c ), Client_ID( Client ), Client_ID( intr_c ), Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
425
426                 return CONNECTED;
427         }
428         else return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
429 } /* IRC_NICK */
430
431
432 GLOBAL BOOLEAN IRC_USER( CLIENT *Client, REQUEST *Req )
433 {
434         assert( Client != NULL );
435         assert( Req != NULL );
436
437 #ifndef STRICT_RFC
438         if( Client_Type( Client ) == CLIENT_GOTNICK || Client_Type( Client ) == CLIENT_GOTPASS || Client_Type( Client ) == CLIENT_UNKNOWN )
439 #else
440         if( Client_Type( Client ) == CLIENT_GOTNICK || Client_Type( Client ) == CLIENT_GOTPASS )
441 #endif
442         {
443                 /* Falsche Anzahl Parameter? */
444                 if( Req->argc != 4 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
445
446                 Client_SetUser( Client, Req->argv[0] );
447                 Client_SetInfo( Client, Req->argv[3] );
448
449                 Log( LOG_DEBUG, "Connection %d: got USER command ...", Client_Conn( Client ));
450                 if( Client_Type( Client ) == CLIENT_GOTNICK ) return Hello_User( Client );
451                 else Client_SetType( Client, CLIENT_GOTUSER );
452                 return CONNECTED;
453         }
454         else if( Client_Type( Client ) == CLIENT_USER || Client_Type( Client ) == CLIENT_SERVER || Client_Type( Client ) == CLIENT_SERVICE )
455         {
456                 return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
457         }
458         else return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
459 } /* IRC_USER */
460
461
462 GLOBAL BOOLEAN IRC_QUIT( CLIENT *Client, REQUEST *Req )
463 {
464         CLIENT *target;
465         
466         assert( Client != NULL );
467         assert( Req != NULL );
468
469         if(( Client_Type( Client ) == CLIENT_USER ) || ( Client_Type( Client ) == CLIENT_SERVICE ))
470         {
471                 /* User / Service */
472                 
473                 /* Falsche Anzahl Parameter? */
474                 if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
475
476                 Conn_Close( Client_Conn( Client ), "Client wants to quit." );
477                 return DISCONNECTED;
478         }
479         else if ( Client_Type( Client ) == CLIENT_SERVER )
480         {
481                 /* Server */
482
483                 /* Falsche Anzahl Parameter? */
484                 if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
485
486                 target = Client_Search( Req->prefix );
487                 if( ! target ) Log( LOG_ALERT, "Got QUIT from %s for unknown server!?", Client_ID( Client ));
488                 else Client_Destroy( target );
489                 return CONNECTED;
490         }
491         else return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
492 } /* IRC_QUIT */
493
494
495 GLOBAL BOOLEAN IRC_SQUIT( CLIENT *Client, REQUEST *Req )
496 {
497         CLIENT *target;
498         
499         assert( Client != NULL );
500         assert( Req != NULL );
501
502         /* SQUIT ist nur fuer Server erlaubt */
503         if( Client_Type( Client ) != CLIENT_SERVER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
504
505         /* Falsche Anzahl Parameter? */
506         if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
507
508         target = Client_GetFromID( Req->argv[0] );
509         if( ! target )
510         {
511                 Log( LOG_ALERT, "Got SQUIT from %s for unknown server \%s\"!?", Client_ID( Client ), Req->argv[0] );
512                 return CONNECTED;
513         }
514
515         if( target == Client ) Log( LOG_NOTICE, "Got SQUIT from %s: %s", Client_ID( Client ), Req->argv[1] );
516         else Log( LOG_NOTICE, "Got SQUIT from %s for %s: %s", Client_ID( Client ), Client_ID( target ), Req->argv[1] );
517
518         /* FIXME: das SQUIT muss an alle Server weiter-
519          * geleitet werden ... */
520
521         if( Client_Conn( target ) > NONE ) Conn_Close( Client_Conn( target ), Req->argv[1] );
522         else Client_Destroy( target );
523         return DISCONNECTED;
524 } /* IRC_SQUIT */
525
526
527 GLOBAL BOOLEAN IRC_PING( CLIENT *Client, REQUEST *Req )
528 {
529         assert( Client != NULL );
530         assert( Req != NULL );
531
532         if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
533
534         /* Falsche Anzahl Parameter? */
535         if( Req->argc < 1 ) return IRC_WriteStrClient( Client, ERR_NOORIGIN_MSG, Client_ID( Client ));
536         if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
537
538         return IRC_WriteStrClient( Client, "PONG %s :%s", Client_ID( Client_ThisServer( )), Client_ID( Client ));
539 } /* IRC_PING */
540
541
542 GLOBAL BOOLEAN IRC_PONG( CLIENT *Client, REQUEST *Req )
543 {
544         assert( Client != NULL );
545         assert( Req != NULL );
546
547         if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
548
549         /* Falsche Anzahl Parameter? */
550         if( Req->argc < 1 ) return IRC_WriteStrClient( Client, ERR_NOORIGIN_MSG, Client_ID( Client ));
551         if( Req->argc > 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
552
553         /* Der Connection-Timestamp wurde schon beim Lesen aus dem Socket
554          * aktualisiert, daher muss das hier nicht mehr gemacht werden. */
555
556         Log( LOG_DEBUG, "Connection %d: received PONG.", Client_Conn( Client ));
557         return CONNECTED;
558 } /* IRC_PONG */
559
560
561 GLOBAL BOOLEAN IRC_MOTD( CLIENT *Client, REQUEST *Req )
562 {
563         assert( Client != NULL );
564         assert( Req != NULL );
565
566         if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
567
568         /* Falsche Anzahl Parameter? */
569         if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
570
571         return Show_MOTD( Client );
572 } /* IRC_MOTD */
573
574
575 GLOBAL BOOLEAN IRC_PRIVMSG( CLIENT *Client, REQUEST *Req )
576 {
577         CLIENT *to;
578         
579         assert( Client != NULL );
580         assert( Req != NULL );
581
582         if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
583
584         /* Falsche Anzahl Parameter? */
585         if( Req->argc == 0 ) return IRC_WriteStrClient( Client, ERR_NORECIPIENT_MSG, Client_ID( Client ), Req->command );
586         if( Req->argc == 1 ) return IRC_WriteStrClient( Client, ERR_NOTEXTTOSEND_MSG, Client_ID( Client ));
587         if( Req->argc > 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
588
589         to = Client_Search( Req->argv[0] );
590         if( to )
591         {
592                 /* Okay, Ziel ist ein User */
593                 if( Client_Conn( Client ) >= 0 ) Conn_UpdateIdle( Client_Conn( Client ));
594                 return IRC_WriteStrClientPrefix( to, Client, "PRIVMSG %s :%s", Client_ID( to ), Req->argv[1] );
595         }
596
597         return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[0] );
598 } /* IRC_PRIVMSG */
599
600
601 GLOBAL BOOLEAN IRC_NOTICE( CLIENT *Client, REQUEST *Req )
602 {
603         CLIENT *to;
604
605         assert( Client != NULL );
606         assert( Req != NULL );
607
608         if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
609
610         /* Falsche Anzahl Parameter? */
611         if( Req->argc != 2 ) return CONNECTED;
612
613         to = Client_Search( Req->argv[0] );
614         if( to )
615         {
616                 /* Okay, Ziel ist ein User */
617                 return IRC_WriteStrClientPrefix( to, Client, "NOTICE %s :%s", Client_ID( to ), Req->argv[1] );
618         }
619
620         return CONNECTED;
621 } /* IRC_NOTICE */
622
623
624 GLOBAL BOOLEAN IRC_MODE( CLIENT *Client, REQUEST *Req )
625 {
626         CHAR x[2], new_modes[CLIENT_MODE_LEN], *ptr;
627         BOOLEAN set, ok;
628         CLIENT *target;
629         
630         assert( Client != NULL );
631         assert( Req != NULL );
632
633         if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
634
635         /* Falsche Anzahl Parameter? */
636         if(( Req->argc > 2 ) || ( Req->argc < 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
637
638         /* "Ziel-Client" suchen */
639         target = Client_Search( Req->argv[0] );
640
641         /* Wer ist der Anfragende? */
642         if( Client_Type( Client ) == CLIENT_USER )
643         {
644                 /* User: MODE ist nur fuer sich selber zulaessig */
645                 if( target != Client ) return IRC_WriteStrClient( Client, ERR_USERSDONTMATCH_MSG, Client_ID( Client ));
646         }
647         else
648         {
649                 /* Server: gibt es den Client ueberhaupt? */
650                 if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[0] );
651         }
652
653         /* Werden die Modes erfragt? */
654         if( Req->argc == 1 ) return IRC_WriteStrClient( Client, RPL_UMODEIS_MSG, Client_ID( Client ), Client_Modes( Client ));
655
656         ptr = Req->argv[1];
657
658         /* Sollen Modes gesetzt oder geloescht werden? */
659         if( *ptr == '+' ) set = TRUE;
660         else if( *ptr == '-' ) set = FALSE;
661         else return IRC_WriteStrClient( Client, ERR_UMODEUNKNOWNFLAG_MSG, Client_ID( Client ));
662
663         /* Reply-String mit Aenderungen vorbereiten */
664         if( set ) strcpy( new_modes, "+" );
665         else strcpy( new_modes, "-" );
666
667         ptr++;
668         ok = TRUE;
669         x[1] = '\0';
670         while( *ptr )
671         {
672                 x[0] = '\0';
673                 if( Client_Type( Client ) == CLIENT_SERVER )
674                 {
675                         x[0] = *ptr;
676                         ok = TRUE;
677                 }
678                 else
679                 {
680                         switch( *ptr )
681                         {
682                                 case 'i':
683                                         /* invisible */
684                                         x[0] = 'i';
685                                         break;
686                                 case 'r':
687                                         /* restricted (kann nur gesetzt werden) */
688                                         if( set ) x[0] = 'r';
689                                         else ok = IRC_WriteStrClient( target, ERR_RESTRICTED_MSG, Client_ID( target ));
690                                         break;
691                                 case 'o':
692                                         /* operator (kann nur geloescht werden) */
693                                         if( ! set )
694                                         {
695                                                 Client_SetOperByMe( target, FALSE );
696                                                 x[0] = 'o';
697                                         }
698                                         else ok = IRC_WriteStrClient( target, ERR_UMODEUNKNOWNFLAG_MSG, Client_ID( target ));
699                                         break;
700                                 default:
701                                         ok = IRC_WriteStrClient( target, ERR_UMODEUNKNOWNFLAG_MSG, Client_ID( target ));
702                                         x[0] = '\0';
703                         }
704                 }
705                 if( ! ok ) break;
706
707                 ptr++;
708                 if( ! x[0] ) continue;
709
710                 /* Okay, gueltigen Mode gefunden */
711                 if( set )
712                 {
713                         /* Mode setzen. Wenn der Client ihn noch nicht hatte: merken */
714                         if( Client_ModeAdd( target, x[0] )) strcat( new_modes, x );
715                 }
716                 else
717                 {
718                         /* Modes geloescht. Wenn der Client ihn hatte: merken */
719                         if( Client_ModeDel( target, x[0] )) strcat( new_modes, x );
720                 }
721         }
722         
723         /* Geanderte Modes? */
724         if( new_modes[1] )
725         {
726                 if( Client_Type( Client ) == CLIENT_SERVER )
727                 {
728                         /* Modes an andere Server forwarden */
729                         /* FIXME */
730                 }
731                 else
732                 {
733                         /* Bestaetigung an Client schicken */
734                         ok = IRC_WriteStrRelated( Client, "MODE %s :%s", Client_ID( target ), new_modes );
735                 }
736                 Log( LOG_DEBUG, "User \"%s\": Mode change, now \"%s\".", Client_Mask( target ), Client_Modes( target ));
737         }
738         return ok;
739 } /* IRC_MODE */
740
741
742 GLOBAL BOOLEAN IRC_OPER( CLIENT *Client, REQUEST *Req )
743 {
744         INT i;
745         
746         assert( Client != NULL );
747         assert( Req != NULL );
748
749         if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
750         
751         /* Falsche Anzahl Parameter? */
752         if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
753
754         /* Operator suchen */
755         for( i = 0; i < Conf_Oper_Count; i++)
756         {
757                 if( Conf_Oper[i].name[0] && Conf_Oper[i].pwd[0] && ( strcmp( Conf_Oper[i].name, Req->argv[0] ) == 0 )) break;
758         }
759         if( i >= Conf_Oper_Count ) return IRC_WriteStrClient( Client, ERR_PASSWDMISMATCH_MSG, Client_ID( Client ));
760
761         /* Stimmt der Name und das Passwort? */
762         if(( strcmp( Conf_Oper[i].name, Req->argv[0] ) != 0 ) || ( strcmp( Conf_Oper[i].pwd, Req->argv[1] ) != 0 )) return IRC_WriteStrClient( Client, ERR_PASSWDMISMATCH_MSG, Client_ID( Client ));
763         
764         if( ! Client_HasMode( Client, 'o' ))
765         {
766                 /* noch kein o-Mode gesetzt */
767                 Client_ModeAdd( Client, 'o' );
768                 if( ! IRC_WriteStrRelated( Client, "MODE %s :+o", Client_ID( Client ))) return DISCONNECTED;
769         }
770
771         if( ! Client_OperByMe( Client )) Log( LOG_NOTICE, "User \"%s\" is now an IRC Operator.", Client_Mask( Client ));
772
773         Client_SetOperByMe( Client, TRUE );
774         return IRC_WriteStrClient( Client, RPL_YOUREOPER_MSG, Client_ID( Client ));
775 } /* IRC_OPER */
776
777
778 GLOBAL BOOLEAN IRC_DIE( CLIENT *Client, REQUEST *Req )
779 {
780         assert( Client != NULL );
781         assert( Req != NULL );
782
783         if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
784
785         /* Falsche Anzahl Parameter? */
786         if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
787
788         if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
789
790         Log( LOG_NOTICE, "Got DIE command from \"%s\", going down!", Client_Mask( Client ));
791         NGIRCd_Quit = TRUE;
792         return CONNECTED;
793 } /* IRC_DIE */
794
795
796 GLOBAL BOOLEAN IRC_RESTART( CLIENT *Client, REQUEST *Req )
797 {
798         assert( Client != NULL );
799         assert( Req != NULL );
800
801         if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
802
803         /* Falsche Anzahl Parameter? */
804         if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
805
806         if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
807
808         Log( LOG_NOTICE, "Got RESTART command from \"%s\", going down!", Client_Mask( Client ));
809         NGIRCd_Restart = TRUE;
810         return CONNECTED;
811 } /* IRC_RESTART */
812
813
814 GLOBAL BOOLEAN IRC_NAMES( CLIENT *Client, REQUEST *Req )
815 {
816         CHAR rpl[COMMAND_LEN];
817         CLIENT *c;
818         
819         assert( Client != NULL );
820         assert( Req != NULL );
821
822         if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
823
824         /* Falsche Anzahl Parameter? */
825         if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
826
827         /* Noch alle User ausgeben, die in keinem Channel sind */
828         rpl[0] = '\0';
829         c = Client_First( );
830         while( c )
831         {
832                 if( Client_Type( c ) == CLIENT_USER )
833                 {
834                         /* Okay, das ist ein User */
835                         strcat( rpl, Client_ID( c ));
836                         strcat( rpl, " " );
837                 }
838
839                 /* Antwort zu lang? Splitten. */
840                 if( strlen( rpl ) > 480 )
841                 {
842                         if( rpl[strlen( rpl ) - 1] == ' ' ) rpl[strlen( rpl ) - 1] = '\0';
843                         if( ! IRC_WriteStrClient( Client, RPL_NAMREPLY_MSG, Client_ID( Client ), "*", "*", rpl )) return DISCONNECTED;
844                         rpl[0] = '\0';
845                 }
846                 
847                 c = Client_Next( c );
848         }
849         if( rpl[0] )
850         {
851                 /* es wurden User gefunden */
852                 if( rpl[strlen( rpl ) - 1] == ' ' ) rpl[strlen( rpl ) - 1] = '\0';
853                 if( ! IRC_WriteStrClient( Client, RPL_NAMREPLY_MSG, Client_ID( Client ), "*", "*", rpl )) return DISCONNECTED;
854         }
855         return IRC_WriteStrClient( Client, RPL_ENDOFNAMES_MSG, Client_ID( Client ), "*" );
856 } /* IRC_NAMES */
857
858
859 GLOBAL BOOLEAN IRC_ISON( CLIENT *Client, REQUEST *Req )
860 {
861         CHAR rpl[COMMAND_LEN];
862         CLIENT *c;
863         CHAR *ptr;
864         INT i;
865         
866         assert( Client != NULL );
867         assert( Req != NULL );
868
869         if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
870
871         /* Falsche Anzahl Parameter? */
872         if(( Req->argc < 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
873
874         strcpy( rpl, RPL_ISON_MSG );
875         for( i = 0; i < Req->argc; i++ )
876         {
877                 ptr = strtok( Req->argv[i], " " );
878                 while( ptr )
879                 {
880                         ngt_TrimStr( ptr );
881                         c = Client_GetFromID( ptr );
882                         if( c && ( Client_Type( c ) == CLIENT_USER ))
883                         {
884                                 /* Dieser Nick ist "online" */
885                                 strcat( rpl, ptr );
886                                 strcat( rpl, " " );
887                         }
888                         ptr = strtok( NULL, " " );
889                 }
890         }
891         if( rpl[strlen( rpl ) - 1] == ' ' ) rpl[strlen( rpl ) - 1] = '\0';
892
893         return IRC_WriteStrClient( Client, rpl, Client_ID( Client ) );
894 } /* IRC_ISON */
895
896
897 GLOBAL BOOLEAN IRC_WHOIS( CLIENT *Client, REQUEST *Req )
898 {
899         CLIENT *c;
900         
901         assert( Client != NULL );
902         assert( Req != NULL );
903
904         if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
905
906         /* Falsche Anzahl Parameter? */
907         if(( Req->argc < 1 ) || ( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
908
909         /* Client suchen */
910         c = Client_GetFromID( Req->argv[0] );
911         if(( ! c ) || ( Client_Type( c ) != CLIENT_USER )) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[0] );
912         
913         /* Nick, User und Name */
914         if( ! IRC_WriteStrClient( Client, RPL_WHOISUSER_MSG, Client_ID( Client ), Client_ID( c ), Client_User( c ), Client_Hostname( c ), Client_Info( c ))) return DISCONNECTED;
915
916         /* Server */
917         if( ! IRC_WriteStrClient( Client, RPL_WHOISSERVER_MSG, Client_ID( Client ), Client_ID( c ), Client_ID( Client_Introducer( c )), Client_Info( Client_Introducer( c )))) return DISCONNECTED;
918
919         /* IRC-Operator? */
920         if( Client_HasMode( c, 'o' ))
921         {
922                 if( ! IRC_WriteStrClient( Client, RPL_WHOISOPERATOR_MSG, Client_ID( Client ), Client_ID( c ))) return DISCONNECTED;
923         }
924
925         /* Idle (nur lokale Clients) */
926         if( Client_Conn( c ) > NONE )
927         {
928                 if( ! IRC_WriteStrClient( Client, RPL_WHOISIDLE_MSG, Client_ID( Client ), Client_ID( c ), Conn_GetIdle( Client_Conn ( c )))) return DISCONNECTED;
929         }
930
931         /* End of Whois */
932         return IRC_WriteStrClient( Client, RPL_ENDOFWHOIS_MSG, Client_ID( Client ), Client_ID( c ));
933 } /* IRC_WHOIS */
934
935
936 GLOBAL BOOLEAN IRC_USERHOST( CLIENT *Client, REQUEST *Req )
937 {
938         CHAR rpl[COMMAND_LEN];
939         CLIENT *c;
940         INT max, i;
941
942         assert( Client != NULL );
943         assert( Req != NULL );
944
945         if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
946
947         /* Falsche Anzahl Parameter? */
948         if(( Req->argc < 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
949
950         if( Req->argc > 5 ) max = 5;
951         else max = Req->argc;
952         
953         strcpy( rpl, RPL_USERHOST_MSG );
954         for( i = 0; i < max; i++ )
955         {
956                 c = Client_GetFromID( Req->argv[i] );
957                 if( c && ( Client_Type( c ) == CLIENT_USER ))
958                 {
959                         /* Dieser Nick ist "online" */
960                         strcat( rpl, Client_ID( c ));
961                         if( Client_HasMode( c, 'o' )) strcat( rpl, "*" );
962                         strcat( rpl, "=" );
963                         if( Client_HasMode( c, 'a' )) strcat( rpl, "-" );
964                         else strcat( rpl, "+" );
965                         strcat( rpl, Client_User( c ));
966                         strcat( rpl, "@" );
967                         strcat( rpl, Client_Hostname( c ));
968                         strcat( rpl, " " );
969                 }
970         }
971         if( rpl[strlen( rpl ) - 1] == ' ' ) rpl[strlen( rpl ) - 1] = '\0';
972
973         return IRC_WriteStrClient( Client, rpl, Client_ID( Client ) );
974 } /* IRC_USERHOST */
975
976
977 GLOBAL BOOLEAN IRC_ERROR( CLIENT *Client, REQUEST *Req )
978 {
979         assert( Client != NULL );
980         assert( Req != NULL );
981
982         if( Req->argc < 1 ) Log( LOG_NOTICE, "Got ERROR from \"%s\"!", Client_Mask( Client ));
983         else Log( LOG_NOTICE, "Got ERROR from \"%s\": %s!", Client_Mask( Client ), Req->argv[0] );
984
985         return CONNECTED;
986 } /* IRC_ERROR */
987
988
989 LOCAL BOOLEAN Hello_User( CLIENT *Client )
990 {
991         assert( Client != NULL );
992
993         /* Passwort ueberpruefen */
994         if( strcmp( Client_Password( Client ), Conf_ServerPwd ) != 0 )
995         {
996                 /* Falsches Passwort */
997                 Log( LOG_ALERT, "User \"%s\" rejected (connection %d): Bad password!", Client_Mask( Client ), Client_Conn( Client ));
998                 Conn_Close( Client_Conn( Client ), "Bad password!" );
999                 return DISCONNECTED;
1000         }
1001
1002         Log( LOG_NOTICE, "User \"%s\" registered (connection %d).", Client_Mask( Client ), Client_Conn( Client ));
1003
1004         IRC_WriteStrClient( Client, RPL_WELCOME_MSG, Client_ID( Client ), Client_Mask( Client ));
1005         IRC_WriteStrClient( Client, RPL_YOURHOST_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )));
1006         IRC_WriteStrClient( Client, RPL_CREATED_MSG, Client_ID( Client ), NGIRCd_StartStr );
1007         IRC_WriteStrClient( Client, RPL_MYINFO_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )));
1008
1009         Client_SetType( Client, CLIENT_USER );
1010
1011         return Show_MOTD( Client );
1012 } /* Hello_User */
1013
1014
1015 LOCAL BOOLEAN Show_MOTD( CLIENT *Client )
1016 {
1017         BOOLEAN ok;
1018         CHAR line[127];
1019         FILE *fd;
1020         
1021         assert( Client != NULL );
1022
1023         fd = fopen( Conf_MotdFile, "r" );
1024         if( ! fd )
1025         {
1026                 Log( LOG_WARNING, "Can't read MOTD file \"%s\": %s", Conf_MotdFile, strerror( errno ));
1027                 return IRC_WriteStrClient( Client, ERR_NOMOTD_MSG, Client_ID( Client ) );
1028         }
1029         
1030         IRC_WriteStrClient( Client, RPL_MOTDSTART_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )));
1031         while( TRUE )
1032         {
1033                 if( ! fgets( line, 126, fd )) break;
1034                 if( line[strlen( line ) - 1] == '\n' ) line[strlen( line ) - 1] = '\0';
1035                 IRC_WriteStrClient( Client, RPL_MOTD_MSG, Client_ID( Client ), line );
1036         }
1037         ok = IRC_WriteStrClient( Client, RPL_ENDOFMOTD_MSG, Client_ID( Client ) );
1038
1039         fclose( fd );
1040         
1041         return ok;
1042 } /* Show_MOTD */
1043
1044
1045 LOCAL VOID Kill_Nick( CHAR *Nick )
1046 {
1047         Log( LOG_ALERT, "User(s) with nick \"%s\" will be disconnected!", Nick );
1048         /* FIXME */
1049         Log( LOG_ALERT, "[Kill_Nick() not implemented - OOOPS!]" );
1050 } /* Kill_Nick */
1051
1052
1053 /* -eof- */