summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-08-07 02:23:33 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-08-07 02:23:33 +0200
commit88093858fa6cf734bb832f7cc9ff06fe57f0ad2a (patch)
tree4a73a8ae3acddfd0e8101f28bcee72fb9e35ddba
parent83a41775849cf6904bbd7f929d0bd1516759260f (diff)
downloadabrt-88093858fa6cf734bb832f7cc9ff06fe57f0ad2a.tar.gz
abrt-88093858fa6cf734bb832f7cc9ff06fe57f0ad2a.tar.xz
abrt-88093858fa6cf734bb832f7cc9ff06fe57f0ad2a.zip
Split real code from lib/MiddleWare/Plugin.h into Plugin.cpp.
30k smaller code. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--lib/MiddleWare/Makefile.am5
-rw-r--r--lib/MiddleWare/Plugin.cpp89
-rw-r--r--lib/MiddleWare/Plugin.h82
-rw-r--r--lib/Plugins/CCpp.cpp11
-rw-r--r--lib/Plugins/KerneloopsReporter.cpp5
-rw-r--r--lib/Plugins/KerneloopsScanner.cpp3
-rw-r--r--lib/Plugins/KerneloopsSysLog.cpp3
-rw-r--r--src/Daemon/MiddleWare.h2
8 files changed, 106 insertions, 94 deletions
diff --git a/lib/MiddleWare/Makefile.am b/lib/MiddleWare/Makefile.am
index 8fbb4060..e10534ca 100644
--- a/lib/MiddleWare/Makefile.am
+++ b/lib/MiddleWare/Makefile.am
@@ -2,8 +2,9 @@ lib_LTLIBRARIES = libABRTMiddleWare.la
libABRTMiddleWare_la_SOURCES = \
RPM.cpp RPM.h \
- Plugin.h MiddleWareTypes.h Action.h Database.h \
- Reporter.h Analyzer.h
+ Plugin.cpp Plugin.h \
+ MiddleWareTypes.h \
+ Action.h Database.h Reporter.h Analyzer.h
libABRTMiddleWare_la_LIBADD = \
$(DL_LIBS) \
../Utils/libABRTUtils.la \
diff --git a/lib/MiddleWare/Plugin.cpp b/lib/MiddleWare/Plugin.cpp
new file mode 100644
index 00000000..cf2dff61
--- /dev/null
+++ b/lib/MiddleWare/Plugin.cpp
@@ -0,0 +1,89 @@
+/*
+ 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 "Plugin.h"
+#include <fstream>
+
+/* class CPlugin's virtuals */
+CPlugin::~CPlugin() {}
+void CPlugin::Init() {}
+void CPlugin::DeInit() {}
+void CPlugin::LoadSettings(const std::string& pPath) {}
+void CPlugin::SetSettings(const map_plugin_settings_t& pSettings) {}
+map_plugin_settings_t CPlugin::GetSettings() {return map_plugin_settings_t();}
+
+void plugin_load_settings(const std::string& path, map_plugin_settings_t& settings)
+{
+ std::ifstream fIn;
+ fIn.open(path.c_str());
+ if (fIn.is_open())
+ {
+ std::string line;
+ while (!fIn.eof())
+ {
+ getline(fIn, line);
+
+ int ii;
+ bool is_value = false;
+ bool valid = false;
+ bool in_quote = false;
+ std::string key = "";
+ std::string value = "";
+ for (ii = 0; ii < line.length(); ii++)
+ {
+ if (line[ii] == '\"')
+ {
+ in_quote = in_quote == true ? false : true;
+ }
+ if (isspace(line[ii]) && !in_quote)
+ {
+ continue;
+ }
+ if (line[ii] == '#' && !in_quote)
+ {
+ break;
+ }
+ else if (line[ii] == '=' && !in_quote)
+ {
+ is_value = true;
+ }
+ else if (line[ii] == '=' && is_value && !in_quote)
+ {
+ key = "";
+ value = "";
+ break;
+ }
+ else if (!is_value)
+ {
+ key += line[ii];
+ }
+ else
+ {
+ valid = true;
+ value += line[ii];
+ }
+ }
+ if (valid && !in_quote)
+ {
+ settings[key] = value;
+ }
+ }
+ fIn.close();
+ }
+}
diff --git a/lib/MiddleWare/Plugin.h b/lib/MiddleWare/Plugin.h
index 47915ce4..60ebc595 100644
--- a/lib/MiddleWare/Plugin.h
+++ b/lib/MiddleWare/Plugin.h
@@ -25,8 +25,6 @@
#include <string>
#include <map>
-#include <fstream>
-
#define PLUGINS_MAGIC_NUMBER 4
@@ -46,34 +44,34 @@ class CPlugin
/**
* A destructor.
*/
- virtual ~CPlugin() {}
+ virtual ~CPlugin();
/**
* A method, which initializes a plugin. It is not mandatory method.
*/
- virtual void Init() {}
+ virtual void Init();
/**
* A method, which deinitializes a plugin. It is not mandatory method.
*/
- virtual void DeInit() {}
+ virtual void DeInit();
/**
* A method, which loads a plugin settings from a file. It is not mandatory method.
* @param pPath A path to plugin configuration file.
*/
- virtual void LoadSettings(const std::string& pPath) {}
+ virtual void LoadSettings(const std::string& pPath);
/**
* A method, which takes a settings and apply them. It is not a mandatory method.
* @param pSettings Plugin's settings
*/
- virtual void SetSettings(const map_plugin_settings_t& pSettings) {}
+ virtual void SetSettings(const map_plugin_settings_t& pSettings);
/**
* A method, which return current settings. It is not mandatory method.
* @return Plugin's settings
*/
- virtual map_plugin_settings_t GetSettings() {return map_plugin_settings_t();}
+ virtual map_plugin_settings_t GetSettings();
};
/**
- * An emun of plugin types.
+ * An enum of plugin types.
*/
typedef enum {
ANALYZER, /**< An analyzer plugin*/
@@ -97,14 +95,12 @@ typedef struct SPluginInfo
const int m_nMagicNumber; /**< Plugin magical number.*/
} plugin_info_t;
-#define PLUGIN_IFACE extern "C"
-
#define PLUGIN_INFO(type, plugin_class, name, version, description, email, www, gtk_builder)\
- PLUGIN_IFACE CPlugin* plugin_new()\
+ extern "C" CPlugin* plugin_new()\
{\
return new plugin_class();\
}\
- PLUGIN_IFACE const plugin_info_t plugin_info =\
+ extern "C" const plugin_info_t plugin_info =\
{\
type,\
name,\
@@ -116,64 +112,6 @@ typedef struct SPluginInfo
PLUGINS_MAGIC_NUMBER,\
};
-inline void plugin_load_settings(const std::string& path, map_plugin_settings_t& settings)
-{
- std::ifstream fIn;
- fIn.open(path.c_str());
- if (fIn.is_open())
- {
- std::string line;
- while (!fIn.eof())
- {
- getline(fIn, line);
-
- int ii;
- bool is_value = false;
- bool valid = false;
- bool in_quote = false;
- std::string key = "";
- std::string value = "";
- for (ii = 0; ii < line.length(); ii++)
- {
- if (line[ii] == '\"')
- {
- in_quote = in_quote == true ? false : true;
- }
- if (isspace(line[ii]) && !in_quote)
- {
- continue;
- }
- if (line[ii] == '#' && !in_quote)
- {
- break;
- }
- else if (line[ii] == '=' && !in_quote)
- {
- is_value = true;
- }
- else if (line[ii] == '=' && is_value && !in_quote)
- {
- key = "";
- value = "";
- break;
- }
- else if (!is_value)
- {
- key += line[ii];
- }
- else
- {
- valid = true;
- value += line[ii];
- }
- }
- if (valid && !in_quote)
- {
- settings[key] = value;
- }
- }
- fIn.close();
- }
-}
+void plugin_load_settings(const std::string& path, map_plugin_settings_t& settings);
#endif /* PLUGIN_H_ */
diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp
index a47ca387..6d092bf5 100644
--- a/lib/Plugins/CCpp.cpp
+++ b/lib/Plugins/CCpp.cpp
@@ -18,8 +18,8 @@
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include "abrtlib.h"
+#include "abrtlib.h"
#include "CCpp.h"
#include "ABRTException.h"
#include "DebugDump.h"
@@ -27,16 +27,7 @@
#include <fstream>
#include <sstream>
#include <set>
-//#include <ctype.h>
-//#include <unistd.h>
-//#include <sys/types.h>
-//#include <sys/wait.h>
-//#include <fcntl.h>
-//#include <stdlib.h>
-//#include <string.h>
#include <iomanip>
-//#include <grp.h>
-//#include <pwd.h>
#include <nss.h>
#include <sechash.h>
diff --git a/lib/Plugins/KerneloopsReporter.cpp b/lib/Plugins/KerneloopsReporter.cpp
index 139ecf54..64037aa0 100644
--- a/lib/Plugins/KerneloopsReporter.cpp
+++ b/lib/Plugins/KerneloopsReporter.cpp
@@ -23,13 +23,10 @@
* Anton Arapov <anton@redhat.com>
* Arjan van de Ven <arjan@linux.intel.com>
*/
-#include "abrtlib.h"
+#include "abrtlib.h"
#include "KerneloopsReporter.h"
#include "CommLayerInner.h"
-
-//#include <stdlib.h>
-//#include <string.h>
#include <curl/curl.h>
#define FILENAME_KERNELOOPS "kerneloops"
diff --git a/lib/Plugins/KerneloopsScanner.cpp b/lib/Plugins/KerneloopsScanner.cpp
index f696a994..12c06667 100644
--- a/lib/Plugins/KerneloopsScanner.cpp
+++ b/lib/Plugins/KerneloopsScanner.cpp
@@ -6,10 +6,7 @@
#include "CommLayerInner.h"
#include <assert.h>
-//#include <stdlib.h>
-//#include <string.h>
#include <syslog.h>
-//#include <sys/stat.h>
#include <asm/unistd.h>
diff --git a/lib/Plugins/KerneloopsSysLog.cpp b/lib/Plugins/KerneloopsSysLog.cpp
index 47ade77d..60c08d71 100644
--- a/lib/Plugins/KerneloopsSysLog.cpp
+++ b/lib/Plugins/KerneloopsSysLog.cpp
@@ -23,12 +23,11 @@
* Anton Arapov <anton@redhat.com>
* Arjan van de Ven <arjan@linux.intel.com>
*/
+
#include "abrtlib.h"
#include "KerneloopsSysLog.h"
#include <list>
-//#include <stdlib.h>
-//#include <string.h>
#include <assert.h>
/*
diff --git a/src/Daemon/MiddleWare.h b/src/Daemon/MiddleWare.h
index 050844cb..c9fc73a9 100644
--- a/src/Daemon/MiddleWare.h
+++ b/src/Daemon/MiddleWare.h
@@ -37,7 +37,7 @@ class CMiddleWare
{
public:
/**
- * An emun contains all return codes.
+ * An enum contains all return codes.
*/
typedef enum {
MW_ERROR, /**< Common error.*/