ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_admin.c
Revision: 345
Committed: Sat Dec 31 11:50:01 2005 UTC (20 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 6211 byte(s)
Log Message:
- Continue doxyfying modules

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_admin.c: Sends administrative information to a user.
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_conf.h"
31     #include "s_serv.h"
32     #include "send.h"
33     #include "msg.h"
34     #include "parse.h"
35     #include "modules.h"
36    
37     static void m_admin(struct Client *, struct Client *, int, char **);
38     static void mr_admin(struct Client *, struct Client *, int, char **);
39     static void ms_admin(struct Client *, struct Client *, int, char **);
40     static void do_admin(struct Client *);
41    
42     struct Message admin_msgtab = {
43     "ADMIN", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
44 michael 345 { mr_admin, m_admin, ms_admin, m_ignore, ms_admin, m_ignore }
45 adx 30 };
46    
47     #ifndef STATIC_MODULES
48     static struct Callback *admin_cb;
49 knight 31 const char *_version = "$Revision$";
50 adx 30
51     static void *
52     va_admin(va_list args)
53     {
54     do_admin(va_arg(args, struct Client *));
55     return NULL;
56     }
57    
58     void
59     _modinit(void)
60     {
61     admin_cb = register_callback("doing_admin", va_admin);
62     mod_add_cmd(&admin_msgtab);
63     }
64    
65     void
66     _moddeinit(void)
67     {
68     mod_del_cmd(&admin_msgtab);
69     uninstall_hook(admin_cb, va_admin);
70     }
71     #endif
72    
73 michael 345 /*! \brief ADMIN command handler (called for unregistered clients only)
74     *
75     * \param client_p Pointer to allocated Client struct with physical connection
76     * to this server, i.e. with an open socket connected.
77     * \param source_p Pointer to allocated Client struct from which the message
78     * originally comes from. This can be a local or remote client.
79     * \param parc Integer holding the number of supplied arguments.
80     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
81     * pointers.
82     * \note Valid arguments for this command are:
83     * - parv[0] = sender prefix
84     * - parv[1] = servername
85 adx 30 */
86     static void
87     mr_admin(struct Client *client_p, struct Client *source_p,
88     int parc, char *parv[])
89     {
90     static time_t last_used = 0;
91 adx 270
92     if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
93 adx 30 {
94     sendto_one(source_p, form_str(RPL_LOAD2HI),
95     me.name, EmptyString(parv[0]) ? "*" : parv[0]);
96     return;
97     }
98     else
99     last_used = CurrentTime;
100    
101     #ifdef STATIC_MODULES
102     do_admin(client_p);
103     #else
104     execute_callback(admin_cb, source_p, parc, parv);
105     #endif
106     }
107    
108 michael 345 /*! \brief ADMIN command handler (called for local clients only)
109     *
110     * \param client_p Pointer to allocated Client struct with physical connection
111     * to this server, i.e. with an open socket connected.
112     * \param source_p Pointer to allocated Client struct from which the message
113     * originally comes from. This can be a local or remote client.
114     * \param parc Integer holding the number of supplied arguments.
115     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
116     * pointers.
117     * \note Valid arguments for this command are:
118     * - parv[0] = sender prefix
119     * - parv[1] = servername
120 adx 30 */
121     static void
122     m_admin(struct Client *client_p, struct Client *source_p,
123     int parc, char *parv[])
124     {
125     static time_t last_used = 0;
126    
127 adx 270 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
128 adx 30 {
129     sendto_one(source_p,form_str(RPL_LOAD2HI),
130     me.name, source_p->name);
131     return;
132     }
133     else
134     last_used = CurrentTime;
135    
136     if (!ConfigFileEntry.disable_remote)
137     {
138     if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
139     return;
140     }
141    
142     #ifdef STATIC_MODULES
143     do_admin(client_p);
144     #else
145     execute_callback(admin_cb, source_p, parc, parv);
146     #endif
147     }
148    
149 michael 345 /*! \brief ADMIN command handler (called for remote clients and servers)
150     *
151     * \param client_p Pointer to allocated Client struct with physical connection
152     * to this server, i.e. with an open socket connected.
153     * \param source_p Pointer to allocated Client struct from which the message
154     * originally comes from. This can be a local or remote client.
155     * \param parc Integer holding the number of supplied arguments.
156     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
157     * pointers.
158     * \note Valid arguments for this command are:
159     * - parv[0] = sender prefix
160     * - parv[1] = servername
161 adx 30 */
162     static void
163     ms_admin(struct Client *client_p, struct Client *source_p,
164     int parc, char *parv[])
165     {
166     if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
167     return;
168    
169     if (IsClient(source_p))
170     #ifdef STATIC_MODULES
171     do_admin(source_p);
172     #else
173     execute_callback(admin_cb, source_p, parc, parv);
174     #endif
175     }
176    
177     /* do_admin()
178     *
179     * inputs - pointer to client to report to
180     * output - none
181     * side effects - admin info is sent to client given
182     */
183     static void
184     do_admin(struct Client *source_p)
185     {
186     const char *me_name;
187     const char *nick;
188    
189     me_name = ID_or_name(&me, source_p->from);
190     nick = ID_or_name(source_p, source_p->from);
191    
192     sendto_one(source_p, form_str(RPL_ADMINME),
193     me_name, nick, me.name);
194     if (AdminInfo.name != NULL)
195     sendto_one(source_p, form_str(RPL_ADMINLOC1),
196     me_name, nick, AdminInfo.name);
197     if (AdminInfo.description != NULL)
198     sendto_one(source_p, form_str(RPL_ADMINLOC2),
199     me_name, nick, AdminInfo.description);
200     if (AdminInfo.email != NULL)
201     sendto_one(source_p, form_str(RPL_ADMINEMAIL),
202     me_name, nick, AdminInfo.email);
203     }

Properties

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