summaryrefslogtreecommitdiff
path: root/modules/m_xline.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/m_xline.c')
-rw-r--r--modules/m_xline.c113
1 files changed, 60 insertions, 53 deletions
diff --git a/modules/m_xline.c b/modules/m_xline.c
index 8f04b24..3fea582 100644
--- a/modules/m_xline.c
+++ b/modules/m_xline.c
@@ -1,8 +1,7 @@
/*
- * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
- * m_xline.c: xlines an user.
+ * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
*
- * Copyright (C) 2002 by the past and present ircd coders, and others.
+ * Copyright (c) 2003-2014 ircd-hybrid development team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,8 +17,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
- *
- * $Id$
+ */
+
+/*! \file m_xline.c
+ * \brief Includes required functions for processing the XLINE/UNXLINE command.
+ * \version $Id$
*/
#include "stdinc.h"
@@ -62,7 +64,7 @@ static void relay_xline(struct Client *, char *[]);
* side effects - x line is added
*
*/
-static void
+static int
mo_xline(struct Client *client_p, struct Client *source_p,
int parc, char *parv[])
{
@@ -74,9 +76,9 @@ mo_xline(struct Client *client_p, struct Client *source_p,
if (!HasOFlag(source_p, OPER_FLAG_X))
{
- sendto_one(source_p, form_str(ERR_NOPRIVS),
- me.name, source_p->name, "xline");
- return;
+ sendto_one(source_p, form_str(ERR_NOPRIVS), me.name,
+ source_p->name, "xline");
+ return 0;
}
/*
@@ -85,47 +87,47 @@ mo_xline(struct Client *client_p, struct Client *source_p,
*/
if (parse_aline("XLINE", source_p, parc, parv, AWILD, &gecos, NULL,
&tkline_time, &target_server, &reason) < 0)
- return;
+ return 0;
if (target_server != NULL)
{
/* if a given expire time is given, ENCAP it */
if (tkline_time != 0)
sendto_match_servs(source_p, target_server, CAP_ENCAP,
- "ENCAP %s XLINE %d %s 0 :%s",
- target_server, (int)tkline_time, gecos, reason);
+ "ENCAP %s XLINE %d %s 0 :%s",
+ target_server, (int)tkline_time, gecos, reason);
else
sendto_match_servs(source_p, target_server, CAP_CLUSTER,
- "XLINE %s %s %d :%s",
- target_server, gecos, (int)tkline_time, reason);
+ "XLINE %s %s %d :%s",
+ target_server, gecos, (int)tkline_time, reason);
/* Allow ON to apply local xline as well if it matches */
if (match(target_server, me.name))
- return;
+ return 0;
}
- else
+ else
{
if (tkline_time != 0)
cluster_a_line(source_p, "ENCAP", CAP_ENCAP, SHARED_XLINE,
- "XLINE %d %s 0 :%s", (int)tkline_time, gecos, reason);
+ "XLINE %d %s 0 :%s", (int)tkline_time, gecos, reason);
else
cluster_a_line(source_p, "XLINE", CAP_KLN, SHARED_XLINE,
- "%s 0 :%s", gecos, reason);
+ "%s 0 :%s", gecos, reason);
}
if (!valid_xline(source_p, gecos, reason, 0))
- return;
+ return 0;
- if ((conf = find_matching_name_conf(CONF_XLINE, gecos,
- NULL, NULL, 0)) != NULL)
+ if ((conf = find_matching_name_conf(CONF_XLINE, gecos, NULL, NULL, 0)))
{
sendto_one(source_p, ":%s NOTICE %s :[%s] already X-Lined by [%s] - %s",
me.name, source_p->name, gecos,
conf->name, conf->reason);
- return;
+ return 0;
}
write_xline(source_p, gecos, reason, tkline_time);
+ return 0;
}
/* ms_xline()
@@ -135,20 +137,21 @@ mo_xline(struct Client *client_p, struct Client *source_p,
* outputs - none
* side effects - propagates xline, applies it if we are a target
*/
-static void
+static int
ms_xline(struct Client *client_p, struct Client *source_p,
int parc, char *parv[])
{
if (parc != 5 || EmptyString(parv[4]))
- return;
+ return 0;
if (!IsClient(source_p))
- return;
+ return 0;
if (!valid_xline(source_p, parv[2], parv[4], 0))
- return;
+ return 0;
relay_xline(source_p, parv);
+ return 0;
}
/* me_xline()
@@ -165,16 +168,17 @@ ms_xline(struct Client *client_p, struct Client *source_p,
* parv[5] = reason
*
* outputs - none
- * side effects -
+ * side effects -
*/
-static void
+static int
me_xline(struct Client *client_p, struct Client *source_p,
int parc, char *parv[])
{
if (!IsClient(source_p) || parc != 5)
- return;
+ return 0;
relay_xline(source_p, parv);
+ return 0;
}
static void
@@ -196,8 +200,7 @@ relay_xline(struct Client *source_p, char *parv[])
source_p->username, source_p->host,
SHARED_XLINE))
{
- if ((conf = find_matching_name_conf(CONF_XLINE, parv[2],
- NULL, NULL, 0)) != NULL)
+ if ((conf = find_matching_name_conf(CONF_XLINE, parv[2], NULL, NULL, 0)))
{
sendto_one(source_p, ":%s NOTICE %s :[%s] already X-Lined by [%s] - %s",
ID_or_name(&me, source_p->from),
@@ -219,7 +222,7 @@ relay_xline(struct Client *source_p, char *parv[])
* output -
* side effects - removes a xline
*/
-static void
+static int
mo_unxline(struct Client *client_p, struct Client *source_p,
int parc, char *parv[])
{
@@ -228,15 +231,15 @@ mo_unxline(struct Client *client_p, struct Client *source_p,
if (!HasOFlag(source_p, OPER_FLAG_X))
{
- sendto_one(source_p, form_str(ERR_NOPRIVS),
- me.name, source_p->name, "unxline");
- return;
+ sendto_one(source_p, form_str(ERR_NOPRIVS), me.name,
+ source_p->name, "xline");
+ return 0;
}
/* UNXLINE bill ON irc.server.com */
if (parse_aline("UNXLINE", source_p, parc, parv, 0, &gecos,
NULL, NULL, &target_server, NULL) < 0)
- return;
+ return 0;
if (target_server != NULL)
{
@@ -245,13 +248,14 @@ mo_unxline(struct Client *client_p, struct Client *source_p,
/* Allow ON to apply local unxline as well if it matches */
if (match(target_server, me.name))
- return;
+ return 0;
}
else
cluster_a_line(source_p, "UNXLINE", CAP_CLUSTER, SHARED_UNXLINE,
- "%s", gecos);
+ "%s", gecos);
remove_xline(source_p, gecos);
+ return 0;
}
/* ms_unxline()
@@ -260,26 +264,27 @@ mo_unxline(struct Client *client_p, struct Client *source_p,
* outputs - none
* side effects - propagates unxline, applies it if we are a target
*/
-static void
+static int
ms_unxline(struct Client *client_p, struct Client *source_p,
int parc, char *parv[])
{
if (parc != 3)
- return;
+ return 0;
if (!IsClient(source_p) || EmptyString(parv[2]))
- return;
+ return 0;
sendto_match_servs(source_p, parv[1], CAP_CLUSTER,
"UNXLINE %s %s", parv[1], parv[2]);
if (match(parv[1], me.name))
- return;
+ return 0;
if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
source_p->username, source_p->host,
SHARED_UNXLINE))
remove_xline(source_p, parv[2]);
+ return 0;
}
/* valid_xline()
@@ -319,7 +324,7 @@ valid_xline(struct Client *source_p, char *gecos, char *reason, int warn)
*/
static void
write_xline(struct Client *source_p, char *gecos, char *reason,
- time_t tkline_time)
+ time_t tkline_time)
{
struct MaskItem *conf = conf_make(CONF_XLINE);
@@ -333,15 +338,14 @@ write_xline(struct Client *source_p, char *gecos, char *reason,
if (tkline_time != 0)
{
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "%s added temporary %d min. X-Line for [%s] [%s]",
- get_oper_name(source_p), (int)tkline_time/60,
- conf->name, conf->reason);
+ "%s added temporary %d min. X-Line for [%s] [%s]",
+ get_oper_name(source_p), (int)tkline_time/60,
+ conf->name, conf->reason);
sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. X-Line [%s]",
- MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
- source_p->name, (int)tkline_time/60, conf->name);
+ MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
+ source_p->name, (int)tkline_time/60, conf->name);
ilog(LOG_TYPE_XLINE, "%s added temporary %d min. X-Line for [%s] [%s]",
- source_p->name, (int)tkline_time/60,
- conf->name, conf->reason);
+ source_p->name, (int)tkline_time/60, conf->name, conf->reason);
conf->until = CurrentTime + tkline_time;
}
else
@@ -408,12 +412,14 @@ remove_xline_match(const char *gecos)
return 0;
}
-static struct Message xline_msgtab = {
+static struct Message xline_msgtab =
+{
"XLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
{ m_unregistered, m_not_oper, ms_xline, me_xline, mo_xline, m_ignore }
};
-static struct Message unxline_msgtab = {
+static struct Message unxline_msgtab =
+{
"UNXLINE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
{ m_unregistered, m_not_oper, ms_unxline, m_ignore, mo_unxline, m_ignore }
};
@@ -432,7 +438,8 @@ module_exit(void)
mod_del_cmd(&unxline_msgtab);
}
-struct module module_entry = {
+struct module module_entry =
+{
.node = { NULL, NULL, NULL },
.name = NULL,
.version = "$Revision$",