Contains implementations of plugin loading functions.
More...
#include <dlfcn.h>
#include <dirent.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <boost/tokenizer.hpp>
#include "ClassFactory.h"
#include "PluginLoader.h"
Go to the source code of this file.
Contains implementations of plugin loading functions.
Definition in file PluginLoader.cpp.
◆ filter()
| static int filter |
( |
std::string & |
name, |
|
|
const char * |
suffix |
|
) |
| |
|
static |
Definition at line 105 of file PluginLoader.cpp.
107 std::string delimiters =
".";
108 std::vector <std::string> items;
110 tokenize(name, delimiters, items);
112 if (items.size() == 0) {
116 if (items[items.size() -1] == suffix) {
Referenced by getDirSos().
◆ getDirSos()
| bool getDirSos |
( |
std::vector< std::string > & |
sos, |
|
|
std::string & |
dir |
|
) |
| |
Definition at line 125 of file PluginLoader.cpp.
128 const char *ds = dir.c_str();
132 dirh = FindFirstFileA(ds, &fd);
133 while (dirh != INVALID_HANDLE_VALUE)
135 std::string name = fd.cFileName;
136 std::string name_lower;
138 std::transform(name.begin(), name.end(), name_lower.begin(), ::tolower);
140 if (
filter(name_lower,
"so")) {
141 name = dir +
"/" + name;
145 if (!FindNextFileA(dirh, &fd))
152 struct dirent *dirent;
154 const char *ds = dir.c_str();
155 DIR *dirfd = opendir(ds);
158 "Field3D_plugin loader: could not open directory " + dir +
"\n";
163 dirent = readdir(dirfd);
164 while (dirent != NULL) {
166 std::string name = dirent->d_name;
169 name = dir +
"/" + name;
173 dirent = readdir(dirfd);
static int filter(std::string &name, const char *suffix)
References filter().
Referenced by PluginLoader::loadPlugins().
◆ findRegistrationFunc()
Definition at line 181 of file PluginLoader.cpp.
184 HMODULE handle = ::LoadLibraryA(sofile.c_str());
186 void *handle = dlopen(sofile.c_str(), RTLD_GLOBAL|RTLD_NOW);
194 FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
195 NULL, GetLastError(),
196 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&errstr,
202 errmsg =
"Unknown error";
209 "Field3D Plugin loader: failed to load plugin: " << errmsg <<
"\n";
224 char *debugEnvVar = getenv(
"FIELD3D_DEBUG");
228 "Field3D plugin loader: failed to load " 229 "the symbol registerField3DPlugin");
FIELD3D_NAMESPACE_OPEN typedef int(* RegistrationFunc)(ClassFactory &)
FIELD3D_API void print(Severity severity, const std::string &message)
Sends the string to the assigned output, prefixing the message with the severity.
References Msg::print(), RegistrationFunc, and Msg::SevWarning.
Referenced by PluginLoader::loadPlugins().
◆ RegistrationFunc