ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_unresv.c
Revision: 3355
Committed: Sun Apr 20 14:35:20 2014 UTC (12 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 5065 byte(s)
Log Message:
- svn propset on m_unresv.c

File Contents

# User Rev Content
1 michael 3354 /*
2     * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3     *
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
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_unresv.c
23     * \brief Includes required functions for processing the UNRESV command.
24 michael 3355 * \version $Id$
25 michael 3354 */
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     #include "hash.h"
40    
41    
42     static void
43     remove_resv(struct Client *source_p, const char *name)
44     {
45     struct MaskItem *conf = NULL;
46    
47     if (IsChanPrefix(*name))
48     {
49     if ((conf = find_exact_name_conf(CONF_CRESV, NULL, name, NULL, NULL)) == NULL)
50     {
51     sendto_one_notice(source_p, &me, ":A RESV does not exist for channel: %s", name);
52     return;
53     }
54    
55     if (!IsConfDatabase(conf))
56     {
57     sendto_one_notice(source_p, &me, ":The RESV for channel: %s is in ircd.conf and must be removed by hand.",
58     name);
59     return;
60     }
61    
62     conf_free(conf);
63     sendto_one_notice(source_p, &me, ":The RESV has been removed on channel: %s",
64     name);
65     sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
66     "%s has removed the RESV for channel: %s",
67     get_oper_name(source_p), name);
68     ilog(LOG_TYPE_RESV, "%s removed RESV for [%s]",
69     get_oper_name(source_p), name);
70     }
71     else
72     {
73     if ((conf = find_exact_name_conf(CONF_NRESV, NULL, name, NULL, NULL)) == NULL)
74     {
75     sendto_one_notice(source_p, &me, ":A RESV does not exist for nick: %s",
76     name);
77     return;
78     }
79    
80     if (!IsConfDatabase(conf))
81     {
82     sendto_one_notice(source_p, &me, ":The RESV for nick: %s is in ircd.conf and must be removed by hand.",
83     name);
84     return;
85     }
86    
87     conf_free(conf);
88     sendto_one_notice(source_p, &me, ":The RESV has been removed on nick: %s", name);
89     sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
90     "%s has removed the RESV for nick: %s",
91     get_oper_name(source_p), name);
92     ilog(LOG_TYPE_RESV, "%s removed RESV for [%s]",
93     get_oper_name(source_p), name);
94     }
95     }
96    
97     /* mo_unresv()
98     * parv[0] = command
99     * parv[1] = channel/nick to unforbid
100     */
101     static int
102     mo_unresv(struct Client *source_p, int parc, char *parv[])
103     {
104     char *resv = NULL;
105     char *reason = NULL;
106     char *target_server = NULL;
107    
108     /* UNRESV #channel ON irc.server.com */
109     /* UNRESV kiddie ON irc.server.com */
110     if (parse_aline("UNRESV", source_p, parc, parv, 0, &resv, NULL,
111     NULL, &target_server, &reason) < 0)
112     return 0;
113    
114     if (target_server != NULL)
115     {
116     sendto_match_servs(source_p, target_server, CAP_CLUSTER,
117     "UNRESV %s %s",
118     target_server, resv);
119    
120     /* Allow ON to apply local unresv as well if it matches */
121     if (match(target_server, me.name))
122     return 0;
123     }
124     else
125     cluster_a_line(source_p, "UNRESV", CAP_KLN, SHARED_UNRESV, resv);
126    
127     remove_resv(source_p, resv);
128     return 0;
129     }
130    
131     /* ms_unresv()
132     * parv[0] = command
133     * parv[1] = target server
134     * parv[2] = resv to remove
135     */
136     static int
137     ms_unresv(struct Client *source_p, int parc, char *parv[])
138     {
139     if ((parc != 3) || EmptyString(parv[2]))
140     return 0;
141    
142     sendto_match_servs(source_p, parv[1], CAP_CLUSTER,
143     "UNRESV %s %s",
144     parv[1], parv[2]);
145    
146     if (!IsClient(source_p) || match(parv[1], me.name))
147     return 0;
148    
149     if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
150     source_p->username, source_p->host,
151     SHARED_UNRESV))
152     remove_resv(source_p, parv[2]);
153     return 0;
154     }
155    
156     static struct Message unresv_msgtab =
157     {
158     "UNRESV", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
159     { m_ignore, m_not_oper, ms_unresv, m_ignore, mo_unresv, m_ignore }
160     };
161    
162     static void
163     module_init(void)
164     {
165     mod_add_cmd(&unresv_msgtab);
166     }
167    
168     static void
169     module_exit(void)
170     {
171     mod_del_cmd(&unresv_msgtab);
172     }
173    
174     struct module module_entry =
175     {
176     .node = { NULL, NULL, NULL },
177     .name = NULL,
178 michael 3355 .version = "$Revision$",
179 michael 3354 .handle = NULL,
180     .modinit = module_init,
181     .modexit = module_exit,
182     .flags = 0
183     };

Properties

Name Value
svn:keywords Id Revision