ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_users.c
Revision: 470
Committed: Fri Feb 17 05:07:43 2006 UTC (19 years, 6 months ago) by db
Content type: text/x-csrc
File size: 3462 byte(s)
Log Message:
- fix compile errors with moved modules.h
- fix a few missing includes, msg.h and parse.h


File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * m_users.c: Gives some basic user statistics.
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 "handlers.h"
27 #include "client.h"
28 #include "ircd.h"
29 #include "numeric.h"
30 #include "s_serv.h"
31 #include "s_conf.h"
32 #include "send.h"
33 #include "msg.h"
34 #include "parse.h"
35 #include "conf/modules.h"
36
37 static void m_users(struct Client *, struct Client *, int, char *[]);
38 static void mo_users(struct Client *, struct Client *, int, char *[]);
39
40 struct Message users_msgtab = {
41 "USERS", 0, 0, 0, 0, MFLG_SLOW, 0,
42 { m_unregistered, m_users, mo_users, m_ignore, mo_users, m_ignore }
43 };
44
45 INIT_MODULE(m_users, "$Revision$")
46 {
47 mod_add_cmd(&users_msgtab);
48 }
49
50 CLEANUP_MODULE
51 {
52 mod_del_cmd(&users_msgtab);
53 }
54
55 /*
56 * m_users
57 * parv[0] = sender prefix
58 * parv[1] = servername
59 */
60 static void
61 m_users(struct Client *client_p, struct Client *source_p,
62 int parc, char *parv[])
63 {
64 static time_t last_used = 0;
65
66 if (last_used + ConfigFileEntry.pace_wait_simple > CurrentTime)
67 {
68 sendto_one(source_p, form_str(RPL_LOAD2HI), me.name, source_p->name);
69 return;
70 }
71
72 last_used = CurrentTime;
73
74 if (!ConfigFileEntry.disable_remote)
75 if (hunt_server(client_p, source_p, ":%s USERS :%s", 1,
76 parc, parv) != HUNTED_ISME)
77 return;
78
79 sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, source_p->name,
80 ConfigServerHide.hide_servers ? Count.total : Count.local,
81 ConfigServerHide.hide_servers ? Count.max_tot : Count.max_loc,
82 ConfigServerHide.hide_servers ? Count.total : Count.local,
83 ConfigServerHide.hide_servers ? Count.max_tot : Count.max_loc);
84
85 sendto_one(source_p, form_str(RPL_GLOBALUSERS), me.name, source_p->name,
86 Count.total, Count.max_tot, Count.total, Count.max_tot);
87 }
88
89 /*
90 * mo_users
91 * parv[0] = sender prefix
92 * parv[1] = servername
93 */
94 static void
95 mo_users(struct Client *client_p, struct Client *source_p,
96 int parc, char *parv[])
97 {
98 if (hunt_server(client_p, source_p, ":%s USERS :%s", 1,
99 parc, parv) != HUNTED_ISME)
100 return;
101
102 if (!IsOper(source_p) && ConfigServerHide.hide_servers)
103 sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, source_p->name,
104 Count.total, Count.max_tot, Count.total, Count.max_tot);
105 else
106 sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, source_p->name,
107 Count.local, Count.max_loc, Count.local, Count.max_loc);
108
109 sendto_one(source_p, form_str(RPL_GLOBALUSERS), me.name, source_p->name,
110 Count.total, Count.max_tot, Count.total, Count.max_tot);
111 }

Properties

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