1 |
|
/* |
2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
< |
* m_resv.c: Reserves(jupes) a nickname or channel. |
2 |
> |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (C) 2001-2002 Hybrid Development Team |
4 |
> |
* Copyright (c) 2001-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 |
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 |
< |
* $Id$ |
20 |
> |
*/ |
21 |
> |
|
22 |
> |
/*! \file m_resv.c |
23 |
> |
* \brief Includes required functions for processing the RESV/UNRESV command. |
24 |
> |
* \version $Id$ |
25 |
|
*/ |
26 |
|
|
27 |
|
#include "stdinc.h" |
48 |
|
* parv[0] = sender prefix |
49 |
|
* parv[1] = channel/nick to forbid |
50 |
|
*/ |
51 |
< |
static void |
51 |
> |
static int |
52 |
|
mo_resv(struct Client *client_p, struct Client *source_p, |
53 |
|
int parc, char *parv[]) |
54 |
|
{ |
60 |
|
/* RESV #channel ON irc.server.com :abuse |
61 |
|
* RESV kiddie ON irc.server.com :abuse |
62 |
|
*/ |
63 |
< |
if (parse_aline("RESV", source_p, parc, parv, |
64 |
< |
AWILD, &resv, NULL, &tkline_time, &target_server, &reason) < 0) |
65 |
< |
return; |
63 |
> |
if (parse_aline("RESV", source_p, parc, parv, AWILD, &resv, NULL, |
64 |
> |
&tkline_time, &target_server, &reason) < 0) |
65 |
> |
return 0; |
66 |
|
|
67 |
|
if (target_server != NULL) |
68 |
|
{ |
69 |
|
/* if a given expire time is given, ENCAP it */ |
70 |
|
if (tkline_time != 0) |
71 |
|
sendto_match_servs(source_p, target_server, CAP_ENCAP, |
72 |
< |
"ENCAP %s RESV %d %s 0 :%s", |
73 |
< |
target_server, (int)tkline_time, resv, reason); |
72 |
> |
"ENCAP %s RESV %d %s 0 :%s", |
73 |
> |
target_server, (int)tkline_time, resv, reason); |
74 |
|
else |
75 |
|
sendto_match_servs(source_p, target_server, CAP_CLUSTER, |
76 |
< |
"RESV %s %s :%s", |
77 |
< |
target_server, resv, reason); |
76 |
> |
"RESV %s %s :%s", |
77 |
> |
target_server, resv, reason); |
78 |
|
/* Allow ON to apply local resv as well if it matches */ |
79 |
|
if (match(target_server, me.name)) |
80 |
< |
return; |
80 |
> |
return 0; |
81 |
|
} |
82 |
|
else |
83 |
|
{ |
86 |
|
*/ |
87 |
|
if (tkline_time != 0) |
88 |
|
cluster_a_line(source_p, "ENCAP", CAP_ENCAP, SHARED_RESV, |
89 |
< |
"RESV %d %s 0 : %s", (int)tkline_time, resv, reason); |
89 |
> |
"RESV %d %s 0 : %s", (int)tkline_time, resv, reason); |
90 |
|
else |
91 |
|
cluster_a_line(source_p, "RESV", CAP_KLN, SHARED_RESV, |
92 |
< |
"%s : %s", resv, reason); |
92 |
> |
"%s : %s", resv, reason); |
93 |
|
} |
94 |
|
|
95 |
|
parse_resv(source_p, resv, (int)tkline_time, reason); |
96 |
+ |
return 0; |
97 |
|
} |
98 |
|
|
99 |
|
/* me_resv() |
113 |
|
* outputs - NONE |
114 |
|
* side effects - |
115 |
|
*/ |
116 |
< |
static void |
116 |
> |
static int |
117 |
|
me_resv(struct Client *client_p, struct Client *source_p, |
118 |
|
int parc, char *parv[]) |
119 |
|
{ |
120 |
|
if (parc != 5 || !IsClient(source_p)) |
121 |
< |
return; |
121 |
> |
return 0; |
122 |
|
|
123 |
|
parse_resv(source_p, parv[2], atoi(parv[1]), parv[4]); |
124 |
+ |
return 0; |
125 |
|
} |
126 |
|
|
127 |
|
/* ms_resv() |
130 |
|
* parv[2] = channel/nick to resv |
131 |
|
* parv[3] = reason |
132 |
|
*/ |
133 |
< |
static void |
133 |
> |
static int |
134 |
|
ms_resv(struct Client *client_p, struct Client *source_p, |
135 |
|
int parc, char *parv[]) |
136 |
|
{ |
137 |
|
if ((parc != 4) || EmptyString(parv[3])) |
138 |
< |
return; |
138 |
> |
return 0; |
139 |
|
|
140 |
|
sendto_match_servs(source_p, parv[1], CAP_CLUSTER, |
141 |
|
"RESV %s %s :%s", |
142 |
|
parv[1], parv[2], parv[3]); |
143 |
|
|
144 |
|
if (!IsClient(source_p) || match(parv[1], me.name)) |
145 |
< |
return; |
145 |
> |
return 0; |
146 |
|
|
147 |
|
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name, |
148 |
|
source_p->username, source_p->host, |
149 |
|
SHARED_RESV)) |
150 |
|
parse_resv(source_p, parv[2], 0, parv[3]); |
151 |
+ |
return 0; |
152 |
|
} |
153 |
|
|
154 |
|
/* mo_unresv() |
155 |
|
* parv[0] = sender prefix |
156 |
|
* parv[1] = channel/nick to unforbid |
157 |
|
*/ |
158 |
< |
static void |
158 |
> |
static int |
159 |
|
mo_unresv(struct Client *client_p, struct Client *source_p, |
160 |
|
int parc, char *parv[]) |
161 |
|
{ |
165 |
|
|
166 |
|
/* UNRESV #channel ON irc.server.com */ |
167 |
|
/* UNRESV kiddie ON irc.server.com */ |
168 |
< |
if (parse_aline("UNRESV", source_p, parc, parv, |
169 |
< |
0, &resv, NULL, NULL, &target_server, &reason) < 0) |
170 |
< |
return; |
168 |
> |
if (parse_aline("UNRESV", source_p, parc, parv, 0, &resv, NULL, |
169 |
> |
NULL, &target_server, &reason) < 0) |
170 |
> |
return 0; |
171 |
|
|
172 |
|
if (target_server != NULL) |
173 |
|
{ |
177 |
|
|
178 |
|
/* Allow ON to apply local unresv as well if it matches */ |
179 |
|
if (match(target_server, me.name)) |
180 |
< |
return; |
180 |
> |
return 0; |
181 |
|
} |
182 |
< |
else |
182 |
> |
else |
183 |
|
cluster_a_line(source_p, "UNRESV", CAP_KLN, SHARED_UNRESV, resv); |
184 |
|
|
185 |
|
remove_resv(source_p, resv); |
186 |
+ |
return 0; |
187 |
|
} |
188 |
|
|
189 |
|
/* ms_unresv() |
191 |
|
* parv[1] = target server |
192 |
|
* parv[2] = resv to remove |
193 |
|
*/ |
194 |
< |
static void |
194 |
> |
static int |
195 |
|
ms_unresv(struct Client *client_p, struct Client *source_p, |
196 |
|
int parc, char *parv[]) |
197 |
|
{ |
198 |
|
if ((parc != 3) || EmptyString(parv[2])) |
199 |
< |
return; |
199 |
> |
return 0; |
200 |
|
|
201 |
|
sendto_match_servs(source_p, parv[1], CAP_CLUSTER, |
202 |
|
"UNRESV %s %s", |
203 |
|
parv[1], parv[2]); |
204 |
|
|
205 |
|
if (!IsClient(source_p) || match(parv[1], me.name)) |
206 |
< |
return; |
206 |
> |
return 0; |
207 |
|
|
208 |
|
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name, |
209 |
|
source_p->username, source_p->host, |
210 |
|
SHARED_UNRESV)) |
211 |
|
remove_resv(source_p, parv[2]); |
212 |
+ |
return 0; |
213 |
|
} |
214 |
|
|
215 |
|
/* parse_resv() |
231 |
|
if ((conf = create_resv(name, reason, NULL)) == NULL) |
232 |
|
{ |
233 |
|
sendto_one(source_p, |
234 |
< |
":%s NOTICE %s :A RESV has already been placed on channel: %s", |
235 |
< |
me.name, source_p->name, name); |
234 |
> |
":%s NOTICE %s :A RESV has already been placed on channel: %s", |
235 |
> |
me.name, source_p->name, name); |
236 |
|
return; |
237 |
|
} |
238 |
|
|
242 |
|
if (tkline_time != 0) |
243 |
|
{ |
244 |
|
sendto_one(source_p, |
245 |
< |
":%s NOTICE %s :A %d minute %s RESV has been placed on channel: %s", |
246 |
< |
me.name, source_p->name, |
240 |
< |
tkline_time/60, |
245 |
> |
":%s NOTICE %s :A %d minute %s RESV has been placed on channel: %s", |
246 |
> |
me.name, source_p->name, tkline_time/60, |
247 |
|
(MyClient(source_p) ? "local" : "remote"), name); |
248 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
249 |
< |
"%s has placed a %d minute %s RESV on channel: %s [%s]", |
250 |
< |
get_oper_name(source_p), |
251 |
< |
tkline_time/60, |
252 |
< |
(MyClient(source_p) ? "local" : "remote"), |
253 |
< |
conf->name, conf->reason); |
249 |
> |
"%s has placed a %d minute %s RESV on channel: %s [%s]", |
250 |
> |
get_oper_name(source_p), |
251 |
> |
tkline_time/60, |
252 |
> |
(MyClient(source_p) ? "local" : "remote"), |
253 |
> |
conf->name, conf->reason); |
254 |
|
ilog(LOG_TYPE_RESV, "%s added temporary %d min. RESV for [%s] [%s]", |
255 |
< |
source_p->name, (int)tkline_time/60, |
256 |
< |
conf->name, conf->reason); |
255 |
> |
source_p->name, (int)tkline_time/60, |
256 |
> |
conf->name, conf->reason); |
257 |
|
conf->until = CurrentTime + tkline_time; |
258 |
|
} |
259 |
|
else |
260 |
|
{ |
261 |
|
sendto_one(source_p, |
262 |
< |
":%s NOTICE %s :A %s RESV has been placed on channel %s", |
262 |
> |
":%s NOTICE %s :A %s RESV has been placed on channel %s", |
263 |
|
me.name, source_p->name, |
264 |
< |
(MyClient(source_p) ? "local" : "remote"), name); |
264 |
> |
(MyClient(source_p) ? "local" : "remote"), name); |
265 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
266 |
< |
"%s has placed a %s RESV on channel %s : [%s]", |
267 |
< |
get_oper_name(source_p), |
268 |
< |
(MyClient(source_p) ? "local" : "remote"), |
269 |
< |
conf->name, conf->reason); |
266 |
> |
"%s has placed a %s RESV on channel %s : [%s]", |
267 |
> |
get_oper_name(source_p), |
268 |
> |
(MyClient(source_p) ? "local" : "remote"), |
269 |
> |
conf->name, conf->reason); |
270 |
|
} |
271 |
|
} |
272 |
|
else |
301 |
|
if (tkline_time != 0) |
302 |
|
{ |
303 |
|
sendto_one(source_p, |
304 |
< |
":%s NOTICE %s :A %d minute %s RESV has been placed on nick %s : [%s]", |
305 |
< |
me.name, source_p->name, |
300 |
< |
tkline_time/60, |
304 |
> |
":%s NOTICE %s :A %d minute %s RESV has been placed on nick %s : [%s]", |
305 |
> |
me.name, source_p->name, tkline_time/60, |
306 |
|
(MyClient(source_p) ? "local" : "remote"), |
307 |
|
conf->name, conf->reason); |
308 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
309 |
< |
"%s has placed a %d minute %s RESV on nick %s : [%s]", |
310 |
< |
get_oper_name(source_p), |
311 |
< |
tkline_time/60, |
312 |
< |
(MyClient(source_p) ? "local" : "remote"), |
308 |
< |
conf->name, conf->reason); |
309 |
> |
"%s has placed a %d minute %s RESV on nick %s : [%s]", |
310 |
> |
get_oper_name(source_p), tkline_time/60, |
311 |
> |
(MyClient(source_p) ? "local" : "remote"), |
312 |
> |
conf->name, conf->reason); |
313 |
|
ilog(LOG_TYPE_RESV, "%s added temporary %d min. RESV for [%s] [%s]", |
314 |
< |
source_p->name, (int)tkline_time/60, |
311 |
< |
conf->name, conf->reason); |
314 |
> |
source_p->name, (int)tkline_time/60, conf->name, conf->reason); |
315 |
|
conf->until = CurrentTime + tkline_time; |
316 |
|
} |
317 |
|
else |
318 |
|
{ |
319 |
|
sendto_one(source_p, |
320 |
< |
":%s NOTICE %s :A %s RESV has been placed on nick %s : [%s]", |
320 |
> |
":%s NOTICE %s :A %s RESV has been placed on nick %s : [%s]", |
321 |
|
me.name, source_p->name, |
322 |
|
(MyClient(source_p) ? "local" : "remote"), |
323 |
|
conf->name, conf->reason); |
324 |
|
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
325 |
< |
"%s has placed a %s RESV on nick %s : [%s]", |
326 |
< |
get_oper_name(source_p), |
327 |
< |
(MyClient(source_p) ? "local" : "remote"), |
328 |
< |
conf->name, conf->reason); |
325 |
> |
"%s has placed a %s RESV on nick %s : [%s]", |
326 |
> |
get_oper_name(source_p), |
327 |
> |
(MyClient(source_p) ? "local" : "remote"), |
328 |
> |
conf->name, conf->reason); |
329 |
|
} |
330 |
|
} |
331 |
|
} |
391 |
|
} |
392 |
|
} |
393 |
|
|
394 |
< |
static struct Message resv_msgtab = { |
394 |
> |
static struct Message resv_msgtab = |
395 |
> |
{ |
396 |
|
"RESV", 0, 0, 3, MAXPARA, MFLG_SLOW, 0, |
397 |
|
{ m_ignore, m_not_oper, ms_resv, me_resv, mo_resv, m_ignore } |
398 |
|
}; |
399 |
|
|
400 |
< |
static struct Message unresv_msgtab = { |
400 |
> |
static struct Message unresv_msgtab = |
401 |
> |
{ |
402 |
|
"UNRESV", 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
403 |
|
{ m_ignore, m_not_oper, ms_unresv, m_ignore, mo_unresv, m_ignore } |
404 |
|
}; |
417 |
|
mod_del_cmd(&unresv_msgtab); |
418 |
|
} |
419 |
|
|
420 |
< |
struct module module_entry = { |
420 |
> |
struct module module_entry = |
421 |
> |
{ |
422 |
|
.node = { NULL, NULL, NULL }, |
423 |
|
.name = NULL, |
424 |
|
.version = "$Revision$", |