FreeRDP
client/common/file.c File Reference
#include <freerdp/config.h>
#include <errno.h>
#include <ctype.h>
#include <stdlib.h>
#include <winpr/string.h>
#include <winpr/file.h>
#include <freerdp/client.h>
#include <freerdp/client/file.h>
#include <freerdp/client/cmdline.h>
#include <freerdp/channels/urbdrc.h>
#include <freerdp/channels/rdpecam.h>
#include <stdio.h>
#include <string.h>
#include <winpr/wtypes.h>
#include <winpr/crt.h>
#include <winpr/path.h>
#include <freerdp/log.h>

Macros

#define TAG   CLIENT_TAG("common")
 
#define INVALID_INTEGER_VALUE   0xFFFFFFFF
 
#define RDP_FILE_LINE_FLAG_FORMATTED   0x00000001
 
#define RDP_FILE_LINE_FLAG_STANDARD   0x00000002
 
#define RDP_FILE_LINE_FLAG_TYPE_STRING   0x00000010
 
#define RDP_FILE_LINE_FLAG_TYPE_INTEGER   0x00000020
 
#define RDP_FILE_LINE_FLAG_TYPE_BINARY   0x00000040
 
#define WRITE_SETTING_(fmt_, param_)
 
#define WRITE_SETTING_INT(fmt_, param_)
 
#define WRITE_SETTING_STR(fmt_, param_)
 

Functions

static SSIZE_T freerdp_client_rdp_file_add_line (rdpFile *file)
 
static rdpFileLine * freerdp_client_rdp_file_find_line_by_name (const rdpFile *file, const char *name)
 
static void freerdp_client_file_string_check_free (LPSTR str)
 
static BOOL freerdp_client_rdp_file_find_integer_entry (rdpFile *file, const char *name, DWORD **outValue, rdpFileLine **outLine)
 
static BOOL freerdp_client_rdp_file_find_string_entry (rdpFile *file, const char *name, LPSTR **outValue, rdpFileLine **outLine)
 
static BOOL freerdp_client_rdp_file_set_integer (rdpFile *file, const char *name, long value)
 
static BOOL freerdp_client_parse_rdp_file_integer (rdpFile *file, const char *name, const char *value)
 
static BOOL freerdp_client_rdp_file_set_string (rdpFile *file, const char *name, const char *value)
 
static BOOL freerdp_client_add_option (rdpFile *file, const char *option)
 
static BOOL freerdp_client_parse_rdp_file_string (rdpFile *file, char *name, char *value)
 
static BOOL freerdp_client_parse_rdp_file_option (rdpFile *file, const char *option)
 
BOOL freerdp_client_parse_rdp_file_buffer (rdpFile *file, const BYTE *buffer, size_t size)
 
static BOOL trim (char **strptr)
 
static BOOL trim_strings (rdpFile *file)
 
BOOL freerdp_client_parse_rdp_file_buffer_ex (rdpFile *file, const BYTE *buffer, size_t size, rdp_file_fkt_parse parse)
 
BOOL freerdp_client_parse_rdp_file (rdpFile *file, const char *name)
 
BOOL freerdp_client_parse_rdp_file_ex (rdpFile *file, const char *name, rdp_file_fkt_parse parse)
 
static INLINE BOOL FILE_POPULATE_STRING (char **_target, const rdpSettings *_settings, size_t _option)
 
static char * freerdp_client_channel_args_to_string (const rdpSettings *settings, const char *channel, const char *option)
 
BOOL freerdp_client_populate_rdp_file_from_settings (rdpFile *file, const rdpSettings *settings)
 
BOOL freerdp_client_write_rdp_file (const rdpFile *file, const char *name, BOOL unicode)
 
static SSIZE_T freerdp_client_write_setting_to_buffer (char **buffer, size_t *bufferSize, const char *fmt,...)
 
size_t freerdp_client_write_rdp_file_buffer (const rdpFile *file, char *buffer, size_t size)
 
static ADDIN_ARGVrdp_file_to_args (const char *channel, const char *values)
 
BOOL freerdp_client_populate_settings_from_rdp_file (const rdpFile *file, rdpSettings *settings)
 
int freerdp_client_rdp_file_set_string_option (rdpFile *file, const char *name, const char *value)
 
const char * freerdp_client_rdp_file_get_string_option (const rdpFile *file, const char *name)
 
int freerdp_client_rdp_file_set_integer_option (rdpFile *file, const char *name, int value)
 
int freerdp_client_rdp_file_get_integer_option (const rdpFile *file, const char *name)
 
rdpFile * freerdp_client_rdp_file_new (void)
 
rdpFile * freerdp_client_rdp_file_new_ex (DWORD flags)
 
void freerdp_client_rdp_file_free (rdpFile *file)
 
void freerdp_client_rdp_file_set_callback_context (rdpFile *file, void *context)
 

Variables

static const BYTE BOM_UTF16_LE [2] = { 0xFF, 0xFE }
 

Macro Definition Documentation

◆ INVALID_INTEGER_VALUE

#define INVALID_INTEGER_VALUE   0xFFFFFFFF

◆ RDP_FILE_LINE_FLAG_FORMATTED

#define RDP_FILE_LINE_FLAG_FORMATTED   0x00000001

◆ RDP_FILE_LINE_FLAG_STANDARD

#define RDP_FILE_LINE_FLAG_STANDARD   0x00000002

◆ RDP_FILE_LINE_FLAG_TYPE_BINARY

#define RDP_FILE_LINE_FLAG_TYPE_BINARY   0x00000040

◆ RDP_FILE_LINE_FLAG_TYPE_INTEGER

#define RDP_FILE_LINE_FLAG_TYPE_INTEGER   0x00000020

◆ RDP_FILE_LINE_FLAG_TYPE_STRING

#define RDP_FILE_LINE_FLAG_TYPE_STRING   0x00000010

◆ TAG

#define TAG   CLIENT_TAG("common")

FreeRDP: A Remote Desktop Protocol Implementation .rdp file

Copyright 2012 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Remote Desktop Plus - Overview of .rdp file settings: http://www.donkz.nl/files/rdpsettings.html

RDP Settings for Remote Desktop Services in Windows Server 2008 R2: http://technet.microsoft.com/en-us/library/ff393699/

https://docs.microsoft.com/en-us/windows-server/remote/remote-desktop-services/clients/rdp-files

◆ WRITE_SETTING_

#define WRITE_SETTING_ (   fmt_,
  param_ 
)
Value:
{ \
SSIZE_T res = freerdp_client_write_setting_to_buffer(&buffer, &size, fmt_, param_); \
if (res < 0) \
return 0; \
totalSize += (size_t)res; \
}
static SSIZE_T freerdp_client_write_setting_to_buffer(char **buffer, size_t *bufferSize, const char *fmt,...)
Definition: client/common/file.c:1230

◆ WRITE_SETTING_INT

#define WRITE_SETTING_INT (   fmt_,
  param_ 
)
Value:
do \
{ \
if (~(param_)) \
WRITE_SETTING_(fmt_, param_) \
} while (0)

◆ WRITE_SETTING_STR

#define WRITE_SETTING_STR (   fmt_,
  param_ 
)
Value:
do \
{ \
if (~(size_t)(param_)) \
WRITE_SETTING_(fmt_, param_) \
} while (0)

Function Documentation

◆ FILE_POPULATE_STRING()

static INLINE BOOL FILE_POPULATE_STRING ( char **  _target,
const rdpSettings *  _settings,
size_t  _option 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_add_option()

static BOOL freerdp_client_add_option ( rdpFile *  file,
const char *  option 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_channel_args_to_string()

static char* freerdp_client_channel_args_to_string ( const rdpSettings *  settings,
const char *  channel,
const char *  option 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_file_string_check_free()

static void freerdp_client_file_string_check_free ( LPSTR  str)
static
Here is the caller graph for this function:

◆ freerdp_client_parse_rdp_file()

BOOL freerdp_client_parse_rdp_file ( rdpFile *  file,
const char *  name 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_parse_rdp_file_buffer()

BOOL freerdp_client_parse_rdp_file_buffer ( rdpFile *  file,
const BYTE buffer,
size_t  size 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_parse_rdp_file_buffer_ex()

BOOL freerdp_client_parse_rdp_file_buffer_ex ( rdpFile *  file,
const BYTE buffer,
size_t  size,
rdp_file_fkt_parse  parse 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_parse_rdp_file_ex()

BOOL freerdp_client_parse_rdp_file_ex ( rdpFile *  file,
const char *  name,
rdp_file_fkt_parse  parse 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_parse_rdp_file_integer()

static BOOL freerdp_client_parse_rdp_file_integer ( rdpFile *  file,
const char *  name,
const char *  value 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_parse_rdp_file_option()

static BOOL freerdp_client_parse_rdp_file_option ( rdpFile *  file,
const char *  option 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_parse_rdp_file_string()

static BOOL freerdp_client_parse_rdp_file_string ( rdpFile *  file,
char *  name,
char *  value 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_populate_rdp_file_from_settings()

BOOL freerdp_client_populate_rdp_file_from_settings ( rdpFile *  file,
const rdpSettings *  settings 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_populate_settings_from_rdp_file()

BOOL freerdp_client_populate_settings_from_rdp_file ( const rdpFile *  file,
rdpSettings *  settings 
)

Screen Mode Id: http://technet.microsoft.com/en-us/library/ff393692/

This setting corresponds to the selection in the Display configuration slider on the Display tab under Options in RDC.

Values:

1: The remote session will appear in a window. 2: The remote session will appear full screen.

SmartSizingWidth and SmartSizingHeight:

Adding this option to use the DesktopHeight and DesktopWidth as parameters for the SmartSizingWidth and SmartSizingHeight, as there are no options for that in standard RDP files.

Equivalent of doing /smart-sizing:WxH

Authentication Level: http://technet.microsoft.com/en-us/library/ff393709/

This setting corresponds to the selection in the If server authentication fails drop-down list on the Advanced tab under Options in RDC.

Values:

0: If server authentication fails, connect to the computer without warning (Connect and don’t warn me). 1: If server authentication fails, do not establish a connection (Do not connect). 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.

Devices to redirect: http://technet.microsoft.com/en-us/library/ff393728/

This setting corresponds to the selections for Other supported Plug and Play (PnP) devices under More on the Local Resources tab under Options in RDC.

Values:

'*': Redirect all supported Plug and Play devices.

'DynamicDevices': Redirect any supported Plug and Play devices that are connected later.

The hardware ID for the supported Plug and Play device: Redirect the specified supported Plug and Play device.

Examples: devicestoredirect:s:* devicestoredirect:s:DynamicDevices devicestoredirect:s:USB\VID_04A9&PID_30C1\6&4BD985D&0&2;,DynamicDevices

Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_rdp_file_add_line()

static SSIZE_T freerdp_client_rdp_file_add_line ( rdpFile *  file)
static
Here is the caller graph for this function:

◆ freerdp_client_rdp_file_find_integer_entry()

static BOOL freerdp_client_rdp_file_find_integer_entry ( rdpFile *  file,
const char *  name,
DWORD **  outValue,
rdpFileLine **  outLine 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_rdp_file_find_line_by_name()

static rdpFileLine * freerdp_client_rdp_file_find_line_by_name ( const rdpFile *  file,
const char *  name 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_rdp_file_find_string_entry()

static BOOL freerdp_client_rdp_file_find_string_entry ( rdpFile *  file,
const char *  name,
LPSTR **  outValue,
rdpFileLine **  outLine 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_rdp_file_free()

void freerdp_client_rdp_file_free ( rdpFile *  file)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_rdp_file_get_integer_option()

int freerdp_client_rdp_file_get_integer_option ( const rdpFile *  file,
const char *  name 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_rdp_file_get_string_option()

const char* freerdp_client_rdp_file_get_string_option ( const rdpFile *  file,
const char *  name 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_rdp_file_new()

rdpFile* freerdp_client_rdp_file_new ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_rdp_file_new_ex()

rdpFile* freerdp_client_rdp_file_new_ex ( DWORD  flags)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_rdp_file_set_callback_context()

void freerdp_client_rdp_file_set_callback_context ( rdpFile *  file,
void *  context 
)

◆ freerdp_client_rdp_file_set_integer()

static BOOL freerdp_client_rdp_file_set_integer ( rdpFile *  file,
const char *  name,
long  value 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_rdp_file_set_integer_option()

int freerdp_client_rdp_file_set_integer_option ( rdpFile *  file,
const char *  name,
int  value 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_rdp_file_set_string()

static BOOL freerdp_client_rdp_file_set_string ( rdpFile *  file,
const char *  name,
const char *  value 
)
static
Parameters
filerdpFile
namename of the string
valuevalue of the string to set
indexline index of the rdpFile
Returns
0 on success, 1 if the key wasn't found (not a standard key), -1 on error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_rdp_file_set_string_option()

int freerdp_client_rdp_file_set_string_option ( rdpFile *  file,
const char *  name,
const char *  value 
)

Set a string option to a rdpFile

Parameters
filerdpFile
namename of the option
valuevalue of the option
Returns
0 on success
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_write_rdp_file()

BOOL freerdp_client_write_rdp_file ( const rdpFile *  file,
const char *  name,
BOOL  unicode 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_write_rdp_file_buffer()

size_t freerdp_client_write_rdp_file_buffer ( const rdpFile *  file,
char *  buffer,
size_t  size 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ freerdp_client_write_setting_to_buffer()

static SSIZE_T freerdp_client_write_setting_to_buffer ( char **  buffer,
size_t *  bufferSize,
const char *  fmt,
  ... 
)
static
Here is the caller graph for this function:

◆ rdp_file_to_args()

static ADDIN_ARGV* rdp_file_to_args ( const char *  channel,
const char *  values 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ trim()

static BOOL trim ( char **  strptr)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ trim_strings()

static BOOL trim_strings ( rdpFile *  file)
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ BOM_UTF16_LE

const BYTE BOM_UTF16_LE[2] = { 0xFF, 0xFE }
static