diff options
| author | Karel Klic <kklic@redhat.com> | 2010-02-15 10:13:34 +0100 |
|---|---|---|
| committer | Karel Klic <kklic@redhat.com> | 2010-02-15 10:13:34 +0100 |
| commit | f49b4e72dc22d004ada91292fcd7179956de81c4 (patch) | |
| tree | 92edd09227bd41e738e004c0e45444d39452c012 /lib | |
| parent | e245149118bff4a364fb6fbb0651b1f09e0ce0bc (diff) | |
| parent | f97428655a81cea935fd0a8cc93af83e712df299 (diff) | |
| download | abrt-f49b4e72dc22d004ada91292fcd7179956de81c4.tar.gz abrt-f49b4e72dc22d004ada91292fcd7179956de81c4.tar.xz abrt-f49b4e72dc22d004ada91292fcd7179956de81c4.zip | |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Plugins/Bugzilla.conf | 2 | ||||
| -rw-r--r-- | lib/Plugins/Makefile.am | 30 | ||||
| -rw-r--r-- | lib/Utils/Plugin.cpp | 69 | ||||
| -rw-r--r-- | lib/Utils/Plugin.h | 18 | ||||
| -rw-r--r-- | lib/Utils/xfuncs.cpp | 2 |
5 files changed, 109 insertions, 12 deletions
diff --git a/lib/Plugins/Bugzilla.conf b/lib/Plugins/Bugzilla.conf index 14fc92c..ff2f828 100644 --- a/lib/Plugins/Bugzilla.conf +++ b/lib/Plugins/Bugzilla.conf @@ -1,4 +1,4 @@ -Enabled = 1 +Enabled = yes # Bugzilla URL BugzillaURL = https://bugzilla.redhat.com/ # yes means that ssl certificates will not be checked diff --git a/lib/Plugins/Makefile.am b/lib/Plugins/Makefile.am index 4fc0efe..fe3969f 100644 --- a/lib/Plugins/Makefile.am +++ b/lib/Plugins/Makefile.am @@ -7,6 +7,7 @@ pluginslib_LTLIBRARIES = \ libLogger.la \ libKerneloopsScanner.la\ libKerneloops.la \ + libKerneloopsReporter.la \ libRunApp.la \ libSOSreport.la \ libBugzilla.la \ @@ -18,8 +19,11 @@ pluginslib_LTLIBRARIES = \ dist_pluginslib_DATA = \ Logger.GTKBuilder \ - Mailx.GTKBuilder Bugzilla.GTKBuilder \ - TicketUploader.GTKBuilder Catcut.GTKBuilder + Mailx.GTKBuilder \ + Bugzilla.GTKBuilder \ + TicketUploader.GTKBuilder \ + Catcut.GTKBuilder \ + KerneloopsReporter.GTKBuilder pluginsconfdir = $(PLUGINS_CONF_DIR) dist_pluginsconf_DATA = \ @@ -35,9 +39,17 @@ dist_pluginsconf_DATA = \ Python.conf \ SOSreport.conf -man_MANS = abrt-FileTransfer.7 abrt-Bugzilla.7 \ - abrt-KerneloopsScanner.7 abrt-Logger.7 abrt-Mailx.7 abrt-plugins.7 \ - abrt-SQLite3.7 abrt-RunApp.7 abrt-TicketUploader.7 +man_MANS = \ + abrt-FileTransfer.7 \ + abrt-Bugzilla.7 \ + abrt-KerneloopsScanner.7 \ + abrt-KerneloopsReporter.7 \ + abrt-Logger.7 abrt-Mailx.7 \ + abrt-plugins.7 \ + abrt-SQLite3.7 \ + abrt-RunApp.7 \ + abrt-TicketUploader.7 + # + abrt-Catcut.7 EXTRA_DIST = $(man_MANS) @@ -78,10 +90,10 @@ libKerneloops_la_LDFLAGS = -avoid-version libKerneloops_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../Utils # KerneloopsReporter -#libKerneloopsReporter_la_SOURCES = KerneloopsReporter.cpp KerneloopsReporter.h -#libKerneloopsReporter_la_LDFLAGS = -avoid-version -#libKerneloopsReporter_la_LIBADD = $(CURL_LIBS) -#libKerneloopsReporter_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../Utils $(CURL_CFLAGS) -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" +libKerneloopsReporter_la_SOURCES = KerneloopsReporter.cpp KerneloopsReporter.h +libKerneloopsReporter_la_LDFLAGS = -avoid-version +libKerneloopsReporter_la_LIBADD = $(CURL_LIBS) +libKerneloopsReporter_la_CPPFLAGS = -I$(srcdir)/../../inc -I$(srcdir)/../Utils $(CURL_CFLAGS) -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" # KerneloopsScanner libKerneloopsScanner_la_SOURCES = KerneloopsScanner.cpp KerneloopsScanner.h KerneloopsSysLog.cpp KerneloopsSysLog.h diff --git a/lib/Utils/Plugin.cpp b/lib/Utils/Plugin.cpp index 2865027..40cd2a0 100644 --- a/lib/Utils/Plugin.cpp +++ b/lib/Utils/Plugin.cpp @@ -17,6 +17,7 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "Plugin.h" +#include "abrtlib.h" CPlugin::CPlugin() {} @@ -33,3 +34,71 @@ const map_plugin_settings_t& CPlugin::GetSettings() { return m_pSettings; } + +bool LoadPluginSettings(const char *pPath, map_plugin_settings_t& pSettings, + bool skipKeysWithoutValue /*= true*/) +{ + FILE *fp = fopen(pPath, "r"); + if (!fp) + return false; + + char line[512]; + while (fgets(line, sizeof(line), fp)) + { + strchrnul(line, '\n')[0] = '\0'; + unsigned ii; + bool is_value = false; + bool valid = false; + bool in_quote = false; + std::string key; + std::string value; + for (ii = 0; line[ii] != '\0'; ii++) + { + if (line[ii] == '"') + { + in_quote = !in_quote; + } + if (isspace(line[ii]) && !in_quote) + { + continue; + } + if (line[ii] == '#' && !in_quote && key == "") + { + break; + } + if (line[ii] == '=' && !in_quote) + { + is_value = true; + valid = true; + continue; + } + if (!is_value) + { + key += line[ii]; + } + else + { + value += line[ii]; + } + } + + /* Skip broken or empty lines. */ + if (!valid) + continue; + + /* Skip lines with empty key. */ + if (key.length() == 0) + continue; + + if (skipKeysWithoutValue && value.length() == 0) + continue; + + /* Skip lines with unclosed quotes. */ + if (in_quote) + continue; + + pSettings[key] = value; + } + fclose(fp); + return true; +} diff --git a/lib/Utils/Plugin.h b/lib/Utils/Plugin.h index c699eb3..edd1561 100644 --- a/lib/Utils/Plugin.h +++ b/lib/Utils/Plugin.h @@ -118,9 +118,25 @@ typedef struct SPluginInfo PLUGINS_MAGIC_NUMBER,\ }; -/* helper finctions */ +/* helper functions */ std::string make_description_bz(const map_crash_data_t& pCrashData); std::string make_description_logger(const map_crash_data_t& pCrashData); std::string make_description_catcut(const map_crash_data_t& pCrashData); +/** + * Loads settings and stores it in second parameter. On success it + * returns true, otherwise returns false. + * + * @param path A path of config file. + * Config file consists of "key=value" lines. + * @param settings A readed plugin's settings. + * @param skipKeysWithoutValue + * If true, lines in format "key=" (without value) are skipped. + * Otherwise empty value "" is inserted into pSettings. + * @return if it success it returns true, otherwise it returns false. + */ +extern bool LoadPluginSettings(const char *pPath, + map_plugin_settings_t& pSettings, + bool skipKeysWithoutValue = true); + #endif diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp index 16f4cb0..7301d7f 100644 --- a/lib/Utils/xfuncs.cpp +++ b/lib/Utils/xfuncs.cpp @@ -252,7 +252,7 @@ void xstat(const char *name, struct stat *stat_buf) perror_msg_and_die("can't stat '%s'", name); } -std::string get_home_dir(int uid) +std::string get_home_dir(uid_t uid) { struct passwd* pw = getpwuid(uid); return pw ? pw->pw_dir : ""; |
