diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-09-18 08:19:54 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-12-14 11:00:25 +0100 |
commit | ab89b4a133946980adc34b86858bebc0dcc7c713 (patch) | |
tree | 1eecbfaded45e210fd2cba04e6e3b6999331208e | |
parent | 12097251ec058b1fa9d9202998c829b27ee5554f (diff) |
Good way to iterate over defined plugins
Change-Id: Ifa3b14ea0f8bcd97347f4e5e6b99ef79f5b27dd4
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r-- | controller/ctl-config.h | 3 | ||||
-rw-r--r-- | 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; |