aboutsummaryrefslogtreecommitdiffstats
path: root/ctl-lib/ctl-plugin.c
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-05-16 15:05:09 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-12-13 15:02:54 +0100
commit240718d4dd333323af06ebae574427b1ee48290b (patch)
tree80b22435a16fa4aa1438e93008783476dc50ed36 /ctl-lib/ctl-plugin.c
parent26f992edfcb8159d81668db2292e1d776a8f0c7a (diff)
Change lua2c JSON syntax.
Clearer JSON writing config. Schema provide informations about objects Change-Id: I55e7c9bef442abaa577c59ab2005da1f315f9312 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'ctl-lib/ctl-plugin.c')
-rw-r--r--ctl-lib/ctl-plugin.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/ctl-lib/ctl-plugin.c b/ctl-lib/ctl-plugin.c
index 82d87e0..0029b68 100644
--- a/ctl-lib/ctl-plugin.c
+++ b/ctl-lib/ctl-plugin.c
@@ -281,23 +281,33 @@ static int PluginLoad (AFB_ApiT apiHandle, CtlPluginT *ctlPlugin, json_object *p
int err = 0, i = 0;
char *searchPath;
const char *sPath = NULL, *file = NULL, *lua2c_prefix = NULL;
- json_object *lua2csJ = NULL, *fileJ = NULL, *pluginPathJ = NULL;
+ json_object *luaJ = NULL, *lua2csJ = NULL, *fileJ = NULL, *pluginPathJ = NULL;
// plugin initialises at 1st load further init actions should be place into onload section
if (!pluginJ) return 0;
- err = wrap_json_unpack(pluginJ, "{ss,s?s,s?s,s?o,s?o,s?s !}",
+ err = wrap_json_unpack(pluginJ, "{ss,s?s,s?s,s?o,s?o !}",
"uid", &ctlPlugin->uid,
"info", &ctlPlugin->info,
"spath", &sPath,
- "files", &fileJ,
- "lua2c", &lua2csJ,
- "lua2c_prefix", &lua2c_prefix);
+ "libs", &fileJ,
+ "lua", &luaJ
+ );
if (err) {
- AFB_ApiError(apiHandle, "CTL-PLUGIN-LOADONE Plugin missing uid|[info]|file|[ldpath]|[lua2c] in:\n-- %s", json_object_get_string(pluginJ));
+ AFB_ApiError(apiHandle, "CTL-PLUGIN-LOADONE Plugin missing uid|[info]|libs|[spath]|[lua] in:\n-- %s", json_object_get_string(pluginJ));
return 1;
}
+ if(luaJ) {
+ err = wrap_json_unpack(luaJ, "{ss,s?o !}",
+ "prefix", &lua2c_prefix,
+ "functions", &lua2csJ);
+ if(err) {
+ AFB_ApiError(apiHandle, "CTL-PLUGIN-LOADONE Missing 'function' in:\n-- %s", json_object_get_string(pluginJ));
+ return 1;
+ }
+ }
+
// if search path not in Json config file, then try default
searchPath = (sPath) ?
strdup(sPath) :