Coverage Report

Created: 2023-09-25 06:56

/src/FreeRDP/libfreerdp/utils/string.c
Line
Count
Source (jump to first uncovered line)
1
/**
2
 * FreeRDP: A Remote Desktop Protocol Implementation
3
 *
4
 * String Utils - Helper functions converting something to string
5
 *
6
 * Copyright 2022 Armin Novak <armin.novak@thincast.com>
7
 * Copyright 2022 Thincast Technologies GmbH
8
 *
9
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 *     http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20
 */
21
22
#include <freerdp/utils/string.h>
23
#include <freerdp/settings.h>
24
25
char* rdp_redirection_flags_to_string(UINT32 flags, char* buffer, size_t size)
26
0
{
27
0
  size_t x;
28
0
  struct map_t
29
0
  {
30
0
    UINT32 flag;
31
0
    const char* name;
32
0
  };
33
0
  const struct map_t map[] = {
34
0
    { LB_TARGET_NET_ADDRESS, "LB_TARGET_NET_ADDRESS" },
35
0
    { LB_LOAD_BALANCE_INFO, "LB_LOAD_BALANCE_INFO" },
36
0
    { LB_USERNAME, "LB_USERNAME" },
37
0
    { LB_DOMAIN, "LB_DOMAIN" },
38
0
    { LB_PASSWORD, "LB_PASSWORD" },
39
0
    { LB_DONTSTOREUSERNAME, "LB_DONTSTOREUSERNAME" },
40
0
    { LB_SMARTCARD_LOGON, "LB_SMARTCARD_LOGON" },
41
0
    { LB_NOREDIRECT, "LB_NOREDIRECT" },
42
0
    { LB_TARGET_FQDN, "LB_TARGET_FQDN" },
43
0
    { LB_TARGET_NETBIOS_NAME, "LB_TARGET_NETBIOS_NAME" },
44
0
    { LB_TARGET_NET_ADDRESSES, "LB_TARGET_NET_ADDRESSES" },
45
0
    { LB_CLIENT_TSV_URL, "LB_CLIENT_TSV_URL" },
46
0
    { LB_SERVER_TSV_CAPABLE, "LB_SERVER_TSV_CAPABLE" },
47
0
    { LB_PASSWORD_IS_PK_ENCRYPTED, "LB_PASSWORD_IS_PK_ENCRYPTED" },
48
0
    { LB_REDIRECTION_GUID, "LB_REDIRECTION_GUID" },
49
0
    { LB_TARGET_CERTIFICATE, "LB_TARGET_CERTIFICATE" },
50
0
  };
51
52
0
  for (x = 0; x < ARRAYSIZE(map); x++)
53
0
  {
54
0
    const struct map_t* cur = &map[x];
55
0
    if (flags & cur->flag)
56
0
    {
57
0
      if (!winpr_str_append(cur->name, buffer, size, "|"))
58
0
        return NULL;
59
0
    }
60
0
  }
61
0
  return buffer;
62
0
}
63
64
char* rdp_cluster_info_flags_to_string(UINT32 flags, char* buffer, size_t size)
65
0
{
66
0
  const UINT32 version = (flags & ServerSessionRedirectionVersionMask) >> 2;
67
0
  if (flags & REDIRECTION_SUPPORTED)
68
0
    winpr_str_append("REDIRECTION_SUPPORTED", buffer, size, "|");
69
0
  if (flags & REDIRECTED_SESSIONID_FIELD_VALID)
70
0
    winpr_str_append("REDIRECTED_SESSIONID_FIELD_VALID", buffer, size, "|");
71
0
  if (flags & REDIRECTED_SMARTCARD)
72
0
    winpr_str_append("REDIRECTED_SMARTCARD", buffer, size, "|");
73
74
0
  const char* str = NULL;
75
0
  switch (version)
76
0
  {
77
0
    case REDIRECTION_VERSION1:
78
0
      str = "REDIRECTION_VERSION1";
79
0
      break;
80
0
    case REDIRECTION_VERSION2:
81
0
      str = "REDIRECTION_VERSION2";
82
0
      break;
83
0
    case REDIRECTION_VERSION3:
84
0
      str = "REDIRECTION_VERSION3";
85
0
      break;
86
0
    case REDIRECTION_VERSION4:
87
0
      str = "REDIRECTION_VERSION4";
88
0
      break;
89
0
    case REDIRECTION_VERSION5:
90
0
      str = "REDIRECTION_VERSION5";
91
0
      break;
92
0
    case REDIRECTION_VERSION6:
93
0
      str = "REDIRECTION_VERSION6";
94
0
      break;
95
0
    default:
96
0
      str = "REDIRECTION_VERSION_UNKNOWN";
97
0
      break;
98
0
  }
99
0
  winpr_str_append(str, buffer, size, "|");
100
0
  {
101
0
    char msg[32] = { 0 };
102
0
    _snprintf(msg, sizeof(msg), "[0x%08" PRIx32 "]", flags);
103
0
    winpr_str_append(msg, buffer, size, "");
104
0
  }
105
0
  return buffer;
106
0
}