2007-01-25 07:40:21 +01:00
|
|
|
/*
|
|
|
|
* ircd-ratbox: A slightly useful ircd.
|
|
|
|
* channel.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) 2004-2016 Charybdis Development Team
|
|
|
|
* Copyright (C) 2016 Jason Volk <jason@zemos.net>
|
2007-01-25 07:40:21 +01: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
|
|
|
|
#define HAVE_IRCD_CHANNEL_H
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-13 05:05:54 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
namespace ircd {
|
2016-08-18 07:33:38 +02:00
|
|
|
namespace chan {
|
2016-08-13 05:05:54 +02:00
|
|
|
|
2016-08-20 09:06:41 +02:00
|
|
|
IRCD_EXCEPTION(ircd::error, error)
|
|
|
|
IRCD_EXCEPTION(error, not_found)
|
|
|
|
IRCD_EXCEPTION(error, invalid_argument)
|
|
|
|
IRCD_EXCEPTION(invalid_argument, invalid_list)
|
2016-08-19 07:58:17 +02:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
enum status
|
|
|
|
{
|
|
|
|
PEON = 0x0000, // normal member of channel
|
|
|
|
VOICE = 0x0001, // the power to speak
|
|
|
|
CHANOP = 0x0002, // Channel operator
|
|
|
|
BANNED = 0x0008, // cached as banned
|
|
|
|
QUIETED = 0x0010, // cached as being +q victim
|
|
|
|
ONLY_OPERS = 0x0020,
|
|
|
|
ONLY_SERVERS = 0x0040,
|
|
|
|
ONLY_CHANOPS = CHANOP,
|
|
|
|
ONLY_CHANOPSVOICED = CHANOP | VOICE,
|
|
|
|
ALL_MEMBERS = PEON,
|
2007-01-25 07:40:21 +01:00
|
|
|
};
|
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
struct topic
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2016-08-18 07:33:38 +02:00
|
|
|
std::string text;
|
|
|
|
std::string info;
|
|
|
|
time_t time = 0;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
operator bool() const;
|
|
|
|
};
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
struct ban
|
|
|
|
{
|
|
|
|
static constexpr auto LEN = 195;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
std::string banstr;
|
|
|
|
std::string who;
|
|
|
|
std::string forward;
|
|
|
|
time_t when;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-19 07:58:17 +02:00
|
|
|
ban(const std::string &banstr,
|
|
|
|
const std::string &who = {},
|
|
|
|
const std::string &forward = {},
|
|
|
|
const time_t &when = 0);
|
2016-08-18 07:33:38 +02:00
|
|
|
};
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-19 07:58:17 +02:00
|
|
|
bool operator<(const ban &a, const ban &b);
|
|
|
|
using list = std::set<ban, std::less<ban>>;
|
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
struct modes
|
|
|
|
{
|
|
|
|
static constexpr size_t KEYLEN = 24; // 23+1 for \0
|
2015-12-13 15:13:52 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
uint mode;
|
|
|
|
int limit;
|
|
|
|
char key[KEYLEN];
|
|
|
|
uint join_num;
|
|
|
|
uint join_time;
|
|
|
|
char forward[LOC_CHANNELLEN + 1];
|
|
|
|
|
|
|
|
modes();
|
2007-01-25 07:40:21 +01:00
|
|
|
};
|
|
|
|
|
2016-08-19 07:57:33 +02:00
|
|
|
uint operator&(const modes &, const mode::type &);
|
|
|
|
uint operator|(const modes &, const mode::type &);
|
|
|
|
uint operator~(const modes &);
|
|
|
|
|
2007-01-25 07:40:21 +01:00
|
|
|
struct membership
|
|
|
|
{
|
2016-08-22 03:57:43 +02:00
|
|
|
using global = std::map<client::client *, membership>;
|
2016-08-20 02:32:26 +02:00
|
|
|
using local = std::list<membership *>;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-20 02:32:26 +02:00
|
|
|
uint flags;
|
2016-03-23 03:53:56 +01:00
|
|
|
time_t bants;
|
2016-08-20 02:32:26 +02:00
|
|
|
global::iterator git;
|
|
|
|
local::iterator lit;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-20 02:32:26 +02:00
|
|
|
membership(const uint &flags = 0);
|
2016-08-18 07:33:38 +02:00
|
|
|
~membership() noexcept;
|
2007-01-25 07:40:21 +01:00
|
|
|
};
|
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
bool is_chanop(const membership &);
|
|
|
|
bool is_chanop(const membership *const &);
|
|
|
|
bool is_voiced(const membership &);
|
|
|
|
bool is_voiced(const membership *const &);
|
|
|
|
bool can_send_banned(const membership &);
|
|
|
|
bool can_send_banned(const membership *const &);
|
|
|
|
const char *find_status(const membership *const &msptr, const int &combine);
|
2016-08-22 03:57:43 +02:00
|
|
|
const client::client &get_client(const membership &);
|
|
|
|
client::client &get_client(membership &);
|
2016-08-20 02:32:26 +02:00
|
|
|
|
|
|
|
struct members
|
|
|
|
{
|
|
|
|
membership::global global;
|
|
|
|
membership::local local;
|
|
|
|
|
|
|
|
members();
|
|
|
|
~members() noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool empty(const members &);
|
|
|
|
size_t size(const members &);
|
|
|
|
bool local_empty(const members &);
|
|
|
|
size_t local_size(const members &);
|
2016-08-22 03:57:43 +02:00
|
|
|
bool exists(const members &, const client::client &);
|
|
|
|
const membership *get(const members &, const client::client &, std::nothrow_t);
|
|
|
|
const membership &get(const members &, const client::client &);
|
|
|
|
membership *get(members &, const client::client &, std::nothrow_t);
|
|
|
|
membership &get(members &, const client::client &);
|
2016-08-18 07:33:38 +02:00
|
|
|
|
2016-08-19 01:53:12 +02:00
|
|
|
bool has_prefix(const char *const &name);
|
|
|
|
bool has_prefix(const std::string &name);
|
|
|
|
bool valid_name(const char *const &name);
|
|
|
|
bool valid_name(const std::string &name);
|
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
struct chan
|
|
|
|
{
|
|
|
|
std::string name;
|
|
|
|
struct modes mode;
|
|
|
|
std::string mode_lock;
|
|
|
|
struct topic topic;
|
2016-08-20 02:32:26 +02:00
|
|
|
struct members members;
|
2016-08-22 03:57:43 +02:00
|
|
|
std::set<client::client *> invites;
|
2016-08-19 07:58:17 +02:00
|
|
|
list bans;
|
|
|
|
list excepts;
|
|
|
|
list invexs;
|
|
|
|
list quiets;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
uint join_count; // joins within delta
|
|
|
|
uint join_delta; // last ts of join
|
|
|
|
uint flood_noticed;
|
|
|
|
int received_number_of_privmsgs;
|
|
|
|
time_t first_received_message_time; // channel flood control
|
|
|
|
time_t last_knock; // don't allow knock to flood
|
|
|
|
time_t bants;
|
|
|
|
time_t channelts;
|
|
|
|
time_t last_checked_ts;
|
2016-08-22 03:57:43 +02:00
|
|
|
const client::client *last_checked_client;
|
2016-08-19 07:58:17 +02:00
|
|
|
mode::type last_checked_type;
|
|
|
|
bool last_checked_result;
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
chan(const std::string &name);
|
|
|
|
~chan() noexcept;
|
|
|
|
};
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-20 02:32:26 +02:00
|
|
|
const auto &name(const chan &);
|
2016-08-19 01:33:46 +02:00
|
|
|
bool is_secret(const chan &);
|
|
|
|
bool is_secret(const chan *const &);
|
|
|
|
bool is_hidden(const chan &);
|
|
|
|
bool is_hidden(const chan *const &);
|
|
|
|
bool is_public(const chan &);
|
|
|
|
bool is_public(const chan *const &);
|
2016-08-22 03:57:43 +02:00
|
|
|
bool is_member(const chan &c, const client::client &);
|
|
|
|
bool is_member(const chan *const &, const client::client *const &);
|
|
|
|
bool can_show(const chan &, const client::client &);
|
|
|
|
bool can_show(const chan *const &, const client::client *const &);
|
2016-08-18 07:33:38 +02:00
|
|
|
|
|
|
|
enum : int
|
|
|
|
{
|
|
|
|
CAN_SEND_NO = 0,
|
|
|
|
CAN_SEND_NONOP = 1,
|
|
|
|
CAN_SEND_OPV = 2,
|
|
|
|
};
|
2016-08-22 03:57:43 +02:00
|
|
|
int can_send(chan *, client::client *, membership *);
|
|
|
|
int can_join(client::client *source, chan *, const char *key, const char **forward);
|
2016-08-19 07:58:17 +02:00
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
bool cache_check(const chan &, const mode::type &, const client::client &, bool &result);
|
|
|
|
void cache_result(chan &, const mode::type &, const client::client &, const bool &result, membership *const &msptr = nullptr);
|
2016-08-19 07:58:17 +02:00
|
|
|
void cache_invalidate(chan &, const mode::type &, time_t time = 0);
|
|
|
|
|
|
|
|
const list &get(const chan &, const mode::type &);
|
|
|
|
list &get(chan &, const mode::type &);
|
|
|
|
size_t size(const chan &, const mode::type &);
|
|
|
|
bool empty(const chan &, const mode::type &);
|
|
|
|
size_t lists_size(const chan &);
|
|
|
|
|
|
|
|
struct check_data
|
|
|
|
{
|
|
|
|
membership *msptr;
|
|
|
|
const char *host;
|
|
|
|
const char *iphost;
|
|
|
|
const char **forward;
|
|
|
|
};
|
2016-08-22 03:57:43 +02:00
|
|
|
bool check(chan &, const mode::type &, const client::client &, check_data *const &data = nullptr);
|
2016-08-19 07:58:17 +02:00
|
|
|
const ban &get(const chan &, const mode::type &, const std::string &mask);
|
2016-08-22 03:57:43 +02:00
|
|
|
bool add(chan &, const mode::type &, const std::string &mask, client::client &source, const std::string &forward = {});
|
2016-08-19 07:58:17 +02:00
|
|
|
bool del(chan &, const mode::type &, const std::string &mask);
|
2016-08-18 07:33:38 +02:00
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
void del_invite(chan &, client::client &);
|
2016-08-19 09:02:18 +02:00
|
|
|
void clear_invites(chan &);
|
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
bool flood_attack_channel(int p_or_n, client::client *source, chan *);
|
|
|
|
void invalidate_bancache_user(client::client *);
|
|
|
|
void channel_member_names(chan *, client::client *, int show_eon);
|
|
|
|
const char *channel_modes(chan *, client::client *who);
|
|
|
|
chan *find_bannickchange_channel(client::client *);
|
|
|
|
void check_spambot_warning(client::client *source, const char *name);
|
2016-08-18 07:33:38 +02:00
|
|
|
void check_splitmode(void *);
|
|
|
|
void set_channel_topic(chan *, const char *topic, const char *topic_info, time_t topicts);
|
|
|
|
void init_chcap_usage_counts(void);
|
2016-08-22 03:57:43 +02:00
|
|
|
void set_chcap_usage_counts(client::client *serv_p);
|
|
|
|
void unset_chcap_usage_counts(client::client *serv_p);
|
|
|
|
void send_cap_mode_changes(client::client *, client::client *source, chan *, mode::change foo[], int);
|
2016-08-18 07:33:38 +02:00
|
|
|
void resv_chan_forcepart(const char *name, const char *reason, int temp_time);
|
2016-08-22 03:57:43 +02:00
|
|
|
void set_channel_mode(client::client *, client::client *source, chan *, membership *, int parc, const char *parv[]);
|
|
|
|
void set_channel_mlock(client::client *, client::client *source, chan *, const char *newmlock, bool propagate);
|
|
|
|
int match_extban(const char *banstr, client::client *, chan *, long mode_type);
|
|
|
|
int valid_extban(const char *banstr, client::client *, chan *, long mode_type);
|
2016-08-18 07:33:38 +02:00
|
|
|
const char * get_extban_string(void);
|
2016-08-22 03:57:43 +02:00
|
|
|
int get_channel_access(client::client *source, chan *, membership *, int dir, const char *modestr);
|
|
|
|
void send_join(chan &, client::client &);
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-20 04:51:37 +02:00
|
|
|
auto empty(const chan &);
|
|
|
|
auto local_size(const chan &);
|
|
|
|
auto size(const chan &);
|
2016-08-22 03:57:43 +02:00
|
|
|
void add(chan &, client::client &, const int &flags = PEON);
|
|
|
|
void del(chan &, client::client &);
|
|
|
|
void del(client::client &); // remove from all channels
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-20 04:51:37 +02:00
|
|
|
// Channels
|
|
|
|
extern std::map<const std::string *, std::unique_ptr<chan>, rfc1459::less> chans;
|
|
|
|
|
|
|
|
bool exists(const std::string &name);
|
|
|
|
chan *get(const std::string &name, std::nothrow_t);
|
|
|
|
chan &get(const std::string &name);
|
2016-08-22 03:57:43 +02:00
|
|
|
chan &add(const std::string &name, client::client &); // get or add (but does not join the client)
|
2016-08-20 04:51:37 +02:00
|
|
|
bool del(const std::string &name);
|
|
|
|
bool del(const chan &);
|
|
|
|
|
2016-08-20 02:32:26 +02:00
|
|
|
// Initialize subsystem
|
2016-08-18 07:33:38 +02:00
|
|
|
void init();
|
2007-01-25 07:40:21 +01:00
|
|
|
|
|
|
|
|
2016-08-20 04:51:37 +02:00
|
|
|
inline auto
|
|
|
|
size(const chan &chan)
|
|
|
|
{
|
|
|
|
return size(chan.members);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline auto
|
|
|
|
local_size(const chan &chan)
|
|
|
|
{
|
|
|
|
return local_size(chan.members);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline auto
|
|
|
|
empty(const chan &chan)
|
|
|
|
{
|
|
|
|
return empty(chan.members);
|
|
|
|
}
|
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-19 01:33:46 +02:00
|
|
|
is_secret(const chan &c)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
|
|
|
return c.mode.mode & mode::SECRET;
|
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-19 01:33:46 +02:00
|
|
|
is_secret(const chan *const &c)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
2016-08-19 01:33:46 +02:00
|
|
|
return c && is_secret(*c);
|
2016-08-18 07:33:38 +02:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-19 01:33:46 +02:00
|
|
|
is_hidden(const chan &c)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
|
|
|
return c.mode.mode & mode::PRIVATE;
|
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-19 01:33:46 +02:00
|
|
|
is_hidden(const chan *const &c)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
2016-08-19 01:33:46 +02:00
|
|
|
return c && is_hidden(*c);
|
2016-08-18 07:33:38 +02:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-19 01:33:46 +02:00
|
|
|
is_public(const chan &c)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
|
|
|
return ~c.mode.mode & (mode::PRIVATE | mode::SECRET);
|
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-19 01:33:46 +02:00
|
|
|
is_public(const chan *const &c)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
2016-08-19 01:33:46 +02:00
|
|
|
return !c || is_public(*c);
|
2016-08-18 07:33:38 +02:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-22 03:57:43 +02:00
|
|
|
is_member(const chan &c, const client::client &client)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
2016-08-20 02:32:26 +02:00
|
|
|
return exists(c.members, client);
|
2016-08-18 07:33:38 +02:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-22 03:57:43 +02:00
|
|
|
is_member(const chan *const &c, const client::client *const &client)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
|
|
|
return c && client && is_member(*c, *client);
|
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-22 03:57:43 +02:00
|
|
|
can_show(const chan &c, const client::client &client)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
2016-08-19 01:33:46 +02:00
|
|
|
return is_public(c) || is_member(c, client);
|
2016-08-18 07:33:38 +02:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-22 03:57:43 +02:00
|
|
|
can_show(const chan *const &c, const client::client *const &client)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
2016-08-19 01:33:46 +02:00
|
|
|
return is_public(c) || is_member(c, client);
|
2016-08-18 07:33:38 +02:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-19 01:53:12 +02:00
|
|
|
has_prefix(const char *const &name)
|
|
|
|
{
|
|
|
|
return name && rfc1459::is_chan_prefix(name[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
has_prefix(const std::string &name)
|
|
|
|
{
|
|
|
|
return !name.empty() && rfc1459::is_chan_prefix(name[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
valid_name(const char *const &name)
|
|
|
|
{
|
|
|
|
return name && name[0] && std::all_of(name, name + strlen(name), rfc1459::is_chan);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
valid_name(const std::string &name)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
2016-08-19 01:53:12 +02:00
|
|
|
return !name.empty() && std::all_of(begin(name), end(name), rfc1459::is_chan);
|
2016-08-18 07:33:38 +02:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-20 02:32:26 +02:00
|
|
|
inline const auto &
|
|
|
|
name(const chan &chan)
|
|
|
|
{
|
|
|
|
return chan.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline size_t
|
|
|
|
local_size(const members &m)
|
|
|
|
{
|
|
|
|
return std::distance(begin(m.local), end(m.local));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
local_empty(const members &m)
|
|
|
|
{
|
|
|
|
return m.local.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline size_t
|
|
|
|
size(const members &m)
|
|
|
|
{
|
|
|
|
return m.global.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
empty(const members &m)
|
|
|
|
{
|
|
|
|
return m.global.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
2016-08-22 03:57:43 +02:00
|
|
|
exists(const members &m, const client::client &c)
|
2016-08-20 02:32:26 +02:00
|
|
|
{
|
2016-08-22 03:57:43 +02:00
|
|
|
return m.global.count(const_cast<client::client *>(&c));
|
2016-08-20 02:32:26 +02:00
|
|
|
}
|
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
inline client::client &
|
2016-08-20 11:49:53 +02:00
|
|
|
get_client(membership &m)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
2016-08-20 11:49:53 +02:00
|
|
|
return *m.git->first;
|
2016-08-18 07:33:38 +02:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-22 03:57:43 +02:00
|
|
|
inline const client::client &
|
2016-08-20 11:49:53 +02:00
|
|
|
get_client(const membership &m)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
2016-08-20 11:49:53 +02:00
|
|
|
return *m.git->first;
|
2016-08-18 07:33:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
2016-08-20 11:49:53 +02:00
|
|
|
can_send_banned(const membership *const &m)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
2016-08-20 11:49:53 +02:00
|
|
|
return m && can_send_banned(*m);
|
2016-08-18 07:33:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
2016-08-20 11:49:53 +02:00
|
|
|
can_send_banned(const membership &m)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
2016-08-20 11:49:53 +02:00
|
|
|
return m.flags & (BANNED | QUIETED);
|
2016-08-18 07:33:38 +02:00
|
|
|
}
|
2010-03-27 16:13:57 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-20 11:49:53 +02:00
|
|
|
is_voiced(const membership *const &m)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
2016-08-20 11:49:53 +02:00
|
|
|
return m && is_voiced(*m);
|
2016-08-18 07:33:38 +02:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-20 11:49:53 +02:00
|
|
|
is_voiced(const membership &m)
|
2016-08-20 02:32:26 +02:00
|
|
|
{
|
2016-08-20 11:49:53 +02:00
|
|
|
return m.flags & VOICE;
|
2016-08-20 02:32:26 +02:00
|
|
|
}
|
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-20 11:49:53 +02:00
|
|
|
is_chanop(const membership *const &m)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
2016-08-20 11:49:53 +02:00
|
|
|
return m && is_chanop(*m);
|
2016-08-18 07:33:38 +02:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
2016-08-20 11:49:53 +02:00
|
|
|
is_chanop(const membership &m)
|
2016-08-18 07:33:38 +02:00
|
|
|
{
|
2016-08-20 11:49:53 +02:00
|
|
|
return m.flags & CHANOP;
|
2016-08-18 07:33:38 +02:00
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-19 07:57:33 +02:00
|
|
|
inline uint
|
|
|
|
operator~(const modes &modes)
|
|
|
|
{
|
|
|
|
return ~modes.mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline uint
|
|
|
|
operator&(const modes &modes, const mode::type &value)
|
|
|
|
{
|
|
|
|
return modes.mode & value;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline uint
|
|
|
|
operator|(const modes &modes, const mode::type &value)
|
|
|
|
{
|
|
|
|
return modes.mode | value;
|
|
|
|
}
|
|
|
|
|
2016-08-19 07:58:17 +02:00
|
|
|
inline bool
|
|
|
|
operator<(const ban &a, const ban &b)
|
|
|
|
{
|
|
|
|
return irccmp(a.banstr, b.banstr);
|
|
|
|
}
|
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline bool
|
|
|
|
operator!(const topic &topic)
|
|
|
|
{
|
|
|
|
return !bool(topic);
|
|
|
|
}
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
inline
|
|
|
|
topic::operator bool()
|
|
|
|
const
|
|
|
|
{
|
|
|
|
return !text.empty();
|
|
|
|
}
|
2010-12-16 07:09:29 +01:00
|
|
|
|
2016-08-18 07:33:38 +02:00
|
|
|
} // namespace chan
|
2016-08-13 05:05:54 +02:00
|
|
|
} // namespace ircd
|
|
|
|
#endif // __cplusplus
|