From 391f5e0ddbd765f6263a2c4dde63d91c8b20fa2d Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Thu, 13 Apr 2023 12:52:38 +0200 Subject: [PATCH] [settings] add freerdp_supported_color_depths_string --- include/freerdp/settings.h | 7 +++++++ libfreerdp/common/settings.c | 25 +++++++++++++++++++++++++ libfreerdp/core/gcc.c | 8 ++++---- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index 11e1e5dc6..bcd7c2da0 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -2172,6 +2172,13 @@ enum rdp_settings_type FREERDP_API const char* freerdp_encryption_methods_string(UINT32 EncryptionLevel, char* buffer, size_t size); + /** \brief returns a string representation of \b RNS_UD_XXBPP_SUPPORT values + * + * return A string reprenentation of the bitmask. + */ + FREERDP_API const char* freerdp_supported_color_depths_string(UINT16 mask, char* buffer, + size_t size); + #ifdef __cplusplus } #endif diff --git a/libfreerdp/common/settings.c b/libfreerdp/common/settings.c index c18de4a3f..cc938a744 100644 --- a/libfreerdp/common/settings.c +++ b/libfreerdp/common/settings.c @@ -2155,3 +2155,28 @@ const char* freerdp_encryption_methods_string(UINT32 EncryptionMethods, char* bu return buffer; } + +const char* freerdp_supported_color_depths_string(UINT16 mask, char* buffer, size_t size) +{ + const UINT32 invalid = mask & ~(RNS_UD_32BPP_SUPPORT | RNS_UD_24BPP_SUPPORT | + RNS_UD_16BPP_SUPPORT | RNS_UD_15BPP_SUPPORT); + + if (mask & RNS_UD_32BPP_SUPPORT) + winpr_str_append("RNS_UD_32BPP_SUPPORT", buffer, size, "|"); + if (mask & RNS_UD_24BPP_SUPPORT) + winpr_str_append("RNS_UD_24BPP_SUPPORT", buffer, size, "|"); + if (mask & RNS_UD_16BPP_SUPPORT) + winpr_str_append("RNS_UD_16BPP_SUPPORT", buffer, size, "|"); + if (mask & RNS_UD_15BPP_SUPPORT) + winpr_str_append("RNS_UD_15BPP_SUPPORT", buffer, size, "|"); + + if (invalid != 0) + { + char str[32] = { 0 }; + _snprintf(str, sizeof(str), "RNS_UD_INVALID[0x%04" PRIx16 "]", invalid); + winpr_str_append(str, buffer, size, "|"); + } + char hex[32] = { 0 }; + _snprintf(hex, sizeof(hex), "[0x%04" PRIx16 "]", mask); + return buffer; +} diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index 8c956f2dd..82fd751c5 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -1332,6 +1332,7 @@ BOOL gcc_read_client_core_data(wStream* s, rdpMcs* mcs, UINT16 blockLength) BOOL gcc_write_client_core_data(wStream* s, const rdpMcs* mcs) { char buffer[2048] = { 0 }; + char dbuffer[2048] = { 0 }; WCHAR* clientName = NULL; size_t clientNameLength; BYTE connectionType; @@ -1392,10 +1393,9 @@ BOOL gcc_write_client_core_data(wStream* s, const rdpMcs* mcs) if (!Stream_EnsureRemainingCapacity(s, 6)) return FALSE; - WLog_DBG(TAG, - "Sending highColorDepth=%s, supportedColorDepths=0x%04" PRIx16 - ", earlyCapabilityFlags=%s", - HighColorToString(highColorDepth), SupportedColorDepths, + WLog_DBG(TAG, "Sending highColorDepth=%s, supportedColorDepths=%s, earlyCapabilityFlags=%s", + HighColorToString(highColorDepth), + freerdp_supported_color_depths_string(SupportedColorDepths, dbuffer, sizeof(dbuffer)), rdp_early_client_caps_string(earlyCapabilityFlags, buffer, sizeof(buffer))); Stream_Write_UINT16(s, highColorDepth); /* highColorDepth */ Stream_Write_UINT16(s, SupportedColorDepths); /* supportedColorDepths */