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
|
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);
|
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 "config/preferences.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
@ -7,26 +13,17 @@
|
|||||||
#include "plugins/c_plugins.h"
|
#include "plugins/c_plugins.h"
|
||||||
#include "ui/ui.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 *
|
ProfPlugin *
|
||||||
c_plugin_create(const char * const filename)
|
c_plugin_create(const char * const filename)
|
||||||
{
|
{
|
||||||
ProfPlugin *plugin;
|
ProfPlugin *plugin;
|
||||||
void *handle = NULL;
|
void *handle = NULL;
|
||||||
char * path = NULL;
|
|
||||||
|
|
||||||
// FIXME so where is the right path for the plugin dir?
|
// TODO use XDG for path
|
||||||
if (-1 == asprintf (&path, "./plugins/%s", filename)) {
|
GString *path = g_string_new("./plugins/");
|
||||||
log_warning ("asprintf failed, plugin %s not loaded", filename);
|
g_string_append(path, filename);
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle = dlopen (path, RTLD_NOW | RTLD_GLOBAL);
|
handle = dlopen (path->str, RTLD_NOW | RTLD_GLOBAL);
|
||||||
|
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
log_warning ("dlopen failed to open `%s', %s", filename, dlerror ());
|
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_connect_func = c_on_connect_hook;
|
||||||
plugin->on_message_received_func = c_on_message_received_hook;
|
plugin->on_message_received_func = c_on_message_received_hook;
|
||||||
|
|
||||||
if (!path)
|
g_string_free(path, TRUE);
|
||||||
free (path);
|
|
||||||
|
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user