diff mbox series

[3/3] Lua: add function to get selection

Message ID 20201117094122.2153374-3-sbabic@denx.de
State Accepted
Headers show
Series [1/3] Connect the internal data tree to the shared data structure | expand

Commit Message

Stefano Babic Nov. 17, 2020, 9:41 a.m. UTC
Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 corelib/lua_interface.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
index 73f5a9c..a0d9297 100644
--- a/corelib/lua_interface.c
+++ b/corelib/lua_interface.c
@@ -831,6 +831,20 @@  static int l_set_bootenv(lua_State *L) {
 	return 0;
 }
 
+static int l_get_selection(lua_State *L) {
+	char tmp[SWUPDATE_GENERAL_STRING_SIZE];
+
+	tmp[0] = '\0';
+	get_install_swset(tmp, sizeof(tmp));
+	lua_pushstring(L, tmp);
+	tmp[0] = '\0';
+	get_install_running_mode(tmp, sizeof(tmp));
+	lua_pushstring(L, tmp);
+
+	return 2;
+}
+
+
 #ifdef CONFIG_HANDLER_IN_LUA
 static int l_get_tmpdir(lua_State *L)
 {
@@ -870,6 +884,7 @@  static const luaL_Reg l_swupdate[] = {
 static const luaL_Reg l_swupdate_bootenv[] = {
         { "get_bootenv", l_get_bootenv },
         { "set_bootenv", l_set_bootenv },
+        { "get_selection", l_get_selection },
         { NULL, NULL }
 };