aboutsummaryrefslogtreecommitdiffstats
path: root/controller/ctl-plugin.c
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-15 16:29:17 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commit677cde6288a4574b8251a4a532b1d9e1594b09b2 (patch)
treec510a0cdd76e2b8de1cdaf254fd270c8bfebae42 /controller/ctl-plugin.c
parenteabae24ea592420de46e36f0b1af5d39eee5b8a4 (diff)
Subscription by plugin to signals
Change-Id: Icb923f87df2be8eb664106bc9077b3a8221dd3ce Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'controller/ctl-plugin.c')
-rw-r--r--controller/ctl-plugin.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/controller/ctl-plugin.c b/controller/ctl-plugin.c
index ae203af..b14d591 100644
--- a/controller/ctl-plugin.c
+++ b/controller/ctl-plugin.c
@@ -153,10 +153,6 @@ STATIC int PluginLoadOne (CtlPluginT *ctlPlugin, json_object *pluginJ, void* han
// store dlopen handle to enable onload action at exec time
ctlPlugin->dlHandle = dlHandle;
- // Jose hack to make verbosity visible from sharedlib
- struct afb_binding_data_v2 *afbHidenData = dlsym(dlHandle, "afbBindingV2data");
- if (afbHidenData) *afbHidenData = afbBindingV2data;
-
// Push lua2cWrapper @ into plugin
Lua2cWrapperT *lua2cInPlug = dlsym(dlHandle, "Lua2cWrap");
#ifndef CONTROL_SUPPORT_LUA
@@ -219,16 +215,31 @@ OnErrorExit:
int PluginConfig(CtlSectionT *section, json_object *pluginsJ) {
int err=0;
- if (json_object_get_type(pluginsJ) == json_type_array) {
- int length = json_object_array_length(pluginsJ);
- ctlPlugins = calloc (length+1, sizeof(CtlPluginT));
- for (int idx=0; idx < length; idx++) {
- json_object *pluginJ = json_object_array_get_idx(pluginsJ, idx);
- err += PluginLoadOne(&ctlPlugins[idx], pluginJ, section->handle);
+ if (ctlPlugins)
+ {
+ int pluginsCount = (sizeof(ctlPlugins) / sizeof(CtlPluginT)) + 1;
+ for(int idx = 0; idx < pluginsCount; idx++)
+ {
+ // Jose hack to make verbosity visible from sharedlib and
+ // be able to call verb from others api inside the binder
+ struct afb_binding_data_v2 *afbHidenData = dlsym(ctlPlugins[idx].dlHandle, "afbBindingV2data");
+ if (afbHidenData) *afbHidenData = afbBindingV2data;
+ }
+ return 0;
+ }
+ else
+ {
+ if (json_object_get_type(pluginsJ) == json_type_array) {
+ int length = json_object_array_length(pluginsJ);
+ ctlPlugins = calloc (length+1, sizeof(CtlPluginT));
+ for (int idx=0; idx < length; idx++) {
+ json_object *pluginJ = json_object_array_get_idx(pluginsJ, idx);
+ err += PluginLoadOne(&ctlPlugins[idx], pluginJ, section->handle);
+ }
+ } else {
+ ctlPlugins = calloc (2, sizeof(CtlPluginT));
+ err += PluginLoadOne(&ctlPlugins[0], pluginsJ, section->handle);
}
- } else {
- ctlPlugins = calloc (2, sizeof(CtlPluginT));
- err += PluginLoadOne(&ctlPlugins[0], pluginsJ, section->handle);
}
return err;