| 1 |
adx |
30 |
/* |
| 2 |
michael |
2865 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
adx |
30 |
* |
| 4 |
michael |
5347 |
* Copyright (c) 1997-2015 ircd-hybrid development team |
| 5 |
adx |
30 |
* |
| 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 of the License, or |
| 9 |
|
|
* (at your option) 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 |
michael |
4565 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 19 |
adx |
30 |
* USA |
| 20 |
|
|
*/ |
| 21 |
|
|
|
| 22 |
|
|
/*! \file channel.h |
| 23 |
|
|
* \brief Responsible for managing channels, members, bans and topics |
| 24 |
knight |
31 |
* \version $Id$ |
| 25 |
adx |
30 |
*/ |
| 26 |
|
|
|
| 27 |
|
|
#ifndef INCLUDED_channel_h |
| 28 |
|
|
#define INCLUDED_channel_h |
| 29 |
|
|
|
| 30 |
|
|
#include "ircd_defs.h" /* KEYLEN, CHANNELLEN */ |
| 31 |
|
|
|
| 32 |
michael |
1798 |
/* channel visible */ |
| 33 |
|
|
#define ShowChannel(v,c) (PubChannel(c) || IsMember((v),(c))) |
| 34 |
|
|
|
| 35 |
|
|
#define IsMember(who, chan) ((find_channel_link(who, chan)) ? 1 : 0) |
| 36 |
|
|
#define AddMemberFlag(x, y) ((x)->flags |= (y)) |
| 37 |
|
|
#define DelMemberFlag(x, y) ((x)->flags &= ~(y)) |
| 38 |
|
|
|
| 39 |
michael |
6323 |
enum |
| 40 |
|
|
{ |
| 41 |
michael |
6328 |
MSG_FLOOD_NOTICED = 0x00000001U, |
| 42 |
michael |
6323 |
JOIN_FLOOD_NOTICED = 0x00000002U |
| 43 |
|
|
}; |
| 44 |
michael |
1798 |
|
| 45 |
michael |
6328 |
#define SetFloodNoticed(x) ((x)->flags |= MSG_FLOOD_NOTICED) |
| 46 |
|
|
#define IsSetFloodNoticed(x) ((x)->flags & MSG_FLOOD_NOTICED) |
| 47 |
|
|
#define ClearFloodNoticed(x) ((x)->flags &= ~MSG_FLOOD_NOTICED) |
| 48 |
michael |
1798 |
|
| 49 |
|
|
#define SetJoinFloodNoticed(x) ((x)->flags |= JOIN_FLOOD_NOTICED) |
| 50 |
|
|
#define IsSetJoinFloodNoticed(x) ((x)->flags & JOIN_FLOOD_NOTICED) |
| 51 |
|
|
#define ClearJoinFloodNoticed(x) ((x)->flags &= ~JOIN_FLOOD_NOTICED) |
| 52 |
|
|
|
| 53 |
adx |
30 |
struct Client; |
| 54 |
|
|
|
| 55 |
|
|
/*! \brief Mode structure for channels */ |
| 56 |
|
|
struct Mode |
| 57 |
|
|
{ |
| 58 |
michael |
4404 |
unsigned int mode; /**< simple modes */ |
| 59 |
|
|
unsigned int limit; /**< +l userlimit */ |
| 60 |
|
|
char key[KEYLEN + 1]; /**< +k key */ |
| 61 |
adx |
30 |
}; |
| 62 |
|
|
|
| 63 |
|
|
/*! \brief Channel structure */ |
| 64 |
|
|
struct Channel |
| 65 |
|
|
{ |
| 66 |
|
|
dlink_node node; |
| 67 |
|
|
|
| 68 |
|
|
struct Channel *hnextch; |
| 69 |
michael |
1013 |
struct Mode mode; |
| 70 |
adx |
30 |
|
| 71 |
michael |
1203 |
char topic[TOPICLEN + 1]; |
| 72 |
michael |
6932 |
char topic_info[NICKLEN + USERLEN + HOSTLEN + 3]; |
| 73 |
michael |
1013 |
|
| 74 |
michael |
4818 |
time_t creationtime; |
| 75 |
adx |
30 |
time_t topic_time; |
| 76 |
michael |
4404 |
time_t last_knock; /**< Don't allow knock to flood */ |
| 77 |
michael |
6792 |
time_t last_invite; |
| 78 |
michael |
1013 |
time_t last_join_time; |
| 79 |
|
|
time_t first_received_message_time; /*!< channel flood control */ |
| 80 |
|
|
unsigned int flags; |
| 81 |
|
|
int received_number_of_privmsgs; |
| 82 |
adx |
30 |
|
| 83 |
michael |
4170 |
dlink_list locmembers; /*!< local members are here too */ |
| 84 |
adx |
30 |
dlink_list members; |
| 85 |
|
|
dlink_list invites; |
| 86 |
|
|
dlink_list banlist; |
| 87 |
|
|
dlink_list exceptlist; |
| 88 |
|
|
dlink_list invexlist; |
| 89 |
|
|
|
| 90 |
|
|
float number_joined; |
| 91 |
|
|
|
| 92 |
michael |
4618 |
char name[CHANNELLEN + 1]; |
| 93 |
adx |
30 |
}; |
| 94 |
|
|
|
| 95 |
|
|
/*! \brief Membership structure */ |
| 96 |
|
|
struct Membership |
| 97 |
|
|
{ |
| 98 |
michael |
4404 |
dlink_node locchannode; /**< link to chptr->locmembers */ |
| 99 |
|
|
dlink_node channode; /**< link to chptr->members */ |
| 100 |
|
|
dlink_node usernode; /**< link to source_p->channel */ |
| 101 |
|
|
struct Channel *chptr; /**< Channel pointer */ |
| 102 |
|
|
struct Client *client_p; /**< Client pointer */ |
| 103 |
|
|
unsigned int flags; /**< user/channel flags, e.g. CHFL_CHANOP */ |
| 104 |
adx |
30 |
}; |
| 105 |
|
|
|
| 106 |
michael |
4404 |
/*! \brief Ban structure. Used for b/e/I n!u\@h masks */ |
| 107 |
adx |
30 |
struct Ban |
| 108 |
|
|
{ |
| 109 |
|
|
dlink_node node; |
| 110 |
michael |
5757 |
char name[NICKLEN + 1]; |
| 111 |
|
|
char user[USERLEN + 1]; |
| 112 |
|
|
char host[HOSTLEN + 1]; |
| 113 |
|
|
char who[NICKLEN + USERLEN + HOSTLEN + 3]; |
| 114 |
michael |
1013 |
size_t len; |
| 115 |
adx |
30 |
time_t when; |
| 116 |
michael |
371 |
struct irc_ssaddr addr; |
| 117 |
|
|
int bits; |
| 118 |
michael |
1644 |
int type; |
| 119 |
adx |
30 |
}; |
| 120 |
|
|
|
| 121 |
michael |
3944 |
extern dlink_list channel_list; |
| 122 |
adx |
30 |
|
| 123 |
michael |
6373 |
extern int channel_check_name(const char *, const int); |
| 124 |
michael |
6858 |
extern int can_send(struct Channel *, struct Client *, struct Membership *, const char *, int); |
| 125 |
michael |
1013 |
extern int is_banned(const struct Channel *, const struct Client *); |
| 126 |
michael |
1847 |
extern int has_member_flags(const struct Membership *, const unsigned int); |
| 127 |
adx |
30 |
|
| 128 |
michael |
3937 |
extern void channel_do_join(struct Client *, char *, char *); |
| 129 |
michael |
3912 |
extern void channel_do_join_0(struct Client *); |
| 130 |
michael |
4785 |
extern void channel_do_part(struct Client *, char *, const char *); |
| 131 |
adx |
30 |
extern void remove_ban(struct Ban *, dlink_list *); |
| 132 |
michael |
1798 |
extern void channel_init(void); |
| 133 |
michael |
4404 |
extern void add_user_to_channel(struct Channel *, struct Client *, unsigned int, int); |
| 134 |
adx |
30 |
extern void remove_user_from_channel(struct Membership *); |
| 135 |
|
|
extern void channel_member_names(struct Client *, struct Channel *, int); |
| 136 |
|
|
extern void add_invite(struct Channel *, struct Client *); |
| 137 |
|
|
extern void del_invite(struct Channel *, struct Client *); |
| 138 |
michael |
5852 |
extern void clear_invites_channel(struct Channel *); |
| 139 |
|
|
extern void clear_invites_client(struct Client *); |
| 140 |
michael |
6373 |
extern void channel_send_modes(struct Client *, struct Channel *); |
| 141 |
adx |
30 |
extern void channel_modes(struct Channel *, struct Client *, char *, char *); |
| 142 |
|
|
extern void check_spambot_warning(struct Client *, const char *); |
| 143 |
michael |
6373 |
extern void channel_free(struct Channel *); |
| 144 |
michael |
3941 |
extern void channel_set_topic(struct Channel *, const char *, const char *, time_t, int); |
| 145 |
adx |
30 |
|
| 146 |
michael |
2133 |
extern const char *get_member_status(const struct Membership *, const int); |
| 147 |
adx |
30 |
|
| 148 |
michael |
6373 |
extern struct Channel *channel_make(const char *); |
| 149 |
adx |
30 |
extern struct Membership *find_channel_link(struct Client *, struct Channel *); |
| 150 |
michael |
4404 |
#endif |