diff options
| author | 2025-11-17 20:57:42 -0600 | |
|---|---|---|
| committer | 2025-11-17 20:57:42 -0600 | |
| commit | 2b44f885e97b0d8902014a5a61f6687fa2931dec (patch) | |
| tree | 9e3ecfb3858f33a3922f47bde8a2163d9deed95e /src/plugins.c | |
| parent | build config + more plugin stuff (diff) | |
ignore this commit
Diffstat (limited to 'src/plugins.c')
| -rw-r--r-- | src/plugins.c | 63 |
1 files changed, 63 insertions, 0 deletions
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; +} |
