/[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 1181 - (show annotations)
Tue Aug 16 08:05:32 2011 UTC (9 years, 6 months ago) by michael
File MIME type: text/x-chdr
File size: 8580 byte(s)
- set minimum required arguments for services alias message handler to 0,
  otherwise we don't send a ERR_NOTEXTTOSEND

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 "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 static void m_botserv(struct Client *, struct Client *, int, char *[]);
46 static void m_chanserv(struct Client *, struct Client *, int, char *[]);
47 static void m_memoserv(struct Client *, struct Client *, int, char *[]);
48 static void m_nickserv(struct Client *, struct Client *, int, char *[]);
49 static void m_operserv(struct Client *, struct Client *, int, char *[]);
50 static void m_identify(struct Client *, struct Client *, int, char *[]);
51
52 struct Message ms_msgtab = {
53 "MS", 0, 0, 0, 1, MFLG_SLOW, 0,
54 {m_unregistered, m_memoserv, m_ignore, m_ignore, m_memoserv, m_ignore}
55 };
56
57 struct Message ns_msgtab = {
58 "NS", 0, 0, 0, 1, MFLG_SLOW, 0,
59 {m_unregistered, m_nickserv, m_ignore, m_ignore, m_nickserv, m_ignore}
60 };
61
62 struct Message os_msgtab = {
63 "OS", 0, 0, 0, 1, MFLG_SLOW, 0,
64 {m_unregistered, m_operserv, m_ignore, m_ignore, m_operserv, m_ignore}
65 };
66
67 struct Message bs_msgtab = {
68 "BS", 0, 0, 0, 1, MFLG_SLOW, 0,
69 {m_unregistered, m_botserv, m_ignore, m_ignore, m_botserv, m_ignore}
70 };
71
72 struct Message cs_msgtab = {
73 "CS", 0, 0, 0, 1, MFLG_SLOW, 0,
74 {m_unregistered, m_chanserv, m_ignore, m_ignore, m_chanserv, m_ignore}
75 };
76
77 struct Message botserv_msgtab = {
78 "BOTSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
79 {m_unregistered, m_botserv, m_ignore, m_ignore, m_botserv, m_ignore}
80 };
81
82 struct Message chanserv_msgtab = {
83 "CHANSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
84 {m_unregistered, m_chanserv, m_ignore, m_ignore, m_chanserv, m_ignore}
85 };
86
87 struct Message memoserv_msgtab = {
88 "MEMOSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
89 {m_unregistered, m_memoserv, m_ignore, m_ignore, m_memoserv, m_ignore}
90 };
91
92 struct Message nickserv_msgtab = {
93 "NICKSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
94 {m_unregistered, m_nickserv, m_ignore, m_ignore, m_nickserv, m_ignore}
95 };
96
97 struct Message operserv_msgtab = {
98 "OPERSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
99 {m_unregistered, m_operserv, m_ignore, m_ignore, m_operserv, m_ignore}
100 };
101
102 struct Message identify_msgtab = {
103 "IDENTIFY", 0, 0, 0, 1, MFLG_SLOW, 0,
104 {m_unregistered, m_identify, m_ignore, m_ignore, m_identify, m_ignore}
105 };
106
107 void
108 _modinit(void)
109 {
110 mod_add_cmd(&botserv_msgtab);
111 mod_add_cmd(&chanserv_msgtab);
112 mod_add_cmd(&memoserv_msgtab);
113 mod_add_cmd(&nickserv_msgtab);
114 mod_add_cmd(&operserv_msgtab);
115 mod_add_cmd(&identify_msgtab);
116 mod_add_cmd(&bs_msgtab);
117 mod_add_cmd(&ns_msgtab);
118 mod_add_cmd(&cs_msgtab);
119 mod_add_cmd(&ms_msgtab);
120 mod_add_cmd(&os_msgtab);
121 }
122
123 void
124 _moddeinit(void)
125 {
126 mod_del_cmd(&botserv_msgtab);
127 mod_del_cmd(&chanserv_msgtab);
128 mod_del_cmd(&memoserv_msgtab);
129 mod_del_cmd(&nickserv_msgtab);
130 mod_del_cmd(&operserv_msgtab);
131 mod_del_cmd(&identify_msgtab);
132 mod_del_cmd(&bs_msgtab);
133 mod_del_cmd(&ns_msgtab);
134 mod_del_cmd(&cs_msgtab);
135 mod_del_cmd(&ms_msgtab);
136 mod_del_cmd(&os_msgtab);
137 }
138
139 const char *_version = "$Revision$";
140
141 /*
142 * XXX: Each services alias handler is currently ugly copy&paste.
143 * Configureable aliases will get implemented.
144 */
145
146 static void
147 m_nickserv(struct Client *client_p, struct Client *source_p,
148 int parc, char *parv[])
149 {
150 struct Client *target_p = NULL;
151
152 assert(client_p && source_p);
153 assert(client_p == source_p);
154
155 if (EmptyString(parv[1]))
156 {
157 sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
158 me.name, source_p->name);
159 return;
160 }
161
162 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
163 {
164 sendto_one(target_p, ":%s PRIVMSG NickServ@%s :%s",
165 source_p->name, ConfigFileEntry.service_name, parv[1]);
166 return;
167 }
168
169 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
170 me.name, source_p->name, "NickServ");
171 }
172
173 static void
174 m_chanserv(struct Client *client_p, struct Client *source_p,
175 int parc, char *parv[])
176 {
177 struct Client *target_p = NULL;
178
179 assert(client_p && source_p);
180 assert(client_p == source_p);
181
182 if (EmptyString(parv[1]))
183 {
184 sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
185 me.name, source_p->name);
186 return;
187 }
188
189 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
190 {
191 sendto_one(target_p, ":%s PRIVMSG ChanServ@%s :%s",
192 source_p->name, ConfigFileEntry.service_name, parv[1]);
193 return;
194 }
195
196 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
197 me.name, source_p->name, "ChanServ");
198 }
199
200 static void
201 m_memoserv(struct Client *client_p, struct Client *source_p,
202 int parc, char *parv[])
203 {
204 struct Client *target_p = NULL;
205
206 assert(client_p && source_p);
207 assert(client_p == source_p);
208
209 if (EmptyString(parv[1]))
210 {
211 sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
212 me.name, source_p->name);
213 return;
214 }
215
216 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
217 {
218 sendto_one(target_p, ":%s PRIVMSG MemoServ@%s :%s",
219 source_p->name, ConfigFileEntry.service_name, parv[1]);
220 return;
221 }
222
223 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
224 me.name, source_p->name, "MemoServ");
225 }
226
227 static void
228 m_operserv(struct Client *client_p, struct Client *source_p,
229 int parc, char *parv[])
230 {
231 struct Client *target_p = NULL;
232
233 assert(client_p && source_p);
234 assert(client_p == source_p);
235
236 if (EmptyString(parv[1]))
237 {
238 sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
239 me.name, source_p->name);
240 return;
241 }
242
243 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
244 {
245 sendto_one(target_p, ":%s PRIVMSG OperServ@%s :%s",
246 source_p->name, ConfigFileEntry.service_name, parv[1]);
247 return;
248 }
249
250 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
251 me.name, source_p->name, "OperServ");
252 }
253
254 static void
255 m_botserv(struct Client *client_p, struct Client *source_p,
256 int parc, char *parv[])
257 {
258 struct Client *target_p = NULL;
259
260 assert(client_p && source_p);
261 assert(client_p == source_p);
262
263 if (EmptyString(parv[1]))
264 {
265 sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
266 me.name, source_p->name);
267 return;
268 }
269
270 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
271 {
272 sendto_one(target_p, ":%s PRIVMSG BotServ@%s :%s",
273 source_p->name, ConfigFileEntry.service_name, parv[1]);
274 return;
275 }
276
277 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
278 me.name, source_p->name, "BotServ");
279 }
280
281 static void
282 m_identify(struct Client *client_p, struct Client *source_p,
283 int parc, char *parv[])
284 {
285 struct Client *target_p = NULL;
286
287 if (EmptyString(parv[1]))
288 {
289 sendto_one(source_p, form_str(ERR_NOTEXTTOSEND),
290 me.name, source_p->name);
291 return;
292 }
293
294 if (IsChanPrefix(*parv[1]))
295 {
296 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
297 sendto_one(target_p, ":%s PRIVMSG ChanServ@%s :IDENTIFY %s",
298 source_p->name, ConfigFileEntry.service_name, parv[1]);
299 else
300 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
301 me.name, source_p->name, "ChanServ");
302 }
303 else
304 {
305 if ((target_p = hash_find_server(ConfigFileEntry.service_name)))
306 sendto_one(target_p, ":%s PRIVMSG NickServ@%s :IDENTIFY %s",
307 source_p->name, ConfigFileEntry.service_name, parv[1]);
308 else
309 sendto_one(source_p, form_str(ERR_SERVICESDOWN),
310 me.name, source_p->name, "NickServ");
311 }
312 }

Properties

Name Value
svn:keywords Id Revision

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