2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * Please read the file COPYING, README and AUTHORS for more information.
11 * $Id: conn.h,v 1.39 2005/09/12 19:10:20 fw Exp $
13 * Connection management (header)
21 #include <time.h> /* for time_t, see below */
24 #define CONN_ISCLOSING 1 /* Conn_Close() already called */
25 #define CONN_ISCONNECTING 2 /* connect() in progress */
28 #define CONN_ZIP 4 /* zlib compressed link */
43 typedef struct _ZipData
45 z_stream in; /* "Handle" for input stream */
46 z_stream out; /* "Handle" for output stream */
47 array rbuf; /* Read buffer (compressed) */
48 array wbuf; /* Write buffer (uncompressed) */
49 long bytes_in, bytes_out; /* Counter for statistics (uncompressed!) */
53 typedef struct _Connection
55 int sock; /* Socket handle */
56 struct sockaddr_in addr; /* Client address */
57 RES_STAT res_stat; /* Status of resolver process */
58 char host[HOST_LEN]; /* Hostname */
59 array rbuf; /* Read buffer */
60 array wbuf; /* Write buffer */
61 time_t lastdata; /* Last activity */
62 time_t lastping; /* Last PING */
63 time_t lastprivmsg; /* Last PRIVMSG */
64 time_t delaytime; /* Ignore link ("penalty") */
65 long bytes_in, bytes_out; /* Received and sent bytes */
66 long msg_in, msg_out; /* Received and sent IRC messages */
67 int flag; /* Flag (see "irc-write" module) */
68 UINT16 options; /* Link options / connection state */
70 ZIPDATA zip; /* Compression information */
74 GLOBAL CONNECTION *My_Connections;
75 GLOBAL CONN_ID Pool_Size;
78 #endif /* CONN_MODULE */
81 GLOBAL void Conn_Init PARAMS((void ));
82 GLOBAL void Conn_Exit PARAMS(( void ));
84 GLOBAL int Conn_InitListeners PARAMS(( void ));
85 GLOBAL void Conn_ExitListeners PARAMS(( void ));
87 GLOBAL void Conn_Handler PARAMS(( void ));
89 GLOBAL bool Conn_Write PARAMS(( CONN_ID Idx, char *Data, unsigned int Len ));
90 GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, char *Format, ... ));
92 GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient ));
94 GLOBAL void Conn_SyncServerStruct PARAMS(( void ));
96 GLOBAL int Conn_MaxFD;