1 |
michael |
2602 |
/* |
2 |
michael |
2820 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
michael |
2602 |
* |
4 |
michael |
2820 |
* Copyright (c) 1999 Bahamut development team. |
5 |
|
|
* Copyright (c) 2013-2014 ircd-hybrid development team |
6 |
michael |
2602 |
* |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
|
|
* USA |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
/*! \file m_svskill.c |
24 |
|
|
* \brief Includes required functions for processing the SVSKILL command. |
25 |
michael |
2605 |
* \version $Id$ |
26 |
michael |
2602 |
*/ |
27 |
|
|
|
28 |
|
|
#include "stdinc.h" |
29 |
|
|
#include "client.h" |
30 |
|
|
#include "ircd.h" |
31 |
michael |
3347 |
#include "server.h" |
32 |
michael |
2602 |
#include "send.h" |
33 |
|
|
#include "parse.h" |
34 |
|
|
#include "modules.h" |
35 |
|
|
#include "irc_string.h" |
36 |
|
|
#include "conf.h" |
37 |
|
|
|
38 |
|
|
|
39 |
michael |
3300 |
/*! \brief SVSKILL command handler |
40 |
michael |
2602 |
* |
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 |
michael |
3096 |
* - parv[0] = command |
48 |
michael |
2602 |
* - parv[1] = nickname |
49 |
michael |
3294 |
* - parv[2] = timestamp |
50 |
michael |
2602 |
* - parv[3] = kill message |
51 |
|
|
*/ |
52 |
michael |
2820 |
static int |
53 |
michael |
3156 |
ms_svskill(struct Client *source_p, int parc, char *parv[]) |
54 |
michael |
2602 |
{ |
55 |
|
|
struct Client *target_p = NULL; |
56 |
|
|
const char *comment = NULL; |
57 |
|
|
char reason[KICKLEN + 1] = "SVSKilled: "; |
58 |
|
|
time_t ts = 0; |
59 |
|
|
|
60 |
|
|
if (!HasFlag(source_p, FLAGS_SERVICE)) |
61 |
michael |
2820 |
return 0; |
62 |
michael |
2602 |
|
63 |
|
|
if (EmptyString(parv[1])) |
64 |
michael |
2820 |
return 0; |
65 |
michael |
2602 |
|
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 |
michael |
3156 |
if ((target_p = find_person(source_p, parv[1])) == NULL) |
75 |
michael |
2820 |
return 0; |
76 |
michael |
2602 |
|
77 |
|
|
if (ts && (ts != target_p->tsinfo)) |
78 |
michael |
2820 |
return 0; |
79 |
michael |
2602 |
|
80 |
michael |
2621 |
if (MyConnect(target_p)) |
81 |
michael |
2602 |
{ |
82 |
|
|
strlcpy(reason + 11, comment, sizeof(reason) - 11); |
83 |
michael |
3171 |
exit_client(target_p, reason); |
84 |
michael |
2820 |
return 0; |
85 |
michael |
2602 |
} |
86 |
|
|
|
87 |
michael |
3156 |
if (target_p->from == source_p->from) |
88 |
michael |
2602 |
{ |
89 |
|
|
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE, |
90 |
|
|
"Received wrong-direction SVSKILL " |
91 |
|
|
"for %s (behind %s) from %s", |
92 |
michael |
3156 |
target_p->name, source_p->from->name, |
93 |
michael |
2602 |
get_client_name(source_p, HIDE_IP)); |
94 |
michael |
2820 |
return 0; |
95 |
michael |
2602 |
} |
96 |
|
|
|
97 |
|
|
if (ts == 0) |
98 |
michael |
3184 |
sendto_one(target_p, ":%s SVSKILL %s :%s", source_p->id, |
99 |
|
|
target_p->id, comment); |
100 |
michael |
2602 |
else |
101 |
michael |
3184 |
sendto_one(target_p, ":%s SVSKILL %s %lu :%s", source_p->id, |
102 |
|
|
target_p->id, ts, comment); |
103 |
michael |
2820 |
return 0; |
104 |
michael |
2602 |
} |
105 |
|
|
|
106 |
michael |
2820 |
static struct Message svskill_msgtab = |
107 |
|
|
{ |
108 |
michael |
4545 |
"SVSKILL", NULL, 0, 0, 2, MAXPARA, MFLG_SLOW, 0, |
109 |
michael |
2820 |
{ m_ignore, m_ignore, ms_svskill, m_ignore, m_ignore, m_ignore } |
110 |
michael |
2602 |
}; |
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 |
michael |
2820 |
struct module module_entry = |
125 |
|
|
{ |
126 |
michael |
2602 |
.node = { NULL, NULL, NULL }, |
127 |
|
|
.name = NULL, |
128 |
michael |
2605 |
.version = "$Revision$", |
129 |
michael |
2602 |
.handle = NULL, |
130 |
|
|
.modinit = module_init, |
131 |
|
|
.modexit = module_exit, |
132 |
|
|
.flags = 0 |
133 |
|
|
}; |