ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/phandler.h
(Generate patch)

Comparing ermyth/include/phandler.h (file contents):
Revision 1.3 by pippijn, Sat Jul 21 13:23:18 2007 UTC vs.
Revision 1.4 by pippijn, Tue Aug 28 17:08:07 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines