channel.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * ngIRCd -- The Next Generation IRC Daemon
  3. * Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors.
  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. #ifndef __channel_h__
  12. #define __channel_h__
  13. /**
  14. * @file
  15. * Channel management (header)
  16. */
  17. #if defined(__channel_c__) | defined(S_SPLINT_S)
  18. #include "lists.h"
  19. #include "defines.h"
  20. #include "array.h"
  21. typedef struct _CHANNEL
  22. {
  23. struct _CHANNEL *next;
  24. char name[CHANNEL_NAME_LEN]; /* Name of the channel */
  25. UINT32 hash; /* Hash of the (lowecase!) name */
  26. char modes[CHANNEL_MODE_LEN]; /* Channel modes */
  27. array topic; /* Topic of the channel */
  28. #ifndef STRICT_RFC
  29. time_t creation_time; /* Channel creation time */
  30. time_t topic_time; /* Time when topic was set */
  31. char topic_who[CLIENT_NICK_LEN];/* Nickname of user that set topic */
  32. #endif
  33. char key[CLIENT_PASS_LEN]; /* Channel key ("password", mode "k" ) */
  34. unsigned long maxusers; /* Maximum number of members (mode "l") */
  35. struct list_head list_bans; /* list head of banned users */
  36. struct list_head list_excepts; /* list head of (ban) exception list */
  37. struct list_head list_invites; /* list head of invited users */
  38. array keyfile; /* Name of the channel key file */
  39. } CHANNEL;
  40. typedef struct _CLIENT2CHAN
  41. {
  42. struct _CLIENT2CHAN *next;
  43. CLIENT *client;
  44. CHANNEL *channel;
  45. char modes[CHANNEL_MODE_LEN]; /* User-Modes in Channel */
  46. } CL2CHAN;
  47. #else
  48. typedef POINTER CHANNEL;
  49. typedef POINTER CL2CHAN;
  50. #endif
  51. GLOBAL struct list_head *Channel_GetListBans PARAMS((CHANNEL *c));
  52. GLOBAL struct list_head *Channel_GetListExcepts PARAMS((CHANNEL *c));
  53. GLOBAL struct list_head *Channel_GetListInvites PARAMS((CHANNEL *c));
  54. GLOBAL void Channel_Init PARAMS(( void ));
  55. GLOBAL void Channel_InitPredefined PARAMS(( void ));
  56. GLOBAL void Channel_Exit PARAMS(( void ));
  57. GLOBAL bool Channel_Join PARAMS(( CLIENT *Client, const char *Name ));
  58. GLOBAL bool Channel_Part PARAMS(( CLIENT *Client, CLIENT *Origin, const char *Name, const char *Reason ));
  59. GLOBAL void Channel_Quit PARAMS(( CLIENT *Client, const char *Reason ));
  60. GLOBAL void Channel_Kick PARAMS((CLIENT *Peer, CLIENT *Target, CLIENT *Origin,
  61. const char *Name, const char *Reason));
  62. GLOBAL unsigned long Channel_CountVisible PARAMS((CLIENT *Client));
  63. GLOBAL unsigned long Channel_MemberCount PARAMS(( CHANNEL *Chan ));
  64. GLOBAL int Channel_CountForUser PARAMS(( CLIENT *Client ));
  65. GLOBAL const char *Channel_Name PARAMS(( const CHANNEL *Chan ));
  66. GLOBAL char *Channel_Modes PARAMS(( CHANNEL *Chan ));
  67. GLOBAL char *Channel_Topic PARAMS(( CHANNEL *Chan ));
  68. GLOBAL char *Channel_Key PARAMS(( CHANNEL *Chan ));
  69. GLOBAL unsigned long Channel_MaxUsers PARAMS(( CHANNEL *Chan ));
  70. GLOBAL void Channel_SetTopic PARAMS(( CHANNEL *Chan, CLIENT *Client, const char *Topic ));
  71. GLOBAL void Channel_SetModes PARAMS(( CHANNEL *Chan, const char *Modes ));
  72. GLOBAL void Channel_SetKey PARAMS(( CHANNEL *Chan, const char *Key ));
  73. GLOBAL void Channel_SetMaxUsers PARAMS(( CHANNEL *Chan, unsigned long Count ));
  74. GLOBAL CHANNEL *Channel_Search PARAMS(( const char *Name ));
  75. GLOBAL CHANNEL *Channel_First PARAMS(( void ));
  76. GLOBAL CHANNEL *Channel_Next PARAMS(( CHANNEL *Chan ));
  77. GLOBAL CL2CHAN *Channel_FirstMember PARAMS(( CHANNEL *Chan ));
  78. GLOBAL CL2CHAN *Channel_NextMember PARAMS(( CHANNEL *Chan, CL2CHAN *Cl2Chan ));
  79. GLOBAL CL2CHAN *Channel_FirstChannelOf PARAMS(( CLIENT *Client ));
  80. GLOBAL CL2CHAN *Channel_NextChannelOf PARAMS(( CLIENT *Client, CL2CHAN *Cl2Chan ));
  81. GLOBAL CLIENT *Channel_GetClient PARAMS(( CL2CHAN *Cl2Chan ));
  82. GLOBAL CHANNEL *Channel_GetChannel PARAMS(( CL2CHAN *Cl2Chan ));
  83. GLOBAL bool Channel_IsValidName PARAMS(( const char *Name ));
  84. GLOBAL bool Channel_ModeAdd PARAMS(( CHANNEL *Chan, char Mode ));
  85. GLOBAL bool Channel_ModeDel PARAMS(( CHANNEL *Chan, char Mode ));
  86. GLOBAL bool Channel_UserModeAdd PARAMS(( CHANNEL *Chan, CLIENT *Client, char Mode ));
  87. GLOBAL bool Channel_UserModeDel PARAMS(( CHANNEL *Chan, CLIENT *Client, char Mode ));
  88. GLOBAL char *Channel_UserModes PARAMS(( CHANNEL *Chan, CLIENT *Client ));
  89. GLOBAL bool Channel_IsMemberOf PARAMS(( CHANNEL *Chan, CLIENT *Client ));
  90. GLOBAL bool Channel_Write PARAMS((CHANNEL *Chan, CLIENT *From, CLIENT *Client,
  91. const char *Command, bool SendErrors,
  92. const char *Text));
  93. GLOBAL CHANNEL *Channel_Create PARAMS(( const char *Name ));
  94. #ifndef STRICT_RFC
  95. GLOBAL unsigned int Channel_TopicTime PARAMS(( CHANNEL *Chan ));
  96. GLOBAL char *Channel_TopicWho PARAMS(( CHANNEL *Chan ));
  97. GLOBAL unsigned int Channel_CreationTime PARAMS(( CHANNEL *Chan ));
  98. #endif
  99. GLOBAL bool Channel_AddBan PARAMS((CHANNEL *c, const char *Mask));
  100. GLOBAL bool Channel_AddExcept PARAMS((CHANNEL *c, const char *Mask));
  101. GLOBAL bool Channel_AddInvite PARAMS((CHANNEL *c, const char *Mask,
  102. bool OnlyOnce));
  103. GLOBAL bool Channel_ShowBans PARAMS((CLIENT *client, CHANNEL *c));
  104. GLOBAL bool Channel_ShowExcepts PARAMS((CLIENT *client, CHANNEL *c));
  105. GLOBAL bool Channel_ShowInvites PARAMS((CLIENT *client, CHANNEL *c));
  106. GLOBAL void Channel_LogServer PARAMS((const char *msg));
  107. GLOBAL bool Channel_CheckKey PARAMS((CHANNEL *Chan, CLIENT *Client,
  108. const char *Key));
  109. GLOBAL void Channel_CheckAdminRights PARAMS((CHANNEL *Chan, CLIENT *Client,
  110. CLIENT *Origin, bool *OnChannel,
  111. bool *AdminOk, bool *UseServerMode));
  112. #define Channel_IsLocal(c) (Channel_Name(c)[0] == '&')
  113. #define Channel_IsModeless(c) (Channel_Name(c)[0] == '+')
  114. #endif
  115. /* -eof- */