2 * FreeRDP: A Remote Desktop Protocol Implementation
3 * FreeRDP Client Command-Line Interface
5 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6 * Copyright 2014 Norbert Federa <norbert.federa@thincast.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
27 #include <winpr/crt.h>
28 #include <winpr/cmdline.h>
30 #include <freerdp/addin.h>
31 #include <freerdp/settings.h>
32 #include <freerdp/client/channels.h>
33 #include <freerdp/crypto/crypto.h>
34 #include <freerdp/locale/keyboard.h>
37 #include <freerdp/client/cmdline.h>
38 #include <freerdp/version.h>
40 #include "compatibility.h"
42 #include <freerdp/log.h>
43 #define TAG CLIENT_TAG("common.cmdline")
45 COMMAND_LINE_ARGUMENT_A args[] =
47 { "v", COMMAND_LINE_VALUE_REQUIRED, "<server>[:port]", NULL, NULL, -1, NULL, "Server hostname" },
48 { "port", COMMAND_LINE_VALUE_REQUIRED, "<number>", NULL, NULL, -1, NULL, "Server port" },
49 { "w", COMMAND_LINE_VALUE_REQUIRED, "<width>", "1024", NULL, -1, NULL, "Width" },
50 { "h", COMMAND_LINE_VALUE_REQUIRED, "<height>", "768", NULL, -1, NULL, "Height" },
51 { "size", COMMAND_LINE_VALUE_REQUIRED, "<width>x<height> or <percent>%", "1024x768", NULL, -1, NULL, "Screen size" },
52 { "f", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "Fullscreen mode" },
53 { "bpp", COMMAND_LINE_VALUE_REQUIRED, "<depth>", "16", NULL, -1, NULL, "Session bpp (color depth)" },
54 { "kbd", COMMAND_LINE_VALUE_REQUIRED, "0x<layout id> or <layout name>", NULL, NULL, -1, NULL, "Keyboard layout" },
55 { "kbd-list", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT, NULL, NULL, NULL, -1, NULL, "List keyboard layouts" },
56 { "kbd-type", COMMAND_LINE_VALUE_REQUIRED, "<type id>", NULL, NULL, -1, NULL, "Keyboard type" },
57 { "kbd-subtype", COMMAND_LINE_VALUE_REQUIRED, "<subtype id>", NULL, NULL, -1, NULL, "Keyboard subtype" },
58 { "kbd-fn-key", COMMAND_LINE_VALUE_REQUIRED, "<function key count>", NULL, NULL, -1, NULL, "Keyboard function key count" },
59 { "admin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "console", "Admin (or console) session" },
60 { "restricted-admin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "restrictedAdmin", "Restricted admin mode" },
61 { "pth", COMMAND_LINE_VALUE_REQUIRED, "<password hash>", NULL, NULL, -1, "pass-the-hash", "Pass the hash (restricted admin mode)" },
62 { "client-hostname", COMMAND_LINE_VALUE_REQUIRED, "<name>", NULL, NULL, -1, NULL, "Client Hostname to send to server" },
63 { "multimon", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Use multiple monitors" },
64 { "span", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Span screen over multiple monitors" },
65 { "workarea", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "Use available work area" },
66 { "monitors", COMMAND_LINE_VALUE_REQUIRED, "<0,1,2...>", NULL, NULL, -1, NULL, "Select monitors to use" },
67 { "monitor-list", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT, NULL, NULL, NULL, -1, NULL, "List detected monitors" },
68 { "t", COMMAND_LINE_VALUE_REQUIRED, "<title>", NULL, NULL, -1, "title", "Window title" },
69 { "decorations", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "Window decorations" },
70 { "smart-sizing", COMMAND_LINE_VALUE_OPTIONAL, "<width>x<height>", NULL, NULL, -1, NULL, "Scale remote desktop to window size" },
71 { "a", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, "addin", "Addin" },
72 { "vc", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Static virtual channel" },
73 { "dvc", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Dynamic virtual channel" },
74 { "u", COMMAND_LINE_VALUE_REQUIRED, "[<domain>\\]<user> or <user>[@<domain>]", NULL, NULL, -1, NULL, "Username" },
75 { "p", COMMAND_LINE_VALUE_REQUIRED, "<password>", NULL, NULL, -1, NULL, "Password" },
76 { "d", COMMAND_LINE_VALUE_REQUIRED, "<domain>", NULL, NULL, -1, NULL, "Domain" },
77 { "g", COMMAND_LINE_VALUE_OPTIONAL, "<gateway>[:port]", NULL, NULL, -1, NULL, "Gateway Hostname" },
78 { "gu", COMMAND_LINE_VALUE_REQUIRED, "[<domain>\\]<user> or <user>[@<domain>]", NULL, NULL, -1, NULL, "Gateway username" },
79 { "gp", COMMAND_LINE_VALUE_REQUIRED, "<password>", NULL, NULL, -1, NULL, "Gateway password" },
80 { "gd", COMMAND_LINE_VALUE_REQUIRED, "<domain>", NULL, NULL, -1, NULL, "Gateway domain" },
81 { "gt", COMMAND_LINE_VALUE_REQUIRED, "<rpc|http|auto>", NULL, NULL, -1, NULL, "Gateway transport type" },
82 { "gateway-usage-method", COMMAND_LINE_VALUE_REQUIRED, "<direct|detect>", NULL, NULL, -1, "gum", "Gateway usage method" },
83 { "load-balance-info", COMMAND_LINE_VALUE_REQUIRED, "<info string>", NULL, NULL, -1, NULL, "Load balance info" },
84 { "app", COMMAND_LINE_VALUE_REQUIRED, "<executable path> or <||alias>", NULL, NULL, -1, NULL, "Remote application program" },
85 { "app-name", COMMAND_LINE_VALUE_REQUIRED, "<app name>", NULL, NULL, -1, NULL, "Remote application name for user interface" },
86 { "app-icon", COMMAND_LINE_VALUE_REQUIRED, "<icon path>", NULL, NULL, -1, NULL, "Remote application icon for user interface" },
87 { "app-cmd", COMMAND_LINE_VALUE_REQUIRED, "<parameters>", NULL, NULL, -1, NULL, "Remote application command-line parameters" },
88 { "app-file", COMMAND_LINE_VALUE_REQUIRED, "<file name>", NULL, NULL, -1, NULL, "File to open with remote application" },
89 { "app-guid", COMMAND_LINE_VALUE_REQUIRED, "<app guid>", NULL, NULL, -1, NULL, "Remote application GUID" },
90 { "compression", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, "z", "Compression" },
91 { "compression-level", COMMAND_LINE_VALUE_REQUIRED, "<level>", NULL, NULL, -1, NULL, "Compression level (0,1,2)" },
92 { "shell", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Alternate shell" },
93 { "shell-dir", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Shell working directory" },
94 { "sound", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, "audio", "Audio output (sound)" },
95 { "microphone", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, "mic", "Audio input (microphone)" },
96 { "audio-mode", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Audio output mode" },
97 { "multimedia", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, "mmr", "Redirect multimedia (video)" },
98 { "network", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Network connection type" },
99 { "drive", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Redirect drive" },
100 { "drives", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Redirect all drives" },
101 { "home-drive", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Redirect home drive" },
102 { "clipboard", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Redirect clipboard" },
103 { "serial", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, "tty", "Redirect serial device" },
104 { "parallel", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Redirect parallel device" },
105 { "smartcard", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Redirect smartcard device" },
106 { "printer", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Redirect printer device" },
107 { "usb", COMMAND_LINE_VALUE_REQUIRED, NULL, NULL, NULL, -1, NULL, "Redirect USB device" },
108 { "multitouch", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Redirect multitouch input" },
109 { "gestures", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Consume multitouch input locally" },
110 { "echo", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "echo", "Echo channel" },
111 { "disp", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "Display control" },
112 { "fonts", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Smooth fonts (ClearType)" },
113 { "aero", COMMAND_LINE_VALUE_BOOL, NULL, NULL, BoolValueFalse, -1, NULL, "Desktop composition" },
114 { "window-drag", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Full window drag" },
115 { "menu-anims", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Menu animations" },
116 { "themes", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "Themes" },
117 { "wallpaper", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "Wallpaper" },
118 { "gdi", COMMAND_LINE_VALUE_REQUIRED, "<sw|hw>", NULL, NULL, -1, NULL, "GDI rendering" },
119 { "gfx", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "RDP8 graphics pipeline (experimental)" },
120 { "gfx-thin-client", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "RDP8 graphics pipeline thin client mode" },
121 { "gfx-small-cache", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "RDP8 graphics pipeline small cache mode" },
122 { "gfx-progressive", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "RDP8 graphics pipeline progressive codec" },
123 { "gfx-h264", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "RDP8.1 graphics pipeline H264 codec" },
124 { "rfx", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "RemoteFX" },
125 { "rfx-mode", COMMAND_LINE_VALUE_REQUIRED, "<image|video>", NULL, NULL, -1, NULL, "RemoteFX mode" },
126 { "frame-ack", COMMAND_LINE_VALUE_REQUIRED, "<number>", NULL, NULL, -1, NULL, "Frame acknowledgement" },
127 { "nsc", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "nscodec", "NSCodec" },
128 { "jpeg", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "JPEG codec" },
129 { "jpeg-quality", COMMAND_LINE_VALUE_REQUIRED, "<percentage>", NULL, NULL, -1, NULL, "JPEG quality" },
130 { "nego", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "protocol security negotiation" },
131 { "sec", COMMAND_LINE_VALUE_REQUIRED, "<rdp|tls|nla|ext>", NULL, NULL, -1, NULL, "force specific protocol security" },
132 { "sec-rdp", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "rdp protocol security" },
133 { "sec-tls", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "tls protocol security" },
134 { "sec-nla", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "nla protocol security" },
135 { "sec-ext", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "nla extended protocol security" },
136 { "tls-ciphers", COMMAND_LINE_VALUE_REQUIRED, "<netmon|ma|ciphers>", NULL, NULL, -1, NULL, "Allowed TLS ciphers" },
137 { "cert-name", COMMAND_LINE_VALUE_REQUIRED, "<name>", NULL, NULL, -1, NULL, "certificate name" },
138 { "cert-ignore", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "ignore certificate" },
139 { "pcb", COMMAND_LINE_VALUE_REQUIRED, "<blob>", NULL, NULL, -1, NULL, "Preconnection Blob" },
140 { "pcid", COMMAND_LINE_VALUE_REQUIRED, "<id>", NULL, NULL, -1, NULL, "Preconnection Id" },
141 { "spn-class", COMMAND_LINE_VALUE_REQUIRED, "<service class>", NULL, NULL, -1, NULL, "SPN authentication service class" },
142 { "credentials-delegation", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Disable credentials delegation" },
143 { "vmconnect", COMMAND_LINE_VALUE_OPTIONAL, "<vmid>", NULL, NULL, -1, NULL, "Hyper-V console (use port 2179, disable negotiation)" },
144 { "authentication", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "authentication (hack!)" },
145 { "encryption", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "encryption (hack!)" },
146 { "grab-keyboard", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "grab keyboard" },
147 { "toggle-fullscreen", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "Alt+Ctrl+Enter toggles fullscreen" },
148 { "mouse-motion", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "mouse-motion" },
149 { "parent-window", COMMAND_LINE_VALUE_REQUIRED, "<window id>", NULL, NULL, -1, NULL, "Parent window id" },
150 { "bitmap-cache", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "bitmap cache" },
151 { "offscreen-cache", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "offscreen bitmap cache" },
152 { "glyph-cache", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "glyph cache" },
153 { "codec-cache", COMMAND_LINE_VALUE_REQUIRED, "<rfx|nsc|jpeg>", NULL, NULL, -1, NULL, "bitmap codec cache" },
154 { "fast-path", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "fast-path input/output" },
155 { "max-fast-path-size", COMMAND_LINE_VALUE_OPTIONAL, "<size>", NULL, NULL, -1, NULL, "maximum fast-path update size" },
156 { "async-input", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "asynchronous input" },
157 { "async-update", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "asynchronous update" },
158 { "async-transport", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "asynchronous transport (unstable)" },
159 { "async-channels", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "asynchronous channels (unstable)" },
160 { "wm-class", COMMAND_LINE_VALUE_REQUIRED, "<class name>", NULL, NULL, -1, NULL, "set the WM_CLASS hint for the window instance" },
161 { "version", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_VERSION, NULL, NULL, NULL, -1, NULL, "print version" },
162 { "help", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, NULL, NULL, NULL, -1, "?", "print help" },
163 { "play-rfx", COMMAND_LINE_VALUE_REQUIRED, "<pcap file>", NULL, NULL, -1, NULL, "Replay rfx pcap file" },
164 { "auth-only", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Authenticate only." },
165 { "auto-reconnect", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Automatic reconnection" },
166 { "reconnect-cookie", COMMAND_LINE_VALUE_REQUIRED, "<base64 cookie>", NULL, NULL, -1, NULL, "Pass base64 reconnect cookie to the connection" },
167 { "print-reconnect-cookie", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Print base64 reconnect cookie after connecting" },
168 { "heartbeat", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Support heartbeat PDUs" },
169 { "multitransport", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Support multitransport protocol" },
170 { "assistance", COMMAND_LINE_VALUE_REQUIRED, "<password>", NULL, NULL, -1, NULL, "Remote assistance password" },
171 { "encryption-methods", COMMAND_LINE_VALUE_REQUIRED, "<40,56,128,FIPS>", NULL, NULL, -1, NULL, "RDP standard security encryption methods" },
172 { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
175 int freerdp_client_print_version()
177 printf("This is FreeRDP version %s (git %s)\n", FREERDP_VERSION_FULL, GIT_REVISION);
181 int freerdp_client_print_command_line_help(int argc, char** argv)
185 COMMAND_LINE_ARGUMENT_A* arg;
188 printf("FreeRDP - A Free Remote Desktop Protocol Implementation\n");
189 printf("See www.freerdp.com for more information\n");
192 printf("Usage: %s [file] [options] [/v:<server>[:port]]\n", argv[0]);
196 printf(" /flag (enables flag)\n");
197 printf(" /option:<value> (specifies option with value)\n");
198 printf(" +toggle -toggle (enables or disables toggle, where '/' is a synonym of '+')\n");
205 if (arg->Flags & COMMAND_LINE_VALUE_FLAG)
208 printf("%-20s", arg->Name);
209 printf("\t%s\n", arg->Text);
211 else if ((arg->Flags & COMMAND_LINE_VALUE_REQUIRED) || (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL))
217 length = (int)(strlen(arg->Name) + strlen(arg->Format) + 2);
218 str = (char*) calloc(length + 1UL, sizeof(char));
219 sprintf_s(str, length + 1, "%s:%s", arg->Name, arg->Format);
220 printf("%-20s", str);
225 printf("%-20s", arg->Name);
228 printf("\t%s\n", arg->Text);
230 else if (arg->Flags & COMMAND_LINE_VALUE_BOOL)
232 length = (int) strlen(arg->Name) + 32;
233 str = (char*) calloc(length + 1UL, sizeof(char));
234 sprintf_s(str, length + 1, "%s (default:%s)", arg->Name,
235 arg->Default ? "on" : "off");
237 printf(" %s", arg->Default ? "-" : "+");
239 printf("%-20s", str);
242 printf("\t%s\n", arg->Text);
245 while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
249 printf("Examples:\n");
250 printf(" xfreerdp connection.rdp /p:Pwd123! /f\n");
251 printf(" xfreerdp /u:CONTOSO\\JohnDoe /p:Pwd123! /v:rdp.contoso.com\n");
252 printf(" xfreerdp /u:JohnDoe /p:Pwd123! /w:1366 /h:768 /v:192.168.1.100:4489\n");
253 printf(" xfreerdp /u:JohnDoe /p:Pwd123! /vmconnect:C824F53E-95D2-46C6-9A18-23A5BB403532 /v:192.168.1.100\n");
256 printf("Clipboard Redirection: +clipboard\n");
259 printf("Drive Redirection: /drive:home,/home/user\n");
260 printf("Smartcard Redirection: /smartcard:<device>\n");
261 printf("Serial Port Redirection: /serial:<name>,<device>,[SerCx2|SerCx|Serial],[permissive]\n");
262 printf("Serial Port Redirection: /serial:COM1,/dev/ttyS0\n");
263 printf("Parallel Port Redirection: /parallel:<device>\n");
264 printf("Printer Redirection: /printer:<device>,<driver>\n");
267 printf("Audio Output Redirection: /sound:sys:alsa\n");
268 printf("Audio Input Redirection: /microphone:sys:alsa\n");
271 printf("Multimedia Redirection: /multimedia:sys:alsa\n");
272 printf("USB Device Redirection: /usb:id,dev:054c:0268\n");
275 printf("More documentation is coming, in the meantime consult source files\n");
281 int freerdp_client_command_line_pre_filter(void* context, int index, int argc, LPCSTR* argv)
286 rdpSettings* settings;
288 length = (int) strlen(argv[index]);
292 if (_stricmp(&(argv[index])[length - 4], ".rdp") == 0)
294 settings = (rdpSettings*) context;
295 settings->ConnectionFile = _strdup(argv[index]);
303 if (_stricmp(&(argv[index])[length - 13], ".msrcIncident") == 0)
305 settings = (rdpSettings*) context;
306 settings->AssistanceFile = _strdup(argv[index]);
316 int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** params)
318 if (strcmp(params[0], "drive") == 0)
325 settings->DeviceRedirection = TRUE;
327 drive = (RDPDR_DRIVE*) calloc(1, sizeof(RDPDR_DRIVE));
332 drive->Type = RDPDR_DTYP_FILESYSTEM;
335 drive->Name = _strdup(params[1]);
338 drive->Path = _strdup(params[2]);
340 freerdp_device_collection_add(settings, (RDPDR_DEVICE*) drive);
344 else if (strcmp(params[0], "printer") == 0)
346 RDPDR_PRINTER* printer;
351 settings->RedirectPrinters = TRUE;
352 settings->DeviceRedirection = TRUE;
356 printer = (RDPDR_PRINTER*) calloc(1, sizeof(RDPDR_PRINTER));
361 printer->Type = RDPDR_DTYP_PRINT;
364 printer->Name = _strdup(params[1]);
367 printer->DriverName = _strdup(params[2]);
369 freerdp_device_collection_add(settings, (RDPDR_DEVICE*) printer);
374 else if (strcmp(params[0], "smartcard") == 0)
376 RDPDR_SMARTCARD* smartcard;
381 settings->RedirectSmartCards = TRUE;
382 settings->DeviceRedirection = TRUE;
386 smartcard = (RDPDR_SMARTCARD*) calloc(1, sizeof(RDPDR_SMARTCARD));
391 smartcard->Type = RDPDR_DTYP_SMARTCARD;
394 smartcard->Name = _strdup(params[1]);
397 smartcard->Path = _strdup(params[2]);
399 freerdp_device_collection_add(settings, (RDPDR_DEVICE*) smartcard);
404 else if (strcmp(params[0], "serial") == 0)
406 RDPDR_SERIAL* serial;
411 settings->RedirectSerialPorts = TRUE;
412 settings->DeviceRedirection = TRUE;
414 serial = (RDPDR_SERIAL*) calloc(1, sizeof(RDPDR_SERIAL));
419 serial->Type = RDPDR_DTYP_SERIAL;
422 serial->Name = _strdup(params[1]);
425 serial->Path = _strdup(params[2]);
428 serial->Driver = _strdup(params[3]);
431 serial->Permissive = _strdup(params[4]);
433 freerdp_device_collection_add(settings, (RDPDR_DEVICE*) serial);
437 else if (strcmp(params[0], "parallel") == 0)
439 RDPDR_PARALLEL* parallel;
444 settings->RedirectParallelPorts = TRUE;
445 settings->DeviceRedirection = TRUE;
447 parallel = (RDPDR_PARALLEL*) calloc(1, sizeof(RDPDR_PARALLEL));
452 parallel->Type = RDPDR_DTYP_PARALLEL;
455 parallel->Name = _strdup(params[1]);
458 parallel->Path = _strdup(params[2]);
460 freerdp_device_collection_add(settings, (RDPDR_DEVICE*) parallel);
468 int freerdp_client_add_static_channel(rdpSettings* settings, int count, char** params)
473 args = (ADDIN_ARGV*) malloc(sizeof(ADDIN_ARGV));
476 args->argv = (char**) calloc(args->argc, sizeof(char*));
478 for (index = 0; index < args->argc; index++)
479 args->argv[index] = _strdup(params[index]);
481 freerdp_static_channel_collection_add(settings, args);
486 int freerdp_client_add_dynamic_channel(rdpSettings* settings, int count, char** params)
491 args = (ADDIN_ARGV*) malloc(sizeof(ADDIN_ARGV));
494 args->argv = (char**) calloc(args->argc, sizeof(char*));
496 for (index = 0; index < args->argc; index++)
497 args->argv[index] = _strdup(params[index]);
499 freerdp_dynamic_channel_collection_add(settings, args);
504 static char** freerdp_command_line_parse_comma_separated_values(char* list, int* count)
514 assert(NULL != count);
520 for (index = 0; list[index]; index++)
521 nCommas += (list[index] == ',') ? 1 : 0;
524 p = (char**) calloc((nArgs + 1UL), sizeof(char*));
530 for (index = 1; index < nArgs; index++)
532 p[index] = strchr(p[index - 1], ',');
537 p[index] = str + strlen(str);
544 static char** freerdp_command_line_parse_comma_separated_values_offset(char* list, int* count)
549 p = freerdp_command_line_parse_comma_separated_values(list, count);
551 t = (char**) realloc(p, sizeof(char*) * (*count + 1));
556 MoveMemory(&p[1], p, sizeof(char*) * *count);
562 int freerdp_client_command_line_post_filter(void* context, COMMAND_LINE_ARGUMENT_A* arg)
564 rdpSettings* settings = (rdpSettings*) context;
566 CommandLineSwitchStart(arg)
568 CommandLineSwitchCase(arg, "a")
573 p = freerdp_command_line_parse_comma_separated_values(arg->Value, &count);
575 if (freerdp_client_add_device_channel(settings, count, p) > 0)
577 settings->DeviceRedirection = TRUE;
582 CommandLineSwitchCase(arg, "vc")
587 p = freerdp_command_line_parse_comma_separated_values(arg->Value, &count);
589 freerdp_client_add_static_channel(settings, count, p);
593 CommandLineSwitchCase(arg, "dvc")
598 p = freerdp_command_line_parse_comma_separated_values(arg->Value, &count);
600 freerdp_client_add_dynamic_channel(settings, count, p);
604 CommandLineSwitchCase(arg, "drive")
609 p = freerdp_command_line_parse_comma_separated_values_offset(arg->Value, &count);
612 freerdp_client_add_device_channel(settings, count, p);
616 CommandLineSwitchCase(arg, "serial")
621 p = freerdp_command_line_parse_comma_separated_values_offset(arg->Value, &count);
624 freerdp_client_add_device_channel(settings, count, p);
628 CommandLineSwitchCase(arg, "parallel")
633 p = freerdp_command_line_parse_comma_separated_values_offset(arg->Value, &count);
636 freerdp_client_add_device_channel(settings, count, p);
640 CommandLineSwitchCase(arg, "smartcard")
645 p = freerdp_command_line_parse_comma_separated_values_offset(arg->Value, &count);
648 freerdp_client_add_device_channel(settings, count, p);
652 CommandLineSwitchCase(arg, "printer")
654 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
659 p = freerdp_command_line_parse_comma_separated_values_offset(arg->Value, &count);
662 freerdp_client_add_device_channel(settings, count, p);
674 freerdp_client_add_device_channel(settings, count, p);
677 CommandLineSwitchCase(arg, "usb")
682 p = freerdp_command_line_parse_comma_separated_values_offset(arg->Value, &count);
685 freerdp_client_add_dynamic_channel(settings, count, p);
689 CommandLineSwitchCase(arg, "multitouch")
691 settings->MultiTouchInput = TRUE;
693 CommandLineSwitchCase(arg, "gestures")
695 settings->MultiTouchGestures = TRUE;
697 CommandLineSwitchCase(arg, "echo")
699 settings->SupportEchoChannel = TRUE;
701 CommandLineSwitchCase(arg, "disp")
703 settings->SupportDisplayControl = TRUE;
705 CommandLineSwitchCase(arg, "sound")
707 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
712 p = freerdp_command_line_parse_comma_separated_values_offset(arg->Value, &count);
715 freerdp_client_add_static_channel(settings, count, p);
727 freerdp_client_add_static_channel(settings, count, p);
730 CommandLineSwitchCase(arg, "microphone")
732 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
737 p = freerdp_command_line_parse_comma_separated_values_offset(arg->Value, &count);
740 freerdp_client_add_dynamic_channel(settings, count, p);
752 freerdp_client_add_dynamic_channel(settings, count, p);
755 CommandLineSwitchCase(arg, "multimedia")
757 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
762 p = freerdp_command_line_parse_comma_separated_values_offset(arg->Value, &count);
765 freerdp_client_add_dynamic_channel(settings, count, p);
777 freerdp_client_add_dynamic_channel(settings, count, p);
780 CommandLineSwitchCase(arg, "heartbeat")
782 settings->SupportHeartbeatPdu = TRUE;
784 CommandLineSwitchCase(arg, "multitransport")
786 settings->SupportMultitransport = TRUE;
787 settings->MultitransportFlags = (TRANSPORT_TYPE_UDP_FECR | TRANSPORT_TYPE_UDP_FECL | TRANSPORT_TYPE_UDP_PREFERRED);
790 CommandLineSwitchEnd(arg)
795 int freerdp_parse_username(char* username, char** user, char** domain)
801 p = strchr(username, '\\');
802 p = strrchr(username, '@');
809 length = (int) (p - username);
810 *user = _strdup(&p[1]);
814 *domain = (char*) calloc(length + 1UL, sizeof(char));
822 strncpy(*domain, username, length);
823 (*domain)[length] = '\0';
827 /* Do not break up the name for '@'; both credSSP and the
828 * ClientInfo PDU expect 'user@corp.net' to be transmitted
829 * as username 'user@corp.net', domain empty (not NULL!).
831 *user = _strdup(username);
835 /* If only username is given, prefix that with 'TARGET'
836 * otherwise set the domain to an empty string.
837 * NOTE: Domain NULL will result in undefined behavior.
840 *domain = _strdup("TARGET");
842 *domain = _strdup("\0");
857 int freerdp_parse_hostname(char* hostname, char** host, int* port)
862 p = strrchr(hostname, ':');
866 length = (p - hostname);
867 *host = (char*) calloc(length + 1UL, sizeof(char));
872 CopyMemory(*host, hostname, length);
873 (*host)[length] = '\0';
878 *host = _strdup(hostname);
889 int freerdp_set_connection_type(rdpSettings* settings, int type)
891 settings->ConnectionType = type;
893 if (type == CONNECTION_TYPE_MODEM)
895 settings->DisableWallpaper = TRUE;
896 settings->AllowFontSmoothing = FALSE;
897 settings->AllowDesktopComposition = FALSE;
898 settings->DisableFullWindowDrag = TRUE;
899 settings->DisableMenuAnims = TRUE;
900 settings->DisableThemes = TRUE;
902 else if (type == CONNECTION_TYPE_BROADBAND_LOW)
904 settings->DisableWallpaper = TRUE;
905 settings->AllowFontSmoothing = FALSE;
906 settings->AllowDesktopComposition = FALSE;
907 settings->DisableFullWindowDrag = TRUE;
908 settings->DisableMenuAnims = TRUE;
909 settings->DisableThemes = FALSE;
911 else if (type == CONNECTION_TYPE_SATELLITE)
913 settings->DisableWallpaper = TRUE;
914 settings->AllowFontSmoothing = FALSE;
915 settings->AllowDesktopComposition = TRUE;
916 settings->DisableFullWindowDrag = TRUE;
917 settings->DisableMenuAnims = TRUE;
918 settings->DisableThemes = FALSE;
920 else if (type == CONNECTION_TYPE_BROADBAND_HIGH)
922 settings->DisableWallpaper = TRUE;
923 settings->AllowFontSmoothing = FALSE;
924 settings->AllowDesktopComposition = TRUE;
925 settings->DisableFullWindowDrag = TRUE;
926 settings->DisableMenuAnims = TRUE;
927 settings->DisableThemes = FALSE;
929 else if (type == CONNECTION_TYPE_WAN)
931 settings->DisableWallpaper = FALSE;
932 settings->AllowFontSmoothing = TRUE;
933 settings->AllowDesktopComposition = TRUE;
934 settings->DisableFullWindowDrag = FALSE;
935 settings->DisableMenuAnims = FALSE;
936 settings->DisableThemes = FALSE;
938 else if (type == CONNECTION_TYPE_LAN)
940 settings->DisableWallpaper = FALSE;
941 settings->AllowFontSmoothing = TRUE;
942 settings->AllowDesktopComposition = TRUE;
943 settings->DisableFullWindowDrag = FALSE;
944 settings->DisableMenuAnims = FALSE;
945 settings->DisableThemes = FALSE;
947 else if (type == CONNECTION_TYPE_AUTODETECT)
949 settings->DisableWallpaper = FALSE;
950 settings->AllowFontSmoothing = TRUE;
951 settings->AllowDesktopComposition = TRUE;
952 settings->DisableFullWindowDrag = FALSE;
953 settings->DisableMenuAnims = FALSE;
954 settings->DisableThemes = FALSE;
956 settings->NetworkAutoDetect = TRUE;
962 int freerdp_map_keyboard_layout_name_to_id(char* name)
966 RDP_KEYBOARD_LAYOUT* layouts;
968 layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD);
970 for (i = 0; layouts[i].code; i++)
972 if (_stricmp(layouts[i].name, name) == 0)
973 id = layouts[i].code;
981 layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_VARIANT);
983 for (i = 0; layouts[i].code; i++)
985 if (_stricmp(layouts[i].name, name) == 0)
986 id = layouts[i].code;
994 layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_IME);
996 for (i = 0; layouts[i].code; i++)
998 if (_stricmp(layouts[i].name, name) == 0)
999 id = layouts[i].code;
1010 int freerdp_detect_command_line_pre_filter(void* context, int index, int argc, LPCSTR* argv)
1016 length = (int) strlen(argv[index]);
1020 if (_stricmp(&(argv[index])[length - 4], ".rdp") == 0)
1028 if (_stricmp(&(argv[index])[length - 13], ".msrcIncident") == 0)
1038 int freerdp_detect_windows_style_command_line_syntax(int argc, char** argv,
1039 int* count, BOOL ignoreUnknown)
1044 COMMAND_LINE_ARGUMENT_A* arg;
1046 flags = COMMAND_LINE_SEPARATOR_COLON;
1047 flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
1051 flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
1056 CommandLineClearArgumentsA(args);
1058 status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags,
1059 NULL, freerdp_detect_command_line_pre_filter, NULL);
1068 if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
1073 while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
1075 if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
1078 return detect_status;
1081 int freerdp_detect_posix_style_command_line_syntax(int argc, char** argv,
1082 int* count, BOOL ignoreUnknown)
1087 COMMAND_LINE_ARGUMENT_A* arg;
1089 flags = COMMAND_LINE_SEPARATOR_SPACE;
1090 flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
1091 flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
1095 flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
1100 CommandLineClearArgumentsA(args);
1102 status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags,
1103 NULL, freerdp_detect_command_line_pre_filter, NULL);
1112 if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
1117 while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
1119 if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
1122 return detect_status;
1125 static BOOL freerdp_client_detect_command_line(int argc, char** argv,
1126 DWORD* flags, BOOL ignoreUnknown)
1130 int posix_cli_status;
1131 int posix_cli_count;
1132 int windows_cli_status;
1133 int windows_cli_count;
1134 BOOL compatibility = FALSE;
1136 windows_cli_status = freerdp_detect_windows_style_command_line_syntax(argc, argv, &windows_cli_count, ignoreUnknown);
1137 posix_cli_status = freerdp_detect_posix_style_command_line_syntax(argc, argv, &posix_cli_count, ignoreUnknown);
1138 old_cli_status = freerdp_detect_old_command_line_syntax(argc, argv, &old_cli_count);
1140 /* Default is POSIX syntax */
1141 *flags = COMMAND_LINE_SEPARATOR_SPACE;
1142 *flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
1143 *flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
1145 if (posix_cli_status <= COMMAND_LINE_STATUS_PRINT)
1146 return compatibility;
1148 /* Check, if this may be windows style syntax... */
1149 if ((windows_cli_count && (windows_cli_count >= posix_cli_count)) || (windows_cli_status <= COMMAND_LINE_STATUS_PRINT))
1151 windows_cli_count = 1;
1152 *flags = COMMAND_LINE_SEPARATOR_COLON;
1153 *flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
1155 else if (old_cli_status >= 0)
1157 /* Ignore legacy parsing in case there is an error in the command line. */
1159 if ((old_cli_status == 1) || ((old_cli_count > posix_cli_count) && (old_cli_status != -1)))
1161 *flags = COMMAND_LINE_SEPARATOR_SPACE;
1162 *flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
1164 compatibility = TRUE;
1168 WLog_DBG(TAG, "windows: %d/%d posix: %d/%d compat: %d/%d", windows_cli_status, windows_cli_count,
1169 posix_cli_status, posix_cli_count, old_cli_status, old_cli_count);
1171 return compatibility;
1174 int freerdp_client_settings_command_line_status_print(rdpSettings* settings, int status, int argc, char** argv)
1176 COMMAND_LINE_ARGUMENT_A* arg;
1178 if (status == COMMAND_LINE_STATUS_PRINT_VERSION)
1180 freerdp_client_print_version();
1181 return COMMAND_LINE_STATUS_PRINT_VERSION;
1183 else if (status == COMMAND_LINE_STATUS_PRINT)
1185 arg = CommandLineFindArgumentA(args, "kbd-list");
1187 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1190 RDP_KEYBOARD_LAYOUT* layouts;
1192 layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD);
1193 printf("\nKeyboard Layouts\n");
1194 for (i = 0; layouts[i].code; i++)
1195 printf("0x%08X\t%s\n", (int) layouts[i].code, layouts[i].name);
1198 layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_VARIANT);
1199 printf("\nKeyboard Layout Variants\n");
1200 for (i = 0; layouts[i].code; i++)
1201 printf("0x%08X\t%s\n", (int) layouts[i].code, layouts[i].name);
1204 layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_IME);
1205 printf("\nKeyboard Input Method Editors (IMEs)\n");
1206 for (i = 0; layouts[i].code; i++)
1207 printf("0x%08X\t%s\n", (int) layouts[i].code, layouts[i].name);
1213 arg = CommandLineFindArgumentA(args, "monitor-list");
1215 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1217 settings->ListMonitors = TRUE;
1220 return COMMAND_LINE_STATUS_PRINT;
1222 else if (status < 0)
1224 freerdp_client_print_command_line_help(argc, argv);
1225 return COMMAND_LINE_STATUS_PRINT_HELP;
1231 int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
1232 int argc, char** argv, BOOL allowUnknown)
1236 char* gwUser = NULL;
1242 COMMAND_LINE_ARGUMENT_A* arg;
1244 compatibility = freerdp_client_detect_command_line(argc, argv, &flags, allowUnknown);
1248 WLog_WARN(TAG, "Using deprecated command-line interface!");
1249 return freerdp_client_parse_old_command_line_arguments(argc, argv, settings);
1253 CommandLineClearArgumentsA(args);
1257 flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
1259 status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags, settings,
1260 freerdp_client_command_line_pre_filter, freerdp_client_command_line_post_filter);
1266 CommandLineFindArgumentA(args, "v");
1272 if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
1275 CommandLineSwitchStart(arg)
1277 CommandLineSwitchCase(arg, "v")
1279 p = strchr(arg->Value, '[');
1283 p = strchr(arg->Value, ':');
1286 length = (int) (p - arg->Value);
1287 settings->ServerPort = atoi(&p[1]);
1288 settings->ServerHostname = (char*) calloc(length + 1UL, sizeof(char));
1289 strncpy(settings->ServerHostname, arg->Value, length);
1290 settings->ServerHostname[length] = '\0';
1294 settings->ServerHostname = _strdup(arg->Value);
1299 char *p2 = strchr(arg->Value, ']');
1300 /* not a valid [] ipv6 addr found */
1305 settings->ServerHostname = (char*) calloc(length, sizeof(char));
1306 strncpy(settings->ServerHostname, p+1, length-1);
1307 if (*(p2 + 1) == ':')
1309 settings->ServerPort = atoi(&p2[2]);
1311 printf("hostname %s port %d\n", settings->ServerHostname, settings->ServerPort);
1314 CommandLineSwitchCase(arg, "spn-class")
1316 settings->AuthenticationServiceClass = _strdup(arg->Value);
1318 CommandLineSwitchCase(arg, "credentials-delegation")
1320 settings->DisableCredentialsDelegation = arg->Value ? FALSE : TRUE;
1322 CommandLineSwitchCase(arg, "vmconnect")
1324 settings->ServerPort = 2179;
1325 settings->NegotiateSecurityLayer = FALSE;
1327 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1329 settings->SendPreconnectionPdu = TRUE;
1330 settings->PreconnectionBlob = _strdup(arg->Value);
1333 CommandLineSwitchCase(arg, "w")
1335 settings->DesktopWidth = atoi(arg->Value);
1337 CommandLineSwitchCase(arg, "h")
1339 settings->DesktopHeight = atoi(arg->Value);
1341 CommandLineSwitchCase(arg, "size")
1343 str = _strdup(arg->Value);
1345 p = strchr(str, 'x');
1350 settings->DesktopWidth = atoi(str);
1351 settings->DesktopHeight = atoi(&p[1]);
1355 p = strchr(str, '%');
1358 settings->PercentScreen = atoi(str);
1364 CommandLineSwitchCase(arg, "f")
1366 settings->Fullscreen = TRUE;
1368 CommandLineSwitchCase(arg, "multimon")
1370 settings->UseMultimon = TRUE;
1372 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1374 if (_stricmp(arg->Value, "force") == 0)
1376 settings->ForceMultimon = TRUE;
1380 CommandLineSwitchCase(arg, "span")
1382 settings->SpanMonitors = TRUE;
1384 CommandLineSwitchCase(arg, "workarea")
1386 settings->Workarea = TRUE;
1388 CommandLineSwitchCase(arg, "monitors")
1390 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1396 p = freerdp_command_line_parse_comma_separated_values(arg->Value, &count);
1401 settings->NumMonitorIds = (UINT32) count;
1403 for (i = 0; i < settings->NumMonitorIds; i++)
1405 settings->MonitorIds[i] = atoi(p[i]);
1411 CommandLineSwitchCase(arg, "monitor-list")
1413 settings->ListMonitors = TRUE;
1415 CommandLineSwitchCase(arg, "t")
1417 settings->WindowTitle = _strdup(arg->Value);
1419 CommandLineSwitchCase(arg, "decorations")
1421 settings->Decorations = arg->Value ? TRUE : FALSE;
1423 CommandLineSwitchCase(arg, "smart-sizing")
1425 settings->SmartSizing = TRUE;
1429 str = _strdup(arg->Value);
1430 if ((p = strchr(str, 'x')))
1433 settings->SmartSizingWidth = atoi(str);
1434 settings->SmartSizingHeight = atoi(&p[1]);
1439 CommandLineSwitchCase(arg, "bpp")
1441 settings->ColorDepth = atoi(arg->Value);
1443 CommandLineSwitchCase(arg, "admin")
1445 settings->ConsoleSession = TRUE;
1447 CommandLineSwitchCase(arg, "restricted-admin")
1449 settings->ConsoleSession = TRUE;
1450 settings->RestrictedAdminModeRequired = TRUE;
1452 CommandLineSwitchCase(arg, "pth")
1454 settings->ConsoleSession = TRUE;
1455 settings->RestrictedAdminModeRequired = TRUE;
1456 settings->PasswordHash = _strdup(arg->Value);
1458 CommandLineSwitchCase(arg, "client-hostname")
1460 settings->ClientHostname = _strdup(arg->Value);
1462 CommandLineSwitchCase(arg, "kbd")
1464 unsigned long int id;
1467 id = strtoul(arg->Value, &pEnd, 16);
1469 if (pEnd != (arg->Value + strlen(arg->Value)))
1474 id = (unsigned long int) freerdp_map_keyboard_layout_name_to_id(arg->Value);
1478 WLog_ERR(TAG, "Could not identify keyboard layout: %s", arg->Value);
1482 settings->KeyboardLayout = (UINT32) id;
1484 CommandLineSwitchCase(arg, "kbd-type")
1486 settings->KeyboardType = atoi(arg->Value);
1488 CommandLineSwitchCase(arg, "kbd-subtype")
1490 settings->KeyboardSubType = atoi(arg->Value);
1492 CommandLineSwitchCase(arg, "kbd-fn-key")
1494 settings->KeyboardFunctionKey = atoi(arg->Value);
1496 CommandLineSwitchCase(arg, "u")
1498 user = _strdup(arg->Value);
1500 CommandLineSwitchCase(arg, "d")
1502 settings->Domain = _strdup(arg->Value);
1504 CommandLineSwitchCase(arg, "p")
1506 settings->Password = _strdup(arg->Value);
1508 CommandLineSwitchCase(arg, "g")
1510 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1512 p = strchr(arg->Value, ':');
1516 length = (int) (p - arg->Value);
1517 settings->GatewayPort = atoi(&p[1]);
1518 settings->GatewayHostname = (char*) calloc(length + 1UL, sizeof(char));
1519 strncpy(settings->GatewayHostname, arg->Value, length);
1520 settings->GatewayHostname[length] = '\0';
1524 settings->GatewayHostname = _strdup(arg->Value);
1529 settings->GatewayHostname = _strdup(settings->ServerHostname);
1532 settings->GatewayEnabled = TRUE;
1533 settings->GatewayUseSameCredentials = TRUE;
1535 freerdp_set_gateway_usage_method(settings, TSC_PROXY_MODE_DIRECT);
1537 CommandLineSwitchCase(arg, "gu")
1539 gwUser = _strdup(arg->Value);
1540 settings->GatewayUseSameCredentials = FALSE;
1542 CommandLineSwitchCase(arg, "gd")
1544 settings->GatewayDomain = _strdup(arg->Value);
1545 settings->GatewayUseSameCredentials = FALSE;
1547 CommandLineSwitchCase(arg, "gp")
1549 settings->GatewayPassword = _strdup(arg->Value);
1550 settings->GatewayUseSameCredentials = FALSE;
1552 CommandLineSwitchCase(arg, "gt")
1554 if (_stricmp(arg->Value, "rpc") == 0)
1556 settings->GatewayRpcTransport = TRUE;
1557 settings->GatewayHttpTransport = FALSE;
1559 else if (_stricmp(arg->Value, "http") == 0)
1561 settings->GatewayRpcTransport = FALSE;
1562 settings->GatewayHttpTransport = TRUE;
1564 else if (_stricmp(arg->Value, "auto") == 0)
1566 settings->GatewayRpcTransport = TRUE;
1567 settings->GatewayHttpTransport = TRUE;
1570 CommandLineSwitchCase(arg, "gateway-usage-method")
1575 type = strtol(arg->Value, &pEnd, 10);
1579 if (_stricmp(arg->Value, "none") == 0)
1580 type = TSC_PROXY_MODE_NONE_DIRECT;
1581 else if (_stricmp(arg->Value, "direct") == 0)
1582 type = TSC_PROXY_MODE_DIRECT;
1583 else if (_stricmp(arg->Value, "detect") == 0)
1584 type = TSC_PROXY_MODE_DETECT;
1585 else if (_stricmp(arg->Value, "default") == 0)
1586 type = TSC_PROXY_MODE_DEFAULT;
1589 freerdp_set_gateway_usage_method(settings, (UINT32) type);
1591 CommandLineSwitchCase(arg, "app")
1593 settings->RemoteApplicationProgram = _strdup(arg->Value);
1595 settings->RemoteApplicationMode = TRUE;
1596 settings->RemoteAppLanguageBarSupported = TRUE;
1597 settings->Workarea = TRUE;
1598 settings->DisableWallpaper = TRUE;
1599 settings->DisableFullWindowDrag = TRUE;
1601 CommandLineSwitchCase(arg, "load-balance-info")
1603 settings->LoadBalanceInfo = (BYTE*) _strdup(arg->Value);
1604 settings->LoadBalanceInfoLength = (UINT32) strlen((char*) settings->LoadBalanceInfo);
1606 CommandLineSwitchCase(arg, "app-name")
1608 settings->RemoteApplicationName = _strdup(arg->Value);
1610 CommandLineSwitchCase(arg, "app-icon")
1612 settings->RemoteApplicationIcon = _strdup(arg->Value);
1614 CommandLineSwitchCase(arg, "app-cmd")
1616 settings->RemoteApplicationCmdLine = _strdup(arg->Value);
1618 CommandLineSwitchCase(arg, "app-file")
1620 settings->RemoteApplicationFile = _strdup(arg->Value);
1622 CommandLineSwitchCase(arg, "app-guid")
1624 settings->RemoteApplicationGuid = _strdup(arg->Value);
1626 CommandLineSwitchCase(arg, "compression")
1628 settings->CompressionEnabled = arg->Value ? TRUE : FALSE;
1630 CommandLineSwitchCase(arg, "compression-level")
1632 settings->CompressionLevel = atoi(arg->Value);
1634 CommandLineSwitchCase(arg, "drives")
1636 settings->RedirectDrives = arg->Value ? TRUE : FALSE;
1638 CommandLineSwitchCase(arg, "home-drive")
1640 settings->RedirectHomeDrive = arg->Value ? TRUE : FALSE;
1642 CommandLineSwitchCase(arg, "clipboard")
1644 settings->RedirectClipboard = arg->Value ? TRUE : FALSE;
1646 CommandLineSwitchCase(arg, "shell")
1648 settings->AlternateShell = _strdup(arg->Value);
1650 CommandLineSwitchCase(arg, "shell-dir")
1652 settings->ShellWorkingDirectory = _strdup(arg->Value);
1654 CommandLineSwitchCase(arg, "audio-mode")
1658 mode = atoi(arg->Value);
1660 if (mode == AUDIO_MODE_REDIRECT)
1662 settings->AudioPlayback = TRUE;
1664 else if (mode == AUDIO_MODE_PLAY_ON_SERVER)
1666 settings->RemoteConsoleAudio = TRUE;
1668 else if (mode == AUDIO_MODE_NONE)
1670 settings->AudioPlayback = FALSE;
1671 settings->RemoteConsoleAudio = FALSE;
1674 CommandLineSwitchCase(arg, "network")
1679 type = strtol(arg->Value, &pEnd, 10);
1683 if (_stricmp(arg->Value, "modem") == 0)
1684 type = CONNECTION_TYPE_MODEM;
1685 else if (_stricmp(arg->Value, "broadband") == 0)
1686 type = CONNECTION_TYPE_BROADBAND_HIGH;
1687 else if (_stricmp(arg->Value, "broadband-low") == 0)
1688 type = CONNECTION_TYPE_BROADBAND_LOW;
1689 else if (_stricmp(arg->Value, "broadband-high") == 0)
1690 type = CONNECTION_TYPE_BROADBAND_HIGH;
1691 else if (_stricmp(arg->Value, "wan") == 0)
1692 type = CONNECTION_TYPE_WAN;
1693 else if (_stricmp(arg->Value, "lan") == 0)
1694 type = CONNECTION_TYPE_LAN;
1695 else if ((_stricmp(arg->Value, "autodetect") == 0) ||
1696 (_stricmp(arg->Value, "auto") == 0) ||
1697 (_stricmp(arg->Value, "detect") == 0))
1699 type = CONNECTION_TYPE_AUTODETECT;
1703 freerdp_set_connection_type(settings, type);
1705 CommandLineSwitchCase(arg, "fonts")
1707 settings->AllowFontSmoothing = arg->Value ? TRUE : FALSE;
1709 CommandLineSwitchCase(arg, "wallpaper")
1711 settings->DisableWallpaper = arg->Value ? FALSE : TRUE;
1713 CommandLineSwitchCase(arg, "window-drag")
1715 settings->DisableFullWindowDrag = arg->Value ? FALSE : TRUE;
1717 CommandLineSwitchCase(arg, "menu-anims")
1719 settings->DisableMenuAnims = arg->Value ? FALSE : TRUE;
1721 CommandLineSwitchCase(arg, "themes")
1723 settings->DisableThemes = arg->Value ? FALSE : TRUE;
1725 CommandLineSwitchCase(arg, "aero")
1727 settings->AllowDesktopComposition = arg->Value ? TRUE : FALSE;
1729 CommandLineSwitchCase(arg, "gdi")
1731 if (_stricmp(arg->Value, "sw") == 0)
1732 settings->SoftwareGdi = TRUE;
1733 else if (_stricmp(arg->Value, "hw") == 0)
1734 settings->SoftwareGdi = FALSE;
1736 CommandLineSwitchCase(arg, "gfx")
1738 settings->SupportGraphicsPipeline = TRUE;
1740 CommandLineSwitchCase(arg, "gfx-thin-client")
1742 settings->GfxThinClient = arg->Value ? TRUE : FALSE;
1743 settings->SupportGraphicsPipeline = TRUE;
1745 CommandLineSwitchCase(arg, "gfx-small-cache")
1747 settings->GfxSmallCache = arg->Value ? TRUE : FALSE;
1748 settings->SupportGraphicsPipeline = TRUE;
1750 CommandLineSwitchCase(arg, "gfx-progressive")
1752 settings->GfxProgressive = arg->Value ? TRUE : FALSE;
1753 settings->GfxThinClient = settings->GfxProgressive ? FALSE : TRUE;
1754 settings->SupportGraphicsPipeline = TRUE;
1756 CommandLineSwitchCase(arg, "gfx-h264")
1758 settings->GfxH264 = arg->Value ? TRUE : FALSE;
1759 settings->SupportGraphicsPipeline = TRUE;
1761 CommandLineSwitchCase(arg, "rfx")
1763 settings->RemoteFxCodec = TRUE;
1764 settings->FastPathOutput = TRUE;
1765 settings->ColorDepth = 32;
1766 settings->LargePointerFlag = TRUE;
1767 settings->FrameMarkerCommandEnabled = TRUE;
1769 CommandLineSwitchCase(arg, "rfx-mode")
1771 if (strcmp(arg->Value, "video") == 0)
1772 settings->RemoteFxCodecMode = 0x00;
1773 else if (strcmp(arg->Value, "image") == 0)
1774 settings->RemoteFxCodecMode = 0x02;
1776 CommandLineSwitchCase(arg, "frame-ack")
1778 settings->FrameAcknowledge = atoi(arg->Value);
1780 CommandLineSwitchCase(arg, "nsc")
1782 settings->NSCodec = TRUE;
1783 settings->FastPathOutput = TRUE;
1784 settings->ColorDepth = 32;
1785 settings->LargePointerFlag = TRUE;
1786 settings->FrameMarkerCommandEnabled = TRUE;
1788 CommandLineSwitchCase(arg, "jpeg")
1790 settings->JpegCodec = TRUE;
1791 settings->JpegQuality = 75;
1793 CommandLineSwitchCase(arg, "jpeg-quality")
1795 settings->JpegQuality = atoi(arg->Value) % 100;
1797 CommandLineSwitchCase(arg, "nego")
1799 settings->NegotiateSecurityLayer = arg->Value ? TRUE : FALSE;
1801 CommandLineSwitchCase(arg, "pcb")
1803 settings->SendPreconnectionPdu = TRUE;
1804 settings->PreconnectionBlob = _strdup(arg->Value);
1806 CommandLineSwitchCase(arg, "pcid")
1808 settings->SendPreconnectionPdu = TRUE;
1809 settings->PreconnectionId = atoi(arg->Value);
1811 CommandLineSwitchCase(arg, "sec")
1813 if (strcmp("rdp", arg->Value) == 0) /* Standard RDP */
1815 settings->RdpSecurity = TRUE;
1816 settings->TlsSecurity = FALSE;
1817 settings->NlaSecurity = FALSE;
1818 settings->ExtSecurity = FALSE;
1819 settings->UseRdpSecurityLayer = TRUE;
1821 else if (strcmp("tls", arg->Value) == 0) /* TLS */
1823 settings->RdpSecurity = FALSE;
1824 settings->TlsSecurity = TRUE;
1825 settings->NlaSecurity = FALSE;
1826 settings->ExtSecurity = FALSE;
1828 else if (strcmp("nla", arg->Value) == 0) /* NLA */
1830 settings->RdpSecurity = FALSE;
1831 settings->TlsSecurity = FALSE;
1832 settings->NlaSecurity = TRUE;
1833 settings->ExtSecurity = FALSE;
1835 else if (strcmp("ext", arg->Value) == 0) /* NLA Extended */
1837 settings->RdpSecurity = FALSE;
1838 settings->TlsSecurity = FALSE;
1839 settings->NlaSecurity = FALSE;
1840 settings->ExtSecurity = TRUE;
1844 WLog_ERR(TAG, "unknown protocol security: %s", arg->Value);
1847 CommandLineSwitchCase(arg, "encryption-methods")
1849 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1855 p = freerdp_command_line_parse_comma_separated_values(arg->Value, &count);
1857 for (i = 0; i < count; i++)
1859 if (!strcmp(p[i], "40"))
1860 settings->EncryptionMethods |= ENCRYPTION_METHOD_40BIT;
1861 else if (!strcmp(p[i], "56"))
1862 settings->EncryptionMethods |= ENCRYPTION_METHOD_56BIT;
1863 else if (!strcmp(p[i], "128"))
1864 settings->EncryptionMethods |= ENCRYPTION_METHOD_128BIT;
1865 else if (!strcmp(p[i], "FIPS"))
1866 settings->EncryptionMethods |= ENCRYPTION_METHOD_FIPS;
1868 WLog_ERR(TAG, "unknown encryption method '%s'", p[i]);
1874 CommandLineSwitchCase(arg, "sec-rdp")
1876 settings->RdpSecurity = arg->Value ? TRUE : FALSE;
1878 CommandLineSwitchCase(arg, "sec-tls")
1880 settings->TlsSecurity = arg->Value ? TRUE : FALSE;
1882 CommandLineSwitchCase(arg, "sec-nla")
1884 settings->NlaSecurity = arg->Value ? TRUE : FALSE;
1886 CommandLineSwitchCase(arg, "sec-ext")
1888 settings->ExtSecurity = arg->Value ? TRUE : FALSE;
1890 CommandLineSwitchCase(arg, "tls-ciphers")
1892 if (strcmp(arg->Value, "netmon") == 0)
1894 settings->AllowedTlsCiphers = _strdup("ALL:!ECDH");
1896 else if (strcmp(arg->Value, "ma") == 0)
1898 settings->AllowedTlsCiphers = _strdup("AES128-SHA");
1902 settings->AllowedTlsCiphers = _strdup(arg->Value);
1905 CommandLineSwitchCase(arg, "cert-name")
1907 settings->CertificateName = _strdup(arg->Value);
1909 CommandLineSwitchCase(arg, "cert-ignore")
1911 settings->IgnoreCertificate = TRUE;
1913 CommandLineSwitchCase(arg, "authentication")
1915 settings->Authentication = arg->Value ? TRUE : FALSE;
1917 CommandLineSwitchCase(arg, "encryption")
1919 settings->UseRdpSecurityLayer = arg->Value ? FALSE : TRUE;
1921 CommandLineSwitchCase(arg, "grab-keyboard")
1923 settings->GrabKeyboard = arg->Value ? TRUE : FALSE;
1925 CommandLineSwitchCase(arg, "toggle-fullscreen")
1927 settings->ToggleFullscreen = arg->Value ? TRUE : FALSE;
1929 CommandLineSwitchCase(arg, "mouse-motion")
1931 settings->MouseMotion = arg->Value ? TRUE : FALSE;
1933 CommandLineSwitchCase(arg, "parent-window")
1935 settings->ParentWindowId = strtol(arg->Value, NULL, 0);
1937 CommandLineSwitchCase(arg, "bitmap-cache")
1939 settings->BitmapCacheEnabled = arg->Value ? TRUE : FALSE;
1941 CommandLineSwitchCase(arg, "offscreen-cache")
1943 settings->OffscreenSupportLevel = arg->Value ? TRUE : FALSE;
1945 CommandLineSwitchCase(arg, "glyph-cache")
1947 settings->GlyphSupportLevel = arg->Value ? GLYPH_SUPPORT_FULL : GLYPH_SUPPORT_NONE;
1949 CommandLineSwitchCase(arg, "codec-cache")
1951 settings->BitmapCacheV3Enabled = TRUE;
1953 if (strcmp(arg->Value, "rfx") == 0)
1955 settings->RemoteFxCodec = TRUE;
1957 else if (strcmp(arg->Value, "nsc") == 0)
1959 settings->NSCodec = TRUE;
1961 else if (strcmp(arg->Value, "jpeg") == 0)
1963 settings->JpegCodec = TRUE;
1965 if (settings->JpegQuality == 0)
1966 settings->JpegQuality = 75;
1969 CommandLineSwitchCase(arg, "fast-path")
1971 settings->FastPathInput = arg->Value ? TRUE : FALSE;
1972 settings->FastPathOutput = arg->Value ? TRUE : FALSE;
1974 CommandLineSwitchCase(arg, "max-fast-path-size")
1976 settings->MultifragMaxRequestSize = atoi(arg->Value);
1978 CommandLineSwitchCase(arg, "async-input")
1980 settings->AsyncInput = arg->Value ? TRUE : FALSE;
1982 CommandLineSwitchCase(arg, "async-update")
1984 settings->AsyncUpdate = arg->Value ? TRUE : FALSE;
1986 CommandLineSwitchCase(arg, "async-channels")
1988 settings->AsyncChannels = arg->Value ? TRUE : FALSE;
1990 CommandLineSwitchCase(arg, "async-transport")
1992 settings->AsyncTransport = arg->Value ? TRUE : FALSE;
1994 CommandLineSwitchCase(arg, "wm-class")
1996 settings->WmClass = _strdup(arg->Value);
1998 CommandLineSwitchCase(arg, "play-rfx")
2000 settings->PlayRemoteFxFile = _strdup(arg->Value);
2001 settings->PlayRemoteFx = TRUE;
2003 CommandLineSwitchCase(arg, "auth-only")
2005 settings->AuthenticationOnly = arg->Value ? TRUE : FALSE;
2007 CommandLineSwitchCase(arg, "auto-reconnect")
2009 settings->AutoReconnectionEnabled = arg->Value ? TRUE : FALSE;
2011 CommandLineSwitchCase(arg, "reconnect-cookie")
2015 crypto_base64_decode((const char *) (arg->Value), (int) strlen(arg->Value),
2017 if ((base64 != NULL) && (length == sizeof(ARC_SC_PRIVATE_PACKET)))
2019 memcpy(settings->ServerAutoReconnectCookie, base64, length);
2024 WLog_ERR(TAG, "reconnect-cookie: invalid base64 '%s'", arg->Value);
2027 CommandLineSwitchCase(arg, "print-reconnect-cookie")
2029 settings->PrintReconnectCookie = arg->Value ? TRUE : FALSE;
2031 CommandLineSwitchCase(arg, "assistance")
2033 settings->RemoteAssistanceMode = TRUE;
2034 settings->RemoteAssistancePassword = _strdup(arg->Value);
2036 CommandLineSwitchDefault(arg)
2040 CommandLineSwitchEnd(arg)
2042 while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
2044 if (!settings->Domain && user)
2046 freerdp_parse_username(user, &settings->Username, &settings->Domain);
2050 settings->Username = user;
2052 if (!settings->GatewayDomain && gwUser)
2054 freerdp_parse_username(gwUser, &settings->GatewayUsername,
2055 &settings->GatewayDomain);
2059 settings->GatewayUsername = gwUser;
2061 freerdp_performance_flags_make(settings);
2063 if (settings->SupportGraphicsPipeline)
2065 settings->FastPathOutput = TRUE;
2066 settings->ColorDepth = 32;
2067 settings->LargePointerFlag = TRUE;
2068 settings->FrameMarkerCommandEnabled = TRUE;
2071 arg = CommandLineFindArgumentA(args, "port");
2073 if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
2075 settings->ServerPort = atoi(arg->Value);
2078 arg = CommandLineFindArgumentA(args, "p");
2080 if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
2082 FillMemory(arg->Value, strlen(arg->Value), '*');
2085 arg = CommandLineFindArgumentA(args, "gp");
2087 if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
2089 FillMemory(arg->Value, strlen(arg->Value), '*');
2095 int freerdp_client_load_static_channel_addin(rdpChannels* channels, rdpSettings* settings, char* name, void* data)
2099 entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC);
2103 if (freerdp_channels_client_load(channels, settings, entry, data) == 0)
2105 WLog_INFO(TAG, "loading channel %s", name);
2113 int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
2118 if ((freerdp_static_channel_collection_find(settings, "rdpsnd")) ||
2119 (freerdp_dynamic_channel_collection_find(settings, "tsmf")))
2121 settings->DeviceRedirection = TRUE; /* rdpsnd requires rdpdr to be registered */
2122 settings->AudioPlayback = TRUE; /* Both rdpsnd and tsmf require this flag to be set */
2125 if (freerdp_dynamic_channel_collection_find(settings, "audin"))
2127 settings->AudioCapture = TRUE;
2130 if (settings->NetworkAutoDetect ||
2131 settings->SupportHeartbeatPdu ||
2132 settings->SupportMultitransport)
2134 settings->DeviceRedirection = TRUE; /* these RDP8 features require rdpdr to be registered */
2137 if (settings->RedirectDrives || settings->RedirectHomeDrive || settings->RedirectSerialPorts
2138 || settings->RedirectSmartCards || settings->RedirectPrinters)
2140 settings->DeviceRedirection = TRUE; /* All of these features require rdpdr */
2143 if (settings->RedirectDrives)
2145 if (!freerdp_device_collection_find(settings, "drive"))
2149 params[0] = "drive";
2150 params[1] = "media";
2153 freerdp_client_add_device_channel(settings, 3, (char**) params);
2157 if (settings->RedirectHomeDrive)
2159 if (!freerdp_device_collection_find(settings, "drive"))
2163 params[0] = "drive";
2167 freerdp_client_add_device_channel(settings, 3, (char**) params);
2171 if (settings->DeviceRedirection)
2173 freerdp_client_load_static_channel_addin(channels, settings, "rdpdr", settings);
2175 if (!freerdp_static_channel_collection_find(settings, "rdpsnd"))
2179 params[0] = "rdpsnd";
2180 params[1] = "sys:fake";
2182 freerdp_client_add_static_channel(settings, 2, (char**) params);
2186 if (settings->RedirectSmartCards)
2188 RDPDR_SMARTCARD* smartcard;
2190 smartcard = (RDPDR_SMARTCARD*) calloc(1, sizeof(RDPDR_SMARTCARD));
2195 smartcard->Type = RDPDR_DTYP_SMARTCARD;
2196 freerdp_device_collection_add(settings, (RDPDR_DEVICE*) smartcard);
2199 if (settings->RedirectPrinters)
2201 RDPDR_PRINTER* printer;
2203 printer = (RDPDR_PRINTER*) calloc(1, sizeof(RDPDR_PRINTER));
2208 printer->Type = RDPDR_DTYP_PRINT;
2209 freerdp_device_collection_add(settings, (RDPDR_DEVICE*) printer);
2212 if (settings->RedirectClipboard)
2214 if (!freerdp_static_channel_collection_find(settings, "cliprdr"))
2218 params[0] = "cliprdr";
2220 freerdp_client_add_static_channel(settings, 1, (char**) params);
2224 if (settings->LyncRdpMode)
2226 settings->EncomspVirtualChannel = TRUE;
2227 settings->RemdeskVirtualChannel = TRUE;
2228 settings->CompressionEnabled = FALSE;
2231 if (settings->RemoteAssistanceMode)
2233 settings->EncomspVirtualChannel = TRUE;
2234 settings->RemdeskVirtualChannel = TRUE;
2237 if (settings->EncomspVirtualChannel)
2238 freerdp_client_load_static_channel_addin(channels, settings, "encomsp", settings);
2240 if (settings->RemdeskVirtualChannel)
2241 freerdp_client_load_static_channel_addin(channels, settings, "remdesk", settings);
2243 for (index = 0; index < settings->StaticChannelCount; index++)
2245 args = settings->StaticChannelArray[index];
2246 freerdp_client_load_static_channel_addin(channels, settings, args->argv[0], args);
2249 if (settings->RemoteApplicationMode)
2251 freerdp_client_load_static_channel_addin(channels, settings, "rail", settings);
2254 if (settings->MultiTouchInput)
2262 freerdp_client_add_dynamic_channel(settings, count, p);
2265 if (settings->SupportGraphicsPipeline)
2273 freerdp_client_add_dynamic_channel(settings, count, p);
2276 if (settings->SupportEchoChannel)
2284 freerdp_client_add_dynamic_channel(settings, count, p);
2287 if (settings->SupportDisplayControl)
2295 freerdp_client_add_dynamic_channel(settings, count, p);
2298 if (settings->DynamicChannelCount)
2299 settings->SupportDynamicChannels = TRUE;
2301 if (settings->SupportDynamicChannels)
2303 freerdp_client_load_static_channel_addin(channels, settings, "drdynvc", settings);