vector_string_t was replaced by glist in these files
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
lib/plugins/KerneloopsScanner.cpp | 28 ++++++++++++++++------------
lib/plugins/KerneloopsSysLog.cpp | 10 ++++++----
lib/plugins/KerneloopsSysLog.h | 3 ++-
lib/plugins/Makefile.am | 4 ++--
src/hooks/Makefile.am | 4 +++-
src/hooks/dumpoops.cpp | 25 +++++++++++++++++--------
6 files changed, 46 insertions(+), 28 deletions(-)
diff --git a/lib/plugins/KerneloopsScanner.cpp b/lib/plugins/KerneloopsScanner.cpp
index e0e6443..0e7d4dc 100644
--- a/lib/plugins/KerneloopsScanner.cpp
+++ b/lib/plugins/KerneloopsScanner.cpp
@@ -22,6 +22,7 @@
*/
#include <syslog.h>
#include <asm/unistd.h> /* __NR_syslog */
+#include <glib.h>
#include "abrtlib.h"
#include "abrt_exception.h"
#include "comm_layer_inner.h"
@@ -30,7 +31,7 @@
// TODO:
https://fedorahosted.org/abrt/ticket/78
-static int scan_dmesg(vector_string_t& oopsList)
+static int scan_dmesg(GList **oopsList)
{
VERB1 log("Scanning dmesg");
@@ -51,7 +52,7 @@ static int scan_dmesg(vector_string_t& oopsList)
/* "dumpoops" tool uses these two functions too */
extern "C" {
-int scan_syslog_file(vector_string_t& oopsList, const char *filename, time_t
*last_changed_p)
+int scan_syslog_file(GList **oopsList, const char *filename, time_t *last_changed_p)
{
VERB1 log("Scanning syslog file '%s'", filename);
@@ -111,10 +112,10 @@ int scan_syslog_file(vector_string_t& oopsList, const char
*filename, time_t *la
}
/* returns number of errors */
-int save_oops_to_debug_dump(const vector_string_t& oopsList)
+int save_oops_to_debug_dump(GList **oopsList)
{
unsigned countdown = 16; /* do not report hundreds of oopses */
- unsigned idx = oopsList.size();
+ unsigned idx = g_list_length(*oopsList);
time_t t = time(NULL);
pid_t my_pid = getpid();
@@ -127,8 +128,7 @@ int save_oops_to_debug_dump(const vector_string_t& oopsList)
char path[sizeof(DEBUG_DUMPS_DIR"/kerneloops-%lu-%lu-%lu") + 3 *
sizeof(long)*3];
sprintf(path, DEBUG_DUMPS_DIR"/kerneloops-%lu-%lu-%lu", (long)t,
(long)my_pid, (long)idx);
- std::string oops = oopsList.at(--idx);
- const char *first_line = oops.c_str();
+ char *first_line = (char*)g_list_nth_data(*oopsList,--idx);
char *second_line = (char*)strchr(first_line, '\n'); /* never NULL */
*second_line++ = '\0';
@@ -161,11 +161,11 @@ CKerneloopsScanner::CKerneloopsScanner()
m_syslog_last_change = 0;
/* Scan dmesg, on first call only */
- vector_string_t oopsList;
- cnt_FoundOopses = scan_dmesg(oopsList);
+ GList *oopsList = NULL;
+ cnt_FoundOopses = scan_dmesg(&oopsList);
if (cnt_FoundOopses > 0)
{
- 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);
}
@@ -178,11 +178,11 @@ void CKerneloopsScanner::Run(const char *pActionDir, const char
*pArgs, int forc
if (it != m_pSettings.end())
syslog_file = it->second.c_str();
- vector_string_t oopsList;
- int cnt_FoundOopses = scan_syslog_file(oopsList, syslog_file,
&m_syslog_last_change);
+ GList *oopsList = NULL;
+ int cnt_FoundOopses = scan_syslog_file(&oopsList, syslog_file,
&m_syslog_last_change);
if (cnt_FoundOopses > 0)
{
- 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);
/*
@@ -198,6 +198,10 @@ void CKerneloopsScanner::Run(const char *pActionDir, const char
*pArgs, int forc
cnt_FoundOopses);
closelog();
}
+
+ for (GList *li = oopsList; li != NULL; li = g_list_next(li))
+ free((char*)li->data);
+ g_list_free(oopsList);
}
PLUGIN_INFO(ACTION,
diff --git a/lib/plugins/KerneloopsSysLog.cpp b/lib/plugins/KerneloopsSysLog.cpp
index 8594bf4..68f309b 100644
--- a/lib/plugins/KerneloopsSysLog.cpp
+++ b/lib/plugins/KerneloopsSysLog.cpp
@@ -18,10 +18,12 @@
*/
#include "abrtlib.h"
#include "KerneloopsSysLog.h"
+#include <glib.h>
-static void queue_oops(vector_string_t &vec, const char *data, const char *version)
+static void queue_oops(GList **vec, const char *data, const char *version)
{
- vec.push_back(ssprintf("%s\n%s", version, data));
+ char *ver_data = xasprintf("%s\n%s", version, data);
+ *vec = g_list_append(*vec, ver_data);
}
/*
@@ -59,7 +61,7 @@ struct line_info {
char level;
};
-static int record_oops(vector_string_t &oopses, struct line_info* lines_info, int
oopsstart, int oopsend)
+static int record_oops(GList **oopses, struct line_info* lines_info, int oopsstart, int
oopsend)
{
int q;
int len;
@@ -98,7 +100,7 @@ static int record_oops(vector_string_t &oopses, struct line_info*
lines_info, in
return rv;
}
#define REALLOC_CHUNK 1000
-int extract_oopses(vector_string_t &oopses, char *buffer, size_t buflen)
+int extract_oopses(GList **oopses, char *buffer, size_t buflen)
{
char *c;
int linecount = 0;
diff --git a/lib/plugins/KerneloopsSysLog.h b/lib/plugins/KerneloopsSysLog.h
index a67b33d..d8b4d32 100644
--- a/lib/plugins/KerneloopsSysLog.h
+++ b/lib/plugins/KerneloopsSysLog.h
@@ -28,7 +28,8 @@
#define __INCLUDE_GUARD_KERNELOOPSSYSLOG_H_
#include "abrt_types.h"
+#include <glib.h>
-int extract_oopses(vector_string_t &oopses, char *buffer, size_t buflen);
+int extract_oopses(GList **oopses, char *buffer, size_t buflen);
#endif
diff --git a/lib/plugins/Makefile.am b/lib/plugins/Makefile.am
index ffdfa33..12fe6db 100644
--- a/lib/plugins/Makefile.am
+++ b/lib/plugins/Makefile.am
@@ -87,8 +87,8 @@ libKerneloopsReporter_la_CPPFLAGS = -I$(INC_PATH) -I$(UTILS_PATH)
$(CURL_CFLAGS)
# KerneloopsScanner
libKerneloopsScanner_la_SOURCES = KerneloopsScanner.cpp KerneloopsScanner.h
KerneloopsSysLog.cpp KerneloopsSysLog.h
-libKerneloopsScanner_la_LDFLAGS = -avoid-version
-libKerneloopsScanner_la_CPPFLAGS = -I$(INC_PATH) -I$(UTILS_PATH)
-DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\"
+libKerneloopsScanner_la_LDFLAGS = -avoid-version $(GLIB_LIBS)
+libKerneloopsScanner_la_CPPFLAGS = -I$(INC_PATH) -I$(UTILS_PATH)
-DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" $(GLIB_CFLAGS)
# Mailx
libMailx_la_SOURCES = Mailx.cpp Mailx.h
diff --git a/src/hooks/Makefile.am b/src/hooks/Makefile.am
index 55ffc44..4d7c342 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 7f5b634..44df2d9 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 @@ int main(int argc, char **argv)
/* 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,23 @@ int main(int argc, char **argv)
// 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);
+ // why while and not for?
+ 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 +121,12 @@ int main(int argc, char **argv)
}
}
- /*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;
}
--
1.7.1