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

Annotation of /ircd-hybrid-7.2/modules/m_admin.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 34 - (hide annotations)
Sun Oct 2 21:05:51 2005 UTC (14 years, 9 months ago) by lusky
File MIME type: text/x-chdr
File size: 4561 byte(s)
create 7.2 branch, we can move/rename it as needed.


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 "hook.h"
36     #include "modules.h"
37     #include "irc_string.h"
38    
39     static void m_admin(struct Client *, struct Client *, int, char **);
40     static void mr_admin(struct Client *, struct Client *, int, char **);
41     static void ms_admin(struct Client *, struct Client *, int, char **);
42     static void do_admin(struct Client *);
43    
44     struct Message admin_msgtab = {
45     "ADMIN", 0, 0, 0, 0, MFLG_SLOW | MFLG_UNREG, 0,
46     {mr_admin, m_admin, ms_admin, m_ignore, ms_admin, m_ignore}
47     };
48    
49     #ifndef STATIC_MODULES
50     static struct Callback *admin_cb;
51 knight 31 const char *_version = "$Revision$";
52 adx 30
53     static void *
54     va_admin(va_list args)
55     {
56     do_admin(va_arg(args, struct Client *));
57     return NULL;
58     }
59    
60     void
61     _modinit(void)
62     {
63     admin_cb = register_callback("doing_admin", va_admin);
64     mod_add_cmd(&admin_msgtab);
65     }
66    
67     void
68     _moddeinit(void)
69     {
70     mod_del_cmd(&admin_msgtab);
71     uninstall_hook(admin_cb, va_admin);
72     }
73     #endif
74    
75     /*
76     * mr_admin - ADMIN command handler
77     * parv[0] = sender prefix
78     * parv[1] = servername
79     */
80     static void
81     mr_admin(struct Client *client_p, struct Client *source_p,
82     int parc, char *parv[])
83     {
84     static time_t last_used = 0;
85    
86     if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
87     {
88     sendto_one(source_p, form_str(RPL_LOAD2HI),
89     me.name, EmptyString(parv[0]) ? "*" : parv[0]);
90     return;
91     }
92     else
93     last_used = CurrentTime;
94    
95     #ifdef STATIC_MODULES
96     do_admin(client_p);
97     #else
98     execute_callback(admin_cb, source_p, parc, parv);
99     #endif
100     }
101    
102     /*
103     * m_admin - ADMIN command handler
104     * parv[0] = sender prefix
105     * parv[1] = servername
106     */
107     static void
108     m_admin(struct Client *client_p, struct Client *source_p,
109     int parc, char *parv[])
110     {
111     static time_t last_used = 0;
112    
113     if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
114     {
115     sendto_one(source_p,form_str(RPL_LOAD2HI),
116     me.name, source_p->name);
117     return;
118     }
119     else
120     last_used = CurrentTime;
121    
122     if (!ConfigFileEntry.disable_remote)
123     {
124     if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
125     return;
126     }
127    
128     #ifdef STATIC_MODULES
129     do_admin(client_p);
130     #else
131     execute_callback(admin_cb, source_p, parc, parv);
132     #endif
133     }
134    
135     /*
136     * ms_admin - ADMIN command handler, used for OPERS as well
137     * parv[0] = sender prefix
138     * parv[1] = servername
139     */
140     static void
141     ms_admin(struct Client *client_p, struct Client *source_p,
142     int parc, char *parv[])
143     {
144     if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1, parc, parv) != HUNTED_ISME)
145     return;
146    
147     if (IsClient(source_p))
148     #ifdef STATIC_MODULES
149     do_admin(source_p);
150     #else
151     execute_callback(admin_cb, source_p, parc, parv);
152     #endif
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     static void
162     do_admin(struct Client *source_p)
163     {
164     const char *me_name;
165     const char *nick;
166    
167     me_name = ID_or_name(&me, source_p->from);
168     nick = ID_or_name(source_p, source_p->from);
169    
170     sendto_one(source_p, form_str(RPL_ADMINME),
171     me_name, nick, me.name);
172     if (AdminInfo.name != NULL)
173     sendto_one(source_p, form_str(RPL_ADMINLOC1),
174     me_name, nick, AdminInfo.name);
175     if (AdminInfo.description != NULL)
176     sendto_one(source_p, form_str(RPL_ADMINLOC2),
177     me_name, nick, AdminInfo.description);
178     if (AdminInfo.email != NULL)
179     sendto_one(source_p, form_str(RPL_ADMINEMAIL),
180     me_name, nick, AdminInfo.email);
181     }

Properties

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

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