#include "plugin.h"
#include "debug.h"

ObFramePlugin * init_render(const gchar * filename) {
	GModule *module;
	gpointer func;

	if (!(module = g_module_open(filename, G_MODULE_BIND_LOCAL))) {
		ob_debug_type(OB_DEBUG_SM, "Failed to load plugin (%s): %s\n",
				filename, g_module_error());
		return;
	}

	if (g_module_symbol(module, "get_info", &func)) {
		ObFramePlugin *plugin = (ObFramePlugin *) ((ObFramePluginFunc) func)();
		return plugin;
	}
	else
	{
		ob_debug_type(OB_DEBUG_SM, "Failed to get \"get_info\" function (%s): %s\n",
						filename, g_module_error());
		exit(1);
	}

	ob_debug_type(OB_DEBUG_SM, "Invalid plugin (%s)\n", filename);
	g_module_close(module);
}

