conn.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.42.2.1 2007/05/09 13:21:38 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. #ifdef ZLIB
  30. #include <zlib.h>
  31. typedef struct _ZipData
  32. {
  33. z_stream in; /* "Handle" for input stream */
  34. z_stream out; /* "Handle" for output stream */
  35. array rbuf; /* Read buffer (compressed) */
  36. array wbuf; /* 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 */
  45. char host[HOST_LEN]; /* Hostname */
  46. array rbuf; /* Read buffer */
  47. array wbuf; /* Write buffer */
  48. time_t lastdata; /* Last activity */
  49. time_t lastping; /* Last PING */
  50. time_t lastprivmsg; /* Last PRIVMSG */
  51. time_t delaytime; /* Ignore link ("penalty") */
  52. long bytes_in, bytes_out; /* Received and sent bytes */
  53. long msg_in, msg_out; /* Received and sent IRC messages */
  54. int flag; /* Flag (see "irc-write" module) */
  55. UINT16 options; /* Link options / connection state */
  56. CLIENT *client; /* pointer to client structure */
  57. #ifdef ZLIB
  58. ZIPDATA zip; /* Compression information */
  59. #endif /* ZLIB */
  60. } CONNECTION;
  61. GLOBAL CONNECTION *My_Connections;
  62. GLOBAL CONN_ID Pool_Size;
  63. GLOBAL long WCounter;
  64. #endif /* CONN_MODULE */
  65. GLOBAL void Conn_Init PARAMS((void ));
  66. GLOBAL void Conn_Exit PARAMS(( void ));
  67. GLOBAL int Conn_InitListeners PARAMS(( void ));
  68. GLOBAL void Conn_ExitListeners PARAMS(( void ));
  69. GLOBAL void Conn_Handler PARAMS(( void ));
  70. GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, char *Format, ... ));
  71. GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient ));
  72. GLOBAL void Conn_SyncServerStruct PARAMS(( void ));
  73. GLOBAL CLIENT* Conn_GetClient PARAMS((CONN_ID i));
  74. #endif
  75. /* -eof- */