1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 2005-2014 ircd-hybrid development team |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
* USA |
20 |
*/ |
21 |
|
22 |
/*! \file m_services.c |
23 |
* \brief Includes required functions for processing the CS/NS/MS/OS/BS services command. |
24 |
* \version $Id$ |
25 |
*/ |
26 |
|
27 |
#include "stdinc.h" |
28 |
#include "client.h" |
29 |
#include "ircd.h" |
30 |
#include "channel_mode.h" |
31 |
#include "numeric.h" |
32 |
#include "conf.h" |
33 |
#include "s_serv.h" |
34 |
#include "send.h" |
35 |
#include "parse.h" |
36 |
#include "modules.h" |
37 |
#include "irc_string.h" |
38 |
#include "s_user.h" |
39 |
#include "hash.h" |
40 |
|
41 |
|
42 |
/* |
43 |
* XXX: Each services alias handler is currently ugly copy&paste. |
44 |
* Configureable aliases will get implemented. |
45 |
*/ |
46 |
|
47 |
static int |
48 |
m_nickserv(struct Client *client_p, struct Client *source_p, |
49 |
int parc, char *parv[]) |
50 |
{ |
51 |
struct Client *target_p = NULL; |
52 |
|
53 |
assert(client_p && source_p); |
54 |
assert(client_p == source_p); |
55 |
|
56 |
if (EmptyString(parv[1])) |
57 |
{ |
58 |
sendto_one_numeric(source_p, &me, ERR_NOTEXTTOSEND); |
59 |
return 0; |
60 |
} |
61 |
|
62 |
if ((target_p = hash_find_server(ConfigFileEntry.service_name))) |
63 |
{ |
64 |
sendto_one(target_p, ":%s PRIVMSG NickServ@%s :%s", |
65 |
source_p->name, ConfigFileEntry.service_name, parv[1]); |
66 |
return 0; |
67 |
} |
68 |
|
69 |
sendto_one_numeric(source_p, &me, ERR_SERVICESDOWN, "NickServ"); |
70 |
return 0; |
71 |
} |
72 |
|
73 |
static int |
74 |
m_chanserv(struct Client *client_p, struct Client *source_p, |
75 |
int parc, char *parv[]) |
76 |
{ |
77 |
struct Client *target_p = NULL; |
78 |
|
79 |
assert(client_p && source_p); |
80 |
assert(client_p == source_p); |
81 |
|
82 |
if (EmptyString(parv[1])) |
83 |
{ |
84 |
sendto_one_numeric(source_p, &me, ERR_NOTEXTTOSEND); |
85 |
return 0; |
86 |
} |
87 |
|
88 |
if ((target_p = hash_find_server(ConfigFileEntry.service_name))) |
89 |
{ |
90 |
sendto_one(target_p, ":%s PRIVMSG ChanServ@%s :%s", |
91 |
source_p->name, ConfigFileEntry.service_name, parv[1]); |
92 |
return 0; |
93 |
} |
94 |
|
95 |
sendto_one_numeric(source_p, &me, ERR_SERVICESDOWN, "ChanServ"); |
96 |
return 0; |
97 |
} |
98 |
|
99 |
static int |
100 |
m_memoserv(struct Client *client_p, struct Client *source_p, |
101 |
int parc, char *parv[]) |
102 |
{ |
103 |
struct Client *target_p = NULL; |
104 |
|
105 |
assert(client_p && source_p); |
106 |
assert(client_p == source_p); |
107 |
|
108 |
if (EmptyString(parv[1])) |
109 |
{ |
110 |
sendto_one_numeric(source_p, &me, ERR_NOTEXTTOSEND); |
111 |
return 0; |
112 |
} |
113 |
|
114 |
if ((target_p = hash_find_server(ConfigFileEntry.service_name))) |
115 |
{ |
116 |
sendto_one(target_p, ":%s PRIVMSG MemoServ@%s :%s", |
117 |
source_p->name, ConfigFileEntry.service_name, parv[1]); |
118 |
return 0; |
119 |
} |
120 |
|
121 |
sendto_one_numeric(source_p, &me, ERR_SERVICESDOWN, "MemoServ"); |
122 |
return 0; |
123 |
} |
124 |
|
125 |
static int |
126 |
m_operserv(struct Client *client_p, struct Client *source_p, |
127 |
int parc, char *parv[]) |
128 |
{ |
129 |
struct Client *target_p = NULL; |
130 |
|
131 |
assert(client_p && source_p); |
132 |
assert(client_p == source_p); |
133 |
|
134 |
if (EmptyString(parv[1])) |
135 |
{ |
136 |
sendto_one_numeric(source_p, &me, ERR_NOTEXTTOSEND); |
137 |
return 0; |
138 |
} |
139 |
|
140 |
if ((target_p = hash_find_server(ConfigFileEntry.service_name))) |
141 |
{ |
142 |
sendto_one(target_p, ":%s PRIVMSG OperServ@%s :%s", |
143 |
source_p->name, ConfigFileEntry.service_name, parv[1]); |
144 |
return 0; |
145 |
} |
146 |
|
147 |
sendto_one_numeric(source_p, &me, ERR_SERVICESDOWN, "OperServ"); |
148 |
return 0; |
149 |
} |
150 |
|
151 |
static int |
152 |
m_statserv(struct Client *client_p, struct Client *source_p, |
153 |
int parc, char *parv[]) |
154 |
{ |
155 |
struct Client *target_p = NULL; |
156 |
|
157 |
assert(client_p && source_p); |
158 |
assert(client_p == source_p); |
159 |
|
160 |
if (EmptyString(parv[1])) |
161 |
{ |
162 |
sendto_one_numeric(source_p, &me, ERR_NOTEXTTOSEND); |
163 |
return 0; |
164 |
} |
165 |
|
166 |
if ((target_p = hash_find_server(ConfigFileEntry.service_name))) |
167 |
{ |
168 |
sendto_one(target_p, ":%s PRIVMSG StatServ@%s :%s", |
169 |
source_p->name, ConfigFileEntry.service_name, parv[1]); |
170 |
return 0; |
171 |
} |
172 |
|
173 |
sendto_one_numeric(source_p, &me, ERR_SERVICESDOWN, "StatServ"); |
174 |
return 0; |
175 |
} |
176 |
|
177 |
static int |
178 |
m_hostserv(struct Client *client_p, struct Client *source_p, |
179 |
int parc, char *parv[]) |
180 |
{ |
181 |
struct Client *target_p = NULL; |
182 |
|
183 |
assert(client_p && source_p); |
184 |
assert(client_p == source_p); |
185 |
|
186 |
if (EmptyString(parv[1])) |
187 |
{ |
188 |
sendto_one_numeric(source_p, &me, ERR_NOTEXTTOSEND); |
189 |
return 0; |
190 |
} |
191 |
|
192 |
if ((target_p = hash_find_server(ConfigFileEntry.service_name))) |
193 |
{ |
194 |
sendto_one(target_p, ":%s PRIVMSG HostServ@%s :%s", |
195 |
source_p->name, ConfigFileEntry.service_name, parv[1]); |
196 |
return 0; |
197 |
} |
198 |
|
199 |
sendto_one_numeric(source_p, &me, ERR_SERVICESDOWN, "HostServ"); |
200 |
return 0; |
201 |
} |
202 |
|
203 |
static int |
204 |
m_botserv(struct Client *client_p, struct Client *source_p, |
205 |
int parc, char *parv[]) |
206 |
{ |
207 |
struct Client *target_p = NULL; |
208 |
|
209 |
assert(client_p && source_p); |
210 |
assert(client_p == source_p); |
211 |
|
212 |
if (EmptyString(parv[1])) |
213 |
{ |
214 |
sendto_one_numeric(source_p, &me, ERR_NOTEXTTOSEND); |
215 |
return 0; |
216 |
} |
217 |
|
218 |
if ((target_p = hash_find_server(ConfigFileEntry.service_name))) |
219 |
{ |
220 |
sendto_one(target_p, ":%s PRIVMSG BotServ@%s :%s", |
221 |
source_p->name, ConfigFileEntry.service_name, parv[1]); |
222 |
return 0; |
223 |
} |
224 |
|
225 |
sendto_one_numeric(source_p, &me, ERR_SERVICESDOWN, "BotServ"); |
226 |
return 0; |
227 |
} |
228 |
|
229 |
|
230 |
static struct Message ms_msgtab = |
231 |
{ |
232 |
"MS", 0, 0, 0, 1, MFLG_SLOW, 0, |
233 |
{ m_unregistered, m_memoserv, m_ignore, m_ignore, m_memoserv, m_ignore } |
234 |
}; |
235 |
|
236 |
static struct Message ns_msgtab = |
237 |
{ |
238 |
"NS", 0, 0, 0, 1, MFLG_SLOW, 0, |
239 |
{ m_unregistered, m_nickserv, m_ignore, m_ignore, m_nickserv, m_ignore } |
240 |
}; |
241 |
|
242 |
static struct Message os_msgtab = |
243 |
{ |
244 |
"OS", 0, 0, 0, 1, MFLG_SLOW, 0, |
245 |
{ m_unregistered, m_operserv, m_ignore, m_ignore, m_operserv, m_ignore } |
246 |
}; |
247 |
|
248 |
static struct Message bs_msgtab = |
249 |
{ |
250 |
"BS", 0, 0, 0, 1, MFLG_SLOW, 0, |
251 |
{ m_unregistered, m_botserv, m_ignore, m_ignore, m_botserv, m_ignore } |
252 |
}; |
253 |
|
254 |
static struct Message cs_msgtab = |
255 |
{ |
256 |
"CS", 0, 0, 0, 1, MFLG_SLOW, 0, |
257 |
{ m_unregistered, m_chanserv, m_ignore, m_ignore, m_chanserv, m_ignore } |
258 |
}; |
259 |
|
260 |
static struct Message ss_msgtab = |
261 |
{ |
262 |
"SS", 0, 0, 0, 1, MFLG_SLOW, 0, |
263 |
{ m_unregistered, m_statserv, m_ignore, m_ignore, m_statserv, m_ignore } |
264 |
}; |
265 |
|
266 |
static struct Message hs_msgtab = |
267 |
{ |
268 |
"HS", 0, 0, 0, 1, MFLG_SLOW, 0, |
269 |
{ m_unregistered, m_hostserv, m_ignore, m_ignore, m_hostserv, m_ignore } |
270 |
}; |
271 |
|
272 |
static struct Message botserv_msgtab = |
273 |
{ |
274 |
"BOTSERV", 0, 0, 0, 1, MFLG_SLOW, 0, |
275 |
{ m_unregistered, m_botserv, m_ignore, m_ignore, m_botserv, m_ignore } |
276 |
}; |
277 |
|
278 |
static struct Message chanserv_msgtab = |
279 |
{ |
280 |
"CHANSERV", 0, 0, 0, 1, MFLG_SLOW, 0, |
281 |
{ m_unregistered, m_chanserv, m_ignore, m_ignore, m_chanserv, m_ignore } |
282 |
}; |
283 |
|
284 |
static struct Message memoserv_msgtab = |
285 |
{ |
286 |
"MEMOSERV", 0, 0, 0, 1, MFLG_SLOW, 0, |
287 |
{ m_unregistered, m_memoserv, m_ignore, m_ignore, m_memoserv, m_ignore } |
288 |
}; |
289 |
|
290 |
static struct Message nickserv_msgtab = |
291 |
{ |
292 |
"NICKSERV", 0, 0, 0, 1, MFLG_SLOW, 0, |
293 |
{ m_unregistered, m_nickserv, m_ignore, m_ignore, m_nickserv, m_ignore } |
294 |
}; |
295 |
|
296 |
static struct Message operserv_msgtab = |
297 |
{ |
298 |
"OPERSERV", 0, 0, 0, 1, MFLG_SLOW, 0, |
299 |
{ m_unregistered, m_operserv, m_ignore, m_ignore, m_operserv, m_ignore } |
300 |
}; |
301 |
|
302 |
static struct Message statserv_msgtab = |
303 |
{ |
304 |
"STATSERV", 0, 0, 0, 1, MFLG_SLOW, 0, |
305 |
{ m_unregistered, m_statserv, m_ignore, m_ignore, m_statserv, m_ignore } |
306 |
}; |
307 |
|
308 |
static struct Message hostserv_msgtab = |
309 |
{ |
310 |
"HOSTSERV", 0, 0, 0, 1, MFLG_SLOW, 0, |
311 |
{ m_unregistered, m_hostserv, m_ignore, m_ignore, m_hostserv, m_ignore } |
312 |
}; |
313 |
|
314 |
|
315 |
static void |
316 |
module_init(void) |
317 |
{ |
318 |
mod_add_cmd(&botserv_msgtab); |
319 |
mod_add_cmd(&chanserv_msgtab); |
320 |
mod_add_cmd(&memoserv_msgtab); |
321 |
mod_add_cmd(&nickserv_msgtab); |
322 |
mod_add_cmd(&operserv_msgtab); |
323 |
mod_add_cmd(&statserv_msgtab); |
324 |
mod_add_cmd(&hostserv_msgtab); |
325 |
mod_add_cmd(&bs_msgtab); |
326 |
mod_add_cmd(&ns_msgtab); |
327 |
mod_add_cmd(&cs_msgtab); |
328 |
mod_add_cmd(&ms_msgtab); |
329 |
mod_add_cmd(&os_msgtab); |
330 |
mod_add_cmd(&ss_msgtab); |
331 |
mod_add_cmd(&hs_msgtab); |
332 |
} |
333 |
|
334 |
static void |
335 |
module_exit(void) |
336 |
{ |
337 |
mod_del_cmd(&botserv_msgtab); |
338 |
mod_del_cmd(&chanserv_msgtab); |
339 |
mod_del_cmd(&memoserv_msgtab); |
340 |
mod_del_cmd(&nickserv_msgtab); |
341 |
mod_del_cmd(&operserv_msgtab); |
342 |
mod_del_cmd(&statserv_msgtab); |
343 |
mod_del_cmd(&hostserv_msgtab); |
344 |
mod_del_cmd(&bs_msgtab); |
345 |
mod_del_cmd(&ns_msgtab); |
346 |
mod_del_cmd(&cs_msgtab); |
347 |
mod_del_cmd(&ms_msgtab); |
348 |
mod_del_cmd(&os_msgtab); |
349 |
mod_del_cmd(&ss_msgtab); |
350 |
mod_del_cmd(&hs_msgtab); |
351 |
} |
352 |
|
353 |
struct module module_entry = |
354 |
{ |
355 |
.node = { NULL, NULL, NULL }, |
356 |
.name = NULL, |
357 |
.version = "$Revision$", |
358 |
.handle = NULL, |
359 |
.modinit = module_init, |
360 |
.modexit = module_exit, |
361 |
.flags = 0 |
362 |
}; |