]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/conn.h
- Client structures are removed correctly now if an outgoing connection can't be...
[ngircd-alex.git] / src / ngircd / conn.h
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  */
15
16
17 #ifndef __conn_h__
18 #define __conn_h__
19
20
21 #include <time.h>                       /* wg. time_t, s.u. */
22
23
24 #ifdef USE_ZLIB
25 #define CONN_ZIP 4                      /* Kompression mit zlib */
26 #endif
27
28
29 typedef INT CONN_ID;
30
31
32 #ifdef CONN_MODULE
33
34 #include "defines.h"
35 #include "resolve.h"
36
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 */
50
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;
74
75 GLOBAL CONNECTION *My_Connections;
76 GLOBAL CONN_ID Pool_Size;
77 GLOBAL LONG WCounter;
78
79 #endif /* CONN_MODULE */
80
81
82 GLOBAL VOID Conn_Init PARAMS((VOID ));
83 GLOBAL VOID Conn_Exit PARAMS(( VOID ));
84
85 GLOBAL INT Conn_InitListeners PARAMS(( VOID ));
86 GLOBAL VOID Conn_ExitListeners PARAMS(( VOID ));
87
88 GLOBAL BOOLEAN Conn_NewListener PARAMS(( CONST UINT Port ));
89
90 GLOBAL VOID Conn_Handler PARAMS(( VOID ));
91
92 GLOBAL BOOLEAN Conn_Write PARAMS(( CONN_ID Idx, CHAR *Data, INT Len ));
93 GLOBAL BOOLEAN Conn_WriteStr PARAMS(( CONN_ID Idx, CHAR *Format, ... ));
94
95 GLOBAL VOID Conn_Close PARAMS(( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient ));
96
97
98 GLOBAL INT Conn_MaxFD;
99
100
101 #endif
102
103
104 /* -eof- */