FreeRDP
Loading...
Searching...
No Matches
TestX11CmdLine.c
1/* FreeRDP: Licensed under the Apache License, Version 2.0. */
2#include <freerdp/config.h>
3#include <freerdp/client/cmdline.h>
4#include "../xf_cmdline.h"
5#include "../xfreerdp.h"
6
7int main(int argc, char* argv[])
8{
9 WINPR_UNUSED(argc);
10 WINPR_UNUSED(argv);
11 static const struct
12 {
13 char* option;
14 BOOL enabled;
15 BOOL valid;
16 } cases[] = { { nullptr, FALSE, TRUE },
17 { "/defer-alt", TRUE, TRUE },
18 { "+defer-alt", TRUE, TRUE },
19 { "-defer-alt", FALSE, TRUE },
20 { "/defer-alt:invalid", FALSE, FALSE },
21 { "/kbd:defer-alt", FALSE, FALSE } };
22
23 for (size_t i = 0; i < ARRAYSIZE(cases); i++)
24 {
25 xfContext xfc = WINPR_C_ARRAY_INIT;
26 rdpSettings* settings = freerdp_settings_new(0);
27 if (!settings)
28 return 1;
29 xfc.common.context.settings = settings;
30 /* Parsing starts with the client's default, even when reusing a context. */
31 xfc.deferAlt = TRUE;
32 char* args[] = { "xfreerdp", "/v:localhost", cases[i].option, nullptr };
33 const int count = cases[i].option ? ARRAYSIZE(args) - 1 : ARRAYSIZE(args) - 2;
34 const int status = xf_client_settings_parse_command_line(&xfc, count, args);
35 const BOOL passed = ((status == 0) == cases[i].valid) &&
36 (!cases[i].valid || (xfc.deferAlt == cases[i].enabled));
37 freerdp_settings_free(settings);
38 if (!passed)
39 {
40 (void)fprintf(stderr, "option %s: status %d, enabled %d\n",
41 cases[i].option ? cases[i].option : "(default)", status, xfc.deferAlt);
42 return 1;
43 }
44 }
45
46 /* The common parser must not expose the X11-only option. */
47 rdpSettings* settings = freerdp_settings_new(0);
48 if (!settings)
49 return 1;
50 char* args[] = { "freerdp", "/v:localhost", "/defer-alt", nullptr };
51 const int status = freerdp_client_settings_parse_command_line_arguments(
52 settings, ARRAYSIZE(args) - 1, args, FALSE);
53 freerdp_settings_free(settings);
54 return status < 0 ? 0 : 1;
55}
FREERDP_API rdpSettings * freerdp_settings_new(DWORD flags)
creates a new setting struct
FREERDP_API void freerdp_settings_free(rdpSettings *settings)
Free a settings struct with all data in it.