diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-05-16 15:05:09 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-05-16 15:12:53 +0200 |
commit | 7af94b8a6f953ed247815bf15049fe951817a21e (patch) | |
tree | 80b22435a16fa4aa1438e93008783476dc50ed36 /ctl-lib | |
parent | 8f7e2014d030eb5117be6bac1aae88cd10e2127a (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')
-rw-r--r-- | ctl-lib/ctl-plugin.c | 22 |
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) : |