Fixed freerdp_client_parse_rdp_file_buffer

The parser function needs a modifyable copy of the input buffer.
This commit is contained in:
Armin Novak 2017-02-14 12:53:14 +01:00
parent 2463575083
commit 2f8e206c58
2 changed files with 195 additions and 152 deletions

View File

@ -59,10 +59,10 @@ static WCHAR CR_LF_STR_W[] = { '\r', '\n', '\0' };
* *
*/ */
static int freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name, int value, int index) static int freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name, int value,
int index)
{ {
int standard = 1; int standard = 1;
#ifdef DEBUG_CLIENT_FILE #ifdef DEBUG_CLIENT_FILE
WLog_DBG(TAG, "%s:i:%d", name, value); WLog_DBG(TAG, "%s:i:%d", name, value);
#endif #endif
@ -201,10 +201,11 @@ static int freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name,
if (index >= 0) if (index >= 0)
{ {
file->lines[index].name = _strdup(name); file->lines[index].name = _strdup(name);
if (!file->lines[index].name) if (!file->lines[index].name)
return -1; return -1;
file->lines[index].iValue = (DWORD) value;
file->lines[index].iValue = (DWORD) value;
file->lines[index].flags = RDP_FILE_LINE_FLAG_FORMATTED; file->lines[index].flags = RDP_FILE_LINE_FLAG_FORMATTED;
file->lines[index].flags |= RDP_FILE_LINE_FLAG_TYPE_INTEGER; file->lines[index].flags |= RDP_FILE_LINE_FLAG_TYPE_INTEGER;
@ -217,32 +218,35 @@ static int freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name,
return standard; return standard;
} }
static BOOL freerdp_client_parse_rdp_file_integer_unicode(rdpFile* file, WCHAR* name, WCHAR* value, int index) static BOOL freerdp_client_parse_rdp_file_integer_unicode(rdpFile* file, const WCHAR* name,
const WCHAR* value, int index)
{ {
int length; int length;
int ivalue; int ivalue;
char* nameA; char* nameA;
char* valueA; char* valueA;
BOOL ret = TRUE; BOOL ret = TRUE;
length = (int) _wcslen(name); length = (int) _wcslen(name);
nameA = (char*) malloc(length + 1); nameA = (char*) malloc(length + 1);
if (!nameA) if (!nameA)
return FALSE; return FALSE;
WideCharToMultiByte(CP_UTF8, 0, name, length, nameA, length, NULL, NULL); WideCharToMultiByte(CP_UTF8, 0, name, length, nameA, length, NULL, NULL);
nameA[length] = '\0'; nameA[length] = '\0';
length = (int) _wcslen(value); length = (int) _wcslen(value);
valueA = (char*) malloc(length + 1); valueA = (char*) malloc(length + 1);
if (!valueA) if (!valueA)
{ {
free(nameA); free(nameA);
return FALSE; return FALSE;
} }
WideCharToMultiByte(CP_UTF8, 0, value, length, valueA, length, NULL, NULL); WideCharToMultiByte(CP_UTF8, 0, value, length, valueA, length, NULL, NULL);
valueA[length] = '\0'; valueA[length] = '\0';
ivalue = atoi(valueA); ivalue = atoi(valueA);
if (freerdp_client_rdp_file_set_integer(file, nameA, ivalue, index) < 0) if (freerdp_client_rdp_file_set_integer(file, nameA, ivalue, index) < 0)
ret = FALSE; ret = FALSE;
@ -251,11 +255,14 @@ static BOOL freerdp_client_parse_rdp_file_integer_unicode(rdpFile* file, WCHAR*
return ret; return ret;
} }
static BOOL freerdp_client_parse_rdp_file_integer_ascii(rdpFile* file, const char* name, const char* value, int index) static BOOL freerdp_client_parse_rdp_file_integer_ascii(rdpFile* file, const char* name,
const char* value, int index)
{ {
int ivalue = atoi(value); int ivalue = atoi(value);
if (freerdp_client_rdp_file_set_integer(file, name, ivalue, index) < 0) if (freerdp_client_rdp_file_set_integer(file, name, ivalue, index) < 0)
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
@ -268,11 +275,11 @@ static BOOL freerdp_client_parse_rdp_file_integer_ascii(rdpFile* file, const cha
* @return 0 on success, 1 if the key wasn't found (not a standard key), -1 on error * @return 0 on success, 1 if the key wasn't found (not a standard key), -1 on error
*/ */
static int freerdp_client_rdp_file_set_string(rdpFile* file, const char* name, const char* value, int index) static int freerdp_client_rdp_file_set_string(rdpFile* file, const char* name, const char* value,
int index)
{ {
int standard = 0; int standard = 0;
LPSTR *tmp = NULL; LPSTR* tmp = NULL;
#ifdef DEBUG_CLIENT_FILE #ifdef DEBUG_CLIENT_FILE
WLog_DBG(TAG, "%s:s:%s", name, value); WLog_DBG(TAG, "%s:s:%s", name, value);
#endif #endif
@ -331,6 +338,7 @@ static int freerdp_client_rdp_file_set_string(rdpFile* file, const char* name, c
file->lines[index].name = _strdup(name); file->lines[index].name = _strdup(name);
file->lines[index].sValue = _strdup(value); file->lines[index].sValue = _strdup(value);
if (!file->lines[index].name || !file->lines[index].sValue) if (!file->lines[index].name || !file->lines[index].sValue)
{ {
free(file->lines[index].name); free(file->lines[index].name);
@ -355,19 +363,22 @@ static BOOL freerdp_client_add_option(rdpFile* file, char* option)
while ((file->argc + 1) > file->argSize) while ((file->argc + 1) > file->argSize)
{ {
int new_size; int new_size;
char **new_argv; char** new_argv;
new_size = file->argSize * 2; new_size = file->argSize * 2;
new_argv = (char**) realloc(file->argv, new_size * sizeof(char*)); new_argv = (char**) realloc(file->argv, new_size * sizeof(char*));
if (!new_argv) if (!new_argv)
return FALSE; return FALSE;
file->argv = new_argv; file->argv = new_argv;
file->argSize = new_size; file->argSize = new_size;
} }
file->argv[file->argc] = _strdup(option); file->argv[file->argc] = _strdup(option);
if (!file->argv[file->argc]) if (!file->argv[file->argc])
return FALSE; return FALSE;
(file->argc)++; (file->argc)++;
return TRUE; return TRUE;
} }
@ -380,33 +391,35 @@ static int freerdp_client_parse_rdp_file_add_line(rdpFile* file, char* line, int
while ((file->lineCount + 1) > file->lineSize) while ((file->lineCount + 1) > file->lineSize)
{ {
int new_size; int new_size;
rdpFileLine *new_line; rdpFileLine* new_line;
new_size = file->lineSize * 2; new_size = file->lineSize * 2;
new_line = (rdpFileLine*) realloc(file->lines, new_size * sizeof(rdpFileLine)); new_line = (rdpFileLine*) realloc(file->lines, new_size * sizeof(rdpFileLine));
if (!new_line) if (!new_line)
return -1; return -1;
file->lines = new_line; file->lines = new_line;
file->lineSize = new_size; file->lineSize = new_size;
} }
ZeroMemory(&(file->lines[file->lineCount]), sizeof(rdpFileLine)); ZeroMemory(&(file->lines[file->lineCount]), sizeof(rdpFileLine));
file->lines[file->lineCount].text = _strdup(line); file->lines[file->lineCount].text = _strdup(line);
if (!file->lines[file->lineCount].text) if (!file->lines[file->lineCount].text)
return -1; return -1;
file->lines[file->lineCount].index = index; file->lines[file->lineCount].index = index;
(file->lineCount)++; (file->lineCount)++;
return index; return index;
} }
static BOOL freerdp_client_parse_rdp_file_add_line_unicode(rdpFile* file, WCHAR* line, int index) static BOOL freerdp_client_parse_rdp_file_add_line_unicode(rdpFile* file, const WCHAR* line,
int index)
{ {
char* lineA = NULL; char* lineA = NULL;
BOOL ret = TRUE; BOOL ret = TRUE;
ConvertFromUnicode(CP_UTF8, 0, line, -1, &lineA, 0, NULL, NULL); ConvertFromUnicode(CP_UTF8, 0, line, -1, &lineA, 0, NULL, NULL);
if (!lineA) if (!lineA)
return FALSE; return FALSE;
@ -421,30 +434,34 @@ static BOOL freerdp_client_parse_rdp_file_add_line_ascii(rdpFile* file, char* li
{ {
if (freerdp_client_parse_rdp_file_add_line(file, line, index) == -1) if (freerdp_client_parse_rdp_file_add_line(file, line, index) == -1)
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
static BOOL freerdp_client_parse_rdp_file_string_unicode(rdpFile* file, WCHAR* name, WCHAR* value, int index) static BOOL freerdp_client_parse_rdp_file_string_unicode(rdpFile* file, const WCHAR* name,
const WCHAR* value, int index)
{ {
int length; int length;
char* nameA; char* nameA;
char* valueA; char* valueA;
BOOL ret = TRUE; BOOL ret = TRUE;
length = (int) _wcslen(name); length = (int) _wcslen(name);
nameA = (char*) malloc(length + 1); nameA = (char*) malloc(length + 1);
if (!nameA) if (!nameA)
return FALSE; return FALSE;
WideCharToMultiByte(CP_UTF8, 0, name, length, nameA, length, NULL, NULL); WideCharToMultiByte(CP_UTF8, 0, name, length, nameA, length, NULL, NULL);
nameA[length] = '\0'; nameA[length] = '\0';
length = (int) _wcslen(value); length = (int) _wcslen(value);
valueA = (char*) malloc(length + 1); valueA = (char*) malloc(length + 1);
if (!valueA) if (!valueA)
{ {
free(nameA); free(nameA);
return FALSE; return FALSE;
} }
WideCharToMultiByte(CP_UTF8, 0, value, length, valueA, length, NULL, NULL); WideCharToMultiByte(CP_UTF8, 0, value, length, valueA, length, NULL, NULL);
valueA[length] = '\0'; valueA[length] = '\0';
@ -456,10 +473,12 @@ static BOOL freerdp_client_parse_rdp_file_string_unicode(rdpFile* file, WCHAR* n
return ret; return ret;
} }
static BOOL freerdp_client_parse_rdp_file_string_ascii(rdpFile* file, char* name, char* value, int index) static BOOL freerdp_client_parse_rdp_file_string_ascii(rdpFile* file, char* name, char* value,
int index)
{ {
BOOL ret = TRUE; BOOL ret = TRUE;
char* valueA = _strdup(value); char* valueA = _strdup(value);
if (!valueA) if (!valueA)
return FALSE; return FALSE;
@ -470,18 +489,18 @@ static BOOL freerdp_client_parse_rdp_file_string_ascii(rdpFile* file, char* name
return ret; return ret;
} }
static BOOL freerdp_client_parse_rdp_file_option_unicode(rdpFile* file, WCHAR* option, int index) static BOOL freerdp_client_parse_rdp_file_option_unicode(rdpFile* file, const WCHAR* option,
int index)
{ {
char* optionA = NULL; char* optionA = NULL;
BOOL ret; BOOL ret;
ConvertFromUnicode(CP_UTF8, 0, option, -1, &optionA, 0, NULL, NULL); ConvertFromUnicode(CP_UTF8, 0, option, -1, &optionA, 0, NULL, NULL);
if (!optionA) if (!optionA)
return FALSE; return FALSE;
ret = freerdp_client_add_option(file, optionA); ret = freerdp_client_add_option(file, optionA);
free(optionA); free(optionA);
return ret; return ret;
} }
@ -490,19 +509,25 @@ static BOOL freerdp_client_parse_rdp_file_option_ascii(rdpFile* file, char* opti
return freerdp_client_add_option(file, option); return freerdp_client_add_option(file, option);
} }
static BOOL freerdp_client_parse_rdp_file_buffer_ascii(rdpFile* file, const BYTE* buffer, size_t size) static BOOL freerdp_client_parse_rdp_file_buffer_ascii(rdpFile* file, const BYTE* buffer,
size_t size)
{ {
int index; int index;
int length; int length;
char* line; char* line;
char* type; char* type;
char* context; char* context;
char *d1, *d2; char* d1, *d2;
char *beg, *end; char* beg, *end;
char *name, *value; char* name, *value;
char* copy = calloc(1, size + sizeof(BYTE));
if (!copy)
return FALSE;
memcpy(copy, buffer, size);
index = 0; index = 0;
line = strtok_s((char*) buffer, "\r\n", &context); line = strtok_s(copy, "\r\n", &context);
while (line) while (line)
{ {
@ -538,7 +563,6 @@ static BOOL freerdp_client_parse_rdp_file_buffer_ascii(rdpFile* file, const BYTE
if ((d2 - d1) != 2) if ((d2 - d1) != 2)
goto next_line; /* improper type length */ goto next_line; /* improper type length */
*d1 = 0; *d1 = 0;
*d2 = 0; *d2 = 0;
name = beg; name = beg;
@ -562,27 +586,33 @@ static BOOL freerdp_client_parse_rdp_file_buffer_ascii(rdpFile* file, const BYTE
} }
} }
next_line: next_line:
line = strtok_s(NULL, "\r\n", &context); line = strtok_s(NULL, "\r\n", &context);
index++; index++;
} }
free(copy);
return TRUE; return TRUE;
} }
static BOOL freerdp_client_parse_rdp_file_buffer_unicode(rdpFile* file, const BYTE* buffer, size_t size) static BOOL freerdp_client_parse_rdp_file_buffer_unicode(rdpFile* file, const BYTE* buffer,
size_t size)
{ {
int index; int index;
int length; int length;
WCHAR* line; const WCHAR* line;
WCHAR* type; WCHAR* type;
WCHAR* context; WCHAR* context;
WCHAR *d1, *d2; WCHAR* d1, *d2;
WCHAR *beg, *end; const WCHAR* name, *value;
WCHAR *name, *value; WCHAR* copy = (WCHAR*)calloc(1, size + sizeof(WCHAR));
if (!copy)
return FALSE;
memcpy(copy, buffer, size);
index = 0; index = 0;
line = wcstok_s((WCHAR*) buffer, CR_LF_STR_W, &context); line = wcstok_s(copy, CR_LF_STR_W, &context);
while (line != NULL) while (line != NULL)
{ {
@ -590,8 +620,8 @@ static BOOL freerdp_client_parse_rdp_file_buffer_unicode(rdpFile* file, const BY
if (length > 1) if (length > 1)
{ {
beg = line; const WCHAR* beg = line;
end = &line[length - 1]; const WCHAR* end = &line[length - 1];
if (!freerdp_client_parse_rdp_file_add_line_unicode(file, line, index)) if (!freerdp_client_parse_rdp_file_add_line_unicode(file, line, index))
return FALSE; return FALSE;
@ -617,7 +647,6 @@ static BOOL freerdp_client_parse_rdp_file_buffer_unicode(rdpFile* file, const BY
if ((d2 - d1) != 2) if ((d2 - d1) != 2)
goto next_line; /* improper type length */ goto next_line; /* improper type length */
*d1 = 0; *d1 = 0;
*d2 = 0; *d2 = 0;
name = beg; name = beg;
@ -641,11 +670,12 @@ static BOOL freerdp_client_parse_rdp_file_buffer_unicode(rdpFile* file, const BY
} }
} }
next_line: next_line:
line = wcstok_s(NULL, CR_LF_STR_W, &context); line = wcstok_s(NULL, CR_LF_STR_W, &context);
index++; index++;
} }
free(copy);
return TRUE; return TRUE;
} }
@ -667,7 +697,6 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, const char* name)
FILE* fp = NULL; FILE* fp = NULL;
size_t read_size; size_t read_size;
long int file_size; long int file_size;
fp = fopen(name, "r"); fp = fopen(name, "r");
if (!fp) if (!fp)
@ -684,11 +713,13 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, const char* name)
} }
buffer = (BYTE*) malloc(file_size + 2); buffer = (BYTE*) malloc(file_size + 2);
if (!buffer) if (!buffer)
{ {
fclose(fp); fclose(fp);
return FALSE; return FALSE;
} }
read_size = fread(buffer, file_size, 1, fp); read_size = fread(buffer, file_size, 1, fp);
if (!read_size) if (!read_size)
@ -696,6 +727,7 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, const char* name)
if (!ferror(fp)) if (!ferror(fp))
read_size = file_size; read_size = file_size;
} }
fclose(fp); fclose(fp);
if (read_size < 1) if (read_size < 1)
@ -706,11 +738,8 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, const char* name)
buffer[file_size] = '\0'; buffer[file_size] = '\0';
buffer[file_size + 1] = '\0'; buffer[file_size + 1] = '\0';
status = freerdp_client_parse_rdp_file_buffer(file, buffer, file_size); status = freerdp_client_parse_rdp_file_buffer(file, buffer, file_size);
free(buffer); free(buffer);
return status; return status;
} }
@ -718,8 +747,8 @@ BOOL freerdp_client_parse_rdp_file(rdpFile* file, const char* name)
#define SETTING_MODIFIED(_settings, _field) (WRITE_ALL_SETTINGS || _settings->SettingsModified[FreeRDP_##_field]) #define SETTING_MODIFIED(_settings, _field) (WRITE_ALL_SETTINGS || _settings->SettingsModified[FreeRDP_##_field])
#define SETTING_MODIFIED_SET(_target, _settings, _field) if SETTING_MODIFIED(_settings, _field) _target = _settings->_field #define SETTING_MODIFIED_SET(_target, _settings, _field) 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); \ #define SETTING_MODIFIED_SET_STRING(_target, _settings, _field) do { if SETTING_MODIFIED(_settings, _field) _target = _strdup(_settings->_field); \
if (!_target) return FALSE; \ if (!_target) 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)
{ {
@ -751,7 +780,6 @@ BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, const rdpSett
SETTING_MODIFIED_SET_STRING(file->GatewayHostname, settings, GatewayHostname); SETTING_MODIFIED_SET_STRING(file->GatewayHostname, settings, GatewayHostname);
SETTING_MODIFIED_SET(file->GatewayUsageMethod, settings, GatewayUsageMethod); SETTING_MODIFIED_SET(file->GatewayUsageMethod, settings, GatewayUsageMethod);
SETTING_MODIFIED_SET(file->PromptCredentialOnce, settings, GatewayUseSameCredentials); SETTING_MODIFIED_SET(file->PromptCredentialOnce, settings, GatewayUseSameCredentials);
SETTING_MODIFIED_SET(file->RemoteApplicationMode, settings, RemoteApplicationMode); SETTING_MODIFIED_SET(file->RemoteApplicationMode, settings, RemoteApplicationMode);
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationProgram, settings, RemoteApplicationProgram); SETTING_MODIFIED_SET_STRING(file->RemoteApplicationProgram, settings, RemoteApplicationProgram);
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationName, settings, RemoteApplicationName); SETTING_MODIFIED_SET_STRING(file->RemoteApplicationName, settings, RemoteApplicationName);
@ -759,10 +787,8 @@ BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, const rdpSett
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationFile, settings, RemoteApplicationFile); SETTING_MODIFIED_SET_STRING(file->RemoteApplicationFile, settings, RemoteApplicationFile);
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationGuid, settings, RemoteApplicationGuid); SETTING_MODIFIED_SET_STRING(file->RemoteApplicationGuid, settings, RemoteApplicationGuid);
SETTING_MODIFIED_SET_STRING(file->RemoteApplicationCmdLine, settings, RemoteApplicationCmdLine); SETTING_MODIFIED_SET_STRING(file->RemoteApplicationCmdLine, settings, RemoteApplicationCmdLine);
SETTING_MODIFIED_SET(file->SpanMonitors, settings, SpanMonitors); SETTING_MODIFIED_SET(file->SpanMonitors, settings, SpanMonitors);
SETTING_MODIFIED_SET(file->UseMultiMon, settings, UseMultimon); SETTING_MODIFIED_SET(file->UseMultiMon, settings, UseMultimon);
return TRUE; return TRUE;
} }
@ -773,7 +799,6 @@ BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL u
char* buffer; char* buffer;
int status = 0; int status = 0;
WCHAR* unicodestr = NULL; WCHAR* unicodestr = NULL;
length = (int) freerdp_client_write_rdp_file_buffer(file, NULL, 0); length = (int) freerdp_client_write_rdp_file_buffer(file, NULL, 0);
if (length < 0) if (length < 0)
@ -801,7 +826,7 @@ BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL u
/* Write multi-byte header */ /* Write multi-byte header */
if (fwrite(BOM_UTF16_LE, sizeof(BYTE), 2, fp) != 2 || if (fwrite(BOM_UTF16_LE, sizeof(BYTE), 2, fp) != 2 ||
fwrite(unicodestr, 2, length, fp) != length) fwrite(unicodestr, 2, length, fp) != length)
{ {
free(buffer); free(buffer);
free(unicodestr); free(unicodestr);
@ -826,7 +851,6 @@ BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL u
} }
free(buffer); free(buffer);
return (status == 0) ? TRUE : FALSE; return (status == 0) ? TRUE : FALSE;
} }
@ -845,7 +869,6 @@ size_t freerdp_client_write_rdp_file_buffer(const rdpFile* file, char* buffer, s
for (index = 0; index < file->lineCount; index++) for (index = 0; index < file->lineCount; index++)
{ {
line = &(file->lines[index]); line = &(file->lines[index]);
length = (int) strlen(line->text); length = (int) strlen(line->text);
if (!buffer) if (!buffer)
@ -882,6 +905,7 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (!freerdp_parse_username(file->Username, &user, &domain)) if (!freerdp_parse_username(file->Username, &user, &domain))
return FALSE; return FALSE;
if (freerdp_set_param_string(settings, FreeRDP_Username, user) != 0) if (freerdp_set_param_string(settings, FreeRDP_Username, user) != 0)
return FALSE; return FALSE;
@ -917,26 +941,35 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->DesktopWidth) if (~file->DesktopWidth)
freerdp_set_param_uint32(settings, FreeRDP_DesktopWidth, file->DesktopWidth); freerdp_set_param_uint32(settings, FreeRDP_DesktopWidth, file->DesktopWidth);
if (~file->DesktopHeight) if (~file->DesktopHeight)
freerdp_set_param_uint32(settings, FreeRDP_DesktopHeight, file->DesktopHeight); freerdp_set_param_uint32(settings, FreeRDP_DesktopHeight, file->DesktopHeight);
if (~file->SessionBpp) if (~file->SessionBpp)
freerdp_set_param_uint32(settings, FreeRDP_ColorDepth, file->SessionBpp); freerdp_set_param_uint32(settings, FreeRDP_ColorDepth, file->SessionBpp);
if (~file->ConnectToConsole) if (~file->ConnectToConsole)
freerdp_set_param_bool(settings, FreeRDP_ConsoleSession, file->ConnectToConsole); freerdp_set_param_bool(settings, FreeRDP_ConsoleSession, file->ConnectToConsole);
if (~file->AdministrativeSession) if (~file->AdministrativeSession)
freerdp_set_param_bool(settings, FreeRDP_ConsoleSession, file->AdministrativeSession); freerdp_set_param_bool(settings, FreeRDP_ConsoleSession, file->AdministrativeSession);
if (~file->NegotiateSecurityLayer) if (~file->NegotiateSecurityLayer)
freerdp_set_param_bool(settings, FreeRDP_NegotiateSecurityLayer, file->NegotiateSecurityLayer); freerdp_set_param_bool(settings, FreeRDP_NegotiateSecurityLayer, file->NegotiateSecurityLayer);
if (~file->EnableCredSSPSupport) if (~file->EnableCredSSPSupport)
freerdp_set_param_bool(settings, FreeRDP_NlaSecurity, file->EnableCredSSPSupport); freerdp_set_param_bool(settings, FreeRDP_NlaSecurity, file->EnableCredSSPSupport);
if (~((size_t) file->AlternateShell)) if (~((size_t) file->AlternateShell))
{ {
if(freerdp_set_param_string(settings, FreeRDP_AlternateShell, file->AlternateShell) != 0) if (freerdp_set_param_string(settings, FreeRDP_AlternateShell, file->AlternateShell) != 0)
return FALSE; return FALSE;
} }
if (~((size_t) file->ShellWorkingDirectory)) if (~((size_t) file->ShellWorkingDirectory))
{ {
if (freerdp_set_param_string(settings, FreeRDP_ShellWorkingDirectory, file->ShellWorkingDirectory) != 0) if (freerdp_set_param_string(settings, FreeRDP_ShellWorkingDirectory,
file->ShellWorkingDirectory) != 0)
return FALSE; return FALSE;
} }
@ -954,22 +987,23 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
* 1: The remote session will appear in a window. * 1: The remote session will appear in a window.
* 2: The remote session will appear full screen. * 2: The remote session will appear full screen.
*/ */
freerdp_set_param_bool(settings, FreeRDP_Fullscreen, freerdp_set_param_bool(settings, FreeRDP_Fullscreen,
(file->ScreenModeId == 2) ? TRUE : FALSE); (file->ScreenModeId == 2) ? TRUE : FALSE);
} }
if (~((size_t) file->SmartSizing)) if (~((size_t) file->SmartSizing))
{ {
freerdp_set_param_bool(settings, FreeRDP_SmartSizing, freerdp_set_param_bool(settings, FreeRDP_SmartSizing,
(file->SmartSizing == 1) ? TRUE : FALSE); (file->SmartSizing == 1) ? TRUE : FALSE);
} }
if (~((size_t) file->LoadBalanceInfo)) if (~((size_t) file->LoadBalanceInfo))
{ {
settings->LoadBalanceInfo = (BYTE*) _strdup(file->LoadBalanceInfo); settings->LoadBalanceInfo = (BYTE*) _strdup(file->LoadBalanceInfo);
if (!settings->LoadBalanceInfo) if (!settings->LoadBalanceInfo)
return FALSE; return FALSE;
settings->LoadBalanceInfoLength = (int) strlen((char*) settings->LoadBalanceInfo); settings->LoadBalanceInfoLength = (int) strlen((char*) settings->LoadBalanceInfo);
} }
@ -989,9 +1023,8 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
* 2: If server authentication fails, show a warning and allow me to connect or refuse the connection (Warn me). * 2: If server authentication fails, show a warning and allow me to connect or refuse the connection (Warn me).
* 3: No authentication requirement is specified. * 3: No authentication requirement is specified.
*/ */
freerdp_set_param_bool(settings, FreeRDP_IgnoreCertificate, freerdp_set_param_bool(settings, FreeRDP_IgnoreCertificate,
(file->AuthenticationLevel == 0) ? TRUE : FALSE); (file->AuthenticationLevel == 0) ? TRUE : FALSE);
} }
if (~file->ConnectionType) if (~file->ConnectionType)
@ -1039,50 +1072,66 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (~file->PromptCredentialOnce) if (~file->PromptCredentialOnce)
freerdp_set_param_bool(settings, FreeRDP_GatewayUseSameCredentials, file->PromptCredentialOnce); freerdp_set_param_bool(settings, FreeRDP_GatewayUseSameCredentials, file->PromptCredentialOnce);
if (~file->RemoteApplicationMode) if (~file->RemoteApplicationMode)
freerdp_set_param_bool(settings, FreeRDP_RemoteApplicationMode, file->RemoteApplicationMode); freerdp_set_param_bool(settings, FreeRDP_RemoteApplicationMode, file->RemoteApplicationMode);
if (~((size_t) file->RemoteApplicationProgram)) if (~((size_t) file->RemoteApplicationProgram))
{ {
if (freerdp_set_param_string(settings, FreeRDP_RemoteApplicationProgram, file->RemoteApplicationProgram) != 0) if (freerdp_set_param_string(settings, FreeRDP_RemoteApplicationProgram,
file->RemoteApplicationProgram) != 0)
return FALSE; return FALSE;
} }
if (~((size_t) file->RemoteApplicationName)) if (~((size_t) file->RemoteApplicationName))
{ {
if (freerdp_set_param_string(settings, FreeRDP_RemoteApplicationName, file->RemoteApplicationName) != 0) if (freerdp_set_param_string(settings, FreeRDP_RemoteApplicationName,
file->RemoteApplicationName) != 0)
return FALSE; return FALSE;
} }
if (~((size_t) file->RemoteApplicationIcon)) if (~((size_t) file->RemoteApplicationIcon))
{ {
if (freerdp_set_param_string(settings, FreeRDP_RemoteApplicationIcon, file->RemoteApplicationIcon) != 0) if (freerdp_set_param_string(settings, FreeRDP_RemoteApplicationIcon,
file->RemoteApplicationIcon) != 0)
return FALSE; return FALSE;
} }
if (~((size_t) file->RemoteApplicationFile)) if (~((size_t) file->RemoteApplicationFile))
{ {
if (freerdp_set_param_string(settings, FreeRDP_RemoteApplicationGuid, file->RemoteApplicationGuid) != 0) if (freerdp_set_param_string(settings, FreeRDP_RemoteApplicationGuid,
file->RemoteApplicationGuid) != 0)
return FALSE; return FALSE;
} }
if (~((size_t) file->RemoteApplicationCmdLine)) if (~((size_t) file->RemoteApplicationCmdLine))
{ {
if (freerdp_set_param_string(settings, FreeRDP_RemoteApplicationCmdLine, file->RemoteApplicationCmdLine) != 0) if (freerdp_set_param_string(settings, FreeRDP_RemoteApplicationCmdLine,
file->RemoteApplicationCmdLine) != 0)
return FALSE; return FALSE;
} }
if (~file->SpanMonitors) if (~file->SpanMonitors)
freerdp_set_param_bool(settings, FreeRDP_SpanMonitors, file->SpanMonitors); freerdp_set_param_bool(settings, FreeRDP_SpanMonitors, file->SpanMonitors);
if (~file->UseMultiMon) if (~file->UseMultiMon)
freerdp_set_param_bool(settings, FreeRDP_UseMultimon, file->UseMultiMon); freerdp_set_param_bool(settings, FreeRDP_UseMultimon, file->UseMultiMon);
if (~file->AllowFontSmoothing) if (~file->AllowFontSmoothing)
freerdp_set_param_bool(settings, FreeRDP_AllowFontSmoothing, file->AllowFontSmoothing); freerdp_set_param_bool(settings, FreeRDP_AllowFontSmoothing, file->AllowFontSmoothing);
if (~file->DisableWallpaper) if (~file->DisableWallpaper)
freerdp_set_param_bool(settings, FreeRDP_DisableWallpaper, file->DisableWallpaper); freerdp_set_param_bool(settings, FreeRDP_DisableWallpaper, file->DisableWallpaper);
if (~file->DisableFullWindowDrag) if (~file->DisableFullWindowDrag)
freerdp_set_param_bool(settings, FreeRDP_DisableFullWindowDrag, file->DisableFullWindowDrag); freerdp_set_param_bool(settings, FreeRDP_DisableFullWindowDrag, file->DisableFullWindowDrag);
if (~file->DisableMenuAnims) if (~file->DisableMenuAnims)
freerdp_set_param_bool(settings, FreeRDP_DisableMenuAnims, file->DisableMenuAnims); freerdp_set_param_bool(settings, FreeRDP_DisableMenuAnims, file->DisableMenuAnims);
if (~file->DisableThemes) if (~file->DisableThemes)
freerdp_set_param_bool(settings, FreeRDP_DisableThemes, file->DisableThemes); freerdp_set_param_bool(settings, FreeRDP_DisableThemes, file->DisableThemes);
if (~file->AllowDesktopComposition) if (~file->AllowDesktopComposition)
freerdp_set_param_bool(settings, FreeRDP_AllowDesktopComposition, file->AllowDesktopComposition); freerdp_set_param_bool(settings, FreeRDP_AllowDesktopComposition, file->AllowDesktopComposition);
@ -1090,10 +1139,12 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
freerdp_set_param_bool(settings, FreeRDP_BitmapCachePersistEnabled, file->BitmapCachePersistEnable); freerdp_set_param_bool(settings, FreeRDP_BitmapCachePersistEnabled, file->BitmapCachePersistEnable);
if (~file->DisableRemoteAppCapsCheck) if (~file->DisableRemoteAppCapsCheck)
freerdp_set_param_bool(settings, FreeRDP_DisableRemoteAppCapsCheck, file->DisableRemoteAppCapsCheck); freerdp_set_param_bool(settings, FreeRDP_DisableRemoteAppCapsCheck,
file->DisableRemoteAppCapsCheck);
if (~file->AutoReconnectionEnabled) if (~file->AutoReconnectionEnabled)
freerdp_set_param_bool(settings, FreeRDP_AutoReconnectionEnabled, file->AutoReconnectionEnabled); freerdp_set_param_bool(settings, FreeRDP_AutoReconnectionEnabled, file->AutoReconnectionEnabled);
if (~file->AutoReconnectMaxRetries) if (~file->AutoReconnectMaxRetries)
freerdp_set_param_uint32(settings, FreeRDP_AutoReconnectMaxRetries, file->AutoReconnectMaxRetries); freerdp_set_param_uint32(settings, FreeRDP_AutoReconnectMaxRetries, file->AutoReconnectMaxRetries);
@ -1152,7 +1203,6 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
* devicestoredirect:s:USB\VID_04A9&PID_30C1\6&4BD985D&0&2;,DynamicDevices * devicestoredirect:s:USB\VID_04A9&PID_30C1\6&4BD985D&0&2;,DynamicDevices
* *
*/ */
freerdp_set_param_bool(settings, FreeRDP_RedirectDrives, TRUE); freerdp_set_param_bool(settings, FreeRDP_RedirectDrives, TRUE);
} }
@ -1164,7 +1214,6 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
* Very similar to DevicesToRedirect, but can contain a * Very similar to DevicesToRedirect, but can contain a
* comma-separated list of drive letters to redirect. * comma-separated list of drive letters to redirect.
*/ */
freerdp_set_param_bool(settings, FreeRDP_RedirectDrives, TRUE); freerdp_set_param_bool(settings, FreeRDP_RedirectDrives, TRUE);
} }
@ -1176,10 +1225,11 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
if (file->argc > 1) if (file->argc > 1)
{ {
char* ConnectionFile = settings->ConnectionFile; char* ConnectionFile = settings->ConnectionFile;
settings->ConnectionFile = NULL; settings->ConnectionFile = NULL;
if (freerdp_client_settings_parse_command_line(settings, file->argc, file->argv, FALSE) < 0) if (freerdp_client_settings_parse_command_line(settings, file->argc, file->argv, FALSE) < 0)
return FALSE; return FALSE;
settings->ConnectionFile = ConnectionFile; settings->ConnectionFile = ConnectionFile;
} }
@ -1189,9 +1239,7 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
static rdpFileLine* freerdp_client_rdp_file_find_line_index(rdpFile* file, int index) static rdpFileLine* freerdp_client_rdp_file_find_line_index(rdpFile* file, int index)
{ {
rdpFileLine* line; rdpFileLine* line;
line = &(file->lines[index]); line = &(file->lines[index]);
return line; return line;
} }
@ -1232,19 +1280,21 @@ int freerdp_client_rdp_file_set_string_option(rdpFile* file, const char* name, c
int length; int length;
char* text; char* text;
rdpFileLine* line; rdpFileLine* line;
length = _scprintf("%s:s:%s", name, value); length = _scprintf("%s:s:%s", name, value);
text = (char*) malloc(length + 1); text = (char*) malloc(length + 1);
if (!text) if (!text)
return -1; return -1;
sprintf_s(text, length + 1, "%s:s:%s", name, value ? value : ""); sprintf_s(text, length + 1, "%s:s:%s", name, value ? value : "");
text[length] = '\0'; text[length] = '\0';
line = freerdp_client_rdp_file_find_line_by_name(file, name); line = freerdp_client_rdp_file_find_line_by_name(file, name);
if (line) if (line)
{ {
free(line->sValue); free(line->sValue);
line->sValue = _strdup(value); line->sValue = _strdup(value);
if (!line->sValue) if (!line->sValue)
goto out_fail; goto out_fail;
@ -1254,6 +1304,7 @@ int freerdp_client_rdp_file_set_string_option(rdpFile* file, const char* name, c
else else
{ {
index = freerdp_client_parse_rdp_file_add_line(file, text, -1); index = freerdp_client_parse_rdp_file_add_line(file, text, -1);
if (index == -1) if (index == -1)
goto out_fail; goto out_fail;
@ -1267,17 +1318,14 @@ int freerdp_client_rdp_file_set_string_option(rdpFile* file, const char* name, c
} }
return 0; return 0;
out_fail: out_fail:
free(text); free(text);
return -1; return -1;
} }
const char* freerdp_client_rdp_file_get_string_option(rdpFile* file, const char* name) const char* freerdp_client_rdp_file_get_string_option(rdpFile* file, const char* name)
{ {
rdpFileLine* line; rdpFileLine* line;
line = freerdp_client_rdp_file_find_line_by_name(file, name); line = freerdp_client_rdp_file_find_line_by_name(file, name);
if (!line) if (!line)
@ -1295,9 +1343,7 @@ int freerdp_client_rdp_file_set_integer_option(rdpFile* file, const char* name,
int length; int length;
char* text; char* text;
rdpFileLine* line; rdpFileLine* line;
line = freerdp_client_rdp_file_find_line_by_name(file, name); line = freerdp_client_rdp_file_find_line_by_name(file, name);
length = _scprintf("%s:i:%d", name, value); length = _scprintf("%s:i:%d", name, value);
text = (char*) malloc(length + 1); text = (char*) malloc(length + 1);
sprintf_s(text, length + 1, "%s:i:%d", name, value); sprintf_s(text, length + 1, "%s:i:%d", name, value);
@ -1306,18 +1352,19 @@ int freerdp_client_rdp_file_set_integer_option(rdpFile* file, const char* name,
if (line) if (line)
{ {
line->iValue = value; line->iValue = value;
free(line->text); free(line->text);
line->text = text; line->text = text;
} }
else else
{ {
index = freerdp_client_parse_rdp_file_add_line(file, text, -1); index = freerdp_client_parse_rdp_file_add_line(file, text, -1);
if (index < 0) if (index < 0)
{ {
free(text); free(text);
return -1; return -1;
} }
line = freerdp_client_rdp_file_find_line_index(file, index); line = freerdp_client_rdp_file_find_line_index(file, index);
if (freerdp_client_rdp_file_set_integer(file, (char*) name, value, index) < 0) if (freerdp_client_rdp_file_set_integer(file, (char*) name, value, index) < 0)
@ -1335,7 +1382,6 @@ int freerdp_client_rdp_file_set_integer_option(rdpFile* file, const char* name,
int freerdp_client_rdp_file_get_integer_option(rdpFile* file, const char* name) int freerdp_client_rdp_file_get_integer_option(rdpFile* file, const char* name)
{ {
rdpFileLine* line; rdpFileLine* line;
line = freerdp_client_rdp_file_find_line_by_name(file, name); line = freerdp_client_rdp_file_find_line_by_name(file, name);
if (!line) if (!line)
@ -1356,26 +1402,25 @@ static void freerdp_client_file_string_check_free(LPSTR str)
rdpFile* freerdp_client_rdp_file_new() rdpFile* freerdp_client_rdp_file_new()
{ {
rdpFile* file; rdpFile* file;
file = (rdpFile*) malloc(sizeof(rdpFile)); file = (rdpFile*) malloc(sizeof(rdpFile));
if (file) if (file)
{ {
FillMemory(file, sizeof(rdpFile), 0xFF); FillMemory(file, sizeof(rdpFile), 0xFF);
file->lineCount = 0; file->lineCount = 0;
file->lineSize = 32; file->lineSize = 32;
file->lines = (rdpFileLine*) malloc(file->lineSize * sizeof(rdpFileLine)); file->lines = (rdpFileLine*) malloc(file->lineSize * sizeof(rdpFileLine));
if (!file->lines) if (!file->lines)
{ {
free(file); free(file);
return NULL; return NULL;
} }
file->argc = 0; file->argc = 0;
file->argSize = 32; file->argSize = 32;
file->argv = (char**) malloc(file->argSize * sizeof(char*)); file->argv = (char**) malloc(file->argSize * sizeof(char*));
if (!file->argv) if (!file->argv)
{ {
free(file->lines); free(file->lines);
@ -1440,7 +1485,6 @@ void freerdp_client_rdp_file_free(rdpFile* file)
freerdp_client_file_string_check_free(file->DrivesToRedirect); freerdp_client_file_string_check_free(file->DrivesToRedirect);
freerdp_client_file_string_check_free(file->DevicesToRedirect); freerdp_client_file_string_check_free(file->DevicesToRedirect);
freerdp_client_file_string_check_free(file->WinPosStr); freerdp_client_file_string_check_free(file->WinPosStr);
free(file); free(file);
} }
} }

View File

@ -5,7 +5,7 @@
#include <freerdp/client/file.h> #include <freerdp/client/file.h>
static BYTE testRdpFileUTF16[] = static const BYTE testRdpFileUTF16[] =
{ {
0xff, 0xfe, 0x73, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00, 0x65, 0x00, 0xff, 0xfe, 0x73, 0x00, 0x63, 0x00, 0x72, 0x00, 0x65, 0x00, 0x65, 0x00,
0x6e, 0x00, 0x20, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x6d, 0x00, 0x6f, 0x00, 0x64, 0x00, 0x65, 0x00,
@ -210,55 +210,55 @@ static BYTE testRdpFileUTF16[] =
}; };
static char testRdpFileUTF8[] = static char testRdpFileUTF8[] =
"screen mode id:i:2\n" "screen mode id:i:2\n"
"use multimon:i:0\n" "use multimon:i:0\n"
"desktopwidth:i:1920\n" "desktopwidth:i:1920\n"
"desktopheight:i:1080\n" "desktopheight:i:1080\n"
"session bpp:i:32\n" "session bpp:i:32\n"
"winposstr:s:0,1,553,211,1353,811\n" "winposstr:s:0,1,553,211,1353,811\n"
"compression:i:1\n" "compression:i:1\n"
"keyboardhook:i:2\n" "keyboardhook:i:2\n"
"audiocapturemode:i:0\n" "audiocapturemode:i:0\n"
"videoplaybackmode:i:1\n" "videoplaybackmode:i:1\n"
"connection type:i:7\n" "connection type:i:7\n"
"networkautodetect:i:1\n" "networkautodetect:i:1\n"
"bandwidthautodetect:i:1\n" "bandwidthautodetect:i:1\n"
"displayconnectionbar:i:1\n" "displayconnectionbar:i:1\n"
"enableworkspacereconnect:i:0\n" "enableworkspacereconnect:i:0\n"
"disable wallpaper:i:0\n" "disable wallpaper:i:0\n"
"allow font smoothing:i:0\n" "allow font smoothing:i:0\n"
"allow desktop composition:i:0\n" "allow desktop composition:i:0\n"
"disable full window drag:i:1\n" "disable full window drag:i:1\n"
"disable menu anims:i:1\n" "disable menu anims:i:1\n"
"disable themes:i:0\n" "disable themes:i:0\n"
"disable cursor setting:i:0\n" "disable cursor setting:i:0\n"
"bitmapcachepersistenable:i:1\n" "bitmapcachepersistenable:i:1\n"
"full address:s:LAB1-W7-DM-01.lab1.awake.local\n" "full address:s:LAB1-W7-DM-01.lab1.awake.local\n"
"audiomode:i:0\n" "audiomode:i:0\n"
"redirectprinters:i:1\n" "redirectprinters:i:1\n"
"redirectcomports:i:0\n" "redirectcomports:i:0\n"
"redirectsmartcards:i:1\n" "redirectsmartcards:i:1\n"
"redirectclipboard:i:1\n" "redirectclipboard:i:1\n"
"redirectposdevices:i:0\n" "redirectposdevices:i:0\n"
"autoreconnection enabled:i:1\n" "autoreconnection enabled:i:1\n"
"authentication level:i:2\n" "authentication level:i:2\n"
"prompt for credentials:i:0\n" "prompt for credentials:i:0\n"
"negotiate security layer:i:1\n" "negotiate security layer:i:1\n"
"remoteapplicationmode:i:0\n" "remoteapplicationmode:i:0\n"
"alternate shell:s:\n" "alternate shell:s:\n"
"shell working directory:s:\n" "shell working directory:s:\n"
"gatewayhostname:s:LAB1-W2K8R2-GW.lab1.awake.local\n" "gatewayhostname:s:LAB1-W2K8R2-GW.lab1.awake.local\n"
"gatewayusagemethod:i:1\n" "gatewayusagemethod:i:1\n"
"gatewaycredentialssource:i:0\n" "gatewaycredentialssource:i:0\n"
"gatewayprofileusagemethod:i:1\n" "gatewayprofileusagemethod:i:1\n"
"promptcredentialonce:i:1\n" "promptcredentialonce:i:1\n"
"use redirection server name:i:0\n" "use redirection server name:i:0\n"
"rdgiskdcproxy:i:0\n" "rdgiskdcproxy:i:0\n"
"kdcproxyname:s:\n" "kdcproxyname:s:\n"
"drivestoredirect:s:*\n" "drivestoredirect:s:*\n"
"username:s:LAB1\\JohnDoe\n" "username:s:LAB1\\JohnDoe\n"
"vendor integer:i:123\n" "vendor integer:i:123\n"
"vendor string:s:microsoft\n"; "vendor string:s:microsoft\n";
int TestClientRdpFile(int argc, char* argv[]) int TestClientRdpFile(int argc, char* argv[])
{ {
@ -267,15 +267,15 @@ int TestClientRdpFile(int argc, char* argv[])
char* sValue; char* sValue;
rdpFile* file; rdpFile* file;
rdpFileLine* line; rdpFileLine* line;
/* Unicode */ /* Unicode */
file = freerdp_client_rdp_file_new(); file = freerdp_client_rdp_file_new();
if (!file) if (!file)
{ {
printf("rdp_file_new failed\n"); printf("rdp_file_new failed\n");
return -1; return -1;
} }
freerdp_client_parse_rdp_file_buffer(file, testRdpFileUTF16, sizeof(testRdpFileUTF16)); freerdp_client_parse_rdp_file_buffer(file, testRdpFileUTF16, sizeof(testRdpFileUTF16));
if (file->UseMultiMon != 0) if (file->UseMultiMon != 0)
@ -292,21 +292,20 @@ int TestClientRdpFile(int argc, char* argv[])
if (file->GatewayProfileUsageMethod != 1) if (file->GatewayProfileUsageMethod != 1)
{ {
printf("GatewayProfileUsageMethod mismatch: Actual: %"PRIu32", Expected: 1\n", file->GatewayProfileUsageMethod); printf("GatewayProfileUsageMethod mismatch: Actual: %"PRIu32", Expected: 1\n",
file->GatewayProfileUsageMethod);
return -1; return -1;
} }
if (strcmp(file->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local") != 0) if (strcmp(file->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local") != 0)
{ {
printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n", printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n",
file->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local"); file->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local");
return -1; return -1;
} }
freerdp_client_rdp_file_free(file); freerdp_client_rdp_file_free(file);
/* Ascii */ /* Ascii */
file = freerdp_client_rdp_file_new(); file = freerdp_client_rdp_file_new();
freerdp_client_parse_rdp_file_buffer(file, (BYTE*) testRdpFileUTF8, sizeof(testRdpFileUTF8)); freerdp_client_parse_rdp_file_buffer(file, (BYTE*) testRdpFileUTF8, sizeof(testRdpFileUTF8));
@ -324,18 +323,20 @@ int TestClientRdpFile(int argc, char* argv[])
if (file->GatewayProfileUsageMethod != 1) if (file->GatewayProfileUsageMethod != 1)
{ {
printf("GatewayProfileUsageMethod mismatch: Actual: %"PRIu32", Expected: 1\n", file->GatewayProfileUsageMethod); printf("GatewayProfileUsageMethod mismatch: Actual: %"PRIu32", Expected: 1\n",
file->GatewayProfileUsageMethod);
return -1; return -1;
} }
if (strcmp(file->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local") != 0) if (strcmp(file->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local") != 0)
{ {
printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n", printf("GatewayHostname mismatch: Actual: %s, Expected: %s\n",
file->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local"); file->GatewayHostname, "LAB1-W2K8R2-GW.lab1.awake.local");
return -1; return -1;
} }
iValue = freerdp_client_rdp_file_get_integer_option(file, "vendor integer"); iValue = freerdp_client_rdp_file_get_integer_option(file, "vendor integer");
if (freerdp_client_rdp_file_set_integer_option(file, "vendor integer", 456) == -1) if (freerdp_client_rdp_file_set_integer_option(file, "vendor integer", 456) == -1)
{ {
printf("failed to set integer: vendor integer"); printf("failed to set integer: vendor integer");
@ -343,12 +344,11 @@ int TestClientRdpFile(int argc, char* argv[])
} }
iValue = freerdp_client_rdp_file_get_integer_option(file, "vendor integer"); iValue = freerdp_client_rdp_file_get_integer_option(file, "vendor integer");
sValue = (char*) freerdp_client_rdp_file_get_string_option(file, "vendor string"); sValue = (char*) freerdp_client_rdp_file_get_string_option(file, "vendor string");
freerdp_client_rdp_file_set_string_option(file, "vendor string", "apple"); freerdp_client_rdp_file_set_string_option(file, "vendor string", "apple");
sValue = (char*) freerdp_client_rdp_file_get_string_option(file, "vendor string"); sValue = (char*) freerdp_client_rdp_file_get_string_option(file, "vendor string");
freerdp_client_rdp_file_set_string_option(file, "fruits", "banana,oranges"); freerdp_client_rdp_file_set_string_option(file, "fruits", "banana,oranges");
if (freerdp_client_rdp_file_set_integer_option(file, "numbers", 123456789) == -1) if (freerdp_client_rdp_file_set_integer_option(file, "numbers", 123456789) == -1)
{ {
printf("failed to set integer: numbers"); printf("failed to set integer: numbers");
@ -364,19 +364,18 @@ int TestClientRdpFile(int argc, char* argv[])
if (line->flags & RDP_FILE_LINE_FLAG_TYPE_STRING) if (line->flags & RDP_FILE_LINE_FLAG_TYPE_STRING)
{ {
printf("line %02d: name: %s value: %s, %s\n", printf("line %02d: name: %s value: %s, %s\n",
line->index, line->name, line->sValue, line->index, line->name, line->sValue,
(line->flags & RDP_FILE_LINE_FLAG_STANDARD) ? "standard" : "non-standard"); (line->flags & RDP_FILE_LINE_FLAG_STANDARD) ? "standard" : "non-standard");
} }
else if (line->flags & RDP_FILE_LINE_FLAG_TYPE_INTEGER) else if (line->flags & RDP_FILE_LINE_FLAG_TYPE_INTEGER)
{ {
printf("line %02d: name: %s value: %"PRIu32", %s\n", printf("line %02d: name: %s value: %"PRIu32", %s\n",
line->index, line->name, line->iValue, line->index, line->name, line->iValue,
(line->flags & RDP_FILE_LINE_FLAG_STANDARD) ? "standard" : "non-standard"); (line->flags & RDP_FILE_LINE_FLAG_STANDARD) ? "standard" : "non-standard");
} }
} }
} }
freerdp_client_rdp_file_free(file); freerdp_client_rdp_file_free(file);
return 0; return 0;
} }