ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_whowas.c
Revision: 31
Committed: Sun Oct 2 20:34:05 2005 UTC (18 years, 6 months ago) by knight
Content type: text/x-csrc
File size: 4261 byte(s)
Log Message:
- Fix svn:keywords

File Contents

# User Rev Content
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     { m_unregistered, m_whowas, m_error, m_ignore, mo_whowas, m_ignore }
51     };
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     char *p, *nick;
121    
122     if (parc > 2)
123     max = atoi(parv[2]);
124     if (parc > 3)
125     if (hunt_server(client_p, source_p, ":%s WHOWAS %s %s :%s", 3, parc, parv))
126     return;
127    
128     nick = parv[1];
129     while (*nick == ',')
130     nick++;
131     if ((p = strchr(nick,',')) != NULL)
132     *p = '\0';
133     if (*nick == '\0')
134     return;
135    
136     temp = WHOWASHASH[strhash(nick)];
137    
138     for (; temp; temp = temp->next)
139     {
140     if (irccmp(nick, temp->name) == 0)
141     {
142     sendto_one(source_p, form_str(RPL_WHOWASUSER),
143     me.name, source_p->name, temp->name,
144     temp->username, temp->hostname,
145     temp->realname);
146    
147     if (ConfigServerHide.hide_servers && !IsOper(source_p))
148     sendto_one(source_p, form_str(RPL_WHOISSERVER),
149     me.name, source_p->name, temp->name,
150     ServerInfo.network_name, myctime(temp->logoff));
151     else
152     sendto_one(source_p, form_str(RPL_WHOISSERVER),
153     me.name, source_p->name, temp->name,
154     temp->servername, myctime(temp->logoff));
155     cur++;
156     }
157    
158     if (max > 0 && cur >= max)
159     break;
160     }
161    
162     if (!cur)
163     sendto_one(source_p, form_str(ERR_WASNOSUCHNICK),
164     me.name, source_p->name, nick);
165    
166     sendto_one(source_p, form_str(RPL_ENDOFWHOWAS),
167     me.name, source_p->name, parv[1]);
168     }

Properties

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