summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c2
-rw-r--r--src/meson.build3
-rw-r--r--src/plugins.c63
3 files changed, 65 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 83ed688..50baf66 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5,8 +5,6 @@
#include "pipeline.h"
-#define UNUSED(_v) ((void)(_v))
-
PIPELINE_STAGE static int identity_stage_handle(const ptx_pipeline_ctx_t *ctx, const void *data, size_t sz)
{
return ptx_pipeline_ctx_next(ctx, data, sz);
diff --git a/src/meson.build b/src/meson.build
index d1a3033..ba3d51b 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,5 +1,6 @@
prog_sources = files(
'pipeline.c',
'connection.c',
- 'main.c'
+ 'main.c',
+ 'plugins.c'
)
diff --git a/src/plugins.c b/src/plugins.c
new file mode 100644
index 0000000..f2f8d14
--- /dev/null
+++ b/src/plugins.c
@@ -0,0 +1,63 @@
+#include "plugins.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <dirent.h>
+
+struct ptx__plugin_manager_tag
+{
+ size_t sz_plugins;
+ ptx_plugin_t *plugins;
+};
+
+struct ptx__plugin_handle_tag
+{
+ char *path;
+};
+
+ptx_plugin_manager_t *ptx_plugin_manager_new(void)
+{
+ ptx_plugin_manager_t *mgr = malloc(sizeof(ptx_plugin_manager_t));
+ if (!mgr) return NULL;
+
+ /* do init */
+ mgr->sz_plugins = 0;
+ mgr->plugins = NULL;
+
+ return mgr;
+}
+
+void ptx_plugin_manager_free(ptx_plugin_manager_t *mgr)
+{
+ if (!mgr) return;
+
+ /* do cleanup */
+
+ free(mgr);
+ return;
+}
+
+int ptx_plugin_manager_load_dir(ptx_plugin_manager_t *mgr, const char *dirnam)
+{
+ struct dirent *ent;
+ DIR *dir = opendir(dirnam);
+
+ if (!dir) {
+ fprintf(stderr, "Failed to load plugins from %s (opendir): %s\n", dirnam, strerror(errno));
+ return -1;
+ }
+
+ while ((errno = 0, ent = readdir(dir))) {
+
+ }
+
+ if (errno != 0) {
+ fprintf(stderr, "Error reading entries from %s (readdir): %s\n", dirnam, strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}