From 104e6e1249e44a8691a456a6c6903d7aa976ee9e Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 26 Aug 2022 19:27:00 +0200 Subject: [PATCH] Add WUPS_GetStorageStatusStr --- include/wups/storage.h | 2 ++ libraries/libwups/storage.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/wups/storage.h b/include/wups/storage.h index 41a1d8e..34750e9 100644 --- a/include/wups/storage.h +++ b/include/wups/storage.h @@ -48,6 +48,8 @@ typedef struct wups_loader_init_storage_args_t_ { /* called by backend */ void WUPS_InitStorage(wups_loader_init_storage_args_t args); +const char *WUPS_GetStorageStatusStr(WUPSStorageError status); + /* opens storage for reading and writing */ WUPSStorageError WUPS_OpenStorage(void); diff --git a/libraries/libwups/storage.cpp b/libraries/libwups/storage.cpp index d185326..28a0a71 100644 --- a/libraries/libwups/storage.cpp +++ b/libraries/libwups/storage.cpp @@ -29,6 +29,34 @@ void WUPS_InitStorage(wups_loader_init_storage_args_t args) { rootItem.type = WUPS_STORAGE_TYPE_ITEM; } +const char *WUPS_GetStorageStatusStr(WUPSStorageError status) { + switch (status) { + case WUPS_STORAGE_ERROR_SUCCESS: + return "WUPS_STORAGE_ERROR_SUCCESS"; + case WUPS_STORAGE_ERROR_NOT_OPENED: + return "WUPS_STORAGE_ERROR_NOT_OPENED"; + case WUPS_STORAGE_ERROR_ALREADY_OPENED: + return "WUPS_STORAGE_ERROR_ALREADY_OPENED"; + case WUPS_STORAGE_ERROR_INVALID_ARGS: + return "WUPS_STORAGE_ERROR_INVALID_ARGS"; + case WUPS_STORAGE_ERROR_NOT_FOUND: + return "WUPS_STORAGE_ERROR_NOT_FOUND"; + case WUPS_STORAGE_ERROR_NOT_INITIALIZED: + return "WUPS_STORAGE_ERROR_NOT_INITIALIZED"; + case WUPS_STORAGE_ERROR_INVALID_BACKEND_PARAMS: + return "WUPS_STORAGE_ERROR_INVALID_BACKEND_PARAMS"; + case WUPS_STORAGE_ERROR_INVALID_JSON: + return "WUPS_STORAGE_ERROR_INVALID_JSON"; + case WUPS_STORAGE_ERROR_IO: + return "WUPS_STORAGE_ERROR_IO"; + case WUPS_STORAGE_ERROR_B64_DECODE_FAILED: + return "WUPS_STORAGE_ERROR_B64_DECODE_FAILED"; + case WUPS_STORAGE_ERROR_BUFFER_TOO_SMALL: + return "WUPS_STORAGE_ERROR_BUFFER_TOO_SMALL"; + } + return "WUPS_STORAGE_ERROR_UNKNOWN"; +} + WUPSStorageError WUPS_OpenStorage(void) { if (!storage_initialized) { return WUPS_STORAGE_ERROR_NOT_INITIALIZED;