Commit Diff


commit - 283aed75cf7b83bdc30c5b63d5380b767c6664ad
commit + f86bbd718d4a439509c290b62722f4aa96c00abb
blob - 8c362ba66aa07c04bfe19b9a92b47a0f08784dfc
blob + e8300ff0839e294ebd7508e2a325b07a36571704
--- src/ngircd/irc.c
+++ 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.101 2002/11/24 16:36:03 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 <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 
 #include "ngircd.h"
 #include "conn.h"
@@ -732,9 +733,47 @@ IRC_ADMIN(CLIENT *Client, REQUEST *Req )
 
 	return CONNECTED;
 } /* 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 )
 {
blob - 40385ba5e665c50da876014798a29760ca7057c6
blob + f83021ad8e84d08c868d13a410d60f8006fdb4de
--- src/ngircd/irc.h
+++ src/ngircd/irc.h
@@ -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.h,v 1.33 2002/11/22 23:31:56 alex Exp $
+ * $Id: irc.h,v 1.34 2002/11/24 18:45:53 alex Exp $
  *
  * irc.h: IRC-Befehle (Header)
  */
@@ -19,29 +19,30 @@
 #define __irc_h__
 
 
-GLOBAL BOOLEAN IRC_MOTD PARAMS((CLIENT *Client, REQUEST *Req ));
-GLOBAL BOOLEAN IRC_LUSERS PARAMS((CLIENT *Client, REQUEST *Req ));
-GLOBAL BOOLEAN IRC_LINKS PARAMS((CLIENT *Client, REQUEST *Req ));
-GLOBAL BOOLEAN IRC_VERSION PARAMS((CLIENT *Client, REQUEST *Req ));
-GLOBAL BOOLEAN IRC_ADMIN PARAMS((CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_MOTD PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_LUSERS PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_LINKS PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_VERSION PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_ADMIN PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_TIME PARAMS(( CLIENT *Client, REQUEST *Req ));
 
-GLOBAL BOOLEAN IRC_PRIVMSG PARAMS((CLIENT *Client, REQUEST *Req ));
-GLOBAL BOOLEAN IRC_NOTICE PARAMS((CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_PRIVMSG PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_NOTICE PARAMS(( CLIENT *Client, REQUEST *Req ));
 
-GLOBAL BOOLEAN IRC_NAMES PARAMS((CLIENT *Client, REQUEST *Req ));
-GLOBAL BOOLEAN IRC_ISON PARAMS((CLIENT *Client, REQUEST *Req ));
-GLOBAL BOOLEAN IRC_WHOIS PARAMS((CLIENT *Client, REQUEST *Req ));
-GLOBAL BOOLEAN IRC_WHOWAS PARAMS((CLIENT *Client, REQUEST *Req ));
-GLOBAL BOOLEAN IRC_USERHOST PARAMS((CLIENT *Client, REQUEST *Req ));
-GLOBAL BOOLEAN IRC_WHO PARAMS((CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_NAMES PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_ISON PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_WHOIS PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_WHOWAS PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_USERHOST PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_WHO PARAMS(( CLIENT *Client, REQUEST *Req ));
 
-GLOBAL BOOLEAN IRC_ERROR PARAMS((CLIENT *Client, REQUEST *Req ));
-GLOBAL BOOLEAN IRC_KILL PARAMS((CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_ERROR PARAMS(( CLIENT *Client, REQUEST *Req ));
+GLOBAL BOOLEAN IRC_KILL PARAMS(( CLIENT *Client, REQUEST *Req ));
 
-GLOBAL BOOLEAN IRC_Send_NAMES PARAMS((CLIENT *Client, CHANNEL *Chan ));
-GLOBAL BOOLEAN IRC_Send_LUSERS PARAMS((CLIENT *Client ));
-GLOBAL BOOLEAN IRC_Show_MOTD PARAMS((CLIENT *Client ));
-GLOBAL BOOLEAN IRC_Send_WHO PARAMS((CLIENT *Client, CHANNEL *Chan, BOOLEAN OnlyOps ));
+GLOBAL BOOLEAN IRC_Send_NAMES PARAMS(( CLIENT *Client, CHANNEL *Chan ));
+GLOBAL BOOLEAN IRC_Send_LUSERS PARAMS(( CLIENT *Client ));
+GLOBAL BOOLEAN IRC_Show_MOTD PARAMS(( CLIENT *Client ));
+GLOBAL BOOLEAN IRC_Send_WHO PARAMS(( CLIENT *Client, CHANNEL *Chan, BOOLEAN OnlyOps ));
 
 
 #endif