1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 2014-2018 ircd-hybrid development team |
5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
19 |
* USA |
20 |
*/ |
21 |
|
22 |
/*! \file m_svspart.c |
23 |
* \brief Includes required functions for processing the SVSPART command. |
24 |
* \version $Id$ |
25 |
*/ |
26 |
|
27 |
#include "stdinc.h" |
28 |
#include "list.h" |
29 |
#include "channel.h" |
30 |
#include "client.h" |
31 |
#include "hash.h" |
32 |
#include "irc_string.h" |
33 |
#include "ircd.h" |
34 |
#include "send.h" |
35 |
#include "parse.h" |
36 |
#include "modules.h" |
37 |
|
38 |
|
39 |
/*! \brief SVSPART 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] = channel name |
50 |
* - parv[3] = part message |
51 |
*/ |
52 |
static int |
53 |
ms_svspart(struct Client *source_p, int parc, char *parv[]) |
54 |
{ |
55 |
if (!HasFlag(source_p, FLAGS_SERVICE)) |
56 |
return 0; |
57 |
|
58 |
if (EmptyString(parv[2])) |
59 |
return 0; |
60 |
|
61 |
struct Client *target_p; |
62 |
if ((target_p = find_person(source_p, parv[1])) == NULL) |
63 |
return 0; |
64 |
|
65 |
if (MyConnect(target_p)) |
66 |
{ |
67 |
channel_do_part(target_p, parv[2], parv[3]); |
68 |
return 0; |
69 |
} |
70 |
|
71 |
if (target_p->from == source_p->from) |
72 |
{ |
73 |
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE, |
74 |
"Received wrong-direction SVSPART " |
75 |
"for %s (behind %s) from %s", |
76 |
target_p->name, source_p->from->name, |
77 |
client_get_name(source_p, HIDE_IP)); |
78 |
return 0; |
79 |
} |
80 |
|
81 |
if (parc == 3) |
82 |
sendto_one(target_p, ":%s SVSPART %s %s", source_p->id, |
83 |
target_p->id, parv[2]); |
84 |
else |
85 |
sendto_one(target_p, ":%s SVSPART %s %s :%s", source_p->id, |
86 |
target_p->id, parv[2], parv[3]); |
87 |
return 0; |
88 |
} |
89 |
|
90 |
static struct Message svspart_msgtab = |
91 |
{ |
92 |
.cmd = "SVSPART", |
93 |
.args_min = 3, |
94 |
.args_max = MAXPARA, |
95 |
.handlers[UNREGISTERED_HANDLER] = m_unregistered, |
96 |
.handlers[CLIENT_HANDLER] = m_ignore, |
97 |
.handlers[SERVER_HANDLER] = ms_svspart, |
98 |
.handlers[ENCAP_HANDLER] = m_ignore, |
99 |
.handlers[OPER_HANDLER] = m_ignore |
100 |
}; |
101 |
|
102 |
static void |
103 |
module_init(void) |
104 |
{ |
105 |
mod_add_cmd(&svspart_msgtab); |
106 |
} |
107 |
|
108 |
static void |
109 |
module_exit(void) |
110 |
{ |
111 |
mod_del_cmd(&svspart_msgtab); |
112 |
} |
113 |
|
114 |
struct module module_entry = |
115 |
{ |
116 |
.version = "$Revision$", |
117 |
.modinit = module_init, |
118 |
.modexit = module_exit, |
119 |
}; |