ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_svskill.c
Revision: 3096
Committed: Sat Mar 1 23:31:45 2014 UTC (12 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 3934 byte(s)
Log Message:
- Applied Adam's "Put the command name in parv[0], not prefix name" patch

File Contents

# User Rev Content
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     #include "s_serv.h"
32     #include "send.h"
33     #include "channel_mode.h"
34     #include "parse.h"
35     #include "modules.h"
36     #include "irc_string.h"
37     #include "s_user.h"
38     #include "conf.h"
39    
40    
41     /*! \brief SVSKILL command handler (called by services)
42     *
43     * \param client_p Pointer to allocated Client struct with physical connection
44     * to this server, i.e. with an open socket connected.
45     * \param source_p Pointer to allocated Client struct from which the message
46     * originally comes from. This can be a local or remote client.
47     * \param parc Integer holding the number of supplied arguments.
48     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
49     * pointers.
50     * \note Valid arguments for this command are:
51 michael 3096 * - parv[0] = command
52 michael 2602 * - parv[1] = nickname
53     * - parv[2] = TS
54     * - parv[3] = kill message
55     */
56 michael 2820 static int
57 michael 2602 ms_svskill(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
58     {
59     struct Client *target_p = NULL;
60     const char *comment = NULL;
61     char reason[KICKLEN + 1] = "SVSKilled: ";
62     time_t ts = 0;
63    
64     if (!HasFlag(source_p, FLAGS_SERVICE))
65 michael 2820 return 0;
66 michael 2602
67     if (EmptyString(parv[1]))
68 michael 2820 return 0;
69 michael 2602
70     if (parc > 3)
71     {
72     comment = parv[3] ? parv[3] : source_p->name;
73     ts = atol(parv[2]);
74     }
75     else
76     comment = (parc > 2 && parv[2]) ? parv[2] : source_p->name;
77    
78     if ((target_p = find_person(client_p, parv[1])) == NULL)
79 michael 2820 return 0;
80 michael 2602
81     if (ts && (ts != target_p->tsinfo))
82 michael 2820 return 0;
83 michael 2602
84 michael 2621 if (MyConnect(target_p))
85 michael 2602 {
86     strlcpy(reason + 11, comment, sizeof(reason) - 11);
87     exit_client(target_p, target_p, reason);
88 michael 2820 return 0;
89 michael 2602 }
90    
91     if (target_p->from == client_p)
92     {
93     sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE,
94     "Received wrong-direction SVSKILL "
95     "for %s (behind %s) from %s",
96     target_p->name, client_p->name,
97     get_client_name(source_p, HIDE_IP));
98 michael 2820 return 0;
99 michael 2602 }
100    
101     if (ts == 0)
102     sendto_one(target_p, ":%s SVSKILL %s :%s",
103 michael 2888 ID_or_name(source_p, target_p),
104     ID_or_name(target_p, target_p), comment);
105 michael 2602 else
106     sendto_one(target_p, ":%s SVSKILL %s %lu :%s",
107 michael 2888 ID_or_name(source_p, target_p),
108     ID_or_name(target_p, target_p), ts, comment);
109 michael 2820 return 0;
110 michael 2602 }
111    
112 michael 2820 static struct Message svskill_msgtab =
113     {
114 michael 2602 "SVSKILL", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
115 michael 2820 { m_ignore, m_ignore, ms_svskill, m_ignore, m_ignore, m_ignore }
116 michael 2602 };
117    
118     static void
119     module_init(void)
120     {
121     mod_add_cmd(&svskill_msgtab);
122     }
123    
124     static void
125     module_exit(void)
126     {
127     mod_del_cmd(&svskill_msgtab);
128     }
129    
130 michael 2820 struct module module_entry =
131     {
132 michael 2602 .node = { NULL, NULL, NULL },
133     .name = NULL,
134 michael 2605 .version = "$Revision$",
135 michael 2602 .handle = NULL,
136     .modinit = module_init,
137     .modexit = module_exit,
138     .flags = 0
139     };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision