ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/branches/8.2.x/modules/m_unxline.c
Revision: 5775
Committed: Sat Apr 4 17:31:06 2015 UTC (10 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 5357 byte(s)
Log Message:
- Changed some function to void if we don't need a return value
- Have some other functions return saner values

File Contents

# User Rev Content
1 michael 3352 /*
2     * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3     *
4 michael 5346 * Copyright (c) 2003-2015 ircd-hybrid development team
5 michael 3352 *
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 michael 4564 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 michael 3352 * USA
20     */
21    
22     /*! \file m_unxline.c
23     * \brief Includes required functions for processing the UNXLINE command.
24 michael 3353 * \version $Id$
25 michael 3352 */
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 "numeric.h"
34     #include "log.h"
35     #include "send.h"
36     #include "server.h"
37     #include "parse.h"
38     #include "modules.h"
39     #include "conf_db.h"
40     #include "memory.h"
41    
42    
43     /* static int remove_tkline_match(const char *host, const char *user)
44     *
45     * Inputs: gecos
46     * Output: returns YES on success, NO if no tkline removed.
47     * Side effects: Any matching tklines are removed.
48     */
49     static int
50 michael 4671 remove_xline_exact(const char *gecos)
51 michael 3352 {
52 michael 4816 dlink_node *node = NULL;
53 michael 3352
54 michael 4816 DLINK_FOREACH(node, xconf_items.head)
55 michael 3352 {
56 michael 4816 struct MaskItem *conf = node->data;
57 michael 3352
58     if (!IsConfDatabase(conf))
59     continue;
60    
61     if (!irccmp(gecos, conf->name))
62     {
63     conf_free(conf);
64     return 1;
65     }
66     }
67    
68     return 0;
69     }
70    
71     static void
72     remove_xline(struct Client *source_p, const char *gecos)
73     {
74 michael 4671 if (remove_xline_exact(gecos))
75 michael 3352 {
76 michael 4645 if (IsClient(source_p))
77     sendto_one_notice(source_p, &me, ":X-Line for [%s] is removed", gecos);
78 michael 4889
79 michael 3352 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
80     "%s has removed the X-Line for: [%s]",
81     get_oper_name(source_p), gecos);
82     ilog(LOG_TYPE_XLINE, "%s removed X-Line for [%s]",
83     get_oper_name(source_p), gecos);
84     }
85 michael 4645 else if (IsClient(source_p))
86 michael 3352 sendto_one_notice(source_p, &me, ":No X-Line for %s", gecos);
87     }
88    
89 michael 3363 /*! \brief UNXLINE command handler
90 michael 3352 *
91 michael 3363 * \param source_p Pointer to allocated Client struct from which the message
92     * originally comes from. This can be a local or remote client.
93     * \param parc Integer holding the number of supplied arguments.
94     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
95     * pointers.
96     * \note Valid arguments for this command are:
97     * - parv[0] = command
98 michael 3365 * - parv[1] = gecos
99 michael 3363 * - parv[2] = "ON"
100     * - parv[3] = target server
101 michael 3352 */
102     static int
103     mo_unxline(struct Client *source_p, int parc, char *parv[])
104     {
105     char *gecos = NULL;
106     char *target_server = NULL;
107    
108     if (!HasOFlag(source_p, OPER_FLAG_UNXLINE))
109     {
110     sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "unxline");
111     return 0;
112     }
113    
114     /* UNXLINE bill ON irc.server.com */
115 michael 5775 if (!parse_aline("UNXLINE", source_p, parc, parv, 0, &gecos,
116     NULL, NULL, &target_server, NULL))
117 michael 3352 return 0;
118    
119 michael 3368 if (target_server)
120 michael 3352 {
121     sendto_match_servs(source_p, target_server, CAP_CLUSTER,
122     "UNXLINE %s %s", target_server, gecos);
123    
124     /* Allow ON to apply local unxline as well if it matches */
125     if (match(target_server, me.name))
126     return 0;
127     }
128     else
129 michael 4645 cluster_a_line(source_p, "UNXLINE", CAP_CLUSTER, SHARED_UNXLINE, "%s", gecos);
130 michael 3352
131     remove_xline(source_p, gecos);
132     return 0;
133     }
134    
135 michael 3363 /*! \brief UNXLINE command handler
136 michael 3352 *
137 michael 3363 * \param source_p Pointer to allocated Client struct from which the message
138     * originally comes from. This can be a local or remote client.
139     * \param parc Integer holding the number of supplied arguments.
140     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
141     * pointers.
142     * \note Valid arguments for this command are:
143     * - parv[0] = command
144     * - parv[1] = target server
145 michael 3791 * - parv[2] = gecos
146 michael 3352 */
147     static int
148     ms_unxline(struct Client *source_p, int parc, char *parv[])
149     {
150 michael 4645 if (parc != 3 || EmptyString(parv[2]))
151 michael 3352 return 0;
152    
153 michael 3368 sendto_match_servs(source_p, parv[1], CAP_CLUSTER, "UNXLINE %s %s",
154     parv[1], parv[2]);
155 michael 3352
156     if (match(parv[1], me.name))
157     return 0;
158    
159 michael 3368 if (HasFlag(source_p, FLAGS_SERVICE) ||
160     find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
161 michael 3352 source_p->username, source_p->host,
162     SHARED_UNXLINE))
163     remove_xline(source_p, parv[2]);
164     return 0;
165     }
166    
167     static struct Message unxline_msgtab =
168     {
169 michael 4546 "UNXLINE", NULL, 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
170 michael 3352 { m_unregistered, m_not_oper, ms_unxline, m_ignore, mo_unxline, m_ignore }
171     };
172    
173     static void
174     module_init(void)
175     {
176     mod_add_cmd(&unxline_msgtab);
177     }
178    
179     static void
180     module_exit(void)
181     {
182     mod_del_cmd(&unxline_msgtab);
183     }
184    
185     struct module module_entry =
186     {
187     .node = { NULL, NULL, NULL },
188     .name = NULL,
189 michael 3353 .version = "$Revision$",
190 michael 3352 .handle = NULL,
191     .modinit = module_init,
192     .modexit = module_exit,
193     .flags = 0
194     };

Properties

Name Value
svn:keywords Id Revision