Merge pull request #846 from awakecoding/master
Command-Line Compatibility Layer
This commit is contained in:
commit
1d9edec48a
@ -21,6 +21,8 @@ set(MODULE_PREFIX "FREERDP_CLIENT")
|
||||
set(${MODULE_PREFIX}_SRCS
|
||||
client.c
|
||||
cmdline.c
|
||||
compatibility.c
|
||||
compatibility.h
|
||||
file.c)
|
||||
|
||||
set(FREERDP_CHANNELS_CLIENT_PATH "../../channels/client")
|
||||
|
@ -31,6 +31,8 @@
|
||||
|
||||
#include <freerdp/client/cmdline.h>
|
||||
|
||||
#include "compatibility.h"
|
||||
|
||||
COMMAND_LINE_ARGUMENT_A args[] =
|
||||
{
|
||||
{ "v", COMMAND_LINE_VALUE_REQUIRED, "<server>[:port]", NULL, NULL, -1, NULL, "Server hostname" },
|
||||
@ -49,7 +51,7 @@ COMMAND_LINE_ARGUMENT_A args[] =
|
||||
{ "multimon", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "Multi-monitor" },
|
||||
{ "workarea", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "Work area" },
|
||||
{ "t", COMMAND_LINE_VALUE_REQUIRED, "<title>", NULL, NULL, -1, "title", "Window title" },
|
||||
{ "decorations", COMMAND_LINE_VALUE_BOOL, NULL, NULL, BoolValueFalse, -1, NULL, "Window decorations" },
|
||||
{ "decorations", COMMAND_LINE_VALUE_BOOL, NULL, NULL, BoolValueTrue, -1, NULL, "Window decorations" },
|
||||
{ "a", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, "addin", "Addin" },
|
||||
{ "vc", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Static virtual channel" },
|
||||
{ "dvc", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Dynamic virtual channel" },
|
||||
@ -109,24 +111,6 @@ COMMAND_LINE_ARGUMENT_A args[] =
|
||||
{ NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
|
||||
};
|
||||
|
||||
BOOL freerdp_detect_windows_style_command_line_syntax(int argc, char** argv)
|
||||
{
|
||||
int index;
|
||||
|
||||
for (index = 1; index < argc; index++)
|
||||
{
|
||||
if (argv[index][0] == '/')
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL freerdp_detect_posix_style_command_line_syntax(int argc, char** argv)
|
||||
{
|
||||
return (!freerdp_detect_windows_style_command_line_syntax(argc, argv));
|
||||
}
|
||||
|
||||
int freerdp_client_print_version()
|
||||
{
|
||||
printf("This is FreeRDP version %s (git %s)\n", FREERDP_VERSION_FULL, GIT_REVISION);
|
||||
@ -232,26 +216,28 @@ int freerdp_client_print_command_line_help(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int freerdp_client_command_line_pre_filter(void* context, int index, LPCSTR arg)
|
||||
int freerdp_client_command_line_pre_filter(void* context, int index, int argc, LPCSTR* argv)
|
||||
{
|
||||
if (index == 1)
|
||||
{
|
||||
int length;
|
||||
rdpSettings* settings;
|
||||
|
||||
length = strlen(arg);
|
||||
length = strlen(argv[index]);
|
||||
|
||||
if (length > 4)
|
||||
{
|
||||
if (_stricmp(&arg[length - 4], ".rdp") == 0)
|
||||
if (_stricmp(&(argv[index])[length - 4], ".rdp") == 0)
|
||||
{
|
||||
settings = (rdpSettings*) context;
|
||||
settings->ConnectionFile = _strdup(arg);
|
||||
settings->ConnectionFile = _strdup(argv[index]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** params)
|
||||
@ -271,6 +257,7 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
|
||||
drive->Path = _strdup(params[2]);
|
||||
|
||||
freerdp_device_collection_add(settings, (RDPDR_DEVICE*) drive);
|
||||
settings->DeviceRedirection = TRUE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -291,6 +278,7 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
|
||||
printer->DriverName = _strdup(params[2]);
|
||||
|
||||
freerdp_device_collection_add(settings, (RDPDR_DEVICE*) printer);
|
||||
settings->DeviceRedirection = TRUE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -311,6 +299,7 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
|
||||
smartcard->Path = _strdup(params[2]);
|
||||
|
||||
freerdp_device_collection_add(settings, (RDPDR_DEVICE*) smartcard);
|
||||
settings->DeviceRedirection = TRUE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -329,6 +318,7 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
|
||||
serial->Path = _strdup(params[2]);
|
||||
|
||||
freerdp_device_collection_add(settings, (RDPDR_DEVICE*) serial);
|
||||
settings->DeviceRedirection = TRUE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -347,6 +337,7 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
|
||||
parallel->Path = _strdup(params[2]);
|
||||
|
||||
freerdp_device_collection_add(settings, (RDPDR_DEVICE*) parallel);
|
||||
settings->DeviceRedirection = TRUE;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -473,7 +464,7 @@ int freerdp_client_command_line_post_filter(void* context, COMMAND_LINE_ARGUMENT
|
||||
|
||||
CommandLineSwitchEnd(arg)
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_parse_username(char* username, char** user, char** domain)
|
||||
@ -626,6 +617,118 @@ int freerdp_map_keyboard_layout_name_to_id(char* name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_detect_windows_style_command_line_syntax(int argc, char** argv, int* count)
|
||||
{
|
||||
int status;
|
||||
DWORD flags;
|
||||
int detect_status;
|
||||
COMMAND_LINE_ARGUMENT_A* arg;
|
||||
|
||||
flags = COMMAND_LINE_SEPARATOR_COLON;
|
||||
flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
|
||||
|
||||
*count = 0;
|
||||
detect_status = 0;
|
||||
CommandLineClearArgumentsA(args);
|
||||
status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags, NULL, NULL, NULL);
|
||||
|
||||
arg = args;
|
||||
|
||||
do
|
||||
{
|
||||
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
|
||||
continue;
|
||||
|
||||
(*count)++;
|
||||
}
|
||||
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
||||
|
||||
if (detect_status == 0)
|
||||
{
|
||||
if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
|
||||
detect_status = -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_detect_posix_style_command_line_syntax(int argc, char** argv, int* count)
|
||||
{
|
||||
int status;
|
||||
DWORD flags;
|
||||
int detect_status;
|
||||
COMMAND_LINE_ARGUMENT_A* arg;
|
||||
|
||||
flags = COMMAND_LINE_SEPARATOR_SPACE;
|
||||
flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
|
||||
flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
|
||||
|
||||
*count = 0;
|
||||
detect_status = 0;
|
||||
CommandLineClearArgumentsA(args);
|
||||
status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags, NULL, NULL, NULL);
|
||||
|
||||
arg = args;
|
||||
|
||||
do
|
||||
{
|
||||
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
|
||||
continue;
|
||||
|
||||
(*count)++;
|
||||
}
|
||||
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
||||
|
||||
if (detect_status == 0)
|
||||
{
|
||||
if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
|
||||
detect_status = -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL freerdp_client_detect_command_line(int argc, char** argv, DWORD* flags)
|
||||
{
|
||||
int old_cli_status;
|
||||
int old_cli_count;
|
||||
int posix_cli_status;
|
||||
int posix_cli_count;
|
||||
int windows_cli_status;
|
||||
int windows_cli_count;
|
||||
BOOL compatibility = FALSE;
|
||||
|
||||
windows_cli_status = freerdp_detect_windows_style_command_line_syntax(argc, argv, &windows_cli_count);
|
||||
posix_cli_status = freerdp_detect_posix_style_command_line_syntax(argc, argv, &posix_cli_count);
|
||||
old_cli_status = freerdp_detect_old_command_line_syntax(argc, argv, &old_cli_count);
|
||||
|
||||
/* Default is POSIX syntax */
|
||||
*flags = COMMAND_LINE_SEPARATOR_SPACE;
|
||||
*flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
|
||||
*flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
|
||||
|
||||
if (windows_cli_count > posix_cli_count)
|
||||
{
|
||||
*flags = COMMAND_LINE_SEPARATOR_COLON;
|
||||
*flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((old_cli_status == 1) || ((old_cli_count > posix_cli_count) && (old_cli_status != -1)))
|
||||
{
|
||||
*flags = COMMAND_LINE_SEPARATOR_SPACE;
|
||||
*flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
|
||||
|
||||
compatibility = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
//printf("windows: %d/%d posix: %d/%d compat: %d/%d\n", windows_cli_status, windows_cli_count,
|
||||
// posix_cli_status, posix_cli_count, old_cli_status, old_cli_count);
|
||||
|
||||
return compatibility;
|
||||
}
|
||||
|
||||
int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettings* settings)
|
||||
{
|
||||
char* p;
|
||||
@ -633,25 +736,25 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin
|
||||
int length;
|
||||
int status;
|
||||
DWORD flags;
|
||||
BOOL compatibility;
|
||||
COMMAND_LINE_ARGUMENT_A* arg;
|
||||
|
||||
freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry, 0);
|
||||
|
||||
if (freerdp_detect_windows_style_command_line_syntax(argc, argv))
|
||||
compatibility = freerdp_client_detect_command_line(argc, argv, &flags);
|
||||
|
||||
if (compatibility)
|
||||
{
|
||||
flags = COMMAND_LINE_SEPARATOR_COLON;
|
||||
flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
|
||||
printf("WARNING: Using deprecated command-line interface!\n");
|
||||
return freerdp_client_parse_old_command_line_arguments(argc, argv, settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
flags = COMMAND_LINE_SEPARATOR_SPACE;
|
||||
flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
|
||||
flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
|
||||
CommandLineClearArgumentsA(args);
|
||||
status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags, settings,
|
||||
freerdp_client_command_line_pre_filter, freerdp_client_command_line_post_filter);
|
||||
}
|
||||
|
||||
status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags, settings,
|
||||
freerdp_client_command_line_pre_filter, freerdp_client_command_line_post_filter);
|
||||
|
||||
if (status == COMMAND_LINE_STATUS_PRINT_HELP)
|
||||
{
|
||||
freerdp_client_print_command_line_help(argc, argv);
|
||||
|
698
client/common/compatibility.c
Normal file
698
client/common/compatibility.c
Normal file
@ -0,0 +1,698 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* FreeRDP Client Compatibility
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.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.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/cmdline.h>
|
||||
|
||||
#include <freerdp/addin.h>
|
||||
#include <freerdp/settings.h>
|
||||
#include <freerdp/client/channels.h>
|
||||
#include <freerdp/locale/keyboard.h>
|
||||
|
||||
#include <freerdp/client/cmdline.h>
|
||||
|
||||
#include "compatibility.h"
|
||||
|
||||
COMMAND_LINE_ARGUMENT_A old_args[] =
|
||||
{
|
||||
{ "0", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "connect to console session" },
|
||||
{ "a", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "set color depth in bits, default is 16" },
|
||||
{ "c", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "shell working directory" },
|
||||
{ "D", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "hide window decorations" },
|
||||
{ "T", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Window title" },
|
||||
{ "d", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "domain" },
|
||||
{ "f", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "fullscreen mode" },
|
||||
{ "g", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "set geometry, using format WxH or X%% or 'workarea', default is 1024x768" },
|
||||
{ "h", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, NULL, NULL, NULL, -1, "help", "print this help" },
|
||||
{ "k", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "set keyboard layout ID" },
|
||||
{ "K", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "do not interfere with window manager bindings" },
|
||||
{ "n", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "hostname" },
|
||||
{ "o", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "console audio" },
|
||||
{ "p", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "password" },
|
||||
{ "s", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "set startup-shell" },
|
||||
{ "t", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "alternative port number, default is 3389" },
|
||||
{ "u", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "username" },
|
||||
{ "x", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "performance flags (m[odem], b[roadband] or l[an])" },
|
||||
{ "X", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "embed into another window with a given XID." },
|
||||
{ "z", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "enable compression" },
|
||||
{ "app", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "RemoteApp connection. This implies -g workarea" },
|
||||
{ "ext", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "load an extension" },
|
||||
{ "no-auth", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable authentication" },
|
||||
{ "authonly", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "authentication only, no UI" },
|
||||
{ "from-stdin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "unspecified username, password, domain and hostname params are prompted" },
|
||||
{ "no-fastpath", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable fast-path" },
|
||||
{ "no-motion", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "don't send mouse motion events" },
|
||||
{ "gdi", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "graphics rendering (hw, sw)" },
|
||||
{ "no-osb", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable offscreen bitmaps" },
|
||||
{ "no-bmp-cache", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable bitmap cache" },
|
||||
{ "plugin", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "load a virtual channel plugin" },
|
||||
{ "rfx", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "enable RemoteFX" },
|
||||
{ "rfx-mode", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "RemoteFX operational flags (v[ideo], i[mage]), default is video" },
|
||||
{ "nsc", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "enable NSCodec (experimental)" },
|
||||
{ "disable-wallpaper", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disables wallpaper" },
|
||||
{ "composition", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "enable desktop composition" },
|
||||
{ "disable-full-window-drag", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disables full window drag" },
|
||||
{ "disable-menu-animations", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disables menu animations" },
|
||||
{ "disable-theming", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disables theming" },
|
||||
{ "no-rdp", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable Standard RDP encryption" },
|
||||
{ "no-tls", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable TLS encryption" },
|
||||
{ "no-nla", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "disable network level authentication" },
|
||||
{ "ntlm", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "force NTLM authentication protocol version (1 or 2)" },
|
||||
{ "ignore-certificate", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "ignore verification of logon certificate" },
|
||||
{ "sec", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "force protocol security (rdp, tls or nla)" },
|
||||
{ "secure-checksum", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "use salted checksums with Standard RDP encryption" },
|
||||
{ "version", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_VERSION, NULL, NULL, NULL, -1, NULL, "print version information" },
|
||||
{ NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
|
||||
};
|
||||
|
||||
void freerdp_client_old_parse_hostname(char* str, char** ServerHostname, UINT32* ServerPort)
|
||||
{
|
||||
char* p;
|
||||
|
||||
if (str[0] == '[' && (p = strchr(str, ']'))
|
||||
&& (p[1] == 0 || (p[1] == ':' && !strchr(p + 2, ':'))))
|
||||
{
|
||||
/* Either "[...]" or "[...]:..." with at most one : after the brackets */
|
||||
*ServerHostname = _strdup(str + 1);
|
||||
|
||||
if ((p = strchr((char*) *ServerHostname, ']')))
|
||||
{
|
||||
*p = 0;
|
||||
|
||||
if (p[1] == ':')
|
||||
*ServerPort = atoi(p + 2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Port number is cut off and used if exactly one : in the string */
|
||||
*ServerHostname = _strdup(str);
|
||||
|
||||
if ((p = strchr((char*) *ServerHostname, ':')) && !strchr(p + 1, ':'))
|
||||
{
|
||||
*p = 0;
|
||||
*ServerPort = atoi(p + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV* args)
|
||||
{
|
||||
if (strcmp(args->argv[0], "cliprdr") == 0)
|
||||
{
|
||||
settings->RedirectClipboard = TRUE;
|
||||
printf("--plugin cliprdr -> --enable-clipboard\n");
|
||||
}
|
||||
else if (strcmp(args->argv[0], "rdpdr") == 0)
|
||||
{
|
||||
if ((strcmp(args->argv[1], "disk") == 0) ||
|
||||
(strcmp(args->argv[1], "drive") == 0))
|
||||
{
|
||||
freerdp_addin_replace_argument(args, "disk", "drive");
|
||||
freerdp_client_add_device_channel(settings, args->argc - 1, &args->argv[1]);
|
||||
}
|
||||
else if (strcmp(args->argv[1], "printer") == 0)
|
||||
{
|
||||
freerdp_client_add_device_channel(settings, args->argc - 1, &args->argv[1]);
|
||||
}
|
||||
else if ((strcmp(args->argv[1], "scard") == 0) ||
|
||||
(strcmp(args->argv[1], "smartcard") == 0))
|
||||
{
|
||||
freerdp_addin_replace_argument(args, "scard", "smartcard");
|
||||
freerdp_client_add_device_channel(settings, args->argc - 1, &args->argv[1]);
|
||||
}
|
||||
else if (strcmp(args->argv[1], "serial") == 0)
|
||||
{
|
||||
freerdp_client_add_device_channel(settings, args->argc - 1, &args->argv[1]);
|
||||
}
|
||||
else if (strcmp(args->argv[1], "parallel") == 0)
|
||||
{
|
||||
freerdp_client_add_device_channel(settings, args->argc - 1, &args->argv[1]);
|
||||
}
|
||||
}
|
||||
else if (strcmp(args->argv[0], "drdynvc") == 0)
|
||||
{
|
||||
freerdp_client_add_dynamic_channel(settings, args->argc - 1, &args->argv[1]);
|
||||
}
|
||||
else if (strcmp(args->argv[0], "rdpsnd") == 0)
|
||||
{
|
||||
freerdp_addin_replace_argument_value(args, args->argv[1], "sys", args->argv[1]);
|
||||
freerdp_client_add_static_channel(settings, args->argc, args->argv);
|
||||
}
|
||||
else if (strcmp(args->argv[0], "rail") == 0)
|
||||
{
|
||||
settings->RemoteApplicationProgram = _strdup(args->argv[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
freerdp_client_add_static_channel(settings, args->argc, args->argv);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int freerdp_client_old_command_line_pre_filter(void* context, int index, int argc, LPCSTR* argv)
|
||||
{
|
||||
rdpSettings* settings;
|
||||
|
||||
settings = (rdpSettings*) context;
|
||||
|
||||
if (index == (argc - 1))
|
||||
{
|
||||
if (argv[index][0] != '-')
|
||||
{
|
||||
if ((strcmp(argv[index - 1], "-v") == 0) ||
|
||||
(strcmp(argv[index - 1], "/v") == 0))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
freerdp_client_old_parse_hostname((char*) argv[index], &settings->ServerHostname, &settings->ServerPort);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp("--plugin", argv[index]) == 0)
|
||||
{
|
||||
int length;
|
||||
char *a, *p;
|
||||
int i, j, t;
|
||||
int old_index;
|
||||
ADDIN_ARGV* args;
|
||||
|
||||
old_index = index;
|
||||
|
||||
index++;
|
||||
t = index;
|
||||
|
||||
if (index == argc)
|
||||
return -1;
|
||||
|
||||
args = (ADDIN_ARGV*) malloc(sizeof(ADDIN_ARGV));
|
||||
args->argv = (char**) malloc(sizeof(char*) * 5);
|
||||
args->argc = 1;
|
||||
|
||||
args->argv[0] = _strdup(argv[t]);
|
||||
|
||||
if ((index < argc - 1) && strcmp("--data", argv[index + 1]) == 0)
|
||||
{
|
||||
i = 0;
|
||||
index += 2;
|
||||
args->argc = 1;
|
||||
|
||||
while ((index < argc) && (strcmp("--", argv[index]) != 0))
|
||||
{
|
||||
args->argc = 1;
|
||||
|
||||
for (j = 0, p = (char*) argv[index]; (j < 4) && (p != NULL); j++)
|
||||
{
|
||||
if (*p == '\'')
|
||||
{
|
||||
a = p + 1;
|
||||
|
||||
p = strchr(p + 1, '\'');
|
||||
|
||||
if (p)
|
||||
*p++ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = p;
|
||||
}
|
||||
|
||||
p = strchr(p, ':');
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
length = p - a;
|
||||
args->argv[j + 1] = malloc(length + 1);
|
||||
CopyMemory(args->argv[j + 1], a, length);
|
||||
args->argv[j + 1][length] = '\0';
|
||||
p++;
|
||||
}
|
||||
else
|
||||
{
|
||||
args->argv[j + 1] = _strdup(a);
|
||||
}
|
||||
|
||||
args->argc++;
|
||||
}
|
||||
|
||||
if (settings->instance)
|
||||
{
|
||||
freerdp_client_old_process_plugin(settings, args);
|
||||
}
|
||||
|
||||
index++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return (index - old_index);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_client_old_command_line_post_filter(void* context, COMMAND_LINE_ARGUMENT_A* arg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_detect_old_command_line_syntax(int argc, char** argv, int* count)
|
||||
{
|
||||
int status;
|
||||
DWORD flags;
|
||||
int detect_status;
|
||||
rdpSettings* settings;
|
||||
COMMAND_LINE_ARGUMENT_A* arg;
|
||||
|
||||
*count = 0;
|
||||
detect_status = 0;
|
||||
flags = COMMAND_LINE_SEPARATOR_SPACE;
|
||||
flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
|
||||
|
||||
settings = (rdpSettings*) malloc(sizeof(rdpSettings));
|
||||
ZeroMemory(settings, sizeof(rdpSettings));
|
||||
|
||||
CommandLineClearArgumentsA(old_args);
|
||||
status = CommandLineParseArgumentsA(argc, (const char**) argv, old_args, flags, settings,
|
||||
freerdp_client_old_command_line_pre_filter, NULL);
|
||||
|
||||
arg = old_args;
|
||||
|
||||
do
|
||||
{
|
||||
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
|
||||
continue;
|
||||
|
||||
CommandLineSwitchStart(arg)
|
||||
|
||||
CommandLineSwitchCase(arg, "a")
|
||||
{
|
||||
if ((strcmp(arg->Value, "8") == 0) ||
|
||||
(strcmp(arg->Value, "15") == 0) || (strcmp(arg->Value, "16") == 0) ||
|
||||
(strcmp(arg->Value, "24") == 0) || (strcmp(arg->Value, "32") == 0))
|
||||
{
|
||||
detect_status = 1;
|
||||
}
|
||||
|
||||
}
|
||||
CommandLineSwitchDefault(arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CommandLineSwitchEnd(arg)
|
||||
|
||||
(*count)++;
|
||||
}
|
||||
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
||||
|
||||
if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
|
||||
detect_status = -1;
|
||||
|
||||
if (detect_status == 0)
|
||||
{
|
||||
if (settings->ServerHostname)
|
||||
detect_status = 1;
|
||||
}
|
||||
|
||||
free(settings);
|
||||
|
||||
return detect_status;
|
||||
}
|
||||
|
||||
int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSettings* settings)
|
||||
{
|
||||
char* p;
|
||||
char* str;
|
||||
int status;
|
||||
DWORD flags;
|
||||
COMMAND_LINE_ARGUMENT_A* arg;
|
||||
|
||||
freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry, 0);
|
||||
|
||||
flags = COMMAND_LINE_SEPARATOR_SPACE;
|
||||
flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
|
||||
flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
|
||||
|
||||
status = CommandLineParseArgumentsA(argc, (const char**) argv, old_args, flags, settings,
|
||||
freerdp_client_old_command_line_pre_filter, freerdp_client_old_command_line_post_filter);
|
||||
|
||||
if (status == COMMAND_LINE_STATUS_PRINT_HELP)
|
||||
{
|
||||
freerdp_client_print_command_line_help(argc, argv);
|
||||
return COMMAND_LINE_STATUS_PRINT_HELP;
|
||||
}
|
||||
else if (status == COMMAND_LINE_STATUS_PRINT_VERSION)
|
||||
{
|
||||
freerdp_client_print_version();
|
||||
return COMMAND_LINE_STATUS_PRINT_VERSION;
|
||||
}
|
||||
else if (status == COMMAND_LINE_STATUS_PRINT)
|
||||
{
|
||||
return COMMAND_LINE_STATUS_PRINT;
|
||||
}
|
||||
|
||||
arg = old_args;
|
||||
|
||||
do
|
||||
{
|
||||
if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
|
||||
continue;
|
||||
|
||||
CommandLineSwitchStart(arg)
|
||||
|
||||
CommandLineSwitchCase(arg, "0")
|
||||
{
|
||||
settings->ConsoleSession = TRUE;
|
||||
printf("-0 -> --admin\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "a")
|
||||
{
|
||||
settings->ColorDepth = atoi(arg->Value);
|
||||
printf("-a %s -> --bpp %s\n", arg->Value, arg->Value);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "c")
|
||||
{
|
||||
settings->ShellWorkingDirectory = _strdup(arg->Value);
|
||||
printf("-c %s -> --shell-dir %s\n", arg->Value, arg->Value);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "D")
|
||||
{
|
||||
settings->Decorations = FALSE;
|
||||
printf("-D -> --disable-decorations\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "T")
|
||||
{
|
||||
settings->WindowTitle = _strdup(arg->Value);
|
||||
printf("-T %s -> --title %s\n", arg->Value, arg->Value);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "d")
|
||||
{
|
||||
settings->Domain = _strdup(arg->Value);
|
||||
printf("-d %s -> -d %s\n", arg->Value, arg->Value);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "f")
|
||||
{
|
||||
settings->Fullscreen = TRUE;
|
||||
printf("-f -> -f\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "g")
|
||||
{
|
||||
str = _strdup(arg->Value);
|
||||
|
||||
p = strchr(str, 'x');
|
||||
|
||||
if (p)
|
||||
{
|
||||
*p = '\0';
|
||||
settings->DesktopWidth = atoi(str);
|
||||
settings->DesktopHeight = atoi(&p[1]);
|
||||
}
|
||||
|
||||
free(str);
|
||||
|
||||
printf("-g %s -> --size %s or -w %d -h %d\n", arg->Value, arg->Value,
|
||||
settings->DesktopWidth, settings->DesktopHeight);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "k")
|
||||
{
|
||||
sscanf(arg->Value, "%X", &(settings->KeyboardLayout));
|
||||
printf("-k %s -> --kbd %s\n", arg->Value, arg->Value);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "K")
|
||||
{
|
||||
settings->GrabKeyboard = FALSE;
|
||||
printf("-K -> --disable-grab-keyboard\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "n")
|
||||
{
|
||||
settings->ClientHostname = _strdup(arg->Value);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "o")
|
||||
{
|
||||
settings->RemoteConsoleAudio = TRUE;
|
||||
printf("-o -> --audio-mode 1\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "p")
|
||||
{
|
||||
settings->Password = _strdup(arg->Value);
|
||||
printf("-p %s -> -p %s\n", arg->Value, arg->Value);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "s")
|
||||
{
|
||||
settings->AlternateShell = _strdup(arg->Value);
|
||||
printf("-s %s -> --shell %s\n", arg->Value, arg->Value);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "t")
|
||||
{
|
||||
settings->ServerPort = atoi(arg->Value);
|
||||
printf("-t %s -> --port %s\n", arg->Value, arg->Value);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "u")
|
||||
{
|
||||
settings->Username = _strdup(arg->Value);
|
||||
printf("-u %s -> -u %s\n", arg->Value, arg->Value);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "x")
|
||||
{
|
||||
int type;
|
||||
char* pEnd;
|
||||
|
||||
type = strtol(arg->Value, &pEnd, 16);
|
||||
|
||||
if (type == 0)
|
||||
{
|
||||
type = CONNECTION_TYPE_LAN;
|
||||
|
||||
if (_stricmp(arg->Value, "m") == 0)
|
||||
type = CONNECTION_TYPE_MODEM;
|
||||
else if (_stricmp(arg->Value, "b") == 0)
|
||||
type = CONNECTION_TYPE_BROADBAND_HIGH;
|
||||
else if (_stricmp(arg->Value, "l") == 0)
|
||||
type = CONNECTION_TYPE_LAN;
|
||||
|
||||
freerdp_set_connection_type(settings, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
settings->PerformanceFlags = type;
|
||||
}
|
||||
|
||||
printf("-x %s -> --network ", arg->Value);
|
||||
|
||||
if (type == CONNECTION_TYPE_MODEM)
|
||||
printf("modem");
|
||||
else if (CONNECTION_TYPE_BROADBAND_HIGH)
|
||||
printf("broadband");
|
||||
else if (CONNECTION_TYPE_LAN)
|
||||
printf("lan");
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "X")
|
||||
{
|
||||
settings->ParentWindowId = strtol(arg->Value, NULL, 0);
|
||||
printf("-X %s -> --parent-window %s\n", arg->Value, arg->Value);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "z")
|
||||
{
|
||||
settings->CompressionEnabled = TRUE;
|
||||
printf("-z -> --compression\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "app")
|
||||
{
|
||||
settings->RemoteApplicationMode = TRUE;
|
||||
printf("--app -> --app + program name or alias\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "ext")
|
||||
{
|
||||
|
||||
}
|
||||
CommandLineSwitchCase(arg, "no-auth")
|
||||
{
|
||||
settings->Authentication = FALSE;
|
||||
printf("--no-auth -> --disable-authentication\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "authonly")
|
||||
{
|
||||
settings->AuthenticationOnly = TRUE;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "from-stdin")
|
||||
{
|
||||
settings->CredentialsFromStdin = TRUE;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "no-fastpath")
|
||||
{
|
||||
settings->FastPathInput = FALSE;
|
||||
settings->FastPathOutput = FALSE;
|
||||
printf("--no-fastpath -> --disable-fast-path\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "no-motion")
|
||||
{
|
||||
settings->MouseMotion = FALSE;
|
||||
printf("--no-motion -> --disable-mouse-motion\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "gdi")
|
||||
{
|
||||
if (strcmp(arg->Value, "sw") == 0)
|
||||
settings->SoftwareGdi = TRUE;
|
||||
else if (strcmp(arg->Value, "hw") == 0)
|
||||
settings->SoftwareGdi = FALSE;
|
||||
|
||||
printf("--gdi %s -> --gdi %s\n", arg->Value, arg->Value);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "no-osb")
|
||||
{
|
||||
settings->OffscreenSupportLevel = FALSE;
|
||||
printf("--no-osb -> --disable-offscreen-cache\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "no-bmp-cache")
|
||||
{
|
||||
settings->BitmapCacheEnabled = FALSE;
|
||||
printf("--no-bmp-cache -> --disable-bitmap-cache\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "plugin")
|
||||
{
|
||||
printf("--plugin -> -a, --vc, --dvc and channel-specific options\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "rfx")
|
||||
{
|
||||
settings->RemoteFxCodec = TRUE;
|
||||
printf("--rfx -> --rfx\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "rfx-mode")
|
||||
{
|
||||
if (arg->Value[0] == 'v')
|
||||
settings->RemoteFxCodecMode = 0x00;
|
||||
else if (arg->Value[0] == 'i')
|
||||
settings->RemoteFxCodecMode = 0x02;
|
||||
printf("--rfx-mode -> --rfx-mode\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "nsc")
|
||||
{
|
||||
settings->NSCodec = TRUE;
|
||||
printf("--nsc -> --nsc\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "disable-wallpaper")
|
||||
{
|
||||
settings->DisableWallpaper = TRUE;
|
||||
printf("--disable-wallpaper -> --disable-wallpaper\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "composition")
|
||||
{
|
||||
settings->AllowDesktopComposition = TRUE;
|
||||
printf("--composition -> --enable-composition\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "disable-full-window-drag")
|
||||
{
|
||||
settings->DisableFullWindowDrag = TRUE;
|
||||
printf("--disable-full-window-drag -> --disable-window-drag\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "disable-menu-animations")
|
||||
{
|
||||
settings->DisableMenuAnims = TRUE;
|
||||
printf("--disable-menu-animations -> --disable-menu-anims\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "disable-theming")
|
||||
{
|
||||
settings->DisableThemes = TRUE;
|
||||
printf("--disable-theming -> --disable-themes\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "ntlm")
|
||||
{
|
||||
|
||||
}
|
||||
CommandLineSwitchCase(arg, "ignore-certificate")
|
||||
{
|
||||
settings->IgnoreCertificate = TRUE;
|
||||
printf("--ignore-certificate -> --cert-ignore\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "sec")
|
||||
{
|
||||
if (strncmp("rdp", arg->Value, 1) == 0) /* Standard RDP */
|
||||
{
|
||||
settings->RdpSecurity = TRUE;
|
||||
settings->TlsSecurity = FALSE;
|
||||
settings->NlaSecurity = FALSE;
|
||||
settings->DisableEncryption = FALSE;
|
||||
settings->EncryptionMethods = ENCRYPTION_METHOD_40BIT | ENCRYPTION_METHOD_128BIT | ENCRYPTION_METHOD_FIPS;
|
||||
settings->EncryptionLevel = ENCRYPTION_LEVEL_CLIENT_COMPATIBLE;
|
||||
}
|
||||
else if (strncmp("tls", arg->Value, 1) == 0) /* TLS */
|
||||
{
|
||||
settings->RdpSecurity = FALSE;
|
||||
settings->TlsSecurity = TRUE;
|
||||
settings->NlaSecurity = FALSE;
|
||||
}
|
||||
else if (strncmp("nla", arg->Value, 1) == 0) /* NLA */
|
||||
{
|
||||
settings->RdpSecurity = FALSE;
|
||||
settings->TlsSecurity = FALSE;
|
||||
settings->NlaSecurity = TRUE;
|
||||
}
|
||||
|
||||
printf("--sec %s -> --sec %s\n", arg->Value, arg->Value);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "no-rdp")
|
||||
{
|
||||
settings->RdpSecurity = FALSE;
|
||||
printf("--no-rdp -> --disable-sec-rdp\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "no-tls")
|
||||
{
|
||||
settings->TlsSecurity = FALSE;
|
||||
printf("--no-tls -> --disable-sec-tls\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "no-nla")
|
||||
{
|
||||
settings->NlaSecurity = FALSE;
|
||||
printf("--no-nla -> --disable-sec-nla\n");
|
||||
}
|
||||
CommandLineSwitchCase(arg, "secure-checksum")
|
||||
{
|
||||
settings->SaltedChecksum = TRUE;
|
||||
}
|
||||
CommandLineSwitchDefault(arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CommandLineSwitchEnd(arg)
|
||||
}
|
||||
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
||||
|
||||
printf("%s -> -v %s", settings->ServerHostname, settings->ServerHostname);
|
||||
|
||||
if (settings->ServerPort != 3389)
|
||||
printf(" --port %d", settings->ServerPort);
|
||||
|
||||
printf("\n");
|
||||
|
||||
return 1;
|
||||
}
|
30
client/common/compatibility.h
Normal file
30
client/common/compatibility.h
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* FreeRDP Client Compatibility
|
||||
*
|
||||
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.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.
|
||||
*/
|
||||
|
||||
#ifndef FREERDP_CLIENT_COMPATIBILITY_H
|
||||
#define FREERDP_CLIENT_COMPATIBILITY_H
|
||||
|
||||
#include <freerdp/api.h>
|
||||
#include <freerdp/freerdp.h>
|
||||
|
||||
int freerdp_detect_old_command_line_syntax(int argc, char** argv, int* count);
|
||||
int freerdp_client_parse_old_command_line_arguments(int argc, char** argv, rdpSettings* settings);
|
||||
|
||||
#endif /* FREERDP_CLIENT_COMPATIBILITY */
|
||||
|
@ -25,10 +25,16 @@
|
||||
|
||||
FREERDP_API int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettings* settings);
|
||||
FREERDP_API int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings);
|
||||
|
||||
FREERDP_API int freerdp_client_print_version();
|
||||
FREERDP_API int freerdp_client_print_command_line_help(int argc, char** argv);
|
||||
|
||||
FREERDP_API int freerdp_parse_username(char* username, char** user, char** domain);
|
||||
FREERDP_API int freerdp_set_connection_type(rdpSettings* settings, int type);
|
||||
|
||||
FREERDP_API int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** params);
|
||||
FREERDP_API int freerdp_client_add_static_channel(rdpSettings* settings, int count, char** params);
|
||||
FREERDP_API int freerdp_client_add_dynamic_channel(rdpSettings* settings, int count, char** params);
|
||||
|
||||
#endif /* FREERDP_CLIENT_CMDLINE */
|
||||
|
||||
|
@ -970,6 +970,11 @@ typedef struct rdp_settings rdpSettings;
|
||||
FREERDP_API rdpSettings* freerdp_settings_new(void* instance);
|
||||
FREERDP_API void freerdp_settings_free(rdpSettings* settings);
|
||||
|
||||
FREERDP_API int freerdp_addin_set_argument(ADDIN_ARGV* args, char* argument);
|
||||
FREERDP_API int freerdp_addin_replace_argument(ADDIN_ARGV* args, char* previous, char* argument);
|
||||
FREERDP_API int freerdp_addin_set_argument_value(ADDIN_ARGV* args, char* option, char* value);
|
||||
FREERDP_API int freerdp_addin_replace_argument_value(ADDIN_ARGV* args, char* previous, char* option, char* value);
|
||||
|
||||
FREERDP_API void freerdp_device_collection_add(rdpSettings* settings, RDPDR_DEVICE* device);
|
||||
FREERDP_API void freerdp_device_collection_free(rdpSettings* settings);
|
||||
|
||||
|
@ -25,8 +25,113 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
|
||||
#include <freerdp/settings.h>
|
||||
|
||||
int freerdp_addin_set_argument(ADDIN_ARGV* args, char* argument)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < args->argc; i++)
|
||||
{
|
||||
if (strcmp(args->argv[i], argument) == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
args->argc++;
|
||||
args->argv = (char**) realloc(args->argv, sizeof(char*) * args->argc);
|
||||
args->argv[args->argc - 1] = _strdup(argument);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_addin_replace_argument(ADDIN_ARGV* args, char* previous, char* argument)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < args->argc; i++)
|
||||
{
|
||||
if (strcmp(args->argv[i], previous) == 0)
|
||||
{
|
||||
free(args->argv[i]);
|
||||
args->argv[i] = _strdup(argument);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
args->argc++;
|
||||
args->argv = (char**) realloc(args->argv, sizeof(char*) * args->argc);
|
||||
args->argv[args->argc - 1] = _strdup(argument);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_addin_set_argument_value(ADDIN_ARGV* args, char* option, char* value)
|
||||
{
|
||||
int i;
|
||||
char* p;
|
||||
char* str;
|
||||
int length;
|
||||
|
||||
length = strlen(option) + strlen(value) + 1;
|
||||
str = (char*) malloc(length + 1);
|
||||
sprintf_s(str, length + 1, "%s:%s", option, value);
|
||||
|
||||
for (i = 0; i < args->argc; i++)
|
||||
{
|
||||
p = strchr(args->argv[i], ':');
|
||||
|
||||
if (p)
|
||||
{
|
||||
if (strncmp(args->argv[i], option, p - args->argv[i]) == 0)
|
||||
{
|
||||
free(args->argv[i]);
|
||||
args->argv[i] = str;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
args->argc++;
|
||||
args->argv = (char**) realloc(args->argv, sizeof(char*) * args->argc);
|
||||
args->argv[args->argc - 1] = str;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int freerdp_addin_replace_argument_value(ADDIN_ARGV* args, char* previous, char* option, char* value)
|
||||
{
|
||||
int i;
|
||||
char* str;
|
||||
int length;
|
||||
|
||||
length = strlen(option) + strlen(value) + 1;
|
||||
str = (char*) malloc(length + 1);
|
||||
sprintf_s(str, length + 1, "%s:%s", option, value);
|
||||
|
||||
for (i = 0; i < args->argc; i++)
|
||||
{
|
||||
if (strcmp(args->argv[i], previous) == 0)
|
||||
{
|
||||
free(args->argv[i]);
|
||||
args->argv[i] = str;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
args->argc++;
|
||||
args->argv = (char**) realloc(args->argv, sizeof(char*) * args->argc);
|
||||
args->argv[args->argc - 1] = str;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void freerdp_device_collection_add(rdpSettings* settings, RDPDR_DEVICE* device)
|
||||
{
|
||||
if (settings->DeviceArraySize < (settings->DeviceCount + 1))
|
||||
|
@ -60,11 +60,13 @@
|
||||
|
||||
/* Command-Line Parsing Error Codes */
|
||||
|
||||
#define COMMAND_LINE_ERROR -1000
|
||||
#define COMMAND_LINE_ERROR_NO_KEYWORD -1001
|
||||
#define COMMAND_LINE_ERROR_UNEXPECTED_VALUE -1002
|
||||
#define COMMAND_LINE_ERROR_MISSING_VALUE -1003
|
||||
#define COMMAND_LINE_ERROR_MISSING_ARGUMENT -1004
|
||||
#define COMMAND_LINE_ERROR_UNEXPECTED_SIGIL -1005
|
||||
#define COMMAND_LINE_ERROR_LAST -1006
|
||||
|
||||
/* Command-Line Parsing Status Codes */
|
||||
|
||||
@ -115,8 +117,8 @@ struct _COMMAND_LINE_ARGUMENT_W
|
||||
#define COMMAND_LINE_ARGUMENT COMMAND_LINE_ARGUMENT_A
|
||||
#endif
|
||||
|
||||
typedef int (*COMMAND_LINE_PRE_FILTER_FN_A)(void* context, int index, LPCSTR arg);
|
||||
typedef int (*COMMAND_LINE_PRE_FILTER_FN_W)(void* context, int index, LPCWSTR arg);
|
||||
typedef int (*COMMAND_LINE_PRE_FILTER_FN_A)(void* context, int index, int argc, LPCSTR* argv);
|
||||
typedef int (*COMMAND_LINE_PRE_FILTER_FN_W)(void* context, int index, int argc, LPCWSTR* argv);
|
||||
|
||||
typedef int (*COMMAND_LINE_POST_FILTER_FN_A)(void* context, COMMAND_LINE_ARGUMENT_A* arg);
|
||||
typedef int (*COMMAND_LINE_POST_FILTER_FN_W)(void* context, COMMAND_LINE_ARGUMENT_W* arg);
|
||||
|
@ -30,44 +30,6 @@
|
||||
* https://pythonconquerstheuniverse.wordpress.com/2010/07/25/command-line-syntax-some-basic-concepts/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Remote Desktop Connection Usage
|
||||
*
|
||||
* mstsc [<connection file>] [/v:<server[:port]>] [/admin] [/f[ullscreen]]
|
||||
* [/w:<width>] [/h:<height>] [/public] | [/span] [/multimon] [/migrate]
|
||||
* [/edit "connection file"] [/?]
|
||||
*
|
||||
* "connection file" -- Specifies the name of an .RDP for the connection.
|
||||
*
|
||||
* /v:<server[:port]> -- Specifies the remote computer to which you want
|
||||
* to connect.
|
||||
*
|
||||
* /admin -- Connects you to the session for administering a server.
|
||||
*
|
||||
* /f -- Starts Remote Desktop in full-screen mode.
|
||||
*
|
||||
* /w:<width> -- Specifies the width of the Remote Desktop window.
|
||||
*
|
||||
* /h:<height> -- Specifies the height of the Remote Desktop window.
|
||||
*
|
||||
* /public -- Runs Remote Desktop in public mode.
|
||||
*
|
||||
* /span -- Matches the remote desktop width and height with the local
|
||||
* virtual desktop, spanning across multiple monitors if necessary. To
|
||||
* span across monitors, the monitors must be arranged to form a
|
||||
* rectangle.
|
||||
*
|
||||
* /multimon -- Configures the remote desktop session layout to
|
||||
* be identical to the current client-side configuration.
|
||||
*
|
||||
* /edit -- Opens the specified .RDP connection file for editing.
|
||||
*
|
||||
* /migrate -- Migrates legacy connection files that were created with
|
||||
* Client Connection Manager to new .RDP connection files.
|
||||
*
|
||||
* /? -- Lists these parameters.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Command-Line Syntax:
|
||||
*
|
||||
@ -87,6 +49,7 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
||||
void* context, COMMAND_LINE_PRE_FILTER_FN_A preFilter, COMMAND_LINE_POST_FILTER_FN_A postFilter)
|
||||
{
|
||||
int i, j;
|
||||
int count;
|
||||
int length;
|
||||
int index;
|
||||
BOOL match;
|
||||
@ -115,7 +78,18 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
||||
index = i;
|
||||
|
||||
if (preFilter)
|
||||
preFilter(context, i, argv[i]);
|
||||
{
|
||||
count = preFilter(context, i, argc, argv);
|
||||
|
||||
if (count < 0)
|
||||
return COMMAND_LINE_ERROR;
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
i += count;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
sigil_index = 0;
|
||||
sigil_length = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user