From 19af0668485071a2a1dc009289ce0455083be77b Mon Sep 17 00:00:00 2001 From: cedric Date: Fri, 20 Nov 2009 20:46:24 +0000 Subject: [PATCH] =?utf8?q?=09*=20eina=5Fmodule:=20Add=20eina=5Fmodule=5Ffi?= =?utf8?q?nd.=20Thanks=20to=20Fabiano=20Fid=C3=AAncio=20.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eina@43847 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- AUTHORS | 1 + src/include/eina_module.h | 1 + src/lib/eina_module.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/AUTHORS b/AUTHORS index febfd76..eae0bfb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,3 +12,4 @@ Albin "Lutin" Tonnerre Andre Dieb Raphael Kubo da Costa Gustavo Chaves +Fabiano Fidêncio diff --git a/src/include/eina_module.h b/src/include/eina_module.h index eca37c4..37c4e3c 100644 --- a/src/include/eina_module.h +++ b/src/include/eina_module.h @@ -70,6 +70,7 @@ EAPI Eina_Array * eina_module_list_get(Eina_Array *array, const char *path, unsi EAPI void eina_module_list_load(Eina_Array *list) EINA_ARG_NONNULL(1); EAPI void eina_module_list_unload(Eina_Array *list) EINA_ARG_NONNULL(1); EAPI void eina_module_list_flush(Eina_Array *list) EINA_ARG_NONNULL(1); +EAPI Eina_Module * eina_module_find(Eina_Array *array, char *module) EINA_ARG_NONNULL(1, 2); /** * @} diff --git a/src/lib/eina_module.c b/src/lib/eina_module.c index 78eae7c..de5d148 100644 --- a/src/lib/eina_module.c +++ b/src/lib/eina_module.c @@ -547,6 +547,37 @@ EAPI Eina_Array * eina_module_list_get(Eina_Array *array, const char *path, unsi } /** + * @brief Find an module in array. + * + * @param array The array to find the module. + * @param module The name of module to be searched; + * + * This function finds an @p module in an @p array; + * If the element is found return the module else NULL. + */ +EAPI Eina_Module * +eina_module_find(Eina_Array *array, char *module) +{ + unsigned int i; + Eina_Array_Iterator iterator; + Eina_Module *m; + + EINA_ARRAY_ITER_NEXT(array, i, m, iterator) + { + const char *file_m; + ssize_t len; + + file_m = basename(eina_module_file_get(m)); + len = strlen(file_m); + len -= sizeof(MODULE_EXTENSION) - 1; + if (len <= 0) continue; + if (!strncmp(module, file_m, len)) return m; + } + + return NULL; +} + +/** * Load every module on the list of modules * @param array The array of modules to load */ -- 2.7.4