forked from enlightenment/efl
move ecore_plugin_available_get() to ecore_plugin.c
SVN revision: 34697
This commit is contained in:
parent
0fe68f24fc
commit
14042818cc
|
@ -211,84 +211,3 @@ ecore_path_group_available(Ecore_Path_Group *group)
|
|||
return avail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of all available plugins in the given path.
|
||||
* @param group_id The identifier for the given path.
|
||||
* @return A pointer to a newly allocated list of all plugins found in the
|
||||
* paths identified by @p group_id. @c NULL otherwise.
|
||||
* @ingroup Ecore_Plugin
|
||||
*/
|
||||
EAPI Ecore_List *
|
||||
ecore_plugin_available_get(Ecore_Path_Group *group)
|
||||
{
|
||||
Ecore_List *avail = NULL;
|
||||
Ecore_Hash *plugins = NULL;
|
||||
char *path;
|
||||
|
||||
CHECK_PARAM_POINTER_RETURN("group", group, NULL);
|
||||
|
||||
if (!group->paths || ecore_list_empty_is(group->paths))
|
||||
return NULL;
|
||||
|
||||
ecore_list_first_goto(group->paths);
|
||||
plugins = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(plugins, free);
|
||||
|
||||
while ((path = ecore_list_next(group->paths)) != NULL)
|
||||
{
|
||||
DIR *dir;
|
||||
struct stat st;
|
||||
struct dirent *d;
|
||||
|
||||
if (stat(path, &st) < 0)
|
||||
continue;
|
||||
|
||||
if (!S_ISDIR(st.st_mode))
|
||||
continue;
|
||||
|
||||
dir = opendir(path);
|
||||
|
||||
if (!dir)
|
||||
continue;
|
||||
|
||||
while ((d = readdir(dir)) != NULL)
|
||||
{
|
||||
char ppath[PATH_MAX];
|
||||
char *ext;
|
||||
|
||||
if (*d->d_name == '.')
|
||||
continue;
|
||||
|
||||
if (!ecore_str_has_suffix(d->d_name, SHARED_LIB_SUFFIX))
|
||||
continue;
|
||||
|
||||
snprintf(ppath, PATH_MAX, "%s/%s", path, d->d_name);
|
||||
|
||||
stat(ppath, &st);
|
||||
|
||||
if (!S_ISREG(st.st_mode))
|
||||
continue;
|
||||
|
||||
ecore_strlcpy(ppath, d->d_name, sizeof(ppath));
|
||||
ext = strrchr(ppath, '.');
|
||||
*ext = '\0';
|
||||
|
||||
if (!ecore_hash_get(plugins, ppath))
|
||||
{
|
||||
char *key;
|
||||
|
||||
key = strdup(ppath);
|
||||
ecore_hash_set(plugins, key, key);
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
ecore_hash_free_key_cb_set(plugins, NULL);
|
||||
avail = ecore_hash_keys(plugins);
|
||||
ecore_list_free_cb_set(avail, free);
|
||||
ecore_hash_destroy(plugins);
|
||||
|
||||
return avail;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,3 +150,85 @@ ecore_plugin_symbol_get(Ecore_Plugin *plugin, const char *symbol_name)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of all available plugins in the given path.
|
||||
* @param group_id The identifier for the given path.
|
||||
* @return A pointer to a newly allocated list of all plugins found in the
|
||||
* paths identified by @p group_id. @c NULL otherwise.
|
||||
* @ingroup Ecore_Plugin
|
||||
*/
|
||||
EAPI Ecore_List *
|
||||
ecore_plugin_available_get(Ecore_Path_Group *group)
|
||||
{
|
||||
Ecore_List *avail = NULL;
|
||||
Ecore_Hash *plugins = NULL;
|
||||
char *path;
|
||||
|
||||
CHECK_PARAM_POINTER_RETURN("group", group, NULL);
|
||||
|
||||
if (!group->paths || ecore_list_empty_is(group->paths))
|
||||
return NULL;
|
||||
|
||||
ecore_list_first_goto(group->paths);
|
||||
plugins = ecore_hash_new(ecore_str_hash, ecore_str_compare);
|
||||
ecore_hash_free_key_cb_set(plugins, free);
|
||||
|
||||
while ((path = ecore_list_next(group->paths)) != NULL)
|
||||
{
|
||||
DIR *dir;
|
||||
struct stat st;
|
||||
struct dirent *d;
|
||||
|
||||
if (stat(path, &st) < 0)
|
||||
continue;
|
||||
|
||||
if (!S_ISDIR(st.st_mode))
|
||||
continue;
|
||||
|
||||
dir = opendir(path);
|
||||
|
||||
if (!dir)
|
||||
continue;
|
||||
|
||||
while ((d = readdir(dir)) != NULL)
|
||||
{
|
||||
char ppath[PATH_MAX];
|
||||
char *ext;
|
||||
|
||||
if (*d->d_name == '.')
|
||||
continue;
|
||||
|
||||
if (!ecore_str_has_suffix(d->d_name, SHARED_LIB_SUFFIX))
|
||||
continue;
|
||||
|
||||
snprintf(ppath, PATH_MAX, "%s/%s", path, d->d_name);
|
||||
|
||||
stat(ppath, &st);
|
||||
|
||||
if (!S_ISREG(st.st_mode))
|
||||
continue;
|
||||
|
||||
ecore_strlcpy(ppath, d->d_name, sizeof(ppath));
|
||||
ext = strrchr(ppath, '.');
|
||||
*ext = '\0';
|
||||
|
||||
if (!ecore_hash_get(plugins, ppath))
|
||||
{
|
||||
char *key;
|
||||
|
||||
key = strdup(ppath);
|
||||
ecore_hash_set(plugins, key, key);
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
ecore_hash_free_key_cb_set(plugins, NULL);
|
||||
avail = ecore_hash_keys(plugins);
|
||||
ecore_list_free_cb_set(avail, free);
|
||||
ecore_hash_destroy(plugins);
|
||||
|
||||
return avail;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue