summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNikola Pajkovsky <npajkovs@redhat.com>2010-10-06 12:42:13 +0200
committerNikola Pajkovsky <npajkovs@redhat.com>2010-10-06 12:42:13 +0200
commit350eacf7f1948d52d6c71789845b0b640bb048ac (patch)
treed4b296a0b348b4d5a2ec878de91a3432708c34d3 /src
parent4fb70fe4df4e54f8da1a8c356fa7724180c96181 (diff)
parent2a43414497aa857d9dbf3e2dc04ac207d5730335 (diff)
downloadabrt-350eacf7f1948d52d6c71789845b0b640bb048ac.tar.gz
abrt-350eacf7f1948d52d6c71789845b0b640bb048ac.tar.xz
abrt-350eacf7f1948d52d6c71789845b0b640bb048ac.zip
Merge branch 'vector_string_t'
* vector_string_t: report.cpp: split() uses GList Kerneloops*.cpp and dumpoops.cpp uses GList Daemon.cpp: FindNewDumps() uses GList
Diffstat (limited to 'src')
-rw-r--r--src/cli/Makefile.am5
-rw-r--r--src/cli/report.cpp24
-rw-r--r--src/daemon/Daemon.cpp18
-rw-r--r--src/hooks/Makefile.am4
-rw-r--r--src/hooks/dumpoops.cpp24
5 files changed, 49 insertions, 26 deletions
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index 3c1a3432..be8e7d8e 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -11,13 +11,14 @@ abrt_cli_CPPFLAGS = \
-I$(srcdir)/../../lib/utils \
-DVAR_RUN=\"$(VAR_RUN)\" \
$(ENABLE_SOCKET_OR_DBUS) \
- $(DBUS_CFLAGS) \
+ $(DBUS_CFLAGS) $(GLIB_CFLAGS) \
-D_GNU_SOURCE
# $(GTK_CFLAGS)
abrt_cli_LDADD = \
../../lib/utils/libABRTUtils.la \
- ../../lib/utils/libABRTdUtils.la
+ ../../lib/utils/libABRTdUtils.la \
+ $(GLIB_LIBS)
man_MANS = abrt-cli.1
EXTRA_DIST = $(man_MANS)
diff --git a/src/cli/report.cpp b/src/cli/report.cpp
index 8099a92e..cb6e2081 100644
--- a/src/cli/report.cpp
+++ b/src/cli/report.cpp
@@ -15,9 +15,8 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <cassert>
-#include <algorithm>
#include <termios.h>
+#include <glib.h>
#include "report.h"
#include "run-command.h"
#include "dbus.h"
@@ -445,13 +444,13 @@ static void read_from_stdin(const char *question, char *result, int result_size)
* Specifies a set of characters that delimit the
* tokens in the parsed string
*/
-static vector_string_t split(const char *s, const char delim)
+static GList *split(const char *s, const char delim)
{
- std::vector<std::string> elems;
+ GList *elems = NULL;
while (1)
{
const char *end = strchrnul(s, delim);
- elems.push_back(std::string(s, end - s));
+ elems = g_list_append(elems, xstrndup(s, end - s));
if (*end == '\0')
break;
s = end + 1;
@@ -505,7 +504,7 @@ static vector_string_t get_enabled_reporters(map_crash_data_t &crash_data)
}
/* Reporters found, now parse the list. */
- vector_string_t reporter_vec = split(reporters_iter->second.c_str(), ',');
+ GList *reporter_list = split(reporters_iter->second.c_str(), ',');
// Get informations about all plugins.
map_map_string_t plugins = call_GetPluginsInfo();
@@ -520,10 +519,17 @@ static vector_string_t get_enabled_reporters(map_crash_data_t &crash_data)
if (0 != strcmp(it->second["Type"].c_str(), "Reporter"))
continue;
// Skip plugins not used in this particular crash.
- if (reporter_vec.end() == std::find(reporter_vec.begin(), reporter_vec.end(), std::string(it->first)))
- continue;
- result.push_back(it->first);
+ for (GList *li = reporter_list; li != NULL; li = g_list_next(li))
+ {
+ if (strcmp((char*)li->data, it->first.c_str()) == 0)
+ result.push_back(it->first);
+ }
}
+
+ for (GList *li = reporter_list; li != NULL; li = g_list_next(li))
+ free((char*)li->data);
+ g_list_free(reporter_list);
+
return result;
}
diff --git a/src/daemon/Daemon.cpp b/src/daemon/Daemon.cpp
index 7f36b318..548067bd 100644
--- a/src/daemon/Daemon.cpp
+++ b/src/daemon/Daemon.cpp
@@ -391,7 +391,7 @@ static int SetUpCron()
static void FindNewDumps(const char* pPath)
{
/* Get all debugdump directories in the pPath directory */
- vector_string_t dirs;
+ GList *dirs = NULL;
DIR *dp = opendir(pPath);
if (dp == NULL)
{
@@ -410,25 +410,25 @@ static void FindNewDumps(const char* pPath)
if (S_ISDIR(stats.st_mode))
{
VERB1 log("Will check directory '%s'", ep->d_name);
- dirs.push_back(dname);
+ dirs = g_list_append(dirs, dname);
+ continue;
}
}
free(dname);
}
closedir(dp);
- unsigned size = dirs.size();
+ unsigned size = g_list_length(dirs);
if (size == 0)
return;
log("Checking for unsaved crashes (dirs to check:%u)", size);
/* Get potentially non-processed debugdumps */
- vector_string_t::iterator itt = dirs.begin();
- for (; itt != dirs.end(); ++itt)
+ for (GList *li = dirs; li != NULL; li = g_list_next(li))
{
try
{
- const char *dir_name = itt->c_str();
+ const char *dir_name = (char*)dirs->data;
map_crash_data_t crashinfo;
mw_result_t res = SaveDebugDump(dir_name, crashinfo);
switch (res)
@@ -461,6 +461,12 @@ static void FindNewDumps(const char* pPath)
error_msg("%s", e.what());
}
}
+
+ for (GList *li = dirs; li != NULL; li = g_list_next(li))
+ free(li->data);
+
+ g_list_free(dirs);
+
log("Done checking for unsaved crashes");
}
diff --git a/src/hooks/Makefile.am b/src/hooks/Makefile.am
index 55ffc446..4d7c342a 100644
--- a/src/hooks/Makefile.am
+++ b/src/hooks/Makefile.am
@@ -24,11 +24,13 @@ dumpoops_CPPFLAGS = \
-DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \
-DCONF_DIR=\"$(CONF_DIR)\" \
-DVAR_RUN=\"$(VAR_RUN)\" \
+ $(GLIB_CFLAGS) \
-D_GNU_SOURCE
# build will succeed, but at runtime plugins do need ABRT*d*Utils
dumpoops_LDADD = \
../../lib/utils/libABRTUtils.la \
- ../../lib/utils/libABRTdUtils.la
+ ../../lib/utils/libABRTdUtils.la \
+ $(GLIB_FLAGS)
python_PYTHON = abrt.pth abrt_exception_handler.py
EXTRA_DIST = abrt_exception_handler.py.in $(man_MANS)
diff --git a/src/hooks/dumpoops.cpp b/src/hooks/dumpoops.cpp
index 547ece9d..c67f8cda 100644
--- a/src/hooks/dumpoops.cpp
+++ b/src/hooks/dumpoops.cpp
@@ -25,6 +25,7 @@
#include "abrt_exception.h"
#include "KerneloopsScanner.h"
#include <dlfcn.h>
+#include <glib.h>
#define LOADSYM(fp, name) \
do { \
@@ -75,8 +76,8 @@ usage:
/* Load KerneloopsScanner plugin */
// const plugin_info_t *plugin_info;
CPlugin* (*plugin_newf)(void);
- int (*scan_syslog_file)(vector_string_t& oopsList, const char *filename, time_t *last_changed_p);
- int (*save_oops_to_debug_dump)(const vector_string_t& oopsList);
+ int (*scan_syslog_file)(GList **oopsList, const char *filename, time_t *last_changed_p);
+ int (*save_oops_to_debug_dump)(GList **oopsList);
void *handle;
errno = 0;
@@ -95,21 +96,22 @@ usage:
// scanner->LoadSettings(path);
/* Use it: parse and dump the oops */
- vector_string_t oopsList;
- int cnt = scan_syslog_file(oopsList, argv[0], NULL);
+ GList *oopsList = NULL;
+ int cnt = scan_syslog_file(&oopsList, argv[0], NULL);
log("found oopses: %d", cnt);
if (cnt > 0) {
if (opt_s) {
int i = 0;
- while (i < oopsList.size()) {
- printf("\nVersion: %s", oopsList[i].c_str());
+ int length = g_list_length(oopsList);
+ while (i < length) {
+ printf("\nVersion: %s", (char*)g_list_nth_data(oopsList, i));
i++;
}
}
if (opt_d) {
log("dumping oopses");
- int errors = save_oops_to_debug_dump(oopsList);
+ int errors = save_oops_to_debug_dump(&oopsList);
if (errors > 0)
{
log("%d errors while dumping oopses", errors);
@@ -118,6 +120,12 @@ usage:
}
}
- /*dlclose(handle); - why bother? */
+ for (GList *li = oopsList; li != NULL; li = g_list_next(li))
+ free((char*)li->data);
+
+ g_list_free(oopsList);
+ /*dlclose(handle); - why bother?
+ * cos we are handsome and good lookin' guys :D
+ */
return 0;
}