ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/phandler.h
Revision: 1.7
Committed: Sun Sep 16 18:54:42 2007 UTC (16 years, 8 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +9 -4 lines
Log Message:
#defines to enum

File Contents

# Content
1 /**
2 * phandler.h: Protocol handlers, both generic and the actual declarations themselves.
3 *
4 * Copyright © 2007 Pippijn van Steenhoven / The Ermyth Team
5 * Rights to this code are as documented in COPYING.
6 *
7 *
8 * Portions of this file were derived from sources bearing the following license:
9 * Copyright © 2005 William Pitcock, et al.
10 * Rights to this code are as documented in doc/pod/license.pod.
11 *
12 * $Id: phandler.h,v 1.6 2007-09-05 11:23:13 pippijn Exp $
13 */
14
15 #ifndef PHANDLER_H
16 #define PHANDLER_H
17
18 #include <ermyth/factory.h>
19
20 namespace protocol
21 {
22 struct ircd_t
23 {
24 char const * const ircdname;
25 char const * const tldprefix;
26 bool uses_uid;
27 bool uses_rcommand;
28 bool uses_owner;
29 bool uses_protect;
30 bool uses_halfops;
31 bool uses_p10; /* Parser hackhack. */
32 bool uses_vhost; /* Do we use vHosts? */
33 unsigned const oper_only_modes;
34 unsigned const owner_mode;
35 unsigned const protect_mode;
36 unsigned const halfops_mode;
37 char const * const owner_mchar;
38 char const * const protect_mchar;
39 char const * const halfops_mchar;
40 unsigned const type;
41 unsigned const perm_mode; /* Modes to not disappear when empty */
42 char const * const ban_like_modes; /* e.g. "beI" */
43 char const except_mchar;
44 char const invex_mchar;
45 int const flags;
46 };
47
48 /* values for type */
49 /* -- what the HELL are these used for? A grep reveals nothing.. --w00t
50 * -- they are used to provide a hint to third-party module coders about what
51 * ircd they are working with. --nenolod
52 */
53 #define PROTOCOL_ASUKA 1
54 #define PROTOCOL_BAHAMUT 2
55 #define PROTOCOL_CHARYBDIS 3
56 #define PROTOCOL_DREAMFORGE 4
57 #define PROTOCOL_HYPERION 5
58 #define PROTOCOL_INSPIRCD 6
59 #define PROTOCOL_IRCNET 7
60 #define PROTOCOL_MONKEY 8 /* obsolete */
61 #define PROTOCOL_PLEXUS 9
62 #define PROTOCOL_PTLINK 10
63 #define PROTOCOL_RATBOX 11
64 #define PROTOCOL_SCYLLA 12
65 #define PROTOCOL_SHADOWIRCD 13
66 #define PROTOCOL_SORCERY 14
67 #define PROTOCOL_ULTIMATE3 15
68 #define PROTOCOL_UNDERNET 16
69 #define PROTOCOL_UNREAL 17
70 #define PROTOCOL_SOLIDIRCD 18
71 #define PROTOCOL_NEFARIOUS 19
72 #define PROTOCOL_OFFICEIRC 20
73
74 #define PROTOCOL_OTHER 255
75
76 /* values for flags */
77 #define IRCD_CIDR_BANS 1
78
79 /* forced nick change types */
80 #define FNC_REGAIN 0 /* give a registered user their nick back */
81 #define FNC_FORCE 1 /* force a user off their nick (kill if unsupported) */
82
83 struct handler
84 {
85 /* pmodule.C */
86 static bool loaded;
87
88 handler ()
89 {
90 loaded = true;
91 }
92
93 virtual ~handler ()
94 {
95 loaded = false;
96 }
97
98 /* server login, usually sends PASS, CAPAB, SERVER and SVINFO
99 * you can still change ircd->uses_uid at this point
100 * set me.bursting = true
101 * return 1 if sts() failed (by returning 1), otherwise 0 */
102 virtual unsigned int server_login (void);
103 /* introduce a client on the services server */
104 virtual void introduce_nick (user_t *u);
105 /* send an invite for a given user to a channel
106 * the source may not be on the channel */
107 virtual void invite_sts (user_t *source, user_t *target, channel_t *channel);
108 /* quit a client on the services server with the given message */
109 virtual void quit_sts (user_t *u, char const * const reason);
110 /* send wallops
111 * use something that only opers can see if easily possible */
112 virtual void wallops_sts (char const * const text);
113 /* join a channel with a client on the services server
114 * the client should be introduced opped
115 * isnew indicates the channel modes (and bans XXX) should be bursted
116 * note that the channelts can still be old in this case (e.g. kills)
117 * modes is a convenience argument giving the simple modes with parameters
118 * do not rely upon chanuser_find(c,u) */
119 virtual void join_sts (channel_t *c, user_t *u, bool isnew, char const * const modes);
120 /* lower the TS of a channel, joining it with the given client on the
121 * services server (opped), replacing the current simple modes with the
122 * ones stored in the channel_t and clearing all other statuses
123 * if bans are timestamped on this ircd, call chanban_clear()
124 * if the topic is timestamped on this ircd, clear it */
125 virtual void chan_lowerts (channel_t *c, user_t *u);
126 /* kick a user from a channel
127 * from is a client on the services server which may or may not be
128 * on the channel */
129 virtual void kick (char const * const from, char const * const channel, char const * const to, char const * const reason);
130 /* change ircd metadata */
131 virtual void mdchange (char const * const target, char const * const key, char const * const value);
132 /* send a privmsg
133 * here it's ok to assume the source is able to send */
134 virtual void privmsg (char const * const from, char const * const target, char const * const fmt, ...);
135 /* send a notice to a user
136 * from can be a client on the services server or the services server
137 * itself (NULL) */
138 virtual void notice_user_sts (user_t *from, user_t *target, char const * const text);
139 /* send a global notice to all users on servers matching the mask
140 * from is a client on the services server
141 * mask is either "*" or it has a non-wildcard TLD */
142 virtual void notice_global_sts (user_t *from, char const * const mask, char const * const text);
143 /* send a notice to a channel
144 * from can be a client on the services server or the services server
145 * itself (NULL)
146 * if the source cannot send because it is not on the channel, send the
147 * notice from the server or join for a moment */
148 virtual void notice_channel_sts (user_t *from, channel_t *target, char const * const text);
149 /* send a notice to ops in a channel
150 * source may or may not be on channel
151 * generic_wallchops() sends an individual notice to each channel operator */
152 virtual void wallchops (user_t *source, channel_t *target, char const * const message);
153 /* send a numeric from must be me.name or ME */
154 virtual void numeric_sts (char const * const from, int numeric, char const * const target, char const * const fmt, ...);
155 /* kill a user
156 * from can be a client on the services server or the services server
157 * itself (me.name or ME)
158 * it is recommended to change an invalid source to ME */
159 virtual void skill (char const * const from, char const * const nick, char const * const fmt, ...);
160 /* part a channel with a client on the services server */
161 virtual void part_sts (channel_t *c, user_t *u);
162 /* add a kline on the servers matching the given mask
163 * duration is in seconds, 0 for a permanent kline
164 * if the ircd requires klines to be sent from users, use opersvs */
165 virtual void kline_sts (char const * const server, char const * const user, char const * const host, long duration, char const * const reason);
166 /* remove a kline on the servers matching the given mask
167 * if the ircd requires unklines to be sent from users, use opersvs */
168 virtual void unkline_sts (char const * const server, char const * const user, char const * const host);
169 /* make chanserv set a topic on a channel
170 * setter and ts should be used if the ircd supports topics to be set
171 * with a given topicsetter and topicts; ts is not a channelts
172 * prevts is the topicts of the old topic or 0 if there was no topic,
173 * useful in optimizing which form of topic change to use
174 * if the given topicts was not set and topicts is used on the ircd,
175 * set c->topicts to the value used */
176 virtual void topic_sts (channel_t *c, char const * const setter, time_t ts, time_t prevts, char const * const topic);
177 /* set modes on a channel by the given sender; sender must be a client
178 * on the services server; sender may or may not be on channel */
179 virtual void mode_sts (char const * const sender, channel_t *target, char const * const modes);
180 /* ping the uplink
181 * first check if me.connected is true and bail if not */
182 virtual void ping_sts (void);
183 /* mark user 'origin' as logged in as 'user'
184 * wantedhost is currently not used
185 * first check if me.connected is true and bail if not */
186 virtual void ircd_on_login (char const * const origin, char const * const user, char const * const wantedhost);
187 /* mark user 'origin' as logged out
188 * first check if me.connected is true and bail if not
189 * return false if successful or logins are not supported
190 * return true if the user was killed to force logout (P10) */
191 virtual bool ircd_on_logout (char const * const origin, char const * const user, char const * const wantedhost);
192 /* introduce a fake server
193 * it is ok to use opersvs to squit the old server
194 * if SQUIT uses kill semantics (e.g. charybdis), server_delete() the server
195 * and continue
196 * if SQUIT uses unconnect semantics (e.g. bahamut), set SF_JUPE_PENDING on
197 * the server and return; you will be called again when the server is really
198 * deleted */
199 virtual void jupe (char const * const server, char const * const reason);
200 /* set a dynamic spoof on a user
201 * if the ircd does not notify the user of this, do
202 * notice(source, target, "Setting your host to \2%s\2.", host); */
203 virtual void sethost_sts (char const * const source, char const * const target, char const * const host);
204 /* force a nickchange for a user
205 * possible values for type:
206 * FNC_REGAIN: give a registered user their nick back
207 * FNC_FORCE: force a user off their nick (kill if unsupported)
208 */
209 virtual void fnc_sts (user_t *source, user_t *u, char const * const newnick, int type);
210 /* temporarily make a nick unavailable to users
211 * source is the responsible service
212 * duration is in seconds, 0 to remove the effect of a previous call
213 * account is an account that may still use the nick, or NULL */
214 virtual void holdnick_sts (user_t *source, int duration, char const * const nick, myuser_t *account);
215 /* change nick, user, host and/or services login name for a user
216 * target may also be a not yet fully introduced UID (for SASL) */
217 virtual void svslogin_sts (char const * const target, char const * const nick, char const * const user, char const * const host, char const * const login);
218 /* send sasl message */
219 virtual void sasl_sts (char const * const target, char const mode, char const * const data);
220 /* find next channel ban (or other ban-like mode) matching user */
221 virtual node_t *next_matching_ban (channel_t *c, user_t *u, int type, node_t *first);
222 /* find next host channel access matching user */
223 virtual node_t *next_matching_host_chanacs (mychan_t *mc, user_t *u, node_t *first);
224 };
225 } // namespace protocol
226
227 #define FACREG_TYPE protocol::handler
228 #define FACREG_TYPE_NAME "protocol handler"
229 #define FACREG_TYPE_IS_ABSTRACT
230 #include <ermyth/factory_reg.h>
231
232 E protocol::handler *phandler;
233 E protocol::ircd_t *ircd;
234
235 E cmode_t *mode_list;
236 E extmode_t *ignore_mode_list;
237 E cmode_t *status_mode_list;
238 E cmode_t *prefix_mode_list;
239
240 #endif