ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/releases/8.0.6/modules/m_whowas.c
Revision: 1230
Committed: Thu Sep 22 19:41:19 2011 UTC (15 years ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_whowas.c
File size: 4332 byte(s)
Log Message:
- cleanup module loader. Make module api more flexible

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

Properties

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