#include "portab.h"
-static char UNUSED id[] = "$Id: client.c,v 1.82 2005/06/04 12:32:09 fw Exp $";
+static char UNUSED id[] = "$Id: client.c,v 1.85 2005/07/31 20:13:08 alex Exp $";
#include "imp.h"
#include <assert.h>
#define GETID_LEN (CLIENT_NICK_LEN-1) + 1 + (CLIENT_USER_LEN-1) + 1 + (CLIENT_HOST_LEN-1) + 1
-LOCAL CLIENT *This_Server, *My_Clients;
-LOCAL char GetID_Buffer[GETID_LEN];
+static CLIENT *This_Server, *My_Clients;
+static char GetID_Buffer[GETID_LEN];
-LOCAL WHOWAS My_Whowas[MAX_WHOWAS];
-LOCAL int Last_Whowas = -1;
+static WHOWAS My_Whowas[MAX_WHOWAS];
+static int Last_Whowas = -1;
-LOCAL long Count PARAMS(( CLIENT_TYPE Type ));
-LOCAL long MyCount PARAMS(( CLIENT_TYPE Type ));
+static long Count PARAMS(( CLIENT_TYPE Type ));
+static long MyCount PARAMS(( CLIENT_TYPE Type ));
-LOCAL CLIENT *New_Client_Struct PARAMS(( void ));
-LOCAL void Generate_MyToken PARAMS(( CLIENT *Client ));
-LOCAL void Adjust_Counters PARAMS(( CLIENT *Client ));
+static CLIENT *New_Client_Struct PARAMS(( void ));
+static void Generate_MyToken PARAMS(( CLIENT *Client ));
+static void Adjust_Counters PARAMS(( CLIENT *Client ));
#ifndef Client_DestroyNow
GLOBAL void Client_DestroyNow PARAMS((CLIENT *Client ));
if( ! client ) return NULL;
/* Initialisieren */
+ client->starttime = time(NULL);
client->conn_id = Idx;
client->introducer = Introducer;
client->topserver = TopServer;
} /* Client_GetLastWhowasIndex */
-LOCAL long
+/**
+ * Get the start time of this client.
+ * The result is the start time in seconds since 1970-01-01, as reported
+ * by the C function time(NULL).
+ */
+GLOBAL time_t
+Client_StartTime(CLIENT *Client)
+{
+ assert( Client != NULL );
+ return Client->starttime;
+} /* Client_Uptime */
+
+
+static long
Count( CLIENT_TYPE Type )
{
CLIENT *c;
} /* Count */
-LOCAL long
+static long
MyCount( CLIENT_TYPE Type )
{
CLIENT *c;
} /* MyCount */
-LOCAL CLIENT *
+static CLIENT *
New_Client_Struct( void )
{
/* Neue CLIENT-Struktur pre-initialisieren */
} /* New_Client */
-LOCAL void
+static void
Generate_MyToken( CLIENT *Client )
{
CLIENT *c;
} /* Generate_MyToken */
-LOCAL void
+static void
Adjust_Counters( CLIENT *Client )
{
long count;
/**
* Register client in My_Whowas structure for further recall by WHOWAS.
+ * Note: Only clients that have been connected at least 30 seconds will be
+ * registered to prevent automated IRC bots to "destroy" a nice server
+ * history database.
*/
GLOBAL void
Client_RegisterWhowas( CLIENT *Client )
assert( Client != NULL );
+ /* Don't register clients that were connected less than 30 seconds. */
+ if( time(NULL) - Client->starttime < 30 )
+ return;
+
slot = Last_Whowas + 1;
if( slot >= MAX_WHOWAS || slot < 0 ) slot = 0;