/[svn]/ircd-hybrid/modules/m_whowas.c
ViewVC logotype

Contents of /ircd-hybrid/modules/m_whowas.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 142 - (show annotations)
Sun Oct 16 09:46:29 2005 UTC (14 years, 11 months ago) by michael
File MIME type: text/x-chdr
File size: 4283 byte(s)
- Fixed a bug where remoteservers would send us an ERROR
  on "WHOWAS nick count remoteserver.net".  Propably one
  of the oldest bugs that got introduced in 7.0.

1 /*
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 * $Id$
23 */
24
25 #include "stdinc.h"
26 #include "whowas.h"
27 #include "handlers.h"
28 #include "client.h"
29 #include "common.h"
30 #include "hash.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"
41
42
43 static void m_whowas(struct Client *, struct Client *, int, char *[]);
44 static void mo_whowas(struct Client *, struct Client *, int, char *[]);
45 static void whowas_do(struct Client *, struct Client *, int, char *[]);
46
47 struct Message whowas_msgtab = {
48 "WHOWAS", 0, 0, 0, 0, MFLG_SLOW, 0,
49 { m_unregistered, m_whowas, mo_whowas, m_ignore, mo_whowas, m_ignore }
50 };
51
52 #ifndef STATIC_MODULES
53 void
54 _modinit(void)
55 {
56 mod_add_cmd(&whowas_msgtab);
57 }
58
59 void
60 _moddeinit(void)
61 {
62 mod_del_cmd(&whowas_msgtab);
63 }
64
65 const char *_version = "$Revision$";
66 #endif
67
68 /*
69 ** m_whowas
70 ** parv[0] = sender prefix
71 ** parv[1] = nickname queried
72 */
73 static void
74 m_whowas(struct Client *client_p, struct Client *source_p,
75 int parc, char *parv[])
76 {
77 static time_t last_used = 0;
78
79 if (parc < 2 || *parv[1] == '\0')
80 {
81 sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
82 me.name, source_p->name);
83 return;
84 }
85
86 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
87 {
88 sendto_one(source_p,form_str(RPL_LOAD2HI),
89 me.name, source_p->name);
90 return;
91 }
92 else
93 last_used = CurrentTime;
94
95 whowas_do(client_p, source_p, parc, parv);
96 }
97
98 static void
99 mo_whowas(struct Client *client_p, struct Client *source_p,
100 int parc, char *parv[])
101 {
102 if (parc < 2 || *parv[1] == '\0')
103 {
104 sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
105 me.name, source_p->name);
106 return;
107 }
108
109 whowas_do(client_p, source_p, parc, parv);
110 }
111
112 static void
113 whowas_do(struct Client *client_p, struct Client *source_p,
114 int parc, char *parv[])
115 {
116 struct Whowas *temp = NULL;
117 int cur = 0;
118 int max = -1;
119 char *p = NULL, *nick = NULL;
120
121 if (parc > 2)
122 max = atoi(parv[2]);
123
124 if (parc > 3)
125 if (hunt_server(client_p, source_p, ":%s WHOWAS %s %s :%s", 3,
126 parc, parv) != HUNTED_ISME)
127 return;
128
129 nick = parv[1];
130 while (*nick == ',')
131 nick++;
132 if ((p = strchr(nick,',')) != NULL)
133 *p = '\0';
134 if (*nick == '\0')
135 return;
136
137 for (temp = WHOWASHASH[strhash(nick)]; temp; temp = temp->next)
138 {
139 if (irccmp(nick, temp->name) == 0)
140 {
141 sendto_one(source_p, form_str(RPL_WHOWASUSER),
142 me.name, source_p->name, temp->name,
143 temp->username, temp->hostname,
144 temp->realname);
145
146 if (ConfigServerHide.hide_servers && !IsOper(source_p))
147 sendto_one(source_p, form_str(RPL_WHOISSERVER),
148 me.name, source_p->name, temp->name,
149 ServerInfo.network_name, myctime(temp->logoff));
150 else
151 sendto_one(source_p, form_str(RPL_WHOISSERVER),
152 me.name, source_p->name, temp->name,
153 temp->servername, myctime(temp->logoff));
154 ++cur;
155 }
156
157 if (max > 0 && cur >= max)
158 break;
159 }
160
161 if (!cur)
162 sendto_one(source_p, form_str(ERR_WASNOSUCHNICK),
163 me.name, source_p->name, nick);
164
165 sendto_one(source_p, form_str(RPL_ENDOFWHOWAS),
166 me.name, source_p->name, parv[1]);
167 }

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28