ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_unresv.c
Revision: 5347
Committed: Sun Jan 11 12:42:20 2015 UTC (10 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 6009 byte(s)
Log Message:
- Update copyright years

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2001-2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 * USA
20 */
21
22 /*! \file m_unresv.c
23 * \brief Includes required functions for processing the UNRESV command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "client.h"
29 #include "ircd.h"
30 #include "irc_string.h"
31 #include "numeric.h"
32 #include "server.h"
33 #include "send.h"
34 #include "parse.h"
35 #include "modules.h"
36 #include "conf.h"
37 #include "log.h"
38 #include "resv.h"
39
40
41 static void
42 remove_resv(struct Client *source_p, const char *name)
43 {
44 struct MaskItem *conf = NULL;
45
46 if (IsChanPrefix(*name))
47 {
48 if ((conf = find_exact_name_conf(CONF_CRESV, NULL, name, NULL, NULL)) == NULL)
49 {
50 if (IsClient(source_p))
51 sendto_one_notice(source_p, &me, ":A RESV does not exist for channel: %s", name);
52
53 return;
54 }
55
56 if (!IsConfDatabase(conf))
57 {
58 if (IsClient(source_p))
59 sendto_one_notice(source_p, &me, ":The RESV for channel: %s is in ircd.conf and must be removed by hand.",
60 name);
61
62 return;
63 }
64
65 conf_free(conf);
66
67 if (IsClient(source_p))
68 sendto_one_notice(source_p, &me, ":The RESV has been removed on channel: %s", name);
69
70 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
71 "%s has removed the RESV for channel: %s",
72 get_oper_name(source_p), name);
73 ilog(LOG_TYPE_RESV, "%s removed RESV for [%s]",
74 get_oper_name(source_p), name);
75 }
76 else
77 {
78 if ((conf = find_exact_name_conf(CONF_NRESV, NULL, name, NULL, NULL)) == NULL)
79 {
80 if (IsClient(source_p))
81 sendto_one_notice(source_p, &me, ":A RESV does not exist for nick: %s", name);
82
83 return;
84 }
85
86 if (!IsConfDatabase(conf))
87 {
88 if (IsClient(source_p))
89 sendto_one_notice(source_p, &me, ":The RESV for nick: %s is in ircd.conf and must be removed by hand.",
90 name);
91
92 return;
93 }
94
95 conf_free(conf);
96
97 if (IsClient(source_p))
98 sendto_one_notice(source_p, &me, ":The RESV has been removed on nick: %s", name);
99
100 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
101 "%s has removed the RESV for nick: %s",
102 get_oper_name(source_p), name);
103 ilog(LOG_TYPE_RESV, "%s removed RESV for [%s]",
104 get_oper_name(source_p), name);
105 }
106 }
107
108 /*! \brief UNRESV command handler
109 *
110 * \param source_p Pointer to allocated Client struct from which the message
111 * originally comes from. This can be a local or remote client.
112 * \param parc Integer holding the number of supplied arguments.
113 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
114 * pointers.
115 * \note Valid arguments for this command are:
116 * - parv[0] = command
117 * - parv[1] = channel/nick
118 * - parv[2] = "ON"
119 * - parv[3] = target server
120 */
121 static int
122 mo_unresv(struct Client *source_p, int parc, char *parv[])
123 {
124 char *resv = NULL;
125 char *reason = NULL;
126 char *target_server = NULL;
127
128 /* UNRESV #channel ON irc.server.com */
129 /* UNRESV kiddie ON irc.server.com */
130 if (parse_aline("UNRESV", source_p, parc, parv, 0, &resv, NULL,
131 NULL, &target_server, &reason) < 0)
132 return 0;
133
134 if (target_server)
135 {
136 sendto_match_servs(source_p, target_server, CAP_CLUSTER, "UNRESV %s %s",
137 target_server, resv);
138
139 /* Allow ON to apply local unresv as well if it matches */
140 if (match(target_server, me.name))
141 return 0;
142 }
143 else
144 cluster_a_line(source_p, "UNRESV", CAP_KLN, SHARED_UNRESV, resv);
145
146 remove_resv(source_p, resv);
147 return 0;
148 }
149
150 /*! \brief UNRESV command handler
151 *
152 * \param source_p Pointer to allocated Client struct from which the message
153 * originally comes from. This can be a local or remote client.
154 * \param parc Integer holding the number of supplied arguments.
155 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
156 * pointers.
157 * \note Valid arguments for this command are:
158 * - parv[0] = command
159 * - parv[1] = target server
160 * - parv[2] = channel/nick
161 */
162 static int
163 ms_unresv(struct Client *source_p, int parc, char *parv[])
164 {
165 if (parc != 3 || EmptyString(parv[2]))
166 return 0;
167
168 sendto_match_servs(source_p, parv[1], CAP_CLUSTER, "UNRESV %s %s",
169 parv[1], parv[2]);
170
171 if (match(parv[1], me.name))
172 return 0;
173
174 if (HasFlag(source_p, FLAGS_SERVICE) ||
175 find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
176 source_p->username, source_p->host,
177 SHARED_UNRESV))
178 remove_resv(source_p, parv[2]);
179 return 0;
180 }
181
182 static struct Message unresv_msgtab =
183 {
184 "UNRESV", NULL, 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
185 { m_ignore, m_not_oper, ms_unresv, m_ignore, mo_unresv, m_ignore }
186 };
187
188 static void
189 module_init(void)
190 {
191 mod_add_cmd(&unresv_msgtab);
192 }
193
194 static void
195 module_exit(void)
196 {
197 mod_del_cmd(&unresv_msgtab);
198 }
199
200 struct module module_entry =
201 {
202 .node = { NULL, NULL, NULL },
203 .name = NULL,
204 .version = "$Revision$",
205 .handle = NULL,
206 .modinit = module_init,
207 .modexit = module_exit,
208 .flags = 0
209 };

Properties

Name Value
svn:keywords Id Revision