From 14576d207c567ec061dc7c8d00d76d8451a06c56 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 3 Sep 2022 17:37:50 +0200 Subject: [PATCH] Add ContentRedirection_GetStatusStr --- include/content_redirection/redirection.h | 2 ++ source/utils.cpp | 26 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/include/content_redirection/redirection.h b/include/content_redirection/redirection.h index 5ecbacf..e5acdc0 100644 --- a/include/content_redirection/redirection.h +++ b/include/content_redirection/redirection.h @@ -62,6 +62,8 @@ typedef enum ContentRedirectionApiErrorType { CONTENT_REDIRECTION_API_ERROR_LAYER_NOT_FOUND = -4, } ContentRedirectionApiErrorType; +const char *ContentRedirection_GetStatusStr(ContentRedirectionStatus status); + /** * This function has to be called before any other function of this lib (except ContentRedirection_GetVersion) can be used. * diff --git a/source/utils.cpp b/source/utils.cpp index 4bde71d..aab630b 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -14,6 +14,32 @@ static int (*sCRRemoveDevice)(const char *) static ContentRedirectionVersion sContentRedirectionVersion = CONTENT_REDIRECTION_MODULE_VERSION_ERROR; +const char *ContentRedirection_GetStatusStr(ContentRedirectionStatus status) { + switch (status) { + case CONTENT_REDIRECTION_RESULT_SUCCESS: + return "CONTENT_REDIRECTION_RESULT_SUCCESS"; + case CONTENT_REDIRECTION_RESULT_MODULE_NOT_FOUND: + return "CONTENT_REDIRECTION_RESULT_MODULE_NOT_FOUND"; + case CONTENT_REDIRECTION_RESULT_MODULE_MISSING_EXPORT: + return "CONTENT_REDIRECTION_RESULT_MODULE_MISSING_EXPORT"; + case CONTENT_REDIRECTION_RESULT_UNSUPPORTED_VERSION: + return "CONTENT_REDIRECTION_RESULT_UNSUPPORTED_VERSION"; + case CONTENT_REDIRECTION_RESULT_INVALID_ARGUMENT: + return "CONTENT_REDIRECTION_RESULT_INVALID_ARGUMENT"; + case CONTENT_REDIRECTION_RESULT_NO_MEMORY: + return "CONTENT_REDIRECTION_RESULT_NO_MEMORY"; + case CONTENT_REDIRECTION_RESULT_UNKNOWN_FS_LAYER_TYPE: + return "CONTENT_REDIRECTION_RESULT_UNKNOWN_FS_LAYER_TYPE"; + case CONTENT_REDIRECTION_RESULT_LAYER_NOT_FOUND: + return "CONTENT_REDIRECTION_RESULT_LAYER_NOT_FOUND"; + case CONTENT_REDIRECTION_RESULT_LIB_UNINITIALIZED: + return "CONTENT_REDIRECTION_RESULT_LIB_UNINITIALIZED"; + case CONTENT_REDIRECTION_RESULT_UNKNOWN_ERROR: + return "CONTENT_REDIRECTION_RESULT_UNKNOWN_ERROR"; + } + return "CONTENT_REDIRECTION_RESULT_UNKNOWN_ERROR"; +} + ContentRedirectionStatus ContentRedirection_InitLibrary() { if (OSDynLoad_Acquire("homebrew_content_redirection", &sModuleHandle) != OS_DYNLOAD_OK) { OSReport("ContentRedirection_Init: OSDynLoad_Acquire failed.\n");