summaryrefslogtreecommitdiffstats
path: root/src/Daemon/ABRTPlugin.cpp
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-08-24 04:58:48 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-08-24 04:58:48 +0200
commit959a0b1b38e45cf8c00a862be01a0bb05e599123 (patch)
tree9c70cbf7ffaf60d834974435edf085b941c93933 /src/Daemon/ABRTPlugin.cpp
parent6f5574c0f60679cd278ca20f0c91d268ccf63927 (diff)
downloadabrt-959a0b1b38e45cf8c00a862be01a0bb05e599123.tar.gz
abrt-959a0b1b38e45cf8c00a862be01a0bb05e599123.tar.xz
abrt-959a0b1b38e45cf8c00a862be01a0bb05e599123.zip
eliminate class DynamicLybrary by folding it into class ABRTPlugin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src/Daemon/ABRTPlugin.cpp')
-rw-r--r--src/Daemon/ABRTPlugin.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/Daemon/ABRTPlugin.cpp b/src/Daemon/ABRTPlugin.cpp
index 20486a2d..e3f5fb8d 100644
--- a/src/Daemon/ABRTPlugin.cpp
+++ b/src/Daemon/ABRTPlugin.cpp
@@ -19,22 +19,28 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "abrtlib.h"
#include "ABRTPlugin.h"
+#include <dlfcn.h>
-CABRTPlugin::CABRTPlugin(const std::string& pLibPath) :
- m_pDynamicLibrary(NULL),
- m_pPluginInfo(NULL),
- m_pFnPluginNew(NULL)
+CABRTPlugin::CABRTPlugin(const char* pLibPath)
{
- m_pDynamicLibrary = new CDynamicLibrary(pLibPath);
- m_pPluginInfo = reinterpret_cast<typeof(m_pPluginInfo)>(m_pDynamicLibrary->FindSymbol("plugin_info"));
- m_pFnPluginNew = reinterpret_cast<typeof(m_pFnPluginNew)>(m_pDynamicLibrary->FindSymbol("plugin_new"));
+ /* All errors are fatal */
+ m_pHandle = dlopen(pLibPath, RTLD_NOW);
+ if (!m_pHandle)
+ error_msg_and_die("can't load '%s'", pLibPath);
+
+#define LOADSYM(fp, handle, name) do { \
+ fp = (typeof(fp)) (dlsym(handle, name)); \
+ if (!fp) \
+ error_msg_and_die("'%s' has no %s entry", pLibPath, name); \
+} while (0)
+
+ LOADSYM(m_pPluginInfo, m_pHandle, "plugin_info");
+ LOADSYM(m_pFnPluginNew, m_pHandle, "plugin_new");
}
CABRTPlugin::~CABRTPlugin()
{
- if (m_pDynamicLibrary != NULL)
- {
- delete m_pDynamicLibrary;
- }
+ dlclose(m_pHandle);
}