mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Use GString for path in creating c plugins, fixed hook name in test-c-plugin
This commit is contained in:
parent
8bbab0ab5f
commit
2dc8030f8b
@ -23,7 +23,7 @@ prof_on_connect (void)
|
||||
}
|
||||
|
||||
void
|
||||
c_on_message_received (const char * const jid, const char * const message)
|
||||
prof_on_message_received (const char * const jid, const char * const message)
|
||||
{
|
||||
fprintf (stderr, "called %s with args=<%s, %s>\n", __func__, jid, message);
|
||||
}
|
||||
|
@ -1,3 +1,9 @@
|
||||
// FIXME on windows this might be a different header
|
||||
#include <dlfcn.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "config/preferences.h"
|
||||
#include "log.h"
|
||||
@ -7,26 +13,17 @@
|
||||
#include "plugins/c_plugins.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
// FIXME on windows this might be a different header
|
||||
#include <dlfcn.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
ProfPlugin *
|
||||
c_plugin_create(const char * const filename)
|
||||
{
|
||||
ProfPlugin *plugin;
|
||||
void * handle = NULL;
|
||||
char * path = NULL;
|
||||
void *handle = NULL;
|
||||
|
||||
// FIXME so where is the right path for the plugin dir?
|
||||
if (-1 == asprintf (&path, "./plugins/%s", filename)) {
|
||||
log_warning ("asprintf failed, plugin %s not loaded", filename);
|
||||
return NULL;
|
||||
}
|
||||
// TODO use XDG for path
|
||||
GString *path = g_string_new("./plugins/");
|
||||
g_string_append(path, filename);
|
||||
|
||||
handle = dlopen (path, RTLD_NOW | RTLD_GLOBAL);
|
||||
handle = dlopen (path->str, RTLD_NOW | RTLD_GLOBAL);
|
||||
|
||||
if (!handle) {
|
||||
log_warning ("dlopen failed to open `%s', %s", filename, dlerror ());
|
||||
@ -42,8 +39,7 @@ c_plugin_create(const char * const filename)
|
||||
plugin->on_connect_func = c_on_connect_hook;
|
||||
plugin->on_message_received_func = c_on_message_received_hook;
|
||||
|
||||
if (!path)
|
||||
free (path);
|
||||
g_string_free(path, TRUE);
|
||||
|
||||
return plugin;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user