summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/config.h16
-rw-r--r--include/modules.h10
-rw-r--r--modules/bs_autoassign.cpp7
-rw-r--r--modules/commands/cs_access.cpp13
-rw-r--r--modules/commands/cs_entrymsg.cpp7
-rw-r--r--modules/commands/cs_fantasy_stats.cpp8
-rw-r--r--modules/commands/cs_fantasy_top.cpp8
-rw-r--r--modules/commands/cs_flags.cpp11
-rw-r--r--modules/commands/cs_seen.cpp9
-rw-r--r--modules/commands/cs_set.cpp7
-rw-r--r--modules/commands/cs_set_misc.cpp15
-rw-r--r--modules/commands/cs_xop.cpp17
-rw-r--r--modules/commands/hs_request.cpp11
-rw-r--r--modules/commands/ns_set.cpp7
-rw-r--r--modules/commands/ns_set_misc.cpp15
-rw-r--r--modules/commands/os_config.cpp2
-rw-r--r--modules/commands/os_defcon.cpp39
-rw-r--r--modules/commands/os_dns.cpp17
-rw-r--r--modules/commands/os_logsearch.cpp8
-rw-r--r--modules/commands/os_reload.cpp13
-rw-r--r--modules/database/db_flatfile.cpp9
-rw-r--r--modules/database/db_plain.cpp14
-rw-r--r--modules/database/db_sql.cpp11
-rw-r--r--modules/database/db_sql_live.cpp9
-rw-r--r--modules/extra/m_chanstats.cpp14
-rw-r--r--modules/extra/m_dns.cpp21
-rw-r--r--modules/extra/m_httpd.cpp21
-rw-r--r--modules/extra/m_ldap.cpp21
-rw-r--r--modules/extra/m_ldap_authentication.cpp23
-rw-r--r--modules/extra/m_ldap_oper.cpp16
-rw-r--r--modules/extra/m_mysql.cpp23
-rw-r--r--modules/extra/m_proxyscan.cpp39
-rw-r--r--modules/extra/m_sql_authentication.cpp12
-rw-r--r--modules/extra/m_sql_oper.cpp10
-rw-r--r--modules/extra/m_sqlite.cpp15
-rw-r--r--modules/extra/m_ssl.cpp14
-rw-r--r--modules/extra/m_xmlrpc.cpp12
-rw-r--r--modules/m_dnsbl.cpp22
-rw-r--r--modules/m_helpchan.cpp9
-rw-r--r--modules/m_rewrite.cpp18
-rw-r--r--modules/ns_maxemail.cpp8
-rw-r--r--src/config.cpp3
-rw-r--r--src/configreader.cpp18
-rw-r--r--src/init.cpp8
-rw-r--r--src/modulemanager.cpp18
45 files changed, 253 insertions, 375 deletions
diff --git a/include/config.h b/include/config.h
index 36a4836c8..901fe0138 100644
--- a/include/config.h
+++ b/include/config.h
@@ -707,11 +707,12 @@ class ConfigException : public CoreException
virtual ~ConfigException() throw() { }
};
-#define CONF_NO_ERROR 0x000000
-#define CONF_NOT_A_NUMBER 0x000010
-#define CONF_INT_NEGATIVE 0x000080
-#define CONF_VALUE_NOT_FOUND 0x000100
-#define CONF_FILE_NOT_FOUND 0x000200
+enum
+{
+ CONF_NO_ERROR,
+ CONF_INT_NEGATIVE = 1 << 1,
+ CONF_VALUE_NOT_FOUND = 1 << 2
+};
/** Allows reading of values from configuration files
* This class allows a module to read from either the main configuration file (services.conf) or from
@@ -721,6 +722,7 @@ class ConfigException : public CoreException
*/
class CoreExport ConfigReader
{
+ ServerConfig *conf;
protected:
/** True if an error occured reading the config file
*/
@@ -737,6 +739,10 @@ class CoreExport ConfigReader
* This constructor initialises the ConfigReader class to read a user-specified config file
*/
ConfigReader(const Anope::string &);
+ /** Overloaded constructor
+ * This constructor initialises the ConfigReader class to use a user sepcific ServerConfig object,
+ */
+ ConfigReader(ServerConfig *);
/** Default destructor.
* This method destroys the ConfigReader class.
*/
diff --git a/include/modules.h b/include/modules.h
index ae7ceb651..20d27b0ab 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -112,6 +112,8 @@ if (true) \
else \
static_cast<void>(0)
+class ConfigReader;
+
/** Possible return types from events.
*/
enum EventReturn
@@ -124,7 +126,6 @@ enum EventReturn
enum ModuleReturn
{
MOD_ERR_OK,
- MOD_ERR_MEMORY,
MOD_ERR_PARAMS,
MOD_ERR_EXISTS,
MOD_ERR_NOEXIST,
@@ -285,9 +286,12 @@ class CoreExport Module : public Extensible
*/
virtual void OnUserKicked(Channel *c, User *target, MessageSource &source, const Anope::string &kickmsg) { }
- /** Called when Services' configuration has been loaded.
+ /** Called when Services' configuration is being (re)loaded.
+ * @param conf The config that is being built now and will replace the global Config object
+ * @param reader A config reader for conf
+ * @throws A ConfigException to abort the config (re)loading process.
*/
- virtual void OnReload() { }
+ virtual void OnReload(ServerConfig *conf, ConfigReader &reader) { }
/** Called before a bot is assigned to a channel.
* @param sender The user assigning the bot
diff --git a/modules/bs_autoassign.cpp b/modules/bs_autoassign.cpp
index 13bde5ff5..134904925 100644
--- a/modules/bs_autoassign.cpp
+++ b/modules/bs_autoassign.cpp
@@ -19,8 +19,6 @@ class BSAutoAssign : public Module
Implementation i[] = { I_OnChanRegistered, I_OnReload };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- this->OnReload();
}
void OnChanRegistered(ChannelInfo *ci) anope_override
@@ -38,10 +36,9 @@ class BSAutoAssign : public Module
bi->Assign(NULL, ci);
}
- void OnReload() anope_override
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
- ConfigReader config;
- this->bot = config.ReadValue("bs_autoassign", "bot", "", 0);
+ this->bot = reader.ReadValue("bs_autoassign", "bot", "", 0);
}
};
diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp
index 10a4c9885..90e17eeed 100644
--- a/modules/commands/cs_access.cpp
+++ b/modules/commands/cs_access.cpp
@@ -790,24 +790,21 @@ class CSAccess : public Module
Implementation i[] = { I_OnReload, I_OnCreateChan, I_OnGroupCheckPriv };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- this->OnReload();
}
- void OnReload() anope_override
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
defaultLevels.clear();
- ConfigReader config;
- for (int i = 0; i < config.Enumerate("privilege"); ++i)
+ for (int i = 0; i < reader.Enumerate("privilege"); ++i)
{
- const Anope::string &pname = config.ReadValue("privilege", "name", "", i);
+ const Anope::string &pname = reader.ReadValue("privilege", "name", "", i);
Privilege *p = PrivilegeManager::FindPrivilege(pname);
if (p == NULL)
continue;
- const Anope::string &value = config.ReadValue("privilege", "level", "", i);
+ const Anope::string &value = reader.ReadValue("privilege", "level", "", i);
if (value.empty())
continue;
else if (value.equals_ci("founder"))
@@ -815,7 +812,7 @@ class CSAccess : public Module
else if (value.equals_ci("disabled"))
defaultLevels[p->name] = ACCESS_INVALID;
else
- defaultLevels[p->name] = config.ReadInteger("privilege", "level", i, false);
+ defaultLevels[p->name] = reader.ReadInteger("privilege", "level", i, false);
}
}
diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp
index bb82e9b24..961cf1895 100644
--- a/modules/commands/cs_entrymsg.cpp
+++ b/modules/commands/cs_entrymsg.cpp
@@ -278,8 +278,6 @@ class CSEntryMessage : public Module
Implementation i[] = { I_OnReload, I_OnJoinChannel };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- this->OnReload();
}
void OnJoinChannel(User *u, Channel *c) anope_override
@@ -294,10 +292,9 @@ class CSEntryMessage : public Module
}
}
- void OnReload() anope_override
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
- ConfigReader config;
- MaxEntries = config.ReadInteger("cs_entrymsg", "maxentries", "5", 0, true);
+ MaxEntries = reader.ReadInteger("cs_entrymsg", "maxentries", "5", 0, true);
}
};
diff --git a/modules/commands/cs_fantasy_stats.cpp b/modules/commands/cs_fantasy_stats.cpp
index 591da28e9..b1b878c63 100644
--- a/modules/commands/cs_fantasy_stats.cpp
+++ b/modules/commands/cs_fantasy_stats.cpp
@@ -75,14 +75,12 @@ class CSStats : public Module
Implementation i[] = { I_OnReload };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
- this->OnReload();
}
- void OnReload() anope_override
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
- ConfigReader config;
- prefix = config.ReadValue("chanstats", "prefix", "anope_", 0);
- Anope::string engine = config.ReadValue("chanstats", "engine", "", 0);
+ prefix = reader.ReadValue("chanstats", "prefix", "anope_", 0);
+ Anope::string engine = reader.ReadValue("chanstats", "engine", "", 0);
this->sql = ServiceReference<SQL::Provider>("SQL::Provider", engine);
}
diff --git a/modules/commands/cs_fantasy_top.cpp b/modules/commands/cs_fantasy_top.cpp
index 739f21f41..4bad46e51 100644
--- a/modules/commands/cs_fantasy_top.cpp
+++ b/modules/commands/cs_fantasy_top.cpp
@@ -102,14 +102,12 @@ class CSTop : public Module
Implementation i[] = { I_OnReload };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
- this->OnReload();
}
- void OnReload() anope_override
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
- ConfigReader config;
- prefix = config.ReadValue("chanstats", "prefix", "anope_", 0);
- Anope::string engine = config.ReadValue("chanstats", "engine", "", 0);
+ prefix = reader.ReadValue("chanstats", "prefix", "anope_", 0);
+ Anope::string engine = reader.ReadValue("chanstats", "engine", "", 0);
this->sql = ServiceReference<SQL::Provider>("SQL::Provider", engine);
}
diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp
index bdff5a6e5..cd1a14e83 100644
--- a/modules/commands/cs_flags.cpp
+++ b/modules/commands/cs_flags.cpp
@@ -394,24 +394,21 @@ class CSFlags : public Module
Implementation i[] = { I_OnReload };
ModuleManager::Attach(i, this, 1);
-
- this->OnReload();
}
- void OnReload() anope_override
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
- ConfigReader config;
defaultFlags.clear();
- for (int i = 0; i < config.Enumerate("privilege"); ++i)
+ for (int i = 0; i < reader.Enumerate("privilege"); ++i)
{
- const Anope::string &pname = config.ReadValue("privilege", "name", "", i);
+ const Anope::string &pname = reader.ReadValue("privilege", "name", "", i);
Privilege *p = PrivilegeManager::FindPrivilege(pname);
if (p == NULL)
continue;
- const Anope::string &value = config.ReadValue("privilege", "flag", "", i);
+ const Anope::string &value = reader.ReadValue("privilege", "flag", "", i);
if (value.empty())
continue;
diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp
index 7c88c89b8..2d45f9a15 100644
--- a/modules/commands/cs_seen.cpp
+++ b/modules/commands/cs_seen.cpp
@@ -335,15 +335,12 @@ class CSSeen : public Module
I_OnPartChannel,
I_OnUserKicked };
ModuleManager::Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
-
- OnReload();
}
- void OnReload() anope_override
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
- ConfigReader config;
- purgetime = Anope::DoTime(config.ReadValue("cs_seen", "purgetime", "30d", 0));
- expiretimeout = Anope::DoTime(config.ReadValue("cs_seen", "expiretimeout", "1d", 0));
+ purgetime = Anope::DoTime(reader.ReadValue("cs_seen", "purgetime", "30d", 0));
+ expiretimeout = Anope::DoTime(reader.ReadValue("cs_seen", "expiretimeout", "1d", 0));
if (purger.GetSecs() != expiretimeout)
purger.SetSecs(expiretimeout);
diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp
index 03aa6c59c..7b6df8a9b 100644
--- a/modules/commands/cs_set.cpp
+++ b/modules/commands/cs_set.cpp
@@ -1164,14 +1164,11 @@ class CSSet : public Module
Implementation i[] = { I_OnReload, I_OnChanRegistered, I_OnCheckKick, I_OnDelChan };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- this->OnReload();
}
- void OnReload() anope_override
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
- ConfigReader config;
- CSDefChanstats = config.ReadFlag("chanstats", "CSDefChanstats", "0", 0);
+ CSDefChanstats = reader.ReadFlag("chanstats", "CSDefChanstats", "0", 0);
}
void OnChanRegistered(ChannelInfo *ci) anope_override
diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp
index 93897f332..e74587be1 100644
--- a/modules/commands/cs_set_misc.cpp
+++ b/modules/commands/cs_set_misc.cpp
@@ -138,26 +138,21 @@ class CSSetMisc : public Module
CSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
csmiscdata_type("CSMiscData", CSMiscData::Unserialize), commandcssetmisc(this)
{
-
Implementation i[] = { I_OnReload, I_OnChanInfo };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- this->OnReload();
}
- void OnReload()
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
- ConfigReader config;
-
descriptions.clear();
- for (int i = 0; i < config.Enumerate("command"); ++i)
+ for (int i = 0; i < reader.Enumerate("command"); ++i)
{
- if (config.ReadValue("command", "command", "", i) != "chanserv/set/misc")
+ if (reader.ReadValue("command", "command", "", i) != "chanserv/set/misc")
continue;
- Anope::string cname = config.ReadValue("command", "name", "", i);
- Anope::string desc = config.ReadValue("command", "misc_description", "", i);
+ Anope::string cname = reader.ReadValue("command", "name", "", i);
+ Anope::string desc = reader.ReadValue("command", "misc_description", "", i);
if (cname.empty() || desc.empty())
continue;
diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp
index 1cfa033e2..32253770f 100644
--- a/modules/commands/cs_xop.cpp
+++ b/modules/commands/cs_xop.cpp
@@ -543,36 +543,33 @@ class CSXOP : public Module
accessprovider(this), commandcsxop(this)
{
this->SetPermanent(true);
-
- this->OnReload();
}
- void OnReload() anope_override
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
order.clear();
permissions.clear();
- ConfigReader config;
- for (int i = 0; i < config.Enumerate("privilege"); ++i)
+ for (int i = 0; i < reader.Enumerate("privilege"); ++i)
{
- const Anope::string &pname = config.ReadValue("privilege", "name", "", i);
+ const Anope::string &pname = reader.ReadValue("privilege", "name", "", i);
Privilege *p = PrivilegeManager::FindPrivilege(pname);
if (p == NULL)
continue;
- const Anope::string &xop = config.ReadValue("privilege", "xop", "", i);
+ const Anope::string &xop = reader.ReadValue("privilege", "xop", "", i);
if (xop.empty())
continue;
permissions[xop].push_back(pname);
}
- for (int i = 0; i < config.Enumerate("command"); ++i)
+ for (int i = 0; i < reader.Enumerate("command"); ++i)
{
- const Anope::string &cname = config.ReadValue("command", "name", "", i),
- &cserv = config.ReadValue("command", "command", "", i);
+ const Anope::string &cname = reader.ReadValue("command", "name", "", i),
+ &cserv = reader.ReadValue("command", "command", "", i);
if (cname.empty() || cserv != "chanserv/xop")
continue;
diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp
index 1867dbb77..8b551f0ed 100644
--- a/modules/commands/hs_request.cpp
+++ b/modules/commands/hs_request.cpp
@@ -357,8 +357,6 @@ class HSRequest : public Module
Implementation i[] = { I_OnReload };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- this->OnReload();
}
~HSRequest()
@@ -370,13 +368,10 @@ class HSRequest : public Module
}
}
- void OnReload() anope_override
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
- ConfigReader config;
- HSRequestMemoUser = config.ReadFlag("hs_request", "memouser", "no", 0);
- HSRequestMemoOper = config.ReadFlag("hs_request", "memooper", "no", 0);
-
- Log(LOG_DEBUG) << "[hs_request] Set config vars: MemoUser=" << HSRequestMemoUser << " MemoOper=" << HSRequestMemoOper;
+ HSRequestMemoUser = reader.ReadFlag("hs_request", "memouser", "no", 0);
+ HSRequestMemoOper = reader.ReadFlag("hs_request", "memooper", "no", 0);
}
};
diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp
index f8b2b7155..793b99fd1 100644
--- a/modules/commands/ns_set.cpp
+++ b/modules/commands/ns_set.cpp
@@ -1404,14 +1404,11 @@ class NSSet : public Module
Implementation i[] = { I_OnReload, I_OnNickRegister, I_OnPreCommand };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- this->OnReload();
}
- void OnReload() anope_override
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
- ConfigReader config;
- NSDefChanstats = config.ReadFlag("chanstats", "NSDefChanstats", "0", 0);
+ NSDefChanstats = reader.ReadFlag("chanstats", "NSDefChanstats", "0", 0);
}
void OnNickRegister(NickAlias *na) anope_override
diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp
index 35210abd0..5ee77a938 100644
--- a/modules/commands/ns_set_misc.cpp
+++ b/modules/commands/ns_set_misc.cpp
@@ -157,26 +157,21 @@ class NSSetMisc : public Module
NSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
nsmiscdata_type("NSMiscData", NSMiscData::Unserialize), commandnssetmisc(this), commandnssasetmisc(this)
{
-
Implementation i[] = { I_OnReload, I_OnNickInfo };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- this->OnReload();
}
- void OnReload()
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
- ConfigReader config;
-
descriptions.clear();
- for (int i = 0; i < config.Enumerate("command"); ++i)
+ for (int i = 0; i < reader.Enumerate("command"); ++i)
{
- if (config.ReadValue("command", "command", "", i) != "nickserv/set/misc" && config.ReadValue("command", "command", "", i) != "nickserv/saset/misc")
+ if (reader.ReadValue("command", "command", "", i) != "nickserv/set/misc" && reader.ReadValue("command", "command", "", i) != "nickserv/saset/misc")
continue;
- Anope::string cname = config.ReadValue("command", "name", "", i);
- Anope::string desc = config.ReadValue("command", "misc_description", "", i);
+ Anope::string cname = reader.ReadValue("command", "name", "", i);
+ Anope::string desc = reader.ReadValue("command", "misc_description", "", i);
if (cname.empty() || desc.empty())
continue;
diff --git a/modules/commands/os_config.cpp b/modules/commands/os_config.cpp
index 540bcc3e7..0517f28d7 100644
--- a/modules/commands/os_config.cpp
+++ b/modules/commands/os_config.cpp
@@ -64,7 +64,7 @@ class CommandOSConfig : public Command
bool allow_wild = dt & DT_ALLOW_WILD;
dt &= ~(DT_ALLOW_NEWLINE | DT_ALLOW_WILD);
- /* Yay for *massive* copypaste from config.cpp */
+ /* Yay for *massive* copypaste from reader.cpp */
switch (dt)
{
case DT_NOSPACES:
diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp
index 53148c6a8..dd45856fb 100644
--- a/modules/commands/os_defcon.cpp
+++ b/modules/commands/os_defcon.cpp
@@ -334,36 +334,25 @@ class OSDefcon : public Module
Implementation i[] = { I_OnReload, I_OnChannelModeSet, I_OnChannelModeUnset, I_OnPreCommand, I_OnUserConnect, I_OnChannelModeAdd, I_OnChannelCreate };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
-
- try
- {
- this->OnReload();
- }
- catch (const ConfigException &ex)
- {
- throw ModuleException(ex.GetReason());
- }
}
- void OnReload() anope_override
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
- ConfigReader config;
DefconConfig dconfig;
- dconfig.defaultlevel = config.ReadInteger("defcon", "defaultlevel", 0, 0);
- dconfig.defcons[4] = config.ReadValue("defcon", "level4", 0);
- dconfig.defcons[3] = config.ReadValue("defcon", "level3", 0);
- dconfig.defcons[2] = config.ReadValue("defcon", "level2", 0);
- dconfig.defcons[1] = config.ReadValue("defcon", "level1", 0);
- dconfig.sessionlimit = config.ReadInteger("defcon", "sessionlimit", 0, 0);
- dconfig.akillreason = config.ReadValue("defcon", "akillreason", 0);
- dconfig.akillexpire = Anope::DoTime(config.ReadValue("defcon", "akillexpire", 0));
- dconfig.chanmodes = config.ReadValue("defcon", "chanmodes", 0);
- dconfig.timeout = Anope::DoTime(config.ReadValue("defcon", "timeout", 0));
- dconfig.globalondefcon = config.ReadFlag("defcon", "globalondefcon", 0);
- dconfig.message = config.ReadValue("defcon", "message", 0);
- dconfig.offmessage = config.ReadValue("defcon", "offmessage", 0);
+ dconfig.defaultlevel = reader.ReadInteger("defcon", "defaultlevel", 0, 0);
+ dconfig.defcons[4] = reader.ReadValue("defcon", "level4", 0);
+ dconfig.defcons[3] = reader.ReadValue("defcon", "level3", 0);
+ dconfig.defcons[2] = reader.ReadValue("defcon", "level2", 0);
+ dconfig.defcons[1] = reader.ReadValue("defcon", "level1", 0);
+ dconfig.sessionlimit = reader.ReadInteger("defcon", "sessionlimit", 0, 0);
+ dconfig.akillreason = reader.ReadValue("defcon", "akillreason", 0);
+ dconfig.akillexpire = Anope::DoTime(reader.ReadValue("defcon", "akillexpire", 0));
+ dconfig.chanmodes = reader.ReadValue("defcon", "chanmodes", 0);
+ dconfig.timeout = Anope::DoTime(reader.ReadValue("defcon", "timeout", 0));
+ dconfig.globalondefcon = reader.ReadFlag("defcon", "globalondefcon", 0);
+ dconfig.message = reader.ReadValue("defcon", "message", 0);
+ dconfig.offmessage = reader.ReadValue("defcon", "offmessage", 0);
if (dconfig.defaultlevel < 1 || dconfig.defaultlevel > 5)
throw ConfigException("The value for <defcon:defaultlevel> must be between 1 and 5");
diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp
index efcff8fc5..04971e89a 100644
--- a/modules/commands/os_dns.cpp
+++ b/modules/commands/os_dns.cpp
@@ -670,8 +670,6 @@ class ModuleDNS : public Module
Implementation i[] = { I_OnReload, I_OnNewServer, I_OnServerQuit, I_OnUserConnect, I_OnPreUserLogoff, I_OnDnsRequest };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
- this->OnReload();
-
for (unsigned j = 0; j < dns_servers->size(); ++j)
{
DNSServer *s = dns_servers->at(j);
@@ -688,16 +686,15 @@ class ModuleDNS : public Module
delete dns_servers->at(i - 1);
}
- void OnReload() anope_override
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
- ConfigReader config;
- this->ttl = Anope::DoTime(config.ReadValue("os_dns", "ttl", 0));
- this->user_drop_mark = config.ReadInteger("os_dns", "user_drop_mark", 0, false);
- this->user_drop_time = Anope::DoTime(config.ReadValue("os_dns", "user_drop_time", 0, false));
- this->user_drop_readd_time = Anope::DoTime(config.ReadValue("os_dns", "user_drop_readd_time", 0, false));
- this->remove_split_servers = config.ReadFlag("os_dns", "remove_split_servers", 0);
- this->readd_connected_servers = config.ReadFlag("os_dns", "readd_connected_servers", 0);
+ this->ttl = Anope::DoTime(reader.ReadValue("os_dns", "ttl", 0));
+ this->user_drop_mark = reader.ReadInteger("os_dns", "user_drop_mark", 0, false);
+ this->user_drop_time = Anope::DoTime(reader.ReadValue("os_dns", "user_drop_time", 0, false));
+ this->user_drop_readd_time = Anope::DoTime(reader.ReadValue("os_dns", "user_drop_readd_time", 0, false));
+ this->remove_split_servers = reader.ReadFlag("os_dns", "remove_split_servers", 0);
+ this->readd_connected_servers = reader.ReadFlag("os_dns", "readd_connected_servers", 0);
}
void OnNewServer(Server *s) anope_override
diff --git a/modules/commands/os_logsearch.cpp b/modules/commands/os_logsearch.cpp
index 5a063ad53..c033c6bb5 100644
--- a/modules/commands/os_logsearch.cpp
+++ b/modules/commands/os_logsearch.cpp
@@ -151,17 +151,13 @@ class OSLogSearch : public Module
OSLogSearch(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
commandoslogsearch(this)
{
-
Implementation i[] = { I_OnReload };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- OnReload();
}
- void OnReload() anope_override
+ void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override
{
- ConfigReader config;
- logfile_name = config.ReadValue("logsearch", "name", "services.log", 0);
+ logfile_name = reader.ReadValue("logsearch", "name", "services.log", 0);
}
};
diff --git a/modules/commands/os_reload.cpp b/modules/commands/os_reload.cpp
index 86b3a040e..fcf3868fa 100644
--- a/modules/commands/os_reload.cpp
+++ b/modules/commands/os_reload.cpp
@@ -24,23 +24,18 @@ class CommandOSReload : public Command
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
- ServerConfig *old_config = Config;
-
try
{
- Config = new ServerConfig();
- FOREACH_MOD(I_OnReload, OnReload());
- delete old_config;
+ ServerConfig *new_config = new ServerConfig();
+ delete Config;
+ Config = new_config;
source.Reply(_("Services' configuration file has been reloaded."));
}
catch (const ConfigException &ex)
{
- Config = old_config;
Log(this->owner) << "Error reloading configuration file: " << ex.GetReason();
- source.Reply(_("Error reloading configuration file: ") + ex.GetReason());
+ source.Reply(_("Error reloading configuration file: %s"), ex.GetReason().c_str());
}
-
- return;
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
diff --git a/modules/database/db_flatfile.cpp b/modules/database/db_flatfile.cpp
index 50a513c65..dcf4a5aa4 100644
--- a/modules/database/db_flatfile.cpp
+++ b/modules/database/db_flatfile.cpp
@@ -169,8 +169,6 @@ class DBFlatFile : public Module, public Pipe
Implementation i[] = { I_OnReload, I_O