ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_whowas.c
Revision: 3295
Committed: Thu Apr 10 18:59:33 2014 UTC (11 years, 4 months ago) by michael
Content type: text/x-csrc
File size: 5083 byte(s)
Log Message:
- doxygen

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

Properties

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