28 |
#include <dlfcn.h> |
#include <dlfcn.h> |
29 |
#include <errno.h> |
#include <errno.h> |
30 |
#include <dirent.h> |
#include <dirent.h> |
31 |
|
#include <sys/types.h> |
32 |
|
#include <sys/stat.h> |
33 |
|
#include <unistd.h> |
34 |
#endif |
#endif |
35 |
#include <string.h> |
#include <string.h> |
36 |
|
|
188 |
return; |
return; |
189 |
} |
} |
190 |
for (dirent* pEntry = readdir(hDir); pEntry; pEntry = readdir(hDir)) { |
for (dirent* pEntry = readdir(hDir); pEntry; pEntry = readdir(hDir)) { |
191 |
|
// dir entry name as full qualified path |
192 |
|
const String sPath = CONFIG_PLUGIN_DIR + ("/" + String(pEntry->d_name)); |
193 |
// skip entries that are not regular files |
// skip entries that are not regular files |
194 |
if (pEntry->d_type != DT_REG) continue; |
struct stat entry_stat; |
195 |
String sPath = pEntry->d_name; |
if (lstat(sPath.c_str(), &entry_stat) != 0 || |
196 |
|
(entry_stat.st_mode & S_IFMT) != S_IFREG) |
197 |
|
continue; |
198 |
// skip files that are not .so files |
// skip files that are not .so files |
199 |
if ( |
if (sPath.length() < 3 || |
200 |
sPath.substr(sPath.length() - 3) != ".so" && |
sPath.substr(sPath.length() - 3) != ".so" && |
201 |
sPath.find(".so.") == String::npos |
sPath.find(".so.") == String::npos |
202 |
) continue; |
) continue; |
|
// make it a full qualified path |
|
|
sPath = CONFIG_PLUGIN_DIR + ("/" + sPath); |
|
203 |
// load the DLL (the plugins should register themselfes automatically) |
// load the DLL (the plugins should register themselfes automatically) |
204 |
void* pDLL = dlopen(sPath.c_str(), RTLD_NOW); |
void* pDLL = dlopen(sPath.c_str(), RTLD_NOW); |
205 |
if (pDLL) LoadedDLLs.push_back(pDLL); |
if (pDLL) LoadedDLLs.push_back(pDLL); |