#include "portab.h"
#include "io.h"
-static char UNUSED id[] = "$Id: conn.c,v 1.167 2005/07/29 09:29:47 fw Exp $";
+static char UNUSED id[] = "$Id: conn.c,v 1.170 2005/08/15 23:02:40 alex Exp $";
#include "imp.h"
#include <assert.h>
#define SERVER_WAIT (NONE - 1)
-LOCAL bool Handle_Write PARAMS(( CONN_ID Idx ));
-LOCAL int New_Connection PARAMS(( int Sock ));
-LOCAL CONN_ID Socket2Index PARAMS(( int Sock ));
-LOCAL void Read_Request PARAMS(( CONN_ID Idx ));
-LOCAL bool Handle_Buffer PARAMS(( CONN_ID Idx ));
-LOCAL void Check_Connections PARAMS(( void ));
-LOCAL void Check_Servers PARAMS(( void ));
-LOCAL void Init_Conn_Struct PARAMS(( CONN_ID Idx ));
-LOCAL bool Init_Socket PARAMS(( int Sock ));
-LOCAL void New_Server PARAMS(( int Server, CONN_ID Idx ));
-LOCAL void Simple_Message PARAMS(( int Sock, char *Msg ));
-LOCAL int Count_Connections PARAMS(( struct sockaddr_in addr ));
-LOCAL int NewListener PARAMS(( const UINT16 Port ));
+static bool Handle_Write PARAMS(( CONN_ID Idx ));
+static int New_Connection PARAMS(( int Sock ));
+static CONN_ID Socket2Index PARAMS(( int Sock ));
+static void Read_Request PARAMS(( CONN_ID Idx ));
+static bool Handle_Buffer PARAMS(( CONN_ID Idx ));
+static void Check_Connections PARAMS(( void ));
+static void Check_Servers PARAMS(( void ));
+static void Init_Conn_Struct PARAMS(( CONN_ID Idx ));
+static bool Init_Socket PARAMS(( int Sock ));
+static void New_Server PARAMS(( int Server, CONN_ID Idx ));
+static void Simple_Message PARAMS(( int Sock, char *Msg ));
+static int Count_Connections PARAMS(( struct sockaddr_in addr ));
+static int NewListener PARAMS(( const UINT16 Port ));
static array My_Listeners;
}
-LOCAL void
+static void
FreeRes_stat( CONNECTION *c )
{
assert( c != NULL );
/* return new listening port file descriptor or -1 on failure */
-LOCAL int
+static int
NewListener( const UINT16 Port )
{
/* Create new listening socket on specified port */
c = Client_GetFromConn( Idx );
/* Should the client be informed? */
- if( InformClient )
- {
+ if (InformClient) {
#ifndef STRICT_RFC
/* Send statistics to client if registered as user: */
- if(( c != NULL ) && ( Client_Type( c ) == CLIENT_USER ))
- {
- Conn_WriteStr( Idx, "NOTICE %s :%sConnection statistics: client %.1f kb, server %.1f kb.", Client_ThisServer( ), NOTICE_TXTPREFIX, (double)My_Connections[Idx].bytes_in / 1024, (double)My_Connections[Idx].bytes_out / 1024 );
+ if ((c != NULL) && (Client_Type(c) == CLIENT_USER)) {
+ Conn_WriteStr( Idx,
+ "NOTICE %s :%sConnection statistics: client %.1f kb, server %.1f kb.",
+ Client_ID(Client_ThisServer()), NOTICE_TXTPREFIX,
+ (double)My_Connections[Idx].bytes_in / 1024,
+ (double)My_Connections[Idx].bytes_out / 1024);
}
#endif
/* Send ERROR to client (see RFC!) */
- if( FwdMsg ) Conn_WriteStr( Idx, "ERROR :%s", FwdMsg );
- else Conn_WriteStr( Idx, "ERROR :Closing connection." );
+ if (FwdMsg)
+ Conn_WriteStr(Idx, "ERROR :%s", FwdMsg);
+ else
+ Conn_WriteStr(Idx, "ERROR :Closing connection.");
}
/* Try to write out the write buffer */
} /* SyncServerStruct */
-LOCAL bool
+static bool
Handle_Write( CONN_ID Idx )
{
/* Daten aus Schreibpuffer versenden bzw. Connection aufbauen */
} /* Handle_Write */
-LOCAL int
+static int
New_Connection( int Sock )
{
/* Neue Client-Verbindung von Listen-Socket annehmen und
} /* New_Connection */
-LOCAL CONN_ID
+static CONN_ID
Socket2Index( int Sock )
{
/* zum Socket passende Connection suchen */
} /* Socket2Index */
-LOCAL void
+static void
Read_Request( CONN_ID Idx )
{
/* Daten von Socket einlesen und entsprechend behandeln.
} /* Read_Request */
-LOCAL bool
+static bool
Handle_Buffer( CONN_ID Idx )
{
/* Handle Data in Connections Read-Buffer.
} /* Handle_Buffer */
-LOCAL void
+static void
Check_Connections( void )
{
/* check if connections are alive. if not, play PING-PONG first.
} /* Check_Connections */
-LOCAL void
+static void
Check_Servers( void )
{
/* Check if we can establish further server links */
} /* Check_Servers */
-LOCAL void
+static void
New_Server( int Server, CONN_ID Idx )
{
/* Establish new server link */
} /* New_Server */
-LOCAL void
+static void
Init_Conn_Struct( CONN_ID Idx )
{
time_t now = time( NULL );
} /* Init_Conn_Struct */
-LOCAL bool
+static bool
Init_Socket( int Sock )
{
/* Initialize socket (set options) */
char *bufptr;
char readbuf[HOST_LEN];
- Log( LOG_DEBUG, "Resolver: started, fd %d\n", r_fd );
+ Log( LOG_DEBUG, "Resolver: started, fd %d", r_fd );
/* Search associated connection ... */
for( i = 0; i < Pool_Size; i++ )
{
} /* Read_Resolver_Result */
-LOCAL void
+static void
Simple_Message( int Sock, char *Msg )
{
char buf[COMMAND_LEN];
} /* Simple_Error */
-LOCAL int
+static int
Count_Connections( struct sockaddr_in addr_in )
{
int i, cnt;