diff options
author | 2018-09-04 10:20:18 +0200 | |
---|---|---|
committer | 2018-09-04 10:20:18 +0200 | |
commit | c33c8c220fae362a86d747bb5d91d02a9116d2c5 (patch) | |
tree | 19525c64cb4c842cd71e4bf9a59f533b6372a22e /ctl-lib/ctl-action.c | |
parent | a185e5cf960ec2083fc45048e93a3a22a02c094f (diff) |
controller: compatibility with v2
build it with AFB_BINDING_VERSION=0
Signed-off-by: Clément Bénier <clement.benier@iot.bzh>
Diffstat (limited to 'ctl-lib/ctl-action.c')
-rw-r--r-- | ctl-lib/ctl-action.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/ctl-lib/ctl-action.c b/ctl-lib/ctl-action.c index 8aa5dc7..9d71160 100644 --- a/ctl-lib/ctl-action.c +++ b/ctl-lib/ctl-action.c @@ -124,7 +124,6 @@ int ActionExecOne(CtlSourceT *source, CtlActionT* action, json_object *queryJ) { // Direct Request Call in APIV3 -#if (defined(AFB_BINDING_PREV3) || (AFB_BINDING_VERSION == 3)) static void ActionDynRequest(AFB_ReqT request) { @@ -140,7 +139,6 @@ static void ActionDynRequest(AFB_ReqT request) { // provide request and execute the action ActionExecOne(&source, action, queryJ); } -#endif void ParseURI(const char *uri, char **first, char **second) { @@ -297,7 +295,7 @@ static int BuildOneAction(AFB_ApiT apiHandle, CtlActionT *action, const char *ur // unpack individual action object -int ActionLoadOne(AFB_ApiT apiHandle, CtlActionT *action, json_object *actionJ, int exportApi) { +int ActionLoadOne_V3(AFB_ApiT apiHandle, CtlActionT *action, json_object *actionJ, int exportApi) { int err = 0; const char *uri = NULL; @@ -312,7 +310,6 @@ int ActionLoadOne(AFB_ApiT apiHandle, CtlActionT *action, json_object *actionJ, "args", &action->argsJ); if (!err) { // in API V3 each control is optionally map to a verb -#if (defined(AFB_BINDING_PREV3) || (AFB_BINDING_VERSION == 3)) if(!apiHandle) return -1; action->api = apiHandle; @@ -323,7 +320,6 @@ int ActionLoadOne(AFB_ApiT apiHandle, CtlActionT *action, json_object *actionJ, return -1; } } -#endif err = BuildOneAction(apiHandle, action, uri); } else { AFB_ApiError(apiHandle, "Fail to parse action JSON : (%s)", json_object_to_json_string(actionJ)); @@ -337,7 +333,7 @@ int ActionLoadOne(AFB_ApiT apiHandle, CtlActionT *action, json_object *actionJ, return err; } -CtlActionT *ActionConfig(AFB_ApiT apiHandle, json_object *actionsJ, int exportApi) { +CtlActionT *ActionConfig_V3(AFB_ApiT apiHandle, json_object *actionsJ, int exportApi) { int err; CtlActionT *actions; @@ -349,14 +345,14 @@ CtlActionT *ActionConfig(AFB_ApiT apiHandle, json_object *actionsJ, int exportAp for (int idx = 0; idx < count; idx++) { json_object *actionJ = json_object_array_get_idx(actionsJ, idx); - err = ActionLoadOne(apiHandle, &actions[idx], actionJ, exportApi); + err = ActionLoadOne_V3(apiHandle, &actions[idx], actionJ, exportApi); if (err) return NULL; } } else { actions = calloc(2, sizeof (CtlActionT)); - err = ActionLoadOne(apiHandle, &actions[0], actionsJ, exportApi); + err = ActionLoadOne_V3(apiHandle, &actions[0], actionsJ, exportApi); if (err) return NULL; } |