diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2019-03-29 15:56:10 +0100 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2019-04-01 11:44:53 +0200 |
commit | f6e6432ed03ff76868efe57396036d3124881069 (patch) | |
tree | f69013eeb924ce7350de2ceab9b6ae03b1e4f80e /src/harvester-binding.c | |
parent | fb1f28adcf1cf90606ac31425e9370edfa9e70c2 (diff) |
Git submodule migration to separated libraries
- Replace controller binder functions definition with the binder ones.
and remove the last used submodules to use the separated libraries.
Bug-AGL: SPEC-2139
Change-Id: I0e354757dec692c13b49f02226fcf891953667f5
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/harvester-binding.c')
-rw-r--r-- | src/harvester-binding.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/harvester-binding.c b/src/harvester-binding.c index 36610b1..afa672e 100644 --- a/src/harvester-binding.c +++ b/src/harvester-binding.c @@ -20,11 +20,10 @@ #include <stdio.h> #include <string.h> #include <time.h> +#include <afb/afb-binding.h> -#include "harvester-binding.h" -// default api to print log when apihandle not avaliable -afb_dynapi *AFB_default; +#include "harvester-binding.h" // Config Section definition (note: controls section index should match handle // retrieval in HalConfigExec) @@ -36,30 +35,30 @@ static CtlSectionT ctrlSections[] = { {.key = NULL} }; -static void ctrlapi_ping(AFB_ReqT request) { +static void ctrlapi_ping(afb_req_t request) { static int count = 0; count++; - AFB_ReqNotice(request, "Controller:ping count=%d", count); - AFB_ReqSuccess(request, json_object_new_int(count), NULL); + AFB_REQ_NOTICE(request, "Controller:ping count=%d", count); + afb_req_success(request, json_object_new_int(count), NULL); return; } -static void ctrlapi_auth(AFB_ReqT request) +static void ctrlapi_auth(afb_req_t request) { - AFB_ReqSetLOA(request, 1); - AFB_ReqSuccess(request, NULL, NULL); + afb_req_session_set_LOA(request, 1); + afb_req_success(request, NULL, NULL); } -static AFB_ApiVerbs CtrlApiVerbs[] = { +static afb_verb_t CtrlApiVerbs[] = { /* VERB'S NAME FUNCTION TO CALL SHORT DESCRIPTION */ {.verb = "ping", .callback = ctrlapi_ping, .info = "ping test for API"}, {.verb = "auth", .callback = ctrlapi_auth, .info = "Authenticate session to raise Level Of Assurance of the session"}, {.verb = NULL} /* marker for end of the array */ }; -static int CtrlLoadStaticVerbs(afb_dynapi *apiHandle, AFB_ApiVerbs *verbs) { +static int CtrlLoadStaticVerbs(afb_dynapi *apiHandle, afb_verb_t *verbs) { int errcount = 0; for (int idx = 0; verbs[idx].verb; idx++) { @@ -71,15 +70,14 @@ static int CtrlLoadStaticVerbs(afb_dynapi *apiHandle, AFB_ApiVerbs *verbs) { return errcount; }; -static int CtrlInitOneApi(AFB_ApiT apiHandle) { +static int CtrlInitOneApi(afb_api_t apiHandle) { int err = 0; - AFB_default = apiHandle; // hugely hack to make all V2 AFB_DEBUG to work in fileutils // retrieve section config from api handle CtlConfigT *ctrlConfig = (CtlConfigT *)afb_dynapi_get_userdata(apiHandle); err = CtlConfigExec(apiHandle, ctrlConfig); if(err) { - AFB_ApiError(apiHandle, "Error at CtlConfigExec step"); + AFB_API_ERROR(apiHandle, "Error at CtlConfigExec step"); return err; } @@ -89,7 +87,7 @@ static int CtrlInitOneApi(AFB_ApiT apiHandle) { // next generation dynamic API-V3 mode #include <signal.h> -static int CtrlLoadOneApi(void *cbdata, AFB_ApiT apiHandle) { +static int CtrlLoadOneApi(void *cbdata, afb_api_t apiHandle) { CtlConfigT *ctrlConfig = (CtlConfigT *)cbdata; // save closure as api's data context @@ -98,7 +96,7 @@ static int CtrlLoadOneApi(void *cbdata, AFB_ApiT apiHandle) { // add static controls verbs int err = CtrlLoadStaticVerbs(apiHandle, CtrlApiVerbs); if (err) { - AFB_ApiError(apiHandle, "CtrlLoadSection fail to register static V2 verbs"); + AFB_API_ERROR(apiHandle, "CtrlLoadSection fail to register static V2 verbs"); return ERROR; } @@ -116,9 +114,7 @@ static int CtrlLoadOneApi(void *cbdata, AFB_ApiT apiHandle) { } int afbBindingEntry(afb_dynapi *apiHandle) { - - AFB_default = apiHandle; - AFB_ApiNotice(apiHandle, "Controller in afbBindingVdyn"); + AFB_API_NOTICE(apiHandle, "Controller in afbBindingVdyn"); const char *dirList = getenv("CONTROL_CONFIG_PATH"); if (!dirList) @@ -126,27 +122,27 @@ int afbBindingEntry(afb_dynapi *apiHandle) { const char *configPath = CtlConfigSearch(apiHandle, dirList, ""); if (!configPath) { - AFB_ApiError(apiHandle, "CtlPreInit: No %s* config found in %s ", GetBinderName(), dirList); + AFB_API_ERROR(apiHandle, "CtlPreInit: No %s* config found in %s ", GetBinderName(), dirList); return ERROR; } // load config file and create API CtlConfigT *ctrlConfig = CtlLoadMetaData(apiHandle, configPath); if (!ctrlConfig) { - AFB_ApiError(apiHandle, + AFB_API_ERROR(apiHandle, "CtrlBindingDyn No valid control config file in:\n-- %s", configPath); return ERROR; } if (!ctrlConfig->api) { - AFB_ApiError(apiHandle, + AFB_API_ERROR(apiHandle, "CtrlBindingDyn API Missing from metadata in:\n-- %s", configPath); return ERROR; } - AFB_ApiNotice(apiHandle, "Controller API='%s' info='%s'", ctrlConfig->api, + AFB_API_NOTICE(apiHandle, "Controller API='%s' info='%s'", ctrlConfig->api, ctrlConfig->info); // create one API per config file (Pre-V3 return code ToBeChanged) |