diff options
-rwxr-xr-x | apps/plugins/lua/rbdefines_helper.pl | 1 | ||||
-rw-r--r-- | apps/plugins/lua/rocklua.c | 12 | ||||
-rw-r--r-- | apps/plugins/lua_scripts/return2WPS.lua | 19 |
3 files changed, 29 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) | |||
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 |
diff --git a/apps/plugins/lua_scripts/return2WPS.lua b/apps/plugins/lua_scripts/return2WPS.lua new file mode 100644 index 0000000000..9202237691 --- /dev/null +++ b/apps/plugins/lua_scripts/return2WPS.lua | |||
@@ -0,0 +1,19 @@ | |||
1 | --[[ | ||
2 | __________ __ ___. | ||
3 | Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | \/ \/ \/ \/ \/ | ||
8 | $Id$ | ||
9 | Example Lua Return to WPS on exit | ||
10 | Copyright (C) 2021 William Wilgus | ||
11 | This program is free software; you can redistribute it and/or | ||
12 | modify it under the terms of the GNU General Public License | ||
13 | as published by the Free Software Foundation; either version 2 | ||
14 | of the License, or (at your option) any later version. | ||
15 | This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | KIND, either express or implied. | ||
17 | ]]-- | ||
18 | |||
19 | os.exit(rb.PLUGIN_GOTO_WPS) | ||