]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/conn.h
- New source files "conn-zip.c" and "conn-zip.h".
[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.28 2002/12/30 16:07:23 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 #if defined(__conn_c__) || defined(__conn_zip_c__)
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
78 #endif /* defined() */
79
80
81 GLOBAL VOID Conn_Init PARAMS((VOID ));
82 GLOBAL VOID Conn_Exit PARAMS(( VOID ));
83
84 GLOBAL INT Conn_InitListeners PARAMS(( VOID ));
85 GLOBAL VOID Conn_ExitListeners PARAMS(( VOID ));
86
87 GLOBAL BOOLEAN Conn_NewListener PARAMS(( CONST UINT Port ));
88
89 GLOBAL VOID Conn_Handler PARAMS(( VOID ));
90
91 GLOBAL BOOLEAN Conn_Write PARAMS(( CONN_ID Idx, CHAR *Data, INT Len ));
92 GLOBAL BOOLEAN Conn_WriteStr PARAMS(( CONN_ID Idx, CHAR *Format, ... ));
93
94 GLOBAL VOID Conn_Close PARAMS(( CONN_ID Idx, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN InformClient ));
95
96 GLOBAL VOID Conn_UpdateIdle PARAMS(( CONN_ID Idx ));
97 GLOBAL time_t Conn_GetIdle PARAMS(( CONN_ID Idx ));
98 GLOBAL time_t Conn_LastPing PARAMS(( CONN_ID Idx ));
99 GLOBAL time_t Conn_StartTime PARAMS(( CONN_ID Idx ));
100 GLOBAL INT Conn_SendQ PARAMS(( CONN_ID Idx ));
101 GLOBAL INT Conn_RecvQ PARAMS(( CONN_ID Idx ));
102 GLOBAL LONG Conn_SendMsg PARAMS(( CONN_ID Idx ));
103 GLOBAL LONG Conn_RecvMsg PARAMS(( CONN_ID Idx ));
104 GLOBAL LONG Conn_SendBytes PARAMS(( CONN_ID Idx ));
105 GLOBAL LONG Conn_RecvBytes PARAMS(( CONN_ID Idx ));
106
107 GLOBAL VOID Conn_SetPenalty PARAMS(( CONN_ID Idx, time_t Seconds ));
108 GLOBAL VOID Conn_ResetPenalty PARAMS(( CONN_ID Idx ));
109
110 GLOBAL VOID Conn_ClearFlags PARAMS(( VOID ));
111 GLOBAL INT Conn_Flag PARAMS(( CONN_ID Idx ));
112 GLOBAL VOID Conn_SetFlag PARAMS(( CONN_ID Idx, INT Flag ));
113
114 GLOBAL CONN_ID Conn_First PARAMS(( VOID ));
115 GLOBAL CONN_ID Conn_Next PARAMS(( CONN_ID Idx ));
116
117 GLOBAL VOID Conn_SetOption PARAMS(( CONN_ID Idx, INT Option ));
118 GLOBAL VOID Conn_UnsetOption PARAMS(( CONN_ID Idx, INT Option ));
119 GLOBAL INT Conn_Options PARAMS(( CONN_ID Idx ));
120
121 GLOBAL VOID Conn_ResetWCounter PARAMS(( VOID ));
122 GLOBAL LONG Conn_WCounter PARAMS(( VOID ));
123
124
125 GLOBAL INT Conn_MaxFD;
126
127
128 #endif
129
130
131 /* -eof- */