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
24 * $Id: m_whowas.c 1717 2006-07-04 14:41:11Z jilles $
34 #include "ircd_defs.h"
44 static int m_whowas(struct Client
*, struct Client
*, int, const char **);
46 struct Message whowas_msgtab
= {
47 "WHOWAS", 0, 0, 0, MFLG_SLOW
,
48 {mg_unreg
, {m_whowas
, 2}, mg_ignore
, mg_ignore
, mg_ignore
, {m_whowas
, 2}}
51 mapi_clist_av1 whowas_clist
[] = { &whowas_msgtab
, NULL
};
52 DECLARE_MODULE_AV1(whowas
, NULL
, NULL
, whowas_clist
, NULL
, NULL
, "$Revision: 1717 $");
56 ** parv[1] = nickname queried
59 m_whowas(struct Client
*client_p
, struct Client
*source_p
, int parc
, const char *parv
[])
63 int max
= -1, found
= 0;
69 static time_t last_used
= 0L;
73 if((last_used
+ ConfigFileEntry
.pace_wait_simple
) > rb_current_time())
75 sendto_one(source_p
, form_str(RPL_LOAD2HI
),
76 me
.name
, source_p
->name
, "WHOWAS");
77 sendto_one(source_p
, form_str(RPL_ENDOFWHOWAS
),
78 me
.name
, source_p
->name
, parv
[1]);
82 last_used
= rb_current_time();
91 if(hunt_server(client_p
, source_p
, ":%s WHOWAS %s %s :%s", 3, parc
, parv
))
95 if((p
= strchr(parv
[1], ',')))
100 sendq_limit
= get_sendq(client_p
) * 9 / 10;
102 temp
= WHOWASHASH
[hash_whowas_name(nick
)];
104 for (; temp
; temp
= temp
->next
)
106 if(!irccmp(nick
, temp
->name
))
108 if(cur
> 0 && rb_linebuf_len(&client_p
->localClient
->buf_sendq
) > sendq_limit
)
110 sendto_one(source_p
, form_str(ERR_TOOMANYMATCHES
),
111 me
.name
, source_p
->name
, "WHOWAS");
114 sendto_one(source_p
, form_str(RPL_WHOWASUSER
),
115 me
.name
, source_p
->name
, temp
->name
,
116 temp
->username
, temp
->hostname
, temp
->realname
);
117 if (MyOper(source_p
) && !EmptyString(temp
->sockhost
))
119 sendto_one(source_p
, form_str(RPL_WHOWASREAL
),
120 me
.name
, source_p
->name
, temp
->name
,
121 "<untracked>", temp
->sockhost
);
123 sendto_one_numeric(source_p
, RPL_WHOISACTUALLY
,
124 form_str(RPL_WHOISACTUALLY
),
125 temp
->name
, temp
->sockhost
);
127 if (!EmptyString(temp
->suser
))
128 sendto_one_numeric(source_p
, RPL_WHOISLOGGEDIN
,
129 "%s %s :was logged in as",
130 temp
->name
, temp
->suser
);
131 sendto_one_numeric(source_p
, RPL_WHOISSERVER
,
132 form_str(RPL_WHOISSERVER
),
133 temp
->name
, temp
->servername
,
134 rb_ctime(temp
->logoff
, tbuf
, sizeof(tbuf
)));
138 if(max
> 0 && cur
>= max
)
143 sendto_one(source_p
, form_str(ERR_WASNOSUCHNICK
),
144 me
.name
, source_p
->name
, nick
);
146 sendto_one(source_p
, form_str(RPL_ENDOFWHOWAS
),
147 me
.name
, source_p
->name
, parv
[1]);