summaryrefslogtreecommitdiffstats
path: root/ctl-lib/ctl-onload.c
diff options
context:
space:
mode:
authorfulup <fulup.arfoll@iot.bzh>2017-10-18 11:31:33 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-12-13 15:02:54 +0100
commit2b77a50d5c578d92ac692b872f5a51c227c29334 (patch)
tree262f653a0369d080e2368bddd840e3c0fa089b29 /ctl-lib/ctl-onload.c
parent2da9781ef4b8c68b22a9a45aaa60c6e5b1e1142d (diff)
1st V2/pre-V3 version
Diffstat (limited to 'ctl-lib/ctl-onload.c')
-rw-r--r--ctl-lib/ctl-onload.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/ctl-lib/ctl-onload.c b/ctl-lib/ctl-onload.c
index 97bd109..1dec75a 100644
--- a/ctl-lib/ctl-onload.c
+++ b/ctl-lib/ctl-onload.c
@@ -23,29 +23,31 @@
#include "ctl-config.h"
// onload section receive one action or an array of actions
-PUBLIC int OnloadConfig(CtlSectionT *section, json_object *actionsJ) {
- CtlActionT *actions;
-
- // Load time parse actions in config file
+PUBLIC int OnloadConfig(AFB_ApiT apiHandle, CtlSectionT *section, json_object *actionsJ) {
+
+ // Load time parse actions in control file
if (actionsJ != NULL) {
- actions= ActionLoad(actionsJ);
- section->handle=actions;
+ section->actions= ActionConfig(apiHandle, actionsJ, 0);
- if (!actions) {
- AFB_ERROR ("OnloadLoad config fail processing onload actions");
+ if (!section->actions) {
+ AFB_ApiError (apiHandle, "OnloadConfig control fail processing onload actions");
goto OnErrorExit;
}
} else {
// Exec time process onload action now
- actions=(CtlActionT*)section->handle;
- if (!actions) {
- AFB_ERROR ("OnloadLoad Cannot Exec Non Existing Onload Action");
+ if (!section->actions) {
+ AFB_ApiError (apiHandle, "OnloadConfig Cannot Exec Non Existing Onload Action");
goto OnErrorExit;
}
- for (int idx=0; actions[idx].source.label != NULL; idx ++) {
- ActionExecOne(&actions[idx], NULL);
+ for (int idx=0; section->actions[idx].label != NULL; idx ++) {
+ CtlSourceT source;
+ source.label = section->actions[idx].label;
+ source.api = section->actions[idx].api;
+ source.request = AFB_ReqNone;
+
+ ActionExecOne(&source, &section->actions[idx], NULL);
}
}