ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_admin.c
Revision: 2820
Committed: Wed Jan 15 23:10:26 2014 UTC (11 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 4926 byte(s)
Log Message:
- Clean up all files in modules/ (fixed indentation, removed whitespaces/tabs)
- Fixed copyright years
- Made module handlers int type for later use

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2820 * Copyright (c) 1997-2014 ircd-hybrid development team
5 adx 30 *
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 michael 1007 /*! \file m_admin.c
23     * \brief Includes required functions for processing the ADMIN command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28     #include "client.h"
29     #include "ircd.h"
30     #include "numeric.h"
31 michael 1309 #include "conf.h"
32 adx 30 #include "s_serv.h"
33     #include "send.h"
34     #include "parse.h"
35     #include "modules.h"
36     #include "irc_string.h"
37    
38    
39    
40 michael 1230 /*! \brief Sends administrative information about this server.
41     *
42     * \param source_p Pointer to client to report to
43     */
44 michael 2820 static int
45 michael 1230 do_admin(struct Client *source_p)
46 adx 30 {
47 michael 1568 const char *me_name = ID_or_name(&me, source_p->from);
48     const char *nick = ID_or_name(source_p, source_p->from);
49 adx 30
50 michael 1618 sendto_realops_flags(UMODE_SPY, L_ALL, SEND_NOTICE,
51 michael 1230 "ADMIN requested by %s (%s@%s) [%s]",
52     source_p->name, source_p->username,
53     source_p->host, source_p->servptr->name);
54    
55 michael 1834 sendto_one(source_p, form_str(RPL_ADMINME),
56 michael 1230 me_name, nick, me.name);
57 michael 1568
58 michael 1230 if (AdminInfo.name != NULL)
59 michael 1834 sendto_one(source_p, form_str(RPL_ADMINLOC1),
60 michael 1230 me_name, nick, AdminInfo.name);
61     if (AdminInfo.description != NULL)
62 michael 1834 sendto_one(source_p, form_str(RPL_ADMINLOC2),
63 michael 1230 me_name, nick, AdminInfo.description);
64     if (AdminInfo.email != NULL)
65 michael 1834 sendto_one(source_p, form_str(RPL_ADMINEMAIL),
66 michael 1230 me_name, nick, AdminInfo.email);
67 michael 2820 return 0;
68 adx 30 }
69    
70 michael 1007 /*! \brief NICK command handler (called by already registered,
71     * locally connected clients)
72     *
73     * \param client_p Pointer to allocated Client struct with physical connection
74     * to this server, i.e. with an open socket connected.
75     * \param source_p Pointer to allocated Client struct from which the message
76     * originally comes from. This can be a local or remote client.
77     * \param parc Integer holding the number of supplied arguments.
78     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
79     * pointers.
80     * \note Valid arguments for this command are:
81     * - parv[0] = sender prefix
82     * - parv[1] = nickname/servername
83 adx 30 */
84 michael 2820 static int
85 adx 30 m_admin(struct Client *client_p, struct Client *source_p,
86     int parc, char *parv[])
87     {
88     static time_t last_used = 0;
89    
90 adx 269 if ((last_used + ConfigFileEntry.pace_wait_simple) > CurrentTime)
91 adx 30 {
92 michael 1834 sendto_one(source_p,form_str(RPL_LOAD2HI),
93 adx 30 me.name, source_p->name);
94 michael 2820 return 0;
95 adx 30 }
96    
97 michael 589 last_used = CurrentTime;
98    
99 michael 2196 if (!ConfigServerHide.disable_remote_commands)
100 michael 589 if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1,
101     parc, parv) != HUNTED_ISME)
102 michael 2820 return 0;
103 adx 30
104 michael 2820 return do_admin(source_p);
105 adx 30 }
106    
107 michael 1007 /*! \brief ADMIN command handler (called by operators and
108     * remotely connected clients)
109     *
110     * \param client_p Pointer to allocated Client struct with physical connection
111     * to this server, i.e. with an open socket connected.
112     * \param source_p Pointer to allocated Client struct from which the message
113     * originally comes from. This can be a local or remote client.
114     * \param parc Integer holding the number of supplied arguments.
115     * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
116     * pointers.
117     * \note Valid arguments for this command are:
118     * - parv[0] = sender prefix
119     * - parv[1] = nickname/servername
120 adx 30 */
121 michael 2820 static int
122 adx 30 ms_admin(struct Client *client_p, struct Client *source_p,
123     int parc, char *parv[])
124     {
125 michael 1144 if (hunt_server(client_p, source_p, ":%s ADMIN :%s", 1,
126     parc, parv) != HUNTED_ISME)
127 michael 2820 return 0;
128 adx 30
129 michael 2820 return do_admin(source_p);
130 adx 30 }
131    
132 michael 2820 static struct Message admin_msgtab =
133     {
134 michael 1568 "ADMIN", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
135 michael 1569 { m_unregistered, m_admin, ms_admin, m_ignore, ms_admin, m_ignore }
136 michael 1230 };
137    
138 adx 30 static void
139 michael 1230 module_init(void)
140 adx 30 {
141 michael 1230 mod_add_cmd(&admin_msgtab);
142     }
143 adx 30
144 michael 1230 static void
145     module_exit(void)
146     {
147     mod_del_cmd(&admin_msgtab);
148     }
149 michael 1144
150 michael 2820 struct module module_entry =
151     {
152 michael 1230 .node = { NULL, NULL, NULL },
153     .name = NULL,
154     .version = "$Revision$",
155     .handle = NULL,
156     .modinit = module_init,
157     .modexit = module_exit,
158     .flags = 0
159     };

Properties

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