From d8cdac44f187ad8a5c036b09370eeac08f923550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 22 Jul 2013 13:23:56 -0400 Subject: [PATCH] libfreerdp-core: export function to retrieve error info from static entry table --- include/freerdp/error.h | 7 +++++++ libfreerdp/core/errinfo.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/include/freerdp/error.h b/include/freerdp/error.h index 8b0abd8f0..628e1e3b9 100644 --- a/include/freerdp/error.h +++ b/include/freerdp/error.h @@ -20,6 +20,10 @@ #ifndef FREERDP_ERROR_H #define FREERDP_ERROR_H +#include + +#include + #ifdef __cplusplus extern "C" { #endif @@ -128,6 +132,9 @@ extern "C" { #define ERRINFO_SUCCESS 0x00000000 #define ERRINFO_NONE 0xFFFFFFFF +FREERDP_API const char* freerdp_get_error_info_string(UINT32 code); +FREERDP_API const char* freerdp_get_error_info_name(UINT32 code); + /** * This static variable holds an error code if the return value from connect is FALSE. * This variable is always set to 0 in the beginning of the connect sequence. diff --git a/libfreerdp/core/errinfo.c b/libfreerdp/core/errinfo.c index 2b78dbc51..da028318a 100644 --- a/libfreerdp/core/errinfo.c +++ b/libfreerdp/core/errinfo.c @@ -443,6 +443,44 @@ static const ERRINFO ERRINFO_CODES[] = ERRINFO_DEFINE(NONE) }; +const char* freerdp_get_error_info_string(UINT32 code) +{ + const ERRINFO* errInfo; + + errInfo = &ERRINFO_CODES[0]; + + while (errInfo->code != ERRINFO_NONE) + { + if (code == errInfo->code) + { + return errInfo->info; + } + + errInfo++; + } + + return "Unknown error."; +} + +const char* freerdp_get_error_info_name(UINT32 code) +{ + const ERRINFO* errInfo; + + errInfo = &ERRINFO_CODES[0]; + + while (errInfo->code != ERRINFO_NONE) + { + if (code == errInfo->code) + { + return errInfo->name; + } + + errInfo++; + } + + return "ERRINFO_UNKNOWN"; +} + void rdp_print_errinfo(UINT32 code) { const ERRINFO* errInfo;