]> jfr.im git - irc/rqf/shadowircd.git/blame - modules/m_admin.c
Removal of ancient SVN ID's part one
[irc/rqf/shadowircd.git] / modules / m_admin.c
CommitLineData
212380e3 1/*
2 * ircd-ratbox: A slightly useful ircd.
3 * m_admin.c: Sends administrative information to a user.
4 *
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 * USA
23 *
212380e3 24 */
25
26#include "stdinc.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 "hook.h"
36#include "modules.h"
37
38static int m_admin(struct Client *, struct Client *, int, const char **);
39static int mr_admin(struct Client *, struct Client *, int, const char **);
40static int ms_admin(struct Client *, struct Client *, int, const char **);
41static void do_admin(struct Client *source_p);
42
43static void admin_spy(struct Client *);
44
45struct Message admin_msgtab = {
46 "ADMIN", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
47 {{mr_admin, 0}, {m_admin, 0}, {ms_admin, 0}, mg_ignore, mg_ignore, {ms_admin, 0}}
48};
49
50int doing_admin_hook;
51
52mapi_clist_av1 admin_clist[] = { &admin_msgtab, NULL };
53mapi_hlist_av1 admin_hlist[] = {
54 { "doing_admin", &doing_admin_hook },
55 { NULL, NULL }
56};
57
88520303 58DECLARE_MODULE_AV1(admin, NULL, NULL, admin_clist, admin_hlist, NULL, "$Revision: 3368 $");
212380e3 59
60/*
61 * mr_admin - ADMIN command handler
212380e3 62 * parv[1] = servername
63 */
64static int
65mr_admin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
66{
67 static time_t last_used = 0L;
68
9f6bbe3c 69 if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
212380e3 70 {
71 sendto_one(source_p, form_str(RPL_LOAD2HI),
72 me.name,
73 EmptyString(source_p->name) ? "*" : source_p->name,
74 "ADMIN");
75 return 0;
76 }
77 else
9f6bbe3c 78 last_used = rb_current_time();
212380e3 79
80 do_admin(source_p);
81
82 return 0;
83}
84
85/*
86 * m_admin - ADMIN command handler
212380e3 87 * parv[1] = servername
88 */
89static int
90m_admin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
91{
92 static time_t last_used = 0L;
93
94 if(parc > 1)
95 {
9f6bbe3c 96 if((last_used + ConfigFileEntry.pace_wait) > rb_current_time())
212380e3 97 {
98 sendto_one(source_p, form_str(RPL_LOAD2HI),
99 me.name, source_p->name, "ADMIN");
100 return 0;
101 }
102 else
9f6bbe3c 103 last_used = rb_current_time();
212380e3 104
105 if(hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
106 return 0;
107 }
108
109 do_admin(source_p);
110
111 return 0;
112}
113
114
115/*
116 * ms_admin - ADMIN command handler, used for OPERS as well
212380e3 117 * parv[1] = servername
118 */
119static int
120ms_admin(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
121{
122 if(hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
123 return 0;
124
125 do_admin(source_p);
126
127 return 0;
128}
129
130
131/*
132 * do_admin
133 *
134 * inputs - pointer to client to report to
135 * output - none
136 * side effects - admin info is sent to client given
137 */
138static void
139do_admin(struct Client *source_p)
140{
212380e3 141 if(IsPerson(source_p))
142 admin_spy(source_p);
143
88520303 144 sendto_one_numeric(source_p, RPL_ADMINME, form_str(RPL_ADMINME), me.name);
212380e3 145 if(AdminInfo.name != NULL)
88520303 146 sendto_one_numeric(source_p, RPL_ADMINLOC1, form_str(RPL_ADMINLOC1), AdminInfo.name);
212380e3 147 if(AdminInfo.description != NULL)
88520303 148 sendto_one_numeric(source_p, RPL_ADMINLOC2, form_str(RPL_ADMINLOC2), AdminInfo.description);
212380e3 149 if(AdminInfo.email != NULL)
88520303 150 sendto_one_numeric(source_p, RPL_ADMINEMAIL, form_str(RPL_ADMINEMAIL), AdminInfo.email);
212380e3 151}
152
153/* admin_spy()
154 *
155 * input - pointer to client
156 * output - none
157 * side effects - event doing_admin is called
158 */
159static void
160admin_spy(struct Client *source_p)
161{
162 hook_data hd;
163
164 hd.client = source_p;
165 hd.arg1 = hd.arg2 = NULL;
166
167 call_hook(doing_admin_hook, &hd);
168}