1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 2014-2014 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_svsjoin.c |
23 |
* \brief Includes required functions for processing the SVSJOIN command. |
24 |
* \version $Id$ |
25 |
*/ |
26 |
|
27 |
#include "stdinc.h" |
28 |
#include "list.h" |
29 |
#include "channel.h" |
30 |
#include "channel_mode.h" |
31 |
#include "client.h" |
32 |
#include "hash.h" |
33 |
#include "irc_string.h" |
34 |
#include "ircd.h" |
35 |
#include "numeric.h" |
36 |
#include "send.h" |
37 |
#include "server.h" |
38 |
#include "conf.h" |
39 |
#include "parse.h" |
40 |
#include "modules.h" |
41 |
#include "resv.h" |
42 |
|
43 |
|
44 |
/*! \brief SVSJOIN command handler |
45 |
* |
46 |
* \param source_p Pointer to allocated Client struct from which the message |
47 |
* originally comes from. This can be a local or remote client. |
48 |
* \param parc Integer holding the number of supplied arguments. |
49 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
50 |
* pointers. |
51 |
* \note Valid arguments for this command are: |
52 |
* - parv[0] = command |
53 |
* - parv[1] = nickname |
54 |
* - parv[2] = channel |
55 |
* - parv[3] = channel password (key) |
56 |
*/ |
57 |
static int |
58 |
ms_svsjoin(struct Client *source_p, int parc, char *parv[]) |
59 |
{ |
60 |
struct Client *target_p = NULL; |
61 |
|
62 |
if (!HasFlag(source_p, FLAGS_SERVICE)) |
63 |
return 0; |
64 |
|
65 |
if (EmptyString(parv[2])) |
66 |
return 0; |
67 |
|
68 |
if ((target_p = find_person(source_p, parv[1])) == NULL) |
69 |
return 0; |
70 |
|
71 |
if (MyConnect(target_p)) |
72 |
{ |
73 |
channel_do_join(target_p, parv[2], parv[3]); |
74 |
return 0; |
75 |
} |
76 |
|
77 |
if (target_p->from == source_p->from) |
78 |
{ |
79 |
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE, |
80 |
"Received wrong-direction SVSJOIN " |
81 |
"for %s (behind %s) from %s", |
82 |
target_p->name, source_p->from->name, |
83 |
get_client_name(source_p, HIDE_IP)); |
84 |
return 0; |
85 |
} |
86 |
|
87 |
if (parc == 3) |
88 |
sendto_one(target_p, ":%s SVSJOIN %s %s", source_p->id, |
89 |
target_p->id, parv[2]); |
90 |
else |
91 |
sendto_one(target_p, ":%s SVSJOIN %s %s %s", source_p->id, |
92 |
target_p->id, parv[2], parv[3]); |
93 |
return 0; |
94 |
} |
95 |
|
96 |
static struct Message svsjoin_msgtab = |
97 |
{ |
98 |
"SVSJOIN", NULL, 0, 0, 3, MAXPARA, MFLG_SLOW, 0, |
99 |
{ m_unregistered, m_ignore, ms_svsjoin, m_ignore, m_ignore, m_ignore } |
100 |
}; |
101 |
|
102 |
static void |
103 |
module_init(void) |
104 |
{ |
105 |
mod_add_cmd(&svsjoin_msgtab); |
106 |
} |
107 |
|
108 |
static void |
109 |
module_exit(void) |
110 |
{ |
111 |
mod_del_cmd(&svsjoin_msgtab); |
112 |
} |
113 |
|
114 |
struct module module_entry = |
115 |
{ |
116 |
.node = { NULL, NULL, NULL }, |
117 |
.name = NULL, |
118 |
.version = "$Revision$", |
119 |
.handle = NULL, |
120 |
.modinit = module_init, |
121 |
.modexit = module_exit, |
122 |
.flags = 0 |
123 |
}; |