summaryrefslogtreecommitdiffstats
path: root/src/include
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-12-08 14:51:47 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2010-12-08 14:51:47 +0100
commit816f3e001271ed8ab7fdadb6d90aeb2c61362dac (patch)
treea7e453859a80fb47c7c74cb37791e35ad50f1d97 /src/include
parent3a9554929de070297a0e816eb2839291335a9403 (diff)
downloadabrt-816f3e001271ed8ab7fdadb6d90aeb2c61362dac.tar.gz
abrt-816f3e001271ed8ab7fdadb6d90aeb2c61362dac.tar.xz
abrt-816f3e001271ed8ab7fdadb6d90aeb2c61362dac.zip
removal of C++isms from libabrt, part 1
This patch converts libabrt usage of C++ map<string, string> to a glib-based container, GHashTable. It is typedef-ed to map_string_h. We can't typedef it to map_string_t, since other parts of ABRT (daemon, cli) still use that name for C++ container. Also, exceptions are removed everywhere. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/Makefile.am1
-rw-r--r--src/include/abrt_exception.h57
-rw-r--r--src/include/abrt_types.h27
-rw-r--r--src/include/abrtlib.h30
-rw-r--r--src/include/plugin.h1
5 files changed, 42 insertions, 74 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index c035aaa9..5b61bd82 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -3,7 +3,6 @@ HEADER_FILES = \
dump_dir.h \
run_event.h \
\
- abrt_exception.h \
abrtlib.h \
abrt_types.h \
comm_layer_inner.h \
diff --git a/src/include/abrt_exception.h b/src/include/abrt_exception.h
deleted file mode 100644
index b826bfa8..00000000
--- a/src/include/abrt_exception.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- Copyright (C) 2010 ABRT team
- Copyright (C) 2010 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 ABRTEXCEPTION_H_
-#define ABRTEXCEPTION_H_
-
-#include "abrtlib.h"
-
-typedef enum {
- EXCEP_UNKNOW,
- EXCEP_DD_OPEN,
- EXCEP_DD_LOAD,
- EXCEP_DD_SAVE,
- EXCEP_DD_DELETE,
- EXCEP_DL,
- EXCEP_PLUGIN,
- EXCEP_ERROR,
-} abrt_exception_t;
-
-/* std::exception is a class with virtual members.
- * deriving from it makes our ctor/dtor much more heavy,
- * and those are inlined in every throw and catch site!
- */
-class CABRTException /*: public std::exception*/
-{
- private:
- abrt_exception_t m_type;
- char *m_what;
-
- /* Not defined. You can't use it */
- CABRTException& operator= (const CABRTException&);
-
- public:
- ~CABRTException() { free(m_what); }
- CABRTException(abrt_exception_t type, const char* fmt, ...);
- CABRTException(const CABRTException& rhs);
-
- abrt_exception_t type() { return m_type; }
- const char* what() const { return m_what; }
-};
-
-#endif
diff --git a/src/include/abrt_types.h b/src/include/abrt_types.h
index 38804895..3ebd1697 100644
--- a/src/include/abrt_types.h
+++ b/src/include/abrt_types.h
@@ -19,6 +19,33 @@
#ifndef ABRT_TYPES_H_
#define ABRT_TYPES_H_
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* We can't typedef it to map_string_t, since other parts of ABRT
+ * (daemon, cli) still use that name for C++ container. For now,
+ * let's call it map_string_h:
+ */
+typedef GHashTable map_string_h;
+
+map_string_h *new_map_string(void);
+void free_map_string(map_string_h *ms);
+const char *get_map_string_item_or_empty(map_string_h *ms, const char *key);
+static inline
+const char *get_map_string_item_or_NULL(map_string_h *ms, const char *key)
+{
+ return (const char*)g_hash_table_lookup(ms, key);
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
#ifdef __cplusplus
#include <map>
diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h
index a4337709..f3a5de4e 100644
--- a/src/include/abrtlib.h
+++ b/src/include/abrtlib.h
@@ -224,6 +224,20 @@ char* make_description_mailx(crash_data_t *crash_data);
void parse_release(const char *pRelease, char **product, char **version);
+/**
+ * Loads settings and stores it in second parameter. On success it
+ * returns true, otherwise returns false.
+ *
+ * @param path A path of config file.
+ * Config file consists of "key=value" lines.
+ * @param settings A read plugin's settings.
+ * @param skipKeysWithoutValue
+ * If true, lines in format "key=" (without value) are skipped.
+ * Otherwise empty value "" is inserted into pSettings.
+ * @return if it success it returns true, otherwise it returns false.
+ */
+bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWithoutValue);
+
#ifdef __cplusplus
}
#endif
@@ -241,22 +255,6 @@ std::string to_string(T x)
return unsigned_to_string(x);
}
-/**
- * Loads settings and stores it in second parameter. On success it
- * returns true, otherwise returns false.
- *
- * @param path A path of config file.
- * Config file consists of "key=value" lines.
- * @param settings A readed plugin's settings.
- * @param skipKeysWithoutValue
- * If true, lines in format "key=" (without value) are skipped.
- * Otherwise empty value "" is inserted into pSettings.
- * @return if it success it returns true, otherwise it returns false.
- */
-extern bool LoadPluginSettings(const char *pPath,
- map_plugin_settings_t& pSettings,
- bool skipKeysWithoutValue = true);
-
// TODO: npajkovs: full rewrite ssprintf -> xasprintf
static inline std::string ssprintf(const char *format, ...)
{
diff --git a/src/include/plugin.h b/src/include/plugin.h
index 3f652e65..322c212f 100644
--- a/src/include/plugin.h
+++ b/src/include/plugin.h
@@ -76,6 +76,7 @@ typedef enum {
REPORTER, /**< A reporter plugin*/
DATABASE, /**< A database plugin*/
MAX_PLUGIN_TYPE = DATABASE,
+ INVALID_PLUGIN_TYPE
} plugin_type_t;
/**