diff options
| author | Zdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com> | 2009-04-16 17:54:20 +0200 |
|---|---|---|
| committer | Zdenek Prikryl <zdeny@dhcp-lab-218.englab.brq.redhat.com> | 2009-04-16 17:54:20 +0200 |
| commit | b67b664e6f3019a142996c5bdc3a2e8c32f4306a (patch) | |
| tree | 95aaf34561d8abc9cd59da1229b4ff620ac194e0 /lib | |
| parent | d71fe39576ded4e9567f5f938e9ef67183bb8afd (diff) | |
- reporter plugins can tak an argiment
- added "Reporters" option which allows report basic info after a crash occurs
- fixed interface of plugins
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/MiddleWare/MiddleWare.cpp | 20 | ||||
| -rw-r--r-- | lib/MiddleWare/MiddleWare.h | 15 | ||||
| -rw-r--r-- | lib/MiddleWare/Plugin.h | 2 | ||||
| -rw-r--r-- | lib/MiddleWare/PluginManager.cpp | 154 | ||||
| -rw-r--r-- | lib/MiddleWare/Reporter.h | 4 | ||||
| -rw-r--r-- | lib/Plugins/Bugzilla.cpp | 2 | ||||
| -rw-r--r-- | lib/Plugins/Bugzilla.h | 3 | ||||
| -rw-r--r-- | lib/Plugins/CCpp.h | 12 | ||||
| -rw-r--r-- | lib/Plugins/Kerneloops.h | 10 | ||||
| -rw-r--r-- | lib/Plugins/KerneloopsReporter.cpp | 2 | ||||
| -rw-r--r-- | lib/Plugins/KerneloopsReporter.h | 4 | ||||
| -rw-r--r-- | lib/Plugins/Logger.cpp | 2 | ||||
| -rw-r--r-- | lib/Plugins/Logger.h | 4 | ||||
| -rw-r--r-- | lib/Plugins/Mailx.conf | 3 | ||||
| -rw-r--r-- | lib/Plugins/Mailx.cpp | 21 | ||||
| -rw-r--r-- | lib/Plugins/Mailx.h | 9 | ||||
| -rw-r--r-- | lib/Plugins/PluginSettings.h | 15 | ||||
| -rw-r--r-- | lib/Plugins/SQLite3.h | 22 |
18 files changed, 165 insertions, 139 deletions
diff --git a/lib/MiddleWare/MiddleWare.cpp b/lib/MiddleWare/MiddleWare.cpp index e1e679a..bc8e9de 100644 --- a/lib/MiddleWare/MiddleWare.cpp +++ b/lib/MiddleWare/MiddleWare.cpp @@ -182,8 +182,8 @@ void CMiddleWare::Report(const std::string& pDebugDumpDir) set_reporters_t::iterator it_r; for (it_r = m_setReporters.begin(); it_r != m_setReporters.end(); it_r++) { - CReporter* reporter = m_pPluginManager->GetReporter(*it_r); - reporter->Report(crashReport); + CReporter* reporter = m_pPluginManager->GetReporter((*it_r).first); + reporter->Report(crashReport, (*it_r).second); } } @@ -206,8 +206,8 @@ void CMiddleWare::Report(const map_crash_report_t& pCrashReport) it_r != m_mapAnalyzerReporters[analyzer].end(); it_r++) { - CReporter* reporter = m_pPluginManager->GetReporter(*it_r); - reporter->Report(pCrashReport); + CReporter* reporter = m_pPluginManager->GetReporter((*it_r).first); + reporter->Report(pCrashReport, (*it_r).second); } } @@ -337,7 +337,7 @@ void CMiddleWare::RunAnalyzerActions(const std::string& pAnalyzer, const std::st { if (m_mapAnalyzerActions.find(pAnalyzer) != m_mapAnalyzerActions.end()) { - set_actions_t::iterator it_a; + set_pairt_strings_t::iterator it_a; for (it_a = m_mapAnalyzerActions[pAnalyzer].begin(); it_a != m_mapAnalyzerActions[pAnalyzer].end(); it_a++) @@ -491,9 +491,10 @@ void CMiddleWare::AddBlackListedPackage(const std::string& pPackage) } void CMiddleWare::AddAnalyzerReporter(const std::string& pAnalyzer, - const std::string& pReporter) + const std::string& pReporter, + const std::string& pArgs) { - m_mapAnalyzerReporters[pAnalyzer].insert(pReporter); + m_mapAnalyzerReporters[pAnalyzer].insert(make_pair(pReporter, pArgs)); } void CMiddleWare::AddAnalyzerAction(const std::string& pAnalyzer, @@ -503,7 +504,8 @@ void CMiddleWare::AddAnalyzerAction(const std::string& pAnalyzer, m_mapAnalyzerActions[pAnalyzer].insert(make_pair(pAction, pArgs)); } -void CMiddleWare::AddReporter(const std::string& pReporter) +void CMiddleWare::AddReporter(const std::string& pReporter, + const std::string& pArgs) { - m_setReporters.insert(pReporter); + m_setReporters.insert(make_pair(pReporter, pArgs)); } diff --git a/lib/MiddleWare/MiddleWare.h b/lib/MiddleWare/MiddleWare.h index 28afb2a..4ec3df3 100644 --- a/lib/MiddleWare/MiddleWare.h +++ b/lib/MiddleWare/MiddleWare.h @@ -34,10 +34,11 @@ class CMiddleWare private: typedef set_strings_t set_blacklist_t; typedef set_strings_t set_enabled_plugins_t; - typedef set_strings_t set_reporters_t; - typedef std::map<std::string, set_reporters_t> map_reporter_associations_t; - typedef std::set<pair_string_string_t> set_actions_t; - typedef std::map<std::string, set_actions_t> map_action_associations_t; + + typedef std::set<pair_string_string_t> set_pairt_strings_t; + typedef std::map<std::string, set_pairt_strings_t> map_reporter_associations_t; + typedef std::map<std::string, set_pairt_strings_t> map_action_associations_t; + typedef set_pairt_strings_t set_reporters_t; CPluginManager* m_pPluginManager; CRPM m_RPM; @@ -98,11 +99,13 @@ class CMiddleWare void AddOpenGPGPublicKey(const std::string& pKey); void AddBlackListedPackage(const std::string& pPackage); void AddAnalyzerReporter(const std::string& pAnalyzer, - const std::string& pReporter); + const std::string& pReporter, + const std::string& pArgs); void AddAnalyzerAction(const std::string& pAnalyzer, const std::string& pAction, const std::string& pArgs); - void AddReporter(const std::string& pReporter); + void AddReporter(const std::string& pReporter, + const std::string& pArgs); }; #endif /*MIDDLEWARE_H_*/ diff --git a/lib/MiddleWare/Plugin.h b/lib/MiddleWare/Plugin.h index e4ebc3c..9fd5929 100644 --- a/lib/MiddleWare/Plugin.h +++ b/lib/MiddleWare/Plugin.h @@ -26,7 +26,7 @@ #include <string> #include <map> -#define PLUGINS_MAGIC_NUMBER 1 +#define PLUGINS_MAGIC_NUMBER 2 #define PLUGINS_CONF_EXTENSION "conf" #define PLUGINS_LIB_EXTENSION "so" diff --git a/lib/MiddleWare/PluginManager.cpp b/lib/MiddleWare/PluginManager.cpp index 2f103f2..cbdd2c1 100644 --- a/lib/MiddleWare/PluginManager.cpp +++ b/lib/MiddleWare/PluginManager.cpp @@ -27,8 +27,8 @@ CPluginManager::CPluginManager(const std::string& pPlugisConfDir, const std::string& pPlugisLibDir) : - m_sPlugisConfDir(pPlugisConfDir), - m_sPlugisLibDir(pPlugisLibDir) + m_sPlugisConfDir(pPlugisConfDir), + m_sPlugisLibDir(pPlugisLibDir) {} CPluginManager::~CPluginManager() @@ -36,26 +36,26 @@ CPluginManager::~CPluginManager() void CPluginManager::LoadPlugins() { - DIR *dir = opendir(m_sPlugisLibDir.c_str()); - struct dirent *dent = NULL; - if (dir != NULL) - { - while ((dent = readdir(dir)) != NULL) - { - if (dent->d_type == DT_REG) - { - std::string name = dent->d_name; - std::string extension = name.substr(name.length()-sizeof(PLUGINS_LIB_EXTENSION)+1); - if (extension == PLUGINS_LIB_EXTENSION) - { - name.erase(0, sizeof(PLUGINS_LIB_PREFIX) - 1); - name.erase(name.length() - sizeof(PLUGINS_LIB_EXTENSION)); - LoadPlugin(name); - } - } - } - closedir(dir); - } + DIR *dir = opendir(m_sPlugisLibDir.c_str()); + struct dirent *dent = NULL; + if (dir != NULL) + { + while ((dent = readdir(dir)) != NULL) + { + if (dent->d_type == DT_REG) + { + std::string name = dent->d_name; + std::string extension = name.substr(name.length()-sizeof(PLUGINS_LIB_EXTENSION)+1); + if (extension == PLUGINS_LIB_EXTENSION) + { + name.erase(0, sizeof(PLUGINS_LIB_PREFIX) - 1); + name.erase(name.length() - sizeof(PLUGINS_LIB_EXTENSION)); + LoadPlugin(name); + } + } + } + closedir(dir); + } } void CPluginManager::UnLoadPlugins() @@ -70,41 +70,41 @@ void CPluginManager::UnLoadPlugins() void CPluginManager::LoadPlugin(const std::string& pName) { - if (m_mapABRTPlugins.find(pName) == m_mapABRTPlugins.end()) - { - CABRTPlugin* abrtPlugin = NULL; - try - { - std::string libPath = m_sPlugisLibDir + "/" + PLUGINS_LIB_PREFIX + pName + "." + PLUGINS_LIB_EXTENSION; - abrtPlugin = new CABRTPlugin(libPath); - if (abrtPlugin->GetMagicNumber() != PLUGINS_MAGIC_NUMBER || - (abrtPlugin->GetType() < ANALYZER && abrtPlugin->GetType() > DATABASE)) - { - throw std::string("non-compatible plugin"); - } - std::cerr << "Plugin " << pName << " (" << abrtPlugin->GetVersion() << ") " << "succesfully loaded." << std::endl; - m_mapABRTPlugins[pName] = abrtPlugin; - } - catch (std::string sError) - { - if (abrtPlugin != NULL) - { - delete abrtPlugin; - } - std::cerr << "Failed to load plugin " << pName << " (" << sError << ")." << std::endl; - } - } + if (m_mapABRTPlugins.find(pName) == m_mapABRTPlugins.end()) + { + CABRTPlugin* abrtPlugin = NULL; + try + { + std::string libPath = m_sPlugisLibDir + "/" + PLUGINS_LIB_PREFIX + pName + "." + PLUGINS_LIB_EXTENSION; + abrtPlugin = new CABRTPlugin(libPath); + if (abrtPlugin->GetMagicNumber() != PLUGINS_MAGIC_NUMBER || + (abrtPlugin->GetType() < ANALYZER && abrtPlugin->GetType() > DATABASE)) + { + throw std::string("non-compatible plugin"); + } + std::cerr << "Plugin " << pName << " (" << abrtPlugin->GetVersion() << ") " << "succesfully loaded." << std::endl; + m_mapABRTPlugins[pName] = abrtPlugin; + } + catch (std::string sError) + { + if (abrtPlugin != NULL) + { + delete abrtPlugin; + } + std::cerr << "Failed to load plugin " << pName << " (" << sError << ")." << std::endl; + } + } } void CPluginManager::UnLoadPlugin(const std::string& pName) { - if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end()) - { - UnRegisterPlugin(pName); - delete m_mapABRTPlugins[pName]; - m_mapABRTPlugins.erase(pName); - std::cerr << "Plugin " << pName << " sucessfully unloaded." << std::endl; - } + if (m_mapABRTPlugins.find(pName) != m_mapABRTPlugins.end()) + { + UnRegisterPlugin(pName); + delete m_mapABRTPlugins[pName]; + m_mapABRTPlugins.erase(pName); + std::cerr << "Plugin " << pName << " sucessfully unloaded." << std::endl; + } } @@ -155,41 +155,41 @@ void CPluginManager::UnRegisterPlugin(const std::string& pName) CAnalyzer* CPluginManager::GetAnalyzer(const std::string& pName) { - if (m_mapPlugins.find(pName) == m_mapPlugins.end()) - { - throw std::string("CPluginManager::GetAnalyzer():" - "Analyzer plugin: '"+pName+"' is not loaded."); - } - return dynamic_cast<CAnalyzer*>(m_mapPlugins[pName]); + if (m_mapPlugins.find(pName) == m_mapPlugins.end()) + { + throw std::string("CPluginManager::GetAnalyzer():" + "Analyzer plugin: '"+pName+"' is not loaded."); + } + return dynamic_cast<CAnalyzer*>(m_mapPlugins[pName]); } CReporter* CPluginManager::GetReporter(const std::string& pName) { - if (m_mapPlugins.find(pName) == m_mapPlugins.end()) - { - throw std::string("CPluginManager::GetReporter():" - "Reporter plugin: '"+pName+"' is not loaded."); - } - return dynamic_cast<CReporter*>(m_mapPlugins[pName]); + if (m_mapPlugins.find(pName) == m_mapPlugins.end()) + { + throw std::string("CPluginManager::GetReporter():" + "Reporter plugin: '"+pName+"' is not loaded."); + } + return dynamic_cast<CReporter*>(m_mapPlugins[pName]); } CAction* CPluginManager::GetAction(const std::string& pName) { - if (m_mapPlugins.find(pName) == m_mapPlugins.end()) - { - throw std::string("CPluginManager::GetAction():" - "Action plugin: '"+pName+"' is not loaded."); - } - return dynamic_cast<CAction*>(m_mapPlugins[pName]); + if (m_mapPlugins.find(pName) == m_mapPlugins.end()) + { + throw std::string("CPluginManager::GetAction():" + "Action plugin: '"+pName+"' is not loaded."); + } + return dynamic_cast<CAction*>(m_mapPlugins[pName]); } CDatabase* CPluginManager::GetDatabase(const std::string& pName) { - if (m_mapPlugins.find(pName) == m_mapPlugins.end()) - { - throw std::string("CPluginManager::GetDatabase():" - "Database plugin: '"+pName+"' is not loaded."); - } - return dynamic_cast<CDatabase*>(m_mapPlugins[pName]); + if (m_mapPlugins.find(pName) == m_mapPlugins.end()) + { + throw std::string("CPluginManager::GetDatabase():" + "Database plugin: '"+pName+"' is not loaded."); + } + return dynamic_cast<CDatabase*>(m_mapPlugins[pName]); } diff --git a/lib/MiddleWare/Reporter.h b/lib/MiddleWare/Reporter.h index 02fae12..76680df 100644 --- a/lib/MiddleWare/Reporter.h +++ b/lib/MiddleWare/Reporter.h @@ -29,9 +29,9 @@ class CReporter : public CPlugin { public: - virtual ~CReporter() {} - virtual void Report(const map_crash_report_t& pCrashReport) = 0; + virtual void Report(const map_crash_report_t& pCrashReport, + const std::string& pArgs) = 0; }; #endif /* REPORTER_H_ */ diff --git a/lib/Plugins/Bugzilla.cpp b/lib/Plugins/Bugzilla.cpp index 2a1c1bb..b4f44b0 100644 --- a/lib/Plugins/Bugzilla.cpp +++ b/lib/Plugins/Bugzilla.cpp @@ -162,7 +162,7 @@ void CReporterBugzilla::NewBug(const map_crash_report_t& pCrashReport) } -void CReporterBugzilla::Report(const map_crash_report_t& pCrashReport) +void CReporterBugzilla::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs) { std::string package = pCrashReport.find(FILENAME_PACKAGE)->second[CD_CONTENT]; std::string component = package.substr(0, package.rfind("-", package.rfind("-")-1)); diff --git a/lib/Plugins/Bugzilla.h b/lib/Plugins/Bugzilla.h index ff6d551..075484a 100644 --- a/lib/Plugins/Bugzilla.h +++ b/lib/Plugins/Bugzilla.h @@ -31,7 +31,8 @@ class CReporterBugzilla : public CReporter CReporterBugzilla(); virtual ~CReporterBugzilla(); virtual void LoadSettings(const std::string& pPath); - virtual void Report(const map_crash_report_t& pCrashReport); + virtual void Report(const map_crash_report_t& pCrashReport, + const std::string& pArgs); }; PLUGIN_INFO(REPORTER, diff --git a/lib/Plugins/CCpp.h b/lib/Plugins/CCpp.h index 1011b70..222bcbf 100644 --- a/lib/Plugins/CCpp.h +++ b/lib/Plugins/CCpp.h @@ -42,12 +42,12 @@ class CAnalyzerCCpp : public CAnalyzer public: CAnalyzerCCpp(); virtual ~CAnalyzerCCpp(); - std::string GetLocalUUID(const std::string& pDebugDumpDir); - std::string GetGlobalUUID(const std::string& pDebugDumpDir); - void CreateReport(const std::string& pDebugDumpDir); - void Init(); - void DeInit(); - void LoadSettings(const std::string& pPath); + virtual std::string GetLocalUUID(const std::string& pDebugDumpDir); + virtual std::string GetGlobalUUID(const std::string& pDebugDumpDir); + virtual void CreateReport(const std::string& pDebugDumpDir); + virtual void Init(); + virtual void DeInit(); + virtual void LoadSettings(const std::string& pPath); }; diff --git a/lib/Plugins/Kerneloops.h b/lib/Plugins/Kerneloops.h index 0eccb08..2fa9026 100644 --- a/lib/Plugins/Kerneloops.h +++ b/lib/Plugins/Kerneloops.h @@ -45,11 +45,11 @@ class CAnalyzerKerneloops : public CAnalyzer public: CAnalyzerKerneloops(); virtual ~CAnalyzerKerneloops() {} - std::string GetLocalUUID(const std::string& pDebugDumpDir); - std::string GetGlobalUUID(const std::string& pDebugDumpDir); - void Init(); - void CreateReport(const std::string& pDebugDumpDir) {} - void LoadSettings(const std::string& pPath); + virtual std::string GetLocalUUID(const std::string& pDebugDumpDir); + virtual std::string GetGlobalUUID(const std::string& pDebugDumpDir); + virtual void Init(); + virtual void CreateReport(const std::string& pDebugDumpDir) {} + virtual void LoadSettings(const std::string& pPath); void ScanDmesg(); void ScanSysLogFile(const char *filename, int issyslog); }; diff --git a/lib/Plugins/KerneloopsReporter.cpp b/lib/Plugins/KerneloopsReporter.cpp index 7121910..15af3ac 100644 --- a/lib/Plugins/KerneloopsReporter.cpp +++ b/lib/Plugins/KerneloopsReporter.cpp @@ -57,7 +57,7 @@ size_t writefunction(void *ptr, size_t size, size_t nmemb, void __attribute((unu return size * nmemb; } -void CKerneloopsReporter::Report(const map_crash_report_t& pCrashReport) +void CKerneloopsReporter::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs) { CURL *handle; struct curl_httppost *post = NULL; diff --git a/lib/Plugins/KerneloopsReporter.h b/lib/Plugins/KerneloopsReporter.h index 7c06d99..dc01b53 100644 --- a/lib/Plugins/KerneloopsReporter.h +++ b/lib/Plugins/KerneloopsReporter.h @@ -41,8 +41,8 @@ class CKerneloopsReporter : public CReporter CKerneloopsReporter(); virtual ~CKerneloopsReporter() {} - void LoadSettings(const std::string& pPath); - void Report(const map_crash_report_t& pCrashReport); + virtual void LoadSettings(const std::string& pPath); + virtual void Report(const map_crash_report_t& pCrashReport, const std::string& pArgs); }; PLUGIN_INFO(REPORTER, diff --git a/lib/Plugins/Logger.cpp b/lib/Plugins/Logger.cpp index 8f89838..d340b2d 100644 --- a/lib/Plugins/Logger.cpp +++ b/lib/Plugins/Logger.cpp @@ -45,7 +45,7 @@ void CLogger::LoadSettings(const std::string& pPath) } } -void CLogger::Report(const map_crash_report_t& pCrashReport) +void CLogger::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs) { std::stringstream binaryFiles, commonFiles, bigTextFiles, additionalFiles, UUIDFile; std::ofstream fOut; diff --git a/lib/Plugins/Logger.h b/lib/Plugins/Logger.h index f5db73f..62b6a1d 100644 --- a/lib/Plugins/Logger.h +++ b/lib/Plugins/Logger.h @@ -35,8 +35,8 @@ class CLogger : public CReporter CLogger(); virtual ~CLogger() {} - void LoadSettings(const std::string& pPath); - void Report(const map_crash_report_t& pCrashReport); + virtual void LoadSettings(const std::string& pPath); + virtual void Report(const map_crash_report_t& pCrashReport, const std::string& pArgs); }; diff --git a/lib/Plugins/Mailx.conf b/lib/Plugins/Mailx.conf index c1bddff..73f669b 100644 --- a/lib/Plugins/Mailx.conf +++ b/lib/Plugins/Mailx.conf @@ -1,4 +1,7 @@ # Configuration to Email reporter plugin +# Subject of an emain +Subject = "[abrt] crash report" + # Parameters Parameters = diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index 8aacef3..b7cdcfe 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -26,23 +26,23 @@ #include "PluginSettings.h" #define MAILX_COMMAND "/bin/mailx" -#define MAILX_SUBJECT "\"abrt automated bug report\"" CMailx::CMailx() : m_sEmailFrom("user@localhost"), m_sEmailTo("root@localhost"), m_sParameters(""), m_sAttachments(""), + m_sSubject("[abrt] full crash report"), m_bSendBinaryData(false) {} -void CMailx::SendEmail(const std::string& pText) +void CMailx::SendEmail(const std::string& pSubject, const std::string& pText) { FILE* command; std::string mailx_command = MAILX_COMMAND + m_sAttachments + " " + m_sParameters + - " -s " + MAILX_SUBJECT + + " -s " + pSubject + " -r " + m_sEmailFrom + " " + m_sEmailTo; command = popen(mailx_command.c_str(), "w"); @@ -58,7 +58,7 @@ void CMailx::SendEmail(const std::string& pText) } -void CMailx::Report(const map_crash_report_t& pCrashReport) +void CMailx::Report(const map_crash_report_t& pCrashReport, const std::string& pArgs) { std::stringstream emailBody; std::stringstream binaryFiles, commonFiles, bigTextFiles, additionalFiles, UUIDFile; @@ -118,7 +118,14 @@ void CMailx::Report(const map_crash_report_t& pCrashReport) m_sAttachments += binaryFiles.str(); } - SendEmail(emailBody.str()); + if (pArgs != "") + { + SendEmail(pArgs, emailBody.str()); + } + else + { + SendEmail(m_sSubject, emailBody.str()); + } } void CMailx::LoadSettings(const std::string& pPath) @@ -126,6 +133,10 @@ void CMailx::LoadSettings(const std::string& pPath) map_settings_t settings; plugin_load_settings(pPath, settings); + if (settings.find("Subject")!= settings.end()) + { + m_sSubject = settings["Subject"]; + } if (settings.find("EmailFrom")!= settings.end()) { m_sEmailFrom = settings["EmailFrom"]; diff --git a/lib/Plugins/Mailx.h b/lib/Plugins/Mailx.h index 3100a17..2f5c343 100644 --- a/lib/Plugins/Mailx.h +++ b/lib/Plugins/Mailx.h @@ -34,23 +34,24 @@ class CMailx : public CReporter std::string m_sEmailTo; std::string m_sParameters; std::string m_sAttachments; + std::string m_sSubject; bool m_bSendBinaryData; - void SendEmail(const std::string& pText); + void SendEmail(const std::string& pSubject, const std::string& pText); public: CMailx(); virtual ~CMailx() {} - void LoadSettings(const std::string& pPath); - void Report(const map_crash_report_t& pCrashReport); + virtual void LoadSettings(const std::string& pPath); + virtual void Report(const map_crash_report_t& pCrashReport, const std::string& pArgs); }; PLUGIN_INFO(REPORTER, CMailx, "Mailx", - "0.0.1", + "0.0.2", "Sends an email with a report via mailx command", "zprikryl@redhat.com", "https://fedorahosted.org/crash-catcher/wiki"); diff --git a/lib/Plugins/PluginSettings.h b/lib/Plugins/PluginSettings.h index d331b35..92af525 100644 --- a/lib/Plugins/PluginSettings.h +++ b/lib/Plugins/PluginSettings.h @@ -43,23 +43,28 @@ inline void plugin_load_settings(const std::string& path, map_settings_t& settin int ii; bool is_value = false; bool valid = false; + bool in_quote = false; std::string key = ""; std::string value = ""; for (ii = 0; ii < line.length(); ii++) { - if (isspace(line[ii])) + if (line[ii] == '\"') + { + in_quote = in_quote == true ? false : true; + } + if (isspace(line[ii]) && !in_quote) { continue; } - if (line[ii] == '#') + if (line[ii] == '#' && !in_quote) { break; } - else if (line[ii] == '=') + else if (line[ii] == '=' && !in_quote) { is_value = true; } - else if (line[ii] == '=' && is_value) + else if (line[ii] == '=' && is_value && !in_quote) { key = ""; value = ""; @@ -75,7 +80,7 @@ inline void plugin_load_settings(const std::string& path, map_settings_t& settin value += line[ii]; } } - if (valid) + if (valid && !in_quote) { settings[key] = value; } diff --git a/lib/Plugins/SQLite3.h b/lib/Plugins/SQLite3.h index 055c059..2280f33 100644 --- a/lib/Plugins/SQLite3.h +++ b/lib/Plugins/SQLite3.h @@ -45,20 +45,20 @@ class CSQLite3 : public CDatabase CSQLite3(); virtual ~CSQLite3() {} - void Connect(); - void DisConnect(); + virtual void Connect(); + virtual void DisConnect(); - void Insert(const std::string& pUUID, - const std::string& pUID, - const std::string& pDebugDumpPath, - const std::string& pTime); + virtual void Insert(const std::string& pUUID, + const std::string& pUID, + const std::string& pDebugDumpPath, + const std::string& pTime); - void Delete(const std::string& pUUID, const std::string& pUID); - void SetReported(const std::string& pUUID, const std::string& pUID); - const vector_database_rows_t GetUIDData(const std::string& pUID); - const database_row_t GetUUIDData(const std::string& pUUID, const std::string& pUID); + virtual void Delete(const std::string& pUUID, const std::string& pUID); + virtual void SetReported(const std::string& pUUID, const std::string& pUID); + virtual const vector_database_rows_t GetUIDData(const std::string& pUID); + virtual const database_row_t GetUUIDData(const std::string& pUUID, const std::string& pUID); - void LoadSettings(const std::string& pPath); + virtual void LoadSettings(const std::string& pPath); }; PLUGIN_INFO(DATABASE, |
