/[svn]/ircd-hybrid-7.3/modules/m_admin.c
ViewVC logotype

Contents of /ircd-hybrid-7.3/modules/m_admin.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1029 - (show annotations)
Sun Nov 8 13:10:50 2009 UTC (10 years, 7 months ago) by michael
File MIME type: text/x-chdr
File size: 6400 byte(s)
- branch off trunk to create 7.3 branch
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 #ifndef STATIC_MODULES
52 static struct Callback *admin_cb;
53 const char *_version = "$Revision$";
54
55 static void *
56 va_admin(va_list args)
57 {
58 do_admin(va_arg(args, struct Client *));
59 return NULL;
60 }
61
62 void
63 _modinit(void)
64 {
65 admin_cb = register_callback("doing_admin", va_admin);
66 mod_add_cmd(&admin_msgtab);
67 }
68
69 void
70 _moddeinit(void)
71 {
72 mod_del_cmd(&admin_msgtab);
73 uninstall_hook(admin_cb, va_admin);
74 }
75 #endif
76
77 /*! \brief ADMIN command handler (called by unregistered,
78 * locally connected clients)
79 *
80 * \param client_p Pointer to allocated Client struct with physical connection
81 * to this server, i.e. with an open socket connected.
82 * \param source_p Pointer to allocated Client struct from which the message
83 * originally comes from. This can be a local or remote client.
84 * \param parc Integer holding the number of supplied arguments.
85 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
86 * pointers.
87 * \note Valid arguments for this command are:
88 * - parv[0] = sender prefix
89 */
90 static void
91 mr_admin(struct Client *client_p, struct Client *source_p,
92 int parc, char *parv[])
93 {
94 static time_t last_used = 0;
95
96 ClearCap(client_p, CAP_TS6);
97
98 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
99 {
100 sendto_one(source_p, form_str(RPL_LOAD2HI),
101 me.name, EmptyString(parv[0]) ? "*" : parv[0]);
102 return;
103 }
104
105 last_used = CurrentTime;
106
107 #ifdef STATIC_MODULES
108 do_admin(client_p);
109 #else
110 execute_callback(admin_cb, source_p, parc, parv);
111 #endif
112 }
113
114 /*! \brief NICK command handler (called by already registered,
115 * locally connected clients)
116 *
117 * \param client_p Pointer to allocated Client struct with physical connection
118 * to this server, i.e. with an open socket connected.
119 * \param source_p Pointer to allocated Client struct from which the message
120 * originally comes from. This can be a local or remote client.
121 * \param parc Integer holding the number of supplied arguments.
122 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
123 * pointers.
124 * \note Valid arguments for this command are:
125 * - parv[0] = sender prefix
126 * - parv[1] = nickname/servername
127 */
128 static void
129 m_admin(struct Client *client_p, struct Client *source_p,
130 int parc, char *parv[])
131 {
132 static time_t last_used = 0;
133
134 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
135 {
136 sendto_one(source_p,form_str(RPL_LOAD2HI),
137 me.name, source_p->name);
138 return;
139 }
140
141 last_used = CurrentTime;
142
143 if (!ConfigFileEntry.disable_remote)
144 if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1,
145 parc, parv) != HUNTED_ISME)
146 return;
147
148 #ifdef STATIC_MODULES
149 do_admin(client_p);
150 #else
151 execute_callback(admin_cb, source_p, parc, parv);
152 #endif
153 }
154
155 /*! \brief ADMIN command handler (called by operators and
156 * remotely connected clients)
157 *
158 * \param client_p Pointer to allocated Client struct with physical connection
159 * to this server, i.e. with an open socket connected.
160 * \param source_p Pointer to allocated Client struct from which the message
161 * originally comes from. This can be a local or remote client.
162 * \param parc Integer holding the number of supplied arguments.
163 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
164 * pointers.
165 * \note Valid arguments for this command are:
166 * - parv[0] = sender prefix
167 * - parv[1] = nickname/servername
168 */
169 static void
170 ms_admin(struct Client *client_p, struct Client *source_p,
171 int parc, char *parv[])
172 {
173 if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv)
174 != HUNTED_ISME)
175 return;
176
177 if (IsClient(source_p))
178 #ifdef STATIC_MODULES
179 do_admin(source_p);
180 #else
181 execute_callback(admin_cb, source_p, parc, parv);
182 #endif
183 }
184
185 /*! \brief Sends administrative information about this server.
186 *
187 * \param source_p Pointer to client to report to
188 */
189 static void
190 do_admin(struct Client *source_p)
191 {
192 const char *me_name;
193 const char *nick;
194
195 me_name = ID_or_name(&me, source_p->from);
196 nick = ID_or_name(source_p, source_p->from);
197
198 sendto_one(source_p, form_str(RPL_ADMINME),
199 me_name, nick, me.name);
200 if (AdminInfo.name != NULL)
201 sendto_one(source_p, form_str(RPL_ADMINLOC1),
202 me_name, nick, AdminInfo.name);
203 if (AdminInfo.description != NULL)
204 sendto_one(source_p, form_str(RPL_ADMINLOC2),
205 me_name, nick, AdminInfo.description);
206 if (AdminInfo.email != NULL)
207 sendto_one(source_p, form_str(RPL_ADMINEMAIL),
208 me_name, nick, AdminInfo.email);
209 }

Properties

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

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28