2008-04-08 21:39:35 +02:00
|
|
|
/*
|
|
|
|
* charybdis: An advanced ircd.
|
|
|
|
* chmode.h: The ircd channel header.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
|
|
|
|
* Copyright (C) 1996-2002 Hybrid Development Team
|
|
|
|
* Copyright (C) 2002-2004 ircd-ratbox development team
|
2016-08-19 07:58:17 +02:00
|
|
|
* Copyright (C) 2008-2016 Charybdis Development Team
|
|
|
|
* Copyright (C) 2016 Jason Volk <jason@zemos.net>
|
2008-04-08 21:39:35 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA
|
|
|
|
*/
|
|
|
|
|
2016-08-13 05:05:54 +02:00
|
|
|
#pragma once
|
2016-08-14 05:35:30 +02:00
|
|
|
#define HAVE_IRCD_CHMODE_H
|
2008-04-08 21:39:35 +02:00
|
|
|
|
2016-08-13 05:05:54 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
namespace ircd {
|
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
//TODO: XXX: is actually used for umode and chmode etc
|
|
|
|
enum : int
|
|
|
|
{
|
|
|
|
MODE_DEL = -1,
|
|
|
|
MODE_QUERY = 0,
|
|
|
|
MODE_ADD = 1,
|
|
|
|
};
|
2016-08-17 05:01:20 +02:00
|
|
|
|
|
|
|
namespace chan {
|
2016-08-18 07:33:38 +02:00
|
|
|
|
|
|
|
struct chan;
|
|
|
|
|
2016-08-17 05:01:20 +02:00
|
|
|
namespace mode {
|
2016-06-26 05:54:37 +02:00
|
|
|
|
2016-08-17 05:01:20 +02:00
|
|
|
// Maximum mode changes allowed per client, per server is different
|
|
|
|
constexpr auto MAXPARAMS = 4;
|
|
|
|
constexpr auto MAXPARAMSSERV = 10;
|
|
|
|
constexpr auto BUFLEN = 200;
|
2016-06-26 05:54:37 +02:00
|
|
|
|
2016-08-17 05:01:20 +02:00
|
|
|
// something not included in messages.tab to change some hooks behaviour when needed -- dwr
|
|
|
|
constexpr auto ERR_CUSTOM = 1000;
|
2016-06-26 05:54:37 +02:00
|
|
|
|
2016-08-17 05:01:20 +02:00
|
|
|
// Channel mode classification
|
|
|
|
enum class category
|
2016-06-26 05:54:37 +02:00
|
|
|
{
|
2016-08-17 05:01:20 +02:00
|
|
|
A, // Mode has a parameter apropos a list (or no param for xfer)
|
|
|
|
B, // Always has a parameter
|
|
|
|
C, // Only has a parameter on MODE_ADD
|
|
|
|
D, // Never has a parameter
|
2016-06-26 05:54:37 +02:00
|
|
|
};
|
|
|
|
|
2016-08-17 05:01:20 +02:00
|
|
|
enum type : uint
|
|
|
|
{
|
|
|
|
PRIVATE = 0x00000001,
|
|
|
|
SECRET = 0x00000002,
|
|
|
|
MODERATED = 0x00000004,
|
|
|
|
TOPICLIMIT = 0x00000008,
|
|
|
|
INVITEONLY = 0x00000010,
|
|
|
|
NOPRIVMSGS = 0x00000020,
|
|
|
|
REGONLY = 0x00000040,
|
|
|
|
EXLIMIT = 0x00000100, // exempt from list limits, +b/+e/+I/+q
|
|
|
|
PERMANENT = 0x00000200, // permanant channel, +P
|
|
|
|
OPMODERATE = 0x00000400, // send rejected messages to ops
|
|
|
|
FREEINVITE = 0x00000800, // allow free use of /invite
|
|
|
|
FREETARGET = 0x00001000, // can be forwarded to without authorization
|
|
|
|
DISFORWARD = 0x00002000, // disable channel forwarding
|
|
|
|
BAN = 0x10000000,
|
|
|
|
EXCEPTION = 0x20000000,
|
|
|
|
INVEX = 0x40000000,
|
|
|
|
QUIET = 0x80000000,
|
|
|
|
};
|
2016-06-26 05:54:37 +02:00
|
|
|
|
2016-08-17 05:01:20 +02:00
|
|
|
struct letter
|
|
|
|
{
|
2016-08-18 07:33:38 +02:00
|
|
|
enum type type = (enum type)0;
|
|
|
|
char letter = '\0';
|
2016-08-17 05:01:20 +02:00
|
|
|
};
|
2008-08-04 19:51:15 +02:00
|
|
|
|
2016-08-17 05:01:20 +02:00
|
|
|
struct change
|
|
|
|
{
|
2016-08-18 07:33:38 +02:00
|
|
|
char letter = '\0';
|
|
|
|
const char *arg = nullptr;
|
|
|
|
const char *id = nullptr;
|
|
|
|
int dir = 0;
|
|
|
|
int mems = 0;
|
2016-08-17 05:01:20 +02:00
|
|
|
};
|
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
using func = void (*)(client::client *, struct chan *, int alevel, int parc, int *parn, const char **parv, int *errors, int dir, char c, type type);
|
2016-08-17 05:01:20 +02:00
|
|
|
|
|
|
|
struct mode
|
|
|
|
{
|
|
|
|
enum type type;
|
|
|
|
enum category category;
|
|
|
|
func set_func;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern mode table[256];
|
|
|
|
extern char arity[2][256];
|
|
|
|
extern char categories[4][256];
|
|
|
|
|
|
|
|
namespace ext
|
|
|
|
{
|
|
|
|
// extban function results
|
|
|
|
enum result
|
|
|
|
{
|
|
|
|
INVALID = -1, // invalid mask, false even if negated
|
|
|
|
NOMATCH = 0, // valid mask, no match
|
|
|
|
MATCH = 1, // matches
|
|
|
|
};
|
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
using func = int (*)(const char *data, client::client *, chan *, type type);
|
2016-08-17 05:01:20 +02:00
|
|
|
extern func table[256];
|
|
|
|
}
|
2016-06-26 05:54:37 +02:00
|
|
|
|
|
|
|
#define CHM_FUNCTION(_NAME_) \
|
2016-08-22 03:57:43 +02:00
|
|
|
void _NAME_(client::client *source_p, chan *chptr, \
|
2016-06-26 05:54:37 +02:00
|
|
|
int alevel, int parc, int *parn, const char **parv, \
|
2016-08-17 05:01:20 +02:00
|
|
|
int *errors, int dir, char c, type type);
|
|
|
|
|
|
|
|
namespace functor
|
|
|
|
{
|
|
|
|
CHM_FUNCTION(nosuch)
|
|
|
|
CHM_FUNCTION(orphaned)
|
|
|
|
CHM_FUNCTION(simple)
|
|
|
|
CHM_FUNCTION(ban)
|
|
|
|
CHM_FUNCTION(hidden)
|
|
|
|
CHM_FUNCTION(staff)
|
|
|
|
CHM_FUNCTION(forward)
|
|
|
|
CHM_FUNCTION(throttle)
|
|
|
|
CHM_FUNCTION(key)
|
|
|
|
CHM_FUNCTION(limit)
|
|
|
|
CHM_FUNCTION(op)
|
|
|
|
CHM_FUNCTION(voice)
|
|
|
|
}
|
|
|
|
|
|
|
|
type add(const uint8_t &c, const category &category, const func &set_func);
|
|
|
|
void orphan(const uint8_t &c);
|
|
|
|
void init(void);
|
2008-06-24 18:45:19 +02:00
|
|
|
|
2016-08-17 05:01:20 +02:00
|
|
|
} // namespace mode
|
|
|
|
} // namespace chan
|
2016-08-13 05:05:54 +02:00
|
|
|
} // namespace ircd
|
|
|
|
#endif // __cplusplus
|