Added flag to ignore unknown keywords

freerdp_client_settings_parse_command_line now allows ignoring
unknown keywords.
This commit is contained in:
Armin Novak 2015-03-16 10:15:37 +01:00
parent 7ad5039ce7
commit c380fb3520
12 changed files with 22 additions and 14 deletions

View File

@ -468,7 +468,7 @@ int main(int argc, char* argv[])
instance->context->argc = argc;
instance->context->argv = argv;
status = freerdp_client_settings_parse_command_line(instance->settings, argc, argv);
status = freerdp_client_settings_parse_command_line(instance->settings, argc, argv, FALSE);
if (status < 0)
exit(0);

View File

@ -105,7 +105,7 @@ void mac_set_view_size(rdpContext* context, MRDPView* view);
context->argc = i;
status = freerdp_client_settings_parse_command_line(context->settings, context->argc, context->argv);
status = freerdp_client_settings_parse_command_line(context->settings, context->argc, context->argv, FALSE);
status = freerdp_client_settings_command_line_status_print(context->settings, status, context->argc, context->argv);

View File

@ -334,7 +334,7 @@ int main(int argc, char* argv[])
channels = instance->context->channels;
status = freerdp_client_settings_parse_command_line(instance->settings, argc, argv);
status = freerdp_client_settings_parse_command_line(instance->settings, argc, argv, FALSE);
if (status < 0)
{

View File

@ -269,7 +269,7 @@ int main(int argc, char* argv[])
instance->ContextFree = wl_context_free;
freerdp_context_new(instance);
status = freerdp_client_settings_parse_command_line_arguments(instance->settings, argc, argv);
status = freerdp_client_settings_parse_command_line_arguments(instance->settings, argc, argv, FALSE);
status = freerdp_client_settings_command_line_status_print(instance->settings, status, argc, argv);

View File

@ -70,7 +70,7 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
for (index = 0; index < context->argc; index++)
context->argv[index] = _strdup(__argv[index]);
status = freerdp_client_settings_parse_command_line(settings, context->argc, context->argv);
status = freerdp_client_settings_parse_command_line(settings, context->argc, context->argv, FALSE);
status = freerdp_client_settings_command_line_status_print(settings, status, context->argc, context->argv);

View File

@ -53,7 +53,7 @@ int main(int argc, char* argv[])
settings = context->settings;
xfc = (xfContext*) context;
status = freerdp_client_settings_parse_command_line(context->settings, argc, argv);
status = freerdp_client_settings_parse_command_line(context->settings, argc, argv, FALSE);
status = freerdp_client_settings_command_line_status_print(settings, status, argc, argv);

View File

@ -159,7 +159,8 @@ out_error:
}
int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc, char** argv)
int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc,
char** argv, BOOL allowUnknown)
{
int status;
@ -169,7 +170,7 @@ int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc,
if (!argv)
return -1;
status = freerdp_client_settings_parse_command_line_arguments(settings, argc, argv);
status = freerdp_client_settings_parse_command_line_arguments(settings, argc, argv, allowUnknown);
if (settings->ConnectionFile)
{

View File

@ -1168,7 +1168,8 @@ int freerdp_client_settings_command_line_status_print(rdpSettings* settings, int
return 0;
}
int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, int argc, char** argv)
int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
int argc, char** argv, BOOL allowUnknown)
{
char* p;
char* str;
@ -1189,6 +1190,10 @@ int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
{
CommandLineClearArgumentsA(args);
if (allowUnknown)
{
flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
}
status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags, settings,
freerdp_client_command_line_pre_filter, freerdp_client_command_line_post_filter);

View File

@ -1040,7 +1040,7 @@ BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings*
char* ConnectionFile = settings->ConnectionFile;
settings->ConnectionFile = NULL;
freerdp_client_settings_parse_command_line(settings, file->argc, file->argv);
freerdp_client_settings_parse_command_line(settings, file->argc, file->argv, FALSE);
settings->ConnectionFile = ConnectionFile;
}

View File

@ -4,13 +4,13 @@
#include <winpr/cmdline.h>
#include <winpr/spec.h>
#define TESTCASE(cmd, expected_return) status = freerdp_client_settings_parse_command_line(settings, ARRAYSIZE(cmd), cmd); \
#define TESTCASE(cmd, expected_return) status = freerdp_client_settings_parse_command_line(settings, ARRAYSIZE(cmd), cmd, FALSE); \
if (status != expected_return) { \
printf("Test argument %s failed\n", #cmd); \
return -1; \
}
#define TESTCASE_SUCCESS(cmd) status = freerdp_client_settings_parse_command_line(settings, ARRAYSIZE(cmd), cmd); \
#define TESTCASE_SUCCESS(cmd) status = freerdp_client_settings_parse_command_line(settings, ARRAYSIZE(cmd), cmd, FALSE); \
if (status < 0) { \
printf("Test argument %s failed\n", #cmd); \
return -1; \

View File

@ -85,7 +85,8 @@ FREERDP_API int freerdp_client_stop(rdpContext* context);
FREERDP_API freerdp* freerdp_client_get_instance(rdpContext* context);
FREERDP_API HANDLE freerdp_client_get_thread(rdpContext* context);
FREERDP_API int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc, char** argv);
FREERDP_API int freerdp_client_settings_parse_command_line(rdpSettings* settings,
int argc, char** argv, BOOL allowUnknown);
FREERDP_API int freerdp_client_settings_parse_connection_file(rdpSettings* settings, const char* filename);
FREERDP_API int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings, const BYTE* buffer, size_t size);

View File

@ -27,7 +27,8 @@
extern "C" {
#endif
FREERDP_API int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings, int argc, char** argv);
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_load_addins(rdpChannels* channels, rdpSettings* settings);