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

# Content
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 "list.h"
27 #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 #include "conf.h"
38 #include "parse.h"
39 #include "modules.h"
40
41
42 static void
43 whowas_do(struct Client *client_p, struct Client *source_p,
44 const int parc, char *parv[])
45 {
46 int cur = 0;
47 int max = -1;
48 char *p = NULL, *nick = NULL;
49 const dlink_node *ptr = NULL;
50
51 if (parc > 2)
52 {
53 max = atoi(parv[2]);
54
55 if (!MyConnect(source_p) && max > 20)
56 max = 20;
57 }
58
59 if (parc > 3)
60 if (hunt_server(client_p, source_p, ":%s WHOWAS %s %s :%s", 3,
61 parc, parv) != HUNTED_ISME)
62 return;
63
64 nick = parv[1];
65 if ((p = strchr(nick,',')) != NULL)
66 *p = '\0';
67 if (*nick == '\0')
68 return;
69
70 DLINK_FOREACH(ptr, WHOWASHASH[strhash(nick)].head)
71 {
72 const struct Whowas *temp = ptr->data;
73
74 if (!irccmp(nick, temp->name))
75 {
76 sendto_one(source_p, form_str(RPL_WHOWASUSER),
77 me.name, source_p->name, temp->name,
78 temp->username, temp->hostname,
79 temp->realname);
80
81 if (ConfigServerHide.hide_servers && !HasUMode(source_p, UMODE_OPER))
82 sendto_one(source_p, form_str(RPL_WHOISSERVER),
83 me.name, source_p->name, temp->name,
84 ServerInfo.network_name, myctime(temp->logoff));
85 else
86 sendto_one(source_p, form_str(RPL_WHOISSERVER),
87 me.name, source_p->name, temp->name,
88 temp->servername, myctime(temp->logoff));
89 ++cur;
90 }
91
92 if (max > 0 && cur >= max)
93 break;
94 }
95
96 if (!cur)
97 sendto_one(source_p, form_str(ERR_WASNOSUCHNICK),
98 me.name, source_p->name, nick);
99
100 sendto_one(source_p, form_str(RPL_ENDOFWHOWAS),
101 me.name, source_p->name, parv[1]);
102 }
103
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 sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
118 me.name, source_p->name);
119 return;
120 }
121
122 if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
123 {
124 sendto_one(source_p,form_str(RPL_LOAD2HI),
125 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 sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN),
141 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