ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_whowas.c
Revision: 4819
Committed: Sat Nov 1 16:49:40 2014 UTC (10 years, 9 months ago) by michael
Content type: text/x-csrc
File size: 5177 byte(s)
Log Message:
- Renamed Client::svid to Client::account

File Contents

# Content
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_whowas.c
23 * \brief Includes required functions for processing the WHOWAS command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "list.h"
29 #include "whowas.h"
30 #include "client.h"
31 #include "hash.h"
32 #include "irc_string.h"
33 #include "ircd.h"
34 #include "ircd_defs.h"
35 #include "numeric.h"
36 #include "misc.h"
37 #include "server.h"
38 #include "send.h"
39 #include "conf.h"
40 #include "parse.h"
41 #include "modules.h"
42
43
44 static void
45 do_whowas(struct Client *source_p, const int parc, char *parv[])
46 {
47 int cur = 0;
48 int max = -1;
49 const dlink_node *node = NULL;
50
51 if (parc > 2 && !EmptyString(parv[2]))
52 if ((max = atoi(parv[2])) > 20 && !MyConnect(source_p))
53 max = 20;
54
55 DLINK_FOREACH(node, WHOWASHASH[strhash(parv[1])].head)
56 {
57 const struct Whowas *temp = node->data;
58
59 if (!irccmp(parv[1], temp->name))
60 {
61 sendto_one_numeric(source_p, &me, RPL_WHOWASUSER, temp->name,
62 temp->username, temp->hostname,
63 temp->realname);
64
65 if (!IsDigit(temp->account[0]) && temp->account[0] != '*')
66 sendto_one_numeric(source_p, &me, RPL_WHOISACCOUNT, temp->name, temp->account, "was");
67
68 if ((temp->shide || ConfigServerHide.hide_servers) && !HasUMode(source_p, UMODE_OPER))
69 sendto_one_numeric(source_p, &me, RPL_WHOISSERVER, temp->name,
70 ConfigServerInfo.network_name, myctime(temp->logoff));
71 else
72 sendto_one_numeric(source_p, &me, RPL_WHOISSERVER, temp->name,
73 temp->servername, myctime(temp->logoff));
74 ++cur;
75 }
76
77 if (max > 0 && cur >= max)
78 break;
79 }
80
81 if (!cur)
82 sendto_one_numeric(source_p, &me, ERR_WASNOSUCHNICK, parv[1]);
83
84 sendto_one_numeric(source_p, &me, RPL_ENDOFWHOWAS, parv[1]);
85 }
86
87 /*! \brief WHOWAS command handler
88 *
89 * \param source_p Pointer to allocated Client struct from which the message
90 * originally comes from. This can be a local or remote client.
91 * \param parc Integer holding the number of supplied arguments.
92 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
93 * pointers.
94 * \note Valid arguments for this command are:
95 * - parv[0] = command
96 * - parv[1] = nickname
97 * - parv[2] = count
98 * - parv[3] = nickname/servername
99 */
100 static int
101 m_whowas(struct Client *source_p, int parc, char *parv[])
102 {
103 static time_t last_used = 0;
104
105 if (parc < 2 || EmptyString(parv[1]))
106 {
107 sendto_one_numeric(source_p, &me, ERR_NONICKNAMEGIVEN);
108 return 0;
109 }
110
111 if ((last_used + ConfigGeneral.pace_wait) > CurrentTime)
112 {
113 sendto_one_numeric(source_p, &me, RPL_LOAD2HI, "WHOWAS");
114 return 0;
115 }
116
117 last_used = CurrentTime;
118
119 if (!ConfigServerHide.disable_remote_commands)
120 if (hunt_server(source_p, ":%s WHOWAS %s %s :%s", 3, parc, parv) != HUNTED_ISME)
121 return 0;
122
123 do_whowas(source_p, parc, parv);
124 return 0;
125 }
126
127 /*! \brief WHOWAS command handler
128 *
129 * \param source_p Pointer to allocated Client struct from which the message
130 * originally comes from. This can be a local or remote client.
131 * \param parc Integer holding the number of supplied arguments.
132 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
133 * pointers.
134 * \note Valid arguments for this command are:
135 * - parv[0] = command
136 * - parv[1] = nickname
137 * - parv[2] = count
138 * - parv[3] = nickname/servername
139 */
140 static int
141 ms_whowas(struct Client *source_p, int parc, char *parv[])
142 {
143 if (parc < 2 || EmptyString(parv[1]))
144 {
145 sendto_one_numeric(source_p, &me, ERR_NONICKNAMEGIVEN);
146 return 0;
147 }
148
149 if (hunt_server(source_p, ":%s WHOWAS %s %s :%s", 3, parc, parv) != HUNTED_ISME)
150 return 0;
151
152 do_whowas(source_p, parc, parv);
153 return 0;
154 }
155
156 static struct Message whowas_msgtab =
157 {
158 "WHOWAS", NULL, 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
159 { m_unregistered, m_whowas, ms_whowas, m_ignore, ms_whowas, m_ignore }
160 };
161
162 static void
163 module_init(void)
164 {
165 mod_add_cmd(&whowas_msgtab);
166 }
167
168 static void
169 module_exit(void)
170 {
171 mod_del_cmd(&whowas_msgtab);
172 }
173
174 struct module module_entry =
175 {
176 .node = { NULL, NULL, NULL },
177 .name = NULL,
178 .version = "$Revision$",
179 .handle = NULL,
180 .modinit = module_init,
181 .modexit = module_exit,
182 .flags = 0
183 };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision