ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-7.3/modules/m_admin.c
Revision: 1121
Committed: Sun Jan 9 11:03:03 2011 UTC (13 years, 2 months ago) by michael
Content type: text/x-csrc
File size: 6197 byte(s)
Log Message:
- removed all instances of STATIC_MODULES since we don't have
  static modules anymore
- removed m_mkpasswd module from contrib

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 *
4 * Copyright (C) 2002 by the past and present ircd coders, and others.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA
20 */
21
22 /*! \file m_admin.c
23 * \brief Includes required functions for processing the ADMIN command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "handlers.h"
29 #include "client.h"
30 #include "ircd.h"
31 #include "numeric.h"
32 #include "s_conf.h"
33 #include "s_serv.h"
34 #include "send.h"
35 #include "msg.h"
36 #include "parse.h"
37 #include "hook.h"
38 #include "modules.h"
39 #include "irc_string.h"
40
41 static void m_admin(struct Client *, struct Client *, int, char *[]);
42 static void mr_admin(struct Client *, struct Client *, int, char *[]);
43 static void ms_admin(struct Client *, struct Client *, int, char *[]);
44 static void do_admin(struct Client *);
45
46 struct Message admin_msgtab = {
47 "ADMIN", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
48 {mr_admin, m_admin, ms_admin, m_ignore, ms_admin, m_ignore}
49 };
50
51 static struct Callback *admin_cb;
52 const char *_version = "$Revision$";
53
54 static void *
55 va_admin(va_list args)
56 {
57 do_admin(va_arg(args, struct Client *));
58 return NULL;
59 }
60
61 void
62 _modinit(void)
63 {
64 admin_cb = register_callback("doing_admin", va_admin);
65 mod_add_cmd(&admin_msgtab);
66 }
67
68 void
69 _moddeinit(void)
70 {
71 mod_del_cmd(&admin_msgtab);
72 uninstall_hook(admin_cb, va_admin);
73 }
74
75 /*! \brief ADMIN command handler (called by unregistered,
76 * locally connected clients)
77 *
78 * \param client_p Pointer to allocated Client struct with physical connection
79 * to this server, i.e. with an open socket connected.
80 * \param source_p Pointer to allocated Client struct from which the message
81 * originally comes from. This can be a local or remote client.
82 * \param parc Integer holding the number of supplied arguments.
83 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
84 * pointers.
85 * \note Valid arguments for this command are:
86 * - parv[0] = sender prefix
87 */
88 static void
89 mr_admin(struct Client *client_p, struct Client *source_p,
90 int parc, char *parv[])
91 {
92 static time_t last_used = 0;
93
94 ClearCap(client_p, CAP_TS6);
95
96 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
97 {
98 sendto_one(source_p, form_str(RPL_LOAD2HI),
99 me.name, EmptyString(parv[0]) ? "*" : parv[0]);
100 return;
101 }
102
103 last_used = CurrentTime;
104
105 execute_callback(admin_cb, source_p, parc, parv);
106 }
107
108 /*! \brief NICK command handler (called by already registered,
109 * locally connected clients)
110 *
111 * \param client_p Pointer to allocated Client struct with physical connection
112 * to this server, i.e. with an open socket connected.
113 * \param source_p Pointer to allocated Client struct from which the message
114 * originally comes from. This can be a local or remote client.
115 * \param parc Integer holding the number of supplied arguments.
116 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
117 * pointers.
118 * \note Valid arguments for this command are:
119 * - parv[0] = sender prefix
120 * - parv[1] = nickname/servername
121 */
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 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
129 {
130 sendto_one(source_p,form_str(RPL_LOAD2HI),
131 me.name, source_p->name);
132 return;
133 }
134
135 last_used = CurrentTime;
136
137 if (!ConfigFileEntry.disable_remote)
138 if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1,
139 parc, parv) != HUNTED_ISME)
140 return;
141
142 execute_callback(admin_cb, source_p, parc, parv);
143 }
144
145 /*! \brief ADMIN command handler (called by operators and
146 * remotely connected clients)
147 *
148 * \param client_p Pointer to allocated Client struct with physical connection
149 * to this server, i.e. with an open socket connected.
150 * \param source_p Pointer to allocated Client struct from which the message
151 * originally comes from. This can be a local or remote client.
152 * \param parc Integer holding the number of supplied arguments.
153 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
154 * pointers.
155 * \note Valid arguments for this command are:
156 * - parv[0] = sender prefix
157 * - parv[1] = nickname/servername
158 */
159 static void
160 ms_admin(struct Client *client_p, struct Client *source_p,
161 int parc, char *parv[])
162 {
163 if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv)
164 != HUNTED_ISME)
165 return;
166
167 if (IsClient(source_p))
168 execute_callback(admin_cb, source_p, parc, parv);
169 }
170
171 /*! \brief Sends administrative information about this server.
172 *
173 * \param source_p Pointer to client to report to
174 */
175 static void
176 do_admin(struct Client *source_p)
177 {
178 const char *me_name;
179 const char *nick;
180
181 me_name = ID_or_name(&me, source_p->from);
182 nick = ID_or_name(source_p, source_p->from);
183
184 sendto_one(source_p, form_str(RPL_ADMINME),
185 me_name, nick, me.name);
186 if (AdminInfo.name != NULL)
187 sendto_one(source_p, form_str(RPL_ADMINLOC1),
188 me_name, nick, AdminInfo.name);
189 if (AdminInfo.description != NULL)
190 sendto_one(source_p, form_str(RPL_ADMINLOC2),
191 me_name, nick, AdminInfo.description);
192 if (AdminInfo.email != NULL)
193 sendto_one(source_p, form_str(RPL_ADMINEMAIL),
194 me_name, nick, AdminInfo.email);
195 }

Properties

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