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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1230 - (hide annotations)
Thu Sep 22 19:41:19 2011 UTC (9 years, 5 months ago) by michael
File MIME type: text/x-chdr
File size: 10614 byte(s)
- cleanup module loader. Make module api more flexible

1 michael 1168 /*
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 "handlers.h"
30     #include "client.h"
31     #include "ircd.h"
32     #include "channel_mode.h"
33     #include "numeric.h"
34     #include "s_conf.h"
35     #include "s_serv.h"
36     #include "send.h"
37     #include "msg.h"
38     #include "parse.h"
39     #include "modules.h"
40     #include "irc_string.h"
41     #include "s_user.h"
42     #include "hash.h"
43    
44    
45     /*
46     * XXX: Each services alias handler is currently ugly copy&paste.
47     * Configureable aliases will get implemented.
48     */
49    
50     static void
51     m_nickserv(struct Client *client_p, struct Client *source_p,
52     int parc, char *parv[])
53     {
54     struct Client *target_p = NULL;
55    
56     assert(client_p && source_p);
57     assert(client_p == source_p);
58    
59 michael 1178 if (EmptyString(parv[1]))
60 michael 1168 {
61     sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
62     me.name, source_p->name);
63     return;
64     }
65    
66 michael 1169 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
67 michael 1168 {
68     sendto_one(target_p, ":%s PRIVMSG NickServ@%s :%s",
69     source_p->name, ConfigFileEntry.service_name, parv[1]);
70     return;
71     }
72    
73     sendto_one(source_p, form_str(ERR_SERVICESDOWN),
74     me.name, source_p->name, "NickServ");
75     }
76    
77     static void
78     m_chanserv(struct Client *client_p, struct Client *source_p,
79     int parc, char *parv[])
80     {
81     struct Client *target_p = NULL;
82    
83     assert(client_p && source_p);
84     assert(client_p == source_p);
85    
86 michael 1178 if (EmptyString(parv[1]))
87 michael 1168 {
88     sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
89     me.name, source_p->name);
90     return;
91     }
92    
93 michael 1169 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
94 michael 1168 {
95     sendto_one(target_p, ":%s PRIVMSG ChanServ@%s :%s",
96     source_p->name, ConfigFileEntry.service_name, parv[1]);
97     return;
98     }
99    
100     sendto_one(source_p, form_str(ERR_SERVICESDOWN),
101     me.name, source_p->name, "ChanServ");
102     }
103    
104     static void
105     m_memoserv(struct Client *client_p, struct Client *source_p,
106     int parc, char *parv[])
107     {
108     struct Client *target_p = NULL;
109    
110     assert(client_p && source_p);
111     assert(client_p == source_p);
112    
113 michael 1178 if (EmptyString(parv[1]))
114 michael 1168 {
115     sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
116     me.name, source_p->name);
117     return;
118     }
119    
120 michael 1169 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
121 michael 1168 {
122     sendto_one(target_p, ":%s PRIVMSG MemoServ@%s :%s",
123     source_p->name, ConfigFileEntry.service_name, parv[1]);
124     return;
125     }
126    
127     sendto_one(source_p, form_str(ERR_SERVICESDOWN),
128     me.name, source_p->name, "MemoServ");
129     }
130    
131     static void
132     m_operserv(struct Client *client_p, struct Client *source_p,
133     int parc, char *parv[])
134     {
135     struct Client *target_p = NULL;
136    
137     assert(client_p && source_p);
138     assert(client_p == source_p);
139    
140 michael 1178 if (EmptyString(parv[1]))
141 michael 1168 {
142     sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
143     me.name, source_p->name);
144     return;
145     }
146    
147 michael 1169 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
148 michael 1168 {
149     sendto_one(target_p, ":%s PRIVMSG OperServ@%s :%s",
150     source_p->name, ConfigFileEntry.service_name, parv[1]);
151     return;
152     }
153    
154     sendto_one(source_p, form_str(ERR_SERVICESDOWN),
155     me.name, source_p->name, "OperServ");
156     }
157    
158     static void
159 michael 1218 m_statserv(struct Client *client_p, struct Client *source_p,
160     int parc, char *parv[])
161     {
162     struct Client *target_p = NULL;
163    
164     assert(client_p && source_p);
165     assert(client_p == source_p);
166    
167     if (EmptyString(parv[1]))
168     {
169     sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
170     me.name, source_p->name);
171     return;
172     }
173    
174     if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
175     {
176     sendto_one(target_p, ":%s PRIVMSG StatServ@%s :%s",
177     source_p->name, ConfigFileEntry.service_name, parv[1]);
178     return;
179     }
180    
181     sendto_one(source_p, form_str(ERR_SERVICESDOWN),
182     me.name, source_p->name, "StatServ");
183     }
184    
185     static void
186     m_helpserv(struct Client *client_p, struct Client *source_p,
187     int parc, char *parv[])
188     {
189     struct Client *target_p = NULL;
190    
191     assert(client_p && source_p);
192     assert(client_p == source_p);
193    
194     if (EmptyString(parv[1]))
195     {
196     sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
197     me.name, source_p->name);
198     return;
199     }
200    
201     if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
202     {
203     sendto_one(target_p, ":%s PRIVMSG HelpServ@%s :%s",
204     source_p->name, ConfigFileEntry.service_name, parv[1]);
205     return;
206     }
207    
208     sendto_one(source_p, form_str(ERR_SERVICESDOWN),
209     me.name, source_p->name, "HelpServ");
210     }
211    
212     static void
213 michael 1168 m_botserv(struct Client *client_p, struct Client *source_p,
214     int parc, char *parv[])
215     {
216     struct Client *target_p = NULL;
217    
218     assert(client_p && source_p);
219     assert(client_p == source_p);
220    
221 michael 1178 if (EmptyString(parv[1]))
222 michael 1168 {
223     sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
224     me.name, source_p->name);
225     return;
226     }
227    
228 michael 1169 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
229 michael 1168 {
230     sendto_one(target_p, ":%s PRIVMSG BotServ@%s :%s",
231     source_p->name, ConfigFileEntry.service_name, parv[1]);
232     return;
233     }
234    
235     sendto_one(source_p, form_str(ERR_SERVICESDOWN),
236     me.name, source_p->name, "BotServ");
237     }
238    
239     static void
240     m_identify(struct Client *client_p, struct Client *source_p,
241     int parc, char *parv[])
242     {
243     struct Client *target_p = NULL;
244    
245 michael 1178 if (EmptyString(parv[1]))
246 michael 1168 {
247     sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
248     me.name, source_p->name);
249     return;
250     }
251    
252     if (IsChanPrefix(*parv[1]))
253     {
254 michael 1169 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
255 michael 1168 sendto_one(target_p, ":%s PRIVMSG ChanServ@%s :IDENTIFY %s",
256     source_p->name, ConfigFileEntry.service_name, parv[1]);
257     else
258     sendto_one(source_p, form_str(ERR_SERVICESDOWN),
259     me.name, source_p->name, "ChanServ");
260     }
261     else
262     {
263 michael 1169 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
264 michael 1168 sendto_one(target_p, ":%s PRIVMSG NickServ@%s :IDENTIFY %s",
265     source_p->name, ConfigFileEntry.service_name, parv[1]);
266     else
267     sendto_one(source_p, form_str(ERR_SERVICESDOWN),
268     me.name, source_p->name, "NickServ");
269     }
270     }
271 michael 1230
272     static struct Message ms_msgtab = {
273     "MS", 0, 0, 0, 1, MFLG_SLOW, 0,
274     {m_unregistered, m_memoserv, m_ignore, m_ignore, m_memoserv, m_ignore}
275     };
276    
277     static struct Message ns_msgtab = {
278     "NS", 0, 0, 0, 1, MFLG_SLOW, 0,
279     {m_unregistered, m_nickserv, m_ignore, m_ignore, m_nickserv, m_ignore}
280     };
281    
282     static struct Message os_msgtab = {
283     "OS", 0, 0, 0, 1, MFLG_SLOW, 0,
284     {m_unregistered, m_operserv, m_ignore, m_ignore, m_operserv, m_ignore}
285     };
286    
287     static struct Message bs_msgtab = {
288     "BS", 0, 0, 0, 1, MFLG_SLOW, 0,
289     {m_unregistered, m_botserv, m_ignore, m_ignore, m_botserv, m_ignore}
290     };
291    
292     static struct Message cs_msgtab = {
293     "CS", 0, 0, 0, 1, MFLG_SLOW, 0,
294     {m_unregistered, m_chanserv, m_ignore, m_ignore, m_chanserv, m_ignore}
295     };
296    
297     static struct Message ss_msgtab = {
298     "SS", 0, 0, 0, 1, MFLG_SLOW, 0,
299     {m_unregistered, m_statserv, m_ignore, m_ignore, m_statserv, m_ignore}
300     };
301    
302     static struct Message hs_msgtab = {
303     "HS", 0, 0, 0, 1, MFLG_SLOW, 0,
304     {m_unregistered, m_helpserv, m_ignore, m_ignore, m_helpserv, m_ignore}
305     };
306    
307     static struct Message botserv_msgtab = {
308     "BOTSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
309     {m_unregistered, m_botserv, m_ignore, m_ignore, m_botserv, m_ignore}
310     };
311    
312     static struct Message chanserv_msgtab = {
313     "CHANSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
314     {m_unregistered, m_chanserv, m_ignore, m_ignore, m_chanserv, m_ignore}
315     };
316    
317     static struct Message memoserv_msgtab = {
318     "MEMOSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
319     {m_unregistered, m_memoserv, m_ignore, m_ignore, m_memoserv, m_ignore}
320     };
321    
322     static struct Message nickserv_msgtab = {
323     "NICKSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
324     {m_unregistered, m_nickserv, m_ignore, m_ignore, m_nickserv, m_ignore}
325     };
326    
327     static struct Message operserv_msgtab = {
328     "OPERSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
329     {m_unregistered, m_operserv, m_ignore, m_ignore, m_operserv, m_ignore}
330     };
331    
332     static struct Message statserv_msgtab = {
333     "STATSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
334     {m_unregistered, m_statserv, m_ignore, m_ignore, m_statserv, m_ignore}
335     };
336    
337     static struct Message helpserv_msgtab = {
338     "HELPSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
339     {m_unregistered, m_helpserv, m_ignore, m_ignore, m_helpserv, m_ignore}
340     };
341    
342     static struct Message identify_msgtab = {
343     "IDENTIFY", 0, 0, 0, 1, MFLG_SLOW, 0,
344     {m_unregistered, m_identify, m_ignore, m_ignore, m_identify, m_ignore}
345     };
346    
347     static void
348     module_init(void)
349     {
350     mod_add_cmd(&botserv_msgtab);
351     mod_add_cmd(&chanserv_msgtab);
352     mod_add_cmd(&memoserv_msgtab);
353     mod_add_cmd(&nickserv_msgtab);
354     mod_add_cmd(&operserv_msgtab);
355     mod_add_cmd(&statserv_msgtab);
356     mod_add_cmd(&helpserv_msgtab);
357     mod_add_cmd(&identify_msgtab);
358     mod_add_cmd(&bs_msgtab);
359     mod_add_cmd(&ns_msgtab);
360     mod_add_cmd(&cs_msgtab);
361     mod_add_cmd(&ms_msgtab);
362     mod_add_cmd(&os_msgtab);
363     mod_add_cmd(&ss_msgtab);
364     mod_add_cmd(&hs_msgtab);
365     }
366    
367     static void
368     module_exit(void)
369     {
370     mod_del_cmd(&botserv_msgtab);
371     mod_del_cmd(&chanserv_msgtab);
372     mod_del_cmd(&memoserv_msgtab);
373     mod_del_cmd(&nickserv_msgtab);
374     mod_del_cmd(&operserv_msgtab);
375     mod_del_cmd(&statserv_msgtab);
376     mod_del_cmd(&helpserv_msgtab);
377     mod_del_cmd(&identify_msgtab);
378     mod_del_cmd(&bs_msgtab);
379     mod_del_cmd(&ns_msgtab);
380     mod_del_cmd(&cs_msgtab);
381     mod_del_cmd(&ms_msgtab);
382     mod_del_cmd(&os_msgtab);
383     mod_del_cmd(&ss_msgtab);
384     mod_del_cmd(&hs_msgtab);
385     }
386    
387     struct module module_entry = {
388     .node = { NULL, NULL, NULL },
389     .name = NULL,
390     .version = "$Revision$",
391     .handle = NULL,
392     .modinit = module_init,
393     .modexit = module_exit,
394     .flags = MODULE_FLAG_CORE
395     };

Properties

Name Value
svn:keywords Id Revision

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