freerdp/freerdp-args.patch

187 lines
5.3 KiB
Diff

diff --git a/client/common/cmdline.c b/client/common/cmdline.c
index f1f9640..72bbd12 100644
--- a/client/common/cmdline.c
+++ b/client/common/cmdline.c
@@ -1078,8 +1078,10 @@ BOOL freerdp_client_detect_command_line(int argc, char** argv, DWORD* flags)
if (posix_cli_status <= COMMAND_LINE_STATUS_PRINT)
return compatibility;
- if (windows_cli_count >= posix_cli_count)
+ /* Check, if this may be windows style syntax... */
+ if ((windows_cli_count && (windows_cli_count >= posix_cli_count)) || (windows_cli_status <= COMMAND_LINE_STATUS_PRINT))
{
+ windows_cli_count = 1;
*flags = COMMAND_LINE_SEPARATOR_COLON;
*flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
}
diff --git a/client/common/compatibility.c b/client/common/compatibility.c
index 3a7d0da..d6efe50 100644
--- a/client/common/compatibility.c
+++ b/client/common/compatibility.c
@@ -122,16 +122,20 @@ void freerdp_client_old_parse_hostname(char* str, char** ServerHostname, UINT32*
int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV* args)
{
+ int args_handled = 0;
if (strcmp(args->argv[0], "cliprdr") == 0)
{
+ args_handled++;
settings->RedirectClipboard = TRUE;
WLog_WARN(TAG, "--plugin cliprdr -> +clipboard");
}
else if (strcmp(args->argv[0], "rdpdr") == 0)
{
+ args_handled++;
if (args->argc < 2)
- return -1;
+ return 1;
+ args_handled++;
if ((strcmp(args->argv[1], "disk") == 0) ||
(strcmp(args->argv[1], "drive") == 0))
{
@@ -159,21 +163,26 @@ int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV* args)
}
else if (strcmp(args->argv[0], "drdynvc") == 0)
{
+ args_handled++;
freerdp_client_add_dynamic_channel(settings, args->argc - 1, &args->argv[1]);
}
else if (strcmp(args->argv[0], "rdpsnd") == 0)
{
+ args_handled++;
if (args->argc < 2)
- return -1;
+ return 1;
+ args_handled++;
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)
{
+ args_handled++;
if (args->argc < 2)
- return -1;
+ return 1;
+ args_handled++;
settings->RemoteApplicationProgram = _strdup(args->argv[1]);
}
else
@@ -181,14 +190,12 @@ int freerdp_client_old_process_plugin(rdpSettings* settings, ADDIN_ARGV* args)
freerdp_client_add_static_channel(settings, args->argc, args->argv);
}
- return 1;
+ return args_handled;
}
int freerdp_client_old_command_line_pre_filter(void* context, int index, int argc, LPCSTR* argv)
{
- rdpSettings* settings;
-
- settings = (rdpSettings*) context;
+ rdpSettings* settings = (rdpSettings*) context;
if (index == (argc - 1))
{
@@ -204,11 +211,10 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
return -1;
}
- if (settings)
- {
- freerdp_client_old_parse_hostname((char*) argv[index],
- &settings->ServerHostname, &settings->ServerPort);
- }
+ freerdp_client_old_parse_hostname((char*) argv[index],
+ &settings->ServerHostname, &settings->ServerPort);
+
+ return 2;
}
else
{
@@ -218,6 +224,7 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
if (strcmp("--plugin", argv[index]) == 0)
{
+ int args_handled = 0;
int length;
char *a, *p;
int i, j, t;
@@ -233,20 +240,19 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
return -1;
args = (ADDIN_ARGV*) malloc(sizeof(ADDIN_ARGV));
- args->argv = (char**) malloc(sizeof(char*) * 5);
+ args->argv = (char**) calloc(argc, sizeof(char*));
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_handled ++;
args->argc = 1;
+ args->argv[0] = _strdup(argv[t]);
for (j = 0, p = (char*) argv[index]; (j < 4) && (p != NULL); j++)
{
@@ -267,6 +273,9 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
if (p != NULL)
{
p = strchr(p, ':');
+ }
+ if (p != NULL)
+ {
length = (int) (p - a);
args->argv[j + 1] = (char*) malloc(length + 1);
CopyMemory(args->argv[j + 1], a, length);
@@ -281,11 +290,14 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
args->argc++;
}
- if (settings->instance)
+ if (settings)
{
freerdp_client_old_process_plugin(settings, args);
}
+ for (i = 0; i < args->argc; i++)
+ free(args->argv[i]);
+ memset(args->argv, 0, argc * sizeof(char*));
index++;
i++;
}
@@ -294,19 +306,16 @@ int freerdp_client_old_command_line_pre_filter(void* context, int index, int arg
{
if (settings)
{
- if (settings->instance)
- {
- freerdp_client_old_process_plugin(settings, args);
- }
+ args->argv[0] = _strdup(argv[t]);
+ args_handled = freerdp_client_old_process_plugin(settings, args);
+ free (args->argv[0]);
}
}
- for (i = 0; i < args->argc; i++)
- free(args->argv[i]);
free(args->argv);
free(args);
- return (index - old_index);
+ return (index - old_index) + args_handled;
}
return 0;