diff options
-rw-r--r-- | src/4a-internals-hal/4a-internals-hal-api-loader.c | 39 | ||||
-rw-r--r-- | src/4a-internals-hal/4a-internals-hal-api-loader.h | 1 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/4a-internals-hal/4a-internals-hal-api-loader.c b/src/4a-internals-hal/4a-internals-hal-api-loader.c index a8b62c6..b41c7b2 100644 --- a/src/4a-internals-hal/4a-internals-hal-api-loader.c +++ b/src/4a-internals-hal/4a-internals-hal-api-loader.c @@ -291,4 +291,43 @@ int InternalHalCreateAllApi(afb_api_t apiHandle, struct HalMgrData *halMgrData) } return 0; +} + +int InternalHalDeleteAllApi(afb_api_t apiHandle, struct HalMgrData *halMgrData) +{ + int err; + + char *toDeleteApiName; + + struct HalData *currentHalData; + + if(! apiHandle || ! halMgrData) { + AFB_API_ERROR(apiHandle, "Invalid argument(s)"); + return -1; + } + + cds_list_for_each_entry(currentHalData, &halMgrData->halDataListHead, node) { + if(! currentHalData->apiName) + return -2; + + toDeleteApiName = strdup(currentHalData->apiName); + if(! toDeleteApiName) { + AFB_API_ERROR(apiHandle, "Didn't succeed to store (allocate) 'apiName' string"); + return -3; + } + + err = InternalHalDeleteApi(apiHandle, &halMgrData->halDataListHead, currentHalData); + if(err) { + AFB_API_ERROR(apiHandle, + "Error %i happened when tried to delete %s api", + err, + toDeleteApiName); + free(toDeleteApiName); + return -4; + } + + free(toDeleteApiName); + } + + return 0; }
\ No newline at end of file diff --git a/src/4a-internals-hal/4a-internals-hal-api-loader.h b/src/4a-internals-hal/4a-internals-hal-api-loader.h index 1628e8a..2a47555 100644 --- a/src/4a-internals-hal/4a-internals-hal-api-loader.h +++ b/src/4a-internals-hal/4a-internals-hal-api-loader.h @@ -28,5 +28,6 @@ int InternalHalCreateApi(afb_api_t apiHandle, char *path, struct HalMgrData *halMgrData); int InternalHalDeleteApi(afb_api_t apiHandle, struct cds_list_head *halDataListHead, struct HalData *toDeleteHalData); int InternalHalCreateAllApi(afb_api_t apiHandle, struct HalMgrData *halMgrData); +int InternalHalDeleteAllApi(afb_api_t apiHandle, struct HalMgrData *halMgrData); #endif /* _INTERNALS_HAL_API_LOADER_INCLUDE_ */
\ No newline at end of file |