ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_users.c
Revision: 1230
Committed: Thu Sep 22 19:41:19 2011 UTC (14 years, 10 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_users.c
File size: 3570 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_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 knight 31 * $Id$
23 adx 30 */
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 "modules.h"
36    
37    
38     /*
39     * m_users
40     * parv[0] = sender prefix
41     * parv[1] = servername
42     */
43     static void
44     m_users(struct Client *client_p, struct Client *source_p,
45     int parc, char *parv[])
46     {
47 adx 269 static time_t last_used = 0;
48    
49     if (last_used + ConfigFileEntry.pace_wait_simple > CurrentTime)
50     {
51 michael 1121 sendto_one(source_p, form_str(RPL_LOAD2HI),
52     me.name, source_p->name);
53 adx 269 return;
54     }
55    
56 michael 435 last_used = CurrentTime;
57    
58 adx 30 if (!ConfigFileEntry.disable_remote)
59     if (hunt_server(client_p, source_p, ":%s USERS :%s", 1,
60     parc, parv) != HUNTED_ISME)
61     return;
62    
63     sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, source_p->name,
64     ConfigServerHide.hide_servers ? Count.total : Count.local,
65 michael 435 ConfigServerHide.hide_servers ? Count.max_tot : Count.max_loc,
66 adx 30 ConfigServerHide.hide_servers ? Count.total : Count.local,
67 adx 268 ConfigServerHide.hide_servers ? Count.max_tot : Count.max_loc);
68 adx 30
69     sendto_one(source_p, form_str(RPL_GLOBALUSERS), me.name, source_p->name,
70     Count.total, Count.max_tot, Count.total, Count.max_tot);
71     }
72    
73     /*
74     * mo_users
75     * parv[0] = sender prefix
76     * parv[1] = servername
77     */
78     static void
79     mo_users(struct Client *client_p, struct Client *source_p,
80     int parc, char *parv[])
81     {
82     if (hunt_server(client_p, source_p, ":%s USERS :%s", 1,
83 michael 435 parc, parv) != HUNTED_ISME)
84 adx 30 return;
85    
86 michael 1219 if (!HasUMode(source_p, UMODE_OPER) && ConfigServerHide.hide_servers)
87 adx 30 sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, source_p->name,
88     Count.total, Count.max_tot, Count.total, Count.max_tot);
89     else
90     sendto_one(source_p, form_str(RPL_LOCALUSERS), me.name, source_p->name,
91     Count.local, Count.max_loc, Count.local, Count.max_loc);
92    
93     sendto_one(source_p, form_str(RPL_GLOBALUSERS), me.name, source_p->name,
94     Count.total, Count.max_tot, Count.total, Count.max_tot);
95     }
96 michael 1230
97     static struct Message users_msgtab = {
98     "USERS", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
99     { m_unregistered, m_users, mo_users, m_ignore, mo_users, m_ignore }
100     };
101    
102     static void
103     module_init(void)
104     {
105     mod_add_cmd(&users_msgtab);
106     }
107    
108     static void
109     module_exit(void)
110     {
111     mod_del_cmd(&users_msgtab);
112     }
113    
114     struct module module_entry = {
115     .node = { NULL, NULL, NULL },
116     .name = NULL,
117     .version = "$Revision$",
118     .handle = NULL,
119     .modinit = module_init,
120     .modexit = module_exit,
121     .flags = 0
122     };

Properties

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