diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-24 13:25:24 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-08-24 13:25:24 +0200 |
commit | 604dcb6694701281b0e42dfee597cbd205c68649 (patch) | |
tree | f0dd957ba225a31d8fb82cde06a4871264f3b727 /src | |
parent | 7c223d2142bf11cda27fd43c387cbfa66838f433 (diff) | |
download | abrt-604dcb6694701281b0e42dfee597cbd205c68649.tar.gz abrt-604dcb6694701281b0e42dfee597cbd205c68649.tar.xz abrt-604dcb6694701281b0e42dfee597cbd205c68649.zip |
dismantle single-instance class CSettings
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/Daemon/Daemon.cpp | 48 | ||||
-rw-r--r-- | src/Daemon/MiddleWare.cpp | 34 | ||||
-rw-r--r-- | src/Daemon/Settings.cpp | 388 | ||||
-rw-r--r-- | src/Daemon/Settings.h | 50 |
4 files changed, 224 insertions, 296 deletions
diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index 5ed0f30a..6bb62b2c 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -49,7 +49,6 @@ typedef struct cron_callback_data_t static uint8_t sig_caught; /* = 0 */ static GMainLoop* g_pMainloop; -static CSettings* g_pSettings; CCrashWatcher *g_cw; CCommLayerServer *g_pCommLayer; @@ -150,39 +149,34 @@ static gboolean cron_activation_reshedule_cb(gpointer data) static void SetUpMW() { - SetOpenGPGCheck(g_pSettings->GetOpenGPGCheck()); - SetDatabase(g_pSettings->GetDatabase()); - set_strings_t openGPGPublicKeys = g_pSettings->GetOpenGPGPublicKeys(); - set_strings_t::iterator it_k; - for (it_k = openGPGPublicKeys.begin(); it_k != openGPGPublicKeys.end(); it_k++) + SetOpenGPGCheck(g_settings_bOpenGPGCheck); + SetDatabase(g_settings_sDatabase); + + set_strings_t::iterator it_k = g_settings_setOpenGPGPublicKeys.begin(); + for (; it_k != g_settings_setOpenGPGPublicKeys.end(); it_k++) { AddOpenGPGPublicKey(*it_k); } - set_strings_t blackList = g_pSettings->GetBlackList(); - set_strings_t::iterator it_b; - for (it_b = blackList.begin(); it_b != blackList.end(); it_b++) + set_strings_t::iterator it_b = g_settings_mapSettingsBlackList.begin(); + for (; it_b != g_settings_mapSettingsBlackList.end(); it_b++) { AddBlackListedPackage(*it_b); } - set_strings_t enabledPlugins = g_pSettings->GetEnabledPlugins(); - set_strings_t::iterator it_p; - for (it_p = enabledPlugins.begin(); it_p != enabledPlugins.end(); it_p++) + set_strings_t::iterator it_p = g_settings_setEnabledPlugins.begin(); + for (; it_p != g_settings_setEnabledPlugins.end(); it_p++) { g_pPluginManager->RegisterPlugin(*it_p); } - vector_pair_strings_t actionsAndReporters = g_pSettings->GetActionsAndReporters(); - vector_pair_strings_t::iterator it_ar; - for (it_ar = actionsAndReporters.begin(); it_ar != actionsAndReporters.end(); it_ar++) + vector_pair_strings_t::iterator it_ar = g_settings_vectorActionsAndReporters.begin(); + for (; it_ar != g_settings_vectorActionsAndReporters.end(); it_ar++) { AddActionOrReporter((*it_ar).first, (*it_ar).second); } - - map_analyzer_actions_and_reporters_t analyzerActionsAndReporters = g_pSettings->GetAnalyzerActionsAndReporters(); - map_analyzer_actions_and_reporters_t::iterator it_aar; - for (it_aar = analyzerActionsAndReporters.begin(); it_aar != analyzerActionsAndReporters.end(); it_aar++) + map_analyzer_actions_and_reporters_t::iterator it_aar = g_settings_mapAnalyzerActionsAndReporters.begin(); + for (; it_aar != g_settings_mapAnalyzerActionsAndReporters.end(); it_aar++) { - vector_pair_strings_t::iterator it_ar; - for (it_ar = it_aar->second.begin(); it_ar != it_aar->second.end(); it_ar++) + vector_pair_strings_t::iterator it_ar = it_aar->second.begin(); + for (; it_ar != it_aar->second.end(); it_ar++) { AddAnalyzerActionOrReporter(it_aar->first, (*it_ar).first, (*it_ar).second); } @@ -191,9 +185,8 @@ static void SetUpMW() static void SetUpCron() { - map_cron_t cron = g_pSettings->GetCron(); - map_cron_t::iterator it_c; - for (it_c = cron.begin(); it_c != cron.end(); it_c++) + map_cron_t::iterator it_c = g_settings_mapCron.begin(); + for (; it_c != g_settings_mapCron.end(); it_c++) { std::string::size_type pos = it_c->first.find(":"); int timeout = 0; @@ -464,7 +457,7 @@ static gboolean handle_event_cb(GIOChannel *gio, GIOCondition condition, gpointe /* we want to ignore the lock files */ if (event->mask & IN_ISDIR) { - if (GetDirSize(DEBUG_DUMPS_DIR) / (1024*1024) < g_pSettings->GetMaxCrashReportsSize()) + if (GetDirSize(DEBUG_DUMPS_DIR) / (1024*1024) < g_settings_nMaxCrashReportsSize) { //std::string sName = name; map_crash_info_t crashinfo; @@ -591,8 +584,7 @@ int main(int argc, char** argv) if (inotify_add_watch(inotify_fd, DEBUG_DUMPS_DIR, IN_CREATE) == -1) perror_msg_and_die("inotify_add_watch failed on '%s'", DEBUG_DUMPS_DIR); /* (comment here) */ - g_pSettings = new CSettings(); - g_pSettings->LoadSettings(std::string(CONF_DIR) + "/abrt.conf"); + LoadSettings(std::string(CONF_DIR) + "/abrt.conf"); /* (comment here) */ g_pMainloop = g_main_loop_new(NULL, FALSE); /* (comment here) */ @@ -636,7 +628,6 @@ int main(int argc, char** argv) delete g_pPluginManager; g_main_loop_unref(g_pMainloop); - delete g_pSettings; if (pthread_mutex_destroy(&g_pJobsMutex) != 0) { error_msg("threading error: job mutex locked"); @@ -676,7 +667,6 @@ int main(int argc, char** argv) delete g_pPluginManager; g_main_loop_unref(g_pMainloop); - delete g_pSettings; /* Exiting */ if (sig_caught) diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp index cb2f3426..380397a6 100644 --- a/src/Daemon/MiddleWare.cpp +++ b/src/Daemon/MiddleWare.cpp @@ -42,7 +42,7 @@ static CRPM m_RPM; /** * A set of blacklisted packages. */ -static set_strings_t m_setBlackList; +static set_strings_t s_setBlackList; /** * A name of database plugin, which is used for metadata. */ @@ -52,16 +52,16 @@ static std::string m_sDatabase; * action or reporter plugins. These are activated when a crash, which * is maintained by particular analyzer, occurs. */ -static map_analyzer_actions_and_reporters_t m_mapAnalyzerActionsAndReporters; +static map_analyzer_actions_and_reporters_t s_mapAnalyzerActionsAndReporters; /** * A vector of one or more action or reporter plugins. These are * activated when any crash occurs. */ -static vector_pair_string_string_t m_vectorActionsAndReporters; +static vector_pair_string_string_t s_vectorActionsAndReporters; /** * Check GPG finger print? */ -static bool m_bOpenGPGCheck = true; +static bool s_bOpenGPGCheck = true; static void RunAnalyzerActions(const std::string& pAnalyzer, const std::string& pDebugDumpDir); @@ -255,7 +255,7 @@ void RunAction(const std::string& pActionDir, void RunActionsAndReporters(const std::string& pDebugDumpDir) { vector_pair_string_string_t::iterator it_ar; - for (it_ar = m_vectorActionsAndReporters.begin(); it_ar != m_vectorActionsAndReporters.end(); it_ar++) + for (it_ar = s_vectorActionsAndReporters.begin(); it_ar != s_vectorActionsAndReporters.end(); it_ar++) { try { @@ -310,11 +310,11 @@ report_status_t Report(const map_crash_report_t& pCrashReport, analyzer += ":" + packageName; } - if (m_mapAnalyzerActionsAndReporters.find(analyzer) != m_mapAnalyzerActionsAndReporters.end()) + if (s_mapAnalyzerActionsAndReporters.find(analyzer) != s_mapAnalyzerActionsAndReporters.end()) { vector_pair_string_string_t::iterator it_r; - for (it_r = m_mapAnalyzerActionsAndReporters[analyzer].begin(); - it_r != m_mapAnalyzerActionsAndReporters[analyzer].end(); + for (it_r = s_mapAnalyzerActionsAndReporters[analyzer].begin(); + it_r != s_mapAnalyzerActionsAndReporters[analyzer].end(); it_r++) { try @@ -451,7 +451,7 @@ static mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecuta package = m_RPM.GetPackage(pExecutable); packageName = package.substr(0, package.rfind("-", package.rfind("-") - 1)); if (packageName == "" || - (m_setBlackList.find(packageName) != m_setBlackList.end())) + (s_setBlackList.find(packageName) != s_setBlackList.end())) { if (packageName == "") { @@ -461,7 +461,7 @@ static mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecuta comm_layer_inner_debug("Blacklisted package"); return MW_BLACKLISTED; } - if (m_bOpenGPGCheck) + if (s_bOpenGPGCheck) { if (!m_RPM.CheckFingerprint(packageName)) { @@ -510,11 +510,11 @@ static mw_result_t SavePackageDescriptionToDebugDump(const std::string& pExecuta */ static void RunAnalyzerActions(const std::string& pAnalyzer, const std::string& pDebugDumpDir) { - if (m_mapAnalyzerActionsAndReporters.find(pAnalyzer) != m_mapAnalyzerActionsAndReporters.end()) + if (s_mapAnalyzerActionsAndReporters.find(pAnalyzer) != s_mapAnalyzerActionsAndReporters.end()) { vector_pair_string_string_t::iterator it_a; - for (it_a = m_mapAnalyzerActionsAndReporters[pAnalyzer].begin(); - it_a != m_mapAnalyzerActionsAndReporters[pAnalyzer].end(); + for (it_a = s_mapAnalyzerActionsAndReporters[pAnalyzer].begin(); + it_a != s_mapAnalyzerActionsAndReporters[pAnalyzer].end(); it_a++) { try @@ -692,7 +692,7 @@ vector_pair_string_string_t GetUUIDsOfCrash(const std::string& pUID) void SetOpenGPGCheck(bool pCheck) { - m_bOpenGPGCheck = pCheck; + s_bOpenGPGCheck = pCheck; } void SetDatabase(const std::string& pDatabase) @@ -707,18 +707,18 @@ void AddOpenGPGPublicKey(const std::string& pKey) void AddBlackListedPackage(const std::string& pPackage) { - m_setBlackList.insert(pPackage); + s_setBlackList.insert(pPackage); } void AddAnalyzerActionOrReporter(const std::string& pAnalyzer, const std::string& pAnalyzerOrReporter, const std::string& pArgs) { - m_mapAnalyzerActionsAndReporters[pAnalyzer].push_back(make_pair(pAnalyzerOrReporter, pArgs)); + s_mapAnalyzerActionsAndReporters[pAnalyzer].push_back(make_pair(pAnalyzerOrReporter, pArgs)); } void AddActionOrReporter(const std::string& pActionOrReporter, const std::string& pArgs) { - m_vectorActionsAndReporters.push_back(make_pair(pActionOrReporter, pArgs)); + s_vectorActionsAndReporters.push_back(make_pair(pActionOrReporter, pArgs)); } diff --git a/src/Daemon/Settings.cpp b/src/Daemon/Settings.cpp index 4c85b999..955bd1bd 100644 --- a/src/Daemon/Settings.cpp +++ b/src/Daemon/Settings.cpp @@ -6,161 +6,47 @@ #define SECTION_ANALYZER_ACTIONS_AND_REPORTERS "AnalyzerActionsAndReporters" #define SECTION_CRON "Cron" -CSettings::CSettings() : - m_bOpenGPGCheck(false), - m_nMaxCrashReportsSize(1000) -{} -void CSettings::LoadSettings(const std::string& pPath) -{ - std::ifstream fIn; - fIn.open(pPath.c_str()); - if (fIn.is_open()) - { - std::string line; - std::string section = ""; - while (!fIn.eof()) - { - getline(fIn, line); +set_strings_t g_settings_setOpenGPGPublicKeys; +set_strings_t g_settings_mapSettingsBlackList; +vector_pair_string_string_t g_settings_vectorActionsAndReporters; +set_strings_t g_settings_setEnabledPlugins; +map_analyzer_actions_and_reporters_t g_settings_mapAnalyzerActionsAndReporters; +unsigned int g_settings_nMaxCrashReportsSize = 1000; +bool g_settings_bOpenGPGCheck = false; +std::string g_settings_sDatabase; +map_cron_t g_settings_mapCron; - unsigned int ii; - bool is_key = true; - bool is_section = false; - bool is_quote = false; - std::string key = ""; - std::string value = ""; - for (ii = 0; ii < line.length(); ii++) - { - if (isspace(line[ii]) && !is_quote) - { - continue; - } - else if (line[ii] == '#' && !is_quote && key == "") - { - break; - } - else if (line[ii] == '[' && !is_quote) - { - is_section = true; - section = ""; - } - else if (line[ii] == '\"') - { - is_quote = is_quote == true ? false : true; - value += line[ii]; - } - else if (is_section) - { - if (line[ii] == ']') - { - break; - } - section += line[ii]; - } - else if (line[ii] == '=' && !is_quote) - { - is_key = false; - key = value; - value = ""; - } - else - { - value += line[ii]; - } - } - if (!is_key && !is_quote) - { - if (section == SECTION_COMMON) - { - if (m_mapSettingsCommon[key] != "") - { - m_mapSettingsCommon[key] += ","; - } - m_mapSettingsCommon[key] += value; - } - else if (section == SECTION_ANALYZER_ACTIONS_AND_REPORTERS) - { - if (m_mapSettingsAnalyzerActionsAndReporters[key] != "") - { - m_mapSettingsAnalyzerActionsAndReporters[key] += ","; - } - m_mapSettingsAnalyzerActionsAndReporters[key] += value; - } - else if (section == SECTION_CRON) - { - if (m_mapSettingsCron[key] != "") - { - m_mapSettingsCron[key] += ","; - } - m_mapSettingsCron[key] += value; - } - } - } - fIn.close(); - } - ParseCommon(); - ParseAnalyzerActionsAndReporters(); - ParseCron(); -} - -void CSettings::ParseCommon() -{ - if (m_mapSettingsCommon.find("OpenGPGCheck") != m_mapSettingsCommon.end()) - { - m_bOpenGPGCheck = m_mapSettingsCommon["OpenGPGCheck"] == "yes"; - } - if (m_mapSettingsCommon.find("OpenGPGPublicKeys") != m_mapSettingsCommon.end()) - { - m_setOpenGPGPublicKeys = ParseList(m_mapSettingsCommon["OpenGPGPublicKeys"]); - } - if (m_mapSettingsCommon.find("BlackList") != m_mapSettingsCommon.end()) - { - m_setBlackList = ParseList(m_mapSettingsCommon["BlackList"]); - } - if (m_mapSettingsCommon.find("Database") != m_mapSettingsCommon.end()) - { - m_sDatabase =m_mapSettingsCommon["Database"]; - } - if (m_mapSettingsCommon.find("EnabledPlugins") != m_mapSettingsCommon.end()) - { - m_setEnabledPlugins = ParseList(m_mapSettingsCommon["EnabledPlugins"]); - } - if (m_mapSettingsCommon.find("MaxCrashReportsSize") != m_mapSettingsCommon.end()) - { - m_nMaxCrashReportsSize = atoi(m_mapSettingsCommon["MaxCrashReportsSize"].c_str()); - } - if (m_mapSettingsCommon.find("ActionsAndReporters") != m_mapSettingsCommon.end()) - { - m_vectorActionsAndReporters = ParseListWithArgs(m_mapSettingsCommon["ActionsAndReporters"]); - } -} +static map_settings_t s_mapSettingsCommon; +static map_settings_t s_mapSettingsAnalyzerActionsAndReporters; +static map_settings_t s_mapSettingsCron; -void CSettings::ParseAnalyzerActionsAndReporters() -{ - map_settings_t::iterator it; - for (it = m_mapSettingsAnalyzerActionsAndReporters.begin(); it != m_mapSettingsAnalyzerActionsAndReporters.end(); it++) - { - set_strings_t keys = ParseKey(it->first); - vector_pair_strings_t actionsAndReporters = ParseListWithArgs(it->second); - set_strings_t::iterator it_keys; - for (it_keys = keys.begin(); it_keys != keys.end(); it_keys++) - { - m_mapAnalyzerActionsAndReporters[*it_keys] = actionsAndReporters; - } - } -} -void CSettings::ParseCron() +static set_strings_t ParseList(const std::string& pList) { - map_settings_t::iterator it; - for (it = m_mapSettingsCron.begin(); it != m_mapSettingsCron.end(); it++) - { - vector_pair_strings_t actionsAndReporters = ParseListWithArgs(it->second); - m_mapCron[it->first] = actionsAndReporters; - } + unsigned int ii; + std::string item = ""; + set_strings_t set; + for(ii = 0; ii < pList.size(); ii++) + { + if (pList[ii] == ',') + { + set.insert(item); + item = ""; + } + else + { + item += pList[ii]; + } + } + if (item != "") + { + set.insert(item); + } + return set; } -vector_pair_strings_t CSettings::ParseListWithArgs(const std::string& pValue) +static vector_pair_strings_t ParseListWithArgs(const std::string& pValue) { vector_pair_strings_t pluginsWithArgs; unsigned int ii; @@ -208,7 +94,49 @@ vector_pair_strings_t CSettings::ParseListWithArgs(const std::string& pValue) return pluginsWithArgs; } -set_strings_t CSettings::ParseKey(const std::string& Key) +static void ParseCommon() +{ + if (s_mapSettingsCommon.find("OpenGPGCheck") != s_mapSettingsCommon.end()) + { + g_settings_bOpenGPGCheck = s_mapSettingsCommon["OpenGPGCheck"] == "yes"; + } + if (s_mapSettingsCommon.find("OpenGPGPublicKeys") != s_mapSettingsCommon.end()) + { + g_settings_setOpenGPGPublicKeys = ParseList(s_mapSettingsCommon["OpenGPGPublicKeys"]); + } + if (s_mapSettingsCommon.find("BlackList") != s_mapSettingsCommon.end()) + { + g_settings_mapSettingsBlackList = ParseList(s_mapSettingsCommon["BlackList"]); + } + if (s_mapSettingsCommon.find("Database") != s_mapSettingsCommon.end()) + { + g_settings_sDatabase = s_mapSettingsCommon["Database"]; + } + if (s_mapSettingsCommon.find("EnabledPlugins") != s_mapSettingsCommon.end()) + { + g_settings_setEnabledPlugins = ParseList(s_mapSettingsCommon["EnabledPlugins"]); + } + if (s_mapSettingsCommon.find("MaxCrashReportsSize") != s_mapSettingsCommon.end()) + { + g_settings_nMaxCrashReportsSize = atoi(s_mapSettingsCommon["MaxCrashReportsSize"].c_str()); + } + if (s_mapSettingsCommon.find("ActionsAndReporters") != s_mapSettingsCommon.end()) + { + g_settings_vectorActionsAndReporters = ParseListWithArgs(s_mapSettingsCommon["ActionsAndReporters"]); + } +} + +static void ParseCron() +{ + map_settings_t::iterator it; + for (it = s_mapSettingsCron.begin(); it != s_mapSettingsCron.end(); it++) + { + vector_pair_strings_t actionsAndReporters = ParseListWithArgs(it->second); + g_settings_mapCron[it->first] = actionsAndReporters; + } +} + +static set_strings_t ParseKey(const std::string& Key) { unsigned int ii; std::string item = ""; @@ -250,72 +178,110 @@ set_strings_t CSettings::ParseKey(const std::string& Key) return set; } -set_strings_t CSettings::ParseList(const std::string& pList) -{ - unsigned int ii; - std::string item = ""; - set_strings_t set; - for(ii = 0; ii < pList.size(); ii++) - { - if (pList[ii] == ',') - { - set.insert(item); - item = ""; - } - else - { - item += pList[ii]; - } - } - if (item != "") - { - set.insert(item); - } - return set; -} - - -const set_strings_t& CSettings::GetBlackList() -{ - return m_setBlackList; -} - -const set_strings_t& CSettings::GetEnabledPlugins() -{ - return m_setEnabledPlugins; -} - -const set_strings_t& CSettings::GetOpenGPGPublicKeys() -{ - return m_setOpenGPGPublicKeys; -} - -bool CSettings::GetOpenGPGCheck() +static void ParseAnalyzerActionsAndReporters() { - return m_bOpenGPGCheck; -} - -const map_analyzer_actions_and_reporters_t& CSettings::GetAnalyzerActionsAndReporters() -{ - return m_mapAnalyzerActionsAndReporters; -} - -const unsigned int& CSettings::GetMaxCrashReportsSize() -{ - return m_nMaxCrashReportsSize; + map_settings_t::iterator it; + for (it = s_mapSettingsAnalyzerActionsAndReporters.begin(); it != s_mapSettingsAnalyzerActionsAndReporters.end(); it++) + { + set_strings_t keys = ParseKey(it->first); + vector_pair_strings_t actionsAndReporters = ParseListWithArgs(it->second); + set_strings_t::iterator it_keys; + for (it_keys = keys.begin(); it_keys != keys.end(); it_keys++) + { + g_settings_mapAnalyzerActionsAndReporters[*it_keys] = actionsAndReporters; + } + } } -const vector_pair_strings_t& CSettings::GetActionsAndReporters() +void LoadSettings(const std::string& pPath) { - return m_vectorActionsAndReporters; -} + std::ifstream fIn; + fIn.open(pPath.c_str()); + if (fIn.is_open()) + { + std::string line; + std::string section = ""; + while (!fIn.eof()) + { + getline(fIn, line); -const std::string& CSettings::GetDatabase() -{ - return m_sDatabase; + unsigned int ii; + bool is_key = true; + bool is_section = false; + bool is_quote = false; + std::string key = ""; + std::string value = ""; + for (ii = 0; ii < line.length(); ii++) + { + if (isspace(line[ii]) && !is_quote) + { + continue; + } + else if (line[ii] == '#' && !is_quote && key == "") + { + break; + } + else if (line[ii] == '[' && !is_quote) + { + is_section = true; + section = ""; + } + else if (line[ii] == '\"') + { + is_quote = is_quote == true ? false : true; + value += line[ii]; + } + else if (is_section) + { + if (line[ii] == ']') + { + break; + } + section += line[ii]; + } + else if (line[ii] == '=' && !is_quote) + { + is_key = false; + key = value; + value = ""; + } + else + { + value += line[ii]; + } + } + if (!is_key && !is_quote) + { + if (section == SECTION_COMMON) + { + if (s_mapSettingsCommon[key] != "") + { + s_mapSettingsCommon[key] += ","; + } + s_mapSettingsCommon[key] += value; + } + else if (section == SECTION_ANALYZER_ACTIONS_AND_REPORTERS) + { + if (s_mapSettingsAnalyzerActionsAndReporters[key] != "") + { + s_mapSettingsAnalyzerActionsAndReporters[key] += ","; + } + s_mapSettingsAnalyzerActionsAndReporters[key] += value; + } + else if (section == SECTION_CRON) + { + if (s_mapSettingsCron[key] != "") + { + s_mapSettingsCron[key] += ","; + } + s_mapSettingsCron[key] += value; + } + } + } + fIn.close(); + } + ParseCommon(); + ParseAnalyzerActionsAndReporters(); + ParseCron(); } -const map_cron_t& CSettings::GetCron() -{ - return m_mapCron; -} diff --git a/src/Daemon/Settings.h b/src/Daemon/Settings.h index 8869c728..2df3806b 100644 --- a/src/Daemon/Settings.h +++ b/src/Daemon/Settings.h @@ -15,44 +15,16 @@ typedef std::vector<pair_string_string_t> vector_pair_strings_t; typedef std::map<std::string, vector_pair_strings_t> map_analyzer_actions_and_reporters_t; typedef std::map<std::string, vector_pair_strings_t> map_cron_t; -class CSettings -{ - private: - map_settings_t m_mapSettingsCommon; - map_settings_t m_mapSettingsAnalyzerActionsAndReporters; - map_settings_t m_mapSettingsCron; - - set_strings_t m_setOpenGPGPublicKeys; - set_strings_t m_setBlackList; - set_strings_t m_setEnabledPlugins; - std::string m_sDatabase; - vector_pair_string_string_t m_vectorActionsAndReporters; - map_cron_t m_mapCron; - - bool m_bOpenGPGCheck; - unsigned int m_nMaxCrashReportsSize; - map_analyzer_actions_and_reporters_t m_mapAnalyzerActionsAndReporters; - - void ParseCommon(); - void ParseAnalyzerActionsAndReporters(); - void ParseCron(); - - set_strings_t ParseList(const std::string& pList); - vector_pair_strings_t ParseListWithArgs(const std::string& pList); - set_strings_t ParseKey(const std::string& pKey); - - public: - CSettings(); - void LoadSettings(const std::string& pPath); - const set_strings_t& GetBlackList(); - const set_strings_t& GetEnabledPlugins(); - const set_strings_t& GetOpenGPGPublicKeys(); - bool GetOpenGPGCheck(); - const map_analyzer_actions_and_reporters_t& GetAnalyzerActionsAndReporters(); - const unsigned int& GetMaxCrashReportsSize(); - const vector_pair_strings_t& GetActionsAndReporters(); - const std::string& GetDatabase(); - const map_cron_t& GetCron(); -}; +void LoadSettings(const std::string& pPath); + +extern set_strings_t g_settings_setOpenGPGPublicKeys; +extern set_strings_t g_settings_mapSettingsBlackList; +extern vector_pair_string_string_t g_settings_vectorActionsAndReporters; +extern set_strings_t g_settings_setEnabledPlugins; +extern map_analyzer_actions_and_reporters_t g_settings_mapAnalyzerActionsAndReporters; +extern unsigned int g_settings_nMaxCrashReportsSize; +extern bool g_settings_bOpenGPGCheck; +extern std::string g_settings_sDatabase; +extern map_cron_t g_settings_mapCron; #endif |