]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/irc-info.c
Include flags in RPL_WHOREPLY messages.
[ngircd-alex.git] / src / ngircd / irc-info.c
1 /*
2  * ngIRCd -- The Next Generation IRC Daemon
3  * Copyright (c)2001-2005 Alexander Barton (alex@barton.de)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * Please read the file COPYING, README and AUTHORS for more information.
10  *
11  * IRC info commands
12  */
13
14
15 #include "portab.h"
16
17 static char UNUSED id[] = "$Id: irc-info.c,v 1.43 2008/02/17 00:00:12 fw Exp $";
18
19 #include "imp.h"
20 #include <assert.h>
21 #include <errno.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <strings.h>
26
27 #include "ngircd.h"
28 #include "cvs-version.h"
29 #include "conn-func.h"
30 #include "conn-zip.h"
31 #include "client.h"
32 #include "channel.h"
33 #include "resolve.h"
34 #include "conf.h"
35 #include "defines.h"
36 #include "log.h"
37 #include "messages.h"
38 #include "match.h"
39 #include "tool.h"
40 #include "parse.h"
41 #include "irc-write.h"
42
43 #include "exp.h"
44 #include "irc-info.h"
45
46
47 GLOBAL bool
48 IRC_ADMIN(CLIENT *Client, REQUEST *Req )
49 {
50         CLIENT *target, *prefix;
51
52         assert( Client != NULL );
53         assert( Req != NULL );
54
55         /* Falsche Anzahl Parameter? */
56         if(( Req->argc > 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
57
58         /* Ziel suchen */
59         if( Req->argc == 1 ) target = Client_Search( Req->argv[0] );
60         else target = Client_ThisServer( );
61
62         /* Prefix ermitteln */
63         if( Client_Type( Client ) == CLIENT_SERVER ) prefix = Client_Search( Req->prefix );
64         else prefix = Client;
65         if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
66
67         /* An anderen Server weiterleiten? */
68         if( target != Client_ThisServer( ))
69         {
70                 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] );
71
72                 /* forwarden */
73                 IRC_WriteStrClientPrefix( target, prefix, "ADMIN %s", Req->argv[0] );
74                 return CONNECTED;
75         }
76
77         /* mit Versionsinfo antworten */
78         if( ! IRC_WriteStrClient( Client, RPL_ADMINME_MSG, Client_ID( prefix ), Conf_ServerName )) return DISCONNECTED;
79         if( ! IRC_WriteStrClient( Client, RPL_ADMINLOC1_MSG, Client_ID( prefix ), Conf_ServerAdmin1 )) return DISCONNECTED;
80         if( ! IRC_WriteStrClient( Client, RPL_ADMINLOC2_MSG, Client_ID( prefix ), Conf_ServerAdmin2 )) return DISCONNECTED;
81         if( ! IRC_WriteStrClient( Client, RPL_ADMINEMAIL_MSG, Client_ID( prefix ), Conf_ServerAdminMail )) return DISCONNECTED;
82
83         IRC_SetPenalty( Client, 1 );
84         return CONNECTED;
85 } /* IRC_ADMIN */
86
87
88 GLOBAL bool
89 IRC_ISON( CLIENT *Client, REQUEST *Req )
90 {
91         char rpl[COMMAND_LEN];
92         CLIENT *c;
93         char *ptr;
94         int i;
95
96         assert( Client != NULL );
97         assert( Req != NULL );
98
99         /* Falsche Anzahl Parameter? */
100         if(( Req->argc < 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
101
102         strlcpy( rpl, RPL_ISON_MSG, sizeof rpl );
103         for( i = 0; i < Req->argc; i++ )
104         {
105                 ptr = strtok( Req->argv[i], " " );
106                 while( ptr )
107                 {
108                         ngt_TrimStr( ptr );
109                         c = Client_Search( ptr );
110                         if( c && ( Client_Type( c ) == CLIENT_USER ))
111                         {
112                                 /* Dieser Nick ist "online" */
113                                 strlcat( rpl, ptr, sizeof( rpl ));
114                                 strlcat( rpl, " ", sizeof( rpl ));
115                         }
116                         ptr = strtok( NULL, " " );
117                 }
118         }
119         ngt_TrimLastChr(rpl, ' ');
120
121         return IRC_WriteStrClient( Client, rpl, Client_ID( Client ) );
122 } /* IRC_ISON */
123
124
125 GLOBAL bool
126 IRC_LINKS( CLIENT *Client, REQUEST *Req )
127 {
128         CLIENT *target, *from, *c;
129         char *mask;
130
131         assert( Client != NULL );
132         assert( Req != NULL );
133
134         /* Falsche Anzahl Parameter? */
135         if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
136
137         /* Server-Mask ermitteln */
138         if( Req->argc > 0 ) mask = Req->argv[Req->argc - 1];
139         else mask = "*";
140
141         /* Absender ermitteln */
142         if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
143         else from = Client;
144         if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
145
146         /* An anderen Server forwarden? */
147         if( Req->argc == 2 )
148         {
149                 target = Client_Search( Req->argv[0] );
150                 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
151                 else if( target != Client_ThisServer( )) return IRC_WriteStrClientPrefix( target, from, "LINKS %s %s", Req->argv[0], Req->argv[1] );
152         }
153
154         /* Wer ist der Absender? */
155         if( Client_Type( Client ) == CLIENT_SERVER ) target = Client_Search( Req->prefix );
156         else target = Client;
157         if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
158
159         c = Client_First( );
160         while( c )
161         {
162                 if( Client_Type( c ) == CLIENT_SERVER )
163                 {
164                         if( ! IRC_WriteStrClient( target, RPL_LINKS_MSG, Client_ID( target ), Client_ID( c ), Client_ID( Client_TopServer( c ) ? Client_TopServer( c ) : Client_ThisServer( )), Client_Hops( c ), Client_Info( c ))) return DISCONNECTED;
165                 }
166                 c = Client_Next( c );
167         }
168         
169         IRC_SetPenalty( target, 1 );
170         return IRC_WriteStrClient( target, RPL_ENDOFLINKS_MSG, Client_ID( target ), mask );
171 } /* IRC_LINKS */
172
173
174 GLOBAL bool
175 IRC_LUSERS( CLIENT *Client, REQUEST *Req )
176 {
177         CLIENT *target, *from;
178
179         assert( Client != NULL );
180         assert( Req != NULL );
181
182         /* Falsche Anzahl Parameter? */
183         if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
184
185         /* Absender ermitteln */
186         if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
187         else from = Client;
188         if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
189
190         /* An anderen Server forwarden? */
191         if( Req->argc == 2 )
192         {
193                 target = Client_Search( Req->argv[1] );
194                 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
195                 else if( target != Client_ThisServer( )) return IRC_WriteStrClientPrefix( target, from, "LUSERS %s %s", Req->argv[0], Req->argv[1] );
196         }
197
198         /* Wer ist der Absender? */
199         if( Client_Type( Client ) == CLIENT_SERVER ) target = Client_Search( Req->prefix );
200         else target = Client;
201         if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
202
203         IRC_Send_LUSERS( target );
204
205         IRC_SetPenalty( target, 1 );
206         return CONNECTED;
207 } /* IRC_LUSERS */
208
209
210 GLOBAL bool
211 IRC_MOTD( CLIENT *Client, REQUEST *Req )
212 {
213         CLIENT *from, *target;
214
215         assert( Client != NULL );
216         assert( Req != NULL );
217
218         /* Falsche Anzahl Parameter? */
219         if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
220
221         /* From aus Prefix ermitteln */
222         if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
223         else from = Client;
224         if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
225
226         if( Req->argc == 1 )
227         {
228                 /* an anderen Server forwarden */
229                 target = Client_Search( Req->argv[0] );
230                 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
231
232                 if( target != Client_ThisServer( ))
233                 {
234                         /* Ok, anderer Server ist das Ziel: forwarden */
235                         return IRC_WriteStrClientPrefix( target, from, "MOTD %s", Req->argv[0] );
236                 }
237         }
238
239         IRC_SetPenalty( from, 3 );
240         return IRC_Show_MOTD( from );
241 } /* IRC_MOTD */
242
243
244 GLOBAL bool
245 IRC_NAMES( CLIENT *Client, REQUEST *Req )
246 {
247         char rpl[COMMAND_LEN], *ptr;
248         CLIENT *target, *from, *c;
249         CHANNEL *chan;
250
251         assert( Client != NULL );
252         assert( Req != NULL );
253
254         /* Falsche Anzahl Parameter? */
255         if( Req->argc > 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
256
257         /* From aus Prefix ermitteln */
258         if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
259         else from = Client;
260         if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
261
262         if( Req->argc == 2 )
263         {
264                 /* an anderen Server forwarden */
265                 target = Client_Search( Req->argv[1] );
266                 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
267
268                 if( target != Client_ThisServer( ))
269                 {
270                         /* Ok, anderer Server ist das Ziel: forwarden */
271                         return IRC_WriteStrClientPrefix( target, from, "NAMES %s :%s", Req->argv[0], Req->argv[1] );
272                 }
273         }
274
275         if( Req->argc > 0 )
276         {
277                 /* bestimmte Channels durchgehen */
278                 ptr = strtok( Req->argv[0], "," );
279                 while( ptr )
280                 {
281                         chan = Channel_Search( ptr );
282                         if( chan )
283                         {
284                                 /* Namen ausgeben */
285                                 if( ! IRC_Send_NAMES( from, chan )) return DISCONNECTED;
286                         }
287                         if( ! IRC_WriteStrClient( from, RPL_ENDOFNAMES_MSG, Client_ID( from ), ptr )) return DISCONNECTED;
288
289                         /* naechsten Namen ermitteln */
290                         ptr = strtok( NULL, "," );
291                 }
292                 return CONNECTED;
293         }
294
295         /* alle Channels durchgehen */
296         chan = Channel_First( );
297         while( chan )
298         {
299                 /* Namen ausgeben */
300                 if( ! IRC_Send_NAMES( from, chan )) return DISCONNECTED;
301
302                 /* naechster Channel */
303                 chan = Channel_Next( chan );
304         }
305
306         /* Nun noch alle Clients ausgeben, die in keinem Channel sind */
307         c = Client_First( );
308         snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" );
309         while( c )
310         {
311                 if(( Client_Type( c ) == CLIENT_USER ) && ( Channel_FirstChannelOf( c ) == NULL ) && ( ! strchr( Client_Modes( c ), 'i' )))
312                 {
313                         /* Okay, das ist ein User: anhaengen */
314                         if( rpl[strlen( rpl ) - 1] != ':' ) strlcat( rpl, " ", sizeof( rpl ));
315                         strlcat( rpl, Client_ID( c ), sizeof( rpl ));
316
317                         if( strlen( rpl ) > ( LINE_LEN - CLIENT_NICK_LEN - 4 ))
318                         {
319                                 /* Zeile wird zu lang: senden! */
320                                 if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED;
321                                 snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" );
322                         }
323                 }
324
325                 /* naechster Client */
326                 c = Client_Next( c );
327         }
328         if( rpl[strlen( rpl ) - 1] != ':')
329         {
330                 /* es wurden User gefunden */
331                 if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED;
332         }
333
334         IRC_SetPenalty( from, 1 );
335         return IRC_WriteStrClient( from, RPL_ENDOFNAMES_MSG, Client_ID( from ), "*" );
336 } /* IRC_NAMES */
337
338
339 static unsigned int
340 t_diff(time_t *t, const time_t div)
341 {
342         time_t diff, remain;
343
344         diff = *t / div;
345
346         remain = diff * div;
347         *t -= remain;
348
349         return diff;
350 }
351
352
353 static unsigned int
354 uptime_days(time_t *now)
355 {
356         return t_diff(now, 60 * 60 * 24);
357 }
358
359
360 static unsigned int
361 uptime_hrs(time_t *now)
362 {
363         return t_diff(now, 60 * 60);
364 }
365
366
367 static unsigned int
368 uptime_mins(time_t *now)
369 {
370          return t_diff(now, 60);
371 }
372
373
374 GLOBAL bool
375 IRC_STATS( CLIENT *Client, REQUEST *Req )
376 {
377         CLIENT *from, *target, *cl;
378         CONN_ID con;
379         char query;
380         COMMAND *cmd;
381         time_t time_now;
382         unsigned int days, hrs, mins;
383
384         assert( Client != NULL );
385         assert( Req != NULL );
386
387         /* Falsche Anzahl Parameter? */
388         if (Req->argc > 2)
389                 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command);
390
391         /* From aus Prefix ermitteln */
392         if (Client_Type(Client) == CLIENT_SERVER)
393                 from = Client_Search(Req->prefix);
394         else
395                 from = Client;
396
397         if (! from)
398                 return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix);
399
400         if (Req->argc == 2) {
401                 /* an anderen Server forwarden */
402                 target = Client_Search( Req->argv[1] );
403                 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER ))
404                         return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
405
406                 if( target != Client_ThisServer()) {
407                         /* Ok, anderer Server ist das Ziel: forwarden */
408                         return IRC_WriteStrClientPrefix( target, from, "STATS %s %s", Req->argv[0], Req->argv[1] );
409                 }
410         }
411
412         if (Req->argc > 0)
413                 query = Req->argv[0][0] ? Req->argv[0][0] : '*';
414         else
415                 query = '*';
416
417         switch (query) {
418                 case 'l':       /* Links */
419                 case 'L':
420                         time_now = time(NULL);
421                         for (con = Conn_First(); con != NONE ;con = Conn_Next(con)) {
422                                 cl = Conn_GetClient(con);
423                                 if (!cl)
424                                         continue;
425                                 if ((Client_Type(cl) == CLIENT_SERVER) || (cl == Client)) {
426                                         /* Server link or our own connection */
427 #ifdef ZLIB
428                                         if (Conn_Options(con) & CONN_ZIP) {
429                                                 if (!IRC_WriteStrClient(from, RPL_STATSLINKINFOZIP_MSG,
430                                                         Client_ID(from), Client_Mask(cl), Conn_SendQ(con),
431                                                         Conn_SendMsg(con), Zip_SendBytes(con), Conn_SendBytes(con),
432                                                         Conn_RecvMsg(con), Zip_RecvBytes(con), Conn_RecvBytes(con), (long)(time_now - Conn_StartTime(con))))
433                                                                 return DISCONNECTED;
434                                                 continue;
435                                         }
436 #endif
437                                         if (!IRC_WriteStrClient(from, RPL_STATSLINKINFO_MSG, Client_ID(from),
438                                                 Client_Mask(cl), Conn_SendQ(con), Conn_SendMsg(con), Conn_SendBytes(con),
439                                                 Conn_RecvMsg(con), Conn_RecvBytes(con), (long)(time_now - Conn_StartTime(con))))
440                                                         return DISCONNECTED;
441                                 }
442                         }
443                         break;
444                 case 'm':       /* IRC-Commands */
445                 case 'M':
446                         cmd = Parse_GetCommandStruct( );
447                         for (; cmd->name ; cmd++) {
448                                 if (cmd->lcount == 0 && cmd->rcount == 0)
449                                         continue;
450                                 if (!IRC_WriteStrClient(from, RPL_STATSCOMMANDS_MSG, Client_ID(from),
451                                                 cmd->name, cmd->lcount, cmd->bytes, cmd->rcount))
452                                                         return DISCONNECTED;
453                         }
454                         break;
455                 case 'u':       /* server uptime */
456                 case 'U':
457                         time_now = time(NULL) - NGIRCd_Start;
458                         days = uptime_days(&time_now);
459                         hrs = uptime_hrs(&time_now);
460                         mins = uptime_mins(&time_now);
461                         if (!IRC_WriteStrClient(from, RPL_STATSUPTIME, Client_ID(from),
462                                         days, hrs, mins, (unsigned int) time_now))
463                                                 return DISCONNECTED;
464                         break;
465         }
466
467         IRC_SetPenalty(from, 2);
468         return IRC_WriteStrClient(from, RPL_ENDOFSTATS_MSG, Client_ID(from), query);
469 } /* IRC_STATS */
470
471
472 GLOBAL bool
473 IRC_TIME( CLIENT *Client, REQUEST *Req )
474 {
475         CLIENT *from, *target;
476         char t_str[64];
477         time_t t;
478
479         assert( Client != NULL );
480         assert( Req != NULL );
481
482         /* Falsche Anzahl Parameter? */
483         if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
484
485         /* From aus Prefix ermitteln */
486         if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
487         else from = Client;
488         if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
489
490         if( Req->argc == 1 )
491         {
492                 /* an anderen Server forwarden */
493                 target = Client_Search( Req->argv[0] );
494                 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] );
495
496                 if( target != Client_ThisServer( ))
497                 {
498                         /* Ok, anderer Server ist das Ziel: forwarden */
499                         return IRC_WriteStrClientPrefix( target, from, "TIME %s", Req->argv[0] );
500                 }
501         }
502
503         t = time( NULL );
504         (void)strftime( t_str, 60, "%A %B %d %Y -- %H:%M %Z", localtime( &t ));
505         return IRC_WriteStrClient( from, RPL_TIME_MSG, Client_ID( from ), Client_ID( Client_ThisServer( )), t_str );
506 } /* IRC_TIME */
507
508
509 GLOBAL bool
510 IRC_USERHOST( CLIENT *Client, REQUEST *Req )
511 {
512         char rpl[COMMAND_LEN];
513         CLIENT *c;
514         int max, i;
515
516         assert( Client != NULL );
517         assert( Req != NULL );
518
519         /* Falsche Anzahl Parameter? */
520         if(( Req->argc < 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
521
522         if( Req->argc > 5 ) max = 5;
523         else max = Req->argc;
524
525         strlcpy( rpl, RPL_USERHOST_MSG, sizeof rpl );
526         for( i = 0; i < max; i++ )
527         {
528                 c = Client_Search( Req->argv[i] );
529                 if( c && ( Client_Type( c ) == CLIENT_USER ))
530                 {
531                         /* Dieser Nick ist "online" */
532                         strlcat( rpl, Client_ID( c ), sizeof( rpl ));
533                         if( Client_HasMode( c, 'o' )) strlcat( rpl, "*", sizeof( rpl ));
534                         strlcat( rpl, "=", sizeof( rpl ));
535                         if( Client_HasMode( c, 'a' )) strlcat( rpl, "-", sizeof( rpl ));
536                         else strlcat( rpl, "+", sizeof( rpl ));
537                         strlcat( rpl, Client_User( c ), sizeof( rpl ));
538                         strlcat( rpl, "@", sizeof( rpl ));
539                         strlcat( rpl, Client_Hostname( c ), sizeof( rpl ));
540                         strlcat( rpl, " ", sizeof( rpl ));
541                 }
542         }
543         ngt_TrimLastChr( rpl, ' ');
544
545         return IRC_WriteStrClient( Client, rpl, Client_ID( Client ) );
546 } /* IRC_USERHOST */
547
548
549 GLOBAL bool
550 IRC_VERSION( CLIENT *Client, REQUEST *Req )
551 {
552         CLIENT *target, *prefix;
553 #ifdef CVSDATE
554         char ver[12], vertxt[30];
555 #endif
556
557         assert( Client != NULL );
558         assert( Req != NULL );
559
560         /* Falsche Anzahl Parameter? */
561         if(( Req->argc > 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
562
563         /* Ziel suchen */
564         if( Req->argc == 1 ) target = Client_Search( Req->argv[0] );
565         else target = Client_ThisServer( );
566
567         /* Prefix ermitteln */
568         if( Client_Type( Client ) == CLIENT_SERVER ) prefix = Client_Search( Req->prefix );
569         else prefix = Client;
570         if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
571
572         /* An anderen Server weiterleiten? */
573         if( target != Client_ThisServer( ))
574         {
575                 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] );
576
577                 /* forwarden */
578                 IRC_WriteStrClientPrefix( target, prefix, "VERSION %s", Req->argv[0] );
579                 return CONNECTED;
580         }
581
582         /* mit Versionsinfo antworten */
583         IRC_SetPenalty( Client, 1 );
584 #ifdef CVSDATE
585         strlcpy( ver, CVSDATE, sizeof( ver ));
586         strncpy( ver + 4, ver + 5, 2 );
587         strncpy( ver + 6, ver + 8, 3 );
588         snprintf( vertxt, sizeof( vertxt ), "%s(%s)", PACKAGE_VERSION, ver );
589         return IRC_WriteStrClient( Client, RPL_VERSION_MSG, Client_ID( prefix ), PACKAGE_NAME, vertxt, NGIRCd_DebugLevel, Conf_ServerName, NGIRCd_VersionAddition );
590 #else
591         return IRC_WriteStrClient( Client, RPL_VERSION_MSG, Client_ID( prefix ), PACKAGE_NAME, PACKAGE_VERSION, NGIRCd_DebugLevel, Conf_ServerName, NGIRCd_VersionAddition );
592 #endif
593 } /* IRC_VERSION */
594
595
596
597 static bool
598 write_whoreply(CLIENT *Client, CLIENT *c, const char *channelname, const char *flags)
599 {
600         return IRC_WriteStrClient(Client, RPL_WHOREPLY_MSG, Client_ID(Client), channelname,
601                         Client_User(c), Client_Hostname(c), Client_ID(Client_Introducer(c)), Client_ID(c),
602                         flags, Client_Hops(c), Client_Info(c));
603 }
604
605
606 static const char *
607 who_flags_status(const char *client_modes)
608 {
609         if (strchr(client_modes, 'a'))
610                 return "G"; /* away */
611         return "H";
612 }
613
614
615 static const char *
616 who_flags_qualifier(const char *chan_user_modes)
617 {
618         if (strchr(chan_user_modes, 'o'))
619                 return "@";
620         else if (strchr(chan_user_modes, 'v'))
621                 return "+";
622         return "";
623 }
624
625
626 static bool
627 IRC_Send_WHO(CLIENT *Client, CHANNEL *Chan, bool OnlyOps)
628 {
629         bool is_visible, is_member, is_ircop;
630         CL2CHAN *cl2chan;
631         const char *client_modes;
632         const char *chan_user_modes;
633         char flags[8];
634         CLIENT *c;
635
636         assert( Client != NULL );
637         assert( Chan != NULL );
638
639         is_member = Channel_IsMemberOf(Chan, Client);
640
641         /* Secret channel? */
642         if (!is_member && strchr(Channel_Modes(Chan), 's'))
643                 return CONNECTED;
644
645         cl2chan = Channel_FirstMember(Chan);
646         for (; cl2chan ; cl2chan = Channel_NextMember(Chan, cl2chan)) {
647                 c = Channel_GetClient(cl2chan);
648
649                 client_modes = Client_Modes(c);
650                 is_ircop = strchr(client_modes, 'o') != NULL;
651                 if (OnlyOps && !is_ircop)
652                         continue;
653
654                 is_visible = strchr(client_modes, 'i') == NULL;
655                 if (is_member || is_visible) {
656                         strcpy(flags, who_flags_status(client_modes));
657                         if (is_ircop)
658                                 strlcat(flags, "*", sizeof(flags));
659
660                         chan_user_modes = Channel_UserModes(Chan, c);
661                         strlcat(flags, who_flags_qualifier(chan_user_modes), sizeof(flags));
662
663                         if (!write_whoreply(Client, c, Channel_Name(Chan), flags))
664                                 return DISCONNECTED;
665                 }
666         }
667         return IRC_WriteStrClient(Client, RPL_ENDOFWHO_MSG, Client_ID(Client), Channel_Name(Chan));
668 } /* IRC_Send_WHO */
669
670
671
672 static bool
673 MatchCaseInsensitive(const char *pattern, const char *searchme)
674 {
675         char haystack[COMMAND_LEN];
676
677         strlcpy(haystack, searchme, sizeof(haystack));
678
679         ngt_LowerStr(haystack);
680
681         return Match(pattern, haystack);
682 }
683
684
685 GLOBAL bool
686 IRC_WHO( CLIENT *Client, REQUEST *Req )
687 {
688         bool only_ops, have_arg, client_match;
689         const char *channelname, *client_modes, *chan_user_modes;
690         char pattern[COMMAND_LEN];
691         char flags[4];
692         CL2CHAN *cl2chan;
693         CHANNEL *chan, *cn;
694         CLIENT *c;
695
696         assert( Client != NULL );
697         assert( Req != NULL );
698
699         if (Req->argc > 2)
700                 return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
701
702         only_ops = false;
703         have_arg = false;
704
705         if (Req->argc == 2) {
706                 if (strcmp(Req->argv[1], "o") == 0)
707                         only_ops = true;
708 #ifdef STRICT_RFC
709                 else return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command);
710 #endif
711         }
712
713         IRC_SetPenalty(Client, 1);
714         if (Req->argc >= 1) { /* Channel or Mask. */
715                 chan = Channel_Search(Req->argv[0]);
716                 if (chan)
717                         return IRC_Send_WHO(Client, chan, only_ops);
718                 if (strcmp(Req->argv[0], "0") != 0) { /* RFC stupidity, same as no arguments */
719                         have_arg = true;
720                         strlcpy(pattern, Req->argv[0], sizeof(pattern));
721                         ngt_LowerStr(pattern);
722                         IRC_SetPenalty(Client, 3);
723                 }
724         }
725
726         for (c = Client_First(); c != NULL; c = Client_Next(c)) {
727                 if (Client_Type(c) != CLIENT_USER)
728                         continue;
729                  /*
730                   * RFC 2812, 3.6.1:
731                   * In the absence of the parameter, all visible (users who aren't
732                   * invisible (user mode +i) and who don't have a common channel
733                   * with the requesting client) are listed.
734                   *
735                   * The same result can be achieved by using a [sic] of "0"
736                   * or any wildcard which will end up matching every visible user.
737                   *
738                   * The [sic] passed to WHO is matched against users' host, server, real name and
739                   * nickname if the channel cannot be found.
740                   */
741                 client_modes = Client_Modes(c);
742                 if (strchr(client_modes, 'i'))
743                         continue;
744
745                 if (only_ops && !strchr(client_modes, 'o'))
746                         continue;
747
748                 if (have_arg) { /* match pattern against user host/server/name/nick */
749                         client_match = MatchCaseInsensitive(pattern, Client_Hostname(c)); /* user's host */
750                         if (!client_match)
751                                 client_match = MatchCaseInsensitive(pattern, Client_ID(Client_Introducer(c))); /* server */
752                         if (!client_match)
753                                 client_match = Match(Req->argv[0], Client_Info(c)); /* realname */
754                         if (!client_match)
755                                 client_match = MatchCaseInsensitive(pattern, Client_ID(c)); /* nick name */
756
757                         if (!client_match) /* This isn't the client you're looking for */
758                                 continue;
759                 }
760
761                 strcpy(flags, who_flags_status(client_modes));
762
763                 if (strchr(client_modes, 'o')) /* this client is an operator */
764                         strlcat(flags, "*", sizeof(flags));
765
766                 /* Search suitable channel */
767                 cl2chan = Channel_FirstChannelOf(c);
768                 while (cl2chan) {
769                         cn = Channel_GetChannel(cl2chan);
770                         if (Channel_IsMemberOf(cn, Client) ||
771                                     !strchr(Channel_Modes(cn), 's'))
772                         {
773                                 channelname = Channel_Name(cn);
774                                 break;
775                         }
776                         cl2chan = Channel_NextChannelOf(c, cl2chan);
777                 }
778                 if (cl2chan) {
779                         chan = Channel_GetChannel(cl2chan);
780                         chan_user_modes = Channel_UserModes(chan, c);
781                         strlcat(flags, who_flags_qualifier(chan_user_modes), sizeof(flags));
782                 } else
783                         channelname = "*";
784
785                 if (!write_whoreply(Client, c, channelname, flags))
786                         return DISCONNECTED;
787         }
788
789         if (Req->argc > 0)
790                 channelname = Req->argv[0];
791         else
792                 channelname = "*";
793
794         return IRC_WriteStrClient(Client, RPL_ENDOFWHO_MSG, Client_ID(Client), channelname);
795 } /* IRC_WHO */
796
797
798 GLOBAL bool
799 IRC_WHOIS( CLIENT *Client, REQUEST *Req )
800 {
801         CLIENT *from, *target, *c;
802         char str[LINE_LEN + 1];
803         CL2CHAN *cl2chan;
804         CHANNEL *chan;
805
806         assert( Client != NULL );
807         assert( Req != NULL );
808
809         /* Bad number of parameters? */
810         if(( Req->argc < 1 ) || ( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
811
812         /* Search client */
813         c = Client_Search( Req->argv[Req->argc - 1] );
814         if(( ! c ) || ( Client_Type( c ) != CLIENT_USER )) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[Req->argc - 1] );
815
816         /* Search sender of the WHOIS */
817         if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
818         else from = Client;
819         if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
820
821         /* Forward to other server? */
822         if( Req->argc > 1 )
823         {
824                 /* Search target server (can be specified as nick of that server!) */
825                 target = Client_Search( Req->argv[0] );
826                 if( ! target ) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
827         }
828         else target = Client_ThisServer( );
829
830         assert( target != NULL );
831
832         if(( Client_NextHop( target ) != Client_ThisServer( )) && ( Client_Type( Client_NextHop( target )) == CLIENT_SERVER )) return IRC_WriteStrClientPrefix( target, from, "WHOIS %s :%s", Req->argv[0], Req->argv[1] );
833
834         /* Nick, user and name */
835         if( ! IRC_WriteStrClient( from, RPL_WHOISUSER_MSG, Client_ID( from ), Client_ID( c ), Client_User( c ), Client_Hostname( c ), Client_Info( c ))) return DISCONNECTED;
836
837         /* Server */
838         if( ! IRC_WriteStrClient( from, RPL_WHOISSERVER_MSG, Client_ID( from ), Client_ID( c ), Client_ID( Client_Introducer( c )), Client_Info( Client_Introducer( c )))) return DISCONNECTED;
839
840         /* Channels */
841         snprintf( str, sizeof( str ), RPL_WHOISCHANNELS_MSG, Client_ID( from ), Client_ID( c ));
842         cl2chan = Channel_FirstChannelOf( c );
843         while( cl2chan )
844         {
845                 chan = Channel_GetChannel( cl2chan );
846                 assert( chan != NULL );
847
848                 /* next */
849                 cl2chan = Channel_NextChannelOf( c, cl2chan );
850
851                 /* Secret channel? */
852                 if( strchr( Channel_Modes( chan ), 's' ) && ! Channel_IsMemberOf( chan, Client )) continue;
853
854                 /* Concatenate channel names */
855                 if( str[strlen( str ) - 1] != ':' ) strlcat( str, " ", sizeof( str ));
856                 if( strchr( Channel_UserModes( chan, c ), 'o' )) strlcat( str, "@", sizeof( str ));
857                 else if( strchr( Channel_UserModes( chan, c ), 'v' )) strlcat( str, "+", sizeof( str ));
858                 strlcat( str, Channel_Name( chan ), sizeof( str ));
859
860                 if( strlen( str ) > ( LINE_LEN - CHANNEL_NAME_LEN - 4 ))
861                 {
862                         /* Line becomes too long: send it! */
863                         if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED;
864                         snprintf( str, sizeof( str ), RPL_WHOISCHANNELS_MSG, Client_ID( from ), Client_ID( c ));
865                 }
866         }
867         if( str[strlen( str ) - 1] != ':')
868         {
869                 /* There is data left to send: */
870                 if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED;
871         }
872
873         /* IRC-Operator? */
874         if( Client_HasMode( c, 'o' ))
875         {
876                 if( ! IRC_WriteStrClient( from, RPL_WHOISOPERATOR_MSG, Client_ID( from ), Client_ID( c ))) return DISCONNECTED;
877         }
878
879         /* Idle and signon time (local clients only!) */
880         if (Client_Conn(c) > NONE ) {
881                 if (! IRC_WriteStrClient(from, RPL_WHOISIDLE_MSG,
882                         Client_ID(from), Client_ID(c),
883                         (unsigned long)Conn_GetIdle(Client_Conn(c)),
884                         (unsigned long)Conn_GetSignon(Client_Conn(c))))
885                                 return DISCONNECTED;
886         }
887
888         /* Away? */
889         if( Client_HasMode( c, 'a' ))
890         {
891                 if( ! IRC_WriteStrClient( from, RPL_AWAY_MSG, Client_ID( from ), Client_ID( c ), Client_Away( c ))) return DISCONNECTED;
892         }
893
894         /* End of Whois */
895         return IRC_WriteStrClient( from, RPL_ENDOFWHOIS_MSG, Client_ID( from ), Client_ID( c ));
896 } /* IRC_WHOIS */
897
898
899 /**
900  * IRC "WHOWAS" function.
901  * This function implements the IRC command "WHOWHAS". It handles local
902  * requests and request that should be forwarded to other servers.
903  */
904 GLOBAL bool
905 IRC_WHOWAS( CLIENT *Client, REQUEST *Req )
906 {
907         CLIENT *target, *prefix;
908         WHOWAS *whowas;
909         int max, last, count, i;
910         char t_str[60];
911         
912         assert( Client != NULL );
913         assert( Req != NULL );
914
915         /* Wrong number of parameters? */
916         if(( Req->argc < 1 ) || ( Req->argc > 3 ))
917                 return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG,
918                                            Client_ID( Client ), Req->command );
919
920         /* Search taget */
921         if( Req->argc == 3 )
922                 target = Client_Search( Req->argv[2] );
923         else
924                 target = Client_ThisServer( );
925
926         /* Get prefix */
927         if( Client_Type( Client ) == CLIENT_SERVER )
928                 prefix = Client_Search( Req->prefix );
929         else
930                 prefix = Client;
931
932         if( ! prefix )
933                 return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG,
934                                            Client_ID( Client ), Req->prefix );
935
936         /* Forward to other server? */
937         if( target != Client_ThisServer( ))
938         {
939                 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER ))
940                         return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG,
941                                                    Client_ID( prefix ),
942                                                    Req->argv[2] );
943
944                 /* Forward */
945                 IRC_WriteStrClientPrefix( target, prefix, "WHOWAS %s %s %s",
946                                           Req->argv[0], Req->argv[1],
947                                           Req->argv[2] );
948                 return CONNECTED;
949         }
950         
951         whowas = Client_GetWhowas( );
952         last = Client_GetLastWhowasIndex( );
953         if( last < 0 ) last = 0;
954         
955         if( Req->argc > 1 )
956         {
957                 max = atoi( Req->argv[1] );
958                 if( max < 1 ) max = MAX_WHOWAS;
959         }
960         else
961                 max = DEFAULT_WHOWAS;
962         
963         i = last;
964         count = 0;
965         do
966         {
967                 /* Used entry? */
968                 if( whowas[i].time > 0 &&
969                     strcasecmp( Req->argv[0], whowas[i].id ) == 0 )
970                 {
971                         (void)strftime( t_str, sizeof(t_str),
972                                         "%a %b %d %H:%M:%S %Y",
973                                         localtime( &whowas[i].time ));
974                 
975                         if( ! IRC_WriteStrClient( prefix, RPL_WHOWASUSER_MSG,
976                                                   Client_ID( prefix ),
977                                                   whowas[i].id,
978                                                   whowas[i].user,
979                                                   whowas[i].host, 
980                                                   whowas[i].info ))
981                                 return DISCONNECTED;
982                 
983                         if( ! IRC_WriteStrClient( prefix, RPL_WHOISSERVER_MSG,
984                                                   Client_ID( prefix ),
985                                                   whowas[i].id,
986                                                   whowas[i].server, t_str ))
987                                 return DISCONNECTED;
988                 
989                         count++;
990                         if( count >= max ) break;
991                 }
992                 
993                 /* previos entry */
994                 i--;
995
996                 /* "underflow", wrap around */
997                 if( i < 0 ) i = MAX_WHOWAS - 1;
998         } while( i != last );
999         
1000         return IRC_WriteStrClient( prefix, RPL_ENDOFWHOWAS_MSG,
1001                                    Client_ID( prefix ), Req->argv[0] );
1002 } /* IRC_WHOWAS */
1003
1004
1005 GLOBAL bool
1006 IRC_Send_LUSERS( CLIENT *Client )
1007 {
1008         unsigned long cnt;
1009 #ifndef STRICT_RFC
1010         unsigned long max;
1011 #endif
1012
1013         assert( Client != NULL );
1014
1015         /* Users, services and serevers in the network */
1016         if( ! IRC_WriteStrClient( Client, RPL_LUSERCLIENT_MSG, Client_ID( Client ), Client_UserCount( ), Client_ServiceCount( ), Client_ServerCount( ))) return DISCONNECTED;
1017
1018         /* Number of IRC operators */
1019         cnt = Client_OperCount( );
1020         if( cnt > 0 )
1021         {
1022                 if( ! IRC_WriteStrClient( Client, RPL_LUSEROP_MSG, Client_ID( Client ), cnt )) return DISCONNECTED;
1023         }
1024
1025         /* Unknown connections */
1026         cnt = Client_UnknownCount( );
1027         if( cnt > 0 )
1028         {
1029                 if( ! IRC_WriteStrClient( Client, RPL_LUSERUNKNOWN_MSG, Client_ID( Client ), cnt )) return DISCONNECTED;
1030         }
1031
1032         /* Number of created channels */
1033         if( ! IRC_WriteStrClient( Client, RPL_LUSERCHANNELS_MSG, Client_ID( Client ), Channel_Count( ))) return DISCONNECTED;
1034
1035         /* Number of local users, services and servers */
1036         if( ! IRC_WriteStrClient( Client, RPL_LUSERME_MSG, Client_ID( Client ), Client_MyUserCount( ), Client_MyServiceCount( ), Client_MyServerCount( ))) return DISCONNECTED;
1037
1038 #ifndef STRICT_RFC
1039         /* Maximum number of local users */
1040         cnt = Client_MyUserCount();
1041         max = Client_MyMaxUserCount();
1042         if (! IRC_WriteStrClient(Client, RPL_LOCALUSERS_MSG, Client_ID(Client),
1043                         cnt, max, cnt, max))
1044                 return DISCONNECTED;
1045         /* Maximum number of users in the network */
1046         cnt = Client_UserCount();
1047         max = Client_MaxUserCount();
1048         if(! IRC_WriteStrClient(Client, RPL_NETUSERS_MSG, Client_ID(Client),
1049                         cnt, max, cnt, max))
1050                 return DISCONNECTED;
1051 #endif
1052         
1053         return CONNECTED;
1054 } /* IRC_Send_LUSERS */
1055
1056
1057 static bool
1058 Show_MOTD_Start(CLIENT *Client)
1059 {
1060         return IRC_WriteStrClient(Client, RPL_MOTDSTART_MSG,
1061                 Client_ID( Client ), Client_ID( Client_ThisServer( )));
1062 }
1063
1064 static bool
1065 Show_MOTD_Sendline(CLIENT *Client, const char *msg)
1066 {
1067         return IRC_WriteStrClient(Client, RPL_MOTD_MSG, Client_ID( Client ), msg);
1068 }
1069
1070 static bool
1071 Show_MOTD_End(CLIENT *Client)
1072 {
1073         return IRC_WriteStrClient( Client, RPL_ENDOFMOTD_MSG, Client_ID( Client ));
1074 }
1075
1076
1077 GLOBAL bool
1078 IRC_Show_MOTD( CLIENT *Client )
1079 {
1080         char line[127];
1081         FILE *fd;
1082
1083         assert( Client != NULL );
1084
1085         if (Conf_MotdPhrase[0]) {
1086                 if (!Show_MOTD_Start(Client))
1087                         return DISCONNECTED;
1088                 if (!Show_MOTD_Sendline(Client, Conf_MotdPhrase))
1089                         return DISCONNECTED;
1090
1091                 return Show_MOTD_End(Client);
1092         }
1093
1094         fd = fopen( Conf_MotdFile, "r" );
1095         if( ! fd ) {
1096                 Log( LOG_WARNING, "Can't read MOTD file \"%s\": %s", Conf_MotdFile, strerror( errno ));
1097                 return IRC_WriteStrClient( Client, ERR_NOMOTD_MSG, Client_ID( Client ) );
1098         }
1099
1100         if (!Show_MOTD_Start( Client )) {
1101                 fclose(fd);
1102                 return false;
1103         }
1104
1105         while (fgets( line, (int)sizeof line, fd )) {
1106                 ngt_TrimLastChr( line, '\n');
1107
1108                 if( ! Show_MOTD_Sendline( Client, line)) {
1109                         fclose( fd );
1110                         return false;
1111                 }
1112         }
1113         fclose(fd);
1114         return Show_MOTD_End(Client);
1115 } /* IRC_Show_MOTD */
1116
1117
1118 GLOBAL bool
1119 IRC_Send_NAMES( CLIENT *Client, CHANNEL *Chan )
1120 {
1121         bool is_visible, is_member;
1122         char str[LINE_LEN + 1];
1123         CL2CHAN *cl2chan;
1124         CLIENT *cl;
1125
1126         assert( Client != NULL );
1127         assert( Chan != NULL );
1128
1129         if( Channel_IsMemberOf( Chan, Client )) is_member = true;
1130         else is_member = false;
1131
1132         /* Secret channel? */
1133         if( ! is_member && strchr( Channel_Modes( Chan ), 's' )) return CONNECTED;
1134
1135         /* Alle Mitglieder suchen */
1136         snprintf( str, sizeof( str ), RPL_NAMREPLY_MSG, Client_ID( Client ), "=", Channel_Name( Chan ));
1137         cl2chan = Channel_FirstMember( Chan );
1138         while( cl2chan )
1139         {
1140                 cl = Channel_GetClient( cl2chan );
1141
1142                 if( strchr( Client_Modes( cl ), 'i' )) is_visible = false;
1143                 else is_visible = true;
1144
1145                 if( is_member || is_visible )
1146                 {
1147                         /* Nick anhaengen */
1148                         if( str[strlen( str ) - 1] != ':' ) strlcat( str, " ", sizeof( str ));
1149                         if( strchr( Channel_UserModes( Chan, cl ), 'o' )) strlcat( str, "@", sizeof( str ));
1150                         else if( strchr( Channel_UserModes( Chan, cl ), 'v' )) strlcat( str, "+", sizeof( str ));
1151                         strlcat( str, Client_ID( cl ), sizeof( str ));
1152
1153                         if( strlen( str ) > ( LINE_LEN - CLIENT_NICK_LEN - 4 ))
1154                         {
1155                                 /* Zeile wird zu lang: senden! */
1156                                 if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED;
1157                                 snprintf( str, sizeof( str ), RPL_NAMREPLY_MSG, Client_ID( Client ), "=", Channel_Name( Chan ));
1158                         }
1159                 }
1160
1161                 /* naechstes Mitglied suchen */
1162                 cl2chan = Channel_NextMember( Chan, cl2chan );
1163         }
1164         if( str[strlen( str ) - 1] != ':')
1165         {
1166                 /* Es sind noch Daten da, die gesendet werden muessen */
1167                 if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED;
1168         }
1169
1170         return CONNECTED;
1171 } /* IRC_Send_NAMES */
1172
1173
1174
1175 /**
1176  * Send the ISUPPORT numeric (005).
1177  * This numeric indicates the features that are supported by this server.
1178  * See <http://www.irc.org/tech_docs/005.html> for details.
1179  */
1180 GLOBAL bool
1181 IRC_Send_ISUPPORT PARAMS((CLIENT * Client))
1182 {
1183         if (!IRC_WriteStrClient(Client, RPL_ISUPPORT1_MSG, Client_ID(Client),
1184                                 Conf_MaxJoins))
1185                 return DISCONNECTED;
1186         return IRC_WriteStrClient(Client, RPL_ISUPPORT2_MSG, Client_ID(Client),
1187                                   CHANNEL_NAME_LEN - 1, Conf_MaxNickLength - 1,
1188                                   COMMAND_LEN - 23, CLIENT_AWAY_LEN - 1,
1189                                   COMMAND_LEN - 113);
1190 } /* IRC_Send_ISUPPORT */
1191
1192
1193 /* -eof- */