ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_rehash.c
Revision: 5347
Committed: Sun Jan 11 12:42:20 2015 UTC (10 years, 7 months ago) by michael
Content type: text/x-csrc
File size: 3733 byte(s)
Log Message:
- Update copyright years

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 *
4 * Copyright (c) 1997-2015 ircd-hybrid development team
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 * USA
20 */
21
22 /*! \file m_rehash.c
23 * \brief Includes required functions for processing the REHASH command.
24 * \version $Id$
25 */
26
27 #include "stdinc.h"
28 #include "client.h"
29 #include "irc_string.h"
30 #include "ircd.h"
31 #include "list.h"
32 #include "numeric.h"
33 #include "res.h"
34 #include "conf.h"
35 #include "log.h"
36 #include "send.h"
37 #include "parse.h"
38 #include "modules.h"
39 #include "motd.h"
40
41
42 /*! \brief REHASH command handler
43 *
44 * \param source_p Pointer to allocated Client struct from which the message
45 * originally comes from. This can be a local or remote client.
46 * \param parc Integer holding the number of supplied arguments.
47 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
48 * pointers.
49 * \note Valid arguments for this command are:
50 * - parv[0] = command
51 * - parv[1] = additional option
52 */
53 static int
54 mo_rehash(struct Client *source_p, int parc, char *parv[])
55 {
56 int found = 0;
57 const char *const option = parv[1];
58
59 if (!HasOFlag(source_p, OPER_FLAG_REHASH))
60 {
61 sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "rehash");
62 return 0;
63 }
64
65 if (!EmptyString(option))
66 {
67 if (!irccmp(option, "DNS"))
68 {
69 sendto_one_numeric(source_p, &me, RPL_REHASHING, "DNS");
70 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
71 "%s is rehashing DNS",
72 get_oper_name(source_p));
73 restart_resolver();
74 found = 1;
75 }
76 else if (!irccmp(option, "MOTD"))
77 {
78 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
79 "%s is forcing re-reading of MOTD files",
80 get_oper_name(source_p));
81 motd_recache();
82 found = 1;
83 }
84
85 if (found)
86 ilog(LOG_TYPE_IRCD, "REHASH %s From %s",
87 option, get_oper_name(source_p));
88 else
89 sendto_one_notice(source_p, &me, ":%s is not a valid option. "
90 "Choose from DNS, MOTD", option);
91 }
92 else
93 {
94 sendto_one_numeric(source_p, &me, RPL_REHASHING, ConfigGeneral.configfile);
95 sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
96 "%s is rehashing configuration file(s)",
97 get_oper_name(source_p));
98 ilog(LOG_TYPE_IRCD, "REHASH From %s",
99 get_oper_name(source_p));
100 conf_rehash(0);
101 }
102
103 return 0;
104 }
105
106 static struct Message rehash_msgtab =
107 {
108 "REHASH", NULL, 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
109 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_rehash, m_ignore }
110 };
111
112 static void
113 module_init(void)
114 {
115 mod_add_cmd(&rehash_msgtab);
116 }
117
118 static void
119 module_exit(void)
120 {
121 mod_del_cmd(&rehash_msgtab);
122 }
123
124 struct module module_entry =
125 {
126 .node = { NULL, NULL, NULL },
127 .name = NULL,
128 .version = "$Revision$",
129 .handle = NULL,
130 .modinit = module_init,
131 .modexit = module_exit,
132 .flags = 0
133 };

Properties

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