]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/irc-info.c
Make IRC_WHO also search username/servername/hostname.
[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.42 2008/02/11 11:06:31 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 bool
607 IRC_Send_WHO(CLIENT *Client, CHANNEL *Chan, bool OnlyOps)
608 {
609         bool is_visible, is_member, is_ircop;
610         CL2CHAN *cl2chan;
611         const char *client_modes;
612         const char *chan_user_modes;
613         char flags[8];
614         CLIENT *c;
615
616         assert( Client != NULL );
617         assert( Chan != NULL );
618
619         is_member = Channel_IsMemberOf(Chan, Client);
620
621         /* Secret channel? */
622         if (!is_member && strchr(Channel_Modes(Chan), 's'))
623                 return CONNECTED;
624
625         cl2chan = Channel_FirstMember(Chan);
626         for (; cl2chan ; cl2chan = Channel_NextMember(Chan, cl2chan)) {
627                 c = Channel_GetClient(cl2chan);
628
629                 client_modes = Client_Modes(c);
630                 is_ircop = strchr(client_modes, 'o') != NULL;
631                 if (OnlyOps && !is_ircop)
632                         continue;
633
634                 is_visible = strchr(client_modes, 'i') == NULL;
635                 if (is_member || is_visible) {
636                         if (strchr(client_modes, 'a'))
637                                 strcpy(flags, "G"); /* away */
638                         else
639                                 strcpy(flags, "H");
640                         if (is_ircop)
641                                 strlcat(flags, "*", sizeof(flags));
642
643                         chan_user_modes = Channel_UserModes(Chan, c);
644                         if (strchr(chan_user_modes, 'o'))
645                                 strlcat(flags, "@", sizeof(flags));
646                         else if (strchr(chan_user_modes, 'v'))
647                                 strlcat(flags, "+", sizeof(flags));
648
649                         if (!write_whoreply(Client, c, Channel_Name(Chan), flags))
650                                 return DISCONNECTED;
651                 }
652         }
653         return IRC_WriteStrClient(Client, RPL_ENDOFWHO_MSG, Client_ID(Client), Channel_Name(Chan));
654 } /* IRC_Send_WHO */
655
656
657 static bool
658 MatchCaseInsensitive(const char *pattern, const char *searchme)
659 {
660         char haystack[COMMAND_LEN];
661
662         strlcpy(haystack, searchme, sizeof(haystack));
663
664         ngt_LowerStr(haystack);
665
666         return Match(pattern, haystack);
667 }
668
669
670 GLOBAL bool
671 IRC_WHO( CLIENT *Client, REQUEST *Req )
672 {
673         bool only_ops, have_arg, client_match;
674         const char *channelname, *client_modes;
675         char pattern[COMMAND_LEN];
676         char flags[4];
677         CL2CHAN *cl2chan;
678         CHANNEL *chan, *cn;
679         CLIENT *c;
680
681         assert( Client != NULL );
682         assert( Req != NULL );
683
684         if (Req->argc > 2)
685                 return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
686
687         only_ops = false;
688         have_arg = false;
689
690         if (Req->argc == 2) {
691                 if (strcmp(Req->argv[1], "o") == 0)
692                         only_ops = true;
693 #ifdef STRICT_RFC
694                 else return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command);
695 #endif
696         }
697
698         IRC_SetPenalty(Client, 1);
699         if (Req->argc >= 1) { /* Channel or Mask. */
700                 chan = Channel_Search(Req->argv[0]);
701                 if (chan)
702                         return IRC_Send_WHO(Client, chan, only_ops);
703                 if (strcmp(Req->argv[0], "0") != 0) { /* RFC stupidity, same as no arguments */
704                         have_arg = true;
705                         strlcpy(pattern, Req->argv[0], sizeof(pattern));
706                         ngt_LowerStr(pattern);
707                         IRC_SetPenalty(Client, 3);
708                 }
709         }
710
711         for (c = Client_First(); c != NULL; c = Client_Next(c)) {
712                 if (Client_Type(c) != CLIENT_USER)
713                         continue;
714                  /*
715                   * RFC 2812, 3.6.1:
716                   * In the absence of the parameter, all visible (users who aren't
717                   * invisible (user mode +i) and who don't have a common channel
718                   * with the requesting client) are listed.
719                   *
720                   * The same result can be achieved by using a [sic] of "0"
721                   * or any wildcard which will end up matching every visible user.
722                   *
723                   * The [sic] passed to WHO is matched against users' host, server, real name and
724                   * nickname if the channel cannot be found.
725                   */
726                 client_modes = Client_Modes(c);
727                 if (strchr(client_modes, 'i'))
728                         continue;
729
730                 if (only_ops && !strchr(client_modes, 'o'))
731                         continue;
732
733                 if (have_arg) { /* match pattern against user host/server/name/nick */
734                         client_match = MatchCaseInsensitive(pattern, Client_Hostname(c)); /* user's host */
735                         if (!client_match)
736                                 client_match = MatchCaseInsensitive(pattern, Client_ID(Client_Introducer(c))); /* server */
737                         if (!client_match)
738                                 client_match = Match(Req->argv[0], Client_Info(c)); /* realname */
739                         if (!client_match)
740                                 client_match = MatchCaseInsensitive(pattern, Client_ID(c)); /* nick name */
741
742                         if (!client_match) /* This isn't the client you're looking for */
743                                 continue;
744                 }
745
746                 if (strchr(client_modes, 'a'))
747                         strcpy(flags, "G"); /* user is away */
748                 else
749                         strcpy(flags, "H");
750
751                 if (only_ops) /* this client is an operator */
752                         strlcat(flags, "*", sizeof(flags));
753
754                 /* Search suitable channel */
755                 cl2chan = Channel_FirstChannelOf(c);
756                 while (cl2chan) {
757                         cn = Channel_GetChannel(cl2chan);
758                         if (Channel_IsMemberOf(cn, Client) ||
759                                     !strchr(Channel_Modes(cn), 's'))
760                         {
761                                 channelname = Channel_Name(cn);
762                                 break;
763                         }
764                         cl2chan = Channel_NextChannelOf(c, cl2chan);
765                 }
766                 if (!cl2chan)
767                         channelname = "*";
768
769                 if (!write_whoreply(Client, c, channelname, flags))
770                         return DISCONNECTED;
771         }
772
773         if (Req->argc > 0)
774                 channelname = Req->argv[0];
775         else
776                 channelname = "*";
777
778         return IRC_WriteStrClient(Client, RPL_ENDOFWHO_MSG, Client_ID(Client), channelname);
779 } /* IRC_WHO */
780
781
782 GLOBAL bool
783 IRC_WHOIS( CLIENT *Client, REQUEST *Req )
784 {
785         CLIENT *from, *target, *c;
786         char str[LINE_LEN + 1];
787         CL2CHAN *cl2chan;
788         CHANNEL *chan;
789
790         assert( Client != NULL );
791         assert( Req != NULL );
792
793         /* Bad number of parameters? */
794         if(( Req->argc < 1 ) || ( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
795
796         /* Search client */
797         c = Client_Search( Req->argv[Req->argc - 1] );
798         if(( ! c ) || ( Client_Type( c ) != CLIENT_USER )) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[Req->argc - 1] );
799
800         /* Search sender of the WHOIS */
801         if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
802         else from = Client;
803         if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
804
805         /* Forward to other server? */
806         if( Req->argc > 1 )
807         {
808                 /* Search target server (can be specified as nick of that server!) */
809                 target = Client_Search( Req->argv[0] );
810                 if( ! target ) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
811         }
812         else target = Client_ThisServer( );
813
814         assert( target != NULL );
815
816         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] );
817
818         /* Nick, user and name */
819         if( ! IRC_WriteStrClient( from, RPL_WHOISUSER_MSG, Client_ID( from ), Client_ID( c ), Client_User( c ), Client_Hostname( c ), Client_Info( c ))) return DISCONNECTED;
820
821         /* Server */
822         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;
823
824         /* Channels */
825         snprintf( str, sizeof( str ), RPL_WHOISCHANNELS_MSG, Client_ID( from ), Client_ID( c ));
826         cl2chan = Channel_FirstChannelOf( c );
827         while( cl2chan )
828         {
829                 chan = Channel_GetChannel( cl2chan );
830                 assert( chan != NULL );
831
832                 /* next */
833                 cl2chan = Channel_NextChannelOf( c, cl2chan );
834
835                 /* Secret channel? */
836                 if( strchr( Channel_Modes( chan ), 's' ) && ! Channel_IsMemberOf( chan, Client )) continue;
837
838                 /* Concatenate channel names */
839                 if( str[strlen( str ) - 1] != ':' ) strlcat( str, " ", sizeof( str ));
840                 if( strchr( Channel_UserModes( chan, c ), 'o' )) strlcat( str, "@", sizeof( str ));
841                 else if( strchr( Channel_UserModes( chan, c ), 'v' )) strlcat( str, "+", sizeof( str ));
842                 strlcat( str, Channel_Name( chan ), sizeof( str ));
843
844                 if( strlen( str ) > ( LINE_LEN - CHANNEL_NAME_LEN - 4 ))
845                 {
846                         /* Line becomes too long: send it! */
847                         if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED;
848                         snprintf( str, sizeof( str ), RPL_WHOISCHANNELS_MSG, Client_ID( from ), Client_ID( c ));
849                 }
850         }
851         if( str[strlen( str ) - 1] != ':')
852         {
853                 /* There is data left to send: */
854                 if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED;
855         }
856
857         /* IRC-Operator? */
858         if( Client_HasMode( c, 'o' ))
859         {
860                 if( ! IRC_WriteStrClient( from, RPL_WHOISOPERATOR_MSG, Client_ID( from ), Client_ID( c ))) return DISCONNECTED;
861         }
862
863         /* Idle and signon time (local clients only!) */
864         if (Client_Conn(c) > NONE ) {
865                 if (! IRC_WriteStrClient(from, RPL_WHOISIDLE_MSG,
866                         Client_ID(from), Client_ID(c),
867                         (unsigned long)Conn_GetIdle(Client_Conn(c)),
868                         (unsigned long)Conn_GetSignon(Client_Conn(c))))
869                                 return DISCONNECTED;
870         }
871
872         /* Away? */
873         if( Client_HasMode( c, 'a' ))
874         {
875                 if( ! IRC_WriteStrClient( from, RPL_AWAY_MSG, Client_ID( from ), Client_ID( c ), Client_Away( c ))) return DISCONNECTED;
876         }
877
878         /* End of Whois */
879         return IRC_WriteStrClient( from, RPL_ENDOFWHOIS_MSG, Client_ID( from ), Client_ID( c ));
880 } /* IRC_WHOIS */
881
882
883 /**
884  * IRC "WHOWAS" function.
885  * This function implements the IRC command "WHOWHAS". It handles local
886  * requests and request that should be forwarded to other servers.
887  */
888 GLOBAL bool
889 IRC_WHOWAS( CLIENT *Client, REQUEST *Req )
890 {
891         CLIENT *target, *prefix;
892         WHOWAS *whowas;
893         int max, last, count, i;
894         char t_str[60];
895         
896         assert( Client != NULL );
897         assert( Req != NULL );
898
899         /* Wrong number of parameters? */
900         if(( Req->argc < 1 ) || ( Req->argc > 3 ))
901                 return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG,
902                                            Client_ID( Client ), Req->command );
903
904         /* Search taget */
905         if( Req->argc == 3 )
906                 target = Client_Search( Req->argv[2] );
907         else
908                 target = Client_ThisServer( );
909
910         /* Get prefix */
911         if( Client_Type( Client ) == CLIENT_SERVER )
912                 prefix = Client_Search( Req->prefix );
913         else
914                 prefix = Client;
915
916         if( ! prefix )
917                 return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG,
918                                            Client_ID( Client ), Req->prefix );
919
920         /* Forward to other server? */
921         if( target != Client_ThisServer( ))
922         {
923                 if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER ))
924                         return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG,
925                                                    Client_ID( prefix ),
926                                                    Req->argv[2] );
927
928                 /* Forward */
929                 IRC_WriteStrClientPrefix( target, prefix, "WHOWAS %s %s %s",
930                                           Req->argv[0], Req->argv[1],
931                                           Req->argv[2] );
932                 return CONNECTED;
933         }
934         
935         whowas = Client_GetWhowas( );
936         last = Client_GetLastWhowasIndex( );
937         if( last < 0 ) last = 0;
938         
939         if( Req->argc > 1 )
940         {
941                 max = atoi( Req->argv[1] );
942                 if( max < 1 ) max = MAX_WHOWAS;
943         }
944         else
945                 max = DEFAULT_WHOWAS;
946         
947         i = last;
948         count = 0;
949         do
950         {
951                 /* Used entry? */
952                 if( whowas[i].time > 0 &&
953                     strcasecmp( Req->argv[0], whowas[i].id ) == 0 )
954                 {
955                         (void)strftime( t_str, sizeof(t_str),
956                                         "%a %b %d %H:%M:%S %Y",
957                                         localtime( &whowas[i].time ));
958                 
959                         if( ! IRC_WriteStrClient( prefix, RPL_WHOWASUSER_MSG,
960                                                   Client_ID( prefix ),
961                                                   whowas[i].id,
962                                                   whowas[i].user,
963                                                   whowas[i].host, 
964                                                   whowas[i].info ))
965                                 return DISCONNECTED;
966                 
967                         if( ! IRC_WriteStrClient( prefix, RPL_WHOISSERVER_MSG,
968                                                   Client_ID( prefix ),
969                                                   whowas[i].id,
970                                                   whowas[i].server, t_str ))
971                                 return DISCONNECTED;
972                 
973                         count++;
974                         if( count >= max ) break;
975                 }
976                 
977                 /* previos entry */
978                 i--;
979
980                 /* "underflow", wrap around */
981                 if( i < 0 ) i = MAX_WHOWAS - 1;
982         } while( i != last );
983         
984         return IRC_WriteStrClient( prefix, RPL_ENDOFWHOWAS_MSG,
985                                    Client_ID( prefix ), Req->argv[0] );
986 } /* IRC_WHOWAS */
987
988
989 GLOBAL bool
990 IRC_Send_LUSERS( CLIENT *Client )
991 {
992         unsigned long cnt;
993 #ifndef STRICT_RFC
994         unsigned long max;
995 #endif
996
997         assert( Client != NULL );
998
999         /* Users, services and serevers in the network */
1000         if( ! IRC_WriteStrClient( Client, RPL_LUSERCLIENT_MSG, Client_ID( Client ), Client_UserCount( ), Client_ServiceCount( ), Client_ServerCount( ))) return DISCONNECTED;
1001
1002         /* Number of IRC operators */
1003         cnt = Client_OperCount( );
1004         if( cnt > 0 )
1005         {
1006                 if( ! IRC_WriteStrClient( Client, RPL_LUSEROP_MSG, Client_ID( Client ), cnt )) return DISCONNECTED;
1007         }
1008
1009         /* Unknown connections */
1010         cnt = Client_UnknownCount( );
1011         if( cnt > 0 )
1012         {
1013                 if( ! IRC_WriteStrClient( Client, RPL_LUSERUNKNOWN_MSG, Client_ID( Client ), cnt )) return DISCONNECTED;
1014         }
1015
1016         /* Number of created channels */
1017         if( ! IRC_WriteStrClient( Client, RPL_LUSERCHANNELS_MSG, Client_ID( Client ), Channel_Count( ))) return DISCONNECTED;
1018
1019         /* Number of local users, services and servers */
1020         if( ! IRC_WriteStrClient( Client, RPL_LUSERME_MSG, Client_ID( Client ), Client_MyUserCount( ), Client_MyServiceCount( ), Client_MyServerCount( ))) return DISCONNECTED;
1021
1022 #ifndef STRICT_RFC
1023         /* Maximum number of local users */
1024         cnt = Client_MyUserCount();
1025         max = Client_MyMaxUserCount();
1026         if (! IRC_WriteStrClient(Client, RPL_LOCALUSERS_MSG, Client_ID(Client),
1027                         cnt, max, cnt, max))
1028                 return DISCONNECTED;
1029         /* Maximum number of users in the network */
1030         cnt = Client_UserCount();
1031         max = Client_MaxUserCount();
1032         if(! IRC_WriteStrClient(Client, RPL_NETUSERS_MSG, Client_ID(Client),
1033                         cnt, max, cnt, max))
1034                 return DISCONNECTED;
1035 #endif
1036         
1037         return CONNECTED;
1038 } /* IRC_Send_LUSERS */
1039
1040
1041 static bool
1042 Show_MOTD_Start(CLIENT *Client)
1043 {
1044         return IRC_WriteStrClient(Client, RPL_MOTDSTART_MSG,
1045                 Client_ID( Client ), Client_ID( Client_ThisServer( )));
1046 }
1047
1048 static bool
1049 Show_MOTD_Sendline(CLIENT *Client, const char *msg)
1050 {
1051         return IRC_WriteStrClient(Client, RPL_MOTD_MSG, Client_ID( Client ), msg);
1052 }
1053
1054 static bool
1055 Show_MOTD_End(CLIENT *Client)
1056 {
1057         return IRC_WriteStrClient( Client, RPL_ENDOFMOTD_MSG, Client_ID( Client ));
1058 }
1059
1060
1061 GLOBAL bool
1062 IRC_Show_MOTD( CLIENT *Client )
1063 {
1064         char line[127];
1065         FILE *fd;
1066
1067         assert( Client != NULL );
1068
1069         if (Conf_MotdPhrase[0]) {
1070                 if (!Show_MOTD_Start(Client))
1071                         return DISCONNECTED;
1072                 if (!Show_MOTD_Sendline(Client, Conf_MotdPhrase))
1073                         return DISCONNECTED;
1074
1075                 return Show_MOTD_End(Client);
1076         }
1077
1078         fd = fopen( Conf_MotdFile, "r" );
1079         if( ! fd ) {
1080                 Log( LOG_WARNING, "Can't read MOTD file \"%s\": %s", Conf_MotdFile, strerror( errno ));
1081                 return IRC_WriteStrClient( Client, ERR_NOMOTD_MSG, Client_ID( Client ) );
1082         }
1083
1084         if (!Show_MOTD_Start( Client )) {
1085                 fclose(fd);
1086                 return false;
1087         }
1088
1089         while (fgets( line, (int)sizeof line, fd )) {
1090                 ngt_TrimLastChr( line, '\n');
1091
1092                 if( ! Show_MOTD_Sendline( Client, line)) {
1093                         fclose( fd );
1094                         return false;
1095                 }
1096         }
1097         fclose(fd);
1098         return Show_MOTD_End(Client);
1099 } /* IRC_Show_MOTD */
1100
1101
1102 GLOBAL bool
1103 IRC_Send_NAMES( CLIENT *Client, CHANNEL *Chan )
1104 {
1105         bool is_visible, is_member;
1106         char str[LINE_LEN + 1];
1107         CL2CHAN *cl2chan;
1108         CLIENT *cl;
1109
1110         assert( Client != NULL );
1111         assert( Chan != NULL );
1112
1113         if( Channel_IsMemberOf( Chan, Client )) is_member = true;
1114         else is_member = false;
1115
1116         /* Secret channel? */
1117         if( ! is_member && strchr( Channel_Modes( Chan ), 's' )) return CONNECTED;
1118
1119         /* Alle Mitglieder suchen */
1120         snprintf( str, sizeof( str ), RPL_NAMREPLY_MSG, Client_ID( Client ), "=", Channel_Name( Chan ));
1121         cl2chan = Channel_FirstMember( Chan );
1122         while( cl2chan )
1123         {
1124                 cl = Channel_GetClient( cl2chan );
1125
1126                 if( strchr( Client_Modes( cl ), 'i' )) is_visible = false;
1127                 else is_visible = true;
1128
1129                 if( is_member || is_visible )
1130                 {
1131                         /* Nick anhaengen */
1132                         if( str[strlen( str ) - 1] != ':' ) strlcat( str, " ", sizeof( str ));
1133                         if( strchr( Channel_UserModes( Chan, cl ), 'o' )) strlcat( str, "@", sizeof( str ));
1134                         else if( strchr( Channel_UserModes( Chan, cl ), 'v' )) strlcat( str, "+", sizeof( str ));
1135                         strlcat( str, Client_ID( cl ), sizeof( str ));
1136
1137                         if( strlen( str ) > ( LINE_LEN - CLIENT_NICK_LEN - 4 ))
1138                         {
1139                                 /* Zeile wird zu lang: senden! */
1140                                 if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED;
1141                                 snprintf( str, sizeof( str ), RPL_NAMREPLY_MSG, Client_ID( Client ), "=", Channel_Name( Chan ));
1142                         }
1143                 }
1144
1145                 /* naechstes Mitglied suchen */
1146                 cl2chan = Channel_NextMember( Chan, cl2chan );
1147         }
1148         if( str[strlen( str ) - 1] != ':')
1149         {
1150                 /* Es sind noch Daten da, die gesendet werden muessen */
1151                 if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED;
1152         }
1153
1154         return CONNECTED;
1155 } /* IRC_Send_NAMES */
1156
1157
1158
1159 /**
1160  * Send the ISUPPORT numeric (005).
1161  * This numeric indicates the features that are supported by this server.
1162  * See <http://www.irc.org/tech_docs/005.html> for details.
1163  */
1164 GLOBAL bool
1165 IRC_Send_ISUPPORT PARAMS((CLIENT * Client))
1166 {
1167         if (!IRC_WriteStrClient(Client, RPL_ISUPPORT1_MSG, Client_ID(Client),
1168                                 Conf_MaxJoins))
1169                 return DISCONNECTED;
1170         return IRC_WriteStrClient(Client, RPL_ISUPPORT2_MSG, Client_ID(Client),
1171                                   CHANNEL_NAME_LEN - 1, Conf_MaxNickLength - 1,
1172                                   COMMAND_LEN - 23, CLIENT_AWAY_LEN - 1,
1173                                   COMMAND_LEN - 113);
1174 } /* IRC_Send_ISUPPORT */
1175
1176
1177 /* -eof- */