From c3fa161dd4ce60236153e827027b1e1f09e48033 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Tue, 4 Dec 2018 12:23:31 +0100 Subject: New function to retrieve Api's name from LUA Change-Id: I1678dced50f1cdaf3f2a3c9caff4aa5afa0c5b49 Signed-off-by: Romain Forlot --- ctl-lib/ctl-lua.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ctl-lib/ctl-lua.c b/ctl-lib/ctl-lua.c index b61885d..ac2b499 100644 --- a/ctl-lib/ctl-lua.c +++ b/ctl-lib/ctl-lua.c @@ -654,6 +654,20 @@ static int LuaAfbEventMake(lua_State* luaState) { return 1; } +static int LuaAfbGetApiName(lua_State* luaState) { + + CtlSourceT *source = LuaSourcePop(luaState, LUA_FIRST_ARG); + if (!source) { + lua_pushliteral(luaState, "LuaAfbEventSubscribe-Fail Invalid request handle"); + return 0; + } + + // extract and return afbSource from timer handle + lua_pushstring(luaState, source->api->apiname); + + return 1; // return argument +} + static int LuaAfbGetUid(lua_State* luaState) { CtlSourceT *source = LuaSourcePop(luaState, LUA_FIRST_ARG); @@ -1288,6 +1302,7 @@ static const luaL_Reg afbFunction[] = { {"subscribe", LuaAfbEventSubscribe}, {"evtmake", LuaAfbEventMake}, {"evtpush", LuaAfbEventPush}, + {"getapiname", LuaAfbGetApiName}, {"getuid", LuaAfbGetUid}, {"getrootdir", LuaAfbGetRootDir}, {"status", LuaAfbGetStatus}, -- cgit 1.2.3-korg