Coverage Report

Created: 2024-05-20 06:11

/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 TAG FREERDP_TAG("core")
30
31
#define ERRBASE_DEFINE(_code)                                            \
32
  {                                                                    \
33
    ERRBASE_##_code, "ERRBASE_" #_code, ERRBASE_##_code##_STRING, "" \
34
  }
35
36
/* Protocol-independent codes */
37
38
/* Special codes */
39
#define ERRBASE_SUCCESS_STRING "Success."
40
#define ERRBASE_NONE_STRING ""
41
42
static const ERRINFO ERRBASE_CODES[] = { ERRBASE_DEFINE(SUCCESS),
43
44
                                       ERRBASE_DEFINE(NONE) };
45
46
const char* freerdp_get_error_base_string(UINT32 code)
47
0
{
48
0
  const ERRINFO* errInfo = NULL;
49
50
0
  errInfo = &ERRBASE_CODES[0];
51
52
0
  while (errInfo->code != ERRBASE_NONE)
53
0
  {
54
0
    if (code == errInfo->code)
55
0
    {
56
0
      return errInfo->info;
57
0
    }
58
59
0
    errInfo++;
60
0
  }
61
62
0
  return "ERRBASE_UNKNOWN";
63
0
}
64
65
const char* freerdp_get_error_base_category(UINT32 code)
66
0
{
67
0
  const ERRINFO* errInfo = NULL;
68
69
0
  errInfo = &ERRBASE_CODES[0];
70
71
0
  while (errInfo->code != ERRBASE_NONE)
72
0
  {
73
0
    if (code == errInfo->code)
74
0
    {
75
0
      return errInfo->category;
76
0
    }
77
78
0
    errInfo++;
79
0
  }
80
81
0
  return "ERRBASE_UNKNOWN";
82
0
}
83
84
const char* freerdp_get_error_base_name(UINT32 code)
85
0
{
86
0
  const ERRINFO* errInfo = NULL;
87
88
0
  errInfo = &ERRBASE_CODES[0];
89
90
0
  while (errInfo->code != ERRBASE_NONE)
91
0
  {
92
0
    if (code == errInfo->code)
93
0
    {
94
0
      return errInfo->name;
95
0
    }
96
97
0
    errInfo++;
98
0
  }
99
100
0
  return "ERRBASE_UNKNOWN";
101
0
}