ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_services.c
Revision: 4340
Committed: Sat Aug 2 16:53:22 2014 UTC (11 years ago) by michael
Content type: text/x-csrc
File size: 6249 byte(s)
Log Message:
- Renamed structures to meet code conventions

File Contents

# Content
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 "server.h"
34 #include "send.h"
35 #include "parse.h"
36 #include "modules.h"
37 #include "irc_string.h"
38 #include "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 void
48 do_service_alias(struct Client *source_p, const char *name, const char *msg)
49 {
50 struct Client *target_p = NULL;
51 struct Client *server_p = NULL;
52
53 if (EmptyString(msg))
54 {
55 sendto_one_numeric(source_p, &me, ERR_NOTEXTTOSEND);
56 return;
57 }
58
59 target_p = find_person(source_p, name);
60 server_p = hash_find_server(ConfigGeneral.service_name);
61
62 if (target_p && server_p && (target_p->servptr == server_p))
63 {
64 sendto_one(target_p, ":%s PRIVMSG %s :%s",
65 source_p->id, target_p->id, msg);
66 return;
67 }
68
69 sendto_one_numeric(source_p, &me, ERR_SERVICESDOWN, name);
70 }
71
72 static int
73 m_nickserv(struct Client *source_p, int parc, char *parv[])
74 {
75 do_service_alias(source_p, "NickServ", parv[1]);
76 return 0;
77 }
78
79 static int
80 m_chanserv(struct Client *source_p, int parc, char *parv[])
81 {
82 do_service_alias(source_p, "ChanServ", parv[1]);
83 return 0;
84 }
85
86 static int
87 m_memoserv(struct Client *source_p, int parc, char *parv[])
88 {
89 do_service_alias(source_p, "MemoServ", parv[1]);
90 return 0;
91 }
92
93 static int
94 m_operserv(struct Client *source_p, int parc, char *parv[])
95 {
96 do_service_alias(source_p, "OperServ", parv[1]);
97 return 0;
98 }
99
100 static int
101 m_statserv(struct Client *source_p, int parc, char *parv[])
102 {
103 do_service_alias(source_p, "StatServ", parv[1]);
104 return 0;
105 }
106
107 static int
108 m_hostserv(struct Client *source_p, int parc, char *parv[])
109 {
110 do_service_alias(source_p, "HostServ", parv[1]);
111 return 0;
112 }
113
114 static int
115 m_botserv(struct Client *source_p, int parc, char *parv[])
116 {
117 do_service_alias(source_p, "BotServ", parv[1]);
118 return 0;
119 }
120
121
122 static struct Message ms_msgtab =
123 {
124 "MS", 0, 0, 0, 1, MFLG_SLOW, 0,
125 { m_unregistered, m_memoserv, m_ignore, m_ignore, m_memoserv, m_ignore }
126 };
127
128 static struct Message ns_msgtab =
129 {
130 "NS", 0, 0, 0, 1, MFLG_SLOW, 0,
131 { m_unregistered, m_nickserv, m_ignore, m_ignore, m_nickserv, m_ignore }
132 };
133
134 static struct Message os_msgtab =
135 {
136 "OS", 0, 0, 0, 1, MFLG_SLOW, 0,
137 { m_unregistered, m_operserv, m_ignore, m_ignore, m_operserv, m_ignore }
138 };
139
140 static struct Message bs_msgtab =
141 {
142 "BS", 0, 0, 0, 1, MFLG_SLOW, 0,
143 { m_unregistered, m_botserv, m_ignore, m_ignore, m_botserv, m_ignore }
144 };
145
146 static struct Message cs_msgtab =
147 {
148 "CS", 0, 0, 0, 1, MFLG_SLOW, 0,
149 { m_unregistered, m_chanserv, m_ignore, m_ignore, m_chanserv, m_ignore }
150 };
151
152 static struct Message ss_msgtab =
153 {
154 "SS", 0, 0, 0, 1, MFLG_SLOW, 0,
155 { m_unregistered, m_statserv, m_ignore, m_ignore, m_statserv, m_ignore }
156 };
157
158 static struct Message hs_msgtab =
159 {
160 "HS", 0, 0, 0, 1, MFLG_SLOW, 0,
161 { m_unregistered, m_hostserv, m_ignore, m_ignore, m_hostserv, m_ignore }
162 };
163
164 static struct Message botserv_msgtab =
165 {
166 "BOTSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
167 { m_unregistered, m_botserv, m_ignore, m_ignore, m_botserv, m_ignore }
168 };
169
170 static struct Message chanserv_msgtab =
171 {
172 "CHANSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
173 { m_unregistered, m_chanserv, m_ignore, m_ignore, m_chanserv, m_ignore }
174 };
175
176 static struct Message memoserv_msgtab =
177 {
178 "MEMOSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
179 { m_unregistered, m_memoserv, m_ignore, m_ignore, m_memoserv, m_ignore }
180 };
181
182 static struct Message nickserv_msgtab =
183 {
184 "NICKSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
185 { m_unregistered, m_nickserv, m_ignore, m_ignore, m_nickserv, m_ignore }
186 };
187
188 static struct Message operserv_msgtab =
189 {
190 "OPERSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
191 { m_unregistered, m_operserv, m_ignore, m_ignore, m_operserv, m_ignore }
192 };
193
194 static struct Message statserv_msgtab =
195 {
196 "STATSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
197 { m_unregistered, m_statserv, m_ignore, m_ignore, m_statserv, m_ignore }
198 };
199
200 static struct Message hostserv_msgtab =
201 {
202 "HOSTSERV", 0, 0, 0, 1, MFLG_SLOW, 0,
203 { m_unregistered, m_hostserv, m_ignore, m_ignore, m_hostserv, m_ignore }
204 };
205
206
207 static void
208 module_init(void)
209 {
210 mod_add_cmd(&botserv_msgtab);
211 mod_add_cmd(&chanserv_msgtab);
212 mod_add_cmd(&memoserv_msgtab);
213 mod_add_cmd(&nickserv_msgtab);
214 mod_add_cmd(&operserv_msgtab);
215 mod_add_cmd(&statserv_msgtab);
216 mod_add_cmd(&hostserv_msgtab);
217 mod_add_cmd(&bs_msgtab);
218 mod_add_cmd(&ns_msgtab);
219 mod_add_cmd(&cs_msgtab);
220 mod_add_cmd(&ms_msgtab);
221 mod_add_cmd(&os_msgtab);
222 mod_add_cmd(&ss_msgtab);
223 mod_add_cmd(&hs_msgtab);
224 }
225
226 static void
227 module_exit(void)
228 {
229 mod_del_cmd(&botserv_msgtab);
230 mod_del_cmd(&chanserv_msgtab);
231 mod_del_cmd(&memoserv_msgtab);
232 mod_del_cmd(&nickserv_msgtab);
233 mod_del_cmd(&operserv_msgtab);
234 mod_del_cmd(&statserv_msgtab);
235 mod_del_cmd(&hostserv_msgtab);
236 mod_del_cmd(&bs_msgtab);
237 mod_del_cmd(&ns_msgtab);
238 mod_del_cmd(&cs_msgtab);
239 mod_del_cmd(&ms_msgtab);
240 mod_del_cmd(&os_msgtab);
241 mod_del_cmd(&ss_msgtab);
242 mod_del_cmd(&hs_msgtab);
243 }
244
245 struct module module_entry =
246 {
247 .node = { NULL, NULL, NULL },
248 .name = NULL,
249 .version = "$Revision$",
250 .handle = NULL,
251 .modinit = module_init,
252 .modexit = module_exit,
253 .flags = 0
254 };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision