ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_whowas.c
Revision: 3156
Committed: Fri Mar 14 19:57:38 2014 UTC (11 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 4072 byte(s)
Log Message:
- Removed client_p pointers from everywhere

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 /*
86 ** m_whowas
87 ** parv[0] = command
88 ** parv[1] = nickname queried
89 */
90 static int
91 m_whowas(struct Client *source_p, int parc, char *parv[])
92 {
93 static time_t last_used = 0;
94
95 if (parc < 2 || EmptyString(parv[1]))
96 {
97 sendto_one_numeric(source_p, &me, ERR_NONICKNAMEGIVEN);
98 return 0;
99 }
100
101 if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
102 {
103 sendto_one_numeric(source_p, &me, RPL_LOAD2HI);
104 return 0;
105 }
106
107 last_used = CurrentTime;
108
109 if (parc > 3 && !ConfigServerHide.disable_remote_commands)
110 if (hunt_server(source_p, ":%s WHOWAS %s %s :%s", 3,
111 parc, parv) != HUNTED_ISME)
112 return 0;
113
114 whowas_do(source_p, parc, parv);
115 return 0;
116 }
117
118 static int
119 mo_whowas(struct Client *source_p, int parc, char *parv[])
120 {
121 if (parc < 2 || EmptyString(parv[1]))
122 {
123 sendto_one_numeric(source_p, &me, ERR_NONICKNAMEGIVEN);
124 return 0;
125 }
126
127 if (parc > 3)
128 if (hunt_server(source_p, ":%s WHOWAS %s %s :%s", 3,
129 parc, parv) != HUNTED_ISME)
130 return 0;
131
132 whowas_do(source_p, parc, parv);
133 return 0;
134 }
135
136 static struct Message whowas_msgtab =
137 {
138 "WHOWAS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
139 { m_unregistered, m_whowas, mo_whowas, m_ignore, mo_whowas, m_ignore }
140 };
141
142 static void
143 module_init(void)
144 {
145 mod_add_cmd(&whowas_msgtab);
146 }
147
148 static void
149 module_exit(void)
150 {
151 mod_del_cmd(&whowas_msgtab);
152 }
153
154 struct module module_entry =
155 {
156 .node = { NULL, NULL, NULL },
157 .name = NULL,
158 .version = "$Revision$",
159 .handle = NULL,
160 .modinit = module_init,
161 .modexit = module_exit,
162 .flags = 0
163 };

Properties

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