ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/channels.h
Revision: 1.6
Committed: Sun Sep 9 20:05:51 2007 UTC (16 years, 8 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.5: +2 -1 lines
Log Message:
- changed configurations to the c++ stdlib
- more #defines to enum
- removed getopt.h and link.h from the system as they were unused
- reworked logstreams
- added an itoa with old syntax
- made klines objects
- moved some global variables into appropriate classes
- fixed boost.foreach's compiler workaround #if's
- allow other files to add exceptions with ADD_EXCEPTION
- changed mynick_t to c++ object
- moved servers.h out of atheme.h
- corrected PING from inspircd 1.2

File Contents

# User Rev Content
1 pippijn 1.1 /*
2 pippijn 1.3 * Copyright © 2005 William Pitcock, et al.
3 pippijn 1.2 * Rights to this code are as documented in doc/pod/license.pod.
4 pippijn 1.1 *
5     * Data structures for channel information.
6     *
7 pippijn 1.6 * $Id: channels.h,v 1.5 2007-09-05 11:23:13 pippijn Exp $
8 pippijn 1.1 */
9    
10     #ifndef CHANNELS_H
11     #define CHANNELS_H
12    
13 pippijn 1.4 #include <map>
14    
15 pippijn 1.6 #include <common/util.h>
16 pippijn 1.3 #include <ermyth/callback.h>
17    
18 pippijn 1.1 #define MAXEXTMODES 5
19    
20 pippijn 1.5 // Channel modes
21     enum
22     {
23     CMODE_INVITE = 1 << 0,
24     CMODE_KEY = 1 << 1,
25     CMODE_LIMIT = 1 << 2,
26     CMODE_MOD = 1 << 3,
27     CMODE_NOEXT = 1 << 4,
28     CMODE_OP = 1 << 5, /* SPECIAL */
29     CMODE_PRIV = 1 << 6, /* AKA PARA */
30     CMODE_SEC = 1 << 7,
31     CMODE_TOPIC = 1 << 8,
32     CMODE_VOICE = 1 << 9 /* SPECIAL */
33     };
34    
35 pippijn 1.3 class channel_t : public zero_initialised
36 pippijn 1.1 {
37 pippijn 1.3 struct callbacks
38     {
39     functor::callback1<channel_t *> add;
40     functor::callback1<channel_t *> akick_add;
41     functor::callback1<channel_t *> remove;
42     functor::callback6<channel_t *, user_t *, server_t *,
43     char const * const /* setter */,
44     time_t /* ts */,
45     char const * const /* topic */,
46     bool /* return value */> can_change_topic;
47     functor::callback3<channel_t *, user_t *, char const * const> message;
48     functor::callback1<channel_t *> topic;
49     functor::callback1<channel_t *> tschange;
50     };
51    
52     public:
53 pippijn 1.5 unsigned modes;
54    
55 pippijn 1.1 char *name;
56    
57     char *key;
58     unsigned int limit;
59     char *extmodes[MAXEXTMODES]; /* non-standard simple modes with param eg +j */
60    
61     unsigned int nummembers;
62    
63     time_t ts;
64    
65     char *topic;
66     char *topic_setter;
67     time_t topicts;
68    
69     list_t members;
70     list_t bans;
71 pippijn 1.3
72     static callbacks callback;
73 pippijn 1.1 };
74    
75     /* struct for channel memberships */
76 pippijn 1.3 class chanuser_t : public zero_initialised
77 pippijn 1.1 {
78 pippijn 1.3 struct callbacks
79     {
80     functor::callback1<chanuser_t *, bool> join;
81     functor::callback1<chanuser_t *> part;
82     };
83    
84     public:
85 pippijn 1.5 unsigned modes;
86    
87 pippijn 1.1 channel_t *chan;
88     user_t *user;
89     node_t unode;
90     node_t cnode;
91 pippijn 1.3
92     static callbacks callback;
93 pippijn 1.1 };
94    
95 pippijn 1.3 struct chanban_t : zero_initialised
96 pippijn 1.1 {
97     channel_t *chan;
98     char *mask;
99     int type; /* 'b', 'e', 'I', etc -- jilles */
100     };
101    
102 pippijn 1.5 enum mtype
103     {
104     MTYPE_NUL,
105     MTYPE_ADD,
106     MTYPE_DEL
107     };
108 pippijn 1.1
109     struct cmode_t
110     {
111     char mode;
112     unsigned int value;
113     };
114    
115 pippijn 1.5 struct extmode_t
116 pippijn 1.1 {
117     char mode;
118 pippijn 1.3 bool (*check) (char const * const, channel_t *, mychan_t *, user_t *, myuser_t *);
119 pippijn 1.1 };
120    
121 pippijn 1.3 #if 0
122 pippijn 1.1 /* channel related hooks */
123     typedef struct
124     {
125     chanuser_t *cu; /* Write NULL here if you kicked the user.
126     When kicking the last user, you must join a
127     service first, otherwise the channel may be
128     destroyed and crashes may occur. The service may
129     not part until you return; chanserv provides
130     MC_INHABIT to help with this.
131     This also prevents kick/rejoin floods.
132     If this is NULL, a previous function kicked
133     the user */
134     } hook_channel_joinpart_t;
135    
136     typedef struct
137     {
138     user_t *u;
139     channel_t *c;
140     char *msg;
141     } hook_cmessage_data_t;
142    
143 pippijn 1.3 struct hook_channel_topic_check_t
144 pippijn 1.1 {
145     user_t *u; /* Online user that changed the topic */
146     server_t *s; /* Server that restored a topic */
147     channel_t *c; /* Channel still has old topic */
148 pippijn 1.3 char const * const setter; /* Stored setter string, can be nick, nick!user@host
149 pippijn 1.1 or server */
150     time_t ts; /* Time the topic was changed */
151 pippijn 1.3 char const * const topic; /* New topic */
152 pippijn 1.1 int approved; /* Write non-zero here to cancel the change */
153    
154 pippijn 1.3 hook_channel_topic_check_t (char const * const _setter, char const * const _topic)
155     : setter (_setter), topic (_topic)
156     {
157     }
158     };
159     #endif
160    
161     /* cmode.C */
162 pippijn 1.1 E char *flags_to_string (int flags);
163     E int mode_to_flag (char c);
164 pippijn 1.3 E void channel_mode (user_t *source, channel_t *chan, int parc, char const * const parv[]);
165     E void channel_mode (user_t *source, channel_t *chan, char const * const arg);
166     E void channel_mode_va (user_t *source, channel_t *chan, int parc, char const * const parv0, ...);
167 pippijn 1.1 E void clear_simple_modes (channel_t *c);
168     E char *channel_modes (channel_t *c, bool doparams);
169     E void modestack_flush_channel (channel_t *channel);
170     E void modestack_forget_channel (channel_t *channel);
171     E void modestack_finalize_channel (channel_t *channel);
172 pippijn 1.5 E void modestack_mode_simple (char *source, channel_t *channel, mtype dir, int flags);
173     E void modestack_mode_limit (char *source, channel_t *channel, mtype dir, unsigned int limit);
174     E void modestack_mode_ext (char *source, channel_t *channel, mtype dir, int i, char const * const value);
175     E void modestack_mode_param (char *source, channel_t *channel, mtype dir, char type, char const * const value);
176 pippijn 1.1 E void check_modes (mychan_t *mychan, bool sendnow);
177    
178 pippijn 1.3 /* channels.C */
179 pippijn 1.4 typedef std::pair<char const * const, channel_t *> channel_pair;
180     typedef std::map<char const * const, channel_t *, irccase_lt> channel_map;
181     E channel_map chanlist;
182 pippijn 1.1
183     E void init_channels (void);
184    
185 pippijn 1.3 E channel_t *channel_add (char const * const name, unsigned int ts, server_t *creator);
186 pippijn 1.1 E void channel_delete (channel_t *c);
187 pippijn 1.3 E channel_t *channel_find (char const * const name);
188 pippijn 1.1
189 pippijn 1.3 E chanuser_t *chanuser_add (channel_t *chan, char const * const user);
190 pippijn 1.1 E void chanuser_delete (channel_t *chan, user_t *user);
191     E chanuser_t *chanuser_find (channel_t *chan, user_t *user);
192    
193 pippijn 1.3 E chanban_t *chanban_add (channel_t *chan, char const * const mask, int type);
194 pippijn 1.1 E void chanban_delete (chanban_t *c);
195 pippijn 1.3 E chanban_t *chanban_find (channel_t *chan, char const * const mask, int type);
196 pippijn 1.1 E void chanban_clear (channel_t *chan);
197    
198     #endif