2008-08-06 11:15:24 -07:00
|
|
|
/* EINA - EFL data type library
|
2008-09-01 05:42:16 -07:00
|
|
|
* Copyright (C) 2007-2008 Jorge Luis Zapata Muga, Cedric BAIL
|
2008-08-06 11:15:24 -07:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library;
|
|
|
|
* if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-08-18 01:18:16 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2008-11-01 08:39:53 -07:00
|
|
|
#ifdef HAVE_DLADDR
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#endif
|
|
|
|
|
2008-08-28 00:46:42 -07:00
|
|
|
#include <stdio.h>
|
2008-08-27 23:49:04 -07:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <string.h>
|
2008-11-01 08:39:53 -07:00
|
|
|
|
2009-01-20 00:29:41 -08:00
|
|
|
#ifdef HAVE_ALLOCA_H
|
|
|
|
# include <alloca.h>
|
|
|
|
#elif defined __GNUC__
|
|
|
|
# define alloca __builtin_alloca
|
|
|
|
#elif defined _AIX
|
|
|
|
# define alloca __alloca
|
|
|
|
#elif defined _MSC_VER
|
|
|
|
# include <malloc.h>
|
|
|
|
# define alloca _alloca
|
|
|
|
#else
|
|
|
|
# include <stddef.h>
|
|
|
|
# ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
# endif
|
|
|
|
void *alloca (size_t);
|
|
|
|
#endif
|
|
|
|
|
2008-08-27 23:49:04 -07:00
|
|
|
#include <dlfcn.h>
|
|
|
|
|
2008-11-01 08:39:53 -07:00
|
|
|
#ifdef HAVE_EVIL
|
|
|
|
# include <Evil.h>
|
|
|
|
#endif
|
|
|
|
|
2008-10-22 01:56:19 -07:00
|
|
|
#include "eina_error.h"
|
2008-07-30 06:35:49 -07:00
|
|
|
#include "eina_module.h"
|
|
|
|
#include "eina_file.h"
|
2008-07-30 05:46:55 -07:00
|
|
|
#include "eina_private.h"
|
2008-12-26 10:31:14 -08:00
|
|
|
#include "eina_safety_checks.h"
|
2008-07-30 05:46:55 -07:00
|
|
|
|
|
|
|
/*============================================================================*
|
2008-08-18 01:18:16 -07:00
|
|
|
* Local *
|
2008-07-30 05:46:55 -07:00
|
|
|
*============================================================================*/
|
2008-08-27 23:49:04 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @cond LOCAL
|
|
|
|
*/
|
|
|
|
|
2009-06-17 21:06:34 -07:00
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
2008-08-27 23:49:04 -07:00
|
|
|
# define MODULE_EXTENSION ".dll"
|
2008-08-28 16:38:43 -07:00
|
|
|
#else
|
2008-08-28 16:51:48 -07:00
|
|
|
# define MODULE_EXTENSION ".so"
|
2009-06-17 21:06:34 -07:00
|
|
|
#endif /* !defined(_WIN32) && !defined(__CYGWIN__) */
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
#define EINA_MODULE_SYMBOL_INIT "__eina_module_init"
|
|
|
|
#define EINA_MODULE_SYMBOL_SHUTDOWN "__eina_module_shutdown"
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2008-10-22 01:56:19 -07:00
|
|
|
EAPI Eina_Error EINA_ERROR_WRONG_MODULE = 0;
|
|
|
|
EAPI Eina_Error EINA_ERROR_MODULE_INIT_FAILED = 0;
|
|
|
|
|
2008-07-30 05:46:55 -07:00
|
|
|
struct _Eina_Module
|
|
|
|
{
|
2008-09-24 05:55:31 -07:00
|
|
|
char *file;
|
|
|
|
void *handle;
|
|
|
|
int ref;
|
2008-08-18 01:18:16 -07:00
|
|
|
};
|
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
typedef struct _Dir_List_Get_Cb_Data
|
2008-08-18 01:18:16 -07:00
|
|
|
{
|
2008-09-24 05:55:31 -07:00
|
|
|
Eina_Module_Cb cb;
|
|
|
|
void *data;
|
2008-09-29 06:28:42 -07:00
|
|
|
Eina_Array *array;
|
2008-09-24 05:55:31 -07:00
|
|
|
} Dir_List_Get_Cb_Data;
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
typedef struct _Dir_List_Cb_Data
|
2008-08-18 01:18:16 -07:00
|
|
|
{
|
2008-09-24 05:55:31 -07:00
|
|
|
Eina_Module_Cb cb;
|
|
|
|
void *data;
|
|
|
|
} Dir_List_Cb_Data;
|
2008-07-31 09:54:02 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
static Eina_Bool _dir_list_get_cb(Eina_Module *m, void *data)
|
2008-08-18 01:18:16 -07:00
|
|
|
{
|
2008-09-24 05:55:31 -07:00
|
|
|
Dir_List_Get_Cb_Data *cb_data = data;
|
|
|
|
Eina_Bool ret = EINA_TRUE;
|
2008-07-30 05:46:55 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
if (cb_data->cb)
|
|
|
|
{
|
|
|
|
ret = cb_data->cb(m, cb_data->data);
|
|
|
|
}
|
|
|
|
if (ret)
|
|
|
|
{
|
2008-09-29 06:28:42 -07:00
|
|
|
eina_array_push(cb_data->array, m);
|
2008-09-24 05:55:31 -07:00
|
|
|
}
|
|
|
|
return ret;
|
2008-07-30 05:46:55 -07:00
|
|
|
}
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
static void _dir_list_cb(const char *name, const char *path, void *data)
|
2008-08-18 01:18:16 -07:00
|
|
|
{
|
2008-09-24 05:55:31 -07:00
|
|
|
Dir_List_Cb_Data *cb_data = data;
|
2009-01-23 08:11:45 -08:00
|
|
|
size_t length;
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
length = strlen(name);
|
|
|
|
if (length < strlen(MODULE_EXTENSION) + 1) /* x.so */
|
|
|
|
return;
|
|
|
|
if (!strcmp(name + length - strlen(MODULE_EXTENSION),
|
|
|
|
MODULE_EXTENSION))
|
|
|
|
{
|
2008-12-23 05:12:06 -08:00
|
|
|
char *file;
|
2008-09-24 05:55:31 -07:00
|
|
|
Eina_Module *m;
|
2009-01-23 08:11:45 -08:00
|
|
|
size_t length;
|
2008-09-24 05:55:31 -07:00
|
|
|
|
2008-12-23 05:12:06 -08:00
|
|
|
length = strlen(path) + strlen(name) + 2;
|
|
|
|
|
|
|
|
file = alloca(sizeof (char) * length);
|
|
|
|
if (!file) return ;
|
|
|
|
|
|
|
|
snprintf(file, length, "%s/%s", path, name);
|
2008-09-24 05:55:31 -07:00
|
|
|
m = eina_module_new(file);
|
|
|
|
if (!m)
|
|
|
|
return;
|
|
|
|
/* call the user provided cb on this module */
|
2009-06-06 15:53:03 -07:00
|
|
|
if (!cb_data->cb(m, cb_data->data))
|
2009-06-24 09:56:49 -07:00
|
|
|
eina_module_free(m);
|
2008-09-24 05:55:31 -07:00
|
|
|
}
|
2008-08-18 01:18:16 -07:00
|
|
|
}
|
2008-09-24 05:55:31 -07:00
|
|
|
static int _eina_module_count = 0;
|
2009-01-20 00:29:41 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @endcond
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*============================================================================*
|
|
|
|
* Global *
|
|
|
|
*============================================================================*/
|
|
|
|
|
2008-08-18 01:18:16 -07:00
|
|
|
/*============================================================================*
|
|
|
|
* API *
|
|
|
|
*============================================================================*/
|
2009-01-20 00:29:41 -08:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
/**
|
2009-06-22 13:03:58 -07:00
|
|
|
* @addtogroup Eina_Module_Group Module
|
|
|
|
*
|
|
|
|
* @brief These functions provide module management.
|
|
|
|
*
|
|
|
|
* @{
|
2008-09-24 05:55:31 -07:00
|
|
|
*/
|
2009-06-22 13:03:58 -07:00
|
|
|
|
2008-08-18 01:18:16 -07:00
|
|
|
EAPI int
|
|
|
|
eina_module_init(void)
|
2008-07-30 05:46:55 -07:00
|
|
|
{
|
2008-09-24 05:55:31 -07:00
|
|
|
_eina_module_count++;
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
if (_eina_module_count != 1)
|
|
|
|
goto end_init;
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2008-10-22 01:56:19 -07:00
|
|
|
eina_error_init();
|
|
|
|
|
|
|
|
EINA_ERROR_WRONG_MODULE = eina_error_msg_register("Wrong file format or no file module found");
|
|
|
|
EINA_ERROR_MODULE_INIT_FAILED = eina_error_msg_register("Module initialisation function failed");
|
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
end_init:
|
|
|
|
return _eina_module_count;
|
2008-07-30 05:46:55 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -07:00
|
|
|
|
2008-08-18 01:18:16 -07:00
|
|
|
EAPI int
|
|
|
|
eina_module_shutdown(void)
|
2008-07-30 05:46:55 -07:00
|
|
|
{
|
2008-09-24 05:55:31 -07:00
|
|
|
_eina_module_count--;
|
|
|
|
if (_eina_module_count != 0)
|
|
|
|
goto end_shutdown;
|
2008-10-22 01:56:19 -07:00
|
|
|
|
|
|
|
eina_error_shutdown();
|
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
/* TODO should we store every module when "new" is called and
|
|
|
|
* delete the list of modules here
|
|
|
|
*/
|
|
|
|
|
|
|
|
end_shutdown:
|
|
|
|
return _eina_module_count;
|
2008-07-30 05:46:55 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
EAPI Eina_Bool eina_module_load(Eina_Module *m)
|
|
|
|
{
|
|
|
|
void *dl_handle;
|
|
|
|
Eina_Module_Init *initcall;
|
|
|
|
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
|
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
if (m->handle) goto loaded;
|
|
|
|
|
|
|
|
dl_handle = dlopen(m->file, RTLD_NOW);
|
2009-06-16 07:59:09 -07:00
|
|
|
if (!dl_handle)
|
|
|
|
{
|
|
|
|
EINA_ERROR_PDBG("could not dlopen(\"%s\", RTLD_NOW): %s\n",
|
|
|
|
m->file, dlerror());
|
|
|
|
eina_error_set(EINA_ERROR_WRONG_MODULE);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2008-10-22 01:56:19 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
initcall = dlsym(dl_handle, EINA_MODULE_SYMBOL_INIT);
|
|
|
|
if ((!initcall) || (!(*initcall)))
|
|
|
|
goto ok;
|
|
|
|
if ((*initcall)() == EINA_TRUE)
|
|
|
|
goto ok;
|
2008-09-29 06:28:42 -07:00
|
|
|
|
2009-06-16 07:59:09 -07:00
|
|
|
eina_error_set(EINA_ERROR_MODULE_INIT_FAILED);
|
2008-09-24 05:55:31 -07:00
|
|
|
dlclose(dl_handle);
|
|
|
|
return EINA_FALSE;
|
|
|
|
ok:
|
|
|
|
m->handle = dl_handle;
|
|
|
|
loaded:
|
|
|
|
m->ref++;
|
2008-10-22 01:56:19 -07:00
|
|
|
|
|
|
|
eina_error_set(0);
|
2008-09-24 05:55:31 -07:00
|
|
|
return EINA_TRUE;
|
2008-08-18 01:18:16 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
EAPI Eina_Bool eina_module_unload(Eina_Module *m)
|
2008-08-18 01:18:16 -07:00
|
|
|
{
|
2008-09-24 05:55:31 -07:00
|
|
|
Eina_Module_Shutdown *shut;
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
m->ref--;
|
|
|
|
if (!m->ref)
|
|
|
|
{
|
|
|
|
shut = dlsym(m->handle, EINA_MODULE_SYMBOL_SHUTDOWN);
|
|
|
|
if ((shut) && (*shut))
|
|
|
|
(*shut)();
|
|
|
|
dlclose(m->handle);
|
2008-09-29 06:28:42 -07:00
|
|
|
m->handle = NULL;
|
2008-09-24 05:55:31 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
2008-08-18 01:18:16 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
EAPI Eina_Module * eina_module_new(const char *file)
|
2008-08-18 01:18:16 -07:00
|
|
|
{
|
2008-09-24 05:55:31 -07:00
|
|
|
Eina_Module *m;
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
|
2008-09-24 05:55:31 -07:00
|
|
|
/* TODO check that the file exists */
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
m = malloc(sizeof(Eina_Module));
|
|
|
|
/* TODO add the magic */
|
|
|
|
m->file = strdup(file);
|
|
|
|
m->ref = 0;
|
|
|
|
m->handle = NULL;
|
2008-09-29 06:28:42 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
return m;
|
2008-08-18 01:18:16 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -07:00
|
|
|
|
2009-06-24 09:56:49 -07:00
|
|
|
EAPI Eina_Bool eina_module_free(Eina_Module *m)
|
2008-08-18 01:18:16 -07:00
|
|
|
{
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE);
|
2008-08-18 01:18:16 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
if (m->handle)
|
|
|
|
{
|
|
|
|
if (eina_module_unload(m) == EINA_FALSE)
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
free(m->file);
|
|
|
|
free(m);
|
|
|
|
return EINA_TRUE;
|
2008-08-18 01:18:16 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
EAPI void * eina_module_symbol_get(Eina_Module *m, const char *symbol)
|
2008-08-18 01:18:16 -07:00
|
|
|
{
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(m->handle, NULL);
|
2008-09-29 06:28:42 -07:00
|
|
|
return dlsym(m->handle, symbol);
|
2008-08-18 01:18:16 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
EAPI const char * eina_module_file_get(Eina_Module *m)
|
2008-08-18 01:18:16 -07:00
|
|
|
{
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
|
2008-09-24 05:55:31 -07:00
|
|
|
return m->file;
|
2008-08-18 01:18:16 -07:00
|
|
|
}
|
|
|
|
|
2008-11-01 08:39:53 -07:00
|
|
|
EAPI char *eina_module_symbol_path_get(const void *symbol, const char *sub_dir)
|
|
|
|
{
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(symbol, NULL);
|
|
|
|
|
2008-11-01 08:39:53 -07:00
|
|
|
#ifdef HAVE_DLADDR
|
|
|
|
Dl_info eina_dl;
|
|
|
|
|
|
|
|
if (dladdr(symbol, &eina_dl))
|
|
|
|
{
|
|
|
|
if (strrchr(eina_dl.dli_fname, '/'))
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
int l0;
|
|
|
|
int l1;
|
|
|
|
int l2 = 0;
|
|
|
|
|
|
|
|
l0 = strlen(eina_dl.dli_fname);
|
|
|
|
l1 = strlen(strrchr(eina_dl.dli_fname, '/'));
|
|
|
|
if (sub_dir && (*sub_dir != '\0'))
|
|
|
|
l2 = strlen(sub_dir);
|
|
|
|
path = malloc(l0 - l1 + l2 + 1);
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
memcpy(path, eina_dl.dli_fname, l0 - l1);
|
|
|
|
if (sub_dir && (*sub_dir != '\0'))
|
|
|
|
memcpy(path + l0 - l1, sub_dir, l2);
|
|
|
|
path[l0 - l1 + l2] = '\0';
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* ! HAVE_DLADDR */
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI char *eina_module_environment_path_get(const char *env, const char *sub_dir)
|
|
|
|
{
|
|
|
|
const char *env_dir;
|
|
|
|
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(env, NULL);
|
|
|
|
|
2008-11-01 08:39:53 -07:00
|
|
|
env_dir = getenv(env);
|
|
|
|
if (env_dir)
|
|
|
|
{
|
2009-01-23 08:11:45 -08:00
|
|
|
char *path;
|
|
|
|
size_t l1;
|
|
|
|
size_t l2 = 0;
|
2008-11-01 08:39:53 -07:00
|
|
|
|
|
|
|
l1 = strlen(env_dir);
|
|
|
|
if (sub_dir && (*sub_dir != '\0'))
|
|
|
|
l2 = strlen(sub_dir);
|
|
|
|
|
|
|
|
path = (char *)malloc(l1 + l2 + 1);
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
memcpy(path, env_dir, l1);
|
|
|
|
if (sub_dir && (*sub_dir != '\0'))
|
|
|
|
memcpy(path + l1, sub_dir, l2);
|
|
|
|
path[l1 + l2] = '\0';
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
/**
|
|
|
|
* Gets a list of modules found on the directory path
|
2008-11-01 08:39:53 -07:00
|
|
|
*
|
2008-09-24 05:55:31 -07:00
|
|
|
* @param path The directory's path to search for modules
|
|
|
|
* @param recursive Iterate recursively on the path
|
|
|
|
* @param cb Callback function to call, if the return value of the callback is zero
|
|
|
|
* it won't be added to the list, if it is one, it will.
|
|
|
|
* @param data Data passed to the callback function
|
|
|
|
*/
|
2008-11-01 08:39:53 -07:00
|
|
|
EAPI Eina_Array * eina_module_list_get(Eina_Array *array, const char *path, unsigned int recursive, Eina_Module_Cb cb, void *data)
|
2008-09-24 05:55:31 -07:00
|
|
|
{
|
|
|
|
Dir_List_Get_Cb_Data list_get_cb_data;
|
|
|
|
Dir_List_Cb_Data list_cb_data;
|
2008-09-29 06:28:42 -07:00
|
|
|
|
2008-12-29 03:49:35 -08:00
|
|
|
if (!path) return array;
|
2008-09-24 05:55:31 -07:00
|
|
|
|
2008-11-01 08:39:53 -07:00
|
|
|
list_get_cb_data.array = array ? array : eina_array_new(4);
|
2008-09-24 05:55:31 -07:00
|
|
|
list_get_cb_data.cb = cb;
|
|
|
|
list_get_cb_data.data = data;
|
2008-09-29 06:28:42 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
list_cb_data.cb = &_dir_list_get_cb;
|
|
|
|
list_cb_data.data = &list_get_cb_data;
|
2008-09-29 06:28:42 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
eina_file_dir_list(path, recursive, &_dir_list_cb, &list_cb_data);
|
2008-09-29 06:28:42 -07:00
|
|
|
|
|
|
|
return list_get_cb_data.array;
|
2008-08-18 01:18:16 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
/**
|
|
|
|
* Load every module on the list of modules
|
|
|
|
* @param list The list of modules
|
|
|
|
*/
|
2008-09-29 06:28:42 -07:00
|
|
|
EAPI void eina_module_list_load(Eina_Array *array)
|
2008-08-18 01:18:16 -07:00
|
|
|
{
|
2008-09-29 06:28:42 -07:00
|
|
|
Eina_Array_Iterator iterator;
|
|
|
|
Eina_Module *m;
|
|
|
|
unsigned int i;
|
|
|
|
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(array);
|
|
|
|
|
2008-09-29 06:28:42 -07:00
|
|
|
EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
|
2008-09-24 05:55:31 -07:00
|
|
|
eina_module_load(m);
|
2008-08-18 01:18:16 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -07:00
|
|
|
|
2008-09-29 06:28:42 -07:00
|
|
|
EAPI void eina_module_list_unload(Eina_Array *array)
|
2008-08-18 01:18:16 -07:00
|
|
|
{
|
2008-09-29 06:28:42 -07:00
|
|
|
Eina_Array_Iterator iterator;
|
|
|
|
Eina_Module *m;
|
|
|
|
unsigned int i;
|
|
|
|
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(array);
|
|
|
|
|
2008-09-29 06:28:42 -07:00
|
|
|
EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
|
2008-09-24 05:55:31 -07:00
|
|
|
eina_module_unload(m);
|
2008-08-18 01:18:16 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -07:00
|
|
|
|
2008-09-24 05:55:31 -07:00
|
|
|
/**
|
|
|
|
* Helper function that iterates over the list of modules and calls
|
2009-06-24 09:56:49 -07:00
|
|
|
* eina_module_free on each
|
2008-09-24 05:55:31 -07:00
|
|
|
*/
|
2008-09-29 06:28:42 -07:00
|
|
|
EAPI void eina_module_list_delete(Eina_Array *array)
|
2008-08-18 01:18:16 -07:00
|
|
|
{
|
2008-09-29 06:28:42 -07:00
|
|
|
Eina_Array_Iterator iterator;
|
|
|
|
Eina_Module *m;
|
|
|
|
unsigned int i;
|
|
|
|
|
2008-12-26 10:31:14 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(array);
|
|
|
|
|
2008-09-29 06:28:42 -07:00
|
|
|
EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
|
2009-06-24 09:56:49 -07:00
|
|
|
eina_module_free(m);
|
2009-02-17 04:58:09 -08:00
|
|
|
|
|
|
|
eina_array_flush(array);
|
2008-08-18 01:18:16 -07:00
|
|
|
}
|
2009-06-22 13:03:58 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|