From ab89b4a133946980adc34b86858bebc0dcc7c713 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Mon, 18 Sep 2017 08:19:54 +0200 Subject: Good way to iterate over defined plugins Change-Id: Ifa3b14ea0f8bcd97347f4e5e6b99ef79f5b27dd4 Signed-off-by: Romain Forlot --- controller/ctl-config.h | 3 --- controller/ctl-plugin.c | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/controller/ctl-config.h b/controller/ctl-config.h index 7c3631c..590a265 100644 --- a/controller/ctl-config.h +++ b/controller/ctl-config.h @@ -49,8 +49,6 @@ extern "C" { #define CTL_PLUGIN_EXT ".ctlso" #endif - - typedef enum { CTL_TYPE_NONE=0, CTL_TYPE_API, @@ -58,7 +56,6 @@ typedef enum { CTL_TYPE_LUA, } CtlActionTypeT; - typedef struct { CtlActionTypeT type; const char* api; diff --git a/controller/ctl-plugin.c b/controller/ctl-plugin.c index 69f0f09..d982b79 100644 --- a/controller/ctl-plugin.c +++ b/controller/ctl-plugin.c @@ -35,7 +35,7 @@ typedef void *Lua2cWrapperT; #include "ctl-config.h" -static CtlPluginT *ctlPlugins=NULL; +static CtlPluginT *ctlPlugins=NULL; int PluginGetCB (CtlActionT *action , json_object *callbackJ) { const char *plugin=NULL, *function=NULL; @@ -221,12 +221,12 @@ int PluginConfig(CtlSectionT *section, json_object *pluginsJ) { if (ctlPlugins) { - int pluginsCount = (sizeof(ctlPlugins) / sizeof(CtlPluginT)) + 1; - for(int idx = 0; idx < pluginsCount; idx++) + int idx = 0; + while(ctlPlugins[idx].label != NULL) { // 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"); + struct afb_binding_data_v2 *afbHidenData = dlsym(ctlPlugins[idx++].dlHandle, "afbBindingV2data"); if (afbHidenData) *afbHidenData = afbBindingV2data; } return 0; -- cgit 1.2.3-korg