From 7565843fbe746d8948d6e996b717e3f69fa53dfd Mon Sep 17 00:00:00 2001 From: hagen Date: Mon, 18 Jan 2016 00:00:00 +0000 Subject: [PATCH] * move ReadConfigFile() : i2p::filesystem -> i2p::config * don't export i2p::config::mapArgs outside namespace --- Daemon.cpp | 2 +- util.cpp | 40 ++++++++++++++++++++-------------------- util.h | 3 +-- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Daemon.cpp b/Daemon.cpp index ca6681b4..1415435a 100644 --- a/Daemon.cpp +++ b/Daemon.cpp @@ -65,7 +65,7 @@ namespace i2p LogPrint(eLogInfo, "i2pd v", VERSION, " starting"); LogPrint(eLogDebug, "FS: data directory: ", i2p::util::filesystem::GetDataDir().string()); - i2p::util::filesystem::ReadConfigFile(i2p::util::config::mapArgs); + i2p::util::config::ReadConfigFile(i2p::util::filesystem::GetConfigFile()); isDaemon = i2p::util::config::GetArg("-daemon", 0); isLogging = i2p::util::config::GetArg("-log", 1); diff --git a/util.cpp b/util.cpp index 850dfa89..cff2aa75 100644 --- a/util.cpp +++ b/util.cpp @@ -124,6 +124,26 @@ namespace config return atoi(mapArgs[strArg].c_str()); return nDefault; } + + void ReadConfigFile(boost::filesystem::path path) + { + boost::filesystem::ifstream streamConfig(path); + if (!streamConfig.good()) + return; // No i2pd.conf file is OK + + std::set setOptions; + setOptions.insert("*"); + + for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it) + { + // Don't overwrite existing settings so command line settings override i2pd.conf + std::string strKey = std::string("-") + it->string_key; + if (mapArgs.count(strKey) == 0) + { + mapArgs[strKey] = it->value[0]; + } + } + } } namespace filesystem @@ -193,26 +213,6 @@ namespace filesystem return pathTunnelsConfigFile; } - void ReadConfigFile(std::map& mapSettingsRet) - { - boost::filesystem::ifstream streamConfig(GetConfigFile()); - if (!streamConfig.good()) - return; // No i2pd.conf file is OK - - std::set setOptions; - setOptions.insert("*"); - - for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it) - { - // Don't overwrite existing settings so command line settings override i2pd.conf - std::string strKey = std::string("-") + it->string_key; - if (mapSettingsRet.count(strKey) == 0) - { - mapSettingsRet[strKey] = it->value[0]; - } - } - } - boost::filesystem::path GetDefaultDataDir() { // Windows < Vista: C:\Documents and Settings\Username\.i2pd diff --git a/util.h b/util.h index 040b3a34..905c2a8d 100644 --- a/util.h +++ b/util.h @@ -16,10 +16,10 @@ namespace util { namespace config { - extern std::map mapArgs; void OptionParser(int argc, const char* const argv[]); int GetArg(const std::string& strArg, int nDefault); std::string GetArg(const std::string& strArg, const std::string& strDefault); + void ReadConfigFile(boost::filesystem::path path); } namespace filesystem @@ -32,7 +32,6 @@ namespace util boost::filesystem::path GetDefaultDataDir(); boost::filesystem::path GetConfigFile(); boost::filesystem::path GetTunnelsConfigFile(); - void ReadConfigFile(std::map& mapSettingsRet); boost::filesystem::path GetCertificatesDir(); }