/[svn]/ircd-hybrid-8/modules/m_services.c
ViewVC logotype

Contents of /ircd-hybrid-8/modules/m_services.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1491 - (show annotations)
Fri Aug 3 16:10:25 2012 UTC (8 years, 1 month ago) by michael
File MIME type: text/x-chdr
File size: 10558 byte(s)
- m_services.c: remove MODULE_FLAG_CORE


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

Properties

Name Value
svn:keywords Id Revision

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28