ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_admin.c
Revision: 347
Committed: Sat Dec 31 13:22:28 2005 UTC (20 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 6499 byte(s)
Log Message:
- m_admin.c: fixed comment about parv[1].  Also did some style cleanups

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 michael 347 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 adx 30 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 michael 347 static struct Callback *admin_cb = NULL;
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 michael 347 * - parv[1] = name of target (rejected for unregistered clients)
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    
99 michael 347 last_used = CurrentTime;
100    
101 adx 30 #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 michael 347 * - parv[1] = name of target (optional; string can be a nick or server
120     * and can also include wildcards)
121 adx 30 */
122     static void
123     m_admin(struct Client *client_p, struct Client *source_p,
124     int parc, char *parv[])
125     {
126     static time_t last_used = 0;
127    
128 adx 270 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
129 adx 30 {
130     sendto_one(source_p,form_str(RPL_LOAD2HI),
131     me.name, source_p->name);
132     return;
133     }
134    
135 michael 347 last_used = CurrentTime;
136    
137 adx 30 if (!ConfigFileEntry.disable_remote)
138 michael 347 if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1,
139     parc, parv) != HUNTED_ISME)
140 adx 30 return;
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 michael 347 * - parv[1] = name of target (optional; string can be a nick or server
161     * and can also include wildcards)
162 adx 30 */
163     static void
164     ms_admin(struct Client *client_p, struct Client *source_p,
165     int parc, char *parv[])
166     {
167 michael 347 if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1,
168     parc, parv) != HUNTED_ISME)
169 adx 30 return;
170    
171     if (IsClient(source_p))
172     #ifdef STATIC_MODULES
173     do_admin(source_p);
174     #else
175     execute_callback(admin_cb, source_p, parc, parv);
176     #endif
177     }
178    
179     /* do_admin()
180     *
181     * inputs - pointer to client to report to
182     * output - none
183     * side effects - admin info is sent to client given
184     */
185     static void
186     do_admin(struct Client *source_p)
187     {
188     const char *me_name;
189     const char *nick;
190    
191     me_name = ID_or_name(&me, source_p->from);
192     nick = ID_or_name(source_p, source_p->from);
193    
194     sendto_one(source_p, form_str(RPL_ADMINME),
195 michael 347 me_name, nick, me.name);
196 adx 30 if (AdminInfo.name != NULL)
197     sendto_one(source_p, form_str(RPL_ADMINLOC1),
198 michael 347 me_name, nick, AdminInfo.name);
199 adx 30 if (AdminInfo.description != NULL)
200     sendto_one(source_p, form_str(RPL_ADMINLOC2),
201 michael 347 me_name, nick, AdminInfo.description);
202 adx 30 if (AdminInfo.email != NULL)
203     sendto_one(source_p, form_str(RPL_ADMINEMAIL),
204 michael 347 me_name, nick, AdminInfo.email);
205 adx 30 }

Properties

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