diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-05-18 00:47:50 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-12-13 15:02:54 +0100 |
commit | 2dbe7229f0956c5018392a1b331b6163fd72d7de (patch) | |
tree | c8f4ea6f120ba0ad06f2447d328bbed4cd568f6f /ctl-lib | |
parent | 934910288403aeb42ea9a54d112268dcfe906e3b (diff) |
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 <romain.forlot@iot.bzh>
Diffstat (limited to 'ctl-lib')
-rw-r--r-- | ctl-lib/ctl-lua.c | 14 |
1 files changed, 1 insertions, 13 deletions
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; } |