aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-11-23 19:00:23 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-11-24 19:12:00 +0100
commit0ed8e06bf1f34fe3c1e9b72170132f9f261f0fda (patch)
treea1022e9bd413a1832d80fb958c2ce03bdcdb24ce
parent22f4773ee8fda1ddff6638b1e4da672488b8d135 (diff)
Get back lua2c functions parsed at plugin load
Format JSON unpack operations Change-Id: Iaed0988d8536ad1df60a32a610e69e35485fc9f8 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--ctl-lib/ctl-action.c10
-rw-r--r--ctl-lib/ctl-lua.c12
-rw-r--r--ctl-lib/ctl-plugin.c15
3 files changed, 29 insertions, 8 deletions
diff --git a/ctl-lib/ctl-action.c b/ctl-lib/ctl-action.c
index 80e4484..41ce70b 100644
--- a/ctl-lib/ctl-action.c
+++ b/ctl-lib/ctl-action.c
@@ -136,8 +136,14 @@ PUBLIC int ActionLoadOne(AFB_ApiT apiHandle, CtlActionT *action, json_object *ac
int err, modeCount = 0;
json_object *callbackJ=NULL, *luaJ=NULL, *subcallJ=NULL;
- err = wrap_json_unpack(actionJ, "{ss,s?s,s?s,s?o,s?o,s?o,s?o !}"
- , "uid", &action->uid, "info", &action->info, "privileges", &action->privileges, "callback", &callbackJ, "lua", &luaJ, "subcall", &subcallJ, "args", &action->argsJ);
+ err = wrap_json_unpack(actionJ, "{ss,s?s,s?s,s?o,s?o,s?o,s?o !}",
+ "uid", &action->uid,
+ "info", &action->info,
+ "privileges", &action->privileges,
+ "callback", &callbackJ,
+ "lua", &luaJ,
+ "subcall", &subcallJ,
+ "args", &action->argsJ);
if (err) {
AFB_ApiError(apiHandle,"ACTION-LOAD-ONE Action missing uid|[info]|[callback]|[lua]|[subcall]|[args] in:\n-- %s", json_object_get_string(actionJ));
goto OnErrorExit;
diff --git a/ctl-lib/ctl-lua.c b/ctl-lib/ctl-lua.c
index 07b26bf..add4c0d 100644
--- a/ctl-lib/ctl-lua.c
+++ b/ctl-lib/ctl-lua.c
@@ -796,7 +796,11 @@ STATIC void LuaDoAction (LuaDoActionT action, AFB_ReqT request) {
// extract value from query
const char *target=NULL,*func=NULL;
json_object *argsJ=NULL;
- err= wrap_json_unpack (queryJ, "{s:s,s?s,s?s,s?o !}","target", &target,"path",&luaScriptPathJ,"function",&func,"args",&argsJ);
+ err= wrap_json_unpack (queryJ, "{s:s,s?s,s?s,s?o !}",
+ "target", &target,
+ "path",&luaScriptPathJ,
+ "function",&func,
+ "args",&argsJ);
if (err) {
AFB_ApiError(source->api, "LUA-DOSCRIPT-SYNTAX:missing target|[path]|[function]|[args] query=%s", json_object_get_string(queryJ));
goto OnErrorExit;
@@ -1023,7 +1027,11 @@ STATIC int LuaTimerSet(lua_State* luaState) {
goto OnErrorExit;
}
- int err = wrap_json_unpack(timerJ, "{ss, s?s si, si !}", "uid", &uid, "info", &info, "delay", &delay, "count", &count);
+ int err = wrap_json_unpack(timerJ, "{ss, s?s si, si !}",
+ "uid", &uid,
+ "info", &info,
+ "delay", &delay,
+ "count", &count);
if (err) {
lua_pushliteral(luaState, "LuaTimerSet: Syntax timerT={uid:xxx delay:ms, count:xx}");
diff --git a/ctl-lib/ctl-plugin.c b/ctl-lib/ctl-plugin.c
index 11df1e3..557f85e 100644
--- a/ctl-lib/ctl-plugin.c
+++ b/ctl-lib/ctl-plugin.c
@@ -36,7 +36,10 @@ PUBLIC int PluginGetCB (AFB_ApiT apiHandle, CtlActionT *action , json_object *ca
goto OnErrorExit;
}
- int err = wrap_json_unpack(callbackJ, "{ss,ss,s?s,s?o!}", "plugin", &plugin, "function", &function, "args", &argsJ);
+ int err = wrap_json_unpack(callbackJ, "{ss,ss,s?s,s?o!}",
+ "plugin", &plugin,
+ "function", &function,
+ "args", &argsJ);
if (err) {
AFB_ApiError(apiHandle, "PluginGet missing plugin|function|[args] in %s", json_object_get_string(callbackJ));
goto OnErrorExit;
@@ -86,10 +89,14 @@ STATIC int PluginLoadOne (AFB_ApiT apiHandle, CtlPluginT *ctlPlugin, json_object
// plugin initialises at 1st load further init actions should be place into onload section
if (!pluginJ) return 0;
- int err = wrap_json_unpack(pluginJ, "{ss,s?s,s?s,s?s !}",
- "uid", &ctlPlugin->uid, "info", &ctlPlugin->info, "ldpath", &ldSearchPath, "basename", &basename);
+ int err = wrap_json_unpack(pluginJ, "{ss,s?s,s?s,s?s,s?o !}",
+ "uid", &ctlPlugin->uid,
+ "info", &ctlPlugin->info,
+ "ldpath", &ldSearchPath,
+ "basename", &basename,
+ "lua2c", &lua2csJ);
if (err) {
- AFB_ApiError(apiHandle, "CTL-PLUGIN-LOADONE Plugin missing uid|[info]|[basename]|[ldpath] in:\n-- %s", json_object_get_string(pluginJ));
+ AFB_ApiError(apiHandle, "CTL-PLUGIN-LOADONE Plugin missing uid|[info]|basename|ldpath|[lua2c] in:\n-- %s", json_object_get_string(pluginJ));
goto OnErrorExit;
}