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_names.c |
23 |
* \brief Includes required functions for processing the NAMES 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 |
|
39 |
|
40 |
/*! \brief NAMES command handler |
41 |
* |
42 |
* \param source_p Pointer to allocated Client struct from which the message |
43 |
* originally comes from. This can be a local or remote client. |
44 |
* \param parc Integer holding the number of supplied arguments. |
45 |
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
46 |
* pointers. |
47 |
* \note Valid arguments for this command are: |
48 |
* - parv[0] = command |
49 |
* - parv[1] = channel name |
50 |
*/ |
51 |
static int |
52 |
m_names(struct Client *source_p, int parc, char *parv[]) |
53 |
{ |
54 |
const char *const para = parc > 1 ? parv[1] : NULL; |
55 |
|
56 |
if (!EmptyString(para)) |
57 |
{ |
58 |
struct Channel *chptr = hash_find_channel(para); |
59 |
if (chptr) |
60 |
channel_member_names(source_p, chptr, 1); |
61 |
else |
62 |
sendto_one_numeric(source_p, &me, RPL_ENDOFNAMES, para); |
63 |
} |
64 |
else |
65 |
sendto_one_numeric(source_p, &me, RPL_ENDOFNAMES, "*"); |
66 |
|
67 |
return 0; |
68 |
} |
69 |
|
70 |
static struct Message names_msgtab = |
71 |
{ |
72 |
.cmd = "NAMES", |
73 |
.args_max = MAXPARA, |
74 |
.handlers[UNREGISTERED_HANDLER] = m_unregistered, |
75 |
.handlers[CLIENT_HANDLER] = m_names, |
76 |
.handlers[SERVER_HANDLER] = m_ignore, |
77 |
.handlers[ENCAP_HANDLER] = m_ignore, |
78 |
.handlers[OPER_HANDLER] = m_names |
79 |
}; |
80 |
|
81 |
static void |
82 |
module_init(void) |
83 |
{ |
84 |
mod_add_cmd(&names_msgtab); |
85 |
} |
86 |
|
87 |
static void |
88 |
module_exit(void) |
89 |
{ |
90 |
mod_del_cmd(&names_msgtab); |
91 |
} |
92 |
|
93 |
struct module module_entry = |
94 |
{ |
95 |
.version = "$Revision$", |
96 |
.modinit = module_init, |
97 |
.modexit = module_exit, |
98 |
}; |