summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJiri Moskovcak <jmoskovc@redhat.com>2009-02-02 14:17:15 +0100
committerJiri Moskovcak <jmoskovc@redhat.com>2009-02-02 14:17:15 +0100
commit9eb8eb3c8a1b291da7359a9fc1f1c749272a1f28 (patch)
tree6ec5b46400b7bf5b69af41dd26484f51b02ef9c4 /lib
downloadabrt-9eb8eb3c8a1b291da7359a9fc1f1c749272a1f28.tar.gz
abrt-9eb8eb3c8a1b291da7359a9fc1f1c749272a1f28.tar.xz
abrt-9eb8eb3c8a1b291da7359a9fc1f1c749272a1f28.zip
Initial git commit
Diffstat (limited to 'lib')
-rw-r--r--lib/DBus/DBusManager.cpp203
-rw-r--r--lib/DBus/DBusManager.h55
-rw-r--r--lib/DBus/Makefile.am11
-rw-r--r--lib/DBus/marshal.c51
-rw-r--r--lib/DBus/marshal.h15
-rw-r--r--lib/DBus/marshal.list1
-rw-r--r--lib/DBus/test.cpp76
-rw-r--r--lib/DebugDump/DebugDump.cpp243
-rw-r--r--lib/DebugDump/DebugDump.h74
-rw-r--r--lib/DebugDump/Makefile.am6
-rw-r--r--lib/Makefile.am1
-rw-r--r--lib/MiddleWare/Application.h35
-rw-r--r--lib/MiddleWare/CrashCatcherPlugin.cpp154
-rw-r--r--lib/MiddleWare/CrashCatcherPlugin.h63
-rw-r--r--lib/MiddleWare/Database.h98
-rw-r--r--lib/MiddleWare/DynamicLibrary.cpp57
-rw-r--r--lib/MiddleWare/DynamicLibrary.h42
-rw-r--r--lib/MiddleWare/Language.h36
-rw-r--r--lib/MiddleWare/Makefile.am16
-rw-r--r--lib/MiddleWare/MiddleWare.cpp87
-rw-r--r--lib/MiddleWare/MiddleWare.h51
-rw-r--r--lib/MiddleWare/Plugin.h86
-rw-r--r--lib/MiddleWare/PluginManager.cpp254
-rw-r--r--lib/MiddleWare/PluginManager.h78
-rw-r--r--lib/MiddleWare/Reporter.h35
-rw-r--r--lib/MiddleWare/test.cpp58
-rw-r--r--lib/Plugins/CCpp.conf3
-rw-r--r--lib/Plugins/CCpp.cpp80
-rw-r--r--lib/Plugins/CCpp.h54
-rw-r--r--lib/Plugins/Mailx.conf12
-rw-r--r--lib/Plugins/Mailx.cpp74
-rw-r--r--lib/Plugins/Mailx.h58
-rw-r--r--lib/Plugins/Makefile.am22
-rw-r--r--lib/Plugins/SQLite3.conf5
-rw-r--r--lib/Plugins/SQLite3.cpp255
-rw-r--r--lib/Plugins/SQLite3.h80
36 files changed, 2529 insertions, 0 deletions
diff --git a/lib/DBus/DBusManager.cpp b/lib/DBus/DBusManager.cpp
new file mode 100644
index 00000000..0b2cb97f
--- /dev/null
+++ b/lib/DBus/DBusManager.cpp
@@ -0,0 +1,203 @@
+/*
+ Copyright (C) 2009 Jiri Moskovcak (jmoskovc@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "DBusManager.h"
+#include <iostream>
+#include <marshal.h>
+
+// only for testing - used by LoopSend()
+static gboolean send_message(DBusGConnection *con)
+{
+ DBusMessage *message;
+ /* Create a new signal "Crash" on the "com.redhat.CrashCatcher" interface,
+ * from the object "/com/redhat/CrashCatcher". */
+ message = dbus_message_new_signal("/com/redhat/CrashCatcher/Crash",
+ "com.redhat.CrashCatcher", "Crash");
+ if(!message){
+ fprintf(stderr,"Message creating error");
+ }
+ char *progname = "Foo";
+ /* Append some info to the signal */
+ dbus_message_append_args(message,DBUS_TYPE_STRING, &progname, DBUS_TYPE_INVALID);
+ /* get the DBusConnection */
+ DBusConnection *dbus_con = dbus_g_connection_get_connection(con);
+ /* Send the signal via low level dbus function coz glib doesn't seem to work */
+ if(!dbus_connection_send(dbus_con, message, NULL)){
+ printf("Error while sending message\n");
+ }
+ printf("flushing bus %p\n", dbus_con);
+ dbus_connection_flush(dbus_con);
+ /* Free the signal */
+ dbus_message_unref(message);
+ /* Tell the user we send a signal */
+ g_print("Message sent!\n");
+ /* Return TRUE to tell the event loop we want to be called again */
+ return TRUE;
+}
+
+
+CDBusManager::CDBusManager()
+{
+ GError *error = NULL;
+ g_type_init();
+ /* first we need to connect to dbus */
+ m_nBus = dbus_g_bus_get(DBUS_BUS, &error);
+ if(!m_nBus)
+ throw std::string("Couldn't connect to dbus") + error->message;
+}
+
+CDBusManager::~CDBusManager()
+{
+}
+
+/* register name com.redhat.CrashCatcher on dbus */
+void CDBusManager::RegisterService()
+{
+ GError *error = NULL;
+ guint request_name_result;
+ g_type_init();
+ // then we need a proxy to talk to dbus
+ m_nBus_proxy = dbus_g_proxy_new_for_name(m_nBus, DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+ if(!m_nBus_proxy){
+ std::cerr << "Error while creating dbus proxy!" << error->message << std::endl;
+ }
+ /* and register our name */
+ if (!dbus_g_proxy_call(m_nBus_proxy, "RequestName", &error,
+ G_TYPE_STRING, CC_DBUS_NAME,
+ G_TYPE_UINT, 0,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, &request_name_result,
+ G_TYPE_INVALID))
+ {
+ throw std::string("Failed to acquire com.redhat.CrashCatcher:") + error->message ;
+ }
+#ifdef DEBUG
+ std::cout << "Service running" << std::endl;
+#endif
+}
+
+void CDBusManager::ConnectToDaemon()
+{
+ GError *error = NULL;
+ guint request_name_result;
+ g_type_init();
+ /* create a proxy object to talk and listen to CC daemon */
+ m_nCCBus_proxy = dbus_g_proxy_new_for_name_owner(m_nBus, CC_DBUS_NAME,
+ CC_DBUS_PATH_NOTIFIER,
+ CC_DBUS_IFACE, &error);
+ if(!m_nCCBus_proxy){
+#ifdef DEBUG
+ std::cerr << "Couldn't connect to daemon via dbus: " << error->message << std::endl;
+#endif
+ throw std::string(error->message);
+ }
+#ifdef DEBUG
+ std::cout << "Connected! Waiting for signals\n" << std::endl;
+#endif
+}
+
+void CDBusManager::RegisterToMessage(const std::string& pMessage, GCallback handler, void * data, GClosureNotify free_data_func)
+{
+#ifdef DEBUG
+ std::cout << "Trying to register" << std::endl;
+#endif /*DEBUG*/
+ /* Register dbus signal marshaller */
+ dbus_g_object_register_marshaller(marshal_VOID__STRING,
+ G_TYPE_NONE, G_TYPE_STRING,
+ G_TYPE_INVALID);
+ dbus_g_proxy_add_signal(m_nCCBus_proxy,"Crash",G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal(m_nCCBus_proxy,"Crash",handler,NULL, NULL);
+#ifdef DEBUG
+ std::cout << "Register done" << std::endl;
+#endif /*DEBUG*/
+}
+
+bool CDBusManager::GSendMessage(const std::string& pMessage, const std::string& pMessParam)
+{
+ DBusMessage *message;
+ /* Create a new signal "Crash" on the "com.redhat.CrashCatcher" interface,
+ * from the object "/com/redhat/CrashCatcher/Crash". */
+ message = dbus_message_new_signal ("/com/redhat/CrashCatcher/Crash",
+ "com.redhat.CrashCatcher", pMessage.c_str());
+ if(!message){
+ std::cerr << "Message creating error" << std::endl;
+ }
+#ifdef DEBUG
+ std::cerr << message << std::endl;
+#endif
+ const char *progname = pMessParam.c_str();
+ /* Append some info to the signal */
+ dbus_message_append_args(message,DBUS_TYPE_STRING, &progname, DBUS_TYPE_INVALID);
+ /* Send the signal */
+ dbus_g_proxy_send(m_nCCBus_proxy, message, NULL);
+ /* Free the signal */
+ dbus_message_unref(message);
+#ifdef DEBUG
+ g_print("Message sent!\n");
+#endif
+ /* Return TRUE to tell the event loop we want to be called again */
+ return TRUE;
+}
+
+bool CDBusManager::SendMessage(const std::string& pMessage, const std::string& pMessParam)
+{
+ DBusMessage *message;
+ const char *progname = pMessParam.c_str();
+ /* Create a new signal "Crash" on the "com.redhat.CrashCatcher" interface,
+ * from the object "/com/redhat/CrashCatcher/Crash". */
+ message = dbus_message_new_signal ("/com/redhat/CrashCatcher/Crash",
+ "com.redhat.CrashCatcher", pMessage.c_str());
+ if(!message){
+ std::cerr << "Message creating error" << std::endl;
+ }
+#ifdef DEBUG
+ std::cerr << message << std::endl;
+#endif
+ /* Add program name as the message argument */
+ dbus_message_append_args(message,DBUS_TYPE_STRING, &progname, DBUS_TYPE_INVALID);
+ /* Send the signal */
+ DBusConnection *dbus_con = dbus_g_connection_get_connection(m_nBus);
+ /* Send the signal via low level dbus functio coz glib sucks */
+ if(!dbus_connection_send(dbus_con, message, NULL)){
+ throw "Error while sending message";
+ }
+ /* flush the connection, otherwise, it won't show on dbus? */
+ dbus_connection_flush(dbus_con);
+ /* Free the signal */
+ dbus_message_unref(message);
+#ifdef DEBUG
+ g_print("Message sent!\n");
+#endif
+ /* Return TRUE to tell the event loop we want to be called again */
+ return TRUE;
+}
+
+
+// just for testing purposes
+void CDBusManager::LoopSend()
+{
+ g_timeout_add(1000, (GSourceFunc)send_message, m_nBus);
+}
+
+void CDBusManager::Unregister()
+{
+ std::cerr << "Unregister" << std::endl;
+}
diff --git a/lib/DBus/DBusManager.h b/lib/DBus/DBusManager.h
new file mode 100644
index 00000000..e3537f89
--- /dev/null
+++ b/lib/DBus/DBusManager.h
@@ -0,0 +1,55 @@
+/*
+ Copyright (C) 2009 Jiri Moskovcak (jmoskovc@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef DBUS_H_
+#define DBUS_H_
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <dbus/dbus.h>
+#include <glib.h>
+#include <string>
+
+#define CC_DBUS_NAME "com.redhat.CrashCatcher"
+#define CC_DBUS_PATH "/com/redhat/CrashCatcher"
+#define CC_DBUS_IFACE "com.redhat.CrashCatcher"
+#define DBUS_BUS DBUS_BUS_SYSTEM
+#define CC_DBUS_PATH_NOTIFIER "/com/redhat/CrashCatcher/Crash"
+
+class CDBusManager
+{
+ private:
+ DBusGConnection *m_nBus;
+ DBusGProxy *m_nBus_proxy;
+ DBusGProxy *m_nCCBus_proxy;
+
+ public:
+ CDBusManager();
+ ~CDBusManager();
+ bool SendMessage(const std::string& pMessage, const std::string& pMessParam);
+ bool GSendMessage(const std::string& pMessage, const std::string& pMessParam);
+ void RegisterService();
+ void ConnectToService();
+ void ConnectToDaemon();
+ void LoopSend();
+ void Unregister();
+ void RegisterToMessage(const std::string& pMessage, GCallback handler, void * data, GClosureNotify free_data_func);
+};
+
+#endif /*DBUS_H_*/
diff --git a/lib/DBus/Makefile.am b/lib/DBus/Makefile.am
new file mode 100644
index 00000000..0d4d9f6e
--- /dev/null
+++ b/lib/DBus/Makefile.am
@@ -0,0 +1,11 @@
+lib_LTLIBRARIES = libDBus.la
+libDBus_la_SOURCES = DBusManager.cpp DBusManager.h marshal.c marshal.h
+libDBus_la_LDFLAGS = -version-info 0:1:0
+libDBus_la_LIBADD = $(DBUS_GLIB_LIBS)
+libDBus_la_CPPFLAGS = $(DBUS_GLIB_CFLAGS)
+
+
+check_PROGRAMS = test
+test_SOURCES = test.cpp
+test_LDADD = libDBus.la $(DL_LIBS)
+test_CPPFLAGS = $(DBUS_GLIB_CFLAGS)
diff --git a/lib/DBus/marshal.c b/lib/DBus/marshal.c
new file mode 100644
index 00000000..247bf1bb
--- /dev/null
+++ b/lib/DBus/marshal.c
@@ -0,0 +1,51 @@
+
+#include <glib-object.h>
+
+
+#ifdef G_ENABLE_DEBUG
+#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
+#define g_marshal_value_peek_char(v) g_value_get_char (v)
+#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v)
+#define g_marshal_value_peek_int(v) g_value_get_int (v)
+#define g_marshal_value_peek_uint(v) g_value_get_uint (v)
+#define g_marshal_value_peek_long(v) g_value_get_long (v)
+#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v)
+#define g_marshal_value_peek_int64(v) g_value_get_int64 (v)
+#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v)
+#define g_marshal_value_peek_enum(v) g_value_get_enum (v)
+#define g_marshal_value_peek_flags(v) g_value_get_flags (v)
+#define g_marshal_value_peek_float(v) g_value_get_float (v)
+#define g_marshal_value_peek_double(v) g_value_get_double (v)
+#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v)
+#define g_marshal_value_peek_param(v) g_value_get_param (v)
+#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v)
+#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v)
+#define g_marshal_value_peek_object(v) g_value_get_object (v)
+#else /* !G_ENABLE_DEBUG */
+/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API.
+ * Do not access GValues directly in your code. Instead, use the
+ * g_value_get_*() functions
+ */
+#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int
+#define g_marshal_value_peek_char(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_int(v) (v)->data[0].v_int
+#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint
+#define g_marshal_value_peek_long(v) (v)->data[0].v_long
+#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64
+#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64
+#define g_marshal_value_peek_enum(v) (v)->data[0].v_long
+#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong
+#define g_marshal_value_peek_float(v) (v)->data[0].v_float
+#define g_marshal_value_peek_double(v) (v)->data[0].v_double
+#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer
+#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer
+#endif /* !G_ENABLE_DEBUG */
+
+
+/* VOID:STRING (marshal.list:1) */
+
diff --git a/lib/DBus/marshal.h b/lib/DBus/marshal.h
new file mode 100644
index 00000000..60608245
--- /dev/null
+++ b/lib/DBus/marshal.h
@@ -0,0 +1,15 @@
+
+#ifndef __marshal_MARSHAL_H__
+#define __marshal_MARSHAL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/* VOID:STRING (marshal.list:1) */
+#define marshal_VOID__STRING g_cclosure_marshal_VOID__STRING
+
+G_END_DECLS
+
+#endif /* __marshal_MARSHAL_H__ */
+
diff --git a/lib/DBus/marshal.list b/lib/DBus/marshal.list
new file mode 100644
index 00000000..30ba5d8d
--- /dev/null
+++ b/lib/DBus/marshal.list
@@ -0,0 +1 @@
+VOID:STRING
diff --git a/lib/DBus/test.cpp b/lib/DBus/test.cpp
new file mode 100644
index 00000000..8f1d66cf
--- /dev/null
+++ b/lib/DBus/test.cpp
@@ -0,0 +1,76 @@
+/*
+ Copyright (C) 2009 Jiri Moskovcak (jmoskovc@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "DBusManager.h"
+#include <cstring>
+#include <iostream>
+#include <climits>
+#include <stdlib.h>
+
+static void
+print_cb(DBusGProxy *proxy, char* progname, gpointer user_data)
+{
+ DBusError error;
+ dbus_error_init (&error);
+ std::cerr << "Application " << progname << " has crashed!" << std::endl;
+}
+
+int main(int argc, char** argv){
+ GMainLoop *mainloop;
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ //no sanity check, it's just a testing program!
+ if (argc < 2){
+ std::cout << "Usage: " << argv[0] << " {s|c}" << std::endl;
+ return 0;
+ }
+ //service
+ if (strcmp(argv[1], "s") == 0){
+ std::cout << "Service: " << std::endl;
+ CDBusManager dm;
+ try
+ {
+ dm.RegisterService();
+ }
+ catch(std::string err)
+ {
+ std::cerr << err << std::endl;
+ return -1;
+ }
+ dm.LoopSend();
+
+ g_main_loop_run(mainloop);
+ }
+ //client
+ else if (strcmp(argv[1], "c") == 0){
+ CDBusManager dm;
+ try
+ {
+ dm.ConnectToService();
+ }
+ catch(std::string error)
+ {
+ std::cerr << error << std::endl;
+ return -1;
+ }
+ dm.RegisterToMessage("Crash",G_CALLBACK(print_cb),NULL,NULL);
+ g_main_loop_run(mainloop);
+ }
+ return 0;
+}
diff --git a/lib/DebugDump/DebugDump.cpp b/lib/DebugDump/DebugDump.cpp
new file mode 100644
index 00000000..7dcfcc10
--- /dev/null
+++ b/lib/DebugDump/DebugDump.cpp
@@ -0,0 +1,243 @@
+/*
+ DebugDump.cpp
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "DebugDump.h"
+#include <fstream>
+#include <iostream>
+#include <sstream>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <sys/utsname.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <sys/procfs.h>
+#include <ctype.h>
+
+CDebugDump::CDebugDump() :
+ m_sDebugDumpDir("")
+{}
+
+void CDebugDump::Open(const std::string& pDebugDumpDir, const mode_t pMode)
+{
+ m_sDebugDumpDir = pDebugDumpDir;
+ if (pMode == CREATE)
+ {
+ Delete(pDebugDumpDir);
+ Create(pDebugDumpDir);
+ SaveEnvironment();
+ }
+ if (!Exist(pDebugDumpDir))
+ {
+ throw "CDebugDump::CDebugDump(): "+pDebugDumpDir+" does not exist.";
+ }
+}
+
+bool CDebugDump::Exist(const std::string& pDir)
+{
+ struct stat buf;
+ if (stat(pDir.c_str(), &buf) == 0)
+ {
+ if (S_ISDIR(buf.st_mode))
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+void CDebugDump::Create(const std::string& pDir)
+{
+ if (mkdir(pDir.c_str(), 0755) == -1)
+ {
+ throw "CDebugDump::Create(): Cannot create dir: " + pDir;
+ }
+}
+
+void CDebugDump::Delete(const std::string& pDir)
+{
+ if (!Exist(pDir))
+ {
+ return;
+ }
+
+ DIR *dir = opendir(pDir.c_str());
+ std::string fullPath;
+ struct dirent *dent = NULL;
+ if (dir != NULL)
+ {
+ while ((dent = readdir(dir)) != NULL)
+ {
+ if (std::string(dent->d_name) != "." && std::string(dent->d_name) != "..")
+ {
+ fullPath = pDir + "/" + dent->d_name;
+ if (dent->d_type == DT_DIR)
+ {
+ Delete(fullPath);
+ }
+ if (remove(fullPath.c_str()) == -1)
+ {
+ throw "CDebugDump::DeleteDir(): Cannot remove file: " + fullPath;
+ }
+ }
+ }
+ closedir(dir);
+ if (remove(pDir.c_str()) == -1)
+ {
+ throw "CDebugDump::DeleteDir(): Cannot remove dir: " + fullPath;
+ }
+ }
+}
+
+void CDebugDump::SaveEnvironment()
+{
+ struct utsname buf;
+ if (uname(&buf) == 0)
+ {
+ SaveText(FILENAME_KERNEL, buf.release);
+ SaveText(FILENAME_ARCHITECTURE, buf.machine);
+ }
+}
+
+void CDebugDump::LoadTextFile(const std::string& pPath, std::string& pData)
+{
+ std::ifstream fIn;
+ pData = "";
+ fIn.open(pPath.c_str());
+ if (fIn.is_open())
+ {
+ std::string line;
+ while (!fIn.eof())
+ {
+ getline (fIn,line);
+ pData += line;
+ }
+ fIn.close();
+ }
+ else
+ {
+ throw "CDebugDump: LoadTextFile(): Cannot open file " + pPath;
+ }
+}
+
+void CDebugDump::LoadBinaryFile(const std::string& pPath, char** pData, unsigned int* pSize)
+{
+ std::ifstream fIn;
+ fIn.open(pPath.c_str(), std::ios::binary | std::ios::ate);
+ unsigned int size;
+ if (fIn.is_open())
+ {
+ size = fIn.tellg();
+ char *data = new char [size];
+ fIn.read(data, size);
+
+ *pData = data;
+ *pSize = size;
+
+ fIn.close();
+ }
+ else
+ {
+ throw "CDebugDump: LoadBinaryFile(): Cannot open file " + pPath;
+ }
+}
+
+
+void CDebugDump::SaveTextFile(const std::string& pPath, const std::string& pData)
+{
+ std::ofstream fOut;
+ fOut.open(pPath.c_str());
+ if (fOut.is_open())
+ {
+ fOut << pData;
+ fOut.close();
+ }
+ else
+ {
+ throw "CDebugDump: SaveTextFile(): Cannot open file " + pPath;
+ }
+}
+
+void CDebugDump::SaveBinaryFile(const std::string& pPath, const char* pData, const unsigned pSize)
+{
+ std::ofstream fOut;
+ fOut.open(pPath.c_str(), std::ios::binary);
+ if (fOut.is_open())
+ {
+ fOut.write(pData, pSize);
+ fOut.close();
+ }
+ else
+ {
+ throw "CDebugDump: SaveBinaryFile(): Cannot open file " + pPath;
+ }
+}
+
+void CDebugDump::LoadText(const std::string& pName, std::string& pData)
+{
+ std::string fullPath = m_sDebugDumpDir + "/" + pName;
+ LoadTextFile(fullPath, pData);
+}
+void CDebugDump::LoadBinary(const std::string& pName, char** pData, unsigned int* pSize)
+{
+ std::string fullPath = m_sDebugDumpDir + "/" + pName;
+ LoadBinaryFile(fullPath, pData, pSize);
+}
+
+void CDebugDump::SaveText(const std::string& pName, const std::string& pData)
+{
+ std::string fullPath = m_sDebugDumpDir + "/" + pName;
+ SaveTextFile(fullPath, pData);
+}
+void CDebugDump::SaveBinary(const std::string& pName, const char* pData, const unsigned int pSize)
+{
+ std::string fullPath = m_sDebugDumpDir + "/" + pName;
+ SaveBinaryFile(fullPath, pData, pSize);
+}
+
+
+void CDebugDump::SaveProc(const std::string& pPID)
+{
+ std::string path = "/proc/"+pPID+"/exe";
+ std::string data;
+ char executable[PATH_MAX];
+
+ if (readlink(path.c_str(), executable, PATH_MAX) == 0)
+ {
+ SaveText(FILENAME_EXECUTABLE, executable);
+ }
+
+ path = "/proc/"+pPID+"/status";
+ std::string uid = "0";
+ int ii = 0;
+
+ LoadTextFile(path, data);
+ data = data.substr(data.find("Uid:")+5);
+
+ while (!isspace(data[ii]))
+ {
+ uid += data[ii];
+ ii++;
+ }
+ SaveText(FILENAME_USER, uid);
+
+ // TODO: Use packagekit
+}
diff --git a/lib/DebugDump/DebugDump.h b/lib/DebugDump/DebugDump.h
new file mode 100644
index 00000000..8b8e79f5
--- /dev/null
+++ b/lib/DebugDump/DebugDump.h
@@ -0,0 +1,74 @@
+/*
+ DebugDump.h - header file for the library caring of writing new reports
+ to the specific directory
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef DEBUGDUMP_H_
+#define DEBUGDUMP_H_
+
+#include <string>
+
+#define FILENAME_ARCHITECTURE "architecture"
+#define FILENAME_KERNEL "kernel"
+#define FILENAME_EXECUTABLE "executable"
+#define FILENAME_TIME "time"
+#define FILENAME_USER "uid"
+#define FILENAME_PACKAGE "package"
+#define FILENAME_HASH "hash"
+#define FILENAME_LANGUAGE "language"
+#define FILENAME_APPLICATION "application"
+#define FILENAME_TEXT_FILE1 "text_file1"
+#define FILENAME_BINARY_FILE1 "binary_file1"
+
+class CDebugDump
+{
+ private:
+ std::string m_sDebugDumpDir;
+
+ void SaveEnvironment();
+
+ bool Exist(const std::string& pDir);
+ void Create(const std::string& pDir);
+ void Delete(const std::string& pDir);
+
+ void LoadTextFile(const std::string& pName, std::string& pData);
+ void LoadBinaryFile(const std::string& pName, char** pData, unsigned int* pSize);
+
+ void SaveTextFile(const std::string& pName, const std::string& pData);
+ void SaveBinaryFile(const std::string& pName, const char* pData, const unsigned int pSize);
+
+
+ public:
+
+ typedef enum {CREATE, OPEN} mode_t;
+
+ CDebugDump();
+ void Open(const std::string& pDebugDumpDir, const mode_t pMode);
+
+ void LoadText(const std::string& pName, std::string& pData);
+ void LoadBinary(const std::string& pName, char** pData, unsigned int* pSize);
+
+ void SaveText(const std::string& pName, const std::string& pData);
+ void SaveBinary(const std::string& pName, const char* pData, const unsigned int pSize);
+
+ void SaveProc(const std::string& pPID);
+};
+
+#endif /*DEBUGDUMP_H_*/
diff --git a/lib/DebugDump/Makefile.am b/lib/DebugDump/Makefile.am
new file mode 100644
index 00000000..1a1ed3ee
--- /dev/null
+++ b/lib/DebugDump/Makefile.am
@@ -0,0 +1,6 @@
+lib_LTLIBRARIES = libDebugDump.la
+libDebugDump_la_SOURCES = DebugDump.cpp DebugDump.h
+libDebugDump_la_LDFLAGS = -version-info 0:1:0
+
+install-data-local:
+ $(mkdir_p) '$(DEBUG_DUMPS_DIR)' \ No newline at end of file
diff --git a/lib/Makefile.am b/lib/Makefile.am
new file mode 100644
index 00000000..c5b18c43
--- /dev/null
+++ b/lib/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = DebugDump MiddleWare Plugins DBus \ No newline at end of file
diff --git a/lib/MiddleWare/Application.h b/lib/MiddleWare/Application.h
new file mode 100644
index 00000000..b68f9d50
--- /dev/null
+++ b/lib/MiddleWare/Application.h
@@ -0,0 +1,35 @@
+/*
+ Application.h - header file for application plugin
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef APPLICATION_H_
+#define APPLICATION_H_
+
+#include <string>
+#include "Plugin.h"
+
+class CApplication : public CPlugin
+{
+ public:
+ virtual ~CApplication() {}
+ virtual std::string GetReport(void* pData) = 0;
+};
+
+#endif /*APPLICATION_H_*/
diff --git a/lib/MiddleWare/CrashCatcherPlugin.cpp b/lib/MiddleWare/CrashCatcherPlugin.cpp
new file mode 100644
index 00000000..e50ba535
--- /dev/null
+++ b/lib/MiddleWare/CrashCatcherPlugin.cpp
@@ -0,0 +1,154 @@
+/*
+ CrashCatcherPlugin.cpp
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "CrashCatcherPlugin.h"
+
+CCrashCatcherPlugin::CCrashCatcherPlugin(const std::string& pLibPath) :
+ m_pDynamicLibrary(NULL),
+ m_pPluginInfo(NULL),
+ m_pFnPluginNew(NULL),
+ m_bEnabled(false)
+{
+ try
+ {
+ m_pDynamicLibrary = new CDynamicLibrary(pLibPath);
+ if (m_pDynamicLibrary == NULL)
+ {
+ throw std::string("Not enought memory.");
+ }
+ m_pPluginInfo = (p_plugin_info_t) m_pDynamicLibrary->FindSymbol("plugin_info");
+ m_pFnPluginNew = (p_fn_plugin_new_t) m_pDynamicLibrary->FindSymbol("plugin_new");
+ }
+ catch (...)
+ {
+ throw;
+ }
+}
+
+CCrashCatcherPlugin::~CCrashCatcherPlugin()
+{
+ if (m_pDynamicLibrary != NULL)
+ {
+ delete m_pDynamicLibrary;
+ }
+}
+
+void CCrashCatcherPlugin::LoadSettings(const std::string& pPath)
+{
+ std::ifstream fIn;
+ fIn.open(pPath.c_str());
+ if (fIn.is_open())
+ {
+ std::string line;
+ while (!fIn.eof())
+ {
+ getline(fIn, line);
+
+ int ii;
+ bool is_value = false;
+ std::string key = "";
+ std::string value = "";
+ for (ii = 0; ii < line.length(); ii++)
+ {
+ if (!isspace(line[ii]))
+ {
+ if (line[ii] == '#')
+ {
+ break;
+ }
+ else if (line[ii] == '=')
+ {
+ is_value = true;
+ }
+ else if (line[ii] == '=' && is_value)
+ {
+ key = "";
+ value = "";
+ break;
+ }
+ else if (!is_value)
+ {
+ key += line[ii];
+ }
+ else
+ {
+ value += line[ii];
+ }
+ }
+ }
+ if (key != "")
+ {
+ m_mapSettings[key] = value;
+ }
+ }
+ fIn.close();
+ }
+}
+
+const bool CCrashCatcherPlugin::IsEnabled()
+{
+ return m_mapSettings["Enabled"] == "yes";
+}
+
+const std::string& CCrashCatcherPlugin::GetVersion()
+{
+ return m_pPluginInfo->m_sVersion;
+}
+
+const int CCrashCatcherPlugin::GetMagicNumber()
+{
+ return m_pPluginInfo->m_nMagicNumber;
+}
+
+const std::string& CCrashCatcherPlugin::GetName()
+{
+ return m_pPluginInfo->m_sName;
+}
+
+const std::string& CCrashCatcherPlugin::GetDescription()
+{
+ return m_pPluginInfo->m_sDescription;
+}
+
+const std::string& CCrashCatcherPlugin::GetEmail()
+{
+ return m_pPluginInfo->m_sEmail;
+}
+
+const std::string& CCrashCatcherPlugin::GetWWW()
+{
+ return m_pPluginInfo->m_sWWW;
+}
+
+const plugin_type_t CCrashCatcherPlugin::GetType()
+{
+ return m_pPluginInfo->m_Type;
+}
+
+CPlugin* CCrashCatcherPlugin::PluginNew()
+{
+ return m_pFnPluginNew();
+}
+
+const map_settings_t& CCrashCatcherPlugin::GetSettings()
+{
+ return m_mapSettings;
+}
diff --git a/lib/MiddleWare/CrashCatcherPlugin.h b/lib/MiddleWare/CrashCatcherPlugin.h
new file mode 100644
index 00000000..0dcf4af3
--- /dev/null
+++ b/lib/MiddleWare/CrashCatcherPlugin.h
@@ -0,0 +1,63 @@
+/*
+ CrashCatcherPlugin.h - header file for CrashCatcher plugin. It takes care
+ of reporting thinks which has loaded plugin.
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#ifndef CRASHCATCHERPLUGIN_H_
+#define CRASHCATCHERPLUGIN_H_
+
+#include <string>
+#include "DynamicLibrary.h"
+#include "Plugin.h"
+
+class CCrashCatcherPlugin
+{
+ private:
+
+ typedef const plugin_info_t* p_plugin_info_t;
+ typedef CPlugin* (*p_fn_plugin_new_t)();
+
+ CDynamicLibrary* m_pDynamicLibrary;
+ p_plugin_info_t m_pPluginInfo;
+ p_fn_plugin_new_t m_pFnPluginNew;
+
+ bool m_bEnabled;
+
+ map_settings_t m_mapSettings;
+ public:
+ CCrashCatcherPlugin(const std::string& pLibPath);
+ ~CCrashCatcherPlugin();
+
+ void LoadSettings(const std::string& pPath);
+ const bool IsEnabled();
+ const std::string& GetVersion();
+ const int GetMagicNumber();
+ const std::string& GetName();
+ const std::string& GetDescription();
+ const std::string& GetEmail();
+ const std::string& GetWWW();
+ const plugin_type_t GetType();
+
+ CPlugin* PluginNew();
+ const map_settings_t& GetSettings();
+};
+
+#endif /*CRASHCATCHERPLUGIN_H_*/
diff --git a/lib/MiddleWare/Database.h b/lib/MiddleWare/Database.h
new file mode 100644
index 00000000..da8567ab
--- /dev/null
+++ b/lib/MiddleWare/Database.h
@@ -0,0 +1,98 @@
+/*
+ Database.h - header file for database plugin
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#ifndef DATABASE_H_
+#define DATABASE_H_
+
+#include <string>
+#include <vector>
+#include "Plugin.h"
+
+/*
+ * Table
+ * =====
+ * UUID | DebugDumpPath | Architecture | Kernel | ProgramPath | Package |
+ * UID | Time | Count | Reported | BackTrace | TextData1
+ *
+ * in the future we can add another TextData if we need it
+ */
+
+#define DATABASE_COLUMN_UUID "UUID"
+#define DATABASE_COLUMN_DEBUG_DUMP_PATH "DebugDumpPath"
+#define DATABASE_COLUMN_ARCHITECTURE "Architecture"
+#define DATABASE_COLUMN_KERNEL "Kernel"
+#define DATABASE_COLUMN_EXECUTABLE "Executable"
+#define DATABASE_COLUMN_PACKAGE "Package"
+#define DATABASE_COLUMN_UID "UID"
+#define DATABASE_COLUMN_TIME "Time"
+#define DATABASE_COLUMN_COUNT "Count"
+#define DATABASE_COLUMN_REPORTED "Reported"
+#define DATABASE_COLUMN_BACKTRACE "BackTrace"
+#define DATABASE_COLUMN_TEXTDATA1 "TextData1"
+
+typedef struct SDatabaseRow
+{
+ std::string m_sUUID;
+ std::string m_sDebugDumpPath;
+ std::string m_sArchitecture;
+ std::string m_sKernel;
+ std::string m_sExecutable;
+ std::string m_sPackage;
+ std::string m_sUID;
+ std::string m_sTime;
+ std::string m_sCount;
+ std::string m_sReported;
+ std::string m_sBackTrace;
+ std::string m_sTextData1;
+} database_row_t;
+
+// <column_name, <array of values in all selected rows> >
+typedef std::vector<database_row_t> vector_database_rows_t;
+
+class CDatabase : public CPlugin
+{
+ public:
+ virtual ~CDatabase() {}
+
+ virtual void Connect() = 0;
+ virtual void DisConnect() = 0;
+ virtual void Insert(const std::string& pUUID,
+ const std::string& pDebugDumpPath,
+ const std::string& pArch,
+ const std::string& pKernel,
+ const std::string& pExecutable,
+ const std::string& pPackage,
+ const std::string& pUID,
+ const std::string& pTime) = 0;
+
+ virtual void InsertBackTrace(const std::string& pUUID,
+ const std::string& pBackTrace) = 0;
+
+ virtual void InsertTextData1(const std::string& pUUID,
+ const std::string& pData) = 0;
+
+ virtual void Delete(const std::string& pUUID) = 0;
+
+ const vector_database_rows_t GetUIDData(const std::string& pUID);
+};
+
+#endif /* DATABASE_H_ */
diff --git a/lib/MiddleWare/DynamicLibrary.cpp b/lib/MiddleWare/DynamicLibrary.cpp
new file mode 100644
index 00000000..1c7c1cbd
--- /dev/null
+++ b/lib/MiddleWare/DynamicLibrary.cpp
@@ -0,0 +1,57 @@
+/*
+ DynamicLybrary.cpp
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "DynamicLibrary.h"
+#include <iostream>
+
+CDynamicLibrary::CDynamicLibrary(const std::string& pPath) :
+ m_pHandle(NULL)
+{
+ Load(pPath);
+}
+
+CDynamicLibrary::~CDynamicLibrary()
+{
+ if (m_pHandle != NULL)
+ {
+ dlclose(m_pHandle);
+ m_pHandle = NULL;
+ }
+}
+
+void CDynamicLibrary::Load(const std::string& pPath)
+{
+ m_pHandle = dlopen(pPath.c_str(), RTLD_NOW);
+ if (m_pHandle == NULL)
+ {
+ throw "CDynamicLibrary::Load(): Cannot load " + pPath + " : " + std::string(dlerror());
+ }
+}
+
+void* CDynamicLibrary::FindSymbol(const std::string& pName)
+{
+ void* sym = dlsym(m_pHandle, pName.c_str());
+ if (sym == NULL)
+ {
+ throw "CDynamicLibrary::Load(): Cannot find symbol '" + pName + "'";
+ }
+ return sym;
+}
diff --git a/lib/MiddleWare/DynamicLibrary.h b/lib/MiddleWare/DynamicLibrary.h
new file mode 100644
index 00000000..4962068c
--- /dev/null
+++ b/lib/MiddleWare/DynamicLibrary.h
@@ -0,0 +1,42 @@
+/*
+ DynamicLybrary.h - header file for dynamic lybrarby wraper. It uses libdl.
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#ifndef DYNAMICLIBRARYH_
+#define DYNAMICLIBRARYH_
+
+#include <string>
+#include <dlfcn.h>
+
+class CDynamicLibrary
+{
+ private:
+ void* m_pHandle;
+
+ void Load(const std::string& pPath);
+ public:
+ CDynamicLibrary(const std::string& pPath);
+ ~CDynamicLibrary();
+
+ void* FindSymbol(const std::string& pName);
+};
+
+#endif /*DYNAMICLIBRARYH_*/
diff --git a/lib/MiddleWare/Language.h b/lib/MiddleWare/Language.h
new file mode 100644
index 00000000..81024a53
--- /dev/null
+++ b/lib/MiddleWare/Language.h
@@ -0,0 +1,36 @@
+/*
+ Language.h - header file for language plugin
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef LANGUAGE_H_
+#define LANGUAGE_H_
+
+#include <string>
+#include "Plugin.h"
+
+class CLanguage : public CPlugin
+{
+ public:
+ virtual ~CLanguage() {}
+ virtual std::string GetUUID(void* pData) = 0;
+ virtual std::string GetReport(void* pData) = 0;
+};
+
+#endif /*LANGUAGE_H_*/
diff --git a/lib/MiddleWare/Makefile.am b/lib/MiddleWare/Makefile.am
new file mode 100644
index 00000000..a6aa22e2
--- /dev/null
+++ b/lib/MiddleWare/Makefile.am
@@ -0,0 +1,16 @@
+lib_LTLIBRARIES = libMiddleWare.la
+libMiddleWare_la_SOURCES = MiddleWare.cpp MiddleWare.h PluginManager.cpp \
+ PluginManager.h CrashCatcherPlugin.cpp \
+ CrashCatcherPlugin.h DynamicLibrary.cpp \
+ DynamicLibrary.h
+libMiddleWare_la_LIBADD = $(DL_LIBS)
+libMiddleWare_la_LDFLAGS = -version-info 0:1:0
+
+
+check_PROGRAMS = test
+test_SOURCES = test.cpp
+test_LDADD = ../DebugDump/libDebugDump.la libMiddleWare.la $(DL_LIBS)
+test_CPPFLAGS = -I$(srcdir)/../DebugDump \
+ -DPLUGINS_LIB_DIR=\"$(PLUGINS_LIB_DIR)\" \
+ -DPLUGINS_CONF_DIR=\"$(PLUGINS_CONF_DIR)\" \
+ -DDEBUG_DUMPS_DIR=\"$(DEBUG_DUMPS_DIR)\" \ No newline at end of file
diff --git a/lib/MiddleWare/MiddleWare.cpp b/lib/MiddleWare/MiddleWare.cpp
new file mode 100644
index 00000000..85b88c9c
--- /dev/null
+++ b/lib/MiddleWare/MiddleWare.cpp
@@ -0,0 +1,87 @@
+/*
+ MiddleWare.cpp
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "MiddleWare.h"
+
+CMiddleWare::CMiddleWare(const std::string& pPlugisConfDir,
+ const std::string& pPlugisLibDir) :
+ m_PluginManager(NULL)
+{
+ m_PluginManager = new CPluginManager(pPlugisConfDir, pPlugisLibDir);
+ if (m_PluginManager == NULL)
+ {
+ throw std::string("Not enought memory.");
+ }
+}
+
+CMiddleWare::~CMiddleWare()
+{
+ if (m_PluginManager != NULL)
+ {
+ delete m_PluginManager;
+ }
+}
+
+void CMiddleWare::LoadPlugins()
+{
+ m_PluginManager->LoadPlugins();
+}
+
+void CMiddleWare::LoadPlugin(const std::string& pName)
+{
+ m_PluginManager->LoadPlugin(pName);
+}
+
+void CMiddleWare::UnLoadPlugin(const std::string& pName)
+{
+ m_PluginManager->UnLoadPlugin(pName);
+}
+
+std::string CMiddleWare::GetUUID(const std::string& pLanguage, void* pData)
+{
+ CLanguage* language = m_PluginManager->GetLanguage(pLanguage);
+ if (language == NULL)
+ {
+ return "";
+ }
+ return language->GetUUID(pData);
+}
+
+std::string CMiddleWare::GetReport(const std::string& pLanguage, void* pData)
+{
+ CLanguage* language = m_PluginManager->GetLanguage(pLanguage);
+ if (language == NULL)
+ {
+ return "";
+ }
+ return language->GetReport(pData);
+}
+
+int CMiddleWare::Report(const std::string& pReporter, const std::string& pDebugDumpPath)
+{
+ CReporter* reporter = m_PluginManager->GetReporter(pReporter);
+ if (reporter == NULL)
+ {
+ return -1;
+ }
+ reporter->Report(pDebugDumpPath);
+}
+
diff --git a/lib/MiddleWare/MiddleWare.h b/lib/MiddleWare/MiddleWare.h
new file mode 100644
index 00000000..105266e2
--- /dev/null
+++ b/lib/MiddleWare/MiddleWare.h
@@ -0,0 +1,51 @@
+/*
+ MiddleWare.h - header file for MiddleWare library. It wraps plugins and
+ take case of them.
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#ifndef MIDDLEWARE_H_
+#define MIDDLEWARE_H_
+
+#include "PluginManager.h"
+
+class CMiddleWare
+{
+ private:
+
+ CPluginManager* m_PluginManager;
+
+ public:
+ CMiddleWare(const std::string& pPlugisConfDir,
+ const std::string& pPlugisLibDir);
+
+ ~CMiddleWare();
+
+ void LoadPlugins();
+ void LoadPlugin(const std::string& pName);
+ void UnLoadPlugin(const std::string& pName);
+
+ std::string GetUUID(const std::string& pLanguage, void* pData);
+ std::string GetReport(const std::string& pLanguage, void* pData);
+ int Report(const std::string& pReporter, const std::string& pDebugDumpPath);
+ //void SaveDebugDumpToDataBase(const std::string& pPath);
+};
+
+#endif /*MIDDLEWARE_H_*/
diff --git a/lib/MiddleWare/Plugin.h b/lib/MiddleWare/Plugin.h
new file mode 100644
index 00000000..7b4168c4
--- /dev/null
+++ b/lib/MiddleWare/Plugin.h
@@ -0,0 +1,86 @@
+/*
+ Plugin.h - header file for plugin. It contains mandatory macros
+ and common function for plugins
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef PLUGIN_H_
+#define PLUGIN_H_
+
+#include <string>
+#include <map>
+#include <fstream>
+
+#define PLUGINS_MAGIC_NUMBER 1
+
+#define PLUGINS_CONF_EXTENSION "conf"
+#define PLUGINS_LIB_EXTENSIONS "so"
+
+typedef std::map<std::string, std::string> map_settings_t;
+
+class CPlugin
+{
+ public:
+ virtual ~CPlugin() {}
+
+ virtual void Init(const map_settings_t& pSettings) = 0;
+ virtual void DeInit() = 0;
+};
+
+typedef enum { LANGUAGE, REPORTER, APPLICATION, DATABASE } plugin_type_t;
+
+typedef struct SPluginInfo
+{
+ const plugin_type_t m_Type;
+ const std::string m_sName;
+ const std::string m_sVersion;
+ const std::string m_sDescription;
+ const std::string m_sEmail;
+ const std::string m_sWWW;
+ const int m_nMagicNumber;
+} plugin_info_t;
+
+#define PLUGIN_IFACE extern "C"
+
+#define PLUGIN_INIT(plugin_class)\
+ PLUGIN_IFACE CPlugin* plugin_new()\
+ {\
+ plugin_class* plugin = new plugin_class();\
+ if (plugin == NULL)\
+ {\
+ throw std::string("Not enought memory");\
+ }\
+ return plugin;\
+ }\
+
+
+#define PLUGIN_INFO(type, name, version,\
+ description, email, www)\
+ PLUGIN_IFACE const plugin_info_t plugin_info =\
+ {\
+ type,\
+ name,\
+ version,\
+ description,\
+ email,\
+ www,\
+ PLUGINS_MAGIC_NUMBER,\
+ };
+
+#endif /* PLUGIN_H_ */
diff --git a/lib/MiddleWare/PluginManager.cpp b/lib/MiddleWare/PluginManager.cpp
new file mode 100644
index 00000000..4e4c56da
--- /dev/null
+++ b/lib/MiddleWare/PluginManager.cpp
@@ -0,0 +1,254 @@
+/*
+ PluginManager.cpp
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <iostream>
+#include "PluginManager.h"
+#include <dirent.h>
+#include <stdio.h>
+#include <sys/types.h>
+
+CPluginManager::CPluginManager(const std::string& pPlugisConfDir,
+ const std::string& pPlugisLibDir) :
+ m_sPlugisConfDir(pPlugisConfDir),
+ m_sPlugisLibDir(pPlugisLibDir)
+{}
+
+CPluginManager::~CPluginManager()
+{
+ map_crash_catcher_plugins_t::iterator it_p;
+ while ((it_p = m_mapCrashCatcherPlugins.begin()) != m_mapCrashCatcherPlugins.end())
+ {
+ std::string pluginName = it_p->first;
+ UnLoadPlugin(pluginName);
+ }
+}
+
+void CPluginManager::LoadPlugins()
+{
+ DIR *dir = opendir(m_sPlugisConfDir.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_CONF_EXTENSION)+1);
+ if (extension == PLUGINS_CONF_EXTENSION)
+ {
+ name.erase(name.length()-sizeof(PLUGINS_CONF_EXTENSION));
+ LoadPlugin(name);
+ }
+ }
+ }
+ closedir(dir);
+ }
+}
+
+void CPluginManager::LoadPlugin(const std::string& pName)
+{
+ if (m_mapCrashCatcherPlugins.find(pName) == m_mapCrashCatcherPlugins.end())
+ {
+ CCrashCatcherPlugin* crashCatcherPlugin = NULL;
+ CPlugin* plugin = NULL;
+ try
+ {
+ std::string libPath = m_sPlugisLibDir + "/lib" + pName + "." + PLUGINS_LIB_EXTENSIONS;
+ crashCatcherPlugin = new CCrashCatcherPlugin(libPath);
+ if (crashCatcherPlugin->GetMagicNumber() != PLUGINS_MAGIC_NUMBER)
+ {
+ throw std::string("non-compatible plugin");
+ }
+ crashCatcherPlugin->LoadSettings(m_sPlugisConfDir + "/" + pName + "." + PLUGINS_CONF_EXTENSION);
+ std::cerr << "Loaded Plugin " << pName << " (" << crashCatcherPlugin->GetVersion() << ") " << "succesfully loaded." << std::endl;
+ std::cerr << " Description: " << crashCatcherPlugin->GetDescription() << std::endl;
+ std::cerr << " Email: " << crashCatcherPlugin->GetEmail() << std::endl;
+ std::cerr << " WWW: " << crashCatcherPlugin->GetWWW() << std::endl;
+ m_mapCrashCatcherPlugins[pName] = crashCatcherPlugin;
+
+ if (crashCatcherPlugin->IsEnabled())
+ {
+ plugin = crashCatcherPlugin->PluginNew();
+ plugin->Init(crashCatcherPlugin->GetSettings());
+ RegisterPlugin(plugin, pName, crashCatcherPlugin->GetType());
+ }
+
+ }
+ catch (std::string sError)
+ {
+ if (plugin != NULL)
+ {
+ delete plugin;
+ }
+ if (crashCatcherPlugin != NULL)
+ {
+ delete plugin;
+ }
+ std::cerr << "Failed to load plugin " << pName << " (" << sError << ")." << std::endl;
+ }
+ }
+}
+
+void CPluginManager::UnLoadPlugin(const std::string& pName)
+{
+ if (m_mapCrashCatcherPlugins.find(pName) != m_mapCrashCatcherPlugins.end())
+ {
+ UnRegisterPlugin(pName, m_mapCrashCatcherPlugins[pName]->GetType());
+ delete m_mapCrashCatcherPlugins[pName];
+ m_mapCrashCatcherPlugins.erase(pName);
+ std::cerr << "Plugin " << pName << " sucessfully unloaded." << std::endl;
+ }
+}
+
+
+void CPluginManager::RegisterPlugin(CPlugin* pPlugin,
+ const std::string pName,
+ const plugin_type_t& pPluginType)
+{
+ switch (pPluginType)
+ {
+ case LANGUAGE:
+ {
+ m_mapLanguages[pName] = (CLanguage*)pPlugin;
+ std::cerr << "Registred Language plugin " << pName << std::endl;
+ }
+ break;
+ case REPORTER:
+ {
+ m_mapReporters[pName] = (CReporter*)pPlugin;
+ std::cerr << "Registred Reporter plugin " << pName << std::endl;
+ }
+ break;
+ case APPLICATION:
+ {
+ m_mapApplications[pName] = (CApplication*)pPlugin;
+ std::cerr << "Registred Application plugin " << pName << std::endl;
+ }
+ break;
+ case DATABASE:
+ {
+ m_mapDatabases[pName] = (CDatabase*)pPlugin;
+ std::cerr << "Registred Database plugin " << pName << std::endl;
+ }
+ break;
+ default:
+ {
+ std::cerr << "Trying to register unknown type of plugin." << std::endl;
+ }
+ break;
+ }
+}
+
+void CPluginManager::UnRegisterPlugin(const std::string pName, const plugin_type_t& pPluginType)
+{
+ switch (pPluginType)
+ {
+ case LANGUAGE:
+ {
+ if (m_mapLanguages.find(pName) != m_mapLanguages.end())
+ {
+ m_mapLanguages[pName]->DeInit();
+ delete m_mapLanguages[pName];
+ m_mapLanguages.erase(pName);
+ std::cerr << "UnRegistred Language plugin " << pName << std::endl;
+ }
+ }
+ break;
+ case REPORTER:
+ {
+ if (m_mapReporters.find(pName) != m_mapReporters.end())
+ {
+ m_mapReporters[pName]->DeInit();
+ delete m_mapReporters[pName];
+ m_mapReporters.erase(pName);
+ std::cerr << "UnRegistred Reporter plugin " << pName << std::endl;
+ }
+ }
+ break;
+ case APPLICATION:
+ {
+ if (m_mapApplications.find(pName) != m_mapApplications.end())
+ {
+ m_mapApplications[pName]->DeInit();
+ delete m_mapApplications[pName];
+ m_mapApplications.erase(pName);
+ std::cerr << "UnRegistred Application plugin " << pName << std::endl;
+ }
+ }
+ break;
+ case DATABASE:
+ {
+ if (m_mapDatabases.find(pName) != m_mapDatabases.end())
+ {
+ m_mapDatabases[pName]->DeInit();
+ delete m_mapDatabases[pName];
+ m_mapDatabases.erase(pName);
+ std::cerr << "UnRegistred Database plugin " << pName << std::endl;
+ }
+ }
+ break;
+ default:
+ std::cerr << "Trying to unregister unknown type of plugin." << std::endl;
+ break;
+ }
+}
+
+CLanguage* CPluginManager::GetLanguage(const std::string& pName)
+{
+ if (m_mapLanguages.find(pName) != m_mapLanguages.end())
+ {
+ return m_mapLanguages[pName];
+ }
+
+ return NULL;
+}
+
+CReporter* CPluginManager::GetReporter(const std::string& pName)
+{
+ if (m_mapReporters.find(pName) != m_mapReporters.end())
+ {
+ return m_mapReporters[pName];
+ }
+
+ return NULL;
+}
+
+CApplication* CPluginManager::GetApplication(const std::string& pName)
+{
+ if (m_mapApplications.find(pName) != m_mapApplications.end())
+ {
+ return m_mapApplications[pName];
+ }
+
+ return NULL;
+}
+
+CDatabase* CPluginManager::GetDatabase(const std::string& pName)
+{
+ if (m_mapDatabases.find(pName) != m_mapDatabases.end())
+ {
+ return m_mapDatabases[pName];
+ }
+
+ return NULL;
+}
+
diff --git a/lib/MiddleWare/PluginManager.h b/lib/MiddleWare/PluginManager.h
new file mode 100644
index 00000000..56799833
--- /dev/null
+++ b/lib/MiddleWare/PluginManager.h
@@ -0,0 +1,78 @@
+/*
+ PluginManager.h - header file for plugin manager. it takes care about
+ (un)loading plugins
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef PLUGINMANAGER_H_
+#define PLUGINMANAGER_H_
+
+#include <map>
+#include <string>
+#include "CrashCatcherPlugin.h"
+#include "Plugin.h"
+#include "Language.h"
+#include "Reporter.h"
+#include "Database.h"
+#include "Application.h"
+
+class CPluginManager
+{
+ private:
+ typedef std::map<std::string, CCrashCatcherPlugin*> map_crash_catcher_plugins_t;
+ typedef std::map<std::string, CLanguage*> map_languages_t;
+ typedef std::map<std::string, CReporter*> map_reporters_t;
+ typedef std::map<std::string, CApplication*> map_applications_t;
+ typedef std::map<std::string, CDatabase*> map_databases_t;
+
+
+ map_crash_catcher_plugins_t m_mapCrashCatcherPlugins;
+ map_languages_t m_mapLanguages;
+ map_reporters_t m_mapReporters;
+ map_applications_t m_mapApplications;
+ map_databases_t m_mapDatabases;
+
+ std::string m_sPlugisConfDir;
+ std::string m_sPlugisLibDir;
+
+ void RegisterPlugin(CPlugin* pPlugin,
+ const std::string pName,
+ const plugin_type_t& pPluginType);
+
+ void UnRegisterPlugin(const std::string pName,
+ const plugin_type_t& pPluginType);
+
+ public:
+ CPluginManager(const std::string& pPlugisConfDir,
+ const std::string& pPlugisLibDir);
+
+ ~CPluginManager();
+
+ void LoadPlugins();
+ void LoadPlugin(const std::string& pName);
+ void UnLoadPlugin(const std::string& pName);
+
+ CLanguage* GetLanguage(const std::string& pName);
+ CReporter* GetReporter(const std::string& pName);
+ CApplication* GetApplication(const std::string& pName);
+ CDatabase* GetDatabase(const std::string& pName);
+
+};
+
+#endif /*PLUGINMANAGER_H_*/
diff --git a/lib/MiddleWare/Reporter.h b/lib/MiddleWare/Reporter.h
new file mode 100644
index 00000000..cff912bc
--- /dev/null
+++ b/lib/MiddleWare/Reporter.h
@@ -0,0 +1,35 @@
+/*
+ Reporter.h - header file for reporter plugin
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef REPORTER_H_
+#define REPORTER_H_
+
+#include <string>
+#include "Plugin.h"
+
+class CReporter : public CPlugin
+{
+ public:
+ virtual ~CReporter() {}
+ virtual void Report(const std::string& pDebugDumpPath) = 0;
+};
+
+#endif /* REPORTER_H_ */
diff --git a/lib/MiddleWare/test.cpp b/lib/MiddleWare/test.cpp
new file mode 100644
index 00000000..380af469
--- /dev/null
+++ b/lib/MiddleWare/test.cpp
@@ -0,0 +1,58 @@
+/*
+ test.cpp - simple library test
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "MiddleWare.h"
+#include "DebugDump.h"
+#include <iostream>
+#include <sys/types.h>
+#include <unistd.h>
+
+
+int main(int argc, char** argv)
+{
+
+
+ try
+ {
+ CMiddleWare middleWare(PLUGINS_CONF_DIR, PLUGINS_LIB_DIR);
+ CDebugDump* dd;
+
+ middleWare.LoadPlugins();
+ middleWare.UnLoadPlugin("Mailx");
+
+ dd = new CDebugDump(DEBUG_DUMPS_DIR);
+
+ dd->Delete();
+ dd->Create();
+ dd->SaveTextFile("UUID", middleWare.GetUUID("CCpp", (void*)"data"));
+ char pid[100];
+ sprintf(pid, "%d", getpid());
+ dd->SaveProc(pid);
+
+ delete dd;
+ }
+ catch (std::string sError)
+ {
+ std::cerr << sError << std::endl;
+ }
+
+ return 0;
+}
diff --git a/lib/Plugins/CCpp.conf b/lib/Plugins/CCpp.conf
new file mode 100644
index 00000000..1d15667b
--- /dev/null
+++ b/lib/Plugins/CCpp.conf
@@ -0,0 +1,3 @@
+# Configuration file for CCpp add-on
+Enabled = yes
+MemoryMap = no \ No newline at end of file
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
new file mode 100644
index 00000000..54ec0907
--- /dev/null
+++ b/lib/Plugins/CCpp.cpp
@@ -0,0 +1,80 @@
+/*
+ DebugDump.cpp
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "CCpp.h"
+#include <fstream>
+#include <ctype.h>
+
+#define CORE_PATTERN_IFACE "/proc/sys/kernel/core_pattern"
+#define CORE_PATTERN CCPP_HOOK_PATH" %p %t %s"
+
+CLanguageCCpp::CLanguageCCpp() :
+ m_bMemoryMap(false)
+{}
+
+std::string CLanguageCCpp::GetUUID(void* pData)
+{
+ if (m_bMemoryMap)
+ return "UUID a memory map";
+ else
+ return "UUID bez memory map";
+}
+
+std::string CLanguageCCpp::GetReport(void* pData)
+{
+ return "reportuju jak blazen";
+}
+
+void CLanguageCCpp::Init(const map_settings_t& pSettings)
+{
+ std::ifstream fInCorePattern;
+ fInCorePattern.open(CORE_PATTERN_IFACE);
+ if (fInCorePattern.is_open())
+ {
+ getline(fInCorePattern, m_sOldCorePattern);
+ fInCorePattern.close();
+ }
+ std::ofstream fOutCorePattern;
+ fOutCorePattern.open(CORE_PATTERN_IFACE);
+ if (fOutCorePattern.is_open())
+ {
+ fOutCorePattern << CORE_PATTERN << std::endl;
+ fOutCorePattern.close();
+ }
+
+ if (pSettings.find("MemoryMap")!= pSettings.end())
+ {
+ m_bMemoryMap = pSettings.find("MemoryMap")->second == "yes";
+ }
+
+}
+
+
+void CLanguageCCpp::DeInit()
+{
+ std::ofstream fOutCorePattern;
+ fOutCorePattern.open(CORE_PATTERN_IFACE);
+ if (fOutCorePattern.is_open())
+ {
+ fOutCorePattern << m_sOldCorePattern << std::endl;
+ fOutCorePattern.close();
+ }
+}
diff --git a/lib/Plugins/CCpp.h b/lib/Plugins/CCpp.h
new file mode 100644
index 00000000..904ac7c5
--- /dev/null
+++ b/lib/Plugins/CCpp.h
@@ -0,0 +1,54 @@
+/*
+ CCpp.h - header file for C/C++ language plugin
+ - it can ger UUID and memory maps from core files
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef CCPP_H_
+#define CCPP_H_
+
+#include <string>
+#include "Plugin.h"
+#include "Language.h"
+
+class CLanguageCCpp : public CLanguage
+{
+ private:
+ bool m_bMemoryMap;
+ std::string m_sOldCorePattern;
+ public:
+ CLanguageCCpp();
+ virtual ~CLanguageCCpp() {}
+ std::string GetUUID(void* pData);
+ std::string GetReport(void* pData);
+ void Init(const map_settings_t& pSettings);
+ void DeInit();
+};
+
+
+PLUGIN_INFO(LANGUAGE,
+ "CCpp",
+ "0.0.1",
+ "Simple C/C++ language plugin.",
+ "zprikryl@redhat.com",
+ "https://fedorahosted.org/crash-catcher/wiki");
+
+PLUGIN_INIT(CLanguageCCpp);
+
+#endif /* CCPP */
diff --git a/lib/Plugins/Mailx.conf b/lib/Plugins/Mailx.conf
new file mode 100644
index 00000000..2b0be9c9
--- /dev/null
+++ b/lib/Plugins/Mailx.conf
@@ -0,0 +1,12 @@
+# Configuration to Email reporter plugin
+
+Enabled = no
+
+# Parameters
+Parameters =
+
+# Your Email
+Email_From = zprikryl@redhat.com
+
+# Email To
+Email_To = jmoskovc@redhat.com
diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp
new file mode 100644
index 00000000..7f4b7a76
--- /dev/null
+++ b/lib/Plugins/Mailx.cpp
@@ -0,0 +1,74 @@
+/*
+ Mailx.cpp
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "Mailx.h"
+#include <stdio.h>
+
+#define MAILX_COMMAND "mailx"
+#define MAILX_SUBJECT "CrashCatcher automated bug report"
+
+CMailx::CMailx() :
+ m_sEmailFrom(""),
+ m_sEmailTo(""),
+ m_sParameters()
+{}
+
+
+void CMailx::SendEmail(const std::string& pText)
+{
+ FILE* command;
+ std::string mailx_command = MAILX_COMMAND + m_sParameters +
+ " -s " + MAILX_SUBJECT +
+ " -r " + m_sEmailTo + " " + m_sEmailFrom;
+
+ command = popen(mailx_command.c_str(), "w");
+ if (!command)
+ {
+ throw std::string("CMailx::SendEmail: Can not execute mailx.");
+ }
+ if (fputs(pText.c_str(), command) == -1)
+ {
+ throw std::string("CMailx::SendEmail: Can not send data.");
+ }
+ pclose(command);
+}
+
+
+void CMailx::Report(const std::string& pDebugDumpPath)
+{
+ SendEmail("Nejakej zbesilej report.");
+}
+
+void CMailx::Init(const map_settings_t& pSettings)
+{
+ if (pSettings.find("Email_From")!= pSettings.end())
+ {
+ m_sEmailFrom = pSettings.find("Email_From")->second;
+ }
+ if (pSettings.find("Email_To")!= pSettings.end())
+ {
+ m_sEmailFrom = pSettings.find("Email_To")->second;
+ }
+ if (pSettings.find("Parameters")!= pSettings.end())
+ {
+ m_sParameters = pSettings.find("Parameters")->second;
+ }
+}
diff --git a/lib/Plugins/Mailx.h b/lib/Plugins/Mailx.h
new file mode 100644
index 00000000..e1463ea0
--- /dev/null
+++ b/lib/Plugins/Mailx.h
@@ -0,0 +1,58 @@
+/*
+ Mailx.h - header file for Mailx reporter plugin
+ - it simple sends an email to specific address via mailx command
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef MAILX_H_
+#define MAILX_H_
+
+#include <string>
+#include "Plugin.h"
+#include "Reporter.h"
+
+class CMailx : public CReporter
+{
+ private:
+ std::string m_sEmailFrom;
+ std::string m_sEmailTo;
+ std::string m_sParameters;
+
+ void SendEmail(const std::string& pText);
+
+ public:
+ CMailx();
+ virtual ~CMailx() {}
+ void Init(const map_settings_t& pSettings);
+ void DeInit() {}
+ void Report(const std::string& pDebugDumpPath);
+};
+
+
+PLUGIN_INFO(REPORTER,
+ "Mailx",
+ "0.0.1",
+ "Sends an email with a report via mailx command",
+ "zprikryl@redhat.com",
+ "https://fedorahosted.org/crash-catcher/wiki");
+
+PLUGIN_INIT(CMailx);
+
+
+#endif /* MAILX_H_ */
diff --git a/lib/Plugins/Makefile.am b/lib/Plugins/Makefile.am
new file mode 100644
index 00000000..02ccafbe
--- /dev/null
+++ b/lib/Plugins/Makefile.am
@@ -0,0 +1,22 @@
+AM_CPPFLAGS = -I$(srcdir)/../MiddleWare
+pluginslibdir=$(PLUGINS_LIB_DIR)
+pluginslib_LTLIBRARIES = libCCpp.la libMailx.la libSQLite3.la
+
+pluginsconfdir=$(PLUGINS_CONF_DIR)
+pluginsconf_DATA = CCpp.conf Mailx.conf SQLite3.conf
+
+# CCpp
+libCCpp_la_SOURCES = CCpp.cpp CCpp.h
+libCCpp_la_LDFLAGS = -version-info 0:1:0
+libCCpp_la_CPPFLAGS = -I$(srcdir)/../MiddleWare -DCCPP_HOOK_PATH=\"${libexecdir}/hookCCpp\"
+
+# Mailx
+libMailx_la_SOURCES = Mailx.cpp Mailx.h
+libMailx_la_LDFLAGS = -version-info 0:1:0
+
+# SQLite3
+libSQLite3_la_SOURCES = SQLite3.cpp SQLite3.h
+libSQLite3_la_LDFLAGS = -version-info 0:1:0
+libSQLite3_la_LIBADD = $(SQLITE3_LIBS)
+libSQLite3_la_CPPFLAGS = -I$(srcdir)/../MiddleWare $(SQLITE3_CFLAGS)
+
diff --git a/lib/Plugins/SQLite3.conf b/lib/Plugins/SQLite3.conf
new file mode 100644
index 00000000..663bbf81
--- /dev/null
+++ b/lib/Plugins/SQLite3.conf
@@ -0,0 +1,5 @@
+# Configuration file for database plugin SQLite3
+
+Enabled = yes
+# DB path
+DBPath = /tmp/CCDB
diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp
new file mode 100644
index 00000000..05beb1b0
--- /dev/null
+++ b/lib/Plugins/SQLite3.cpp
@@ -0,0 +1,255 @@
+/*
+ DebugDump.h - header file for the library caring of writing new reports
+ to the specific directory
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <sqlite3.h>
+#include "SQLite3.h"
+#include <string>
+
+
+#define TABLE_NAME "CrashCatcher"
+
+CSQLite3::CSQLite3() :
+ m_sDBPath(""),
+ m_pDB(NULL)
+{}
+
+bool CSQLite3::IsReported(const std::string& pUUID)
+{
+ vector_database_rows_t table;
+ GetTable("SELECT "DATABASE_COLUMN_REPORTED" FROM "TABLE_NAME" WHERE "DATABASE_COLUMN_UUID" = '"+pUUID+"';", table);
+ if(table.empty())
+ {
+ return false;
+ }
+ return true;
+}
+
+void CSQLite3::Exec(const std::string& pCommand)
+{
+ char *err;
+ int ret = sqlite3_exec(m_pDB, pCommand.c_str(), 0, 0, &err);
+ if (ret != SQLITE_OK)
+ {
+ throw std::string("SQLite3::Exec(): Error on: " + pCommand + " " + err);
+ }
+}
+
+void CSQLite3::GetTable(const std::string& pCommand, vector_database_rows_t& pTable)
+{
+
+ char **table;
+ int ncol, nrow;
+ char *err;
+ int ret = sqlite3_get_table(m_pDB, pCommand.c_str(), &table, &nrow, &ncol, &err);
+ if (ret != SQLITE_OK)
+ {
+ throw std::string("SQLite3::GetTable(): Error on: " + pCommand + " " + err);
+ }
+ pTable.clear();
+ int ii;
+ for (ii = 0; ii < nrow; ii++)
+ {
+ int jj;
+ database_row_t row;
+ for (jj = 0; jj < ncol; jj++)
+ {
+ switch(jj)
+ {
+ case 0: row.m_sUUID = table[jj + ncol];
+ break;
+ case 1: row.m_sDebugDumpPath = table[jj + ncol];
+ break;
+ case 2: row.m_sArchitecture = table[jj + ncol];
+ break;
+ case 3: row.m_sKernel = table[jj + ncol];
+ break;
+ case 4: row.m_sExecutable = table[jj + ncol];
+ break;
+ case 5: row.m_sPackage = table[jj + ncol];
+ break;
+ case 6: row.m_sUID = table[jj + ncol];
+ break;
+ case 7: row.m_sTime = table[jj + ncol];
+ break;
+ case 8: row.m_sCount = table[jj + ncol];
+ break;
+ case 9: row.m_sReported = table[jj + ncol];
+ break;
+ case 10: row.m_sBackTrace = table[jj + ncol];
+ break;
+ case 11: row.m_sTextData1 = table[jj + ncol];
+ break;
+ default:
+ break;
+ }
+ }
+ pTable.push_back(row);
+ }
+ sqlite3_free_table(table);
+}
+
+
+void CSQLite3::Connect()
+{
+ int ret = sqlite3_open_v2(m_sDBPath.c_str(),
+ &m_pDB,
+ SQLITE_OPEN_READWRITE,
+ NULL);
+
+ if(ret == SQLITE_CANTOPEN)
+ {
+ Create();
+ }
+ else if (ret != SQLITE_OK)
+ {
+ throw std::string("SQLite3::Connect(): Could not open database.") + sqlite3_errmsg(m_pDB);
+ }
+}
+
+void CSQLite3::Create()
+{
+ int ret = sqlite3_open_v2(m_sDBPath.c_str(),
+ &m_pDB,
+ SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
+ NULL);
+ if(ret != SQLITE_OK)
+ {
+ throw std::string("SQLite3::Create(): Could not create database.") + sqlite3_errmsg(m_pDB);
+ }
+
+ Exec("CREATE TABLE "TABLE_NAME"("
+ DATABASE_COLUMN_UUID" VARCHAR NOT NULL PRIMARY KEY,"
+ DATABASE_COLUMN_DEBUG_DUMP_PATH" VARCHAR NOT NULL,"
+ DATABASE_COLUMN_ARCHITECTURE" VARCHAR(16) NOT NULL,"
+ DATABASE_COLUMN_KERNEL" VARCHAR(32) NOT NULL,"
+ DATABASE_COLUMN_EXECUTABLE" VARCHAR NOT NULL,"
+ DATABASE_COLUMN_PACKAGE" VARCHAR(64) NOT NULL,"
+ DATABASE_COLUMN_UID" VARCHAR(64) NOT NULL,"
+ DATABASE_COLUMN_TIME" VARCHAR(32) NOT NULL,"
+ DATABASE_COLUMN_COUNT" INT(10) NOT NULL DEFAULT 1,"
+ DATABASE_COLUMN_REPORTED" INT(10) NOT NULL DEFAULT 0,"
+ DATABASE_COLUMN_BACKTRACE" VARCHAR DEFAULT \"\","
+ DATABASE_COLUMN_TEXTDATA1" VARCHAR DEFAULT \"\""
+ ");");
+}
+
+void CSQLite3::DisConnect()
+{
+ sqlite3_close(m_pDB);
+}
+
+void CSQLite3::Insert(const std::string& pUUID,
+ const std::string& pDebugDumpPath,
+ const std::string& pArch,
+ const std::string& pKernel,
+ const std::string& pExecutable,
+ const std::string& pPackage,
+ const std::string& pUID,
+ const std::string& pTime)
+{
+ if (!IsReported(pUUID))
+ {
+ Exec("INSERT INTO "TABLE_NAME"("
+ DATABASE_COLUMN_UUID","
+ DATABASE_COLUMN_DEBUG_DUMP_PATH","
+ DATABASE_COLUMN_ARCHITECTURE","
+ DATABASE_COLUMN_KERNEL","
+ DATABASE_COLUMN_EXECUTABLE","
+ DATABASE_COLUMN_PACKAGE","
+ DATABASE_COLUMN_UID","
+ DATABASE_COLUMN_TIME")"
+ " VALUES ('"+pUUID+"'"
+ "'"+pDebugDumpPath+"'"
+ "'"+pArch+"'"
+ "'"+pKernel+"'"
+ "'"+pExecutable+"'"
+ "'"+pPackage+"'"
+ "'"+pUID+"'"
+ "'"+pTime+"'"
+ ");");
+ }
+ else
+ {
+ Exec("UPDATE "TABLE_NAME" "
+ "SET "DATABASE_COLUMN_COUNT" = "DATABASE_COLUMN_COUNT" + 1 "
+ "WHERE "DATABASE_COLUMN_UUID" = '"+pUUID+"';");
+ }
+}
+
+void CSQLite3::Delete(const std::string& pUUID)
+{
+ if (IsReported(pUUID))
+ {
+ Exec("DELETE FROM "TABLE_NAME
+ " WHERE "DATABASE_COLUMN_UUID" = '"+pUUID+"';");
+ }
+}
+
+void CSQLite3::InsertBackTrace(const std::string& pUUID,
+ const std::string& pBackTrace)
+{
+ if (IsReported(pUUID))
+ {
+ Exec("UPDATE "TABLE_NAME
+ "SET "DATABASE_COLUMN_BACKTRACE" = "+pBackTrace+
+ "WHERE "DATABASE_COLUMN_UUID" = '"+pUUID+"';");
+ }
+}
+
+void CSQLite3::InsertTextData1(const std::string& pUUID,
+ const std::string& pData)
+{
+ if (IsReported(pUUID))
+ {
+ Exec("UPDATE "TABLE_NAME
+ "SET "DATABASE_COLUMN_TEXTDATA1" = "+pData+
+ "WHERE "DATABASE_COLUMN_UUID" = '"+pUUID+"';");
+ }
+}
+
+const vector_database_rows_t CSQLite3::GetUIDData(const std::string& pUID)
+{
+ vector_database_rows_t table;
+ if (pUID == "0")
+ {
+ GetTable("SELECT * FROM "TABLE_NAME";", table);
+ Exec("UPDATE "TABLE_NAME" SET "DATABASE_COLUMN_REPORTED" = 1;");
+ }
+ else
+ {
+ GetTable("SELECT * FROM "TABLE_NAME
+ " WHERE "DATABASE_COLUMN_UID" = '"+pUID+"';",
+ table);
+ Exec("UPDATE "TABLE_NAME
+ " SET "DATABASE_COLUMN_REPORTED" = 1 "
+ " WHERE "DATABASE_COLUMN_UID" = '"+pUID+"';");
+ }
+ return table;
+}
+
+void CSQLite3::Init(const map_settings_t& pSettings)
+{
+ if (pSettings.find("DBPath")!= pSettings.end())
+ {
+ m_sDBPath = pSettings.find("DBPath")->second;
+ }
+}
diff --git a/lib/Plugins/SQLite3.h b/lib/Plugins/SQLite3.h
new file mode 100644
index 00000000..5270988e
--- /dev/null
+++ b/lib/Plugins/SQLite3.h
@@ -0,0 +1,80 @@
+/*
+ DebugDump.h - header file for the library caring of writing new reports
+ to the specific directory
+
+ Copyright (C) 2009 Zdenek Prikryl (zprikryl@redhat.com)
+ Copyright (C) 2009 RedHat inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef SQLITE3_H_
+#define SQLITE3_H_
+
+#include "Plugin.h"
+#include "Database.h"
+
+class CSQLite3 : public CDatabase
+{
+ private:
+
+ std::string m_sDBPath;
+ sqlite3* m_pDB;
+
+ void Create();
+ void Exec(const std::string& pCommand);
+ void GetTable(const std::string& pCommand, vector_database_rows_t& pTable);
+ bool IsReported(const std::string& pUUID);
+
+ public:
+ CSQLite3();
+ virtual ~CSQLite3() {}
+
+ void Connect();
+ void DisConnect();
+
+ void Insert(const std::string& pUUID,
+ const std::string& pDebugDumpPath,
+ const std::string& pArch,
+ const std::string& pKernel,
+ const std::string& pExecutable,
+ const std::string& pPackage,
+ const std::string& pUID,
+ const std::string& pTime);
+
+ void InsertBackTrace(const std::string& pUUID,
+ const std::string& pBackTrace);
+
+ void InsertTextData1(const std::string& pUUID,
+ const std::string& pData);
+
+ void Delete(const std::string& pUUID);
+
+ const vector_database_rows_t GetUIDData(const std::string& pUID);
+
+ void Init(const map_settings_t& pSettings);
+ void DeInit() {}
+};
+
+PLUGIN_INFO(DATABASE,
+ "SQLite3",
+ "0.0.1",
+ "SQLite3 database plugin.",
+ "zprikryl@redhat.com",
+ "https://fedorahosted.org/crash-catcher/wiki");
+
+PLUGIN_INIT(CSQLite3);
+
+#endif /* SQLITE3_H_ */