unixpluginloader.cpp
39 lines
| 1.3 KiB
| text/x-c
|
CppLexer
Jeandet Alexis
|
r0 | #include "unixpluginloader.h" | ||
#include <stdio.h> | ||||
#include <QDebug> | ||||
Jeandet Alexis
|
r100 | #include <socexplorerengine.h> | ||
Jeandet Alexis
|
r0 | |||
unixPluginLoader::unixPluginLoader(const QString &libPath) | ||||
{ | ||||
Jeandet Alexis
|
r100 | SocExplorerEngine::message("unixPluginLoader::unixPluginLoader","try to open "+libPath,3); | ||
Jeandet Alexis
|
r0 | dlHandle = dlopen(libPath.toStdString().c_str(),RTLD_LAZY|RTLD_GLOBAL); | ||
if(dlHandle==NULL) | ||||
Jeandet Alexis
|
r100 | SocExplorerEngine::message("unixPluginLoader::unixPluginLoader",QString("Failed ") + dlerror(),3); | ||
Jeandet Alexis
|
r0 | else | ||
Jeandet Alexis
|
r100 | SocExplorerEngine::message("unixPluginLoader::unixPluginLoader","Success " ,3); | ||
Jeandet Alexis
|
r0 | this->libPath = libPath; | ||
} | ||||
void *unixPluginLoader::resolve(const QString &symbol) | ||||
{ | ||||
if(dlHandle!=NULL) | ||||
{ | ||||
Jeandet Alexis
|
r100 | SocExplorerEngine::message("unixPluginLoader::resolve","try to resolve "+symbol+" in "+libPath ,3); | ||
Jeandet Alexis
|
r0 | void* sym = dlsym (dlHandle, symbol.toStdString().c_str()); | ||
if(sym==NULL) | ||||
Jeandet Alexis
|
r100 | SocExplorerEngine::message("unixPluginLoader::resolve",QString("Failed")+ dlerror() ,3); | ||
Jeandet Alexis
|
r0 | else | ||
Jeandet Alexis
|
r100 | SocExplorerEngine::message("unixPluginLoader::resolve","Success",3); | ||
Jeandet Alexis
|
r0 | return sym; | ||
} | ||||
return NULL; | ||||
} | ||||
void unixPluginLoader::close() | ||||
{ | ||||
if(dlHandle!=NULL) | ||||
{ | ||||
dlclose(dlHandle); | ||||
Jeandet Alexis
|
r100 | SocExplorerEngine::message("unixPluginLoader::close",dlerror(),3); | ||
Jeandet Alexis
|
r0 | } | ||
} | ||||