ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/channels.h
Revision: 1.3
Committed: Tue Aug 28 17:08:06 2007 UTC (16 years, 9 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.2: +58 -21 lines
Log Message:
- changed name
- updated the example config to the new system
- added more documentation
- enhanced documentation generators
- added a link to the pdf to the website
- added an RSS feed generator
- transitioned hooks to c++ callbacks
- did various merges with upstream along the way
- added const where appropriate
- removed the old block allocator
- fixed most memory leaks
- transitioned some dictionaries to std::map
- transitioned some lists to std::vector
- made some free functions members where appropriate
- renamed string to dynstr and added a static string ststr
- use NOW instead of time (NULL) if possible
- completely reworked database backends, crypto handlers and protocol handlers
  to use an object factory
- removed the old module system. ermyth does not do any dynamic loading anymore
- fixed most of the build system
- reworked how protocol commands work

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