*API CHANGE*

- Use Ecore_Path_Group instead of the group id
- remove the name


SVN revision: 32410
This commit is contained in:
Peter Wehrfritz 2007-11-06 16:58:12 +00:00
parent b8c6905eb0
commit a64803dea8
3 changed files with 42 additions and 135 deletions

View File

@ -285,37 +285,37 @@ extern "C" {
typedef struct _ecore_path_group Ecore_Path_Group;
# define ECORE_PATH_GROUP(group) ((Ecore_Path_Group *)(group))
struct _ecore_path_group
{
int id;
char *name;
Ecore_List *paths;
};
/*
* Create a new path group
*/
EAPI int ecore_path_group_new(const char *group_name);
EAPI Ecore_Path_Group *ecore_path_group_new(void);
/*
* Destroy a previous path group
*/
EAPI void ecore_path_group_del(int group_id);
EAPI void ecore_path_group_del(Ecore_Path_Group *group);
/*
* Add a directory to be searched for files
*/
EAPI void ecore_path_group_add(int group_id, const char *path);
EAPI void ecore_path_group_add(Ecore_Path_Group *group, const char *path);
/*
* Remove a directory to be searched for files
*/
EAPI void ecore_path_group_remove(int group_id, const char *path);
EAPI void ecore_path_group_remove(Ecore_Path_Group *group, const char *path);
/*
* Find the absolute path if it exists in the group of paths
*/
EAPI char * ecore_path_group_find(int group_id, const char *name);
EAPI char * ecore_path_group_find(Ecore_Path_Group *group, const char *name);
/*
* Get a list of all the available files in a path set
@ -332,7 +332,7 @@ extern "C" {
/*
* Load the specified plugin
*/
EAPI Ecore_Plugin *ecore_plugin_load(int group_id, const char *plugin, const char *version);
EAPI Ecore_Plugin *ecore_plugin_load(Ecore_Path_Group *group, const char *plugin, const char *version);
/*
* Unload the specified plugin
@ -344,7 +344,7 @@ extern "C" {
*/
EAPI void *ecore_plugin_symbol_get(Ecore_Plugin * plugin, const char *symbol_name);
EAPI Ecore_List *ecore_plugin_available_get(int group_id);
EAPI Ecore_List *ecore_plugin_available_get(Ecore_Path_Group *group);
typedef struct _ecore_heap Ecore_Sheap;

View File

@ -5,11 +5,6 @@
#include "Ecore_Data.h"
#include "Ecore_Str.h"
static Ecore_List *group_list = NULL;
Ecore_Path_Group *__ecore_path_group_find(const char *name);
Ecore_Path_Group *__ecore_path_group_find_id(int id);
/**
* @defgroup Ecore_Path_Group Path Group Functions
*
@ -24,118 +19,69 @@ Ecore_Path_Group *__ecore_path_group_find_id(int id);
* @return @c 0 on error, the integer id of the new group on success.
* @ingroup Ecore_Path_Group
*/
EAPI int
ecore_path_group_new(const char *group_name)
EAPI Ecore_Path_Group *
ecore_path_group_new(void)
{
int lastid;
Ecore_Path_Group *group;
CHECK_PARAM_POINTER_RETURN("group_name", group_name, -1);
if (!group_list)
{
group_list = ecore_list_new();
if (!group_list) return 0;
lastid = 0;
}
else
{
Ecore_Path_Group *last;
group = __ecore_path_group_find(group_name);
if (group)
return 0;
last = ecore_list_last_goto(group_list);
lastid = last->id;
}
group = (Ecore_Path_Group *)malloc(sizeof(Ecore_Path_Group));
memset(group, 0, sizeof(Ecore_Path_Group));
group->name = strdup(group_name);
group->id = lastid + 1;
ecore_list_append(group_list, group);
return group->id;
return group;
}
/**
* Destroys a previously created path group
* @param group_id The unique identifier for the group.
* @param group The group to delete.
* @ingroup Ecore_Path_Group
*/
EAPI void
ecore_path_group_del(int group_id)
ecore_path_group_del(Ecore_Path_Group *group)
{
Ecore_Path_Group *group;
group = __ecore_path_group_find_id(group_id);
if (!group)
return;
CHECK_PARAM_POINTER("group", group);
if (group->paths)
{
ecore_list_for_each(group->paths, ECORE_FOR_EACH(free), NULL);
ecore_list_destroy(group->paths);
}
ecore_list_destroy(group->paths);
if (ecore_list_goto(group_list, group))
ecore_list_remove(group_list);
if (ecore_list_empty_is(group_list))
{
ecore_list_destroy(group_list);
group_list = NULL;
}
free(group->name);
free(group);
}
/**
* Adds a directory to be searched for files.
* @param group_id The unique identifier for the group to add the path.
* @param group The group to add the path.
* @param path The new path to be added to the group.
* @ingroup Ecore_Path_Group
*/
EAPI void
ecore_path_group_add(int group_id, const char *path)
ecore_path_group_add(Ecore_Path_Group *group, const char *path)
{
Ecore_Path_Group *group;
CHECK_PARAM_POINTER("group", group);
CHECK_PARAM_POINTER("path", path);
group = __ecore_path_group_find_id(group_id);
if (!group)
return;
if (!group->paths)
group->paths = ecore_list_new();
{
group->paths = ecore_list_new();
ecore_list_free_cb_set(group->paths, free);
}
ecore_list_append(group->paths, strdup(path));
}
/**
* Removes the given directory from the given group.
* @param group_id The identifier for the given group.
* @param group The group to remove the path from.
* @param path The path of the directory to be removed.
* @ingroup Ecore_Path_Group
*/
EAPI void
ecore_path_group_remove(int group_id, const char *path)
ecore_path_group_remove(Ecore_Path_Group *group, const char *path)
{
char *found;
Ecore_Path_Group *group;
CHECK_PARAM_POINTER("group", group);
CHECK_PARAM_POINTER("path", path);
group = __ecore_path_group_find_id(group_id);
if (!group || !group->paths)
if (!group->paths)
return;
/*
@ -150,33 +96,29 @@ ecore_path_group_remove(int group_id, const char *path)
* If the path is found, remove and free it
*/
if (found)
{
ecore_list_remove(group->paths);
free(found);
}
ecore_list_remove_destroy(group->paths);
}
/**
* Finds a file in a group of paths.
* @param group_id The path group id to search.
* @param group The group to search.
* @param name The name of the file to find.
* @return A pointer to a newly allocated path location of the found file
* on success. @c NULL on failure.
* @ingroup Ecore_Path_Group
*/
EAPI char *
ecore_path_group_find(int group_id, const char *name)
ecore_path_group_find(Ecore_Path_Group *group, const char *name)
{
int r;
char *p;
struct stat st;
char path[PATH_MAX];
Ecore_Path_Group *group;
CHECK_PARAM_POINTER_RETURN("group", group, NULL);
CHECK_PARAM_POINTER_RETURN("name", name, NULL);
group = __ecore_path_group_find_id(group_id);
if (!group)
if (!group->paths)
return NULL;
/*
@ -209,10 +151,10 @@ EAPI Ecore_List *
ecore_path_group_available(int group_id)
{
Ecore_List *avail = NULL;
Ecore_Path_Group *group;
Ecore_Path_Group *group = NULL;
char *path;
group = __ecore_path_group_find_id(group_id);
//group = __ecore_path_group_find_id(group_id);
if (!group || !group->paths || ecore_list_empty_is(group->paths))
return NULL;
@ -284,16 +226,15 @@ ecore_path_group_available(int group_id)
* @ingroup Ecore_Plugin
*/
EAPI Ecore_List *
ecore_plugin_available_get(int group_id)
ecore_plugin_available_get(Ecore_Path_Group *group)
{
Ecore_List *avail = NULL;
Ecore_Hash *plugins = NULL;
Ecore_Path_Group *group;
char *path;
group = __ecore_path_group_find_id(group_id);
CHECK_PARAM_POINTER_RETURN("group", group, NULL);
if (!group || !group->paths || ecore_list_empty_is(group->paths))
if (!group->paths || ecore_list_empty_is(group->paths))
return NULL;
ecore_list_first_goto(group->paths);
@ -360,38 +301,4 @@ ecore_plugin_available_get(int group_id)
return avail;
}
/*
* Find the specified group name
*/
Ecore_Path_Group *
__ecore_path_group_find(const char *name)
{
Ecore_Path_Group *group;
CHECK_PARAM_POINTER_RETURN("name", name, NULL);
ecore_list_first_goto(group_list);
while ((group = ecore_list_next(group_list)) != NULL)
if (!strcmp(group->name, name))
return group;
return NULL;
}
/*
* Find the specified group id
*/
Ecore_Path_Group *
__ecore_path_group_find_id(int id)
{
Ecore_Path_Group *group;
ecore_list_first_goto(group_list);
while ((group = ecore_list_next(group_list)) != NULL)
if (group->id == id)
return group;
return NULL;
}

View File

@ -99,7 +99,7 @@ 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 group 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.
@ -108,7 +108,7 @@ static Ecore_List *loaded_plugins = NULL;
* @ingroup Ecore_Plugin
*/
EAPI Ecore_Plugin *
ecore_plugin_load(int group_id, const char *plugin_name, const char *version)
ecore_plugin_load(Ecore_Path_Group *group, const char *plugin_name, const char *version)
{
char *path;
char temp[PATH_MAX];
@ -130,14 +130,14 @@ ecore_plugin_load(int group_id, const char *plugin_name, const char *version)
snprintf(temp, sizeof(temp), "%s-%s.dll", plugin_name, version);
#endif /* _WIN32 */
path = ecore_path_group_find(group_id, temp);
path = ecore_path_group_find(group, temp);
#ifndef _WIN32
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);
path = ecore_path_group_find(group, temp);
}
#endif /* _WIN32 */