summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2019-10-11 15:21:50 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2019-10-17 11:29:21 +0200
commit6baf3d19cfb593359d951c4353a48910802f73a2 (patch)
treeefa98f52a1dc013a72ed9860fc61916dc5e41fa1
parentf540130618e106d79b5eef0ef548d761a4585632 (diff)
Add a function to delete all hal api
BUG-AGL: SPEC-2893 Change-Id: I577565ac2134f87151491644c74c057e3634ed52 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
-rw-r--r--src/4a-internals-hal/4a-internals-hal-api-loader.c39
-rw-r--r--src/4a-internals-hal/4a-internals-hal-api-loader.h1
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