1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1999 Bahamut development team. |
5 |
* Copyright (c) 2013-2014 ircd-hybrid development team |
6 |
* |
7 |
* This program is free software; you can redistribute it and/or modify |
8 |
* it under the terms of the GNU General Public License as published by |
9 |
* the Free Software Foundation; either version 2 of the License, or |
10 |
* (at your option) any later version. |
11 |
* |
12 |
* This program is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with this program; if not, write to the Free Software |
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
20 |
* USA |
21 |
*/ |
22 |
|
23 |
/*! \file m_svskill.c |
24 |
* \brief Includes required functions for processing the SVSKILL command. |
25 |
* \version $Id$ |
26 |
*/ |
27 |
|
28 |
#include "stdinc.h" |
29 |
#include "client.h" |
30 |
#include "ircd.h" |
31 |
#include "server.h" |
32 |
#include "send.h" |
33 |
#include "parse.h" |
34 |
#include "modules.h" |
35 |
#include "irc_string.h" |
36 |
#include "conf.h" |
37 |
|
38 |
|
39 |
/*! \brief SVSKILL command handler |
40 |
* |
41 |
* \param source_p Pointer to allocated Client struct from which the message |
42 |
* originally comes from. This can be a local or remote client. |
43 |
* \param parc Integer holding the number of supplied arguments. |
44 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
45 |
* pointers. |
46 |
* \note Valid arguments for this command are: |
47 |
* - parv[0] = command |
48 |
* - parv[1] = nickname |
49 |
* - parv[2] = timestamp |
50 |
* - parv[3] = kill message |
51 |
*/ |
52 |
static int |
53 |
ms_svskill(struct Client *source_p, int parc, char *parv[]) |
54 |
{ |
55 |
struct Client *target_p = NULL; |
56 |
const char *comment = NULL; |
57 |
char reason[KILLLEN + 1] = "SVSKilled: "; |
58 |
time_t ts = 0; |
59 |
|
60 |
if (!HasFlag(source_p, FLAGS_SERVICE)) |
61 |
return 0; |
62 |
|
63 |
if (EmptyString(parv[1])) |
64 |
return 0; |
65 |
|
66 |
if (parc > 3) |
67 |
{ |
68 |
comment = parv[3] ? parv[3] : source_p->name; |
69 |
ts = atol(parv[2]); |
70 |
} |
71 |
else |
72 |
comment = (parc > 2 && parv[2]) ? parv[2] : source_p->name; |
73 |
|
74 |
if ((target_p = find_person(source_p, parv[1])) == NULL) |
75 |
return 0; |
76 |
|
77 |
if (ts && (ts != target_p->tsinfo)) |
78 |
return 0; |
79 |
|
80 |
if (MyConnect(target_p)) |
81 |
{ |
82 |
strlcpy(reason + 11, comment, sizeof(reason) - 11); |
83 |
exit_client(target_p, reason); |
84 |
return 0; |
85 |
} |
86 |
|
87 |
if (target_p->from == source_p->from) |
88 |
{ |
89 |
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE, |
90 |
"Received wrong-direction SVSKILL " |
91 |
"for %s (behind %s) from %s", |
92 |
target_p->name, source_p->from->name, |
93 |
get_client_name(source_p, HIDE_IP)); |
94 |
return 0; |
95 |
} |
96 |
|
97 |
if (ts == 0) |
98 |
sendto_one(target_p, ":%s SVSKILL %s :%s", source_p->id, |
99 |
target_p->id, comment); |
100 |
else |
101 |
sendto_one(target_p, ":%s SVSKILL %s %lu :%s", source_p->id, |
102 |
target_p->id, ts, comment); |
103 |
return 0; |
104 |
} |
105 |
|
106 |
static struct Message svskill_msgtab = |
107 |
{ |
108 |
"SVSKILL", NULL, 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
109 |
{ m_ignore, m_ignore, ms_svskill, m_ignore, m_ignore, m_ignore } |
110 |
}; |
111 |
|
112 |
static void |
113 |
module_init(void) |
114 |
{ |
115 |
mod_add_cmd(&svskill_msgtab); |
116 |
} |
117 |
|
118 |
static void |
119 |
module_exit(void) |
120 |
{ |
121 |
mod_del_cmd(&svskill_msgtab); |
122 |
} |
123 |
|
124 |
struct module module_entry = |
125 |
{ |
126 |
.node = { NULL, NULL, NULL }, |
127 |
.name = NULL, |
128 |
.version = "$Revision$", |
129 |
.handle = NULL, |
130 |
.modinit = module_init, |
131 |
.modexit = module_exit, |
132 |
.flags = 0 |
133 |
}; |