ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_unresv.c
Revision: 8431
Committed: Tue Mar 27 18:49:15 2018 UTC (7 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 5091 byte(s)
Log Message:
- Stylistic changes

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 2001-2018 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 "list.h"
29 #include "client.h"
30 #include "irc_string.h"
31 #include "ircd.h"
32 #include "conf.h"
33 #include "conf_cluster.h"
34 #include "conf_resv.h"
35 #include "conf_shared.h"
36 #include "numeric.h"
37 #include "log.h"
38 #include "send.h"
39 #include "server_capab.h"
40 #include "parse.h"
41 #include "modules.h"
42 #include "memory.h"
43
44
45 static void
46 resv_remove(struct Client *source_p, const char *mask)
47 {
48 struct ResvItem *resv;
49
50 if ((resv = resv_find(mask, irccmp)) == NULL)
51 {
52 if (IsClient(source_p))
53 sendto_one_notice(source_p, &me, ":No RESV for %s", mask);
54
55 return;
56 }
57
58 if (!resv->in_database)
59 {
60 if (IsClient(source_p))
61 sendto_one_notice(source_p, &me, ":The RESV for %s is in ircd.conf and must be removed by hand",
62 resv->mask);
63 return;
64 }
65
66 resv_delete(resv);
67
68 if (IsClient(source_p))
69 sendto_one_notice(source_p, &me, ":RESV for [%s] is removed", mask);
70
71 sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE,
72 "%s has removed the RESV for: [%s]",
73 get_oper_name(source_p), mask);
74 ilog(LOG_TYPE_RESV, "%s removed RESV for [%s]",
75 get_oper_name(source_p), mask);
76 }
77
78 /*! \brief UNRESV command handler
79 *
80 * \param source_p Pointer to allocated Client struct from which the message
81 * originally comes from. This can be a local or remote client.
82 * \param parc Integer holding the number of supplied arguments.
83 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
84 * pointers.
85 * \note Valid arguments for this command are:
86 * - parv[0] = command
87 * - parv[1] = channel/nick
88 * - parv[2] = "ON"
89 * - parv[3] = target server
90 */
91 static int
92 mo_unresv(struct Client *source_p, int parc, char *parv[])
93 {
94 char *mask = NULL;
95 char *target_server = NULL;
96
97 if (!HasOFlag(source_p, OPER_FLAG_UNRESV))
98 {
99 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "unresv");
100 return 0;
101 }
102
103 if (!parse_aline("UNRESV", source_p, parc, parv, &mask, NULL,
104 NULL, &target_server, NULL))
105 return 0;
106
107 if (target_server)
108 {
109 sendto_match_servs(source_p, target_server, CAPAB_CLUSTER, "UNRESV %s %s",
110 target_server, mask);
111
112 /* Allow ON to apply local unresv as well if it matches */
113 if (match(target_server, me.name))
114 return 0;
115 }
116 else
117 cluster_distribute(source_p, "UNRESV", CAPAB_KLN, CLUSTER_UNRESV, mask);
118
119 resv_remove(source_p, mask);
120 return 0;
121 }
122
123 /*! \brief UNRESV command handler
124 *
125 * \param source_p Pointer to allocated Client struct from which the message
126 * originally comes from. This can be a local or remote client.
127 * \param parc Integer holding the number of supplied arguments.
128 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
129 * pointers.
130 * \note Valid arguments for this command are:
131 * - parv[0] = command
132 * - parv[1] = target server mask
133 * - parv[2] = name mask
134 */
135 static int
136 ms_unresv(struct Client *source_p, int parc, char *parv[])
137 {
138 if (parc != 3 || EmptyString(parv[2]))
139 return 0;
140
141 sendto_match_servs(source_p, parv[1], CAPAB_CLUSTER, "UNRESV %s %s",
142 parv[1], parv[2]);
143
144 if (match(parv[1], me.name))
145 return 0;
146
147 if (HasFlag(source_p, FLAGS_SERVICE) ||
148 shared_find(SHARED_UNRESV, source_p->servptr->name,
149 source_p->username, source_p->host))
150 resv_remove(source_p, parv[2]);
151
152 return 0;
153 }
154
155 static struct Message unresv_msgtab =
156 {
157 .cmd = "UNRESV",
158 .args_min = 2,
159 .args_max = MAXPARA,
160 .handlers[UNREGISTERED_HANDLER] = m_unregistered,
161 .handlers[CLIENT_HANDLER] = m_not_oper,
162 .handlers[SERVER_HANDLER] = ms_unresv,
163 .handlers[ENCAP_HANDLER] = m_ignore,
164 .handlers[OPER_HANDLER] = mo_unresv
165 };
166
167 static void
168 module_init(void)
169 {
170 mod_add_cmd(&unresv_msgtab);
171 }
172
173 static void
174 module_exit(void)
175 {
176 mod_del_cmd(&unresv_msgtab);
177 }
178
179 struct module module_entry =
180 {
181 .version = "$Revision$",
182 .modinit = module_init,
183 .modexit = module_exit,
184 };

Properties

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