summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2015-04-13 15:42:02 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-05-06 15:05:20 +0100
commiteea537ded38c546d5c3500c711e5f6d61c968355 (patch)
treec32edebb60e9f45ebf235a5b0354d2e081363f8a /src/bin
parent02de415312b185aa79ef9cc4f80c7f98932579e6 (diff)
elua: cleanup launcher
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/elua/main.c80
1 files changed, 35 insertions, 45 deletions
diff --git a/src/bin/elua/main.c b/src/bin/elua/main.c
index be4748653d..48665699f9 100644
--- a/src/bin/elua/main.c
+++ b/src/bin/elua/main.c
@@ -21,22 +21,8 @@
21 21
22static int _el_log_domain = -1; 22static int _el_log_domain = -1;
23 23
24#define DBG(...) EINA_LOG_DOM_DBG(_el_log_domain, __VA_ARGS__)
25#define INF(...) EINA_LOG_DOM_INFO(_el_log_domain, __VA_ARGS__) 24#define INF(...) EINA_LOG_DOM_INFO(_el_log_domain, __VA_ARGS__)
26#define WRN(...) EINA_LOG_DOM_WARN(_el_log_domain, __VA_ARGS__)
27#define ERR(...) EINA_LOG_DOM_ERR(_el_log_domain, __VA_ARGS__) 25#define ERR(...) EINA_LOG_DOM_ERR(_el_log_domain, __VA_ARGS__)
28#define CRT(...) EINA_LOG_DOM_CRITICAL(_el_log_domain, __VA_ARGS__)
29
30void
31elua_bin_shutdown(Elua_State *es, int c)
32{
33 INF("elua shutdown");
34 if (es) elua_state_free(es);
35 if (_el_log_domain != EINA_LOG_DOMAIN_GLOBAL)
36 eina_log_domain_unregister(_el_log_domain);
37 elua_shutdown();
38 exit(c);
39}
40 26
41struct Main_Data 27struct Main_Data
42{ 28{
@@ -95,35 +81,27 @@ elua_main(lua_State *L)
95 int ch; 81 int ch;
96 82
97 while ((ch = getopt_long(argc, argv, "+LhC:M:A:l:I:E", lopt, NULL)) != -1) 83 while ((ch = getopt_long(argc, argv, "+LhC:M:A:l:I:E", lopt, NULL)) != -1)
98 { 84 switch (ch)
99 switch (ch) 85 {
100 { 86 case 'h':
101 case 'h': 87 elua_print_help(elua_state_prog_name_get(es), stdout); goto success;
102 elua_print_help(elua_state_prog_name_get(es), stdout); 88 case 'C':
103 if (largs) eina_list_free(largs); 89 coredir = optarg; break;
104 return 0; 90 case 'M':
105 case 'C': 91 moddir = optarg; break;
106 coredir = optarg; 92 case 'A':
107 break; 93 appsdir = optarg; break;
108 case 'M': 94 case 'l':
109 moddir = optarg; 95 case 'I':
110 break; 96 if (!optarg[0]) continue;
111 case 'A': 97 if (ch == 'l')
112 appsdir = optarg; 98 largs = eina_list_append(largs, optarg);
113 break; 99 else
114 case 'l': 100 elua_state_include_path_add(es, optarg);
115 if (!optarg[0]) continue; 101 break;
116 largs = eina_list_append(largs, optarg); 102 case 'E':
117 break; 103 noenv = EINA_TRUE; break;
118 case 'I': 104 }
119 if (!optarg[0]) continue;
120 elua_state_include_path_add(es, optarg);
121 break;
122 case 'E':
123 noenv = EINA_TRUE;
124 break;
125 }
126 }
127 105
128 INF("arguments parsed"); 106 INF("arguments parsed");
129 107
@@ -150,7 +128,7 @@ elua_main(lua_State *L)
150 if (elua_util_script_run(es, argc, argv, optind, &quit)) 128 if (elua_util_script_run(es, argc, argv, optind, &quit))
151 goto error; 129 goto error;
152 if (quit) 130 if (quit)
153 return 0; 131 goto success;
154 } 132 }
155 else 133 else
156 { 134 {
@@ -160,14 +138,26 @@ elua_main(lua_State *L)
160 138
161 ecore_main_loop_begin(); 139 ecore_main_loop_begin();
162 140
163 return 0; 141 goto success;
164 142
165error: 143error:
166 m->status = 1; 144 m->status = 1;
145success:
167 if (largs) eina_list_free(largs); 146 if (largs) eina_list_free(largs);
168 return 0; 147 return 0;
169} 148}
170 149
150void
151elua_bin_shutdown(Elua_State *es, int c)
152{
153 INF("elua shutdown");
154 if (es) elua_state_free(es);
155 if (_el_log_domain != EINA_LOG_DOMAIN_GLOBAL)
156 eina_log_domain_unregister(_el_log_domain);
157 elua_shutdown();
158 exit(c);
159}
160
171int 161int
172main(int argc, char **argv) 162main(int argc, char **argv)
173{ 163{