Blob


1 /*
2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
4 *
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.
10 *
11 * $Id: conn.h,v 1.29 2002/12/30 17:14:59 alex Exp $
12 *
13 * Connection management (header)
14 */
17 #ifndef __conn_h__
18 #define __conn_h__
21 #include <time.h> /* wg. time_t, s.u. */
24 #ifdef USE_ZLIB
25 #define CONN_ZIP 4 /* Kompression mit zlib */
26 #endif
29 typedef INT CONN_ID;
32 #ifdef CONN_MODULE
34 #include "defines.h"
35 #include "resolve.h"
37 #ifdef USE_ZLIB
38 #include <zlib.h>
39 typedef struct _ZipData
40 {
41 z_stream in; /* "Handle" for input stream */
42 z_stream out; /* "Handle" for output stream */
43 CHAR rbuf[READBUFFER_LEN]; /* Read buffer */
44 INT rdatalen; /* Length of data in read buffer (compressed) */
45 CHAR wbuf[WRITEBUFFER_LEN]; /* Write buffer */
46 INT wdatalen; /* Length of data in write buffer (uncompressed) */
47 LONG bytes_in, bytes_out; /* Counter for statistics (uncompressed!) */
48 } ZIPDATA;
49 #endif /* USE_ZLIB */
51 typedef struct _Connection
52 {
53 INT sock; /* Socket handle */
54 struct sockaddr_in addr; /* Client address */
55 RES_STAT *res_stat; /* Status of resolver process, if any */
56 CHAR host[HOST_LEN]; /* Hostname */
57 CHAR rbuf[READBUFFER_LEN]; /* Read buffer */
58 INT rdatalen; /* Length of data in read buffer */
59 CHAR wbuf[WRITEBUFFER_LEN]; /* Write buffer */
60 INT wdatalen; /* Length of data in write buffer */
61 time_t starttime; /* Start time of link */
62 time_t lastdata; /* Last activity */
63 time_t lastping; /* Last PING */
64 time_t lastprivmsg; /* Last PRIVMSG */
65 time_t delaytime; /* Ignore link ("penalty") */
66 LONG bytes_in, bytes_out; /* Received and sent bytes */
67 LONG msg_in, msg_out; /* Received and sent IRC messages */
68 INT flag; /* Flag (see "irc-write" module) */
69 INT options; /* Link options */
70 #ifdef USE_ZLIB
71 ZIPDATA zip; /* Compression information */
72 #endif /* USE_ZLIB */
73 } CONNECTION;
75 GLOBAL CONNECTION *My_Connections;
76 GLOBAL CONN_ID Pool_Size;
77 GLOBAL LONG WCounter;
79 #endif /* CONN_MODULE */
82 GLOBAL VOID Conn_Init PARAMS((VOID ));
83 GLOBAL VOID Conn_Exit PARAMS(( VOID ));
85 GLOBAL INT Conn_InitListeners PARAMS(( VOID ));
86 GLOBAL VOID Conn_ExitListeners PARAMS(( VOID ));
88 GLOBAL BOOLEAN Conn_NewListener PARAMS(( CONST UINT Port ));
90 GLOBAL VOID Conn_Handler PARAMS(( VOID ));
92 GLOBAL BOOLEAN Conn_Write PARAMS(( CONN_ID Idx, CHAR *Data, INT Len ));
93 GLOBAL BOOLEAN Conn_WriteStr PARAMS(( CONN_ID Idx, CHAR *Format, ... ));
95 GLOBAL VOID Conn_Close PARAMS(( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient ));
98 GLOBAL INT Conn_MaxFD;
101 #endif
104 /* -eof- */