ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/modules/m_admin.c
Revision: 609
Committed: Tue May 16 10:42:05 2006 UTC (19 years, 3 months ago) by michael
Content type: text/x-csrc
File size: 6211 byte(s)
Log Message:
- Killed the client_p parameter of hunt_server() as suggested
  by adx some time ago.

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 db 470 #include "conf/modules.h"
36 adx 30
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 444 static void *do_admin(va_list);
41 adx 30
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 michael 347 static struct Callback *admin_cb = NULL;
48 adx 30
49 adx 442 INIT_MODULE(m_admin, "$Revision$")
50 adx 30 {
51 adx 444 admin_cb = register_callback("doing_admin", do_admin);
52 adx 30 mod_add_cmd(&admin_msgtab);
53     }
54    
55 adx 442 CLEANUP_MODULE
56 adx 30 {
57     mod_del_cmd(&admin_msgtab);
58 adx 444 uninstall_hook(admin_cb, do_admin);
59 adx 30 }
60    
61 michael 345 /*! \brief ADMIN command handler (called for unregistered clients only)
62     *
63     * \param client_p Pointer to allocated Client struct with physical connection
64     * to this server, i.e. with an open socket connected.
65     * \param source_p Pointer to allocated Client struct from which the message
66     * originally comes from. This can be a local or remote client.
67     * \param parc Integer holding the number of supplied arguments.
68     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
69     * pointers.
70     * \note Valid arguments for this command are:
71     * - parv[0] = sender prefix
72 michael 347 * - parv[1] = name of target (rejected for unregistered clients)
73 adx 30 */
74     static void
75     mr_admin(struct Client *client_p, struct Client *source_p,
76     int parc, char *parv[])
77     {
78     static time_t last_used = 0;
79 adx 270
80     if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
81 adx 30 {
82     sendto_one(source_p, form_str(RPL_LOAD2HI),
83     me.name, EmptyString(parv[0]) ? "*" : parv[0]);
84     return;
85     }
86    
87 michael 347 last_used = CurrentTime;
88    
89 adx 30 execute_callback(admin_cb, source_p, parc, parv);
90     }
91    
92 michael 345 /*! \brief ADMIN command handler (called for local clients only)
93     *
94     * \param client_p Pointer to allocated Client struct with physical connection
95     * to this server, i.e. with an open socket connected.
96     * \param source_p Pointer to allocated Client struct from which the message
97     * originally comes from. This can be a local or remote client.
98     * \param parc Integer holding the number of supplied arguments.
99     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
100     * pointers.
101     * \note Valid arguments for this command are:
102     * - parv[0] = sender prefix
103 michael 347 * - parv[1] = name of target (optional; string can be a nick or server
104     * and can also include wildcards)
105 adx 30 */
106     static void
107     m_admin(struct Client *client_p, struct Client *source_p,
108     int parc, char *parv[])
109     {
110     static time_t last_used = 0;
111    
112 adx 270 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
113 adx 30 {
114     sendto_one(source_p,form_str(RPL_LOAD2HI),
115     me.name, source_p->name);
116     return;
117     }
118    
119 michael 347 last_used = CurrentTime;
120    
121 adx 30 if (!ConfigFileEntry.disable_remote)
122 michael 609 if (hunt_server(source_p, ":%s ADMIN :%s", 1,
123 michael 347 parc, parv) != HUNTED_ISME)
124 adx 30 return;
125    
126     execute_callback(admin_cb, source_p, parc, parv);
127     }
128    
129 michael 345 /*! \brief ADMIN command handler (called for remote clients and servers)
130     *
131     * \param client_p Pointer to allocated Client struct with physical connection
132     * to this server, i.e. with an open socket connected.
133     * \param source_p Pointer to allocated Client struct from which the message
134     * originally comes from. This can be a local or remote client.
135     * \param parc Integer holding the number of supplied arguments.
136     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
137     * pointers.
138     * \note Valid arguments for this command are:
139     * - parv[0] = sender prefix
140 michael 347 * - parv[1] = name of target (optional; string can be a nick or server
141     * and can also include wildcards)
142 adx 30 */
143     static void
144     ms_admin(struct Client *client_p, struct Client *source_p,
145     int parc, char *parv[])
146     {
147 michael 609 if (hunt_server(source_p, ":%s ADMIN :%s", 1,
148 michael 347 parc, parv) != HUNTED_ISME)
149 adx 30 return;
150    
151     if (IsClient(source_p))
152     execute_callback(admin_cb, source_p, parc, parv);
153     }
154    
155     /* do_admin()
156     *
157     * inputs - pointer to client to report to
158     * output - none
159     * side effects - admin info is sent to client given
160     */
161 adx 444 static void *
162     do_admin(va_list args)
163 adx 30 {
164 adx 444 struct Client *source_p = va_arg(args, struct Client *);
165 adx 30 const char *me_name;
166     const char *nick;
167    
168     me_name = ID_or_name(&me, source_p->from);
169     nick = ID_or_name(source_p, source_p->from);
170    
171     sendto_one(source_p, form_str(RPL_ADMINME),
172 michael 347 me_name, nick, me.name);
173 adx 30 if (AdminInfo.name != NULL)
174     sendto_one(source_p, form_str(RPL_ADMINLOC1),
175 michael 347 me_name, nick, AdminInfo.name);
176 adx 30 if (AdminInfo.description != NULL)
177     sendto_one(source_p, form_str(RPL_ADMINLOC2),
178 michael 347 me_name, nick, AdminInfo.description);
179 adx 30 if (AdminInfo.email != NULL)
180     sendto_one(source_p, form_str(RPL_ADMINEMAIL),
181 michael 347 me_name, nick, AdminInfo.email);
182 adx 444
183     return NULL;
184 adx 30 }

Properties

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