ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_whowas.c
Revision: 1358
Committed: Sun Apr 22 13:49:23 2012 UTC (11 years, 11 months ago) by michael
Content type: text/x-csrc
File size: 4316 byte(s)
Log Message:
- cleanup and rewrite whowas.c to use the dlink list manipulation routines
- increase NICKNAMEHISTORYLENGTH to 16384

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

Properties

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