ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_svskill.c
Revision: 2621
Committed: Wed Dec 4 19:25:23 2013 UTC (12 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 3931 byte(s)
Log Message:
- m_svskill.c: replaced MyClient() test with MyConnect()

File Contents

# User Rev Content
1 michael 2602 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     *
4     * Copyright (C) 1999 by the Bahamut Development Team.
5     * Copyright (C) 2013 by the 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., 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     * - parv[0] = sender prefix
52     * - parv[1] = nickname
53     * - parv[2] = TS
54     * - parv[3] = kill message
55     */
56     static void
57     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     return;
66    
67     if (EmptyString(parv[1]))
68     return;
69    
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     return;
80    
81     if (ts && (ts != target_p->tsinfo))
82     return;
83    
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     return;
89     }
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     return;
99     }
100    
101     if (ts == 0)
102     sendto_one(target_p, ":%s SVSKILL %s :%s",
103     ID_or_name(source_p, target_p->from),
104     ID_or_name(target_p, target_p->from), comment);
105     else
106     sendto_one(target_p, ":%s SVSKILL %s %lu :%s",
107     ID_or_name(source_p, target_p->from),
108     ID_or_name(target_p, target_p->from), ts, comment);
109     }
110    
111     static struct Message svskill_msgtab = {
112     "SVSKILL", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
113     {m_ignore, m_ignore, ms_svskill, m_ignore, m_ignore, m_ignore}
114     };
115    
116     static void
117     module_init(void)
118     {
119     mod_add_cmd(&svskill_msgtab);
120     }
121    
122     static void
123     module_exit(void)
124     {
125     mod_del_cmd(&svskill_msgtab);
126     }
127    
128     struct module module_entry = {
129     .node = { NULL, NULL, NULL },
130     .name = NULL,
131 michael 2605 .version = "$Revision$",
132 michael 2602 .handle = NULL,
133     .modinit = module_init,
134     .modexit = module_exit,
135     .flags = 0
136     };

Properties

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