| 1 |
|
/* |
| 2 |
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
|
* |
| 4 |
< |
* Copyright (c) 1997-2014 ircd-hybrid development team |
| 4 |
> |
* Copyright (c) 1997-2020 ircd-hybrid development team |
| 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 |
| 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 18 |
> |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 19 |
|
* USA |
| 20 |
|
*/ |
| 21 |
|
|
| 27 |
|
#ifndef INCLUDED_channel_mode_h |
| 28 |
|
#define INCLUDED_channel_mode_h |
| 29 |
|
|
| 30 |
< |
#define MODEBUFLEN 200 |
| 30 |
> |
|
| 31 |
> |
#define CMEMBER_STATUS_FLAGS "@%+" |
| 32 |
> |
enum { CMEMBER_STATUS_FLAGS_LEN = sizeof(CMEMBER_STATUS_FLAGS) - 1 }; |
| 33 |
> |
|
| 34 |
> |
enum { MODEBUFLEN = 200 }; |
| 35 |
|
|
| 36 |
|
/* Maximum mode changes allowed per client, per server is different */ |
| 37 |
< |
#define MAXMODEPARAMS 4 |
| 37 |
> |
enum { MAXMODEPARAMS = 6 }; |
| 38 |
|
|
| 39 |
|
enum |
| 40 |
|
{ |
| 41 |
< |
MODE_QUERY = 0, |
| 42 |
< |
MODE_ADD = 1, |
| 43 |
< |
MODE_DEL = -1 |
| 41 |
> |
MODE_QUERY, |
| 42 |
> |
MODE_DEL, |
| 43 |
> |
MODE_ADD |
| 44 |
|
}; |
| 45 |
|
|
| 46 |
|
enum |
| 47 |
|
{ |
| 48 |
|
CHACCESS_NOTONCHAN = -1, |
| 49 |
< |
CHACCESS_PEON = 0, |
| 50 |
< |
CHACCESS_HALFOP = 1, |
| 51 |
< |
CHACCESS_CHANOP = 2, |
| 52 |
< |
CHACCESS_REMOTE = 3 |
| 49 |
> |
CHACCESS_PEON, |
| 50 |
> |
CHACCESS_HALFOP, |
| 51 |
> |
CHACCESS_CHANOP, |
| 52 |
> |
CHACCESS_REMOTE |
| 53 |
|
}; |
| 54 |
|
|
| 55 |
< |
/* can_send results */ |
| 55 |
> |
/* Channel related flags */ |
| 56 |
|
enum |
| 57 |
|
{ |
| 58 |
< |
CAN_SEND_NO = 0, |
| 59 |
< |
CAN_SEND_NONOP = -1, |
| 60 |
< |
CAN_SEND_OPV = -2 |
| 58 |
> |
CHFL_CHANOP = 1 << 0, /* Channel operator */ |
| 59 |
> |
CHFL_HALFOP = 1 << 1, /* Channel half op */ |
| 60 |
> |
CHFL_VOICE = 1 << 2, /* the power to speak */ |
| 61 |
> |
CHFL_BAN = 1 << 3, /* ban channel flag */ |
| 62 |
> |
CHFL_EXCEPTION = 1 << 4, /* exception to ban channel flag */ |
| 63 |
> |
CHFL_INVEX = 1 << 5, |
| 64 |
> |
/* Cache flags for silence on ban */ |
| 65 |
> |
CHFL_BAN_CHECKED = 1 << 6, |
| 66 |
> |
CHFL_BAN_SILENCED = 1 << 7 |
| 67 |
|
}; |
| 68 |
|
|
| 59 |
– |
|
| 60 |
– |
/* Channel related flags */ |
| 61 |
– |
#define CHFL_CHANOP 0x0001U /* Channel operator */ |
| 62 |
– |
#define CHFL_HALFOP 0x0002U /* Channel half op */ |
| 63 |
– |
#define CHFL_VOICE 0x0004U /* the power to speak */ |
| 64 |
– |
#define CHFL_BAN 0x0008U /* ban channel flag */ |
| 65 |
– |
#define CHFL_EXCEPTION 0x0010U /* exception to ban channel flag */ |
| 66 |
– |
#define CHFL_INVEX 0x0020U |
| 67 |
– |
|
| 69 |
|
/* channel modes ONLY */ |
| 70 |
< |
#define MODE_PRIVATE 0x0001U /**< */ |
| 71 |
< |
#define MODE_SECRET 0x0002U /**< Channel does not show up on NAMES or LIST */ |
| 72 |
< |
#define MODE_MODERATED 0x0004U /**< Users without +v/h/o cannot send text to the channel */ |
| 73 |
< |
#define MODE_TOPICLIMIT 0x0008U /**< Only chanops can change the topic */ |
| 74 |
< |
#define MODE_INVITEONLY 0x0010U /**< Only invited usersmay join this channel */ |
| 75 |
< |
#define MODE_NOPRIVMSGS 0x0020U /**< Users must be in the channel to send text to it */ |
| 76 |
< |
#define MODE_SSLONLY 0x0040U /**< Prevents anyone who isn't connected via SSL/TLS from joining the channel */ |
| 77 |
< |
#define MODE_OPERONLY 0x0080U /**< Prevents anyone who hasn't obtained IRC operator status from joining the channel */ |
| 78 |
< |
#define MODE_REGISTERED 0x0100U /**< Channel has been registered with ChanServ */ |
| 79 |
< |
#define MODE_REGONLY 0x0200U /**< Only registered clients may join a channel with that mode set */ |
| 80 |
< |
#define MODE_NOCTRL 0x0400U /**< Prevents users from sending messages containing control codes to the channel */ |
| 81 |
< |
#define MODE_MODREG 0x0800U /**< Unregistered/unidentified clients cannot send text to the channel */ |
| 82 |
< |
|
| 83 |
< |
/* cache flags for silence on ban */ |
| 84 |
< |
#define CHFL_BAN_CHECKED 0x0080U |
| 85 |
< |
#define CHFL_BAN_SILENCED 0x0100U |
| 70 |
> |
enum |
| 71 |
> |
{ |
| 72 |
> |
MODE_PRIVATE = 1 << 0, /**< */ |
| 73 |
> |
MODE_SECRET = 1 << 1, /**< Channel does not show up on NAMES or LIST */ |
| 74 |
> |
MODE_MODERATED = 1 << 2, /**< Users without +v/+h/+o cannot send text to the channel */ |
| 75 |
> |
MODE_TOPICLIMIT = 1 << 3, /**< Only chanops can change the topic */ |
| 76 |
> |
MODE_INVITEONLY = 1 << 4, /**< Only invited users may join this channel */ |
| 77 |
> |
MODE_NOPRIVMSGS = 1 << 5, /**< Users must be in the channel to send text to it */ |
| 78 |
> |
MODE_SSLONLY = 1 << 6, /**< Prevents anyone who isn't connected via SSL/TLS from joining the channel */ |
| 79 |
> |
MODE_OPERONLY = 1 << 7, /**< Prevents anyone who hasn't obtained IRC operator status from joining the channel */ |
| 80 |
> |
MODE_REGISTERED = 1 << 8, /**< Channel has been registered with ChanServ */ |
| 81 |
> |
MODE_REGONLY = 1 << 9, /**< Only registered clients may join a channel with that mode set */ |
| 82 |
> |
MODE_NOCTRL = 1 << 10, /**< Prevents users from sending messages containing control codes to the channel */ |
| 83 |
> |
MODE_MODREG = 1 << 11, /**< Unregistered/unidentified clients cannot send text to the channel */ |
| 84 |
> |
MODE_NOCTCP = 1 << 12, /**< Clients cannot send CTCP messages to the channel */ |
| 85 |
> |
MODE_NONOTICE = 1 << 13, /**< Clients cannot send NOTICE to the channel */ |
| 86 |
> |
MODE_HIDEBMASKS = 1 << 14, /**< Hides +b/+e/+I lists/changes for non-chanops everywhere */ |
| 87 |
> |
MODE_EXTLIMIT = 1 << 15, /**< Channel can make use of the extended ban list limit */ |
| 88 |
> |
MODE_NONICKCHANGE = 1 << 16 /**< User is prevented from changing their nick while in this channel */ |
| 89 |
> |
}; |
| 90 |
> |
|
| 91 |
> |
#define HasCMode(x, y) ((x)->mode.mode & (y)) |
| 92 |
> |
#define AddCMode(x, y) ((x)->mode.mode |= (y)) |
| 93 |
> |
#define DelCMode(x, y) ((x)->mode.mode &= ~(y)) |
| 94 |
|
|
| 95 |
|
/* name invisible */ |
| 96 |
|
#define SecretChannel(x) (((x)->mode.mode & MODE_SECRET)) |
| 98 |
|
/* knock is forbidden, halfops can't kick/deop other halfops. */ |
| 99 |
|
#define PrivateChannel(x) (((x)->mode.mode & MODE_PRIVATE)) |
| 100 |
|
|
| 92 |
– |
struct ChannelMode |
| 93 |
– |
{ |
| 94 |
– |
void (*func)(struct Client *, |
| 95 |
– |
struct Channel *, int, int *, char **, |
| 96 |
– |
int *, int, int, char, unsigned int); |
| 97 |
– |
unsigned int d; |
| 98 |
– |
}; |
| 99 |
– |
|
| 101 |
|
struct ChModeChange |
| 102 |
|
{ |
| 103 |
|
char letter; |
| 104 |
|
const char *arg; |
| 105 |
|
const char *id; |
| 106 |
< |
int dir; |
| 107 |
< |
int mems; |
| 106 |
> |
unsigned int dir; |
| 107 |
> |
unsigned int flags; |
| 108 |
|
}; |
| 109 |
|
|
| 110 |
< |
struct mode_letter |
| 110 |
> |
struct chan_mode |
| 111 |
|
{ |
| 112 |
< |
const unsigned int mode; |
| 113 |
< |
const unsigned char letter; |
| 112 |
> |
unsigned char letter; |
| 113 |
> |
unsigned int mode; |
| 114 |
> |
unsigned int flag; |
| 115 |
> |
bool only_opers; |
| 116 |
> |
bool only_servers; |
| 117 |
> |
int required_oplevel; |
| 118 |
> |
void (*func)(struct Client *, |
| 119 |
> |
struct Channel *, int, int *, char **, int *, |
| 120 |
> |
int, int, const char, const struct chan_mode *); |
| 121 |
|
}; |
| 122 |
|
|
| 123 |
< |
extern const struct mode_letter chan_modes[]; |
| 124 |
< |
extern const struct ChannelMode ModeTable[]; |
| 123 |
> |
extern const struct chan_mode *cmode_map[]; |
| 124 |
> |
extern const struct chan_mode cmode_tab[]; |
| 125 |
|
|
| 126 |
< |
extern int add_id(struct Client *, struct Channel *, char *, unsigned int); |
| 127 |
< |
extern void set_channel_mode(struct Client *, struct Channel *, |
| 128 |
< |
struct Membership *, int, char **); |
| 129 |
< |
extern void clear_ban_cache(struct Channel *); |
| 130 |
< |
extern void clear_ban_cache_client(struct Client *); |
| 126 |
> |
extern void channel_mode_init(void); |
| 127 |
> |
extern bool add_id(struct Client *, struct Channel *, char *, dlink_list *); |
| 128 |
> |
extern void channel_mode_set(struct Client *, struct Channel *, |
| 129 |
> |
struct ChannelMember *, int, char **); |
| 130 |
> |
extern void clear_ban_cache_list(dlink_list *); |
| 131 |
|
#endif /* INCLUDED_channel_mode_h */ |