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

Annotation of /ircd-hybrid-7.2/modules/m_whowas.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 143 - (hide annotations)
Sun Oct 16 09:49:16 2005 UTC (14 years, 11 months ago) by michael
File MIME type: text/x-chdr
File size: 4313 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.

  (Backported from HEAD)

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

Properties

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

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