Remove cruft left behind by removed stats_p_hook.
[seven-1.x.git] / modules / m_whowas.c
blob47f8f0546757221d6319745e223a10154d9ac532
1 /*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_whois.c: Shows who a user was.
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
25 #include "stdinc.h"
26 #include "whowas.h"
27 #include "client.h"
28 #include "common.h"
29 #include "hash.h"
30 #include "irc_string.h"
31 #include "ircd.h"
32 #include "ircd_defs.h"
33 #include "numeric.h"
34 #include "s_serv.h"
35 #include "s_user.h"
36 #include "send.h"
37 #include "s_conf.h"
38 #include "msg.h"
39 #include "parse.h"
40 #include "modules.h"
42 static int m_whowas(struct Client *, struct Client *, int, const char **);
44 struct Message whowas_msgtab = {
45 "WHOWAS", 0, 0, 0, MFLG_SLOW,
46 {mg_unreg, {m_whowas, 2}, mg_ignore, mg_ignore, mg_ignore, {m_whowas, 2}}
49 mapi_clist_av1 whowas_clist[] = { &whowas_msgtab, NULL };
50 DECLARE_MODULE_AV1(whowas, NULL, NULL, whowas_clist, NULL, NULL, "$Revision: 26 $");
53 ** m_whowas
54 ** parv[0] = sender prefix
55 ** parv[1] = nickname queried
57 static int
58 m_whowas(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
60 struct Whowas *temp;
61 int cur = 0;
62 int max = -1, found = 0;
63 char *p;
64 const char *nick;
66 static time_t last_used = 0L;
68 if(!IsOper(source_p))
70 if((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
72 sendto_one(source_p, form_str(RPL_LOAD2HI),
73 me.name, source_p->name, "WHOWAS");
74 sendto_one(source_p, form_str(RPL_ENDOFWHOWAS),
75 me.name, source_p->name, parv[1]);
76 return 0;
78 else
79 last_used = CurrentTime;
83 if(parc > 2)
84 max = atoi(parv[2]);
86 #if 0
87 if(parc > 3)
88 if(hunt_server(client_p, source_p, ":%s WHOWAS %s %s :%s", 3, parc, parv))
89 return 0;
90 #endif
92 if((p = strchr(parv[1], ',')))
93 *p = '\0';
95 nick = parv[1];
97 temp = WHOWASHASH[hash_whowas_name(nick)];
98 found = 0;
99 for (; temp; temp = temp->next)
101 if(!irccmp(nick, temp->name))
103 sendto_one(source_p, form_str(RPL_WHOWASUSER),
104 me.name, source_p->name, temp->name,
105 temp->username, temp->hostname, temp->realname);
106 if (MyOper(source_p) && !EmptyString(temp->sockhost))
107 #if 0
108 sendto_one(source_p, form_str(RPL_WHOWASREAL),
109 me.name, source_p->name, temp->name,
110 "<untracked>", temp->sockhost);
111 #else
112 sendto_one_numeric(source_p, RPL_WHOISACTUALLY,
113 form_str(RPL_WHOISACTUALLY),
114 temp->name, temp->sockhost);
115 #endif
116 sendto_one_numeric(source_p, RPL_WHOISSERVER,
117 form_str(RPL_WHOISSERVER),
118 temp->name, temp->servername,
119 myctime(temp->logoff));
120 cur++;
121 found++;
123 if(max > 0 && cur >= max)
124 break;
127 if(!found)
128 sendto_one(source_p, form_str(ERR_WASNOSUCHNICK),
129 me.name, source_p->name, nick);
131 sendto_one(source_p, form_str(RPL_ENDOFWHOWAS),
132 me.name, source_p->name, parv[1]);
133 return 0;