From 2be63668af1cadf846ae2d44a0fd5c909ceaf47e Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 4 Apr 2020 11:32:54 +0200 Subject: Add plugins --- plugin.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 plugin.cpp (limited to 'plugin.cpp') diff --git a/plugin.cpp b/plugin.cpp new file mode 100644 index 0000000..9c47ed2 --- /dev/null +++ b/plugin.cpp @@ -0,0 +1,36 @@ +#include "plugin.h" + +#include +#include +#include + +#include +#include + +#include "plugin_interface.h" + +namespace dll = boost::dll; +namespace fs = std::filesystem; +using namespace std::string_literals; + +void load_plugins(Config& config) +{ + const auto& plugin_directories{config.PluginDirectories()}; + + for (const auto& dir: plugin_directories) { + for (auto& path: fs::recursive_directory_iterator(dir)) { + if (path.is_regular_file()) { + + dll::fs::path lib_path{path.path()}; + + boost::shared_ptr plugin = dll::import(lib_path, "webserver_plugin", dll::load_mode::append_decorations); + if (!plugin) + throw std::runtime_error("Can't load plugin"); + + std::cout << "Plugin: " << plugin->generate_page("a") << std::endl; + } + } + } + +} + -- cgit v1.2.3