X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Firc.c;h=e8300ff0839e294ebd7508e2a325b07a36571704;hb=7a6f99a607176e9172877fe3de68c3cf8f700166;hp=3c878148df4fd657b24a5055c9318ec89bd5eea7;hpb=39d7b014cfc775690d386334cbab9387e68ea25c;p=ngircd-alex.git diff --git a/src/ngircd/irc.c b/src/ngircd/irc.c index 3c878148..e8300ff0 100644 --- a/src/ngircd/irc.c +++ b/src/ngircd/irc.c @@ -9,7 +9,7 @@ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: irc.c,v 1.97 2002/10/09 13:33:19 alex Exp $ + * $Id: irc.c,v 1.102 2002/11/24 18:45:53 alex Exp $ * * irc.c: IRC-Befehle */ @@ -23,6 +23,7 @@ #include #include #include +#include #include "ngircd.h" #include "conn.h" @@ -44,15 +45,35 @@ GLOBAL BOOLEAN IRC_MOTD( CLIENT *Client, REQUEST *Req ) { + CLIENT *from, *target; + assert( Client != NULL ); assert( Req != NULL ); - if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client )); + if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client )); /* Falsche Anzahl Parameter? */ - if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); + if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); + + /* 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( 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_ThisServer( )) + { + /* Ok, anderer Server ist das Ziel: forwarden */ + return IRC_WriteStrClientPrefix( target, from, "MOTD %s", Req->argv[0] ); + } + } - return IRC_Show_MOTD( Client ); + return IRC_Show_MOTD( from ); } /* IRC_MOTD */ @@ -109,7 +130,7 @@ IRC_NOTICE( CLIENT *Client, REQUEST *Req ) assert( Client != NULL ); assert( Req != NULL ); - if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return; + if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return CONNECTED; /* Falsche Anzahl Parameter? */ if( Req->argc != 2 ) return CONNECTED; @@ -361,6 +382,23 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req ) } /* IRC_WHOIS */ +GLOBAL BOOLEAN +IRC_WHOWAS( CLIENT *Client, REQUEST *Req ) +{ + assert( Client != NULL ); + assert( Req != NULL ); + + if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client )); + + /* Falsche Anzahl Parameter? */ + if(( Req->argc < 1 ) || ( Req->argc > 3 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); + + /* ... */ + + return CONNECTED; +} /* IRC_WHOWAS */ + + GLOBAL BOOLEAN IRC_WHO( CLIENT *Client, REQUEST *Req ) { @@ -697,6 +735,44 @@ IRC_ADMIN(CLIENT *Client, REQUEST *Req ) } /* IRC_ADMIN */ +GLOBAL BOOLEAN +IRC_TIME( CLIENT *Client, REQUEST *Req ) +{ + CLIENT *from, *target; + CHAR t_str[64]; + time_t t; + + assert( Client != NULL ); + assert( Req != NULL ); + + if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client )); + + /* Falsche Anzahl Parameter? */ + if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); + + /* 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( 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_ThisServer( )) + { + /* Ok, anderer Server ist das Ziel: forwarden */ + return IRC_WriteStrClientPrefix( target, from, "TIME %s", Req->argv[0] ); + } + } + + t = time( NULL ); + (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 */ + GLOBAL BOOLEAN IRC_Show_MOTD( CLIENT *Client ) @@ -834,7 +910,7 @@ IRC_Send_WHO( CLIENT *Client, CHANNEL *Chan, BOOLEAN OnlyOps ) GLOBAL BOOLEAN IRC_Send_LUSERS( CLIENT *Client ) { - INT cnt; + LONG cnt; assert( Client != NULL );