#include "portab.h"
-static char UNUSED id[] = "$Id: client.c,v 1.90 2006/03/24 23:25:38 fw Exp $";
+static char UNUSED id[] = "$Id: client.c,v 1.91 2006/04/23 10:37:27 fw Exp $";
#include "imp.h"
#include <assert.h>
} /* Client_ModeDel */
-GLOBAL CLIENT *
-Client_GetFromConn( CONN_ID Idx )
-{
- /* return Client-Structure that belongs to the local Connection Idx.
- * If none is found, return NULL.
- */
-
- CLIENT *c;
-
- assert( Idx >= 0 );
-
- c = My_Clients;
- while( c )
- {
- if( c->conn_id == Idx ) return c;
- c = (CLIENT *)c->next;
- }
- return NULL;
-} /* Client_GetFromConn */
-
-
GLOBAL CLIENT *
Client_Search( char *Nick )
{
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
- * $Id: client.h,v 1.41 2006/03/11 01:37:31 alex Exp $
+ * $Id: client.h,v 1.42 2006/04/23 10:37:27 fw Exp $
*
* Client management (header)
*/
#define CLIENT_TYPE int
+#include "defines.h"
#if defined(__client_c__) | defined(S_SPLINT_S)
GLOBAL CLIENT *Client_ThisServer PARAMS(( void ));
-GLOBAL CLIENT *Client_GetFromConn PARAMS(( CONN_ID Idx ));
GLOBAL CLIENT *Client_GetFromToken PARAMS(( CLIENT *Client, int Token ));
GLOBAL CLIENT *Client_Search PARAMS(( char *ID ));
#include "portab.h"
-static char UNUSED id[] = "$Id: conn-func.c,v 1.8 2005/09/04 23:38:32 alex Exp $";
+static char UNUSED id[] = "$Id: conn-func.c,v 1.9 2006/04/23 10:37:27 fw Exp $";
#include "imp.h"
#include <assert.h>
assert(Idx > NONE);
/* Search client structure for this link ... */
- c = Client_GetFromConn(Idx);
+ c = Conn_GetClient(Idx);
if(c != NULL)
return Client_StartTime(c);
#include "portab.h"
#include "io.h"
-static char UNUSED id[] = "$Id: conn.c,v 1.191 2006/03/18 22:27:09 fw Exp $";
+static char UNUSED id[] = "$Id: conn.c,v 1.192 2006/04/23 10:37:27 fw Exp $";
#include "imp.h"
#include <assert.h>
/* Clean up the CLIENT structure (to avoid silly log
* messages) and call Conn_Close() to do the rest. */
- c = Client_GetFromConn(idx);
+ c = Conn_GetClient(idx);
if (c)
Client_DestroyNow(c);
#endif
len = strlcat( buffer, "\r\n", sizeof( buffer ));
- assert(len < COMMAND_LEN);
ok = Conn_Write(Idx, buffer, len);
My_Connections[Idx].msg_out++;
Log( LOG_INFO, "Shutting down connection %d (%s) with %s:%d ...", Idx, LogMsg ? LogMsg : FwdMsg, My_Connections[Idx].host, ntohs( My_Connections[Idx].addr.sin_port ));
/* Search client, if any */
- c = Client_GetFromConn( Idx );
+ c = Conn_GetClient( Idx );
/* Should the client be informed? */
if (InformClient) {
(void)Handle_Write( Idx );
/* Search client, if any (re-check!) */
- c = Client_GetFromConn( Idx );
+ c = Conn_GetClient( Idx );
/* Shut down socket */
if( ! io_close( My_Connections[Idx].sock ))
continue;
/* Server connection? */
- client = Client_GetFromConn( i );
+ client = Conn_GetClient( i );
if(( ! client ) || ( Client_Type( client ) != CLIENT_SERVER )) continue;
for( c = 0; c < MAX_SERVERS; c++ )
Init_Conn_Struct( new_sock );
My_Connections[new_sock].sock = new_sock;
My_Connections[new_sock].addr = new_addr;
+ My_Connections[new_sock].client = c;
/* register callback */
if (!io_event_create( new_sock, IO_WANTREAD, cb_clientserver)) {
* registered as a user, server or service connection. Don't update
* otherwise, so users have at least Conf_PongTimeout seconds time to
* register with the IRC server -- see Check_Connections(). */
- c = Client_GetFromConn(Idx);
+ c = Conn_GetClient(Idx);
if (c && (Client_Type(c) == CLIENT_USER
|| Client_Type(c) == CLIENT_SERVER
|| Client_Type(c) == CLIENT_SERVICE))
if (My_Connections[i].sock < 0)
continue;
- c = Client_GetFromConn( i );
+ c = Conn_GetClient( i );
if( c && (( Client_Type( c ) == CLIENT_USER ) || ( Client_Type( c ) == CLIENT_SERVER ) || ( Client_Type( c ) == CLIENT_SERVICE )))
{
/* connected User, Server or Service */
Conf_Server[Server].conn_id = new_sock;
My_Connections[new_sock].sock = new_sock;
My_Connections[new_sock].addr = new_addr;
+ My_Connections[new_sock].client = c;
strlcpy( My_Connections[new_sock].host, Conf_Server[Server].host,
sizeof(My_Connections[new_sock].host ));
* incoming connections.*/
assert ( My_Connections[i].sock >= 0 );
/* Incoming connection. Search client ... */
- c = Client_GetFromConn( i );
+ c = Conn_GetClient( i );
assert( c != NULL );
/* Only update client information of unregistered clients */
static void
Simple_Message( int Sock, const char *Msg )
{
- size_t len;
char buf[COMMAND_LEN];
+ size_t len;
/* Write "simple" message to socket, without using compression
* or even the connection write buffers. Used e.g. for error
* messages by New_Connection(). */
strlcpy( buf, Msg, sizeof buf - 2);
len = strlcat( buf, "\r\n", sizeof buf);
- assert(len < COMMAND_LEN);
(void)write(Sock, buf, len);
} /* Simple_Error */
} /* Count_Connections */
+GLOBAL CLIENT *
+Conn_GetClient( CONN_ID Idx )
+{
+ /* return Client-Structure that belongs to the local Connection Idx.
+ * If none is found, return NULL.
+ */
+ CONNECTION *c;
+ assert( Idx >= 0 );
+
+ c = array_get(&My_ConnArray, sizeof (CONNECTION), Idx);
+
+ assert(c != NULL);
+
+ return c ? c->client : NULL;
+}
/* -eof- */
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
- * $Id: conn.h,v 1.40 2006/02/02 21:00:22 fw Exp $
+ * $Id: conn.h,v 1.41 2006/04/23 10:37:27 fw Exp $
*
* Connection management (header)
*/
typedef int CONN_ID;
+#include "client.h"
#ifdef CONN_MODULE
long msg_in, msg_out; /* Received and sent IRC messages */
int flag; /* Flag (see "irc-write" module) */
UINT16 options; /* Link options / connection state */
+ CLIENT *client; /* pointer to client structure */
#ifdef ZLIB
ZIPDATA zip; /* Compression information */
#endif /* ZLIB */
GLOBAL void Conn_SyncServerStruct PARAMS(( void ));
+GLOBAL CLIENT* Conn_GetClient PARAMS((CONN_ID i));
#endif
-
/* -eof- */
#include "portab.h"
-static char UNUSED id[] = "$Id: irc-info.c,v 1.31 2006/01/27 17:19:58 fw Exp $";
+static char UNUSED id[] = "$Id: irc-info.c,v 1.32 2006/04/23 10:37:27 fw Exp $";
#include "imp.h"
#include <assert.h>
con = Conn_First( );
while( con != NONE )
{
- cl = Client_GetFromConn( con );
+ cl = Conn_GetClient( con );
if( cl && (( Client_Type( cl ) == CLIENT_SERVER ) || ( cl == Client )))
{
/* Server link or our own connection */
#include "portab.h"
-static char UNUSED id[] = "$Id: irc-oper.c,v 1.24 2005/07/31 20:13:08 alex Exp $";
+static char UNUSED id[] = "$Id: irc-oper.c,v 1.25 2006/04/23 10:37:27 fw Exp $";
#include "imp.h"
#include <assert.h>
if( ! Conf_DisableServer( Req->argv[0] )) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] );
/* Are we still connected or were we killed, too? */
- if( Client_GetFromConn( my_conn )) return CONNECTED;
+ if( Conn_GetClient( my_conn )) return CONNECTED;
else return DISCONNECTED;
} /* IRC_CONNECT */
#include "portab.h"
-static char UNUSED id[] = "$Id: irc.c,v 1.128 2005/08/02 23:19:22 alex Exp $";
+static char UNUSED id[] = "$Id: irc.c,v 1.129 2006/04/23 10:37:27 fw Exp $";
#include "imp.h"
#include <assert.h>
Log( LOG_NOTICE, "Client with nick \"%s\" is unknown here.", Req->argv[0] );
/* Are we still connected or were we killed, too? */
- if(( my_conn > NONE ) && ( Client_GetFromConn( my_conn )))
+ if(( my_conn > NONE ) && ( Conn_GetClient( my_conn )))
return CONNECTED;
else
return DISCONNECTED;
#include "portab.h"
-static char UNUSED id[] = "$Id: parse.c,v 1.66 2005/09/04 23:42:24 alex Exp $";
+static char UNUSED id[] = "$Id: parse.c,v 1.67 2006/04/23 10:37:27 fw Exp $";
/**
* @file
if( ! Req->prefix ) return true;
/* Client-Struktur der Connection ermitteln */
- client = Client_GetFromConn( Idx );
+ client = Conn_GetClient( Idx );
assert( client != NULL );
/* nur validieren, wenn bereits registrierte Verbindung */
{
/* das angegebene Prefix ist aus dieser Richtung, also
* aus der gegebenen Connection, ungueltig! */
- Log( LOG_ERR, "Spoofed prefix \"%s\" from \"%s\" (connection %d, command %s)!", Req->prefix, Client_Mask( Client_GetFromConn( Idx )), Idx, Req->command );
+ Log( LOG_ERR, "Spoofed prefix \"%s\" from \"%s\" (connection %d, command %s)!", Req->prefix, Client_Mask( Conn_GetClient( Idx )), Idx, Req->command );
Conn_Close( Idx, NULL, "Spoofed prefix", true);
*Closed = true;
return false;
assert( Req != NULL );
assert( Req->command != NULL );
- client = Client_GetFromConn( Idx );
+ client = Conn_GetClient( Idx );
assert( client != NULL );
/* Statuscode? */