1 |
adx |
30 |
/* |
2 |
|
|
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
|
|
* m_whois.c: Shows who a user was. |
4 |
|
|
* |
5 |
|
|
* Copyright (C) 2002 by the past and present ircd coders, and others. |
6 |
|
|
* |
7 |
|
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU General Public License as published by |
9 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
10 |
|
|
* (at your option) any later version. |
11 |
|
|
* |
12 |
|
|
* This program is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with this program; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
20 |
|
|
* USA |
21 |
|
|
* |
22 |
knight |
31 |
* $Id$ |
23 |
adx |
30 |
*/ |
24 |
|
|
|
25 |
|
|
#include "stdinc.h" |
26 |
michael |
1358 |
#include "list.h" |
27 |
adx |
30 |
#include "whowas.h" |
28 |
|
|
#include "client.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 |
michael |
1309 |
#include "conf.h" |
38 |
adx |
30 |
#include "parse.h" |
39 |
|
|
#include "modules.h" |
40 |
|
|
|
41 |
|
|
|
42 |
|
|
static void |
43 |
|
|
whowas_do(struct Client *client_p, struct Client *source_p, |
44 |
|
|
int parc, char *parv[]) |
45 |
|
|
{ |
46 |
|
|
int cur = 0; |
47 |
|
|
int max = -1; |
48 |
michael |
143 |
char *p = NULL, *nick = NULL; |
49 |
michael |
1358 |
const dlink_node *ptr = NULL; |
50 |
adx |
30 |
|
51 |
|
|
if (parc > 2) |
52 |
michael |
145 |
{ |
53 |
adx |
30 |
max = atoi(parv[2]); |
54 |
michael |
143 |
|
55 |
michael |
145 |
if (!MyConnect(source_p) && max > 20) |
56 |
|
|
max = 20; |
57 |
|
|
} |
58 |
|
|
|
59 |
adx |
30 |
if (parc > 3) |
60 |
michael |
143 |
if (hunt_server(client_p, source_p, ":%s WHOWAS %s %s :%s", 3, |
61 |
|
|
parc, parv) != HUNTED_ISME) |
62 |
adx |
30 |
return; |
63 |
|
|
|
64 |
|
|
nick = parv[1]; |
65 |
|
|
while (*nick == ',') |
66 |
|
|
nick++; |
67 |
|
|
if ((p = strchr(nick,',')) != NULL) |
68 |
|
|
*p = '\0'; |
69 |
|
|
if (*nick == '\0') |
70 |
|
|
return; |
71 |
|
|
|
72 |
michael |
1358 |
DLINK_FOREACH(ptr, WHOWASHASH[strhash(nick)].head) |
73 |
|
|
{ |
74 |
|
|
const struct Whowas *temp = ptr->data; |
75 |
adx |
30 |
|
76 |
michael |
1121 |
if (!irccmp(nick, temp->name)) |
77 |
adx |
30 |
{ |
78 |
michael |
1832 |
sendto_one(source_p, RPL_WHOWASUSER, |
79 |
adx |
30 |
me.name, source_p->name, temp->name, |
80 |
|
|
temp->username, temp->hostname, |
81 |
|
|
temp->realname); |
82 |
|
|
|
83 |
michael |
1219 |
if (ConfigServerHide.hide_servers && !HasUMode(source_p, UMODE_OPER)) |
84 |
michael |
1832 |
sendto_one(source_p, RPL_WHOISSERVER, |
85 |
adx |
30 |
me.name, source_p->name, temp->name, |
86 |
|
|
ServerInfo.network_name, myctime(temp->logoff)); |
87 |
|
|
else |
88 |
michael |
1832 |
sendto_one(source_p, RPL_WHOISSERVER, |
89 |
adx |
30 |
me.name, source_p->name, temp->name, |
90 |
|
|
temp->servername, myctime(temp->logoff)); |
91 |
michael |
1358 |
++cur; |
92 |
adx |
30 |
} |
93 |
|
|
|
94 |
|
|
if (max > 0 && cur >= max) |
95 |
|
|
break; |
96 |
|
|
} |
97 |
|
|
|
98 |
|
|
if (!cur) |
99 |
michael |
1832 |
sendto_one(source_p, ERR_WASNOSUCHNICK, |
100 |
adx |
30 |
me.name, source_p->name, nick); |
101 |
|
|
|
102 |
michael |
1832 |
sendto_one(source_p, RPL_ENDOFWHOWAS, |
103 |
adx |
30 |
me.name, source_p->name, parv[1]); |
104 |
|
|
} |
105 |
michael |
1230 |
|
106 |
|
|
/* |
107 |
|
|
** m_whowas |
108 |
|
|
** parv[0] = sender prefix |
109 |
|
|
** parv[1] = nickname queried |
110 |
|
|
*/ |
111 |
|
|
static void |
112 |
|
|
m_whowas(struct Client *client_p, struct Client *source_p, |
113 |
|
|
int parc, char *parv[]) |
114 |
|
|
{ |
115 |
|
|
static time_t last_used = 0; |
116 |
|
|
|
117 |
|
|
if (parc < 2 || EmptyString(parv[1])) |
118 |
|
|
{ |
119 |
michael |
1832 |
sendto_one(source_p, ERR_NONICKNAMEGIVEN, |
120 |
michael |
1230 |
me.name, source_p->name); |
121 |
|
|
return; |
122 |
|
|
} |
123 |
|
|
|
124 |
|
|
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime) |
125 |
|
|
{ |
126 |
michael |
1832 |
sendto_one(source_p, RPL_LOAD2HI, |
127 |
michael |
1230 |
me.name, source_p->name); |
128 |
|
|
return; |
129 |
|
|
} |
130 |
|
|
|
131 |
|
|
last_used = CurrentTime; |
132 |
|
|
|
133 |
|
|
whowas_do(client_p, source_p, parc, parv); |
134 |
|
|
} |
135 |
|
|
|
136 |
|
|
static void |
137 |
|
|
mo_whowas(struct Client *client_p, struct Client *source_p, |
138 |
|
|
int parc, char *parv[]) |
139 |
|
|
{ |
140 |
|
|
if (parc < 2 || EmptyString(parv[1])) |
141 |
|
|
{ |
142 |
michael |
1832 |
sendto_one(source_p, ERR_NONICKNAMEGIVEN, |
143 |
michael |
1230 |
me.name, source_p->name); |
144 |
|
|
return; |
145 |
|
|
} |
146 |
|
|
|
147 |
|
|
whowas_do(client_p, source_p, parc, parv); |
148 |
|
|
} |
149 |
|
|
|
150 |
|
|
static struct Message whowas_msgtab = { |
151 |
|
|
"WHOWAS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0, |
152 |
|
|
{ m_unregistered, m_whowas, mo_whowas, m_ignore, mo_whowas, m_ignore } |
153 |
|
|
}; |
154 |
|
|
|
155 |
|
|
static void |
156 |
|
|
module_init(void) |
157 |
|
|
{ |
158 |
|
|
mod_add_cmd(&whowas_msgtab); |
159 |
|
|
} |
160 |
|
|
|
161 |
|
|
static void |
162 |
|
|
module_exit(void) |
163 |
|
|
{ |
164 |
|
|
mod_del_cmd(&whowas_msgtab); |
165 |
|
|
} |
166 |
|
|
|
167 |
|
|
struct module module_entry = { |
168 |
|
|
.node = { NULL, NULL, NULL }, |
169 |
|
|
.name = NULL, |
170 |
|
|
.version = "$Revision$", |
171 |
|
|
.handle = NULL, |
172 |
|
|
.modinit = module_init, |
173 |
|
|
.modexit = module_exit, |
174 |
|
|
.flags = 0 |
175 |
|
|
}; |