diff options
Diffstat (limited to 'plugin.cpp')
-rw-r--r-- | plugin.cpp | 35 |
1 files changed, 21 insertions, 14 deletions
@@ -20,24 +20,31 @@ void PluginLoader::load_plugins() for (const auto& dir: plugin_directories) { for (auto& path: fs::recursive_directory_iterator(dir)) { - if (path.is_regular_file()) { + if (path.is_regular_file() && path.path().extension() == ".so"s) { dll::fs::path lib_path{path.path()}; try { - boost::shared_ptr<webserver_plugin_interface> plugin = dll::import<webserver_plugin_interface>(lib_path, "webserver_plugin", dll::load_mode::append_decorations); - if (plugin) { - if (plugin->version() != webserver_plugin_interface::interface_version) - throw std::runtime_error("Bad interface version for "s + path.path().generic_string() + ": "s + std::to_string(plugin->version()) + " vs. "s + std::to_string(webserver_plugin_interface::interface_version)); - - if (m_plugins.contains(plugin->name())) - throw std::runtime_error("Plugin already exists: "s + plugin->name()); - - m_plugins.emplace(plugin->name(), plugin); - - std::cout << "Found plugin: " << plugin->name() << std::endl; - } else - std::cout << "Can't load plugin from " << path.path().generic_string() << std::endl; + boost::shared_ptr<webserver_plugin_interface> plugin = dll::import<webserver_plugin_interface>(lib_path, "webserver_plugin", dll::load_mode::append_decorations); + if (plugin) { + if (plugin->version() != webserver_plugin_interface::interface_version) + throw std::runtime_error("Bad interface version for "s + path.path().generic_string() + ": "s + std::to_string(plugin->version()) + " vs. "s + std::to_string(webserver_plugin_interface::interface_version)); + + std::string name{plugin->name()}; + if (m_plugins.contains(name)) + throw std::runtime_error("Plugin already exists: "s + name); + + std::cout << "Found plugin: " << name << " (" << path.path().string() << "), "; + if (m_config.PluginIsConfigured(name)) { + std::cout << "loading."; + m_plugins.emplace(plugin->name(), plugin); + } else { + std::cout << "ignored (not configured)."; + } + std::cout << std::endl; + + } else + std::cout << "Can't load plugin from " << path.path().generic_string() << std::endl; } catch (const std::exception& ex) { std::cout << "Can't load plugin from " << path.path().generic_string() << ": " << ex.what() << std::endl; } |