1 |
/* |
2 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
* |
4 |
* Copyright (c) 1997-2017 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_part.c |
23 |
* \brief Includes required functions for processing the PART 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 "numeric.h" |
35 |
#include "send.h" |
36 |
#include "parse.h" |
37 |
#include "modules.h" |
38 |
#include "conf.h" |
39 |
#include "packet.h" |
40 |
|
41 |
|
42 |
/*! \brief PART command handler |
43 |
* |
44 |
* \param source_p Pointer to allocated Client struct from which the message |
45 |
* originally comes from. This can be a local or remote client. |
46 |
* \param parc Integer holding the number of supplied arguments. |
47 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
48 |
* pointers. |
49 |
* \note Valid arguments for this command are: |
50 |
* - parv[0] = command |
51 |
* - parv[1] = channel name |
52 |
* - parv[2] = part message |
53 |
*/ |
54 |
static int |
55 |
m_part(struct Client *source_p, int parc, char *parv[]) |
56 |
{ |
57 |
if (EmptyString(parv[1])) |
58 |
{ |
59 |
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, "PART"); |
60 |
return 0; |
61 |
} |
62 |
|
63 |
/* Finish the flood grace period... */ |
64 |
if (MyClient(source_p) && !IsFloodDone(source_p)) |
65 |
flood_endgrace(source_p); |
66 |
|
67 |
channel_do_part(source_p, parv[1], parv[2]); |
68 |
return 0; |
69 |
} |
70 |
|
71 |
static struct Message part_msgtab = |
72 |
{ |
73 |
.cmd = "PART", |
74 |
.args_min = 2, |
75 |
.args_max = MAXPARA, |
76 |
.handlers[UNREGISTERED_HANDLER] = m_unregistered, |
77 |
.handlers[CLIENT_HANDLER] = m_part, |
78 |
.handlers[SERVER_HANDLER] = m_part, |
79 |
.handlers[ENCAP_HANDLER] = m_ignore, |
80 |
.handlers[OPER_HANDLER] = m_part |
81 |
}; |
82 |
|
83 |
static void |
84 |
module_init(void) |
85 |
{ |
86 |
mod_add_cmd(&part_msgtab); |
87 |
} |
88 |
|
89 |
static void |
90 |
module_exit(void) |
91 |
{ |
92 |
mod_del_cmd(&part_msgtab); |
93 |
} |
94 |
|
95 |
struct module module_entry = |
96 |
{ |
97 |
.version = "$Revision$", |
98 |
.modinit = module_init, |
99 |
.modexit = module_exit, |
100 |
.flags = MODULE_FLAG_CORE |
101 |
}; |