1 /* vi: set et sw=4 ts=4 cino=t0,(0: */
2 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
4 * This file is part of gsignond
6 * Copyright (C) 2012-2014 Intel Corporation.
8 * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
31 #include "gsignond/gsignond-log.h"
32 #include "gsignond-plugin-loader.h"
35 gsignond_load_plugin (
36 GSignondConfig* config,
37 const gchar *plugin_type)
39 const gchar *plugin_path = GSIGNOND_GPLUGINS_DIR;
40 gchar *plugin_filename;
41 GSignondPlugin *plugin;
44 const gchar *env_val = g_getenv("SSO_GPLUGINS_DIR");
46 plugin_path = env_val;
48 plugin_filename = g_module_build_path (plugin_path, plugin_type);
49 plugin = gsignond_load_plugin_with_filename (plugin_type,
51 g_free(plugin_filename);
56 gsignond_load_plugin_with_filename(
57 const gchar *plugin_type,
58 const gchar *plugin_filename)
60 DBG("Loading plugin %s", plugin_filename);
61 GModule* plugin_module = g_module_open (plugin_filename,
63 if (plugin_module == NULL) {
64 DBG("Plugin couldn't be opened: %s", g_module_error());
68 gchar* plugin_get_type = g_strdup_printf("gsignond_%s_plugin_get_type",
72 DBG("Resolving symbol %s", plugin_get_type);
73 gboolean symfound = g_module_symbol (plugin_module,
75 g_free(plugin_get_type);
77 DBG("Symbol couldn't be resolved");
78 g_module_close (plugin_module);
82 DBG("Creating plugin object");
83 GType (*plugin_get_type_f)(void) = p;
84 GSignondPlugin* plugin = g_object_new(plugin_get_type_f(), NULL);
86 DBG("Plugin couldn't be created");
87 g_module_close (plugin_module);
90 g_module_make_resident (plugin_module);