summaryrefslogtreecommitdiff
path: root/src/bin/exactness/player.c
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2020-03-17 16:53:30 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2020-03-20 12:04:35 +0100
commitb84694f5189f86e223c68695366c0d676d8fc6a4 (patch)
tree402a74ecd7daeb4f9fbc24bc6f0a40a3900deb67 /src/bin/exactness/player.c
parentb5c24af2e14c9a56dbba0f61119281c06da66758 (diff)
exactness: factour out the program invoke code
It needs a little special case handling for the player (to load the edj file), but the rest is really the same. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D11460
Diffstat (limited to 'src/bin/exactness/player.c')
-rw-r--r--src/bin/exactness/player.c92
1 files changed, 2 insertions, 90 deletions
diff --git a/src/bin/exactness/player.c b/src/bin/exactness/player.c
index fa9f0c63d3..ff500fcd8d 100644
--- a/src/bin/exactness/player.c
+++ b/src/bin/exactness/player.c
@@ -56,7 +56,6 @@ static Exactness_Unit *_src_unit = NULL;
56static const char *_test_name = NULL; 56static const char *_test_name = NULL;
57static int _verbose = 0; 57static int _verbose = 0;
58 58
59static Evas *(*_evas_new)(void) = NULL;
60static Eina_List *_evas_list = NULL; 59static Eina_List *_evas_list = NULL;
61 60
62static Eina_List *_cur_event_list = NULL; 61static Eina_List *_cur_event_list = NULL;
@@ -804,94 +803,6 @@ _src_open()
804 return EINA_TRUE; 803 return EINA_TRUE;
805} 804}
806 805
807static int
808_prg_invoke(const char *full_path, int argc, char **argv)
809{
810 Eina_Value *ret__;
811 int real__;
812
813 void (*efl_main)(void *data, const Efl_Event *ev);
814 int (*elm_main)(int argc, char **argv);
815 int (*c_main)(int argc, char **argv);
816 Eina_Module *h = eina_module_new(full_path);
817 if (!h || !eina_module_load(h))
818 {
819 fprintf(stderr, "Failed loading %s.\n", full_path);
820 if (h) eina_module_free(h);
821 return 1;
822 }
823 efl_main = eina_module_symbol_get(h, "efl_main");
824 elm_main = eina_module_symbol_get(h, "elm_main");
825 c_main = eina_module_symbol_get(h, "main");
826 _evas_new = eina_module_symbol_get(h, "evas_new");
827 if (!_evas_new)
828 {
829 fprintf(stderr, "Failed loading symbol 'evas_new' from %s.\n", full_path);
830 eina_module_free(h);
831 return 1;
832 }
833
834 if (efl_main)
835 {
836 elm_init(argc, argv);
837 elm_theme_overlay_add(NULL, DATA_DIR"/exactness_play.edj");
838 efl_event_callback_add(efl_main_loop_get(), EFL_LOOP_EVENT_ARGUMENTS, efl_main, NULL);
839 ret__ = efl_loop_begin(efl_main_loop_get());
840 real__ = efl_loop_exit_code_process(ret__);
841 elm_shutdown();
842 }
843 else if (elm_main)
844 {
845 elm_init(argc, argv);
846 elm_theme_overlay_add(NULL, DATA_DIR"/exactness_play.edj");
847 real__ = elm_main(argc, argv);
848 elm_shutdown();
849 }
850 else if (c_main)
851 {
852 real__ = c_main(argc, argv);
853 }
854 else
855 {
856 fprintf(stderr, "Failed loading symbol 'efl_main', 'elm_main' or 'main' from %s.\n", full_path);
857 eina_module_free(h);
858 real__ = 1;
859 }
860
861 return real__;
862}
863
864static Eina_Stringshare *
865_prg_full_path_guess(const char *prg)
866{
867 char full_path[PATH_MAX];
868 if (strchr(prg, '/')) return eina_stringshare_add(prg);
869 char *env_path = eina_strdup(getenv("PATH"));
870 Eina_Stringshare *ret = NULL;
871 char *paths = env_path;
872
873 while (paths && *paths && !ret)
874 {
875 char *real_path;
876 char *colon = strchr(paths, ':');
877 if (colon) *colon = '\0';
878
879 sprintf(full_path, "%s/%s", paths, prg);
880 real_path = ecore_file_realpath(full_path);
881 if (*real_path)
882 {
883 ret = eina_stringshare_add(real_path);
884 // check if executable
885 }
886 free(real_path);
887
888 paths += strlen(paths);
889 if (colon) paths++;
890 }
891 free(env_path);
892 return ret;
893}
894
895static Eina_Bool 806static Eina_Bool
896_mkdir(const char *path, Eina_Bool skip_last) 807_mkdir(const char *path, Eina_Bool skip_last)
897{ 808{
@@ -1022,6 +933,7 @@ int main(int argc, char **argv)
1022 const char *chosen_fonts = NULL; 933 const char *chosen_fonts = NULL;
1023 Eina_Bool show_on_screen = EINA_FALSE; 934 Eina_Bool show_on_screen = EINA_FALSE;
1024 Eina_Bool want_quit = EINA_FALSE, external_injection = EINA_FALSE; 935 Eina_Bool want_quit = EINA_FALSE, external_injection = EINA_FALSE;
936 _evas_new = NULL;
1025 937
1026 Ecore_Getopt_Value values[] = { 938 Ecore_Getopt_Value values[] = {
1027 ECORE_GETOPT_VALUE_STR(dest), 939 ECORE_GETOPT_VALUE_STR(dest),
@@ -1255,7 +1167,7 @@ int main(int argc, char **argv)
1255 ecore_evas_callback_new_set(_my_evas_new); 1167 ecore_evas_callback_new_set(_my_evas_new);
1256 if (_src_type != FTYPE_REMOTE) 1168 if (_src_type != FTYPE_REMOTE)
1257 ecore_idler_add(_src_feed, NULL); 1169 ecore_idler_add(_src_feed, NULL);
1258 pret = _prg_invoke(_prg_full_path_guess(argv[0]), argc - opt_args, argv); 1170 pret = ex_prg_invoke(ex_prg_full_path_guess(argv[0]), argc - opt_args, argv, EINA_TRUE);
1259 1171
1260 if (_dest && _dest_unit) 1172 if (_dest && _dest_unit)
1261 { 1173 {