ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/modules/m_rehash.c
Revision: 1230
Committed: Thu Sep 22 19:41:19 2011 UTC (14 years, 10 months ago) by michael
Content type: text/x-csrc
File size: 4102 byte(s)
Log Message:
- cleanup module loader. Make module api more flexible

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_rehash.c: Re-reads the configuration file.
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 "common.h"
29     #include "irc_string.h"
30     #include "ircd.h"
31     #include "list.h"
32     #include "numeric.h"
33     #include "irc_res.h"
34     #include "s_conf.h"
35     #include "s_log.h"
36     #include "send.h"
37     #include "msg.h"
38     #include "parse.h"
39     #include "modules.h"
40    
41    
42     /*
43     * mo_rehash - REHASH message handler
44     *
45     */
46     static void
47     mo_rehash(struct Client *client_p, struct Client *source_p,
48     int parc, char *parv[])
49     {
50     int found = 0;
51    
52 michael 1219 if (!HasOFlag(source_p, OPER_FLAG_REHASH))
53 adx 30 {
54     sendto_one(source_p, form_str(ERR_NOPRIVS),
55     me.name, source_p->name, "rehash");
56     return;
57     }
58    
59     if (parc > 1)
60     {
61     if (irccmp(parv[1], "DNS") == 0)
62     {
63     sendto_one(source_p, form_str(RPL_REHASHING), me.name, parv[0], "DNS");
64     sendto_realops_flags(UMODE_ALL, L_ALL, "%s is rehashing DNS",
65     get_oper_name(source_p));
66     restart_resolver(); /* re-read /etc/resolv.conf AGAIN?
67     and close/re-open res socket */
68     found = 1;
69     }
70     else if (irccmp(parv[1], "FDLIMIT") == 0)
71     {
72     sendto_one(source_p, form_str(RPL_REHASHING), me.name,
73     parv[0], "FDLIMIT");
74     sendto_realops_flags(UMODE_ALL, L_ALL, "%s is updating FDLIMIT",
75     get_oper_name(source_p));
76     recalc_fdlimit(NULL);
77     found = 1;
78     }
79 michael 1001 else if (irccmp(parv[1], "MOTD") == 0)
80 adx 30 {
81     sendto_realops_flags(UMODE_ALL, L_ALL,
82     "%s is forcing re-reading of MOTD file",
83     get_oper_name(source_p));
84     read_message_file(&ConfigFileEntry.motd);
85     found = 1;
86     }
87     else if (irccmp(parv[1], "OMOTD") == 0)
88     {
89     sendto_realops_flags(UMODE_ALL, L_ALL,
90     "%s is forcing re-reading of OPER MOTD file",
91     get_oper_name(source_p));
92     read_message_file(&ConfigFileEntry.opermotd);
93     found = 1;
94     }
95    
96     if (found)
97     {
98     ilog(L_NOTICE, "REHASH %s From %s",
99     parv[1], get_client_name(source_p, HIDE_IP));
100     return;
101     }
102     else
103     {
104     sendto_one(source_p, ":%s NOTICE %s :rehash one of :DNS FDLIMIT "
105     "MOTD OMOTD", me.name, source_p->name);
106     return;
107     }
108     }
109     else
110     {
111     sendto_one(source_p, form_str(RPL_REHASHING),
112     me.name, source_p->name, ConfigFileEntry.configfile);
113     sendto_realops_flags(UMODE_ALL, L_ALL,
114     "%s is rehashing server config file",
115     get_oper_name(source_p));
116     ilog(L_NOTICE, "REHASH From %s[%s]",
117     get_oper_name(source_p), source_p->sockhost);
118     rehash(0);
119     }
120     }
121 michael 1230
122     static struct Message rehash_msgtab = {
123     "REHASH", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
124     {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_rehash, m_ignore}
125     };
126    
127     static void
128     module_init(void)
129     {
130     mod_add_cmd(&rehash_msgtab);
131     }
132    
133     static void
134     module_exit(void)
135     {
136     mod_del_cmd(&rehash_msgtab);
137     }
138    
139     struct module module_entry = {
140     .node = { NULL, NULL, NULL },
141     .name = NULL,
142     .version = "$Revision$",
143     .handle = NULL,
144     .modinit = module_init,
145     .modexit = module_exit,
146     .flags = 0
147     };

Properties

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