Enlightenment CVS committal

Author  : pfritz
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/bin


Modified Files:
        Ewl_Test.h main.c 


Log Message:
use ecore_plugin instead of dlopen

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/bin/Ewl_Test.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- Ewl_Test.h  23 Aug 2007 05:26:42 -0000      1.9
+++ Ewl_Test.h  5 Sep 2007 18:33:25 -0000       1.10
@@ -49,7 +49,7 @@
        const char *filename;            /**< Filename of the test */
        const char *tip;                 /**< Tooltip for the test */
 
-       void *handle;                    /**< Dynamic file handle for test */
+       Ecore_Plugin *plugin;            /**< Dynamic file handle for test */
        Ewl_Test_Type type;              /**< The type of test */
        int (*func)(Ewl_Container *con); /**< The test function */
        Ewl_Unit_Test *unit_tests;       /**< The test unit tests */
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/bin/main.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -3 -r1.70 -r1.71
--- main.c      30 Aug 2007 16:56:26 -0000      1.70
+++ main.c      5 Sep 2007 18:33:25 -0000       1.71
@@ -16,7 +16,6 @@
 #include <string.h>
 #include <stdlib.h>
 #include <limits.h>
-#include <dlfcn.h>
 #include <fcntl.h>
 #include <ctype.h>
 #include <sys/types.h>
@@ -44,6 +43,7 @@
                "recompile or edit the test application.\n";
 
 static int ewl_test_setup_tests(void);
+static void ewl_test_free(Ewl_Test *test);
 static void ewl_test_print_tests(void);
 
 static void run_test_boxed(Ewl_Test *t);
@@ -80,6 +80,7 @@
 static unsigned int cb_unit_test_count(void *data);
 
 static Ecore_List *tests = NULL;
+static int tests_path_group = 0;
 static int window_count = 0;
 static int current_unit_test = 0;
 static Ecore_Timer *unit_test_timer = NULL;
@@ -172,6 +173,7 @@
                ewl_main();
 
        if (tests) ecore_list_destroy(tests);
+       if (tests_path_group) ecore_path_group_del(tests_path_group);
 
        return ret;
 }
@@ -360,58 +362,59 @@
 static int
 ewl_test_setup_tests(void)
 {
-       char buf[PATH_MAX], buf2[PATH_MAX];
        Ecore_List *list = NULL;
-       char *file = NULL;
+       char *name = NULL;
+
+       if (tests) return 1;
 
        tests = ecore_list_new();
        if (!tests) return 0;
 
-       ecore_list_free_cb_set(tests, ECORE_FREE_CB(free));
+       ecore_list_free_cb_set(tests, ECORE_FREE_CB(ewl_test_free));
 
-       snprintf(buf, sizeof(buf), "%s", PACKAGE_LIB_DIR "/ewl/tests");
-       list = ecore_file_ls(buf);
-       if (list && ecore_list_count(list) > 0)
+       tests_path_group = ecore_path_group_new("Test Plugins");
+       ecore_path_group_add(tests_path_group, PACKAGE_LIB_DIR "/ewl/tests");
+       list = ecore_plugin_available_get(tests_path_group);
+       /* no tests found ... */
+       if (!list) return 0;
+       
+       while ((name = ecore_list_first_goto(list)))
        {
-               ecore_list_first_goto(list);
-               while ((file = ecore_list_first_remove(list)))
-               {
-                       int len;
+               Ecore_Plugin *plugin;
+               void (*func_info)(Ewl_Test *test);
 
-                       /* see if this is a .so file */
-                       len = strlen(file);
-                       if (!strncmp(file + (len - 3), ".so", 3))
-                       {
-                               void *handle;
+               plugin = ecore_plugin_load(tests_path_group, name, NULL);
+               if (!plugin)
+                       continue;
 
-                               snprintf(buf2, sizeof(buf2), "%s/%s", buf, 
file);
-                               handle = dlopen(buf2, RTLD_LAZY | RTLD_GLOBAL);
-                               if (handle)
-                               {
-                                       void (*func_info)(Ewl_Test *test);
-
-                                       /* the UI test info */
-                                       func_info = dlsym(handle, "test_info");
-                                       if (func_info)
-                                       {
-                                               Ewl_Test *t;
-
-                                               t = calloc(1, sizeof(Ewl_Test));
-                                               func_info(t);
-                                               t->handle = handle;
-                                               ecore_list_append(tests, t);
-                                       }
-                               }
-                       }
-                       free(file);
+
+               /* the UI test info */
+               func_info = ecore_plugin_symbol_get(plugin, "test_info");
+               if (func_info)
+               {
+                       Ewl_Test *t;
+
+                       t = calloc(1, sizeof(Ewl_Test));
+                       func_info(t);
+                       t->plugin = plugin;
+                       ecore_list_append(tests, t);
                }
-               ecore_list_destroy(list);
+
+               ecore_list_remove(list);
        }
+       ecore_list_destroy(list);
 
        /* no tests found ... */
        if (ecore_list_count(tests) == 0) return 0;
 
        return 1;
+}
+
+static void 
+ewl_test_free(Ewl_Test *test)
+{
+       if (test->plugin) ecore_plugin_unload(test->plugin);
+       free(test);
 }
 
 static int



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to