diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-07-13 17:38:58 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2013-07-13 17:47:01 +0200 |
commit | 7827b7ccdbfd639a0c49052ec7c94ae29c50f2ea (patch) | |
tree | 6869465be5fa16e3efe3a33301149dd80aa7be9d /utils/hwstub/tools | |
parent | f617da0552c95202807c5e41c70bc78a3189378e (diff) | |
download | rockbox-7827b7ccdbfd639a0c49052ec7c94ae29c50f2ea.tar.gz rockbox-7827b7ccdbfd639a0c49052ec7c94ae29c50f2ea.zip |
hwstub: allow to escape shell with a function call
Change-Id: I65b7b230d3b89a5014db134d3159861474fd889f
Diffstat (limited to 'utils/hwstub/tools')
-rw-r--r-- | utils/hwstub/tools/hwstub_shell.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/utils/hwstub/tools/hwstub_shell.cpp b/utils/hwstub/tools/hwstub_shell.cpp index 69e580f88e..86824b680c 100644 --- a/utils/hwstub/tools/hwstub_shell.cpp +++ b/utils/hwstub/tools/hwstub_shell.cpp | |||
@@ -37,6 +37,7 @@ | |||
37 | * Global variables | 37 | * Global variables |
38 | */ | 38 | */ |
39 | bool g_quiet = false; | 39 | bool g_quiet = false; |
40 | bool g_exit = false; | ||
40 | struct hwstub_device_t g_hwdev; | 41 | struct hwstub_device_t g_hwdev; |
41 | struct usb_resp_info_version_t g_hwdev_ver; | 42 | struct usb_resp_info_version_t g_hwdev_ver; |
42 | struct usb_resp_info_layout_t g_hwdev_layout; | 43 | struct usb_resp_info_layout_t g_hwdev_layout; |
@@ -210,6 +211,12 @@ int my_lua_printlog(lua_State *state) | |||
210 | return 0; | 211 | return 0; |
211 | } | 212 | } |
212 | 213 | ||
214 | int my_lua_exit(lua_State *state) | ||
215 | { | ||
216 | g_exit = true; | ||
217 | return 0; | ||
218 | } | ||
219 | |||
213 | bool my_lua_import_hwstub() | 220 | bool my_lua_import_hwstub() |
214 | { | 221 | { |
215 | int oldtop = lua_gettop(g_lua); | 222 | int oldtop = lua_gettop(g_lua); |
@@ -340,6 +347,12 @@ bool my_lua_import_hwstub() | |||
340 | lua_pushcfunction(g_lua, my_lua_help); | 347 | lua_pushcfunction(g_lua, my_lua_help); |
341 | lua_setglobal(g_lua, "help"); | 348 | lua_setglobal(g_lua, "help"); |
342 | 349 | ||
350 | lua_pushcfunction(g_lua, my_lua_exit); | ||
351 | lua_setglobal(g_lua, "exit"); | ||
352 | |||
353 | lua_pushcfunction(g_lua, my_lua_exit); | ||
354 | lua_setglobal(g_lua, "quit"); | ||
355 | |||
343 | if(lua_gettop(g_lua) != oldtop) | 356 | if(lua_gettop(g_lua) != oldtop) |
344 | { | 357 | { |
345 | printf("internal error: unbalanced my_lua_import_soc"); | 358 | printf("internal error: unbalanced my_lua_import_soc"); |
@@ -824,7 +837,7 @@ int main(int argc, char **argv) | |||
824 | 837 | ||
825 | // use readline to provide some history and completion | 838 | // use readline to provide some history and completion |
826 | rl_bind_key('\t', rl_complete); | 839 | rl_bind_key('\t', rl_complete); |
827 | while(1) | 840 | while(!g_exit) |
828 | { | 841 | { |
829 | char *input = readline("> "); | 842 | char *input = readline("> "); |
830 | if(!input) | 843 | if(!input) |