diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-10-30 17:09:23 +0100 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2018-10-31 10:16:41 +0100 |
commit | 809495144f97fbc9e6dc98fdf71af6a413577982 (patch) | |
tree | 9498eec2d0504aacb3d796b85aa52137f47a7078 /ctl-lib | |
parent | 871bd64410e2a1a2b20d6d89a456a951e0370dd2 (diff) |
Retrieve plugin list from api rather than a global
Change-Id: Iba7c564eea48495c76de8ca919725a2e4b332fd6
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'ctl-lib')
-rw-r--r-- | ctl-lib/ctl-action.c | 5 | ||||
-rw-r--r-- | ctl-lib/ctl-config.c | 7 | ||||
-rw-r--r-- | ctl-lib/ctl-config.h | 3 | ||||
-rw-r--r-- | ctl-lib/ctl-plugin.c | 5 | ||||
-rw-r--r-- | ctl-lib/ctl-plugin.h | 2 |
5 files changed, 9 insertions, 13 deletions
diff --git a/ctl-lib/ctl-action.c b/ctl-lib/ctl-action.c index c1b7123..0bd9c7b 100644 --- a/ctl-lib/ctl-action.c +++ b/ctl-lib/ctl-action.c @@ -408,8 +408,3 @@ int AddActionsToSection(AFB_ApiT apiHandle, CtlSectionT *section, json_object *a } return 0; } - -int AddActionsToSectionFromPlugin(AFB_ApiT apiHandle, CtlPluginT *externalCtlPlugins, CtlSectionT *section, json_object *actionsJ, int exportApi) { - ctlPlugins = externalCtlPlugins; - return AddActionsToSection(apiHandle, section, actionsJ, exportApi); -} diff --git a/ctl-lib/ctl-config.c b/ctl-lib/ctl-config.c index accc608..532a2e8 100644 --- a/ctl-lib/ctl-config.c +++ b/ctl-lib/ctl-config.c @@ -187,11 +187,10 @@ CtlConfigT *CtlLoadMetaDataJson(AFB_ApiT apiHandle, json_object *ctlConfigJ, con free(ctlHandle); return NULL; } - } - ctlHandle->configJ = ctlConfigJ; - ctlHandle->prefix = prefix; - ctlHandle->ctlPlugins = &ctlPlugins; + ctlHandle->configJ = ctlConfigJ; + ctlHandle->prefix = prefix; + } return ctlHandle; } diff --git a/ctl-lib/ctl-config.h b/ctl-lib/ctl-config.h index 4bf82f9..1facf39 100644 --- a/ctl-lib/ctl-config.h +++ b/ctl-lib/ctl-config.h @@ -75,7 +75,7 @@ typedef struct { json_object *configJ; json_object *requireJ; CtlSectionT *sections; - CtlPluginT **ctlPlugins; + CtlPluginT *ctlPlugins; void *external; } CtlConfigT; @@ -92,7 +92,6 @@ typedef enum { // ctl-action.c extern int AddActionsToSection(AFB_ApiT apiHandle, CtlSectionT *section, json_object *actionsJ, int exportApi); -extern int AddActionsToSectionFromPlugin(AFB_ApiT apiHandle, CtlPluginT *externalCtlPlugins, CtlSectionT *section, json_object *actionsJ, int exportApi); extern CtlActionT *ActionConfig(AFB_ApiT apiHandle, json_object *actionsJ, int exportApi); extern void ActionExecUID(AFB_ReqT request, CtlConfigT *ctlConfig, const char *uid, json_object *queryJ); extern int ActionExecOne( CtlSourceT *source, CtlActionT* action, json_object *queryJ); diff --git a/ctl-lib/ctl-plugin.c b/ctl-lib/ctl-plugin.c index a632450..8eea0e0 100644 --- a/ctl-lib/ctl-plugin.c +++ b/ctl-lib/ctl-plugin.c @@ -37,6 +37,9 @@ int PluginGetCB (AFB_ApiT apiHandle, CtlActionT *action , json_object *callbackJ json_object *argsJ; int idx; + CtlConfigT *ctlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle); + CtlPluginT *ctlPlugins = ctlConfig->ctlPlugins; + if (!ctlPlugins) { AFB_ApiError(apiHandle, "PluginGetCB plugin section missing cannot call '%s'", json_object_get_string(callbackJ)); return 1; @@ -415,6 +418,8 @@ int PluginConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object *pluginsJ int idx = 0, jdx = 0; int pluginNb = 0, newPluginsNb = 0, totalPluginNb = 0; + CtlConfigT *ctlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle); + CtlPluginT *ctlPlugins = ctlConfig->ctlPlugins; if (ctlPlugins) { // There is something to add let that happens diff --git a/ctl-lib/ctl-plugin.h b/ctl-lib/ctl-plugin.h index d7ede8e..0ae6fbf 100644 --- a/ctl-lib/ctl-plugin.h +++ b/ctl-lib/ctl-plugin.h @@ -117,8 +117,6 @@ typedef struct { } exec; } CtlActionT; -extern CtlPluginT *ctlPlugins; - typedef int(*DispatchPluginInstallCbT)(CtlPluginT *plugin, void* handle); #define MACRO_STR_VALUE(arg) #arg |