aboutsummaryrefslogtreecommitdiffstats
path: root/ctl-lib
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 13:52:47 +0000
commita0704895ec6a6ed6ad6620fbef290eeeb0c103bf (patch)
treec8f4ea6f120ba0ad06f2447d328bbed4cd568f6f /ctl-lib
parentdcc27f25fb8c4ec4ee5074da5dbf3acf7b24bdc4 (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.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;
}