Reformatting

This commit is contained in:
Martin Fleisz 2019-07-17 15:48:26 +02:00 committed by akallabeth
parent 26bbb459b2
commit 397db534d2

View File

@ -529,8 +529,7 @@ static SSIZE_T freerdp_client_parse_rdp_file_add_line(rdpFile* file, const char*
return index; return index;
} }
static BOOL freerdp_client_parse_rdp_file_string(rdpFile* file, char* name, char* value, static BOOL freerdp_client_parse_rdp_file_string(rdpFile* file, char* name, char* value, int index)
int index)
{ {
BOOL ret = TRUE; BOOL ret = TRUE;
char* valueA = _strdup(value); char* valueA = _strdup(value);
@ -553,14 +552,13 @@ static BOOL freerdp_client_parse_rdp_file_option(rdpFile* file, const char* opti
return freerdp_client_add_option(file, option); return freerdp_client_add_option(file, option);
} }
BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file, const BYTE* buffer, BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file, const BYTE* buffer, size_t size)
size_t size)
{ {
return freerdp_client_parse_rdp_file_buffer_ex(file, buffer, size, NULL); return freerdp_client_parse_rdp_file_buffer_ex(file, buffer, size, NULL);
} }
BOOL freerdp_client_parse_rdp_file_buffer_ex(rdpFile* file, const BYTE* buffer, BOOL freerdp_client_parse_rdp_file_buffer_ex(rdpFile* file, const BYTE* buffer, size_t size,
size_t size, rdp_file_fkt_parse parse) rdp_file_fkt_parse parse)
{ {
BOOL rc = FALSE; BOOL rc = FALSE;
int index; int index;
@ -639,7 +637,6 @@ BOOL freerdp_client_parse_rdp_file_buffer_ex(rdpFile* file, const BYTE* buffer,
if (parse && parse(file->context, name, *type, value)) if (parse && parse(file->context, name, *type, value))
{ {
} }
else if (*type == 'i') else if (*type == 'i')
{ {
@ -676,8 +673,7 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, const char* name)
return freerdp_client_parse_rdp_file_ex(file, name, NULL); return freerdp_client_parse_rdp_file_ex(file, name, NULL);
} }
BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file, const char* name, BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file, const char* name, rdp_file_fkt_parse parse)
rdp_file_fkt_parse parse)
{ {
BOOL status; BOOL status;
BYTE* buffer; BYTE* buffer;
@ -736,10 +732,18 @@ BOOL freerdp_client_parse_rdp_file_ex(rdpFile* file, const char* name,
} }
#define WRITE_ALL_SETTINGS TRUE #define WRITE_ALL_SETTINGS TRUE
#define SETTING_MODIFIED(_settings, _field) (WRITE_ALL_SETTINGS || _settings->SettingsModified[FreeRDP_##_field]) #define SETTING_MODIFIED(_settings, _field) \
#define SETTING_MODIFIED_SET(_target, _settings, _field) if SETTING_MODIFIED(_settings, _field) _target = _settings->_field (WRITE_ALL_SETTINGS || _settings->SettingsModified[FreeRDP_##_field])
#define SETTING_MODIFIED_SET_STRING(_target, _settings, _field) do { if SETTING_MODIFIED(_settings, _field) _target = _strdup(_settings->_field); \ #define SETTING_MODIFIED_SET(_target, _settings, _field) \
if (!_target && _settings->_field) return FALSE; \ if \
SETTING_MODIFIED(_settings, _field) _target = _settings->_field
#define SETTING_MODIFIED_SET_STRING(_target, _settings, _field) \
do \
{ \
if \
SETTING_MODIFIED(_settings, _field) _target = _strdup(_settings->_field); \
if (!_target && _settings->_field) \
return FALSE; \
} while (0) } while (0)
BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, const rdpSettings* settings) BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, const rdpSettings* settings)
@ -826,8 +830,7 @@ BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL u
ConvertToUnicode(CP_UTF8, 0, buffer, length, &unicodestr, 0); ConvertToUnicode(CP_UTF8, 0, buffer, length, &unicodestr, 0);
/* Write multi-byte header */ /* Write multi-byte header */
if ((length < 0) || if ((length < 0) || (fwrite(BOM_UTF16_LE, sizeof(BYTE), 2, fp) != 2) ||
(fwrite(BOM_UTF16_LE, sizeof(BYTE), 2, fp) != 2) ||
(fwrite(unicodestr, 2, (size_t)length, fp) != (size_t)length)) (fwrite(unicodestr, 2, (size_t)length, fp) != (size_t)length))
{ {
free(buffer); free(buffer);
@ -990,7 +993,8 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->AdministrativeSession) if (~file->AdministrativeSession)
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession, file->AdministrativeSession)) if (!freerdp_settings_set_bool(settings, FreeRDP_ConsoleSession,
file->AdministrativeSession))
return FALSE; return FALSE;
} }
@ -1067,10 +1071,10 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
* *
* Values: * Values:
* *
* 0: If server authentication fails, connect to the computer without warning (Connect and dont warn me). * 0: If server authentication fails, connect to the computer without warning (Connect and
* 1: If server authentication fails, do not establish a connection (Do not connect). * dont warn me). 1: If server authentication fails, do not establish a connection (Do not
* 2: If server authentication fails, show a warning and allow me to connect or refuse the connection (Warn me). * connect). 2: If server authentication fails, show a warning and allow me to connect or
* 3: No authentication requirement is specified. * refuse the connection (Warn me). 3: No authentication requirement is specified.
*/ */
settings->AuthenticationLevel = file->AuthenticationLevel; settings->AuthenticationLevel = file->AuthenticationLevel;
} }
@ -1129,7 +1133,8 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~((size_t)file->GatewayAccessToken)) if (~((size_t)file->GatewayAccessToken))
{ {
if (!freerdp_settings_set_string(settings, FreeRDP_GatewayAccessToken, file->GatewayAccessToken)) if (!freerdp_settings_set_string(settings, FreeRDP_GatewayAccessToken,
file->GatewayAccessToken))
return FALSE; return FALSE;
} }
@ -1209,7 +1214,8 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->AllowFontSmoothing) if (~file->AllowFontSmoothing)
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_AllowFontSmoothing, file->AllowFontSmoothing)) if (!freerdp_settings_set_bool(settings, FreeRDP_AllowFontSmoothing,
file->AllowFontSmoothing))
return FALSE; return FALSE;
} }
@ -1282,13 +1288,15 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->RedirectSmartCards) if (~file->RedirectSmartCards)
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSmartCards, file->RedirectSmartCards)) if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSmartCards,
file->RedirectSmartCards))
return FALSE; return FALSE;
} }
if (~file->RedirectClipboard) if (~file->RedirectClipboard)
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectClipboard, file->RedirectClipboard)) if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectClipboard,
file->RedirectClipboard))
return FALSE; return FALSE;
} }
@ -1306,15 +1314,19 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->RedirectPosDevices) if (~file->RedirectPosDevices)
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSerialPorts, file->RedirectComPorts) || if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSerialPorts,
!freerdp_settings_set_bool(settings, FreeRDP_RedirectParallelPorts, file->RedirectComPorts)) file->RedirectComPorts) ||
!freerdp_settings_set_bool(settings, FreeRDP_RedirectParallelPorts,
file->RedirectComPorts))
return FALSE; return FALSE;
} }
if (~file->RedirectComPorts) if (~file->RedirectComPorts)
{ {
if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSerialPorts, file->RedirectComPorts) || if (!freerdp_settings_set_bool(settings, FreeRDP_RedirectSerialPorts,
!freerdp_settings_set_bool(settings, FreeRDP_RedirectParallelPorts, file->RedirectComPorts)) file->RedirectComPorts) ||
!freerdp_settings_set_bool(settings, FreeRDP_RedirectParallelPorts,
file->RedirectComPorts))
return FALSE; return FALSE;
} }
@ -1375,7 +1387,8 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~((size_t)file->PreconnectionBlob)) if (~((size_t)file->PreconnectionBlob))
{ {
if (!freerdp_settings_set_string(settings, FreeRDP_PreconnectionBlob, file->PreconnectionBlob) || if (!freerdp_settings_set_string(settings, FreeRDP_PreconnectionBlob,
file->PreconnectionBlob) ||
!freerdp_settings_set_bool(settings, FreeRDP_SendPreconnectionPdu, TRUE) || !freerdp_settings_set_bool(settings, FreeRDP_SendPreconnectionPdu, TRUE) ||
!freerdp_settings_set_bool(settings, FreeRDP_VmConnectMode, TRUE)) !freerdp_settings_set_bool(settings, FreeRDP_VmConnectMode, TRUE))
return FALSE; return FALSE;