Merge pull request #3940 from akallabeth/custom_help_arguments
Added a new function to allow printing help with additional arguments.
This commit is contained in:
commit
7fe8648ab1
@ -199,36 +199,23 @@ static COMMAND_LINE_ARGUMENT_A args[] =
|
||||
{ NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
|
||||
};
|
||||
|
||||
BOOL freerdp_client_print_version()
|
||||
BOOL freerdp_client_print_version(void)
|
||||
{
|
||||
printf("This is FreeRDP version %s (%s)\n", FREERDP_VERSION_FULL,
|
||||
GIT_REVISION);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL freerdp_client_print_buildconfig()
|
||||
BOOL freerdp_client_print_buildconfig(void)
|
||||
{
|
||||
printf("%s", freerdp_get_build_config());
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL freerdp_client_print_command_line_help(int argc, char** argv)
|
||||
static void freerdp_client_print_command_line_args(COMMAND_LINE_ARGUMENT_A* arg)
|
||||
{
|
||||
char* str;
|
||||
int length;
|
||||
COMMAND_LINE_ARGUMENT_A* arg;
|
||||
printf("\n");
|
||||
printf("FreeRDP - A Free Remote Desktop Protocol Implementation\n");
|
||||
printf("See www.freerdp.com for more information\n");
|
||||
printf("\n");
|
||||
printf("Usage: %s [file] [options] [/v:<server>[:port]]\n", argv[0]);
|
||||
printf("\n");
|
||||
printf("Syntax:\n");
|
||||
printf(" /flag (enables flag)\n");
|
||||
printf(" /option:<value> (specifies option with value)\n");
|
||||
printf(" +toggle -toggle (enables or disables toggle, where '/' is a synonym of '+')\n");
|
||||
printf("\n");
|
||||
arg = args;
|
||||
if (!arg)
|
||||
return;
|
||||
|
||||
do
|
||||
{
|
||||
@ -242,12 +229,12 @@ BOOL freerdp_client_print_command_line_help(int argc, char** argv)
|
||||
|| (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL))
|
||||
{
|
||||
BOOL overlong = FALSE;
|
||||
|
||||
printf(" %s", "/");
|
||||
|
||||
if (arg->Format)
|
||||
{
|
||||
length = (int)(strlen(arg->Name) + strlen(arg->Format) + 2);
|
||||
size_t length = (strlen(arg->Name) + strlen(arg->Format) + 2);
|
||||
|
||||
if (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL)
|
||||
length += 2;
|
||||
|
||||
@ -257,18 +244,10 @@ BOOL freerdp_client_print_command_line_help(int argc, char** argv)
|
||||
overlong = TRUE;
|
||||
}
|
||||
|
||||
str = (char*) calloc(length + 1UL, sizeof(char));
|
||||
|
||||
if (!str)
|
||||
return FALSE;
|
||||
|
||||
if (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL)
|
||||
sprintf_s(str, length + 1, "%s[:%s]", arg->Name, overlong ? "..." : arg->Format);
|
||||
printf("%s[:%s]", arg->Name, overlong ? "..." : arg->Format);
|
||||
else
|
||||
sprintf_s(str, length + 1, "%s:%s", arg->Name, overlong ? "..." : arg->Format);
|
||||
printf("%-20s", str);
|
||||
|
||||
free(str);
|
||||
printf("%s:%s", arg->Name, overlong ? "..." : arg->Format);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -285,7 +264,29 @@ BOOL freerdp_client_print_command_line_help(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
||||
}
|
||||
|
||||
BOOL freerdp_client_print_command_line_help(int argc, char** argv)
|
||||
{
|
||||
return freerdp_client_print_command_line_help_ex(argc, argv, NULL);
|
||||
}
|
||||
|
||||
BOOL freerdp_client_print_command_line_help_ex(int argc, char** argv,
|
||||
COMMAND_LINE_ARGUMENT_A* custom)
|
||||
{
|
||||
printf("\n");
|
||||
printf("FreeRDP - A Free Remote Desktop Protocol Implementation\n");
|
||||
printf("See www.freerdp.com for more information\n");
|
||||
printf("\n");
|
||||
printf("Usage: %s [file] [options] [/v:<server>[:port]]\n", argv[0]);
|
||||
printf("\n");
|
||||
printf("Syntax:\n");
|
||||
printf(" /flag (enables flag)\n");
|
||||
printf(" /option:<value> (specifies option with value)\n");
|
||||
printf(" +toggle -toggle (enables or disables toggle, where '/' is a synonym of '+')\n");
|
||||
printf("\n");
|
||||
freerdp_client_print_command_line_args(custom);
|
||||
freerdp_client_print_command_line_args(args);
|
||||
printf("\n");
|
||||
printf("Examples:\n");
|
||||
printf(" xfreerdp connection.rdp /p:Pwd123! /f\n");
|
||||
@ -311,7 +312,6 @@ BOOL freerdp_client_print_command_line_help(int argc, char** argv)
|
||||
printf("Multimedia Redirection: /multimedia:sys:alsa\n");
|
||||
printf("USB Device Redirection: /usb:id,dev:054c:0268\n");
|
||||
printf("\n");
|
||||
|
||||
printf("For Gateways, the https_proxy environment variable is respected:\n");
|
||||
#ifdef _WIN32
|
||||
printf(" set HTTPS_PROXY=http://proxy.contoso.com:3128/\n");
|
||||
@ -320,7 +320,6 @@ BOOL freerdp_client_print_command_line_help(int argc, char** argv)
|
||||
#endif
|
||||
printf(" xfreerdp /g:rdp.contoso.com ...\n");
|
||||
printf("\n");
|
||||
|
||||
printf("More documentation is coming, in the meantime consult source files\n");
|
||||
printf("\n");
|
||||
return TRUE;
|
||||
@ -866,8 +865,6 @@ static int freerdp_client_command_line_post_filter(void* context,
|
||||
free(p);
|
||||
}
|
||||
CommandLineSwitchCase(arg, "smartcard")
|
||||
{
|
||||
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
||||
{
|
||||
char** p;
|
||||
int count;
|
||||
@ -877,15 +874,6 @@ static int freerdp_client_command_line_post_filter(void* context,
|
||||
status = freerdp_client_add_device_channel(settings, count, p);
|
||||
free(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
char* p[1];
|
||||
int count;
|
||||
count = 1;
|
||||
p[0] = "smartcard";
|
||||
status = freerdp_client_add_device_channel(settings, count, p);
|
||||
}
|
||||
}
|
||||
CommandLineSwitchCase(arg, "printer")
|
||||
{
|
||||
if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
|
||||
@ -1395,6 +1383,13 @@ static BOOL freerdp_client_detect_command_line(int argc, char** argv,
|
||||
|
||||
int freerdp_client_settings_command_line_status_print(rdpSettings* settings,
|
||||
int status, int argc, char** argv)
|
||||
{
|
||||
return freerdp_client_settings_command_line_status_print_ex(
|
||||
settings, status, argc, argv, NULL);
|
||||
}
|
||||
|
||||
int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings,
|
||||
int status, int argc, char** argv, COMMAND_LINE_ARGUMENT_A* custom)
|
||||
{
|
||||
COMMAND_LINE_ARGUMENT_A* arg;
|
||||
|
||||
@ -1456,7 +1451,7 @@ int freerdp_client_settings_command_line_status_print(rdpSettings* settings,
|
||||
}
|
||||
else if (status < 0)
|
||||
{
|
||||
freerdp_client_print_command_line_help(argc, argv);
|
||||
freerdp_client_print_command_line_help_ex(argc, argv, custom);
|
||||
return COMMAND_LINE_STATUS_PRINT_HELP;
|
||||
}
|
||||
|
||||
@ -1621,6 +1616,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
settings->PercentScreenUseWidth = 1;
|
||||
partial = TRUE;
|
||||
}
|
||||
|
||||
if (strchr(p, 'h'))
|
||||
{
|
||||
settings->PercentScreenUseHeight = 1;
|
||||
@ -2148,6 +2144,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
if (arg->Value)
|
||||
{
|
||||
#ifdef WITH_GFX_H264
|
||||
|
||||
if (_strnicmp("AVC444", arg->Value, 6) == 0)
|
||||
{
|
||||
settings->GfxH264 = TRUE;
|
||||
@ -2166,8 +2163,10 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
CommandLineSwitchCase(arg, "gfx-thin-client")
|
||||
{
|
||||
settings->GfxThinClient = arg->Value ? TRUE : FALSE;
|
||||
|
||||
if (settings->GfxThinClient)
|
||||
settings->GfxSmallCache = TRUE;
|
||||
|
||||
settings->SupportGraphicsPipeline = TRUE;
|
||||
}
|
||||
CommandLineSwitchCase(arg, "gfx-small-cache")
|
||||
@ -2427,6 +2426,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
{
|
||||
settings->NSCodec = TRUE;
|
||||
}
|
||||
|
||||
#if defined(WITH_JPEG)
|
||||
else if (strcmp(arg->Value, "jpeg") == 0)
|
||||
{
|
||||
@ -2435,6 +2435,7 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
|
||||
if (settings->JpegQuality == 0)
|
||||
settings->JpegQuality = 75;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
CommandLineSwitchCase(arg, "fast-path")
|
||||
|
@ -20,6 +20,8 @@
|
||||
#ifndef FREERDP_CLIENT_CMDLINE_H
|
||||
#define FREERDP_CLIENT_CMDLINE_H
|
||||
|
||||
#include <winpr/cmdline.h>
|
||||
|
||||
#include <freerdp/api.h>
|
||||
#include <freerdp/freerdp.h>
|
||||
|
||||
@ -29,12 +31,18 @@ extern "C" {
|
||||
|
||||
FREERDP_API int freerdp_client_settings_parse_command_line_arguments(
|
||||
rdpSettings* settings, int argc, char** argv, BOOL allowUnknown);
|
||||
FREERDP_API int freerdp_client_settings_command_line_status_print(rdpSettings* settings, int status, int argc, char** argv);
|
||||
FREERDP_API int freerdp_client_settings_command_line_status_print(
|
||||
rdpSettings* settings, int status, int argc, char** argv);
|
||||
FREERDP_API int freerdp_client_settings_command_line_status_print_ex(
|
||||
rdpSettings* settings, int status, int argc, char** argv,
|
||||
COMMAND_LINE_ARGUMENT_A* custom);
|
||||
FREERDP_API BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings);
|
||||
|
||||
FREERDP_API BOOL freerdp_client_print_version(void);
|
||||
FREERDP_API BOOL freerdp_client_print_buildconfig(void);
|
||||
FREERDP_API BOOL freerdp_client_print_command_line_help(int argc, char** argv);
|
||||
FREERDP_API BOOL freerdp_client_print_command_line_help_ex(
|
||||
int argc, char** argv, COMMAND_LINE_ARGUMENT_A* custom);
|
||||
|
||||
FREERDP_API BOOL freerdp_parse_username(char* username, char** user, char** domain);
|
||||
FREERDP_API BOOL freerdp_parse_hostname(char* hostname, char** host, int* port);
|
||||
@ -42,7 +50,8 @@ FREERDP_API BOOL freerdp_set_connection_type(rdpSettings* settings, int type);
|
||||
|
||||
FREERDP_API BOOL freerdp_client_add_device_channel(rdpSettings* settings, int count, char** params);
|
||||
FREERDP_API BOOL freerdp_client_add_static_channel(rdpSettings* settings, int count, char** params);
|
||||
FREERDP_API BOOL freerdp_client_add_dynamic_channel(rdpSettings* settings, int count, char** params);
|
||||
FREERDP_API BOOL freerdp_client_add_dynamic_channel(rdpSettings* settings, int count,
|
||||
char** params);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -137,13 +137,17 @@ extern "C" {
|
||||
WINPR_API int CommandLineClearArgumentsA(COMMAND_LINE_ARGUMENT_A* options);
|
||||
WINPR_API int CommandLineClearArgumentsW(COMMAND_LINE_ARGUMENT_W* options);
|
||||
|
||||
WINPR_API int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A* options, DWORD flags,
|
||||
WINPR_API int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A* options,
|
||||
DWORD flags,
|
||||
void* context, COMMAND_LINE_PRE_FILTER_FN_A preFilter, COMMAND_LINE_POST_FILTER_FN_A postFilter);
|
||||
WINPR_API int CommandLineParseArgumentsW(int argc, LPCWSTR* argv, COMMAND_LINE_ARGUMENT_W* options, DWORD flags,
|
||||
WINPR_API int CommandLineParseArgumentsW(int argc, LPCWSTR* argv, COMMAND_LINE_ARGUMENT_W* options,
|
||||
DWORD flags,
|
||||
void* context, COMMAND_LINE_PRE_FILTER_FN_W preFilter, COMMAND_LINE_POST_FILTER_FN_W postFilter);
|
||||
|
||||
WINPR_API COMMAND_LINE_ARGUMENT_A* CommandLineFindArgumentA(COMMAND_LINE_ARGUMENT_A* options, LPCSTR Name);
|
||||
WINPR_API COMMAND_LINE_ARGUMENT_W* CommandLineFindArgumentW(COMMAND_LINE_ARGUMENT_W* options, LPCWSTR Name);
|
||||
WINPR_API COMMAND_LINE_ARGUMENT_A* CommandLineFindArgumentA(COMMAND_LINE_ARGUMENT_A* options,
|
||||
LPCSTR Name);
|
||||
WINPR_API COMMAND_LINE_ARGUMENT_W* CommandLineFindArgumentW(COMMAND_LINE_ARGUMENT_W* options,
|
||||
LPCWSTR Name);
|
||||
|
||||
WINPR_API COMMAND_LINE_ARGUMENT_A* CommandLineFindNextArgumentA(COMMAND_LINE_ARGUMENT_A* argument);
|
||||
|
||||
|
@ -45,7 +45,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A* options, DWORD flags,
|
||||
int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A* options,
|
||||
DWORD flags,
|
||||
void* context, COMMAND_LINE_PRE_FILTER_FN_A preFilter, COMMAND_LINE_POST_FILTER_FN_A postFilter)
|
||||
{
|
||||
int i, j;
|
||||
@ -71,9 +72,7 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
||||
int value_length;
|
||||
int value_index;
|
||||
int toggle;
|
||||
|
||||
status = 0;
|
||||
|
||||
match = FALSE;
|
||||
found = FALSE;
|
||||
argument = FALSE;
|
||||
@ -92,7 +91,6 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
index = i;
|
||||
|
||||
escaped = TRUE;
|
||||
|
||||
if (preFilter)
|
||||
@ -160,15 +158,16 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
||||
if ((sigil_length > 0) || (flags & COMMAND_LINE_SIGIL_NONE) ||
|
||||
(flags & COMMAND_LINE_SIGIL_NOT_ESCAPED))
|
||||
{
|
||||
if (length < (sigil_length + 1)) {
|
||||
if (length < (sigil_length + 1))
|
||||
{
|
||||
if ((flags & COMMAND_LINE_IGN_UNKNOWN_KEYWORD))
|
||||
continue;
|
||||
|
||||
return COMMAND_LINE_ERROR_NO_KEYWORD;
|
||||
}
|
||||
|
||||
keyword_index = sigil_index + sigil_length;
|
||||
keyword = (char*) &argv[i][keyword_index];
|
||||
|
||||
toggle = -1;
|
||||
|
||||
if (flags & COMMAND_LINE_SIGIL_ENABLE_DISABLE)
|
||||
@ -199,9 +198,7 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
||||
{
|
||||
separator_length = 1;
|
||||
separator_index = (int)(separator - argv[i]);
|
||||
|
||||
keyword_length = (int)(separator - keyword);
|
||||
|
||||
value_index = separator_index + separator_length;
|
||||
value = (char*) &argv[i][value_index];
|
||||
value_length = (length - value_index);
|
||||
@ -211,7 +208,6 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
||||
separator_length = 0;
|
||||
separator_index = -1;
|
||||
keyword_length = (length - keyword_index);
|
||||
|
||||
value_index = -1;
|
||||
value = NULL;
|
||||
value_length = 0;
|
||||
@ -221,6 +217,7 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
||||
continue;
|
||||
|
||||
found = FALSE;
|
||||
|
||||
for (j = 0; options[j].Name != NULL; j++)
|
||||
{
|
||||
match = FALSE;
|
||||
@ -279,7 +276,6 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
||||
i++;
|
||||
value_index = 0;
|
||||
length = (int) strlen(argv[i]);
|
||||
|
||||
value = (char*) &argv[i][value_index];
|
||||
value_length = (length - value_index);
|
||||
}
|
||||
@ -375,7 +371,8 @@ int CommandLineParseArgumentsA(int argc, LPCSTR* argv, COMMAND_LINE_ARGUMENT_A*
|
||||
return status;
|
||||
}
|
||||
|
||||
int CommandLineParseArgumentsW(int argc, LPCWSTR* argv, COMMAND_LINE_ARGUMENT_W* options, DWORD flags,
|
||||
int CommandLineParseArgumentsW(int argc, LPCWSTR* argv, COMMAND_LINE_ARGUMENT_W* options,
|
||||
DWORD flags,
|
||||
void* context, COMMAND_LINE_PRE_FILTER_FN_W preFilter, COMMAND_LINE_POST_FILTER_FN_W postFilter)
|
||||
{
|
||||
return 0;
|
||||
@ -409,7 +406,7 @@ int CommandLineClearArgumentsW(COMMAND_LINE_ARGUMENT_W* options)
|
||||
|
||||
COMMAND_LINE_ARGUMENT_A* CommandLineFindArgumentA(COMMAND_LINE_ARGUMENT_A* options, LPCSTR Name)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; options[i].Name != NULL; i++)
|
||||
{
|
||||
@ -428,7 +425,7 @@ COMMAND_LINE_ARGUMENT_A* CommandLineFindArgumentA(COMMAND_LINE_ARGUMENT_A* optio
|
||||
|
||||
COMMAND_LINE_ARGUMENT_W* CommandLineFindArgumentW(COMMAND_LINE_ARGUMENT_W* options, LPCWSTR Name)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; options[i].Name != NULL; i++)
|
||||
{
|
||||
@ -449,6 +446,9 @@ COMMAND_LINE_ARGUMENT_A* CommandLineFindNextArgumentA(COMMAND_LINE_ARGUMENT_A* a
|
||||
{
|
||||
COMMAND_LINE_ARGUMENT_A* nextArgument;
|
||||
|
||||
if (!argument)
|
||||
return NULL;
|
||||
|
||||
nextArgument = &argument[1];
|
||||
|
||||
if (nextArgument->Name == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user