2006-08-03 12:26:08 -07:00
|
|
|
/*
|
|
|
|
* mooplugin-loader.c
|
|
|
|
*
|
2007-01-04 02:41:30 -08:00
|
|
|
* Copyright (C) 2004-2007 by Yevgen Muntyan <muntyan@math.tamu.edu>
|
2006-08-03 12:26:08 -07:00
|
|
|
*
|
2007-06-24 10:56:20 -07:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
2007-09-23 09:47:28 -07:00
|
|
|
* License version 2.1 as published by the Free Software Foundation.
|
2006-08-03 12:26:08 -07:00
|
|
|
*
|
|
|
|
* See COPYING file that comes with this distribution.
|
|
|
|
*/
|
|
|
|
|
2006-11-23 19:18:25 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2006-08-03 12:26:08 -07:00
|
|
|
#include "mooedit/mooplugin-loader.h"
|
|
|
|
#include "mooedit/mooplugin.h"
|
|
|
|
#include "mooutils/mooutils-misc.h"
|
2007-08-20 20:15:58 -07:00
|
|
|
#include "mooutils/mooutils-debug.h"
|
2006-08-03 12:26:08 -07:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <gmodule.h>
|
|
|
|
|
|
|
|
#ifdef __WIN32__
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define GROUP_MODULE "module"
|
|
|
|
#define GROUP_PLUGIN "plugin"
|
|
|
|
#define KEY_LOADER "type"
|
|
|
|
#define KEY_FILE "file"
|
|
|
|
#define KEY_ID "id"
|
|
|
|
#define KEY_NAME "name"
|
|
|
|
#define KEY_DESCRIPTION "description"
|
|
|
|
#define KEY_AUTHOR "author"
|
|
|
|
#define KEY_VERSION "version"
|
|
|
|
#define KEY_LANGS "langs"
|
|
|
|
#define KEY_ENABLED "enabled"
|
|
|
|
#define KEY_VISIBLE "visible"
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2006-08-04 02:17:32 -07:00
|
|
|
char *ini_file;
|
2006-08-03 12:26:08 -07:00
|
|
|
char *loader;
|
|
|
|
char *file;
|
|
|
|
char *plugin_id;
|
|
|
|
MooPluginInfo *plugin_info;
|
|
|
|
MooPluginParams *plugin_params;
|
|
|
|
} ModuleInfo;
|
|
|
|
|
|
|
|
|
|
|
|
static GHashTable *registered_loaders;
|
2006-08-04 02:17:32 -07:00
|
|
|
static GSList *waiting_list;
|
2006-08-03 12:26:08 -07:00
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
static void init_loaders (void);
|
|
|
|
GType _moo_c_plugin_loader_get_type (void);
|
|
|
|
static void module_info_free (ModuleInfo *info);
|
2006-08-03 12:26:08 -07:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
2006-08-04 02:17:32 -07:00
|
|
|
moo_plugin_loader_load (const MooPluginLoader *loader,
|
|
|
|
ModuleInfo *module_info)
|
2006-08-03 12:26:08 -07:00
|
|
|
{
|
2006-08-04 02:17:32 -07:00
|
|
|
if (module_info->plugin_id)
|
|
|
|
{
|
|
|
|
g_return_if_fail (loader->load_plugin != NULL);
|
|
|
|
loader->load_plugin (module_info->file,
|
|
|
|
module_info->plugin_id,
|
|
|
|
module_info->plugin_info,
|
|
|
|
module_info->plugin_params,
|
|
|
|
module_info->ini_file,
|
|
|
|
loader->data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_return_if_fail (loader->load_module != NULL);
|
|
|
|
loader->load_module (module_info->file,
|
|
|
|
module_info->ini_file,
|
|
|
|
loader->data);
|
|
|
|
}
|
2006-08-03 12:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
MooPluginLoader *
|
2006-08-03 12:26:08 -07:00
|
|
|
moo_plugin_loader_lookup (const char *id)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (id != NULL, NULL);
|
2006-08-04 02:17:32 -07:00
|
|
|
|
|
|
|
if (registered_loaders)
|
|
|
|
return g_hash_table_lookup (registered_loaders, id);
|
|
|
|
else
|
|
|
|
return NULL;
|
2006-08-03 12:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2006-08-04 02:17:32 -07:00
|
|
|
moo_plugin_loader_add (const MooPluginLoader *loader,
|
|
|
|
const char *type)
|
2006-08-03 12:26:08 -07:00
|
|
|
{
|
2006-08-04 02:17:32 -07:00
|
|
|
MooPluginLoader *copy;
|
|
|
|
|
|
|
|
g_return_if_fail (loader != NULL);
|
2006-08-03 12:26:08 -07:00
|
|
|
g_return_if_fail (type != NULL);
|
|
|
|
g_return_if_fail (registered_loaders != NULL);
|
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
copy = g_memdup (loader, sizeof (MooPluginLoader));
|
|
|
|
g_hash_table_insert (registered_loaders, g_strdup (type), copy);
|
2006-08-03 12:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2006-08-04 02:17:32 -07:00
|
|
|
moo_plugin_loader_register (const MooPluginLoader *loader,
|
|
|
|
const char *type)
|
2006-08-03 12:26:08 -07:00
|
|
|
{
|
2006-08-04 02:17:32 -07:00
|
|
|
GSList *open_now = NULL, *hold = NULL;
|
|
|
|
GSList *l;
|
|
|
|
|
|
|
|
g_return_if_fail (loader != NULL);
|
2006-08-03 12:26:08 -07:00
|
|
|
g_return_if_fail (type != NULL);
|
2006-08-04 02:17:32 -07:00
|
|
|
|
2006-08-03 12:26:08 -07:00
|
|
|
init_loaders ();
|
2006-08-04 02:17:32 -07:00
|
|
|
g_return_if_fail (!g_hash_table_lookup (registered_loaders, type));
|
|
|
|
|
2006-08-03 12:26:08 -07:00
|
|
|
moo_plugin_loader_add (loader, type);
|
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
for (l = waiting_list; l != NULL; l = l->next)
|
|
|
|
{
|
|
|
|
ModuleInfo *info = l->data;
|
2006-08-03 12:26:08 -07:00
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
if (!strcmp (info->loader, type))
|
|
|
|
open_now = g_slist_prepend (open_now, info);
|
|
|
|
else
|
|
|
|
hold = g_slist_prepend (hold, info);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (open_now)
|
2006-08-03 12:26:08 -07:00
|
|
|
{
|
2006-08-04 02:17:32 -07:00
|
|
|
open_now = g_slist_reverse (open_now);
|
|
|
|
g_slist_free (waiting_list);
|
|
|
|
waiting_list = g_slist_reverse (hold);
|
2006-08-03 12:26:08 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-08-04 02:17:32 -07:00
|
|
|
g_slist_free (hold);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (open_now)
|
|
|
|
{
|
|
|
|
moo_plugin_loader_load (loader, open_now->data);
|
|
|
|
module_info_free (open_now->data);
|
|
|
|
open_now = g_slist_delete_link (open_now, open_now);
|
2006-08-03 12:26:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
parse_plugin_info (GKeyFile *key_file,
|
|
|
|
const char *plugin_id,
|
|
|
|
MooPluginInfo **info_p,
|
|
|
|
MooPluginParams **params_p)
|
|
|
|
{
|
|
|
|
MooPluginInfo *info;
|
|
|
|
MooPluginParams *params;
|
|
|
|
char *name;
|
|
|
|
char *description;
|
|
|
|
char *author;
|
|
|
|
char *version;
|
|
|
|
char *langs;
|
|
|
|
gboolean enabled = TRUE;
|
|
|
|
gboolean visible = TRUE;
|
|
|
|
|
2006-08-03 20:40:19 -07:00
|
|
|
name = g_key_file_get_locale_string (key_file, GROUP_PLUGIN, KEY_NAME, NULL, NULL);
|
|
|
|
description = g_key_file_get_locale_string (key_file, GROUP_PLUGIN, KEY_DESCRIPTION, NULL, NULL);
|
|
|
|
author = g_key_file_get_locale_string (key_file, GROUP_PLUGIN, KEY_AUTHOR, NULL, NULL);
|
|
|
|
version = g_key_file_get_locale_string (key_file, GROUP_PLUGIN, KEY_VERSION, NULL, NULL);
|
2006-08-03 12:26:08 -07:00
|
|
|
langs = g_key_file_get_string (key_file, GROUP_PLUGIN, KEY_LANGS, NULL);
|
|
|
|
|
|
|
|
if (g_key_file_has_key (key_file, GROUP_PLUGIN, KEY_ENABLED, NULL))
|
|
|
|
enabled = g_key_file_get_boolean (key_file, GROUP_PLUGIN, KEY_ENABLED, NULL);
|
|
|
|
if (g_key_file_has_key (key_file, GROUP_PLUGIN, KEY_VISIBLE, NULL))
|
|
|
|
visible = g_key_file_get_boolean (key_file, GROUP_PLUGIN, KEY_VISIBLE, NULL);
|
|
|
|
|
|
|
|
info = moo_plugin_info_new (name ? name : plugin_id,
|
|
|
|
description ? description : "",
|
|
|
|
author ? author : "",
|
|
|
|
version ? version : "",
|
|
|
|
langs);
|
|
|
|
params = moo_plugin_params_new (enabled, visible);
|
|
|
|
|
|
|
|
*info_p = info;
|
|
|
|
*params_p = params;
|
|
|
|
|
|
|
|
g_free (name);
|
|
|
|
g_free (description);
|
|
|
|
g_free (author);
|
|
|
|
g_free (version);
|
|
|
|
g_free (langs);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
check_version (const char *version,
|
|
|
|
const char *ini_file_path)
|
|
|
|
{
|
|
|
|
char *dot;
|
|
|
|
char *end = NULL;
|
|
|
|
long major, minor;
|
|
|
|
|
|
|
|
dot = strchr (version, '.');
|
|
|
|
|
|
|
|
if (!dot || dot == version)
|
|
|
|
goto invalid;
|
|
|
|
|
|
|
|
major = strtol (version, &end, 10);
|
|
|
|
|
|
|
|
if (end != dot)
|
|
|
|
goto invalid;
|
|
|
|
|
|
|
|
minor = strtol (dot + 1, &end, 10);
|
|
|
|
|
|
|
|
if (*end != 0)
|
|
|
|
goto invalid;
|
|
|
|
|
2006-12-04 23:30:20 -08:00
|
|
|
if (!moo_module_check_version (major, minor))
|
2006-08-03 12:26:08 -07:00
|
|
|
{
|
2006-12-04 23:30:20 -08:00
|
|
|
guint current_major, current_minor;
|
|
|
|
_moo_module_version (¤t_major, ¤t_minor);
|
|
|
|
g_warning ("module version '%s' in file '%s' is not "
|
|
|
|
"compatible with current version %u.%u",
|
|
|
|
version, ini_file_path, current_major, current_minor);
|
2006-08-03 12:26:08 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
invalid:
|
|
|
|
g_warning ("invalid module version '%s' in file '%s'",
|
|
|
|
version, ini_file_path);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
static ModuleInfo *
|
|
|
|
parse_ini_file (const char *dir,
|
|
|
|
const char *ini_file)
|
2006-08-03 12:26:08 -07:00
|
|
|
{
|
|
|
|
GKeyFile *key_file;
|
|
|
|
GError *error = NULL;
|
|
|
|
char *ini_file_path;
|
|
|
|
char *file = NULL, *loader = NULL, *id = NULL, *version = NULL;
|
|
|
|
MooPluginInfo *info = NULL;
|
|
|
|
MooPluginParams *params = NULL;
|
2006-08-04 02:17:32 -07:00
|
|
|
ModuleInfo *module_info = NULL;
|
2006-08-03 12:26:08 -07:00
|
|
|
|
|
|
|
ini_file_path = g_build_filename (dir, ini_file, NULL);
|
|
|
|
key_file = g_key_file_new ();
|
|
|
|
|
|
|
|
if (!g_key_file_load_from_file (key_file, ini_file_path, 0, &error))
|
|
|
|
{
|
|
|
|
g_warning ("error parsing plugin ini file '%s': %s", ini_file_path, error->message);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!g_key_file_has_group (key_file, GROUP_MODULE))
|
|
|
|
{
|
|
|
|
g_warning ("plugin ini file '%s' does not have '" GROUP_MODULE "' group", ini_file_path);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(version = g_key_file_get_string (key_file, GROUP_MODULE, KEY_VERSION, &error)))
|
|
|
|
{
|
|
|
|
g_warning ("plugin ini file '%s' does not specify version of module system", ini_file_path);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!check_version (version, ini_file_path))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (!(loader = g_key_file_get_string (key_file, GROUP_MODULE, KEY_LOADER, &error)))
|
|
|
|
{
|
|
|
|
g_warning ("plugin ini file '%s' does not specify module type", ini_file_path);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(file = g_key_file_get_string (key_file, GROUP_MODULE, KEY_FILE, &error)))
|
|
|
|
{
|
|
|
|
g_warning ("plugin ini file '%s' does not specify module file", ini_file_path);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!g_path_is_absolute (file))
|
|
|
|
{
|
|
|
|
char *tmp = file;
|
|
|
|
file = g_build_filename (dir, file, NULL);
|
|
|
|
g_free (tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_key_file_has_group (key_file, GROUP_PLUGIN))
|
|
|
|
{
|
|
|
|
if (!(id = g_key_file_get_string (key_file, GROUP_PLUGIN, KEY_ID, NULL)))
|
|
|
|
{
|
|
|
|
g_warning ("plugin ini file '%s' does not specify plugin id", ini_file_path);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!parse_plugin_info (key_file, id, &info, ¶ms))
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
module_info = g_new0 (ModuleInfo, 1);
|
2006-08-03 12:26:08 -07:00
|
|
|
module_info->loader = loader;
|
|
|
|
module_info->file = g_build_path (dir, file, NULL);
|
|
|
|
module_info->plugin_id = id;
|
|
|
|
module_info->plugin_info = info;
|
|
|
|
module_info->plugin_params = params;
|
2006-08-04 02:17:32 -07:00
|
|
|
module_info->ini_file = ini_file_path;
|
|
|
|
ini_file_path = NULL;
|
2006-08-03 12:26:08 -07:00
|
|
|
|
|
|
|
out:
|
|
|
|
if (error)
|
|
|
|
g_error_free (error);
|
|
|
|
g_free (ini_file_path);
|
|
|
|
g_key_file_free (key_file);
|
|
|
|
g_free (file);
|
|
|
|
g_free (version);
|
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
if (!module_info)
|
2006-08-03 12:26:08 -07:00
|
|
|
{
|
|
|
|
g_free (loader);
|
|
|
|
g_free (id);
|
|
|
|
moo_plugin_info_free (info);
|
|
|
|
moo_plugin_params_free (params);
|
|
|
|
}
|
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
return module_info;
|
2006-08-03 12:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2006-08-04 02:17:32 -07:00
|
|
|
module_info_free (ModuleInfo *module_info)
|
2006-08-03 12:26:08 -07:00
|
|
|
{
|
2006-08-04 02:17:32 -07:00
|
|
|
g_free (module_info->ini_file);
|
2006-08-03 12:26:08 -07:00
|
|
|
g_free (module_info->loader);
|
|
|
|
g_free (module_info->file);
|
|
|
|
g_free (module_info->plugin_id);
|
|
|
|
moo_plugin_info_free (module_info->plugin_info);
|
|
|
|
moo_plugin_params_free (module_info->plugin_params);
|
2006-08-04 02:17:32 -07:00
|
|
|
g_free (module_info);
|
2006-08-03 12:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
_moo_plugin_load (const char *dir,
|
|
|
|
const char *ini_file)
|
|
|
|
{
|
2006-08-04 02:17:32 -07:00
|
|
|
ModuleInfo *module_info;
|
2006-08-03 12:26:08 -07:00
|
|
|
MooPluginLoader *loader;
|
|
|
|
|
|
|
|
g_return_if_fail (dir != NULL && ini_file != NULL);
|
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
init_loaders ();
|
|
|
|
|
|
|
|
module_info = parse_ini_file (dir, ini_file);
|
|
|
|
|
2007-02-27 20:31:35 -08:00
|
|
|
if (module_info)
|
2006-08-03 12:26:08 -07:00
|
|
|
{
|
2007-02-27 20:31:35 -08:00
|
|
|
loader = moo_plugin_loader_lookup (module_info->loader);
|
2006-08-03 12:26:08 -07:00
|
|
|
|
2007-02-27 20:31:35 -08:00
|
|
|
if (!loader)
|
|
|
|
{
|
|
|
|
waiting_list = g_slist_append (waiting_list, module_info);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
moo_plugin_loader_load (loader, module_info);
|
|
|
|
module_info_free (module_info);
|
|
|
|
}
|
|
|
|
}
|
2006-08-04 02:17:32 -07:00
|
|
|
}
|
2006-08-03 12:26:08 -07:00
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
_moo_plugin_finish_load (void)
|
|
|
|
{
|
|
|
|
while (waiting_list)
|
|
|
|
{
|
|
|
|
ModuleInfo *info = waiting_list->data;
|
2006-11-01 22:38:00 -08:00
|
|
|
_moo_message ("unknown module type '%s' in file %s",
|
|
|
|
info->loader, info->ini_file);
|
2006-08-04 02:17:32 -07:00
|
|
|
module_info_free (info);
|
|
|
|
waiting_list = g_slist_delete_link (waiting_list, waiting_list);
|
|
|
|
}
|
2006-08-03 12:26:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GModule *
|
|
|
|
module_open (const char *path)
|
|
|
|
{
|
|
|
|
GModule *module;
|
|
|
|
|
2006-11-23 21:08:22 -08:00
|
|
|
moo_disable_win32_error_message ();
|
2006-08-04 02:17:32 -07:00
|
|
|
module = g_module_open (path, G_MODULE_BIND_LAZY);
|
2006-11-23 21:08:22 -08:00
|
|
|
moo_enable_win32_error_message ();
|
2006-08-03 12:26:08 -07:00
|
|
|
|
|
|
|
if (!module)
|
|
|
|
g_warning ("could not open module '%s': %s", path, g_module_error ());
|
|
|
|
|
|
|
|
return module;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2006-08-04 02:17:32 -07:00
|
|
|
load_c_module (const char *module_file,
|
|
|
|
G_GNUC_UNUSED const char *ini_file,
|
|
|
|
G_GNUC_UNUSED gpointer data)
|
2006-08-03 12:26:08 -07:00
|
|
|
{
|
2007-01-04 02:41:30 -08:00
|
|
|
gpointer init_func_ptr;
|
2007-10-08 07:08:32 -07:00
|
|
|
MooModuleInitFunc init_func;
|
2006-08-03 12:26:08 -07:00
|
|
|
GModule *module;
|
|
|
|
|
|
|
|
module = module_open (module_file);
|
|
|
|
|
|
|
|
if (!module)
|
|
|
|
return;
|
|
|
|
|
2007-01-04 02:41:30 -08:00
|
|
|
if (g_module_symbol (module, MOO_MODULE_INIT_FUNC_NAME, &init_func_ptr) &&
|
|
|
|
(init_func = init_func_ptr) && init_func ())
|
2006-08-03 12:26:08 -07:00
|
|
|
{
|
|
|
|
g_module_make_resident (module);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_module_close (module);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2006-08-04 02:17:32 -07:00
|
|
|
load_c_plugin (const char *plugin_file,
|
2006-08-03 12:26:08 -07:00
|
|
|
const char *plugin_id,
|
|
|
|
MooPluginInfo *info,
|
|
|
|
MooPluginParams *params,
|
2006-08-04 02:17:32 -07:00
|
|
|
G_GNUC_UNUSED const char *ini_file,
|
|
|
|
G_GNUC_UNUSED gpointer data)
|
2006-08-03 12:26:08 -07:00
|
|
|
{
|
2007-01-04 02:41:30 -08:00
|
|
|
gpointer init_func_ptr;
|
2006-08-03 12:26:08 -07:00
|
|
|
MooPluginModuleInitFunc init_func;
|
|
|
|
GModule *module;
|
|
|
|
GType type = 0;
|
|
|
|
|
|
|
|
module = module_open (plugin_file);
|
|
|
|
|
|
|
|
if (!module)
|
|
|
|
return;
|
|
|
|
|
2007-01-04 02:41:30 -08:00
|
|
|
if (!g_module_symbol (module, MOO_PLUGIN_INIT_FUNC_NAME, &init_func_ptr) ||
|
|
|
|
!(init_func = init_func_ptr) ||
|
|
|
|
!init_func (&type))
|
2006-08-03 12:26:08 -07:00
|
|
|
{
|
|
|
|
g_module_close (module);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_return_if_fail (g_type_is_a (type, MOO_TYPE_PLUGIN));
|
|
|
|
|
|
|
|
if (!moo_plugin_register (plugin_id, type, info, params))
|
|
|
|
{
|
|
|
|
g_module_close (module);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_module_make_resident (module);
|
|
|
|
g_module_close (module);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
init_loaders (void)
|
|
|
|
{
|
2006-08-04 02:17:32 -07:00
|
|
|
MooPluginLoader loader = {load_c_module, load_c_plugin, NULL};
|
2006-08-03 12:26:08 -07:00
|
|
|
|
|
|
|
if (registered_loaders)
|
|
|
|
return;
|
|
|
|
|
|
|
|
registered_loaders = g_hash_table_new_full (g_str_hash, g_str_equal,
|
2006-08-04 02:17:32 -07:00
|
|
|
g_free, g_free);
|
2006-08-03 12:26:08 -07:00
|
|
|
|
2006-08-04 02:17:32 -07:00
|
|
|
moo_plugin_loader_add (&loader, "C");
|
2006-08-03 12:26:08 -07:00
|
|
|
}
|