/src/FreeRDP/libfreerdp/core/errbase.c
Line | Count | Source (jump to first uncovered line) |
1 | | /** |
2 | | * FreeRDP: A Remote Desktop Protocol Implementation |
3 | | * Error Base |
4 | | * |
5 | | * Copyright 2015 Armin Novak <armin.novak@thincast.com> |
6 | | * Copyright 2015 Thincast Technologies GmbH |
7 | | * |
8 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
9 | | * you may not use this file except in compliance with the License. |
10 | | * You may obtain a copy of the License at |
11 | | * |
12 | | * http://www.apache.org/licenses/LICENSE-2.0 |
13 | | * |
14 | | * Unless required by applicable law or agreed to in writing, software |
15 | | * distributed under the License is distributed on an "AS IS" BASIS, |
16 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17 | | * See the License for the specific language governing permissions and |
18 | | * limitations under the License. |
19 | | */ |
20 | | |
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 | | |
40 | | static const ERRINFO ERRBASE_CODES[] = { ERRBASE_DEFINE(SUCCESS), |
41 | | |
42 | | ERRBASE_DEFINE(NONE) }; |
43 | | |
44 | | const char* freerdp_get_error_base_string(UINT32 code) |
45 | 0 | { |
46 | 0 | for (size_t x = 0; x < ARRAYSIZE(ERRBASE_CODES); x++) |
47 | 0 | { |
48 | 0 | const ERRINFO* errInfo = &ERRBASE_CODES[x]; |
49 | |
|
50 | 0 | if (code == errInfo->code) |
51 | 0 | { |
52 | 0 | return errInfo->info; |
53 | 0 | } |
54 | 0 | } |
55 | | |
56 | 0 | return "ERRBASE_UNKNOWN"; |
57 | 0 | } |
58 | | |
59 | | const char* freerdp_get_error_base_category(UINT32 code) |
60 | 0 | { |
61 | 0 | for (size_t x = 0; x < ARRAYSIZE(ERRBASE_CODES); x++) |
62 | 0 | { |
63 | 0 | const ERRINFO* errInfo = &ERRBASE_CODES[x]; |
64 | 0 | if (code == errInfo->code) |
65 | 0 | { |
66 | 0 | return errInfo->category; |
67 | 0 | } |
68 | 0 | } |
69 | | |
70 | 0 | return "ERRBASE_UNKNOWN"; |
71 | 0 | } |
72 | | |
73 | | const char* freerdp_get_error_base_name(UINT32 code) |
74 | 0 | { |
75 | 0 | for (size_t x = 0; x < ARRAYSIZE(ERRBASE_CODES); x++) |
76 | 0 | { |
77 | 0 | const ERRINFO* errInfo = &ERRBASE_CODES[x]; |
78 | 0 | if (code == errInfo->code) |
79 | 0 | { |
80 | 0 | return errInfo->name; |
81 | 0 | } |
82 | 0 | } |
83 | | |
84 | 0 | return "ERRBASE_UNKNOWN"; |
85 | 0 | } |