Author: David M <captj@superlink.net>
[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) ((IsAnOper(sptr)) \
105                                           && (IsLocalChannel(chname)))
106
107  
108 #ifdef OPER_WALK_THROUGH_LMODES
109   /* used in can_join to determine if an oper forced a join on a channel */
110   #define MAGIC_OPER_OVERRIDE 1000
111 #endif
112
113
114
115 /* used in SetMode() in channel.c and m_umode() in s_msg.c */
116
117 #define MODE_NULL      0
118 #define MODE_ADD       0x40000000
119 #define MODE_DEL       0x20000000
120
121 /*=============================================================================
122  * Structures
123  */
124
125 struct SMode {
126   unsigned int mode;
127   unsigned int limit;
128   char key[KEYLEN + 1];
129 };
130
131 struct Channel {
132   struct Channel *nextch, *prevch, *hnextch;
133   Mode mode;
134   time_t creationtime;
135   char topic[TOPICLEN + 1];
136   char topic_nick[NICKLEN + 1];
137   time_t topic_time;
138   unsigned int users;
139   struct SLink *members;
140   struct SLink *invites;
141   struct SLink *banlist;
142   char chname[1];
143 };
144
145 struct ListingArgs {
146   time_t max_time;
147   time_t min_time;
148   unsigned int max_users;
149   unsigned int min_users;
150   unsigned int topic_limits;
151   time_t max_topic_time;
152   time_t min_topic_time;
153   struct Channel *chptr;
154 };
155
156 /*=============================================================================
157  * Proto types
158  */
159
160 extern int m_names(aClient *cptr, aClient *sptr, int parc, char *parv[]);
161 extern Link *IsMember(aClient *cptr, aChannel *chptr);
162 extern void remove_user_from_channel(aClient *sptr, aChannel *chptr);
163 extern int is_chan_op(aClient *cptr, aChannel *chptr);
164 extern int is_zombie(aClient *cptr, aChannel *chptr);
165 extern int has_voice(aClient *cptr, aChannel *chptr);
166 extern int can_send(aClient *cptr, aChannel *chptr);
167 extern void send_channel_modes(aClient *cptr, aChannel *chptr);
168 extern int m_mode(aClient *cptr, aClient *sptr, int parc, char *parv[]);
169 extern char *pretty_mask(char *mask);
170 extern void del_invite(aClient *cptr, aChannel *chptr);
171 extern void list_next_channels(aClient *cptr, int nr);
172 extern int m_join(aClient *cptr, aClient *sptr, int parc, char *parv[]);
173 extern int m_create(aClient *cptr, aClient *sptr, int parc, char *parv[]);
174 extern int m_destruct(aClient *cptr, aClient *sptr, int parc, char *parv[]);
175 extern int m_burst(aClient *cptr, aClient *sptr, int parc, char *parv[]);
176 extern int m_part(aClient *cptr, aClient *sptr, int parc, char *parv[]);
177 extern int m_kick(aClient *cptr, aClient *sptr, int parc, char *parv[]);
178 extern int m_topic(aClient *cptr, aClient *sptr, int parc, char *parv[]);
179 extern int m_invite(aClient *cptr, aClient *sptr, int parc, char *parv[]);
180 extern int m_list(aClient *cptr, aClient *sptr, int parc, char *parv[]);
181 extern void send_user_joins(aClient *cptr, aClient *user);
182
183 extern aChannel *channel;
184
185 #endif /* CHANNEL_H */