ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_whowas.c
Revision: 1876
Committed: Sat Apr 27 09:36:33 2013 UTC (13 years, 5 months ago) by michael
Content type: text/x-csrc
File size: 4287 byte(s)
Log Message:
- m_whowas.c,m_names.c,m_kick.c: remove pointless code. There's no real reason why
  we should skip preceding commas in nick-/channelnames

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 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 michael 1857 const int parc, char *parv[])
45 adx 30 {
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     if ((p = strchr(nick,',')) != NULL)
66     *p = '\0';
67     if (*nick == '\0')
68     return;
69    
70 michael 1358 DLINK_FOREACH(ptr, WHOWASHASH[strhash(nick)].head)
71     {
72     const struct Whowas *temp = ptr->data;
73 adx 30
74 michael 1121 if (!irccmp(nick, temp->name))
75 adx 30 {
76 michael 1834 sendto_one(source_p, form_str(RPL_WHOWASUSER),
77 adx 30 me.name, source_p->name, temp->name,
78     temp->username, temp->hostname,
79     temp->realname);
80    
81 michael 1219 if (ConfigServerHide.hide_servers && !HasUMode(source_p, UMODE_OPER))
82 michael 1834 sendto_one(source_p, form_str(RPL_WHOISSERVER),
83 adx 30 me.name, source_p->name, temp->name,
84     ServerInfo.network_name, myctime(temp->logoff));
85     else
86 michael 1834 sendto_one(source_p, form_str(RPL_WHOISSERVER),
87 adx 30 me.name, source_p->name, temp->name,
88     temp->servername, myctime(temp->logoff));
89 michael 1358 ++cur;
90 adx 30 }
91    
92     if (max > 0 && cur >= max)
93     break;
94     }
95    
96     if (!cur)
97 michael 1834 sendto_one(source_p, form_str(ERR_WASNOSUCHNICK),
98 adx 30 me.name, source_p->name, nick);
99    
100 michael 1834 sendto_one(source_p, form_str(RPL_ENDOFWHOWAS),
101 adx 30 me.name, source_p->name, parv[1]);
102     }
103 michael 1230
104     /*
105     ** m_whowas
106     ** parv[0] = sender prefix
107     ** parv[1] = nickname queried
108     */
109     static void
110     m_whowas(struct Client *client_p, struct Client *source_p,
111     int parc, char *parv[])
112     {
113     static time_t last_used = 0;
114    
115     if (parc < 2 || EmptyString(parv[1]))
116     {
117 michael 1834 sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
118 michael 1230 me.name, source_p->name);
119     return;
120     }
121    
122     if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
123     {
124 michael 1834 sendto_one(source_p,form_str(RPL_LOAD2HI),
125 michael 1230 me.name, source_p->name);
126     return;
127     }
128    
129     last_used = CurrentTime;
130    
131     whowas_do(client_p, source_p, parc, parv);
132     }
133    
134     static void
135     mo_whowas(struct Client *client_p, struct Client *source_p,
136     int parc, char *parv[])
137     {
138     if (parc < 2 || EmptyString(parv[1]))
139     {
140 michael 1834 sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
141 michael 1230 me.name, source_p->name);
142     return;
143     }
144    
145     whowas_do(client_p, source_p, parc, parv);
146     }
147    
148     static struct Message whowas_msgtab = {
149     "WHOWAS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
150     { m_unregistered, m_whowas, mo_whowas, m_ignore, mo_whowas, m_ignore }
151     };
152    
153     static void
154     module_init(void)
155     {
156     mod_add_cmd(&whowas_msgtab);
157     }
158    
159     static void
160     module_exit(void)
161     {
162     mod_del_cmd(&whowas_msgtab);
163     }
164    
165     struct module module_entry = {
166     .node = { NULL, NULL, NULL },
167     .name = NULL,
168     .version = "$Revision$",
169     .handle = NULL,
170     .modinit = module_init,
171     .modexit = module_exit,
172     .flags = 0
173     };

Properties

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