FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
errbase.c
1
21#include <freerdp/config.h>
22
23#include <stdio.h>
24
25#include <freerdp/log.h>
26
27#include "errinfo.h"
28
29#define ERRBASE_DEFINE(_code) \
30 { \
31 ERRBASE_##_code, "ERRBASE_" #_code, ERRBASE_##_code##_STRING, "" \
32 }
33
34/* Protocol-independent codes */
35
36/* Special codes */
37#define ERRBASE_SUCCESS_STRING "Success."
38#define ERRBASE_NONE_STRING ""
39
40static const ERRINFO ERRBASE_CODES[] = { ERRBASE_DEFINE(SUCCESS),
41
42 ERRBASE_DEFINE(NONE) };
43
44const char* freerdp_get_error_base_string(UINT32 code)
45{
46 for (size_t x = 0; x < ARRAYSIZE(ERRBASE_CODES); x++)
47 {
48 const ERRINFO* errInfo = &ERRBASE_CODES[x];
49
50 if (code == errInfo->code)
51 {
52 return errInfo->info;
53 }
54 }
55
56 return "ERRBASE_UNKNOWN";
57}
58
59const char* freerdp_get_error_base_category(UINT32 code)
60{
61 for (size_t x = 0; x < ARRAYSIZE(ERRBASE_CODES); x++)
62 {
63 const ERRINFO* errInfo = &ERRBASE_CODES[x];
64 if (code == errInfo->code)
65 {
66 return errInfo->category;
67 }
68 }
69
70 return "ERRBASE_UNKNOWN";
71}
72
73const char* freerdp_get_error_base_name(UINT32 code)
74{
75 for (size_t x = 0; x < ARRAYSIZE(ERRBASE_CODES); x++)
76 {
77 const ERRINFO* errInfo = &ERRBASE_CODES[x];
78 if (code == errInfo->code)
79 {
80 return errInfo->name;
81 }
82 }
83
84 return "ERRBASE_UNKNOWN";
85}