Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
plugin-dynlib.c
Go to the documentation of this file.
1/*
2 PluginDynlib - Lumiera Plugin loader for dynamic libraries
3
4 Copyright (C)
5 2008, Christian Thaeter <ct@pipapo.org>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12* *****************************************************************/
13
14
19#include "include/logging.h"
20#include "lib/tmpbuf.h"
21#include "common/plugin.h"
22
23#include <dlfcn.h>
24#include <nobug.h>
25
26
29{
30 TRACE (pluginloader_dbg, "load DYNLIB: %s", name);
31 REQUIRE (name);
33 LumieraInterface plugin = NULL;
34
35 void* handle = dlopen (name, RTLD_LAZY|RTLD_LOCAL);
36 if (handle)
37 {
38 plugin = (LumieraInterface) dlsym (handle, LUMIERA_INTERFACE_DSTRING (lumieraorg__plugin, 0, lumieraorg_plugin));
39
40 if (!plugin)
41 LUMIERA_ERROR_SET (pluginloader, PLUGIN_WTF, name);
42 }
43 else
44 LUMIERA_ERROR_SET (pluginloader_dbg, PLUGIN_OPEN, lumiera_tmpbuf_snprintf (4096, "%s: %s", name, dlerror()));
45
46 return lumiera_plugin_init (self, handle, plugin);
47}
48
49
50void
52{
53 TRACE (pluginloader_dbg);
54 void* handle = lumiera_plugin_handle (self);
55 if (handle)
56 dlclose (handle);
58}
#define LUMIERA_ERROR_SET(flag, err, extra)
Helper macro to raise an error for the current thread.
Definition error.h:82
#define LUMIERA_INTERFACE_DSTRING(iname, version, dname)
Construct a definition string for an interface.
Definition interface.h:111
lumiera_interface * LumieraInterface
Definition interface.h:355
return NULL
Definition llist.h:586
This header is for including and configuring NoBug.
void lumiera_plugin_unload_DYNLIB(LumieraPlugin self)
LumieraPlugin lumiera_plugin_load_DYNLIB(const char *name)
void * lumiera_plugin_handle(LumieraPlugin self)
Query the plugin handle.
Definition plugin.c:157
LumieraPlugin lumiera_plugin_init(LumieraPlugin self, void *handle, LumieraInterface plugin)
Definition plugin.c:139
LumieraPlugin lumiera_plugin_new(const char *name)
Allocates an preinitialises a plugin structure.
Definition plugin.c:123
Lumiera plugins define 'interfaces' as shown in interface.h, the plugin system handles the loading of...
lumiera_plugin * LumieraPlugin
Definition plugin.h:64
char * lumiera_tmpbuf_snprintf(size_t size, const char *fmt,...)
Construct a string in a tmpbuf.
Definition tmpbuf.c:116
Round robin temporary buffers.