summaryrefslogtreecommitdiff
path: root/apps/plugins/lua
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2021-10-21 22:26:27 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2021-10-21 22:28:05 -0400
commitf4c7dc933d0df00c8ecc9308553a135a998399e2 (patch)
treed3376010a54378ad1ae7e714349ec07ebd22d9eb /apps/plugins/lua
parent1697b1369353ecfbd8c8b640e35b908e01126fc4 (diff)
downloadrockbox-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')
-rwxr-xr-xapps/plugins/lua/rbdefines_helper.pl1
-rw-r--r--apps/plugins/lua/rocklua.c12
2 files changed, 10 insertions, 3 deletions
diff --git a/apps/plugins/lua/rbdefines_helper.pl b/apps/plugins/lua/rbdefines_helper.pl
index e788855e87..5fb0946a6a 100755
--- a/apps/plugins/lua/rbdefines_helper.pl
+++ b/apps/plugins/lua/rbdefines_helper.pl
@@ -50,6 +50,7 @@ if ($def_type eq "rb_defines") {
50 '^SYS_(TIMEOUT|POWEROFF|BATTERY_UPDATE)$', 50 '^SYS_(TIMEOUT|POWEROFF|BATTERY_UPDATE)$',
51 '^SYS_USB_(DIS|)CONNECTED$', 51 '^SYS_USB_(DIS|)CONNECTED$',
52 '^HOME_DIR$', 52 '^HOME_DIR$',
53 '^PLUGIN(_OK|_USB_CONNECTED|_POWEROFF|_GOTO_WPS|_GOTO_PLUGIN)$',
53 '^PLUGIN_DIR$', 54 '^PLUGIN_DIR$',
54 '^PLUGIN(_APPS_|_GAMES_|_)DATA_DIR$', 55 '^PLUGIN(_APPS_|_GAMES_|_)DATA_DIR$',
55 '^ROCKBOX_DIR$', 56 '^ROCKBOX_DIR$',
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)
175static void lua_atexit(void) 175static 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 {
200ERR_RUN: 206ERR_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