aboutsummaryrefslogtreecommitdiff
path: root/src/rc-plugin.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-05-14 19:50:13 +0000
committerRoy Marples <roy@marples.name>2007-05-14 19:50:13 +0000
commitf3888d76138c9f347e118e3942d5a1dd49b351ff (patch)
treeb2c20c5d6643a050a088595bc74448ecfa2f86a1 /src/rc-plugin.c
parentd0308aaecd1cb2f1c620a742f2fbaee00cb03c04 (diff)
Implement FreeBSD's dlfunc function to avoid ISO warnings on dlsym - thanks to drizztbsd for find public domain code :)
Diffstat (limited to 'src/rc-plugin.c')
-rw-r--r--src/rc-plugin.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/rc-plugin.c b/src/rc-plugin.c
index 2c8bfff5..66ffeb5c 100644
--- a/src/rc-plugin.c
+++ b/src/rc-plugin.c
@@ -29,6 +29,19 @@ typedef struct plugin
static plugin_t *plugins = NULL;
+#ifndef __FreeBSD__
+dlfunc_t dlfunc (void * __restrict handle, const char * __restrict symbol)
+{
+ union {
+ void *d;
+ dlfunc_t f;
+ } rv;
+
+ rv.d = dlsym (handle, symbol);
+ return (rv.f);
+}
+#endif
+
void rc_plugin_load (void)
{
char **files;
@@ -62,11 +75,7 @@ void rc_plugin_load (void)
func = rc_xmalloc (sizeof (char *) * len);
snprintf (func, len, "_%s_hook", file);
-#ifdef __FreeBSD__
fptr = (int (*)(rc_hook_t, const char*)) dlfunc (h, func);
-#else
- fptr = (int (*)(rc_hook_t, const char*)) dlsym (h, func);
-#endif
if (! fptr) {
eerror ("`%s' does not expose the symbol `%s'", p, func);
dlclose (h);