23 #include <freerdp/config.h>
30 #include <winpr/crt.h>
31 #include <winpr/assert.h>
33 #include "../core/settings.h"
34 #include "../core/capabilities.h"
36 #include <freerdp/crypto/certificate.h>
37 #include <freerdp/settings.h>
38 #include <freerdp/freerdp.h>
39 #include <freerdp/log.h>
41 #define TAG FREERDP_TAG("common")
43 BOOL freerdp_addin_argv_add_argument_ex(
ADDIN_ARGV* args,
const char* argument,
size_t len)
46 char** new_argv = NULL;
48 if (!args || !argument)
52 len = strlen(argument);
54 new_argv = (
char**)realloc((
void*)args->argv,
sizeof(
char*) * (args->argc + 1));
59 args->argv = new_argv;
61 str = calloc(len + 1,
sizeof(
char));
64 memcpy(str, argument, len);
65 args->argv[args->argc++] = str;
69 BOOL freerdp_addin_argv_add_argument(
ADDIN_ARGV* args,
const char* argument)
71 return freerdp_addin_argv_add_argument_ex(args, argument, 0);
74 BOOL freerdp_addin_argv_del_argument(
ADDIN_ARGV* args,
const char* argument)
76 if (!args || !argument)
78 for (
int x = 0; x < args->argc; x++)
80 char* arg = args->argv[x];
81 if (strcmp(argument, arg) == 0)
84 memmove_s((
void*)&args->argv[x], (args->argc - x) *
sizeof(
char*),
85 (
void*)&args->argv[x + 1], (args->argc - x - 1) *
sizeof(
char*));
86 args->argv[args->argc - 1] = NULL;
94 int freerdp_addin_set_argument(
ADDIN_ARGV* args,
const char* argument)
96 if (!args || !argument)
99 for (
int i = 0; i < args->argc; i++)
101 if (strcmp(args->argv[i], argument) == 0)
107 if (!freerdp_addin_argv_add_argument(args, argument))
112 int freerdp_addin_replace_argument(
ADDIN_ARGV* args,
const char* previous,
const char* argument)
114 if (!args || !previous || !argument)
117 for (
int i = 0; i < args->argc; i++)
119 if (strcmp(args->argv[i], previous) == 0)
123 if (!(args->argv[i] = _strdup(argument)))
130 if (!freerdp_addin_argv_add_argument(args, argument))
135 int freerdp_addin_set_argument_value(
ADDIN_ARGV* args,
const char* option,
const char* value)
141 if (!args || !option || !value)
143 length = strlen(option) + strlen(value) + 1;
144 str = (
char*)calloc(length + 1,
sizeof(
char));
149 (void)sprintf_s(str, length + 1,
"%s:%s", option, value);
151 for (
int i = 0; i < args->argc; i++)
153 p = strchr(args->argv[i],
':');
157 if (strncmp(args->argv[i], option, p - args->argv[i]) == 0)
166 rc = freerdp_addin_argv_add_argument(args, str);
173 int freerdp_addin_replace_argument_value(
ADDIN_ARGV* args,
const char* previous,
const char* option,
179 if (!args || !previous || !option || !value)
181 length = strlen(option) + strlen(value) + 1;
182 str = (
char*)calloc(length + 1,
sizeof(
char));
187 (void)sprintf_s(str, length + 1,
"%s:%s", option, value);
189 for (
int i = 0; i < args->argc; i++)
191 if (strcmp(args->argv[i], previous) == 0)
199 rc = freerdp_addin_argv_add_argument(args, str);
206 BOOL freerdp_device_collection_add(rdpSettings* settings,
RDPDR_DEVICE* device)
210 WINPR_ASSERT(settings);
211 WINPR_ASSERT(device);
217 UINT32 new_size = old * 2;
221 new_size = count * 2;
229 settings->DeviceArray = new_array;
230 memset((
void*)&settings->DeviceArray[old], 0, (new_size - old) *
sizeof(
RDPDR_DEVICE*));
236 settings->DeviceArray[settings->DeviceCount++] = device;
242 WINPR_ASSERT(settings);
247 const UINT32 count = settings->DeviceCount;
248 for (
size_t x = 0; x < count; x++)
253 for (
size_t y = x + 1; y < count; y++)
256 settings->DeviceArray[y - 1] = next;
258 settings->DeviceArray[count - 1] = NULL;
259 settings->DeviceCount--;
267 RDPDR_DEVICE* freerdp_device_collection_find(rdpSettings* settings,
const char* name)
271 WINPR_ASSERT(settings);
273 for (UINT32 index = 0; index < settings->DeviceCount; index++)
275 device = settings->DeviceArray[index];
280 if (strcmp(device->Name, name) == 0)
287 RDPDR_DEVICE* freerdp_device_collection_find_type(rdpSettings* settings, UINT32 type)
290 WINPR_ASSERT(settings);
292 for (UINT32 index = 0; index < settings->DeviceCount; index++)
294 device = settings->DeviceArray[index];
296 if (device->Type == type)
303 RDPDR_DEVICE* freerdp_device_new(UINT32 Type,
size_t count,
const char*
const args[])
317 WINPR_ASSERT(args || (count == 0));
321 case RDPDR_DTYP_PRINT:
324 case RDPDR_DTYP_SERIAL:
327 case RDPDR_DTYP_PARALLEL:
330 case RDPDR_DTYP_SMARTCARD:
333 case RDPDR_DTYP_FILESYSTEM:
340 device.base = calloc(1, size);
344 device.base->Type = Type;
348 device.base->Name = _strdup(args[0]);
349 if (!device.base->Name)
354 case RDPDR_DTYP_PRINT:
357 device.printer->DriverName = _strdup(args[1]);
358 if (!device.printer->DriverName)
364 device.printer->IsDefault = _stricmp(args[2],
"default") == 0;
367 case RDPDR_DTYP_SERIAL:
370 device.serial->Path = _strdup(args[1]);
371 if (!device.serial->Path)
377 device.serial->Driver = _strdup(args[2]);
378 if (!device.serial->Driver)
384 device.serial->Permissive = _strdup(args[3]);
385 if (!device.serial->Permissive)
389 case RDPDR_DTYP_PARALLEL:
392 device.parallel->Path = _strdup(args[1]);
393 if (!device.serial->Path)
397 case RDPDR_DTYP_SMARTCARD:
399 case RDPDR_DTYP_FILESYSTEM:
402 device.drive->Path = _strdup(args[1]);
403 if (!device.drive->Path)
407 device.drive->automount = (args[2] == NULL) ? TRUE : FALSE;
416 freerdp_device_free(device.base);
437 switch (device->Type)
439 case RDPDR_DTYP_PRINT:
440 free(cnv.printer->DriverName);
442 case RDPDR_DTYP_SERIAL:
443 free(cnv.serial->Path);
444 free(cnv.serial->Driver);
445 free(cnv.serial->Permissive);
447 case RDPDR_DTYP_PARALLEL:
448 free(cnv.parallel->Path);
450 case RDPDR_DTYP_SMARTCARD:
452 case RDPDR_DTYP_FILESYSTEM:
453 free(cnv.drive->Path);
484 const char* args[4] = { 0 };
495 args[0] = device->Name;
498 switch (device->Type)
500 case RDPDR_DTYP_FILESYSTEM:
503 args[1] = src.drive->Path;
508 case RDPDR_DTYP_PRINT:
509 if (src.printer->DriverName)
511 args[1] = src.printer->DriverName;
516 case RDPDR_DTYP_SMARTCARD:
519 case RDPDR_DTYP_SERIAL:
520 if (src.serial->Path)
522 args[1] = src.serial->Path;
526 if (src.serial->Driver)
528 args[2] = src.serial->Driver;
532 if (src.serial->Permissive)
534 args[3] = src.serial->Permissive;
539 case RDPDR_DTYP_PARALLEL:
540 if (src.parallel->Path)
542 args[1] = src.parallel->Path;
547 WLog_ERR(TAG,
"unknown device type %" PRIu32
"", device->Type);
551 copy.dev = freerdp_device_new(device->Type, count, args);
555 copy.dev->Id = device->Id;
560 void freerdp_device_collection_free(rdpSettings* settings)
562 WINPR_ASSERT(settings);
564 if (settings->DeviceArray)
566 for (UINT32 index = 0; index < settings->DeviceArraySize; index++)
567 (
void)freerdp_settings_set_pointer_array(settings, FreeRDP_DeviceArray, index, NULL);
570 free((
void*)settings->DeviceArray);
577 BOOL freerdp_static_channel_collection_del(rdpSettings* settings,
const char* name)
580 if (!settings || !settings->StaticChannelArray)
583 for (UINT32 x = 0; x < count; x++)
585 ADDIN_ARGV* cur = settings->StaticChannelArray[x];
586 if (cur && (cur->argc > 0))
588 if (strcmp(name, cur->argv[0]) == 0)
590 const size_t rem = settings->StaticChannelArraySize - count + 1;
591 memmove_s((
void*)&settings->StaticChannelArray[x],
593 (
void*)&settings->StaticChannelArray[x + 1],
595 memset((
void*)&settings->StaticChannelArray[count - 1], 0,
598 freerdp_addin_argv_free(cur);
604 const size_t rem = settings->StaticChannelArraySize - count;
605 memset((
void*)&settings->StaticChannelArray[count], 0,
sizeof(
ADDIN_ARGV*) * rem);
610 BOOL freerdp_static_channel_collection_add(rdpSettings* settings,
ADDIN_ARGV* channel)
614 WINPR_ASSERT(settings);
615 WINPR_ASSERT(channel);
620 const UINT32 oldSize =
622 UINT32 new_size = oldSize * 2ul;
625 new_size = count * 2ul;
627 new_array = (
ADDIN_ARGV**)realloc((
void*)settings->StaticChannelArray,
633 settings->StaticChannelArray = new_array;
635 const size_t rem = new_size - oldSize;
636 memset((
void*)&settings->StaticChannelArray[oldSize], 0,
sizeof(
ADDIN_ARGV*) * rem);
644 ADDIN_ARGV** cur = &settings->StaticChannelArray[count++];
645 freerdp_addin_argv_free(*cur);
650 ADDIN_ARGV* freerdp_static_channel_collection_find(rdpSettings* settings,
const char* name)
654 WINPR_ASSERT(settings);
657 for (UINT32 index = 0;
660 channel = settings->StaticChannelArray[index];
662 if (strcmp(channel->argv[0], name) == 0)
669 void freerdp_static_channel_collection_free(rdpSettings* settings)
674 if (settings->StaticChannelArray)
678 freerdp_addin_argv_free(settings->StaticChannelArray[i]);
681 free((
void*)settings->StaticChannelArray);
683 settings->StaticChannelArray = NULL;
687 BOOL freerdp_dynamic_channel_collection_del(rdpSettings* settings,
const char* name)
690 if (!settings || !settings->DynamicChannelArray)
693 for (UINT32 x = 0; x < count; x++)
695 ADDIN_ARGV* cur = settings->DynamicChannelArray[x];
696 if (cur && (cur->argc > 0))
698 if (strcmp(name, cur->argv[0]) == 0)
700 const size_t rem = settings->DynamicChannelArraySize - count + 1;
701 memmove_s((
void*)&settings->DynamicChannelArray[x],
703 (
void*)&settings->DynamicChannelArray[x + 1],
705 memset((
void*)&settings->DynamicChannelArray[count - 1], 0,
708 freerdp_addin_argv_free(cur);
718 BOOL freerdp_dynamic_channel_collection_add(rdpSettings* settings,
ADDIN_ARGV* channel)
723 WINPR_ASSERT(settings);
724 WINPR_ASSERT(channel);
731 UINT32 size = oldSize * 2;
741 settings->DynamicChannelArray = new_array;
743 const size_t rem = size - oldSize;
744 memset((
void*)&settings->DynamicChannelArray[oldSize], 0,
sizeof(
ADDIN_ARGV*) * rem);
751 settings->DynamicChannelArray[count++] = channel;
755 ADDIN_ARGV* freerdp_dynamic_channel_collection_find(
const rdpSettings* settings,
const char* name)
757 WINPR_ASSERT(settings);
760 for (UINT32 index = 0;
763 ADDIN_ARGV* channel = settings->DynamicChannelArray[index];
765 if (strcmp(channel->argv[0], name) == 0)
772 void freerdp_addin_argv_free(
ADDIN_ARGV* args)
779 for (
int index = 0; index < args->argc; index++)
780 free(args->argv[index]);
781 free((
void*)args->argv);
787 ADDIN_ARGV* freerdp_addin_argv_new(
size_t argc,
const char*
const argv[])
789 if (argc > INT32_MAX)
798 args->argc = (int)argc;
799 args->argv = (
char**)calloc(argc,
sizeof(
char*));
805 for (
size_t x = 0; x < argc; x++)
807 args->argv[x] = _strdup(argv[x]);
815 WINPR_PRAGMA_DIAG_PUSH
816 WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC
817 freerdp_addin_argv_free(args);
818 WINPR_PRAGMA_DIAG_POP
832 return freerdp_addin_argv_new(args->argc, cnv.cc);
835 void freerdp_dynamic_channel_collection_free(rdpSettings* settings)
837 WINPR_ASSERT(settings);
839 if (settings->DynamicChannelArray)
843 freerdp_addin_argv_free(settings->DynamicChannelArray[i]);
846 free((
void*)settings->DynamicChannelArray);
848 settings->DynamicChannelArray = NULL;
852 void freerdp_capability_buffer_free(rdpSettings* settings)
854 WINPR_ASSERT(settings);
856 if (settings->ReceivedCapabilityData)
858 for (UINT32 x = 0; x < settings->ReceivedCapabilitiesSize; x++)
860 free(settings->ReceivedCapabilityData[x]);
861 settings->ReceivedCapabilityData[x] = NULL;
864 settings->ReceivedCapabilitiesSize = 0;
866 free(settings->ReceivedCapabilityDataSizes);
867 settings->ReceivedCapabilityDataSizes = NULL;
869 free((
void*)settings->ReceivedCapabilityData);
870 settings->ReceivedCapabilityData = NULL;
871 free(settings->ReceivedCapabilities);
872 settings->ReceivedCapabilities = NULL;
875 BOOL freerdp_capability_buffer_copy(rdpSettings* settings,
const rdpSettings* src)
877 WINPR_ASSERT(settings);
880 if (!freerdp_capability_buffer_allocate(settings, src->ReceivedCapabilitiesSize))
883 for (UINT32 x = 0; x < src->ReceivedCapabilitiesSize; x++)
885 WINPR_ASSERT(settings->ReceivedCapabilities);
886 settings->ReceivedCapabilities[x] = src->ReceivedCapabilities[x];
888 WINPR_ASSERT(settings->ReceivedCapabilityDataSizes);
889 settings->ReceivedCapabilityDataSizes[x] = src->ReceivedCapabilityDataSizes[x];
891 WINPR_ASSERT(settings->ReceivedCapabilityData);
892 if (src->ReceivedCapabilityDataSizes[x] > 0)
894 void* tmp = realloc(settings->ReceivedCapabilityData[x],
895 settings->ReceivedCapabilityDataSizes[x]);
898 memcpy(tmp, src->ReceivedCapabilityData[x], src->ReceivedCapabilityDataSizes[x]);
899 settings->ReceivedCapabilityData[x] = tmp;
903 free(settings->ReceivedCapabilityData[x]);
904 settings->ReceivedCapabilityData[x] = NULL;
910 void freerdp_target_net_addresses_free(rdpSettings* settings)
912 WINPR_ASSERT(settings);
914 if (settings->TargetNetAddresses)
916 for (UINT32 index = 0; index < settings->TargetNetAddressCount; index++)
917 free(settings->TargetNetAddresses[index]);
920 free((
void*)settings->TargetNetAddresses);
921 free(settings->TargetNetPorts);
922 settings->TargetNetAddressCount = 0;
923 settings->TargetNetAddresses = NULL;
924 settings->TargetNetPorts = NULL;
927 void freerdp_server_license_issuers_free(rdpSettings* settings)
929 WINPR_ASSERT(settings);
931 if (settings->ServerLicenseProductIssuers)
933 for (UINT32 x = 0; x < settings->ServerLicenseProductIssuersCount; x++)
934 free(settings->ServerLicenseProductIssuers[x]);
936 free((
void*)settings->ServerLicenseProductIssuers);
937 settings->ServerLicenseProductIssuers = NULL;
938 settings->ServerLicenseProductIssuersCount = 0;
941 BOOL freerdp_server_license_issuers_copy(rdpSettings* settings,
char** issuers, UINT32 count)
943 WINPR_ASSERT(settings);
944 WINPR_ASSERT(issuers || (count == 0));
950 for (UINT32 x = 0; x < count; x++)
952 char* issuer = _strdup(issuers[x]);
955 settings->ServerLicenseProductIssuers[x] = issuer;
961 void freerdp_performance_flags_make(rdpSettings* settings)
963 UINT32 PerformanceFlags = PERF_FLAG_NONE;
966 PerformanceFlags |= PERF_ENABLE_FONT_SMOOTHING;
969 PerformanceFlags |= PERF_ENABLE_DESKTOP_COMPOSITION;
972 PerformanceFlags |= PERF_DISABLE_WALLPAPER;
975 PerformanceFlags |= PERF_DISABLE_FULLWINDOWDRAG;
978 PerformanceFlags |= PERF_DISABLE_MENUANIMATIONS;
981 PerformanceFlags |= PERF_DISABLE_THEMING;
985 void freerdp_performance_flags_split(rdpSettings* settings)
988 settings, FreeRDP_AllowFontSmoothing,
990 PERF_ENABLE_FONT_SMOOTHING)
994 settings, FreeRDP_AllowDesktopComposition,
996 PERF_ENABLE_DESKTOP_COMPOSITION)
1000 settings, FreeRDP_DisableWallpaper,
1005 settings, FreeRDP_DisableFullWindowDrag,
1007 PERF_DISABLE_FULLWINDOWDRAG)
1011 settings, FreeRDP_DisableMenuAnims,
1013 PERF_DISABLE_MENUANIMATIONS)
1017 settings, FreeRDP_DisableThemes,
1028 if (GatewayUsageMethod == TSC_PROXY_MODE_NONE_DIRECT)
1034 else if (GatewayUsageMethod == TSC_PROXY_MODE_DIRECT)
1040 else if (GatewayUsageMethod == TSC_PROXY_MODE_DETECT)
1046 else if (GatewayUsageMethod == TSC_PROXY_MODE_DEFAULT)
1057 else if (GatewayUsageMethod == TSC_PROXY_MODE_NONE_DETECT)
1067 void freerdp_update_gateway_usage_method(rdpSettings* settings, UINT32 GatewayEnabled,
1068 UINT32 GatewayBypassLocal)
1070 UINT32 GatewayUsageMethod = 0;
1072 if (!GatewayEnabled && !GatewayBypassLocal)
1073 GatewayUsageMethod = TSC_PROXY_MODE_NONE_DIRECT;
1074 else if (GatewayEnabled && !GatewayBypassLocal)
1075 GatewayUsageMethod = TSC_PROXY_MODE_DIRECT;
1076 else if (GatewayEnabled && GatewayBypassLocal)
1077 GatewayUsageMethod = TSC_PROXY_MODE_DETECT;
1082 #if defined(WITH_FREERDP_DEPRECATED)
1083 BOOL freerdp_get_param_bool(
const rdpSettings* settings,
int id)
1088 int freerdp_set_param_bool(rdpSettings* settings,
int id, BOOL param)
1093 int freerdp_get_param_int(
const rdpSettings* settings,
int id)
1098 int freerdp_set_param_int(rdpSettings* settings,
int id,
int param)
1103 UINT32 freerdp_get_param_uint32(
const rdpSettings* settings,
int id)
1108 int freerdp_set_param_uint32(rdpSettings* settings,
int id, UINT32 param)
1113 UINT64 freerdp_get_param_uint64(
const rdpSettings* settings,
int id)
1118 int freerdp_set_param_uint64(rdpSettings* settings,
int id, UINT64 param)
1123 char* freerdp_get_param_string(
const rdpSettings* settings,
int id)
1126 return WINPR_CAST_CONST_PTR_AWAY(str,
char*);
1129 int freerdp_set_param_string(rdpSettings* settings,
int id,
const char* param)
1135 static BOOL value_to_uint(
const char* value, ULONGLONG* result, ULONGLONG min, ULONGLONG max)
1137 char* endptr = NULL;
1138 unsigned long long rc = 0;
1140 if (!value || !result)
1144 rc = _strtoui64(value, &endptr, 0);
1149 if (endptr == value)
1152 if ((rc < min) || (rc > max))
1159 static BOOL value_to_int(
const char* value, LONGLONG* result, LONGLONG min, LONGLONG max)
1161 char* endptr = NULL;
1164 if (!value || !result)
1168 rc = _strtoi64(value, &endptr, 0);
1173 if (endptr == value)
1176 if ((rc < min) || (rc > max))
1183 static BOOL parsing_fail(
const char* key,
const char* type,
const char* value)
1185 WLog_ERR(TAG,
"Failed to parse key [%s] of type [%s]: value [%s]", key, type, value);
1189 BOOL freerdp_settings_set_value_for_name(rdpSettings* settings,
const char* name,
const char* value)
1195 if (!settings || !name)
1201 WLog_ERR(TAG,
"Invalid settings key [%s]", name);
1205 const SSIZE_T index = i;
1211 case RDP_SETTINGS_TYPE_BOOL:
1213 const BOOL val = (_strnicmp(value,
"TRUE", 5) == 0) || (_strnicmp(value,
"ON", 5) == 0);
1215 (_strnicmp(value,
"FALSE", 6) == 0) || (_strnicmp(value,
"OFF", 6) == 0);
1217 return parsing_fail(name,
"BOOL", value);
1222 case RDP_SETTINGS_TYPE_UINT16:
1223 if (!value_to_uint(value, &uval, 0, UINT16_MAX))
1224 return parsing_fail(name,
"UINT16", value);
1229 return parsing_fail(name,
"UINT16", value);
1232 case RDP_SETTINGS_TYPE_INT16:
1233 if (!value_to_int(value, &ival, INT16_MIN, INT16_MAX))
1234 return parsing_fail(name,
"INT16", value);
1239 return parsing_fail(name,
"INT16", value);
1241 case RDP_SETTINGS_TYPE_UINT32:
1242 if (!value_to_uint(value, &uval, 0, UINT32_MAX))
1243 return parsing_fail(name,
"UINT32", value);
1248 return parsing_fail(name,
"UINT32", value);
1250 case RDP_SETTINGS_TYPE_INT32:
1251 if (!value_to_int(value, &ival, INT32_MIN, INT32_MAX))
1252 return parsing_fail(name,
"INT32", value);
1257 return parsing_fail(name,
"INT32", value);
1259 case RDP_SETTINGS_TYPE_UINT64:
1260 if (!value_to_uint(value, &uval, 0, UINT64_MAX))
1261 return parsing_fail(name,
"UINT64", value);
1265 return parsing_fail(name,
"UINT64", value);
1267 case RDP_SETTINGS_TYPE_INT64:
1268 if (!value_to_int(value, &ival, INT64_MIN, INT64_MAX))
1269 return parsing_fail(name,
"INT64", value);
1273 return parsing_fail(name,
"INT64", value);
1276 case RDP_SETTINGS_TYPE_STRING:
1280 case RDP_SETTINGS_TYPE_POINTER:
1281 return parsing_fail(name,
"POINTER", value);
1288 BOOL freerdp_settings_set_pointer_len_(rdpSettings* settings, FreeRDP_Settings_Keys_Pointer
id,
1289 FreeRDP_Settings_Keys_UInt32 lenId,
const void* data,
1290 size_t len,
size_t size)
1298 if (lenId != FreeRDP_UINT32_UNUSED)
1304 if (len > UINT32_MAX)
1308 copy = calloc(len, size);
1312 memcpy(copy, data, len * size);
1322 if (lenId == FreeRDP_UINT32_UNUSED)
1328 FreeRDP_Settings_Keys_Pointer
id)
1332 const rdpSettings* pc;
1340 const void* data,
size_t len)
1354 case FreeRDP_RdpServerCertificate:
1355 freerdp_certificate_free(settings->RdpServerCertificate);
1359 WLog_ERR(TAG,
"FreeRDP_RdpServerCertificate::len must be 0 or 1");
1362 settings->RdpServerCertificate = cnv.v;
1363 if (!settings->RdpServerCertificate && (len > 0))
1365 settings->RdpServerCertificate = freerdp_certificate_new();
1366 if (!settings->RdpServerCertificate)
1370 case FreeRDP_RdpServerRsaKey:
1371 freerdp_key_free(settings->RdpServerRsaKey);
1374 WLog_ERR(TAG,
"FreeRDP_RdpServerRsaKey::len must be 0 or 1");
1377 settings->RdpServerRsaKey = (rdpPrivateKey*)cnv.v;
1378 if (!settings->RdpServerRsaKey && (len > 0))
1380 settings->RdpServerRsaKey = freerdp_key_new();
1381 if (!settings->RdpServerRsaKey)
1385 case FreeRDP_RedirectionPassword:
1386 return freerdp_settings_set_pointer_len_(
1387 settings,
id, FreeRDP_RedirectionPasswordLength, data, len,
sizeof(
char));
1388 case FreeRDP_RedirectionTsvUrl:
1389 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_RedirectionTsvUrlLength,
1390 data, len,
sizeof(
char));
1391 case FreeRDP_RedirectionTargetCertificate:
1392 freerdp_certificate_free(settings->RedirectionTargetCertificate);
1396 WLog_ERR(TAG,
"FreeRDP_RedirectionTargetCertificate::len must be 0 or 1");
1399 settings->RedirectionTargetCertificate = cnv.v;
1400 if (!settings->RedirectionTargetCertificate && (len > 0))
1402 settings->RedirectionTargetCertificate = freerdp_certificate_new();
1403 if (!settings->RedirectionTargetCertificate)
1407 case FreeRDP_RedirectionGuid:
1408 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_RedirectionGuidLength,
1409 data, len,
sizeof(BYTE));
1410 case FreeRDP_LoadBalanceInfo:
1411 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_LoadBalanceInfoLength,
1412 data, len,
sizeof(
char));
1413 case FreeRDP_ServerRandom:
1414 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_ServerRandomLength, data,
1416 case FreeRDP_ClientRandom:
1417 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_ClientRandomLength, data,
1419 case FreeRDP_ServerCertificate:
1420 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_ServerCertificateLength,
1421 data, len,
sizeof(
char));
1422 case FreeRDP_TargetNetAddresses:
1423 if ((data == NULL) && (len == 0))
1425 freerdp_target_net_addresses_free(settings);
1430 "[BUG] FreeRDP_TargetNetAddresses must not be resized from outside the library!");
1432 case FreeRDP_ServerLicenseProductIssuers:
1434 freerdp_server_license_issuers_free(settings);
1435 return freerdp_settings_set_pointer_len_(settings, FreeRDP_ServerLicenseProductIssuers,
1436 FreeRDP_ServerLicenseProductIssuersCount, data,
1437 len,
sizeof(
char*));
1438 case FreeRDP_TargetNetPorts:
1439 if ((data == NULL) && (len == 0))
1441 freerdp_target_net_addresses_free(settings);
1445 "[BUG] FreeRDP_TargetNetPorts must not be resized from outside the library!");
1447 case FreeRDP_DeviceArray:
1449 freerdp_device_collection_free(settings);
1450 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_DeviceArraySize, data,
1452 case FreeRDP_ChannelDefArray:
1453 if ((len > 0) && (len < CHANNEL_MAX_COUNT))
1455 "FreeRDP_ChannelDefArray::len expected to be >= %" PRIu32
1456 ", but have %" PRIu32,
1457 CHANNEL_MAX_COUNT, len);
1458 return freerdp_settings_set_pointer_len_(settings, FreeRDP_ChannelDefArray,
1459 FreeRDP_ChannelDefArraySize, data, len,
1461 case FreeRDP_MonitorDefArray:
1462 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_MonitorDefArraySize,
1464 case FreeRDP_ClientAutoReconnectCookie:
1465 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_UINT32_UNUSED, data, len,
1467 case FreeRDP_ServerAutoReconnectCookie:
1468 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_UINT32_UNUSED, data, len,
1470 case FreeRDP_ClientTimeZone:
1473 WLog_ERR(TAG,
"FreeRDP_ClientTimeZone::len must be 0 or 1");
1476 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_UINT32_UNUSED, data, len,
1478 case FreeRDP_BitmapCacheV2CellInfo:
1479 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_BitmapCacheV2NumCells,
1481 case FreeRDP_GlyphCache:
1482 if ((len != 0) && (len != 10))
1484 WLog_ERR(TAG,
"FreeRDP_GlyphCache::len must be 0 or 10");
1487 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_UINT32_UNUSED, data, len,
1489 case FreeRDP_FragCache:
1492 WLog_ERR(TAG,
"FreeRDP_FragCache::len must be 0 or 1");
1495 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_UINT32_UNUSED, data, len,
1497 case FreeRDP_StaticChannelArray:
1499 freerdp_static_channel_collection_free(settings);
1500 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_StaticChannelArraySize,
1502 case FreeRDP_DynamicChannelArray:
1504 freerdp_dynamic_channel_collection_free(settings);
1505 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_DynamicChannelArraySize,
1507 case FreeRDP_ReceivedCapabilityData:
1509 freerdp_capability_buffer_free(settings);
1510 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_ReceivedCapabilitiesSize,
1511 data, len,
sizeof(BYTE*));
1512 case FreeRDP_ReceivedCapabilities:
1514 freerdp_capability_buffer_free(settings);
1515 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_ReceivedCapabilitiesSize,
1516 data, len,
sizeof(
char));
1517 case FreeRDP_OrderSupport:
1518 return freerdp_settings_set_pointer_len_(settings,
id, FreeRDP_UINT32_UNUSED, data, len,
1521 case FreeRDP_MonitorIds:
1522 return freerdp_settings_set_pointer_len_(
1523 settings, FreeRDP_MonitorIds, FreeRDP_NumMonitorIds, data, len,
sizeof(UINT32));
1526 if ((data == NULL) && (len == 0))
1531 WLog_WARN(TAG,
"Invalid id %" PRIuz,
id);
1536 void* freerdp_settings_get_pointer_array_writable(
const rdpSettings* settings,
1537 FreeRDP_Settings_Keys_Pointer
id,
size_t offset)
1544 case FreeRDP_ClientAutoReconnectCookie:
1546 if ((offset >= max) || !settings->ClientAutoReconnectCookie)
1548 return &settings->ClientAutoReconnectCookie[offset];
1549 case FreeRDP_ServerAutoReconnectCookie:
1551 if ((offset >= max) || !settings->ServerAutoReconnectCookie)
1553 return &settings->ServerAutoReconnectCookie[offset];
1554 case FreeRDP_ServerCertificate:
1558 return &settings->ServerCertificate[offset];
1559 case FreeRDP_ServerRandom:
1563 return &settings->ServerRandom[offset];
1564 case FreeRDP_ClientRandom:
1568 return &settings->ClientRandom[offset];
1569 case FreeRDP_LoadBalanceInfo:
1573 return &settings->LoadBalanceInfo[offset];
1575 case FreeRDP_RedirectionTsvUrl:
1579 return &settings->RedirectionTsvUrl[offset];
1581 case FreeRDP_RedirectionPassword:
1585 return &settings->RedirectionPassword[offset];
1587 case FreeRDP_OrderSupport:
1591 return &settings->OrderSupport[offset];
1592 case FreeRDP_MonitorIds:
1596 return &settings->MonitorIds[offset];
1597 case FreeRDP_MonitorDefArray:
1601 return &settings->MonitorDefArray[offset];
1602 case FreeRDP_ChannelDefArray:
1606 return &settings->ChannelDefArray[offset];
1607 case FreeRDP_DeviceArray:
1611 return settings->DeviceArray[offset];
1612 case FreeRDP_StaticChannelArray:
1616 return settings->StaticChannelArray[offset];
1617 case FreeRDP_DynamicChannelArray:
1621 return settings->DynamicChannelArray[offset];
1622 case FreeRDP_FragCache:
1626 return &settings->FragCache[offset];
1627 case FreeRDP_GlyphCache:
1631 return &settings->GlyphCache[offset];
1632 case FreeRDP_BitmapCacheV2CellInfo:
1636 return &settings->BitmapCacheV2CellInfo[offset];
1637 case FreeRDP_ReceivedCapabilities:
1641 return &settings->ReceivedCapabilities[offset];
1642 case FreeRDP_TargetNetAddresses:
1646 return settings->TargetNetAddresses[offset];
1647 case FreeRDP_TargetNetPorts:
1651 return &settings->TargetNetPorts[offset];
1652 case FreeRDP_ClientTimeZone:
1656 return settings->ClientTimeZone;
1657 case FreeRDP_RdpServerCertificate:
1661 return settings->RdpServerCertificate;
1662 case FreeRDP_RdpServerRsaKey:
1666 return settings->RdpServerRsaKey;
1673 WLog_WARN(TAG,
"Invalid offset for %s [%" PRIuz
"]: size=%" PRIuz
", offset=%" PRIuz,
1678 BOOL freerdp_settings_set_pointer_array(rdpSettings* settings, FreeRDP_Settings_Keys_Pointer
id,
1679 size_t offset,
const void* data)
1681 size_t maxOffset = 0;
1686 case FreeRDP_ClientAutoReconnectCookie:
1688 if ((offset >= maxOffset) || !data || !settings->ClientAutoReconnectCookie)
1692 case FreeRDP_ServerAutoReconnectCookie:
1694 if ((offset >= maxOffset) || !data || !settings->ServerAutoReconnectCookie)
1698 case FreeRDP_ServerCertificate:
1700 if ((offset >= maxOffset) || !data)
1702 settings->ServerCertificate[offset] = *(
const BYTE*)data;
1704 case FreeRDP_DeviceArray:
1706 if (offset >= maxOffset)
1708 freerdp_device_free(settings->DeviceArray[offset]);
1709 settings->DeviceArray[offset] = freerdp_device_clone(data);
1711 case FreeRDP_TargetNetAddresses:
1713 if ((offset >= maxOffset) || !data)
1715 free(settings->TargetNetAddresses[offset]);
1716 settings->TargetNetAddresses[offset] = _strdup((
const char*)data);
1717 return settings->TargetNetAddresses[offset] != NULL;
1718 case FreeRDP_TargetNetPorts:
1720 if ((offset >= maxOffset) || !data)
1722 settings->TargetNetPorts[offset] = *((
const UINT32*)data);
1724 case FreeRDP_StaticChannelArray:
1726 if ((offset >= maxOffset) || !data)
1728 freerdp_addin_argv_free(settings->StaticChannelArray[offset]);
1729 settings->StaticChannelArray[offset] = freerdp_addin_argv_clone(data);
1731 case FreeRDP_DynamicChannelArray:
1733 if ((offset >= maxOffset) || !data)
1735 freerdp_addin_argv_free(settings->DynamicChannelArray[offset]);
1736 settings->DynamicChannelArray[offset] = freerdp_addin_argv_clone(data);
1738 case FreeRDP_BitmapCacheV2CellInfo:
1740 if ((offset >= maxOffset) || !data)
1744 settings->BitmapCacheV2CellInfo[offset] = *cdata;
1747 case FreeRDP_ServerRandom:
1749 if ((offset >= maxOffset) || !data)
1751 settings->ServerRandom[offset] = *(
const BYTE*)data;
1753 case FreeRDP_ClientRandom:
1755 if ((offset >= maxOffset) || !data)
1757 settings->ClientRandom[offset] = *(
const BYTE*)data;
1759 case FreeRDP_LoadBalanceInfo:
1761 if ((offset >= maxOffset) || !data)
1763 settings->LoadBalanceInfo[offset] = *(
const BYTE*)data;
1765 case FreeRDP_RedirectionTsvUrl:
1767 if ((offset >= maxOffset) || !data)
1769 settings->RedirectionTsvUrl[offset] = *(
const BYTE*)data;
1771 case FreeRDP_RedirectionPassword:
1773 if ((offset >= maxOffset) || !data)
1775 settings->RedirectionPassword[offset] = *(
const BYTE*)data;
1777 case FreeRDP_OrderSupport:
1779 if (!settings->OrderSupport)
1781 if ((offset >= maxOffset) || !data)
1783 settings->OrderSupport[offset] = *(
const BOOL*)data;
1785 case FreeRDP_GlyphCache:
1787 if (!settings->GlyphCache)
1789 if ((offset >= maxOffset) || !data)
1793 case FreeRDP_FragCache:
1795 if (!settings->FragCache)
1797 if ((offset >= maxOffset) || !data)
1801 case FreeRDP_MonitorIds:
1803 if ((offset >= maxOffset) || !data)
1805 settings->MonitorIds[offset] = *(
const UINT32*)data;
1807 case FreeRDP_ChannelDefArray:
1809 if ((offset >= maxOffset) || !data)
1811 settings->ChannelDefArray[offset] = *(
const CHANNEL_DEF*)data;
1813 case FreeRDP_MonitorDefArray:
1815 if ((offset >= maxOffset) || !data)
1817 settings->MonitorDefArray[offset] = *(
const rdpMonitor*)data;
1820 case FreeRDP_ClientTimeZone:
1822 if ((offset >= maxOffset) || !data || !settings->ClientTimeZone)
1833 WLog_WARN(TAG,
"[%s] Invalid offset=%" PRIuz
" [%" PRIuz
"] or NULL data=%p",
1838 const void* freerdp_settings_get_pointer_array(
const rdpSettings* settings,
1839 FreeRDP_Settings_Keys_Pointer
id,
size_t offset)
1841 return freerdp_settings_get_pointer_array_writable(settings,
id, offset);
1846 UINT32 flags = FREERDP_CODEC_ALL;
1847 if (settings->RemoteFxCodec == FALSE)
1849 flags &= ~FREERDP_CODEC_REMOTEFX;
1851 if (settings->NSCodec == FALSE)
1853 flags &= ~FREERDP_CODEC_NSCODEC;
1861 WINPR_ASSERT(settings);
1862 const char* hostname = settings->ServerHostname;
1864 if (settings->UserSpecifiedServerName)
1865 hostname = settings->UserSpecifiedServerName;
1870 #if defined(WITH_FREERDP_DEPRECATED)
1873 return freerdp_addin_argv_clone(channel);
1878 return freerdp_addin_argv_clone(channel);
1882 BOOL freerdp_target_net_addresses_copy(rdpSettings* settings,
char** addresses, UINT32 count)
1884 WINPR_ASSERT(settings);
1885 WINPR_ASSERT(addresses);
1887 if (!freerdp_target_net_adresses_reset(settings, count))
1890 for (UINT32 i = 0; i < settings->TargetNetAddressCount; i++)
1892 if (!freerdp_settings_set_pointer_array(settings, FreeRDP_TargetNetAddresses, i,
1895 freerdp_target_net_addresses_free(settings);
1905 if (!what && !expect)
1907 if (!what || !expect)
1910 if (what->Id != expect->Id)
1912 if (what->Type != expect->Type)
1914 if (what->Name && expect->Name)
1916 if (strcmp(what->Name, expect->Name) != 0)
1921 if (what->Name != expect->Name)
1927 case RDPDR_DTYP_PRINT:
1931 if (a->DriverName && b->DriverName)
1932 return strcmp(a->DriverName, b->DriverName) == 0;
1933 return a->DriverName == b->DriverName;
1936 case RDPDR_DTYP_SERIAL:
1941 if (a->Path && b->Path)
1943 if (strcmp(a->Path, b->Path) != 0)
1946 else if (a->Path != b->Path)
1949 if (a->Driver && b->Driver)
1951 if (strcmp(a->Driver, b->Driver) != 0)
1954 else if (a->Driver != b->Driver)
1956 if (a->Permissive && b->Permissive)
1957 return strcmp(a->Permissive, b->Permissive) == 0;
1958 return a->Permissive == b->Permissive;
1961 case RDPDR_DTYP_PARALLEL:
1965 if (a->Path && b->Path)
1966 return strcmp(a->Path, b->Path) == 0;
1967 return a->Path == b->Path;
1970 case RDPDR_DTYP_SMARTCARD:
1972 case RDPDR_DTYP_FILESYSTEM:
1976 if (a->automount != b->automount)
1978 if (a->Path && b->Path)
1979 return strcmp(a->Path, b->Path) == 0;
1980 return a->Path == b->Path;
1993 RAIL_LEVEL_SUPPORTED | RAIL_LEVEL_DOCKED_LANGBAR_SUPPORTED |
1994 RAIL_LEVEL_SHELL_INTEGRATION_SUPPORTED | RAIL_LEVEL_LANGUAGE_IME_SYNC_SUPPORTED |
1995 RAIL_LEVEL_SERVER_TO_CLIENT_IME_SYNC_SUPPORTED | RAIL_LEVEL_HIDE_MINIMIZED_APPS_SUPPORTED |
1996 RAIL_LEVEL_WINDOW_CLOAKING_SUPPORTED | RAIL_LEVEL_HANDSHAKE_EX_SUPPORTED;
1998 if (flags & RAIL_LEVEL_SUPPORTED)
1999 winpr_str_append(
"RAIL_LEVEL_SUPPORTED", buffer, length,
"|");
2000 if (flags & RAIL_LEVEL_DOCKED_LANGBAR_SUPPORTED)
2001 winpr_str_append(
"RAIL_LEVEL_DOCKED_LANGBAR_SUPPORTED", buffer, length,
"|");
2002 if (flags & RAIL_LEVEL_SHELL_INTEGRATION_SUPPORTED)
2003 winpr_str_append(
"RAIL_LEVEL_SHELL_INTEGRATION_SUPPORTED", buffer, length,
"|");
2004 if (flags & RAIL_LEVEL_LANGUAGE_IME_SYNC_SUPPORTED)
2005 winpr_str_append(
"RAIL_LEVEL_LANGUAGE_IME_SYNC_SUPPORTED", buffer, length,
"|");
2006 if (flags & RAIL_LEVEL_SERVER_TO_CLIENT_IME_SYNC_SUPPORTED)
2007 winpr_str_append(
"RAIL_LEVEL_SERVER_TO_CLIENT_IME_SYNC_SUPPORTED", buffer, length,
"|");
2008 if (flags & RAIL_LEVEL_HIDE_MINIMIZED_APPS_SUPPORTED)
2009 winpr_str_append(
"RAIL_LEVEL_HIDE_MINIMIZED_APPS_SUPPORTED", buffer, length,
"|");
2010 if (flags & RAIL_LEVEL_WINDOW_CLOAKING_SUPPORTED)
2011 winpr_str_append(
"RAIL_LEVEL_WINDOW_CLOAKING_SUPPORTED", buffer, length,
"|");
2012 if (flags & RAIL_LEVEL_HANDSHAKE_EX_SUPPORTED)
2013 winpr_str_append(
"RAIL_LEVEL_HANDSHAKE_EX_SUPPORTED", buffer, length,
"|");
2014 if (flags & RAIL_LEVEL_LANGUAGE_IME_SYNC_SUPPORTED)
2015 winpr_str_append(
"RAIL_LEVEL_LANGUAGE_IME_SYNC_SUPPORTED", buffer, length,
"|");
2016 if ((flags & ~mask) != 0)
2018 char tbuffer[64] = { 0 };
2019 (void)_snprintf(tbuffer,
sizeof(tbuffer),
"RAIL_FLAG_UNKNOWN 0x%08" PRIx32, flags & mask);
2020 winpr_str_append(tbuffer, buffer, length,
"|");
2026 const BYTE** capsData,
const UINT32* capsSizes,
2027 UINT32 capsCount, BOOL serverReceivedCaps)
2029 WINPR_ASSERT(settings);
2030 WINPR_ASSERT(capsFlags || (capsCount == 0));
2031 WINPR_ASSERT(capsData || (capsCount == 0));
2032 WINPR_ASSERT(capsSizes || (capsCount == 0));
2033 WINPR_ASSERT(capsCount <= UINT16_MAX);
2035 for (UINT32 x = 0; x < capsCount; x++)
2040 wStream* sub = Stream_StaticConstInit(&buffer, capsData[x], capsSizes[x]);
2042 if (!rdp_read_capability_set(sub, (UINT16)x, settings, serverReceivedCaps))
2055 return "RDP_VERSION_4";
2056 case RDP_VERSION_5_PLUS:
2057 return "RDP_VERSION_5_PLUS";
2058 case RDP_VERSION_10_0:
2059 return "RDP_VERSION_10_0";
2060 case RDP_VERSION_10_1:
2061 return "RDP_VERSION_10_1";
2062 case RDP_VERSION_10_2:
2063 return "RDP_VERSION_10_2";
2064 case RDP_VERSION_10_3:
2065 return "RDP_VERSION_10_3";
2066 case RDP_VERSION_10_4:
2067 return "RDP_VERSION_10_4";
2068 case RDP_VERSION_10_5:
2069 return "RDP_VERSION_10_5";
2070 case RDP_VERSION_10_6:
2071 return "RDP_VERSION_10_6";
2072 case RDP_VERSION_10_7:
2073 return "RDP_VERSION_10_7";
2074 case RDP_VERSION_10_8:
2075 return "RDP_VERSION_10_8";
2076 case RDP_VERSION_10_9:
2077 return "RDP_VERSION_10_9";
2078 case RDP_VERSION_10_10:
2079 return "RDP_VERSION_10_10";
2080 case RDP_VERSION_10_11:
2081 return "RDP_VERSION_10_11";
2082 case RDP_VERSION_10_12:
2083 return "RDP_VERSION_10_12";
2085 return "RDP_VERSION_UNKNOWN";
2092 WINPR_ASSERT(settings);
2095 return freerdp_settings_set_string_copy_(settings,
id, NULL, 0, TRUE);
2099 char* str = ConvertWCharToUtf8Alloc(param, &len);
2100 if (!str && (len != 0))
2103 return freerdp_settings_set_string_(settings,
id, str, len);
2107 const WCHAR* param,
size_t length)
2111 WINPR_ASSERT(settings);
2114 return freerdp_settings_set_string_copy_(settings,
id, NULL, length, TRUE);
2116 char* str = ConvertWCharNToUtf8Alloc(param, length, &len);
2117 if (!str && (length != 0))
2121 const size_t wlen = _wcsnlen(param, length);
2126 return freerdp_settings_set_string_(settings,
id, str, len);
2130 FreeRDP_Settings_Keys_String
id,
size_t* pCharLen)
2137 return ConvertUtf8ToWCharAlloc(str, pCharLen);
2144 case RDPDR_DTYP_FILESYSTEM:
2145 return "RDPDR_DTYP_FILESYSTEM";
2146 case RDPDR_DTYP_PARALLEL:
2147 return "RDPDR_DTYP_PARALLEL";
2148 case RDPDR_DTYP_PRINT:
2149 return "RDPDR_DTYP_PRINT";
2150 case RDPDR_DTYP_SERIAL:
2151 return "RDPDR_DTYP_SERIAL";
2152 case RDPDR_DTYP_SMARTCARD:
2153 return "RDPDR_DTYP_SMARTCARD";
2155 return "RDPDR_DTYP_UNKNOWN";
2159 const char* freerdp_encryption_level_string(UINT32 EncryptionLevel)
2161 switch (EncryptionLevel)
2163 case ENCRYPTION_LEVEL_NONE:
2164 return "ENCRYPTION_LEVEL_NONE";
2165 case ENCRYPTION_LEVEL_LOW:
2166 return "ENCRYPTION_LEVEL_LOW";
2167 case ENCRYPTION_LEVEL_CLIENT_COMPATIBLE:
2168 return "ENCRYPTION_LEVEL_CLIENT_COMPATIBLE";
2169 case ENCRYPTION_LEVEL_HIGH:
2170 return "ENCRYPTION_LEVEL_HIGH";
2171 case ENCRYPTION_LEVEL_FIPS:
2172 return "ENCRYPTION_LEVEL_FIPS";
2174 return "ENCRYPTION_LEVEL_UNKNOWN";
2178 const char* freerdp_encryption_methods_string(UINT32 EncryptionMethods,
char* buffer,
size_t size)
2180 if (EncryptionMethods == ENCRYPTION_METHOD_NONE)
2182 winpr_str_append(
"ENCRYPTION_METHOD_NONE", buffer, size,
"|");
2186 if (EncryptionMethods & ENCRYPTION_METHOD_40BIT)
2188 winpr_str_append(
"ENCRYPTION_METHOD_40BIT", buffer, size,
"|");
2190 if (EncryptionMethods & ENCRYPTION_METHOD_128BIT)
2192 winpr_str_append(
"ENCRYPTION_METHOD_128BIT", buffer, size,
"|");
2194 if (EncryptionMethods & ENCRYPTION_METHOD_56BIT)
2196 winpr_str_append(
"ENCRYPTION_METHOD_56BIT", buffer, size,
"|");
2198 if (EncryptionMethods & ENCRYPTION_METHOD_FIPS)
2200 winpr_str_append(
"ENCRYPTION_METHOD_FIPS", buffer, size,
"|");
2208 const UINT32 invalid = mask & ~(RNS_UD_32BPP_SUPPORT | RNS_UD_24BPP_SUPPORT |
2209 RNS_UD_16BPP_SUPPORT | RNS_UD_15BPP_SUPPORT);
2211 if (mask & RNS_UD_32BPP_SUPPORT)
2212 winpr_str_append(
"RNS_UD_32BPP_SUPPORT", buffer, size,
"|");
2213 if (mask & RNS_UD_24BPP_SUPPORT)
2214 winpr_str_append(
"RNS_UD_24BPP_SUPPORT", buffer, size,
"|");
2215 if (mask & RNS_UD_16BPP_SUPPORT)
2216 winpr_str_append(
"RNS_UD_16BPP_SUPPORT", buffer, size,
"|");
2217 if (mask & RNS_UD_15BPP_SUPPORT)
2218 winpr_str_append(
"RNS_UD_15BPP_SUPPORT", buffer, size,
"|");
2222 char str[32] = { 0 };
2223 (void)_snprintf(str,
sizeof(str),
"RNS_UD_INVALID[0x%04" PRIx32
"]", invalid);
2224 winpr_str_append(str, buffer, size,
"|");
2226 char hex[32] = { 0 };
2227 (void)_snprintf(hex,
sizeof(hex),
"[0x%04" PRIx16
"]", mask);
2232 const char* separator,
const char* param)
2240 winpr_asprintf(&str, &len,
"%s", param);
2241 else if (!separator)
2242 winpr_asprintf(&str, &len,
"%s%s", old, param);
2244 winpr_asprintf(&str, &len,
"%s%s%s", old, separator, param);
2253 return settings != NULL;
FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.
BOOL freerdp_settings_update_from_caps(rdpSettings *settings, const BYTE *capsFlags, const BYTE **capsData, const UINT32 *capsSizes, UINT32 capsCount, BOOL serverReceivedCaps)
Parse capability data and apply to settings.
FREERDP_API BOOL freerdp_settings_set_string(rdpSettings *settings, FreeRDP_Settings_Keys_String id, const char *param)
Sets a string settings value. The param is copied.
FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.
const void * freerdp_settings_get_pointer(const rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id)
Returns a immutable pointer settings value.
BOOL freerdp_settings_set_string_from_utf16N(rdpSettings *settings, FreeRDP_Settings_Keys_String id, const WCHAR *param, size_t length)
Sets a string settings value. The param is converted to UTF-8 and the copy stored.
FREERDP_API SSIZE_T freerdp_settings_get_type_for_key(SSIZE_T key)
Get a key type for the key index.
BOOL freerdp_settings_are_valid(const rdpSettings *settings)
Returns TRUE if settings are in a valid state, FALSE otherwise.
FREERDP_API UINT64 freerdp_settings_get_uint64(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt64 id)
Returns a UINT64 settings value.
FREERDP_API SSIZE_T freerdp_settings_get_key_for_name(const char *value)
Get a key index for the name string of that key.
FREERDP_API const char * freerdp_settings_get_string(const rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a immutable string settings value.
const char * freerdp_rail_support_flags_to_string(UINT32 flags, char *buffer, size_t length)
Returns a stringified representation of RAIL support flags.
BOOL freerdp_settings_set_pointer_len(rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id, const void *data, size_t len)
Set a pointer to value data.
const char * freerdp_supported_color_depths_string(UINT16 mask, char *buffer, size_t size)
returns a string representation of RNS_UD_XXBPP_SUPPORT values
FREERDP_API BOOL freerdp_settings_set_int32(rdpSettings *settings, FreeRDP_Settings_Keys_Int32 id, INT32 param)
Sets a INT32 settings value.
const char * freerdp_rdpdr_dtyp_string(UINT32 type)
Returns a string representation of RDPDR_DTYP_*.
const char * freerdp_settings_get_server_name(const rdpSettings *settings)
A helper function to return the correct server name.
BOOL freerdp_device_collection_del(rdpSettings *settings, const RDPDR_DEVICE *device)
Removed a device from the settings, returns ownership of the allocated device to caller.
BOOL freerdp_set_gateway_usage_method(rdpSettings *settings, UINT32 GatewayUsageMethod)
FREERDP_API BOOL freerdp_settings_set_uint64(rdpSettings *settings, FreeRDP_Settings_Keys_UInt64 id, UINT64 param)
Sets a UINT64 settings value.
WCHAR * freerdp_settings_get_string_as_utf16(const rdpSettings *settings, FreeRDP_Settings_Keys_String id, size_t *pCharLen)
Return an allocated UTF16 string.
FREERDP_API BOOL freerdp_settings_set_int16(rdpSettings *settings, FreeRDP_Settings_Keys_Int16 id, INT16 param)
Sets a INT16 settings value.
FREERDP_API BOOL freerdp_settings_set_int64(rdpSettings *settings, FreeRDP_Settings_Keys_Int64 id, INT64 param)
Sets a INT64 settings value.
BOOL freerdp_settings_set_string_from_utf16(rdpSettings *settings, FreeRDP_Settings_Keys_String id, const WCHAR *param)
Sets a string settings value. The param is converted to UTF-8 and the copy stored.
FREERDP_API BOOL freerdp_settings_set_pointer(rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id, const void *data)
Set a pointer to value data.
FREERDP_API INT32 freerdp_settings_get_int32(const rdpSettings *settings, FreeRDP_Settings_Keys_Int32 id)
Returns a INT32 settings value.
UINT32 freerdp_settings_get_codecs_flags(const rdpSettings *settings)
helper function to get a mask of supported codec flags.
const char * freerdp_rdp_version_string(UINT32 version)
Returns a stringified representation of the RDP protocol version.
FREERDP_API BOOL freerdp_settings_set_string_len(rdpSettings *settings, FreeRDP_Settings_Keys_String id, const char *param, size_t len)
Sets a string settings value. The param is copied.
FREERDP_API BOOL freerdp_settings_set_uint32(rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id, UINT32 param)
Sets a UINT32 settings value.
BOOL freerdp_settings_append_string(rdpSettings *settings, FreeRDP_Settings_Keys_String id, const char *separator, const char *param)
appends a string to a settings value. The param is copied. If the initial value of the setting was no...
FREERDP_API BOOL freerdp_settings_set_uint16(rdpSettings *settings, FreeRDP_Settings_Keys_UInt16 id, UINT16 param)
Sets a UINT16 settings value.
FREERDP_API BOOL freerdp_settings_set_bool(rdpSettings *settings, FreeRDP_Settings_Keys_Bool id, BOOL param)
Sets a BOOL settings value.
FREERDP_API void * freerdp_settings_get_pointer_writable(rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id)
Returns a mutable pointer settings value.
FREERDP_API const char * freerdp_settings_get_name_for_key(SSIZE_T key)
Returns the type name for a key.