conn.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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.35.2.1 2005/07/30 23:24:50 alex Exp $
  12. *
  13. * Connection management (header)
  14. */
  15. #ifndef __conn_h__
  16. #define __conn_h__
  17. #include <time.h> /* for time_t, see below */
  18. #define CONN_ISCLOSING 1 /* Conn_Close() already called */
  19. #define CONN_ISCONNECTING 2 /* connect() in progress */
  20. #ifdef ZLIB
  21. #define CONN_ZIP 4 /* zlib compressed link */
  22. #endif
  23. typedef int CONN_ID;
  24. #ifdef CONN_MODULE
  25. #include "defines.h"
  26. #include "resolve.h"
  27. #ifdef ZLIB
  28. #include <zlib.h>
  29. typedef struct _ZipData
  30. {
  31. z_stream in; /* "Handle" for input stream */
  32. z_stream out; /* "Handle" for output stream */
  33. char rbuf[READBUFFER_LEN]; /* Read buffer */
  34. int rdatalen; /* Length of data in read buffer (compressed) */
  35. char wbuf[WRITEBUFFER_LEN]; /* Write buffer */
  36. int wdatalen; /* Length of data in write buffer (uncompressed) */
  37. long bytes_in, bytes_out; /* Counter for statistics (uncompressed!) */
  38. } ZIPDATA;
  39. #endif /* ZLIB */
  40. typedef struct _Connection
  41. {
  42. int sock; /* Socket handle */
  43. struct sockaddr_in addr; /* Client address */
  44. RES_STAT *res_stat; /* Status of resolver process, if any */
  45. char host[HOST_LEN]; /* Hostname */
  46. char rbuf[READBUFFER_LEN]; /* Read buffer */
  47. int rdatalen; /* Length of data in read buffer */
  48. char wbuf[WRITEBUFFER_LEN]; /* Write buffer */
  49. int wdatalen; /* Length of data in write buffer */
  50. time_t lastdata; /* Last activity */
  51. time_t lastping; /* Last PING */
  52. time_t lastprivmsg; /* Last PRIVMSG */
  53. time_t delaytime; /* Ignore link ("penalty") */
  54. long bytes_in, bytes_out; /* Received and sent bytes */
  55. long msg_in, msg_out; /* Received and sent IRC messages */
  56. int flag; /* Flag (see "irc-write" module) */
  57. UINT16 options; /* Link options / connection state */
  58. #ifdef ZLIB
  59. ZIPDATA zip; /* Compression information */
  60. #endif /* ZLIB */
  61. } CONNECTION;
  62. GLOBAL CONNECTION *My_Connections;
  63. GLOBAL CONN_ID Pool_Size;
  64. GLOBAL long WCounter;
  65. #endif /* CONN_MODULE */
  66. GLOBAL void Conn_Init PARAMS((void ));
  67. GLOBAL void Conn_Exit PARAMS(( void ));
  68. GLOBAL int Conn_InitListeners PARAMS(( void ));
  69. GLOBAL void Conn_ExitListeners PARAMS(( void ));
  70. GLOBAL bool Conn_NewListener PARAMS(( const UINT16 Port ));
  71. GLOBAL void Conn_Handler PARAMS(( void ));
  72. GLOBAL bool Conn_Write PARAMS(( CONN_ID Idx, char *Data, int Len ));
  73. GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, char *Format, ... ));
  74. GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient ));
  75. GLOBAL void Conn_SyncServerStruct PARAMS(( void ));
  76. GLOBAL int Conn_MaxFD;
  77. #endif
  78. /* -eof- */