From 7af94b8a6f953ed247815bf15049fe951817a21e Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Wed, 16 May 2018 15:05:09 +0200 Subject: Change lua2c JSON syntax. Clearer JSON writing config. Schema provide informations about objects Change-Id: I55e7c9bef442abaa577c59ab2005da1f315f9312 Signed-off-by: Romain Forlot --- ctl-lib/ctl-plugin.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'ctl-lib/ctl-plugin.c') 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) : -- cgit 1.2.3-korg