summaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/plugin_manager.c11
-rw-r--r--src/plugins/plugin_manager.h5
2 files changed, 7 insertions, 9 deletions
diff --git a/src/plugins/plugin_manager.c b/src/plugins/plugin_manager.c
index 12c85cd..afca55e 100644
--- a/src/plugins/plugin_manager.c
+++ b/src/plugins/plugin_manager.c
@@ -39,13 +39,12 @@ void zptr_register_plugin(ZPlugin *plugin)
head = node;
}
-int zptr_load_plugin(const char *path)
+ZPlugin *zptr_load_plugin(const char *path)
{
void *handle = dlopen(path, RTLD_LAZY);
if (!handle)
{
- fprintf(stderr, "Failed to load plugin '%s': %s\n", path, dlerror());
- return 0;
+ return NULL;
}
ZPluginInitFn init_fn = (ZPluginInitFn)dlsym(handle, "z_plugin_init");
@@ -53,7 +52,7 @@ int zptr_load_plugin(const char *path)
{
fprintf(stderr, "Plugin '%s' missing 'z_plugin_init' symbol\n", path);
dlclose(handle);
- return 0;
+ return NULL;
}
ZPlugin *plugin = init_fn();
@@ -61,7 +60,7 @@ int zptr_load_plugin(const char *path)
{
fprintf(stderr, "Plugin '%s' init returned NULL\n", path);
dlclose(handle);
- return 0;
+ return NULL;
}
// Register
@@ -71,7 +70,7 @@ int zptr_load_plugin(const char *path)
node->next = head;
head = node;
- return 1;
+ return plugin;
}
ZPlugin *zptr_find_plugin(const char *name)
diff --git a/src/plugins/plugin_manager.h b/src/plugins/plugin_manager.h
index a1e8ca6..9b35c2d 100644
--- a/src/plugins/plugin_manager.h
+++ b/src/plugins/plugin_manager.h
@@ -10,9 +10,8 @@ void zptr_plugin_mgr_init(void);
void zptr_register_plugin(ZPlugin *plugin);
// Load a plugin from a shared object file (.so).
-// Returns 1 on success, 0 on failure.
-// Yeah, for now, I'm sorry Windows guys.
-int zptr_load_plugin(const char *path);
+// Returns ZPlugin pointer on success, NULL on failure.
+ZPlugin *zptr_load_plugin(const char *path);
// Find a registered plugin by name.
ZPlugin *zptr_find_plugin(const char *name);