From 7df6f7dd70ffc7f073e466cc7e3788276c148e2e Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Sat, 21 Jul 2018 00:48:25 +0200 Subject: DynAPI > V3 migration of afb-test binding. Controller is still using dynapi and preV3 version. This is a preparation for future controller update to V3 Submodule app-controller-submodule 88892db..b79a761: > Split loading JSON controller file. > Release arguments once C function returned. > Fix : typo introduced in a previous commit. > Fixed character counting that was shortening paths > Keep json unmodified during action execution Change-Id: Iba37b3fbd35e58973b9601a7f91bfdb61abcf76f Signed-off-by: Romain Forlot --- app-controller-submodule | 2 +- src/aft.c | 26 +++++++++++++------------- src/mapis.c | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app-controller-submodule b/app-controller-submodule index 88892db..b79a761 160000 --- a/app-controller-submodule +++ b/app-controller-submodule @@ -1 +1 @@ -Subproject commit 88892db78f2f5b047923af5b36169052c96bc3c0 +Subproject commit b79a76136974423445f647db9f04c236938401ce diff --git a/src/aft.c b/src/aft.c index d72e165..3ce4c0f 100644 --- a/src/aft.c +++ b/src/aft.c @@ -26,7 +26,7 @@ #define CONTROL_PREFIX "aft" // default api to print log when apihandle not avaliable -afb_dynapi *AFB_default; +afb_api_t AFB_default; static int CtrlCreateApi(AFB_ApiT apiHandle, const char *configPath); // Config Section definition @@ -70,13 +70,13 @@ static AFB_ApiVerbs CtrlApiVerbs[] = { {.verb = NULL} /* marker for end of the array */ }; -static int CtrlLoadStaticVerbs(afb_dynapi *apiHandle, AFB_ApiVerbs *verbs) { +static int CtrlLoadStaticVerbs(afb_api_t apiHandle, AFB_ApiVerbs *verbs) { int errcount = 0; for(int idx = 0; verbs[idx].verb; idx++) { - errcount += afb_dynapi_add_verb( + errcount += afb_api_add_verb( apiHandle, CtrlApiVerbs[idx].verb, NULL, CtrlApiVerbs[idx].callback, - (void *)&CtrlApiVerbs[idx], CtrlApiVerbs[idx].auth, 0); + (void *)&CtrlApiVerbs[idx], CtrlApiVerbs[idx].auth, 0, 0); } return errcount; @@ -86,7 +86,7 @@ static int CtrlInitOneApi(AFB_ApiT apiHandle) { // Hugely hack to make all V2 AFB_DEBUG to work in fileutils AFB_default = apiHandle; - CtlConfigT *ctrlConfig = afb_dynapi_get_userdata(apiHandle); + CtlConfigT *ctrlConfig = afb_api_get_userdata(apiHandle); return CtlConfigExec(apiHandle, ctrlConfig); } @@ -98,7 +98,7 @@ static int CtrlLoadOneApi(void *cbdata, AFB_ApiT apiHandle) { CtlConfigT *ctrlConfig = (CtlConfigT *)cbdata; // save closure as api's data context - afb_dynapi_set_userdata(apiHandle, ctrlConfig); + afb_api_set_userdata(apiHandle, ctrlConfig); // add static controls verbs int err = CtrlLoadStaticVerbs(apiHandle, CtrlApiVerbs); @@ -111,12 +111,12 @@ static int CtrlLoadOneApi(void *cbdata, AFB_ApiT apiHandle) { err = CtlLoadSections(apiHandle, ctrlConfig, ctrlSections); // declare an event event manager for this API; - afb_dynapi_on_event(apiHandle, CtrlDispatchApiEvent); + afb_api_on_event(apiHandle, CtrlDispatchApiEvent); // init API function (does not receive user closure ??? - afb_dynapi_on_init(apiHandle, CtrlInitOneApi); + afb_api_on_init(apiHandle, CtrlInitOneApi); - afb_dynapi_seal(apiHandle); + afb_api_seal(apiHandle); return err; } @@ -158,12 +158,12 @@ static int CtrlCreateApi(AFB_ApiT apiHandle, const char *configPath) { wrap_json_object_add(ctrlConfig->configJ, resourcesJ); wrap_json_object_add(ctrlConfig->configJ, eventsJ); - err = afb_dynapi_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, CtrlLoadOneApi, ctrlConfig); - - return err; + if(afb_api_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, CtrlLoadOneApi, ctrlConfig)) + return err; + return -1; } -int afbBindingEntry(afb_dynapi *apiHandle) { +int afbBindingEntry(afb_api_t apiHandle) { size_t len = 0; char *dirList; const char *envDirList = NULL, *configPath = NULL; diff --git a/src/mapis.c b/src/mapis.c index 64543e5..0c2a4aa 100644 --- a/src/mapis.c +++ b/src/mapis.c @@ -32,7 +32,7 @@ static int LoadOneMapi(void *data, AFB_ApiT apiHandle) { int savedCount = 0, count = 0, idx = 0; CtlActionT *savedActions = NULL, *newActions = NULL; struct mapisHandleT *mapisHandle = (struct mapisHandleT*)data; - CtlConfigT *ctrlConfig = afb_dynapi_get_userdata(mapisHandle->mainApiHandle); + CtlConfigT *ctrlConfig = afb_api_get_userdata(mapisHandle->mainApiHandle); if(PluginConfig(apiHandle, mapisHandle->section, mapisHandle->mapiJ)) { AFB_ApiError(apiHandle, "Problem loading the plugin as an API for %s, see log message above", json_object_get_string(mapisHandle->mapiJ)); @@ -83,7 +83,7 @@ static int LoadOneMapi(void *data, AFB_ApiT apiHandle) { ctrlConfig->sections[idx].actions = mergedActions; // declare an event event manager for this API; - afb_dynapi_on_event(apiHandle, CtrlDispatchApiEvent); + afb_api_on_event(apiHandle, CtrlDispatchApiEvent); return 0; } @@ -112,7 +112,7 @@ static void OneMapiConfig(void *data, json_object *mapiJ) { json_object_object_del(mapiJ, "events"); mapisHandle->mapiJ = mapiJ; - if (afb_dynapi_new_api(mapisHandle->mainApiHandle, uid, info, 1, LoadOneMapi, (void*)mapisHandle)) { + if (afb_api_new_api(mapisHandle->mainApiHandle, uid, info, 1, LoadOneMapi, (void*)mapisHandle)) { AFB_ApiError(mapisHandle->mainApiHandle, "Error creating new api: %s", uid); return; } -- cgit 1.2.3-korg