summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2018-05-12 13:38:59 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2018-05-12 13:38:59 +0200
commit6e24cfe738366c7622df2546da978d389701483a (patch)
tree43daadac9e35690a68d6fe47f6a9f51401b73c54
-rw-r--r--meson.build6
-rw-r--r--src/luncher.c94
-rw-r--r--src/meson.build20
-rw-r--r--src/test1.c51
-rw-r--r--src/test2.c51
5 files changed, 222 insertions, 0 deletions
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..93615db
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,6 @@
1project('devilsgate',
2 'c',
3 version: '6.6.6'
4)
5
6subdir('src')
diff --git a/src/luncher.c b/src/luncher.c
new file mode 100644
index 0000000..2b2921a
--- /dev/null
+++ b/src/luncher.c
@@ -0,0 +1,94 @@
1#define EFL_EO_API_SUPPORT
2#define EFL_BETA_API_SUPPORT
3
4#include <dlfcn.h>
5#include <Elementary.h>
6#include <Efl_Net.h>
7#include <Ecore_Getopt.h>
8
9typedef struct {
10 void *opened_bin;
11 Eina_Stringshare *path;
12} Lazy_Start_App;
13
14#define BLACKLIST_SYMBOL(ret, b) \
15EAPI ret \
16b () \
17{ \
18 printf("ERROR! call to " #b " not permitted\n"); \
19} \
20
21BLACKLIST_SYMBOL(void, efl_exit);
22BLACKLIST_SYMBOL(void, ecore_main_loop_quit);
23BLACKLIST_SYMBOL(void, exit);
24BLACKLIST_SYMBOL(void, _exit);
25BLACKLIST_SYMBOL(void, abort);
26
27//symbols that are required
28static char* whitelist_symbols[] = {"efl_main", NULL};
29
30static void
31lazy_app_start(Lazy_Start_App *app)
32{
33 void(*l)(void*, const Efl_Event*);
34
35 l = dlsym(app->opened_bin, "efl_main");
36
37 l(NULL, NULL);
38}
39
40static Lazy_Start_App*
41lazy_app_load(const char *str)
42{
43 void *h;
44 Lazy_Start_App *app;
45
46 h = dlopen(str, RTLD_LAZY | RTLD_LOCAL);
47
48 if (!h)
49 {
50 printf("dlopen failed: %s\n", dlerror());
51 return NULL;
52 }
53
54 for (int i = 0; whitelist_symbols[i]; ++i)
55 {
56 if (!dlsym(h, whitelist_symbols[i]))
57 {
58 printf("Symbol %s not found in binary %s\n", whitelist_symbols[i], str);
59 printf("This symbol is required\n");
60 return NULL;
61 }
62 }
63
64 app = calloc(1, sizeof(Lazy_Start_App));
65 app->path = eina_stringshare_add(str);
66 app->opened_bin = h;
67 return app;
68}
69
70static char* path[] = {"/home/marcel/git/efl-launcher/build/src/test1", "/home/marcel/git/efl-launcher/build/src/test2", NULL};
71
72EAPI_MAIN void
73efl_main(void *data EINA_UNUSED,
74 const Efl_Event *ev)
75{
76 Eina_List *lst = NULL, *n;
77 Lazy_Start_App *app;
78
79 for (int i = 0; path[i]; ++i)
80 {
81 app = lazy_app_load(path[i]);
82
83 if (!app) continue;
84
85 lst = eina_list_append(lst, app);
86 }
87
88 EINA_LIST_FOREACH(lst, n, app)
89 {
90 lazy_app_start(app);
91 }
92}
93
94EFL_MAIN();
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..fd581f7
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,20 @@
1elm = dependency('elementary')
2
3executable('devilsgate',
4 'luncher.c',
5 dependencies: elm,
6)
7
8executable('test1',
9 'test1.c',
10 c_args: '-fpie',
11 link_args:['-pie', '-rdynamic'],
12 dependencies: elm,
13)
14
15executable('test2',
16 'test2.c',
17 c_args: '-fpie',
18 link_args: ['-pie', '-rdynamic'],
19 dependencies: elm,
20)
diff --git a/src/test1.c b/src/test1.c
new file mode 100644
index 0000000..8ea0e6e
--- /dev/null
+++ b/src/test1.c
@@ -0,0 +1,51 @@
1#define EFL_EO_API_SUPPORT 1
2#define EFL_BETA_API_SUPPORT 1
3
4#include <Eina.h>
5#include <Elementary.h>
6#include <Efl_Ui.h>
7
8static void
9_gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
10{
11 efl_exit(0);
12}
13
14static void
15_gui_setup()
16{
17 Eo *win, *box;
18
19 win = efl_add(EFL_UI_WIN_CLASS, NULL,
20 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
21 efl_text_set(efl_added, "Hello World"),
22 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
23
24 // when the user clicks "close" on a window there is a request to delete
25 efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _gui_quit_cb, NULL);
26
27 box = efl_add(EFL_UI_BOX_CLASS, win,
28 efl_content_set(win, efl_added),
29 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)));
30
31 efl_add(EFL_UI_TEXT_CLASS, box,
32 efl_text_markup_set(efl_added, "Hello World.<br>This is an <b>Efl.Ui</b> application!"),
33 efl_text_interactive_selection_allowed_set(efl_added, EINA_FALSE),
34 efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.9),
35 efl_gfx_size_hint_align_set(efl_added, 0.5, 0.5),
36 efl_pack(box, efl_added));
37
38 efl_add(EFL_UI_BUTTON_CLASS, box,
39 efl_text_set(efl_added, "Quit"),
40 efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.1),
41 efl_pack(box, efl_added),
42 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
43 _gui_quit_cb, efl_added));
44}
45
46EAPI_MAIN void
47efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
48{
49 _gui_setup();
50}
51EFL_MAIN()
diff --git a/src/test2.c b/src/test2.c
new file mode 100644
index 0000000..8ea0e6e
--- /dev/null
+++ b/src/test2.c
@@ -0,0 +1,51 @@
1#define EFL_EO_API_SUPPORT 1
2#define EFL_BETA_API_SUPPORT 1
3
4#include <Eina.h>
5#include <Elementary.h>
6#include <Efl_Ui.h>
7
8static void
9_gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
10{
11 efl_exit(0);
12}
13
14static void
15_gui_setup()
16{
17 Eo *win, *box;
18
19 win = efl_add(EFL_UI_WIN_CLASS, NULL,
20 efl_ui_win_type_set(efl_added, EFL_UI_WIN_BASIC),
21 efl_text_set(efl_added, "Hello World"),
22 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
23
24 // when the user clicks "close" on a window there is a request to delete
25 efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _gui_quit_cb, NULL);
26
27 box = efl_add(EFL_UI_BOX_CLASS, win,
28 efl_content_set(win, efl_added),
29 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(360, 240)));
30
31 efl_add(EFL_UI_TEXT_CLASS, box,
32 efl_text_markup_set(efl_added, "Hello World.<br>This is an <b>Efl.Ui</b> application!"),
33 efl_text_interactive_selection_allowed_set(efl_added, EINA_FALSE),
34 efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.9),
35 efl_gfx_size_hint_align_set(efl_added, 0.5, 0.5),
36 efl_pack(box, efl_added));
37
38 efl_add(EFL_UI_BUTTON_CLASS, box,
39 efl_text_set(efl_added, "Quit"),
40 efl_gfx_size_hint_weight_set(efl_added, 1.0, 0.1),
41 efl_pack(box, efl_added),
42 efl_event_callback_add(efl_added, EFL_UI_EVENT_CLICKED,
43 _gui_quit_cb, efl_added));
44}
45
46EAPI_MAIN void
47efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
48{
49 _gui_setup();
50}
51EFL_MAIN()