]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/conn.h
Remove INT, LONG, BOOLEAN, STATIC, CONST, CHAR datatypes.
[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.33 2005/03/19 18:43:48 fw Exp $
12  *
13  * Connection management (header)
14  */
15
16
17 #ifndef __conn_h__
18 #define __conn_h__
19
20
21 #include <time.h>                       /* for time_t, see below */
22
23
24 #define CONN_ISCLOSING 1                /* Conn_Close() already called */
25
26 #ifdef ZLIB
27 #define CONN_ZIP 2                      /* zlib compressed link */
28 #endif
29
30
31 typedef int CONN_ID;
32
33
34 #ifdef CONN_MODULE
35
36 #include "defines.h"
37 #include "resolve.h"
38
39 #ifdef ZLIB
40 #include <zlib.h>
41 typedef struct _ZipData
42 {
43         z_stream in;                    /* "Handle" for input stream */
44         z_stream out;                   /* "Handle" for output stream */
45         char rbuf[READBUFFER_LEN];      /* Read buffer */
46         int rdatalen;                   /* Length of data in read buffer (compressed) */
47         char wbuf[WRITEBUFFER_LEN];     /* Write buffer */
48         int wdatalen;                   /* Length of data in write buffer (uncompressed) */
49         long bytes_in, bytes_out;       /* Counter for statistics (uncompressed!) */
50 } ZIPDATA;
51 #endif /* ZLIB */
52
53 typedef struct _Connection
54 {
55         int sock;                       /* Socket handle */
56         struct sockaddr_in addr;        /* Client address */
57         RES_STAT *res_stat;             /* Status of resolver process, if any */
58         char host[HOST_LEN];            /* Hostname */
59         char rbuf[READBUFFER_LEN];      /* Read buffer */
60         int rdatalen;                   /* Length of data in read buffer */
61         char wbuf[WRITEBUFFER_LEN];     /* Write buffer */
62         int wdatalen;                   /* Length of data in write buffer */
63         time_t starttime;               /* Start time of link */
64         time_t lastdata;                /* Last activity */
65         time_t lastping;                /* Last PING */
66         time_t lastprivmsg;             /* Last PRIVMSG */
67         time_t delaytime;               /* Ignore link ("penalty") */
68         long bytes_in, bytes_out; /* Received and sent bytes */
69         long msg_in, msg_out;     /* Received and sent IRC messages */
70         int flag;                       /* Flag (see "irc-write" module) */
71         int options;                    /* Link options */
72 #ifdef ZLIB
73         ZIPDATA zip;                    /* Compression information */
74 #endif  /* ZLIB */
75 } CONNECTION;
76
77 GLOBAL CONNECTION *My_Connections;
78 GLOBAL CONN_ID Pool_Size;
79 GLOBAL long WCounter;
80
81 #endif /* CONN_MODULE */
82
83
84 GLOBAL void Conn_Init PARAMS((void ));
85 GLOBAL void Conn_Exit PARAMS(( void ));
86
87 GLOBAL int Conn_InitListeners PARAMS(( void ));
88 GLOBAL void Conn_ExitListeners PARAMS(( void ));
89
90 GLOBAL bool Conn_NewListener PARAMS(( const UINT16 Port ));
91
92 GLOBAL void Conn_Handler PARAMS(( void ));
93
94 GLOBAL bool Conn_Write PARAMS(( CONN_ID Idx, char *Data, int Len ));
95 GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, char *Format, ... ));
96
97 GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient ));
98
99 GLOBAL void Conn_SyncServerStruct PARAMS(( void ));
100
101 GLOBAL int Conn_MaxFD;
102
103
104 #endif
105
106
107 /* -eof- */