aboutsummaryrefslogtreecommitdiff
path: root/arken/src/plugin_load.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2026-01-06 23:08:25 -0700
committerJosh Rahm <joshuarahm@gmail.com>2026-01-06 23:09:52 -0700
commit37e5037b68fb35276f0c426779f61aa278d5b21b (patch)
tree94e0b7a413b2899e7114c7453cd0f234a438ce15 /arken/src/plugin_load.c
parent09860c75bb129c70768692aaec3bd42d0b2735e3 (diff)
downloadmontis-37e5037b68fb35276f0c426779f61aa278d5b21b.tar.gz
montis-37e5037b68fb35276f0c426779f61aa278d5b21b.tar.bz2
montis-37e5037b68fb35276f0c426779f61aa278d5b21b.zip
[reorg] use X macro system rather than perl generation.
This remove the dependency on Perl and makes things less brittle.
Diffstat (limited to 'arken/src/plugin_load.c')
-rw-r--r--arken/src/plugin_load.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/arken/src/plugin_load.c b/arken/src/plugin_load.c
new file mode 100644
index 0000000..6525969
--- /dev/null
+++ b/arken/src/plugin_load.c
@@ -0,0 +1,39 @@
+#include "plugin.h"
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+#include "plugin_exports.h"
+
+int load_plugin_from_dl_(dlhandle_t dl, plugin_t *plug)
+{
+ void *ptr;
+ int ret = 0;
+
+ const char **name = dlsym(dl, "plugin_name");
+ if (name) {
+ plug->plugin_name = *name;
+ }
+ else {
+ plug->plugin_name = NULL;
+ }
+
+ plug->state = NULL;
+ plug->library_handle = dl;
+
+#define LOAD_SYM(ret_type, sym, args) \
+ do { \
+ ptr = dlsym(dl, #sym); \
+ if (!ptr) { \
+ fprintf(stderr, "Plugin missing %s\n", #sym); \
+ ret |= 1; \
+ } \
+ plug->sym = (ret_type(*) args)ptr; \
+ } while (0);
+
+ MONTIS_PLUGIN_EXPORTS(LOAD_SYM);
+
+#undef LOAD_SYM
+
+ return ret;
+}