1 |
/* |
2 |
* Copyright © 2005 William Pitcock, et al. |
3 |
* Rights to this code are as documented in doc/LICENSE. |
4 |
* |
5 |
* Data structures for channel information. |
6 |
* |
7 |
* $Id: channels.h 8223 2007-05-05 12:58:06Z jilles $ |
8 |
*/ |
9 |
|
10 |
#ifndef CHANNELS_H |
11 |
#define CHANNELS_H |
12 |
|
13 |
#define MAXEXTMODES 5 |
14 |
|
15 |
struct channel_t |
16 |
{ |
17 |
char *name; |
18 |
|
19 |
unsigned int modes; |
20 |
char *key; |
21 |
unsigned int limit; |
22 |
char *extmodes[MAXEXTMODES]; /* non-standard simple modes with param eg +j */ |
23 |
|
24 |
unsigned int nummembers; |
25 |
|
26 |
time_t ts; |
27 |
|
28 |
char *topic; |
29 |
char *topic_setter; |
30 |
time_t topicts; |
31 |
|
32 |
list_t members; |
33 |
list_t bans; |
34 |
}; |
35 |
|
36 |
/* struct for channel memberships */ |
37 |
struct chanuser_t |
38 |
{ |
39 |
channel_t *chan; |
40 |
user_t *user; |
41 |
unsigned int modes; |
42 |
node_t unode; |
43 |
node_t cnode; |
44 |
}; |
45 |
|
46 |
struct chanban_t |
47 |
{ |
48 |
channel_t *chan; |
49 |
char *mask; |
50 |
int type; /* 'b', 'e', 'I', etc -- jilles */ |
51 |
}; |
52 |
|
53 |
#define CMODE_OP 0x00000020 /* SPECIAL */ |
54 |
#define CMODE_VOICE 0x00000200 /* SPECIAL */ |
55 |
|
56 |
#define CMODE_INVITE 0x00000001 |
57 |
#define CMODE_KEY 0x00000002 |
58 |
#define CMODE_LIMIT 0x00000004 |
59 |
#define CMODE_MOD 0x00000008 |
60 |
#define CMODE_NOEXT 0x00000010 |
61 |
#define CMODE_PRIV 0x00000040 /* AKA PARA */ |
62 |
#define CMODE_SEC 0x00000080 |
63 |
#define CMODE_TOPIC 0x00000100 |
64 |
|
65 |
#define MTYPE_NUL 0 |
66 |
#define MTYPE_ADD 1 |
67 |
#define MTYPE_DEL 2 |
68 |
|
69 |
struct cmode_t |
70 |
{ |
71 |
char mode; |
72 |
unsigned int value; |
73 |
}; |
74 |
|
75 |
struct extmode |
76 |
{ |
77 |
char mode; |
78 |
bool (*check) (const char *, channel_t *, mychan_t *, user_t *, myuser_t *); |
79 |
}; |
80 |
|
81 |
/* channel related hooks */ |
82 |
typedef struct |
83 |
{ |
84 |
chanuser_t *cu; /* Write NULL here if you kicked the user. |
85 |
When kicking the last user, you must join a |
86 |
service first, otherwise the channel may be |
87 |
destroyed and crashes may occur. The service may |
88 |
not part until you return; chanserv provides |
89 |
MC_INHABIT to help with this. |
90 |
This also prevents kick/rejoin floods. |
91 |
If this is NULL, a previous function kicked |
92 |
the user */ |
93 |
} hook_channel_joinpart_t; |
94 |
|
95 |
typedef struct |
96 |
{ |
97 |
user_t *u; |
98 |
channel_t *c; |
99 |
char *msg; |
100 |
} hook_cmessage_data_t; |
101 |
|
102 |
typedef struct |
103 |
{ |
104 |
user_t *u; /* Online user that changed the topic */ |
105 |
server_t *s; /* Server that restored a topic */ |
106 |
channel_t *c; /* Channel still has old topic */ |
107 |
char *setter; /* Stored setter string, can be nick, nick!user@host |
108 |
or server */ |
109 |
time_t ts; /* Time the topic was changed */ |
110 |
char *topic; /* New topic */ |
111 |
int approved; /* Write non-zero here to cancel the change */ |
112 |
} hook_channel_topic_check_t; |
113 |
|
114 |
/* cmode.c */ |
115 |
E char *flags_to_string (int flags); |
116 |
E int mode_to_flag (char c); |
117 |
E void channel_mode (user_t *source, channel_t *chan, int parc, char *parv[]); |
118 |
E void channel_mode_va (user_t *source, channel_t *chan, int parc, char *parv0, ...); |
119 |
E void clear_simple_modes (channel_t *c); |
120 |
E char *channel_modes (channel_t *c, bool doparams); |
121 |
E void modestack_flush_channel (channel_t *channel); |
122 |
E void modestack_forget_channel (channel_t *channel); |
123 |
E void modestack_finalize_channel (channel_t *channel); |
124 |
E void modestack_mode_simple (char *source, channel_t *channel, int dir, int flags); |
125 |
E void modestack_mode_limit (char *source, channel_t *channel, int dir, unsigned int limit); |
126 |
E void modestack_mode_ext (char *source, channel_t *channel, int dir, int i, const char *value); |
127 |
E void modestack_mode_param (char *source, channel_t *channel, int dir, char type, const char *value); |
128 |
E void check_modes (mychan_t *mychan, bool sendnow); |
129 |
|
130 |
/* channels.c */ |
131 |
E dictionary_tree_t *chanlist; |
132 |
|
133 |
E void init_channels (void); |
134 |
|
135 |
E channel_t *channel_add (const char *name, unsigned int ts, server_t *creator); |
136 |
E void channel_delete (channel_t *c); |
137 |
E channel_t *channel_find (const char *name); |
138 |
|
139 |
E chanuser_t *chanuser_add (channel_t *chan, const char *user); |
140 |
E void chanuser_delete (channel_t *chan, user_t *user); |
141 |
E chanuser_t *chanuser_find (channel_t *chan, user_t *user); |
142 |
|
143 |
E chanban_t *chanban_add (channel_t *chan, const char *mask, int type); |
144 |
E void chanban_delete (chanban_t *c); |
145 |
E chanban_t *chanban_find (channel_t *chan, const char *mask, int type); |
146 |
E void chanban_clear (channel_t *chan); |
147 |
|
148 |
#endif |