aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-05-18 00:47:50 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-05-18 00:47:50 +0200
commit421c9096a9f27826c98871c5782ab0fa1033c091 (patch)
tree7331ead270c1843aa6aacae06246a057964c6e49
parentd22104c2a1beab2077848aea3c6a7aa63dbd1cd4 (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 simplify the processing avoiding the guess and deduction... Change-Id: I3197b4c7798589f4c62814407909270cdabd1dae Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--ctl-lib/ctl-lua.c14
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;
}