conn.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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.46 2008/02/26 22:04:17 fw 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. #include "client.h"
  25. #ifdef CONN_MODULE
  26. #include "defines.h"
  27. #include "resolve.h"
  28. #include "array.h"
  29. #include "tool.h"
  30. #include "ng_ipaddr.h"
  31. #ifdef ZLIB
  32. #include <zlib.h>
  33. typedef struct _ZipData
  34. {
  35. z_stream in; /* "Handle" for input stream */
  36. z_stream out; /* "Handle" for output stream */
  37. array rbuf; /* Read buffer (compressed) */
  38. array wbuf; /* Write buffer (uncompressed) */
  39. long bytes_in, bytes_out; /* Counter for statistics (uncompressed!) */
  40. } ZIPDATA;
  41. #endif /* ZLIB */
  42. typedef struct _Connection
  43. {
  44. int sock; /* Socket handle */
  45. ng_ipaddr_t addr; /* Client address */
  46. RES_STAT res_stat; /* Status of resolver process */
  47. char host[HOST_LEN]; /* Hostname */
  48. array rbuf; /* Read buffer */
  49. array wbuf; /* Write buffer */
  50. time_t signon; /* Signon ("connect") time */
  51. time_t lastdata; /* Last activity */
  52. time_t lastping; /* Last PING */
  53. time_t lastprivmsg; /* Last PRIVMSG */
  54. time_t delaytime; /* Ignore link ("penalty") */
  55. long bytes_in, bytes_out; /* Received and sent bytes */
  56. long msg_in, msg_out; /* Received and sent IRC messages */
  57. int flag; /* Flag (see "irc-write" module) */
  58. UINT16 options; /* Link options / connection state */
  59. CLIENT *client; /* pointer to client structure */
  60. #ifdef ZLIB
  61. ZIPDATA zip; /* Compression information */
  62. #endif /* ZLIB */
  63. } CONNECTION;
  64. GLOBAL CONNECTION *My_Connections;
  65. GLOBAL CONN_ID Pool_Size;
  66. GLOBAL long WCounter;
  67. #endif /* CONN_MODULE */
  68. GLOBAL void Conn_Init PARAMS((void ));
  69. GLOBAL void Conn_Exit PARAMS(( void ));
  70. GLOBAL unsigned int Conn_InitListeners PARAMS(( void ));
  71. GLOBAL void Conn_ExitListeners PARAMS(( void ));
  72. GLOBAL void Conn_Handler PARAMS(( void ));
  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 CLIENT* Conn_GetClient PARAMS((CONN_ID i));
  77. #endif
  78. /* -eof- */