1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge branch 'plugins' into ruby

This commit is contained in:
James Booth 2013-08-18 17:04:25 +01:00
commit fd3419b8af
2 changed files with 15 additions and 17 deletions

View File

@ -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);
} }

View File

@ -1,34 +1,33 @@
// 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 "plugins/api.h" #include "plugins/api.h"
#include "plugins/callbacks.h" #include "plugins/callbacks.h"
#include "plugins/plugins.h" #include "plugins/plugins.h"
#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 ());
g_string_free(path, TRUE);
return NULL; return NULL;
} }
@ -41,8 +40,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;
} }