ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/phandler.C
Revision: 1.5
Committed: Sun Sep 16 18:54:45 2007 UTC (16 years, 8 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +7 -2 lines
Log Message:
#defines to enum

File Contents

# Content
1 /*
2 * phandler.C: Generic protocol handling routines.
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 * Rights to this code are documented in doc/pod/license.pod.
10 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
11 */
12
13 static char const rcsid[] = "$Id: phandler.C,v 1.4 2007-08-28 17:08:12 pippijn Exp $";
14
15 #include "atheme.h"
16 #include <account/chanacs.h>
17 #include "uplink.h"
18
19 namespace protocol
20 {
21 unsigned int
22 handler::server_login (void)
23 {
24 /* Nothing to do here. */
25 return 0;
26 }
27
28 void
29 handler::introduce_nick (user_t *u)
30 {
31 /* Nothing to do here. */
32 }
33
34 void
35 handler::wallops_sts (char const * const text)
36 {
37 slog (LG_INFO, "Don't know how to send wallops: %s", text);
38 }
39
40 void
41 handler::join_sts (channel_t *c, user_t *u, bool isnew, char const * const modes)
42 {
43 /* We can't do anything here. Bail. */
44 }
45
46 void
47 handler::chan_lowerts (channel_t *c, user_t *u)
48 {
49 slog (LG_ERROR, "chan_lowerts() called but not supported!");
50 join_sts (c, u, true, channel_modes (c, true));
51 }
52
53 void
54 handler::kick (char const * const from, char const * const channel, char const * const to, char const * const reason)
55 {
56 /* We can't do anything here. Bail. */
57 }
58
59 void
60 handler::mdchange (char const *target, char const *key, char const *value)
61 {
62 /* We can't do anything here. Bail. */
63 }
64
65 void
66 handler::privmsg (char const * const from, char const * const target, char const * const fmt, ...)
67 {
68 va_list ap;
69 char *buf;
70
71 va_start (ap, fmt);
72 vasprintf (&buf, fmt, ap);
73 va_end (ap);
74
75 slog (LG_INFO, "Cannot send message to %s (%s): don't know how. Load a protocol module perhaps?", target, buf);
76 sfree (buf);
77 }
78
79 void
80 handler::notice_user_sts (user_t *from, user_t *target, char const * const text)
81 {
82 slog (LG_INFO, "Cannot send notice to %s (%s): don't know how. Load a protocol module perhaps?", target->nick, text);
83 }
84
85 void
86 handler::notice_global_sts (user_t *from, char const * const mask, char const * const text)
87 {
88 slog (LG_INFO, "Cannot send global notice to %s (%s): don't know how. Load a protocol module perhaps?", mask, text);
89 }
90
91 void
92 handler::notice_channel_sts (user_t *from, channel_t *target, char const * const text)
93 {
94 slog (LG_INFO, "Cannot send notice to %s (%s): don't know how. Load a protocol module perhaps?", target->name, text);
95 }
96
97 void
98 handler::wallchops (user_t *sender, channel_t *channel, char const * const message)
99 {
100 /* ugly, but always works -- jilles */
101 node_t *n;
102 chanuser_t *cu;
103
104 LIST_FOREACH (n, channel->members.head)
105 {
106 cu = (chanuser_t *) n->data;
107 if (cu->user->server != me.me && cu->modes & CMODE_OP)
108 notice (sender->nick, cu->user->nick, "[@%s] %s", channel->name, message);
109 }
110 }
111
112 void
113 handler::numeric_sts (char const * const from, int numeric, char const * const target, char const * const fmt, ...)
114 {
115 va_list va;
116 char *buf;
117
118 va_start (va, fmt);
119 vasprintf (&buf, fmt, va);
120 va_end (va);
121
122 sts (":%s %d %s %s", from, numeric, target, buf);
123 sfree (buf);
124 }
125
126 void
127 handler::skill (char const * const from, char const * const nick, char const * const fmt, ...)
128 {
129 /* cant do anything here. bail. */
130 }
131
132 void
133 handler::part_sts (channel_t *c, user_t *u)
134 {
135 /* cant do anything here. bail. */
136 }
137
138 void
139 handler::kline_sts (char const * const server, char const * const user, char const * const host, long duration, char const * const reason)
140 {
141 /* cant do anything here. bail. */
142 }
143
144 void
145 handler::unkline_sts (char const * const server, char const * const user, char const * const host)
146 {
147 /* cant do anything here. bail. */
148 }
149
150 void
151 handler::topic_sts (channel_t *c, char const * const setter, time_t ts, time_t prevts, char const * const topic)
152 {
153 /* cant do anything here. bail. */
154 }
155
156 void
157 handler::mode_sts (char const * const sender, channel_t *target, char const * const modes)
158 {
159 /* cant do anything here. bail. */
160 }
161
162 void
163 handler::ping_sts (void)
164 {
165 /* cant do anything here. bail. */
166 }
167
168 void
169 handler::quit_sts (user_t *u, char const * const reason)
170 {
171 /* cant do anything here. bail. */
172 }
173
174 void
175 handler::ircd_on_login (char const * const origin, char const * const user, char const * const wantedhost)
176 {
177 /* nothing to do here. */
178 }
179
180 bool
181 handler::ircd_on_logout (char const * const origin, char const * const user, char const * const wantedhost)
182 {
183 /* nothing to do here. */
184 return false;
185 }
186
187 void
188 handler::jupe (char const * const server, char const * const reason)
189 {
190 /* nothing to do here. */
191 }
192
193 void
194 handler::sethost_sts (char const * const source, char const * const target, char const * const host)
195 {
196 /* nothing to do here. */
197 }
198
199 void
200 handler::fnc_sts (user_t *source, user_t *u, char const * const newnick, int type)
201 {
202 if (type == FNC_FORCE)
203 skill (source->nick, u->nick, "Nickname enforcement (%s)", u->nick);
204 }
205
206 void
207 handler::holdnick_sts (user_t *source, int duration, char const * const nick, myuser_t *account)
208 {
209 /* nothing to do here. */
210 }
211
212 void
213 handler::invite_sts (user_t *source, user_t *target, channel_t *channel)
214 {
215 /* nothing to do here. */
216 }
217
218 void
219 handler::svslogin_sts (char const * const target, char const * const nick, char const * const user, char const * const host, char const * const login)
220 {
221 /* nothing to do here. */
222 }
223
224 void
225 handler::sasl_sts (char const * const target, char const mode, char const * const data)
226 {
227 /* nothing to do here. */
228 }
229
230 node_t *
231 handler::next_matching_ban (channel_t *c, user_t *u, int type, node_t *first)
232 {
233 chanban_t *cb;
234 node_t *n;
235 char hostbuf[NICKLEN + USERLEN + HOSTLEN];
236 char realbuf[NICKLEN + USERLEN + HOSTLEN];
237 char ipbuf[NICKLEN + USERLEN + HOSTLEN];
238
239 snprintf (hostbuf, sizeof hostbuf, "%s!%s@%s", u->nick, u->user, u->vhost);
240 snprintf (realbuf, sizeof realbuf, "%s!%s@%s", u->nick, u->user, u->host);
241 /* will be nick!user@ if ip unknown, doesn't matter */
242 snprintf (ipbuf, sizeof ipbuf, "%s!%s@%s", u->nick, u->user, u->ip);
243 LIST_FOREACH (n, first)
244 {
245 cb = static_cast<chanban_t *> (n->data);
246
247 if (cb->type == type && (!match (cb->mask, hostbuf) || !match (cb->mask, realbuf) || !match (cb->mask, ipbuf) || (ircd->flags & IRCD_CIDR_BANS && !match_cidr (cb->mask, ipbuf))))
248 return n;
249 }
250 return NULL;
251 }
252
253 node_t *
254 handler::next_matching_host_chanacs (mychan_t *mc, user_t *u, node_t *first)
255 {
256 chanacs_t *ca;
257 node_t *n;
258 char hostbuf[NICKLEN + USERLEN + HOSTLEN];
259 char ipbuf[NICKLEN + USERLEN + HOSTLEN];
260
261 snprintf (hostbuf, sizeof hostbuf, "%s!%s@%s", u->nick, u->user, u->vhost);
262 /* will be nick!user@ if ip unknown, doesn't matter */
263 snprintf (ipbuf, sizeof ipbuf, "%s!%s@%s", u->nick, u->user, u->ip);
264
265 LIST_FOREACH (n, first)
266 {
267 ca = static_cast<chanacs_t *> (n->data);
268
269 if (ca->myuser != NULL)
270 continue;
271 if (!match (ca->host, hostbuf) || !match (ca->host, ipbuf) || (ircd->flags & IRCD_CIDR_BANS && !match_cidr (ca->host, ipbuf)))
272 return n;
273 }
274 return NULL;
275 }
276 } // namespace protocol