From b2ec7dd266b83a2b5c8eb2f6e6c94f3c32093da7 Mon Sep 17 00:00:00 2001 From: Peter Wehrfritz Date: Tue, 4 Sep 2007 18:23:47 +0000 Subject: [PATCH] *API BREAK* rename ecore_plugin_call() to ecore_plugin_symbol_get() add a version argument to ecore_plugin_load(); it makes it possible to have different versions for the interface. NULL gives you the old behaivor SVN revision: 31616 --- legacy/ecore/src/lib/ecore/Ecore_Data.h | 8 +++--- legacy/ecore/src/lib/ecore/ecore_path.c | 8 +++++- legacy/ecore/src/lib/ecore/ecore_plugin.c | 31 ++++++++++++++++++----- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/legacy/ecore/src/lib/ecore/Ecore_Data.h b/legacy/ecore/src/lib/ecore/Ecore_Data.h index 0c2671e032..7f272fae48 100644 --- a/legacy/ecore/src/lib/ecore/Ecore_Data.h +++ b/legacy/ecore/src/lib/ecore/Ecore_Data.h @@ -324,15 +324,13 @@ extern "C" { typedef struct _ecore_plugin Ecore_Plugin; struct _ecore_plugin { - int group; - char *name; void *handle; }; /* * Load the specified plugin */ - EAPI Ecore_Plugin *ecore_plugin_load(int group_id, const char *plugin); + EAPI Ecore_Plugin *ecore_plugin_load(int group_id, const char *plugin, const char *version); /* * Unload the specified plugin @@ -342,8 +340,8 @@ extern "C" { /* * Lookup the specified symbol for the plugin */ - EAPI void *ecore_plugin_call(Ecore_Plugin * plugin, const char *symbol_name); - + EAPI void *ecore_plugin_symbol_get(Ecore_Plugin * plugin, const char *symbol_name); + EAPI Ecore_List *ecore_plugin_available_get(int group_id); diff --git a/legacy/ecore/src/lib/ecore/ecore_path.c b/legacy/ecore/src/lib/ecore/ecore_path.c index 4326d326fa..b74415892d 100644 --- a/legacy/ecore/src/lib/ecore/ecore_path.c +++ b/legacy/ecore/src/lib/ecore/ecore_path.c @@ -331,7 +331,13 @@ ecore_plugin_available_get(int group_id) ext = strrchr(ppath, '.'); *ext = '\0'; - ecore_hash_set(plugins, strdup(ppath), (void *)1); + if (!ecore_hash_get(plugins, ppath)) + { + char *key; + + key = strdup(ppath); + ecore_hash_set(plugins, key, key); + } } } ecore_hash_free_key_cb_set(plugins, NULL); diff --git a/legacy/ecore/src/lib/ecore/ecore_plugin.c b/legacy/ecore/src/lib/ecore/ecore_plugin.c index e87ff3fcfc..66788ece83 100644 --- a/legacy/ecore/src/lib/ecore/ecore_plugin.c +++ b/legacy/ecore/src/lib/ecore/ecore_plugin.c @@ -1,3 +1,6 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ #ifndef _WIN32 # include # include "ecore_private.h" @@ -15,12 +18,14 @@ static Ecore_List *loaded_plugins = NULL; * Loads the specified plugin from the specified path group. * @param group_id The path group to search for the plugin to load * @param plugin_name The name of the plugin to load. + * @param version The interface version of the plugin. With version + * equal to NULL the default will be loaded. * @return A pointer to the newly loaded plugin on success, @c NULL on * failure. * @ingroup Ecore_Plugin */ EAPI Ecore_Plugin * -ecore_plugin_load(int group_id, const char *plugin_name) +ecore_plugin_load(int group_id, const char *plugin_name, const char *version) { char *path; char temp[PATH_MAX]; @@ -30,14 +35,28 @@ ecore_plugin_load(int group_id, const char *plugin_name) CHECK_PARAM_POINTER_RETURN("plugin_name", plugin_name, NULL); - snprintf(temp, PATH_MAX, "%s.so", plugin_name); + if (!version || *version == '\0') + snprintf(temp, sizeof(temp), "%s.so", plugin_name); + else + snprintf(temp, sizeof(temp), "%s.so.%s", plugin_name, version); + path = ecore_path_group_find(group_id, temp); + if (!path && version) + { + /* if this file doesn't exist try a different order */ + snprintf(temp, sizeof(temp), "%s.%s.so", plugin_name, version); + path = ecore_path_group_find(group_id, temp); + } + if (!path) return NULL; handle = dlopen(path, RTLD_LAZY); if (!handle) - return NULL; + { + FREE(path); + return NULL; + } /* * Allocate the new plugin and initialize it's fields @@ -46,12 +65,11 @@ ecore_plugin_load(int group_id, const char *plugin_name) if (!plugin) { dlclose(handle); + FREE(path); return NULL; } memset(plugin, 0, sizeof(Ecore_Plugin)); - plugin->group = group_id; - plugin->name = strdup(plugin_name); plugin->handle = handle; /* @@ -91,7 +109,6 @@ ecore_plugin_unload(Ecore_Plugin *plugin) dlclose(plugin->handle); - FREE(plugin->name); FREE(plugin); } @@ -103,7 +120,7 @@ ecore_plugin_unload(Ecore_Plugin *plugin) * @ingroup Ecore_Plugin */ EAPI void * -ecore_plugin_call(Ecore_Plugin *plugin, const char *symbol_name) +ecore_plugin_symbol_get(Ecore_Plugin *plugin, const char *symbol_name) { void *ret;