* eina_module: Add eina_module_find. Thanks to Fabiano FidĂȘncio <fidencio@profusion...
authorcedric <cedric>
Fri, 20 Nov 2009 20:46:24 +0000 (20:46 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 20 Nov 2009 20:46:24 +0000 (20:46 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eina@43847 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

AUTHORS
src/include/eina_module.h
src/lib/eina_module.c

diff --git a/AUTHORS b/AUTHORS
index febfd76..eae0bfb 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -12,3 +12,4 @@ Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>
 Andre Dieb <andre.dieb@gmail.com>
 Raphael Kubo da Costa <kubo@profusion.mobi>
 Gustavo Chaves <glima@profusion.mobi>
+Fabiano FidĂȘncio <fidencio@profusion.mobi>
index eca37c4..37c4e3c 100644 (file)
@@ -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);
 
 /**
  * @}
index 78eae7c..de5d148 100644 (file)
@@ -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
  */