167e9cf2346c00b2fc360b536dea22e7d0a8b396
[ircu2.10.12-pk.git] / include / channel.h
1 /*
2  * IRC - Internet Relay Chat, ircd/channel.h
3  * Copyright (C) 1990 Jarkko Oikarinen
4  * Copyright (C) 1996 - 1997 Carlo Wood
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 #include "list.h"
22
23 #ifndef CHANNEL_H
24 #define CHANNEL_H
25
26 /*=============================================================================
27  * General defines
28  */
29
30 #define MAXMODEPARAMS   6
31 #define MODEBUFLEN      200
32
33 #define KEYLEN          23
34 #define TOPICLEN        160
35 #define CHANNELLEN      200
36 #define MAXBANS         30
37 #define MAXBANLENGTH    1024
38
39 /*=============================================================================
40  * Macro's
41  */
42
43 #define ChannelExists(n)        (FindChannel(n) != NullChn)
44 #define NullChn ((aChannel *)0)
45 #define CREATE 1                /* whether a channel should be
46                                  * created or just tested for existance */
47
48 #define CHFL_CHANOP             0x0001  /* Channel operator */
49 #define CHFL_VOICE              0x0002  /* the power to speak */
50 #define CHFL_DEOPPED            0x0004  /* Is de-opped by a server */
51 #define CHFL_SERVOPOK           0x0008  /* Server op allowed */
52 #define CHFL_ZOMBIE             0x0010  /* Kicked from channel */
53 #define CHFL_BAN                0x0020  /* ban channel flag */
54 #define CHFL_BAN_IPMASK         0x0040  /* ban mask is an IP-number mask */
55 #define CHFL_BAN_OVERLAPPED     0x0080  /* ban overlapped, need bounce */
56 #define CHFL_OVERLAP    (CHFL_CHANOP|CHFL_VOICE)
57 #define CHFL_BURST_JOINED       0x0100  /* Just joined by net.junction */
58 #define CHFL_BURST_BAN          0x0200  /* Ban part of last BURST */
59 #define CHFL_BURST_BAN_WIPEOUT  0x0400  /* Ban will be wiped at end of BURST */
60 #define CHFL_BANVALID           0x0800  /* CHFL_BANNED bit is valid */
61 #define CHFL_BANNED             0x1000  /* Channel member is banned */
62 #define CHFL_SILENCE_IPMASK     0x2000  /* silence mask is an IP-number mask */
63
64 /* Channel Visibility macros */
65
66 #define MODE_CHANOP     CHFL_CHANOP
67 #define MODE_VOICE      CHFL_VOICE
68 #define MODE_PRIVATE    0x0004
69 #define MODE_SECRET     0x0008
70 #define MODE_MODERATED  0x0010
71 #define MODE_TOPICLIMIT 0x0020
72 #define MODE_INVITEONLY 0x0040
73 #define MODE_NOPRIVMSGS 0x0080
74 #define MODE_KEY        0x0100
75 #define MODE_BAN        0x0200
76 #define MODE_LIMIT      0x0400
77 #define MODE_SENDTS     0x0800  /* TS was 0 during a local user /join; send
78                                  * temporary TS; can be removed when all 2.10 */
79 #define MODE_LISTED     0x10000
80
81 /*
82  * mode flags which take another parameter (With PARAmeterS)
83  */
84 #define MODE_WPARAS     (MODE_CHANOP|MODE_VOICE|MODE_BAN|MODE_KEY|MODE_LIMIT)
85
86 #define HoldChannel(x)          (!(x))
87 /* name invisible */
88 #define SecretChannel(x)        ((x) && ((x)->mode.mode & MODE_SECRET))
89 /* channel not shown but names are */
90 #define HiddenChannel(x)        ((x) && ((x)->mode.mode & MODE_PRIVATE))
91 /* channel visible */
92 #define ShowChannel(v,c)        (PubChannel(c) || IsMember((v),(c)))
93 #define PubChannel(x)           ((!x) || ((x)->mode.mode & \
94                                     (MODE_PRIVATE | MODE_SECRET)) == 0)
95 #define is_listed(x)            ((x)->mode.mode & MODE_LISTED)
96
97 #define IsLocalChannel(name)    (*(name) == '&')
98 #define IsModelessChannel(name) (*(name) == '+')
99 #define IsChannelName(name)     (*(name) == '#' || \
100                                 IsModelessChannel(name) || IsLocalChannel(name))
101
102 /* Check if a sptr is an oper, and chptr is a local channel. */
103
104 #define IsOperOnLocalChannel(sptr,chname) ((IsOper(sptr)) && (IsLocalChannel(chname)))
105
106 /* used in SetMode() in channel.c and m_umode() in s_msg.c */
107
108 #define MODE_NULL      0
109 #define MODE_ADD       0x40000000
110 #define MODE_DEL       0x20000000
111
112 /*=============================================================================
113  * Structures
114  */
115
116 struct SMode {
117   unsigned int mode;
118   unsigned int limit;
119   char key[KEYLEN + 1];
120 };
121
122 struct Channel {
123   struct Channel *nextch, *prevch, *hnextch;
124   Mode mode;
125   time_t creationtime;
126   char topic[TOPICLEN + 1];
127   char topic_nick[NICKLEN + 1];
128   time_t topic_time;
129   unsigned int users;
130   struct SLink *members;
131   struct SLink *invites;
132   struct SLink *banlist;
133   char chname[1];
134 };
135
136 struct ListingArgs {
137   time_t max_time;
138   time_t min_time;
139   unsigned int max_users;
140   unsigned int min_users;
141   unsigned int topic_limits;
142   time_t max_topic_time;
143   time_t min_topic_time;
144   struct Channel *chptr;
145 };
146
147 /*=============================================================================
148  * Proto types
149  */
150
151 extern int m_names(aClient *cptr, aClient *sptr, int parc, char *parv[]);
152 extern Link *IsMember(aClient *cptr, aChannel *chptr);
153 extern void remove_user_from_channel(aClient *sptr, aChannel *chptr);
154 extern int is_chan_op(aClient *cptr, aChannel *chptr);
155 extern int is_zombie(aClient *cptr, aChannel *chptr);
156 extern int has_voice(aClient *cptr, aChannel *chptr);
157 extern int can_send(aClient *cptr, aChannel *chptr);
158 extern void send_channel_modes(aClient *cptr, aChannel *chptr);
159 extern int m_mode(aClient *cptr, aClient *sptr, int parc, char *parv[]);
160 extern char *pretty_mask(char *mask);
161 extern void del_invite(aClient *cptr, aChannel *chptr);
162 extern void list_next_channels(aClient *cptr, int nr);
163 extern int m_join(aClient *cptr, aClient *sptr, int parc, char *parv[]);
164 extern int m_create(aClient *cptr, aClient *sptr, int parc, char *parv[]);
165 extern int m_destruct(aClient *cptr, aClient *sptr, int parc, char *parv[]);
166 extern int m_burst(aClient *cptr, aClient *sptr, int parc, char *parv[]);
167 extern int m_part(aClient *cptr, aClient *sptr, int parc, char *parv[]);
168 extern int m_kick(aClient *cptr, aClient *sptr, int parc, char *parv[]);
169 extern int m_topic(aClient *cptr, aClient *sptr, int parc, char *parv[]);
170 extern int m_invite(aClient *cptr, aClient *sptr, int parc, char *parv[]);
171 extern int m_list(aClient *cptr, aClient *sptr, int parc, char *parv[]);
172 extern void send_user_joins(aClient *cptr, aClient *user);
173
174 extern aChannel *channel;
175
176 #endif /* CHANNEL_H */