X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Firc-info.c;h=e4d1c7fcc3fbcd93dd4dacff65aac44242b737dc;hp=30ee925f059e8d59d8a025feab41347d887a6c1f;hb=7b6e26628a884a768863c753a3fdff00116c0eed;hpb=bad7ac62a7a8434f0e0629b14a3dfe6df111f6c4 diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c index 30ee925f..e4d1c7fc 100644 --- a/src/ngircd/irc-info.c +++ b/src/ngircd/irc-info.c @@ -2,21 +2,20 @@ * ngIRCd -- The Next Generation IRC Daemon * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de) * - * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen - * der GNU General Public License (GPL), wie von der Free Software Foundation - * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2 - * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version. - * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste - * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * Please read the file COPYING, README and AUTHORS for more information. * - * $Id: irc-info.c,v 1.3 2002/12/02 13:20:02 alex Exp $ - * - * irc-info.c: IRC-Info-Befehle + * IRC info commands */ #include "portab.h" +static char UNUSED id[] = "$Id: irc-info.c,v 1.18 2003/11/05 23:24:48 alex Exp $"; + #include "imp.h" #include #include @@ -24,7 +23,9 @@ #include #include "ngircd.h" -#include "conn.h" +#include "cvs-version.h" +#include "conn-func.h" +#include "conn-zip.h" #include "client.h" #include "channel.h" #include "resolve.h" @@ -58,12 +59,12 @@ IRC_ADMIN(CLIENT *Client, REQUEST *Req ) /* Prefix ermitteln */ if( Client_Type( Client ) == CLIENT_SERVER ) prefix = Client_Search( Req->prefix ); else prefix = Client; - if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->prefix ); + if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); /* An anderen Server weiterleiten? */ if( target != Client_ThisServer( )) { - if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] ); + if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] ); /* forwarden */ IRC_WriteStrClientPrefix( target, prefix, "ADMIN %s", Req->argv[0] ); @@ -76,6 +77,7 @@ IRC_ADMIN(CLIENT *Client, REQUEST *Req ) if( ! IRC_WriteStrClient( Client, RPL_ADMINLOC2_MSG, Client_ID( prefix ), Conf_ServerAdmin2 )) return DISCONNECTED; if( ! IRC_WriteStrClient( Client, RPL_ADMINEMAIL_MSG, Client_ID( prefix ), Conf_ServerAdminMail )) return DISCONNECTED; + IRC_SetPenalty( Client, 1 ); return CONNECTED; } /* IRC_ADMIN */ @@ -105,15 +107,15 @@ IRC_ISON( CLIENT *Client, REQUEST *Req ) if( c && ( Client_Type( c ) == CLIENT_USER )) { /* Dieser Nick ist "online" */ - strcat( rpl, ptr ); - strcat( rpl, " " ); + strlcat( rpl, ptr, sizeof( rpl )); + strlcat( rpl, " ", sizeof( rpl )); } ptr = strtok( NULL, " " ); } } if( rpl[strlen( rpl ) - 1] == ' ' ) rpl[strlen( rpl ) - 1] = '\0'; - return IRC_WriteStrClient( Client, "%s", rpl, Client_ID( Client ) ); + return IRC_WriteStrClient( Client, rpl, Client_ID( Client ) ); } /* IRC_ISON */ @@ -142,7 +144,7 @@ IRC_LINKS( CLIENT *Client, REQUEST *Req ) if( Req->argc == 2 ) { target = Client_Search( Req->argv[0] ); - if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] ); + if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] ); else if( target != Client_ThisServer( )) return IRC_WriteStrClientPrefix( target, from, "LINKS %s %s", Req->argv[0], Req->argv[1] ); } @@ -160,7 +162,8 @@ IRC_LINKS( CLIENT *Client, REQUEST *Req ) } c = Client_Next( c ); } - + + IRC_SetPenalty( target, 1 ); return IRC_WriteStrClient( target, RPL_ENDOFLINKS_MSG, Client_ID( target ), mask ); } /* IRC_LINKS */ @@ -185,7 +188,7 @@ IRC_LUSERS( CLIENT *Client, REQUEST *Req ) if( Req->argc == 2 ) { target = Client_Search( Req->argv[1] ); - if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[1] ); + if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] ); else if( target != Client_ThisServer( )) return IRC_WriteStrClientPrefix( target, from, "LUSERS %s %s", Req->argv[0], Req->argv[1] ); } @@ -196,6 +199,7 @@ IRC_LUSERS( CLIENT *Client, REQUEST *Req ) IRC_Send_LUSERS( target ); + IRC_SetPenalty( target, 1 ); return CONNECTED; } /* IRC_LUSERS */ @@ -214,13 +218,13 @@ IRC_MOTD( CLIENT *Client, REQUEST *Req ) /* From aus Prefix ermitteln */ if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix ); else from = Client; - if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->prefix ); + if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); if( Req->argc == 1 ) { /* an anderen Server forwarden */ target = Client_Search( Req->argv[0] ); - if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] ); + if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] ); if( target != Client_ThisServer( )) { @@ -229,6 +233,7 @@ IRC_MOTD( CLIENT *Client, REQUEST *Req ) } } + IRC_SetPenalty( from, 3 ); return IRC_Show_MOTD( from ); } /* IRC_MOTD */ @@ -249,13 +254,13 @@ IRC_NAMES( CLIENT *Client, REQUEST *Req ) /* From aus Prefix ermitteln */ if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix ); else from = Client; - if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->prefix ); + if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); if( Req->argc == 2 ) { /* an anderen Server forwarden */ target = Client_Search( Req->argv[1] ); - if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[1] ); + if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] ); if( target != Client_ThisServer( )) { @@ -297,20 +302,20 @@ IRC_NAMES( CLIENT *Client, REQUEST *Req ) /* Nun noch alle Clients ausgeben, die in keinem Channel sind */ c = Client_First( ); - sprintf( rpl, RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" ); + snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" ); while( c ) { if(( Client_Type( c ) == CLIENT_USER ) && ( Channel_FirstChannelOf( c ) == NULL ) && ( ! strchr( Client_Modes( c ), 'i' ))) { /* Okay, das ist ein User: anhaengen */ - if( rpl[strlen( rpl ) - 1] != ':' ) strcat( rpl, " " ); - strcat( rpl, Client_ID( c )); + if( rpl[strlen( rpl ) - 1] != ':' ) strlcat( rpl, " ", sizeof( rpl )); + strlcat( rpl, Client_ID( c ), sizeof( rpl )); if( strlen( rpl ) > ( LINE_LEN - CLIENT_NICK_LEN - 4 )) { /* Zeile wird zu lang: senden! */ if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED; - sprintf( rpl, RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" ); + snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" ); } } @@ -323,6 +328,7 @@ IRC_NAMES( CLIENT *Client, REQUEST *Req ) if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED; } + IRC_SetPenalty( from, 1 ); return IRC_WriteStrClient( from, RPL_ENDOFNAMES_MSG, Client_ID( from ), "*" ); } /* IRC_NAMES */ @@ -333,6 +339,7 @@ IRC_STATS( CLIENT *Client, REQUEST *Req ) CLIENT *from, *target, *cl; CONN_ID con; CHAR query; + COMMAND *cmd; assert( Client != NULL ); assert( Req != NULL ); @@ -343,18 +350,18 @@ IRC_STATS( CLIENT *Client, REQUEST *Req ) /* From aus Prefix ermitteln */ if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix ); else from = Client; - if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->prefix ); + if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); if( Req->argc == 2 ) { /* an anderen Server forwarden */ target = Client_Search( Req->argv[1] ); - if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[1] ); + if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] ); if( target != Client_ThisServer( )) { /* Ok, anderer Server ist das Ziel: forwarden */ - return IRC_WriteStrClientPrefix( target, from, "STATS %s", Req->argv[0], Req->argv[1] ); + return IRC_WriteStrClientPrefix( target, from, "STATS %s %s", Req->argv[0], Req->argv[1] ); } } @@ -369,12 +376,13 @@ IRC_STATS( CLIENT *Client, REQUEST *Req ) while( con != NONE ) { cl = Client_GetFromConn( con ); - if( cl ) + if( cl && (( Client_Type( cl ) == CLIENT_SERVER ) || ( cl == Client ))) { + /* Server link or our own connection */ #ifdef USE_ZLIB if( Conn_Options( con ) & CONN_ZIP ) { - if( ! IRC_WriteStrClient( from, RPL_STATSLINKINFOZIP_MSG, Client_ID( from ), Client_Mask( cl ), Conn_SendQ( con ), Conn_SendMsg( con ), Conn_SendBytesZip( con ), Conn_SendBytes( con ), Conn_RecvMsg( con ), Conn_RecvBytesZip( con ), Conn_RecvBytes( con ), (LONG)( time( NULL ) - Conn_StartTime( con )))) return DISCONNECTED; + if( ! IRC_WriteStrClient( from, RPL_STATSLINKINFOZIP_MSG, Client_ID( from ), Client_Mask( cl ), Conn_SendQ( con ), Conn_SendMsg( con ), Zip_SendBytes( con ), Conn_SendBytes( con ), Conn_RecvMsg( con ), Zip_RecvBytes( con ), Conn_RecvBytes( con ), (LONG)( time( NULL ) - Conn_StartTime( con )))) return DISCONNECTED; } else #endif @@ -387,9 +395,19 @@ IRC_STATS( CLIENT *Client, REQUEST *Req ) break; case 'm': /* IRC-Befehle */ case 'M': + cmd = Parse_GetCommandStruct( ); + while( cmd->name ) + { + if( cmd->lcount > 0 || cmd->rcount > 0 ) + { + if( ! IRC_WriteStrClient( from, RPL_STATSCOMMANDS_MSG, Client_ID( from ), cmd->name, cmd->lcount, cmd->bytes, cmd->rcount )) return DISCONNECTED; + } + cmd++; + } break; } + IRC_SetPenalty( from, 2 ); return IRC_WriteStrClient( from, RPL_ENDOFSTATS_MSG, Client_ID( from ), query ); } /* IRC_STATS */ @@ -410,13 +428,13 @@ IRC_TIME( CLIENT *Client, REQUEST *Req ) /* From aus Prefix ermitteln */ if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix ); else from = Client; - if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->prefix ); + if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); if( Req->argc == 1 ) { /* an anderen Server forwarden */ target = Client_Search( Req->argv[0] ); - if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] ); + if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] ); if( target != Client_ThisServer( )) { @@ -426,7 +444,7 @@ IRC_TIME( CLIENT *Client, REQUEST *Req ) } t = time( NULL ); - (VOID)strftime( t_str, 60, "%A %B %d %Y -- %H:%M %z", localtime( &t )); + (VOID)strftime( t_str, 60, "%A %B %d %Y -- %H:%M %Z", localtime( &t )); return IRC_WriteStrClient( from, RPL_TIME_MSG, Client_ID( from ), Client_ID( Client_ThisServer( )), t_str ); } /* IRC_TIME */ @@ -454,20 +472,20 @@ IRC_USERHOST( CLIENT *Client, REQUEST *Req ) if( c && ( Client_Type( c ) == CLIENT_USER )) { /* Dieser Nick ist "online" */ - strcat( rpl, Client_ID( c )); - if( Client_HasMode( c, 'o' )) strcat( rpl, "*" ); - strcat( rpl, "=" ); - if( Client_HasMode( c, 'a' )) strcat( rpl, "-" ); - else strcat( rpl, "+" ); - strcat( rpl, Client_User( c )); - strcat( rpl, "@" ); - strcat( rpl, Client_Hostname( c )); - strcat( rpl, " " ); + strlcat( rpl, Client_ID( c ), sizeof( rpl )); + if( Client_HasMode( c, 'o' )) strlcat( rpl, "*", sizeof( rpl )); + strlcat( rpl, "=", sizeof( rpl )); + if( Client_HasMode( c, 'a' )) strlcat( rpl, "-", sizeof( rpl )); + else strlcat( rpl, "+", sizeof( rpl )); + strlcat( rpl, Client_User( c ), sizeof( rpl )); + strlcat( rpl, "@", sizeof( rpl )); + strlcat( rpl, Client_Hostname( c ), sizeof( rpl )); + strlcat( rpl, " ", sizeof( rpl )); } } if( rpl[strlen( rpl ) - 1] == ' ' ) rpl[strlen( rpl ) - 1] = '\0'; - return IRC_WriteStrClient( Client, "%s", rpl, Client_ID( Client ) ); + return IRC_WriteStrClient( Client, rpl, Client_ID( Client ) ); } /* IRC_USERHOST */ @@ -475,6 +493,9 @@ GLOBAL BOOLEAN IRC_VERSION( CLIENT *Client, REQUEST *Req ) { CLIENT *target, *prefix; +#ifdef CVSDATE + CHAR ver[12]; +#endif assert( Client != NULL ); assert( Req != NULL ); @@ -489,12 +510,12 @@ IRC_VERSION( CLIENT *Client, REQUEST *Req ) /* Prefix ermitteln */ if( Client_Type( Client ) == CLIENT_SERVER ) prefix = Client_Search( Req->prefix ); else prefix = Client; - if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->prefix ); + if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); /* An anderen Server weiterleiten? */ if( target != Client_ThisServer( )) { - if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] ); + if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] ); /* forwarden */ IRC_WriteStrClientPrefix( target, prefix, "VERSION %s", Req->argv[0] ); @@ -502,7 +523,15 @@ IRC_VERSION( CLIENT *Client, REQUEST *Req ) } /* mit Versionsinfo antworten */ - return IRC_WriteStrClient( Client, RPL_VERSION_MSG, Client_ID( prefix ), PACKAGE, VERSION, NGIRCd_DebugLevel, Conf_ServerName, NGIRCd_VersionAddition( )); + IRC_SetPenalty( Client, 1 ); +#ifdef CVSDATE + strlcpy( ver, CVSDATE, sizeof( ver )); + strncpy( ver + 4, ver + 5, 2 ); + strncpy( ver + 6, ver + 8, 3 ); + return IRC_WriteStrClient( Client, RPL_VERSION_MSG, Client_ID( prefix ), PACKAGE_NAME, ver, NGIRCd_DebugLevel, Conf_ServerName, NGIRCd_VersionAddition( )); +#else + return IRC_WriteStrClient( Client, RPL_VERSION_MSG, Client_ID( prefix ), PACKAGE_NAME, PACKAGE_VERSION, NGIRCd_DebugLevel, Conf_ServerName, NGIRCd_VersionAddition( )); +#endif } /* IRC_VERSION */ @@ -562,7 +591,7 @@ IRC_WHO( CLIENT *Client, REQUEST *Req ) { /* Flags zusammenbasteln */ strcpy( flags, "H" ); - if( strchr( Client_Modes( c ), 'o' )) strcat( flags, "*" ); + if( strchr( Client_Modes( c ), 'o' )) strlcat( flags, "*", sizeof( flags )); /* ausgeben */ cl2chan = Channel_FirstChannelOf( c ); @@ -586,72 +615,71 @@ GLOBAL BOOLEAN IRC_WHOIS( CLIENT *Client, REQUEST *Req ) { CLIENT *from, *target, *c; - CHAR str[LINE_LEN + 1], *ptr = NULL; + CHAR str[LINE_LEN + 1]; CL2CHAN *cl2chan; CHANNEL *chan; assert( Client != NULL ); assert( Req != NULL ); - /* Falsche Anzahl Parameter? */ + /* Bad number of parameters? */ if(( Req->argc < 1 ) || ( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); - /* Client suchen */ + /* Search client */ c = Client_Search( Req->argv[Req->argc - 1] ); if(( ! c ) || ( Client_Type( c ) != CLIENT_USER )) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->argv[Req->argc - 1] ); - /* Empfaenger des WHOIS suchen */ + /* Search sender of the WHOIS */ if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix ); else from = Client; if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); - /* Forwarden an anderen Server? */ + /* Forward to other server? */ if( Req->argc > 1 ) { - /* angegebenen Ziel-Server suchen */ - target = Client_Search( Req->argv[1] ); - if( ! target ) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] ); - ptr = Req->argv[1]; + /* Search target server (can be specified as nick of that server!) */ + target = Client_Search( Req->argv[0] ); + if( ! target ) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] ); } else target = Client_ThisServer( ); assert( target != NULL ); - if(( Client_NextHop( target ) != Client_ThisServer( )) && ( Client_Type( Client_NextHop( target )) == CLIENT_SERVER )) return IRC_WriteStrClientPrefix( target, from, "WHOIS %s :%s", Req->argv[0], ptr ); + 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] ); - /* Nick, User und Name */ + /* Nick, user and name */ if( ! IRC_WriteStrClient( from, RPL_WHOISUSER_MSG, Client_ID( from ), Client_ID( c ), Client_User( c ), Client_Hostname( c ), Client_Info( c ))) return DISCONNECTED; /* Server */ 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; /* Channels */ - sprintf( str, RPL_WHOISCHANNELS_MSG, Client_ID( from ), Client_ID( c )); + snprintf( str, sizeof( str ), RPL_WHOISCHANNELS_MSG, Client_ID( from ), Client_ID( c )); cl2chan = Channel_FirstChannelOf( c ); while( cl2chan ) { chan = Channel_GetChannel( cl2chan ); assert( chan != NULL ); - /* Channel-Name anhaengen */ - if( str[strlen( str ) - 1] != ':' ) strcat( str, " " ); - if( strchr( Channel_UserModes( chan, c ), 'o' )) strcat( str, "@" ); - else if( strchr( Channel_UserModes( chan, c ), 'v' )) strcat( str, "+" ); - strcat( str, Channel_Name( chan )); + /* Concatenate channel names */ + if( str[strlen( str ) - 1] != ':' ) strlcat( str, " ", sizeof( str )); + if( strchr( Channel_UserModes( chan, c ), 'o' )) strlcat( str, "@", sizeof( str )); + else if( strchr( Channel_UserModes( chan, c ), 'v' )) strlcat( str, "+", sizeof( str )); + strlcat( str, Channel_Name( chan ), sizeof( str )); if( strlen( str ) > ( LINE_LEN - CHANNEL_NAME_LEN - 4 )) { - /* Zeile wird zu lang: senden! */ + /* Line becomes too long: send it! */ if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED; - sprintf( str, RPL_WHOISCHANNELS_MSG, Client_ID( from ), Client_ID( c )); + snprintf( str, sizeof( str ), RPL_WHOISCHANNELS_MSG, Client_ID( from ), Client_ID( c )); } - /* naechstes Mitglied suchen */ + /* next */ cl2chan = Channel_NextChannelOf( c, cl2chan ); } if( str[strlen( str ) - 1] != ':') { - /* Es sind noch Daten da, die gesendet werden muessen */ + /* There is data left to send: */ if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED; } @@ -661,7 +689,7 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req ) if( ! IRC_WriteStrClient( from, RPL_WHOISOPERATOR_MSG, Client_ID( from ), Client_ID( c ))) return DISCONNECTED; } - /* Idle (nur lokale Clients) */ + /* Idle (only local clients) */ if( Client_Conn( c ) > NONE ) { if( ! IRC_WriteStrClient( from, RPL_WHOISIDLE_MSG, Client_ID( from ), Client_ID( c ), Conn_GetIdle( Client_Conn ( c )))) return DISCONNECTED; @@ -700,29 +728,36 @@ IRC_Send_LUSERS( CLIENT *Client ) assert( Client != NULL ); - /* Users, Services und Serevr im Netz */ + /* Users, services and serevers in the network */ if( ! IRC_WriteStrClient( Client, RPL_LUSERCLIENT_MSG, Client_ID( Client ), Client_UserCount( ), Client_ServiceCount( ), Client_ServerCount( ))) return DISCONNECTED; - /* IRC-Operatoren im Netz */ + /* Number of IRC operators */ cnt = Client_OperCount( ); if( cnt > 0 ) { if( ! IRC_WriteStrClient( Client, RPL_LUSEROP_MSG, Client_ID( Client ), cnt )) return DISCONNECTED; } - /* Unbekannt Verbindungen */ + /* Unknown connections */ cnt = Client_UnknownCount( ); if( cnt > 0 ) { if( ! IRC_WriteStrClient( Client, RPL_LUSERUNKNOWN_MSG, Client_ID( Client ), cnt )) return DISCONNECTED; } - /* Channels im Netz */ + /* Number of created channels */ if( ! IRC_WriteStrClient( Client, RPL_LUSERCHANNELS_MSG, Client_ID( Client ), Channel_Count( ))) return DISCONNECTED; - /* Channels im Netz */ + /* Number of local users, services and servers */ if( ! IRC_WriteStrClient( Client, RPL_LUSERME_MSG, Client_ID( Client ), Client_MyUserCount( ), Client_MyServiceCount( ), Client_MyServerCount( ))) return DISCONNECTED; +#ifndef STRICT_RFC + /* Maximum number of local users */ + if( ! IRC_WriteStrClient( Client, RPL_LOCALUSERS_MSG, Client_ID( Client ), Client_MyUserCount( ), Client_MyMaxUserCount( ))) return DISCONNECTED; + /* Maximum number of users in the network */ + if( ! IRC_WriteStrClient( Client, RPL_NETUSERS_MSG, Client_ID( Client ), Client_UserCount( ), Client_MaxUserCount( ))) return DISCONNECTED; +#endif + return CONNECTED; } /* IRC_Send_LUSERS */ @@ -777,7 +812,7 @@ IRC_Send_NAMES( CLIENT *Client, CHANNEL *Chan ) else is_member = FALSE; /* Alle Mitglieder suchen */ - sprintf( str, RPL_NAMREPLY_MSG, Client_ID( Client ), "=", Channel_Name( Chan )); + snprintf( str, sizeof( str ), RPL_NAMREPLY_MSG, Client_ID( Client ), "=", Channel_Name( Chan )); cl2chan = Channel_FirstMember( Chan ); while( cl2chan ) { @@ -789,16 +824,16 @@ IRC_Send_NAMES( CLIENT *Client, CHANNEL *Chan ) if( is_member || is_visible ) { /* Nick anhaengen */ - if( str[strlen( str ) - 1] != ':' ) strcat( str, " " ); - if( strchr( Channel_UserModes( Chan, cl ), 'o' )) strcat( str, "@" ); - else if( strchr( Channel_UserModes( Chan, cl ), 'v' )) strcat( str, "+" ); - strcat( str, Client_ID( cl )); + if( str[strlen( str ) - 1] != ':' ) strlcat( str, " ", sizeof( str )); + if( strchr( Channel_UserModes( Chan, cl ), 'o' )) strlcat( str, "@", sizeof( str )); + else if( strchr( Channel_UserModes( Chan, cl ), 'v' )) strlcat( str, "+", sizeof( str )); + strlcat( str, Client_ID( cl ), sizeof( str )); if( strlen( str ) > ( LINE_LEN - CLIENT_NICK_LEN - 4 )) { /* Zeile wird zu lang: senden! */ if( ! IRC_WriteStrClient( Client, "%s", str )) return DISCONNECTED; - sprintf( str, RPL_NAMREPLY_MSG, Client_ID( Client ), "=", Channel_Name( Chan )); + snprintf( str, sizeof( str ), RPL_NAMREPLY_MSG, Client_ID( Client ), "=", Channel_Name( Chan )); } } @@ -842,9 +877,9 @@ IRC_Send_WHO( CLIENT *Client, CHANNEL *Chan, BOOLEAN OnlyOps ) { /* Flags zusammenbasteln */ strcpy( flags, "H" ); - if( strchr( Client_Modes( c ), 'o' )) strcat( flags, "*" ); - if( strchr( Channel_UserModes( Chan, c ), 'o' )) strcat( flags, "@" ); - else if( strchr( Channel_UserModes( Chan, c ), 'v' )) strcat( flags, "+" ); + if( strchr( Client_Modes( c ), 'o' )) strlcat( flags, "*", sizeof( flags )); + if( strchr( Channel_UserModes( Chan, c ), 'o' )) strlcat( flags, "@", sizeof( flags )); + else if( strchr( Channel_UserModes( Chan, c ), 'v' )) strlcat( flags, "+", sizeof( flags )); /* ausgeben */ if(( ! OnlyOps ) || ( strchr( Client_Modes( c ), 'o' )))