| 1 |
adx |
30 |
/* |
| 2 |
michael |
2820 |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
| 3 |
adx |
30 |
* |
| 4 |
michael |
2820 |
* Copyright (c) 1997-2014 ircd-hybrid development team |
| 5 |
adx |
30 |
* |
| 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 |
michael |
4564 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 19 |
adx |
30 |
* USA |
| 20 |
|
|
*/ |
| 21 |
|
|
|
| 22 |
michael |
2820 |
/*! \file m_close.c |
| 23 |
|
|
* \brief Includes required functions for processing the CLOSE command. |
| 24 |
|
|
* \version $Id$ |
| 25 |
|
|
*/ |
| 26 |
|
|
|
| 27 |
adx |
30 |
#include "stdinc.h" |
| 28 |
michael |
1011 |
#include "list.h" |
| 29 |
adx |
30 |
#include "client.h" |
| 30 |
|
|
#include "ircd.h" |
| 31 |
|
|
#include "numeric.h" |
| 32 |
|
|
#include "send.h" |
| 33 |
|
|
#include "parse.h" |
| 34 |
|
|
#include "modules.h" |
| 35 |
|
|
|
| 36 |
|
|
|
| 37 |
michael |
3266 |
/*! \brief CLOSE command handler |
| 38 |
|
|
* |
| 39 |
|
|
* \param source_p Pointer to allocated Client struct from which the message |
| 40 |
|
|
* originally comes from. This can be a local or remote client. |
| 41 |
|
|
* \param parc Integer holding the number of supplied arguments. |
| 42 |
|
|
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
| 43 |
|
|
* pointers. |
| 44 |
|
|
* \note Valid arguments for this command are: |
| 45 |
|
|
* - parv[0] = command |
| 46 |
adx |
30 |
*/ |
| 47 |
michael |
2820 |
static int |
| 48 |
michael |
3156 |
mo_close(struct Client *source_p, int parc, char *parv[]) |
| 49 |
adx |
30 |
{ |
| 50 |
michael |
4816 |
dlink_node *node = NULL, *node_next = NULL; |
| 51 |
michael |
970 |
unsigned int closed = dlink_list_length(&unknown_list); |
| 52 |
adx |
30 |
|
| 53 |
michael |
4816 |
DLINK_FOREACH_SAFE(node, node_next, unknown_list.head) |
| 54 |
adx |
30 |
{ |
| 55 |
michael |
4816 |
struct Client *target_p = node->data; |
| 56 |
adx |
30 |
|
| 57 |
michael |
3109 |
sendto_one_numeric(source_p, &me, RPL_CLOSING, |
| 58 |
|
|
get_client_name(target_p, SHOW_IP), |
| 59 |
|
|
target_p->status); |
| 60 |
michael |
970 |
|
| 61 |
michael |
1011 |
/* |
| 62 |
michael |
2820 |
* Exit here is safe, because it is guaranteed not to be source_p |
| 63 |
adx |
30 |
* because it is unregistered and source_p is an oper. |
| 64 |
|
|
*/ |
| 65 |
michael |
3171 |
exit_client(target_p, "Oper Closing"); |
| 66 |
adx |
30 |
} |
| 67 |
|
|
|
| 68 |
michael |
3109 |
sendto_one_numeric(source_p, &me, RPL_CLOSEEND, closed); |
| 69 |
michael |
2820 |
return 0; |
| 70 |
adx |
30 |
} |
| 71 |
michael |
1230 |
|
| 72 |
michael |
2820 |
static struct Message close_msgtab = |
| 73 |
|
|
{ |
| 74 |
michael |
4546 |
"CLOSE", NULL, 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
| 75 |
michael |
1230 |
{ m_unregistered, m_not_oper, m_ignore, m_ignore, mo_close, m_ignore } |
| 76 |
|
|
}; |
| 77 |
|
|
|
| 78 |
|
|
static void |
| 79 |
|
|
module_init(void) |
| 80 |
|
|
{ |
| 81 |
|
|
mod_add_cmd(&close_msgtab); |
| 82 |
|
|
} |
| 83 |
|
|
|
| 84 |
|
|
static void |
| 85 |
|
|
module_exit(void) |
| 86 |
|
|
{ |
| 87 |
|
|
mod_del_cmd(&close_msgtab); |
| 88 |
|
|
} |
| 89 |
|
|
|
| 90 |
michael |
2820 |
struct module module_entry = |
| 91 |
|
|
{ |
| 92 |
michael |
1230 |
.node = { NULL, NULL, NULL }, |
| 93 |
|
|
.name = NULL, |
| 94 |
|
|
.version = "$Revision$", |
| 95 |
|
|
.handle = NULL, |
| 96 |
|
|
.modinit = module_init, |
| 97 |
|
|
.modexit = module_exit, |
| 98 |
|
|
.flags = 0 |
| 99 |
|
|
}; |