summaryrefslogtreecommitdiffstats
path: root/controller/ctl-plugin.c
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-26 12:17:55 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commitbbb4351eab7476be9a93f0248860ac0d1574d8a6 (patch)
tree1c5624454be5fc37828341b20de2f2e79fc90013 /controller/ctl-plugin.c
parent1480ff8d68ee4b923596d8178e37eba7b9202a30 (diff)
Make calling lua2c function from lua works
Change-Id: I56d78a3fe567d1f7a6c675f6a56473f96d325c85 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'controller/ctl-plugin.c')
-rw-r--r--controller/ctl-plugin.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/controller/ctl-plugin.c b/controller/ctl-plugin.c
index 550924f..1be97d4 100644
--- a/controller/ctl-plugin.c
+++ b/controller/ctl-plugin.c
@@ -173,14 +173,14 @@ STATIC int PluginLoadOne (CtlPluginT *ctlPlugin, json_object *pluginJ, void* han
return 0;
}
- int errCount = 0;
+ int errCount = 0, count = 0;
luaL_Reg *l2cFunc = NULL;
// look on l2c command and push them to LUA
if (json_object_get_type(lua2csJ) == json_type_array) {
int length = json_object_array_length(lua2csJ);
l2cFunc = calloc(length + 1, sizeof (luaL_Reg));
- for (int count = 0; count < length; count++) {
+ for (count = 0; count < length; count++) {
int err;
const char *l2cName = json_object_get_string(json_object_array_get_idx(lua2csJ, count));
err = Lua2cAddOne(l2cFunc, l2cName, count);
@@ -190,11 +190,19 @@ STATIC int PluginLoadOne (CtlPluginT *ctlPlugin, json_object *pluginJ, void* han
l2cFunc = calloc(2, sizeof (luaL_Reg));
const char *l2cName = json_object_get_string(lua2csJ);
errCount = Lua2cAddOne(l2cFunc, l2cName, 0);
+ count = 1;
}
if (errCount) {
AFB_ERROR("CTL-PLUGIN-LOADONE %d symbols not found in plugin='%s'", errCount, pluginpath);
goto OnErrorExit;
}
+ else {
+ ctlPlugin->l2cFunc = l2cFunc;
+ ctlPlugin->l2cCount = count;
+ LuaL2cNewLib (ctlPlugin->label,
+ ctlPlugin->l2cFunc,
+ ctlPlugin->l2cCount);
+ }
}
#endif