From 2dbe7229f0956c5018392a1b331b6163fd72d7de Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Fri, 18 May 2018 00:47:50 +0200 Subject: Make action item from a LUA action mandatory It is already mandatory from a JSON schema point of view so here it should be the same. Also it simplifies the process avoiding the guess and deduction... Change-Id: I3197b4c7798589f4c62814407909270cdabd1dae Signed-off-by: Romain Forlot --- ctl-lib/ctl-lua.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'ctl-lib/ctl-lua.c') diff --git a/ctl-lib/ctl-lua.c b/ctl-lib/ctl-lua.c index 449ae09..15e1fd8 100644 --- a/ctl-lib/ctl-lua.c +++ b/ctl-lib/ctl-lua.c @@ -745,12 +745,11 @@ static int LuaDoScript(json_object *queryJ, CtlSourceT *source) { json_object *argsJ = NULL; static json_object *luaScriptPathJ = NULL; - if (!queryJ) { return -1; } - err = wrap_json_unpack(queryJ, "{s:s,s?s,s?s,s?o !}", + err = wrap_json_unpack(queryJ, "{s:s,s?s,ss,s?o !}", "uid", &uid, "spath", &luaScriptPathJ, "action", &func, @@ -796,17 +795,6 @@ static int LuaDoScript(json_object *queryJ, CtlSourceT *source) { err = LuaLoadScript(luaScriptPath); if (err) { AFB_ApiError(source->api, "LUA-DOSCRIPT HOOPs Error in LUA loading scripts=%s err=%s", luaScriptPath, lua_tostring(luaState, -1)); - return err; - } - - // if no func name given try to deduct from filename - if (!func && (func = (char*) GetMidleName(filename)) != NULL) { - strncpy(luaScriptPath, "_", CONTROL_MAXPATH_LEN - 1); - strncat(luaScriptPath, func, CONTROL_MAXPATH_LEN - strlen(luaScriptPath) - 1); - func = luaScriptPath; - } - if (!func) { - AFB_ApiError(source->api, "LUA-DOSCRIPT:FAIL to deduct funcname from %s", filename); return -1; } -- cgit 1.2.3-korg