diff options
author | William Wilgus <wilgus.william@gmail.com> | 2021-10-21 22:26:27 -0400 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2021-10-21 22:28:05 -0400 |
commit | f4c7dc933d0df00c8ecc9308553a135a998399e2 (patch) | |
tree | d3376010a54378ad1ae7e714349ec07ebd22d9eb /apps/plugins/lua/rocklua.c | |
parent | 1697b1369353ecfbd8c8b640e35b908e01126fc4 (diff) | |
download | rockbox-f4c7dc933d0df00c8ecc9308553a135a998399e2.tar.gz rockbox-f4c7dc933d0df00c8ecc9308553a135a998399e2.zip |
lua add ability to pass PLUGIN_ ret vals with os.exit() + add defines
Change-Id: I45998245271fbd8fee4534f8497b014025e4dcc7
Diffstat (limited to 'apps/plugins/lua/rocklua.c')
-rw-r--r-- | apps/plugins/lua/rocklua.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/apps/plugins/lua/rocklua.c b/apps/plugins/lua/rocklua.c index 3909f3008f..3cf0fce945 100644 --- a/apps/plugins/lua/rocklua.c +++ b/apps/plugins/lua/rocklua.c | |||
@@ -175,9 +175,10 @@ static int loadfile_newstate(lua_State **L, const char *filename) | |||
175 | static void lua_atexit(void) | 175 | static void lua_atexit(void) |
176 | { | 176 | { |
177 | char *filename; | 177 | char *filename; |
178 | 178 | int err_n; | |
179 | if(Ls && lua_gettop(Ls) > 1) | 179 | if(Ls && lua_gettop(Ls) > 1) |
180 | { | 180 | { |
181 | err_n = lua_tointeger(Ls, -1); /* os.exit? */ | ||
181 | if (Ls == lua_touserdata(Ls, -1)) /* signal from restart_lua */ | 182 | if (Ls == lua_touserdata(Ls, -1)) /* signal from restart_lua */ |
182 | { | 183 | { |
183 | filename = (char *) malloc((MAX_PATH * 2) + 1); | 184 | filename = (char *) malloc((MAX_PATH * 2) + 1); |
@@ -195,7 +196,12 @@ static void lua_atexit(void) | |||
195 | free(filename); | 196 | free(filename); |
196 | plugin_start(NULL); | 197 | plugin_start(NULL); |
197 | } | 198 | } |
198 | else if (lua_tointeger(Ls, -1) != 0) /* os.exit */ | 199 | else if (err_n >= PLUGIN_USB_CONNECTED) /* INTERNAL PLUGIN RETVAL */ |
200 | { | ||
201 | lua_close(Ls); | ||
202 | _exit(err_n); /* don't call exit handler */ | ||
203 | } | ||
204 | else if (err_n != 0) | ||
199 | { | 205 | { |
200 | ERR_RUN: | 206 | ERR_RUN: |
201 | lu_status = LUA_ERRRUN; | 207 | lu_status = LUA_ERRRUN; |
@@ -205,7 +211,7 @@ ERR_RUN: | |||
205 | else | 211 | else |
206 | lua_close(Ls); | 212 | lua_close(Ls); |
207 | } | 213 | } |
208 | _exit(0); /* don't call exit handler */ | 214 | _exit(PLUGIN_OK); /* don't call exit handler */ |
209 | } | 215 | } |
210 | 216 | ||
211 | /* split filename at argchar | 217 | /* split filename at argchar |