summaryrefslogtreecommitdiffhomepage
path: root/plugin.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-04-04 11:32:54 +0200
committerRoland Reichwein <mail@reichwein.it>2020-04-04 11:32:54 +0200
commit2be63668af1cadf846ae2d44a0fd5c909ceaf47e (patch)
treeaf80bc23d9b1dde815a3cf44285c6719490d282a /plugin.cpp
parent12972923e74e3dd174f3ce3e59c2db5ca9b400eb (diff)
Add plugins
Diffstat (limited to 'plugin.cpp')
-rw-r--r--plugin.cpp36
1 files changed, 36 insertions, 0 deletions
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 <boost/dll/import.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/filesystem.hpp>
+
+#include <iostream>
+#include <filesystem>
+
+#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<webserver_plugin_interface> plugin = dll::import<webserver_plugin_interface>(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;
+ }
+ }
+ }
+
+}
+