1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1997-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_tmode.c |
23 |
* \brief Includes required functions for processing the TMODE 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 "user.h" |
37 |
#include "conf.h" |
38 |
#include "server.h" |
39 |
#include "send.h" |
40 |
#include "parse.h" |
41 |
#include "modules.h" |
42 |
#include "packet.h" |
43 |
|
44 |
|
45 |
/*! \brief TMODE command handler |
46 |
* |
47 |
* \param source_p Pointer to allocated Client struct from which the message |
48 |
* originally comes from. This can be a local or remote client. |
49 |
* \param parc Integer holding the number of supplied arguments. |
50 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
51 |
* pointers. |
52 |
* \note Valid arguments for this command are: |
53 |
* - parv[0] = command |
54 |
* - parv[1] = timestamp |
55 |
* - parv[2] = channel name |
56 |
* - parv[3] = modes to be added or removed |
57 |
*/ |
58 |
static int |
59 |
ms_tmode(struct Client *source_p, int parc, char *parv[]) |
60 |
{ |
61 |
struct Channel *chptr = NULL; |
62 |
|
63 |
if ((chptr = hash_find_channel(parv[2])) == NULL) |
64 |
{ |
65 |
sendto_one_numeric(source_p, &me, ERR_NOSUCHCHANNEL, parv[2]); |
66 |
return 0; |
67 |
} |
68 |
|
69 |
if (atol(parv[1]) > chptr->channelts) |
70 |
return 0; |
71 |
|
72 |
if (IsServer(source_p) || HasFlag(source_p, FLAGS_SERVICE)) |
73 |
set_channel_mode(source_p, chptr, NULL, parc - 3, parv + 3); |
74 |
else |
75 |
{ |
76 |
struct Membership *member = find_channel_link(source_p, chptr); |
77 |
|
78 |
set_channel_mode(source_p, chptr, member, parc - 3, parv + 3); |
79 |
} |
80 |
|
81 |
return 0; |
82 |
} |
83 |
|
84 |
static struct Message tmode_msgtab = |
85 |
{ |
86 |
"TMODE", NULL, 0, 0, 4, MAXPARA, MFLG_SLOW, 0, |
87 |
{ m_ignore, m_ignore, ms_tmode, m_ignore, m_ignore, m_ignore } |
88 |
}; |
89 |
|
90 |
static void |
91 |
module_init(void) |
92 |
{ |
93 |
mod_add_cmd(&tmode_msgtab); |
94 |
} |
95 |
|
96 |
static void |
97 |
module_exit(void) |
98 |
{ |
99 |
mod_del_cmd(&tmode_msgtab); |
100 |
} |
101 |
|
102 |
struct module module_entry = |
103 |
{ |
104 |
.node = { NULL, NULL, NULL }, |
105 |
.name = NULL, |
106 |
.version = "$Revision$", |
107 |
.handle = NULL, |
108 |
.modinit = module_init, |
109 |
.modexit = module_exit, |
110 |
.flags = MODULE_FLAG_CORE |
111 |
}; |