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 u = strrchr(username, '@');
806 length = (int) (p - username);
807 *user = _strdup(&p[1]);
811 *domain = (char*) calloc(length + 1UL, sizeof(char));
819 strncpy(*domain, username, length);
820 (*domain)[length] = '\0';
824 length = (int) (u - username);
825 *domain = _strdup(&u[1]);
829 *user = (char*) calloc(length + 1UL, sizeof(char));
835 strncpy(*user, username, length);
836 (*user)[length] = '\0';
840 /* Do not break up the name for '@'; both credSSP and the
841 * ClientInfo PDU expect 'user@corp.net' to be transmitted
842 * as username 'user@corp.net', domain empty.
844 *user = _strdup(username);
854 int freerdp_parse_hostname(char* hostname, char** host, int* port)
859 p = strrchr(hostname, ':');
863 length = (p - hostname);
864 *host = (char*) calloc(length + 1UL, sizeof(char));
869 CopyMemory(*host, hostname, length);
870 (*host)[length] = '\0';
875 *host = _strdup(hostname);
886 int freerdp_set_connection_type(rdpSettings* settings, int type)
888 settings->ConnectionType = type;
890 if (type == CONNECTION_TYPE_MODEM)
892 settings->DisableWallpaper = TRUE;
893 settings->AllowFontSmoothing = FALSE;
894 settings->AllowDesktopComposition = FALSE;
895 settings->DisableFullWindowDrag = TRUE;
896 settings->DisableMenuAnims = TRUE;
897 settings->DisableThemes = TRUE;
899 else if (type == CONNECTION_TYPE_BROADBAND_LOW)
901 settings->DisableWallpaper = TRUE;
902 settings->AllowFontSmoothing = FALSE;
903 settings->AllowDesktopComposition = FALSE;
904 settings->DisableFullWindowDrag = TRUE;
905 settings->DisableMenuAnims = TRUE;
906 settings->DisableThemes = FALSE;
908 else if (type == CONNECTION_TYPE_SATELLITE)
910 settings->DisableWallpaper = TRUE;
911 settings->AllowFontSmoothing = FALSE;
912 settings->AllowDesktopComposition = TRUE;
913 settings->DisableFullWindowDrag = TRUE;
914 settings->DisableMenuAnims = TRUE;
915 settings->DisableThemes = FALSE;
917 else if (type == CONNECTION_TYPE_BROADBAND_HIGH)
919 settings->DisableWallpaper = TRUE;
920 settings->AllowFontSmoothing = FALSE;
921 settings->AllowDesktopComposition = TRUE;
922 settings->DisableFullWindowDrag = TRUE;
923 settings->DisableMenuAnims = TRUE;
924 settings->DisableThemes = FALSE;
926 else if (type == CONNECTION_TYPE_WAN)
928 settings->DisableWallpaper = FALSE;
929 settings->AllowFontSmoothing = TRUE;
930 settings->AllowDesktopComposition = TRUE;
931 settings->DisableFullWindowDrag = FALSE;
932 settings->DisableMenuAnims = FALSE;
933 settings->DisableThemes = FALSE;
935 else if (type == CONNECTION_TYPE_LAN)
937 settings->DisableWallpaper = FALSE;
938 settings->AllowFontSmoothing = TRUE;
939 settings->AllowDesktopComposition = TRUE;
940 settings->DisableFullWindowDrag = FALSE;
941 settings->DisableMenuAnims = FALSE;
942 settings->DisableThemes = FALSE;
944 else if (type == CONNECTION_TYPE_AUTODETECT)
946 settings->DisableWallpaper = FALSE;
947 settings->AllowFontSmoothing = TRUE;
948 settings->AllowDesktopComposition = TRUE;
949 settings->DisableFullWindowDrag = FALSE;
950 settings->DisableMenuAnims = FALSE;
951 settings->DisableThemes = FALSE;
953 settings->NetworkAutoDetect = TRUE;
959 int freerdp_map_keyboard_layout_name_to_id(char* name)
963 RDP_KEYBOARD_LAYOUT* layouts;
965 layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD);
967 for (i = 0; layouts[i].code; i++)
969 if (_stricmp(layouts[i].name, name) == 0)
970 id = layouts[i].code;
978 layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_VARIANT);
980 for (i = 0; layouts[i].code; i++)
982 if (_stricmp(layouts[i].name, name) == 0)
983 id = layouts[i].code;
991 layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_IME);
993 for (i = 0; layouts[i].code; i++)
995 if (_stricmp(layouts[i].name, name) == 0)
996 id = layouts[i].code;
1007 int freerdp_detect_command_line_pre_filter(void* context, int index, int argc, LPCSTR* argv)
1013 length = (int) strlen(argv[index]);
1017 if (_stricmp(&(argv[index])[length - 4], ".rdp") == 0)
1025 if (_stricmp(&(argv[index])[length - 13], ".msrcIncident") == 0)
1035 int freerdp_detect_windows_style_command_line_syntax(int argc, char** argv,
1036 int* count, BOOL ignoreUnknown)
1041 COMMAND_LINE_ARGUMENT_A* arg;
1043 flags = COMMAND_LINE_SEPARATOR_COLON;
1044 flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
1048 flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
1053 CommandLineClearArgumentsA(args);
1055 status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags,
1056 NULL, freerdp_detect_command_line_pre_filter, NULL);
1065 if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
1070 while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
1072 if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
1075 return detect_status;
1078 int freerdp_detect_posix_style_command_line_syntax(int argc, char** argv,
1079 int* count, BOOL ignoreUnknown)
1084 COMMAND_LINE_ARGUMENT_A* arg;
1086 flags = COMMAND_LINE_SEPARATOR_SPACE;
1087 flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
1088 flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
1092 flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
1097 CommandLineClearArgumentsA(args);
1099 status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags,
1100 NULL, freerdp_detect_command_line_pre_filter, NULL);
1109 if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
1114 while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
1116 if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
1119 return detect_status;
1122 static BOOL freerdp_client_detect_command_line(int argc, char** argv,
1123 DWORD* flags, BOOL ignoreUnknown)
1127 int posix_cli_status;
1128 int posix_cli_count;
1129 int windows_cli_status;
1130 int windows_cli_count;
1131 BOOL compatibility = FALSE;
1133 windows_cli_status = freerdp_detect_windows_style_command_line_syntax(argc, argv, &windows_cli_count, ignoreUnknown);
1134 posix_cli_status = freerdp_detect_posix_style_command_line_syntax(argc, argv, &posix_cli_count, ignoreUnknown);
1135 old_cli_status = freerdp_detect_old_command_line_syntax(argc, argv, &old_cli_count);
1137 /* Default is POSIX syntax */
1138 *flags = COMMAND_LINE_SEPARATOR_SPACE;
1139 *flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
1140 *flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
1142 if (posix_cli_status <= COMMAND_LINE_STATUS_PRINT)
1143 return compatibility;
1145 /* Check, if this may be windows style syntax... */
1146 if ((windows_cli_count && (windows_cli_count >= posix_cli_count)) || (windows_cli_status <= COMMAND_LINE_STATUS_PRINT))
1148 windows_cli_count = 1;
1149 *flags = COMMAND_LINE_SEPARATOR_COLON;
1150 *flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
1152 else if (old_cli_status >= 0)
1154 /* Ignore legacy parsing in case there is an error in the command line. */
1156 if ((old_cli_status == 1) || ((old_cli_count > posix_cli_count) && (old_cli_status != -1)))
1158 *flags = COMMAND_LINE_SEPARATOR_SPACE;
1159 *flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
1161 compatibility = TRUE;
1165 WLog_DBG(TAG, "windows: %d/%d posix: %d/%d compat: %d/%d", windows_cli_status, windows_cli_count,
1166 posix_cli_status, posix_cli_count, old_cli_status, old_cli_count);
1168 return compatibility;
1171 int freerdp_client_settings_command_line_status_print(rdpSettings* settings, int status, int argc, char** argv)
1173 COMMAND_LINE_ARGUMENT_A* arg;
1175 if (status == COMMAND_LINE_STATUS_PRINT_VERSION)
1177 freerdp_client_print_version();
1178 return COMMAND_LINE_STATUS_PRINT_VERSION;
1180 else if (status == COMMAND_LINE_STATUS_PRINT)
1182 arg = CommandLineFindArgumentA(args, "kbd-list");
1184 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1187 RDP_KEYBOARD_LAYOUT* layouts;
1189 layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD);
1190 printf("\nKeyboard Layouts\n");
1191 for (i = 0; layouts[i].code; i++)
1192 printf("0x%08X\t%s\n", (int) layouts[i].code, layouts[i].name);
1195 layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_VARIANT);
1196 printf("\nKeyboard Layout Variants\n");
1197 for (i = 0; layouts[i].code; i++)
1198 printf("0x%08X\t%s\n", (int) layouts[i].code, layouts[i].name);
1201 layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_IME);
1202 printf("\nKeyboard Input Method Editors (IMEs)\n");
1203 for (i = 0; layouts[i].code; i++)
1204 printf("0x%08X\t%s\n", (int) layouts[i].code, layouts[i].name);
1210 arg = CommandLineFindArgumentA(args, "monitor-list");
1212 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1214 settings->ListMonitors = TRUE;
1217 return COMMAND_LINE_STATUS_PRINT;
1219 else if (status < 0)
1221 freerdp_client_print_command_line_help(argc, argv);
1222 return COMMAND_LINE_STATUS_PRINT_HELP;
1228 int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
1229 int argc, char** argv, BOOL allowUnknown)
1233 char* gwUser = NULL;
1239 COMMAND_LINE_ARGUMENT_A* arg;
1241 compatibility = freerdp_client_detect_command_line(argc, argv, &flags, allowUnknown);
1245 WLog_WARN(TAG, "Using deprecated command-line interface!");
1246 return freerdp_client_parse_old_command_line_arguments(argc, argv, settings);
1250 CommandLineClearArgumentsA(args);
1254 flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
1256 status = CommandLineParseArgumentsA(argc, (const char**) argv, args, flags, settings,
1257 freerdp_client_command_line_pre_filter, freerdp_client_command_line_post_filter);
1263 CommandLineFindArgumentA(args, "v");
1269 if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
1272 CommandLineSwitchStart(arg)
1274 CommandLineSwitchCase(arg, "v")
1276 p = strchr(arg->Value, '[');
1280 p = strchr(arg->Value, ':');
1283 length = (int) (p - arg->Value);
1284 settings->ServerPort = atoi(&p[1]);
1285 settings->ServerHostname = (char*) calloc(length + 1UL, sizeof(char));
1286 strncpy(settings->ServerHostname, arg->Value, length);
1287 settings->ServerHostname[length] = '\0';
1291 settings->ServerHostname = _strdup(arg->Value);
1296 char *p2 = strchr(arg->Value, ']');
1297 /* not a valid [] ipv6 addr found */
1302 settings->ServerHostname = (char*) calloc(length, sizeof(char));
1303 strncpy(settings->ServerHostname, p+1, length-1);
1304 if (*(p2 + 1) == ':')
1306 settings->ServerPort = atoi(&p2[2]);
1308 printf("hostname %s port %d\n", settings->ServerHostname, settings->ServerPort);
1311 CommandLineSwitchCase(arg, "spn-class")
1313 settings->AuthenticationServiceClass = _strdup(arg->Value);
1315 CommandLineSwitchCase(arg, "credentials-delegation")
1317 settings->DisableCredentialsDelegation = arg->Value ? FALSE : TRUE;
1319 CommandLineSwitchCase(arg, "vmconnect")
1321 settings->ServerPort = 2179;
1322 settings->NegotiateSecurityLayer = FALSE;
1324 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1326 settings->SendPreconnectionPdu = TRUE;
1327 settings->PreconnectionBlob = _strdup(arg->Value);
1330 CommandLineSwitchCase(arg, "w")
1332 settings->DesktopWidth = atoi(arg->Value);
1334 CommandLineSwitchCase(arg, "h")
1336 settings->DesktopHeight = atoi(arg->Value);
1338 CommandLineSwitchCase(arg, "size")
1340 str = _strdup(arg->Value);
1342 p = strchr(str, 'x');
1347 settings->DesktopWidth = atoi(str);
1348 settings->DesktopHeight = atoi(&p[1]);
1352 p = strchr(str, '%');
1355 settings->PercentScreen = atoi(str);
1361 CommandLineSwitchCase(arg, "f")
1363 settings->Fullscreen = TRUE;
1365 CommandLineSwitchCase(arg, "multimon")
1367 settings->UseMultimon = TRUE;
1369 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1371 if (_stricmp(arg->Value, "force") == 0)
1373 settings->ForceMultimon = TRUE;
1377 CommandLineSwitchCase(arg, "span")
1379 settings->SpanMonitors = TRUE;
1381 CommandLineSwitchCase(arg, "workarea")
1383 settings->Workarea = TRUE;
1385 CommandLineSwitchCase(arg, "monitors")
1387 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1393 p = freerdp_command_line_parse_comma_separated_values(arg->Value, &count);
1398 settings->NumMonitorIds = (UINT32) count;
1400 for (i = 0; i < settings->NumMonitorIds; i++)
1402 settings->MonitorIds[i] = atoi(p[i]);
1408 CommandLineSwitchCase(arg, "monitor-list")
1410 settings->ListMonitors = TRUE;
1412 CommandLineSwitchCase(arg, "t")
1414 settings->WindowTitle = _strdup(arg->Value);
1416 CommandLineSwitchCase(arg, "decorations")
1418 settings->Decorations = arg->Value ? TRUE : FALSE;
1420 CommandLineSwitchCase(arg, "smart-sizing")
1422 settings->SmartSizing = TRUE;
1426 str = _strdup(arg->Value);
1427 if ((p = strchr(str, 'x')))
1430 settings->SmartSizingWidth = atoi(str);
1431 settings->SmartSizingHeight = atoi(&p[1]);
1436 CommandLineSwitchCase(arg, "bpp")
1438 settings->ColorDepth = atoi(arg->Value);
1440 CommandLineSwitchCase(arg, "admin")
1442 settings->ConsoleSession = TRUE;
1444 CommandLineSwitchCase(arg, "restricted-admin")
1446 settings->ConsoleSession = TRUE;
1447 settings->RestrictedAdminModeRequired = TRUE;
1449 CommandLineSwitchCase(arg, "pth")
1451 settings->ConsoleSession = TRUE;
1452 settings->RestrictedAdminModeRequired = TRUE;
1453 settings->PasswordHash = _strdup(arg->Value);
1455 CommandLineSwitchCase(arg, "client-hostname")
1457 settings->ClientHostname = _strdup(arg->Value);
1459 CommandLineSwitchCase(arg, "kbd")
1461 unsigned long int id;
1464 id = strtoul(arg->Value, &pEnd, 16);
1466 if (pEnd != (arg->Value + strlen(arg->Value)))
1471 id = (unsigned long int) freerdp_map_keyboard_layout_name_to_id(arg->Value);
1475 WLog_ERR(TAG, "Could not identify keyboard layout: %s", arg->Value);
1479 settings->KeyboardLayout = (UINT32) id;
1481 CommandLineSwitchCase(arg, "kbd-type")
1483 settings->KeyboardType = atoi(arg->Value);
1485 CommandLineSwitchCase(arg, "kbd-subtype")
1487 settings->KeyboardSubType = atoi(arg->Value);
1489 CommandLineSwitchCase(arg, "kbd-fn-key")
1491 settings->KeyboardFunctionKey = atoi(arg->Value);
1493 CommandLineSwitchCase(arg, "u")
1495 user = _strdup(arg->Value);
1497 CommandLineSwitchCase(arg, "d")
1499 settings->Domain = _strdup(arg->Value);
1501 CommandLineSwitchCase(arg, "p")
1503 settings->Password = _strdup(arg->Value);
1505 CommandLineSwitchCase(arg, "g")
1507 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1509 p = strchr(arg->Value, ':');
1513 length = (int) (p - arg->Value);
1514 settings->GatewayPort = atoi(&p[1]);
1515 settings->GatewayHostname = (char*) calloc(length + 1UL, sizeof(char));
1516 strncpy(settings->GatewayHostname, arg->Value, length);
1517 settings->GatewayHostname[length] = '\0';
1521 settings->GatewayHostname = _strdup(arg->Value);
1526 settings->GatewayHostname = _strdup(settings->ServerHostname);
1529 settings->GatewayEnabled = TRUE;
1530 settings->GatewayUseSameCredentials = TRUE;
1532 freerdp_set_gateway_usage_method(settings, TSC_PROXY_MODE_DIRECT);
1534 CommandLineSwitchCase(arg, "gu")
1536 gwUser = _strdup(arg->Value);
1537 settings->GatewayUseSameCredentials = FALSE;
1539 CommandLineSwitchCase(arg, "gd")
1541 settings->GatewayDomain = _strdup(arg->Value);
1542 settings->GatewayUseSameCredentials = FALSE;
1544 CommandLineSwitchCase(arg, "gp")
1546 settings->GatewayPassword = _strdup(arg->Value);
1547 settings->GatewayUseSameCredentials = FALSE;
1549 CommandLineSwitchCase(arg, "gt")
1551 if (_stricmp(arg->Value, "rpc") == 0)
1553 settings->GatewayRpcTransport = TRUE;
1554 settings->GatewayHttpTransport = FALSE;
1556 else if (_stricmp(arg->Value, "http") == 0)
1558 settings->GatewayRpcTransport = FALSE;
1559 settings->GatewayHttpTransport = TRUE;
1561 else if (_stricmp(arg->Value, "auto") == 0)
1563 settings->GatewayRpcTransport = TRUE;
1564 settings->GatewayHttpTransport = TRUE;
1567 CommandLineSwitchCase(arg, "gateway-usage-method")
1572 type = strtol(arg->Value, &pEnd, 10);
1576 if (_stricmp(arg->Value, "none") == 0)
1577 type = TSC_PROXY_MODE_NONE_DIRECT;
1578 else if (_stricmp(arg->Value, "direct") == 0)
1579 type = TSC_PROXY_MODE_DIRECT;
1580 else if (_stricmp(arg->Value, "detect") == 0)
1581 type = TSC_PROXY_MODE_DETECT;
1582 else if (_stricmp(arg->Value, "default") == 0)
1583 type = TSC_PROXY_MODE_DEFAULT;
1586 freerdp_set_gateway_usage_method(settings, (UINT32) type);
1588 CommandLineSwitchCase(arg, "app")
1590 settings->RemoteApplicationProgram = _strdup(arg->Value);
1592 settings->RemoteApplicationMode = TRUE;
1593 settings->RemoteAppLanguageBarSupported = TRUE;
1594 settings->Workarea = TRUE;
1595 settings->DisableWallpaper = TRUE;
1596 settings->DisableFullWindowDrag = TRUE;
1598 CommandLineSwitchCase(arg, "load-balance-info")
1600 settings->LoadBalanceInfo = (BYTE*) _strdup(arg->Value);
1601 settings->LoadBalanceInfoLength = (UINT32) strlen((char*) settings->LoadBalanceInfo);
1603 CommandLineSwitchCase(arg, "app-name")
1605 settings->RemoteApplicationName = _strdup(arg->Value);
1607 CommandLineSwitchCase(arg, "app-icon")
1609 settings->RemoteApplicationIcon = _strdup(arg->Value);
1611 CommandLineSwitchCase(arg, "app-cmd")
1613 settings->RemoteApplicationCmdLine = _strdup(arg->Value);
1615 CommandLineSwitchCase(arg, "app-file")
1617 settings->RemoteApplicationFile = _strdup(arg->Value);
1619 CommandLineSwitchCase(arg, "app-guid")
1621 settings->RemoteApplicationGuid = _strdup(arg->Value);
1623 CommandLineSwitchCase(arg, "compression")
1625 settings->CompressionEnabled = arg->Value ? TRUE : FALSE;
1627 CommandLineSwitchCase(arg, "compression-level")
1629 settings->CompressionLevel = atoi(arg->Value);
1631 CommandLineSwitchCase(arg, "drives")
1633 settings->RedirectDrives = arg->Value ? TRUE : FALSE;
1635 CommandLineSwitchCase(arg, "home-drive")
1637 settings->RedirectHomeDrive = arg->Value ? TRUE : FALSE;
1639 CommandLineSwitchCase(arg, "clipboard")
1641 settings->RedirectClipboard = arg->Value ? TRUE : FALSE;
1643 CommandLineSwitchCase(arg, "shell")
1645 settings->AlternateShell = _strdup(arg->Value);
1647 CommandLineSwitchCase(arg, "shell-dir")
1649 settings->ShellWorkingDirectory = _strdup(arg->Value);
1651 CommandLineSwitchCase(arg, "audio-mode")
1655 mode = atoi(arg->Value);
1657 if (mode == AUDIO_MODE_REDIRECT)
1659 settings->AudioPlayback = TRUE;
1661 else if (mode == AUDIO_MODE_PLAY_ON_SERVER)
1663 settings->RemoteConsoleAudio = TRUE;
1665 else if (mode == AUDIO_MODE_NONE)
1667 settings->AudioPlayback = FALSE;
1668 settings->RemoteConsoleAudio = FALSE;
1671 CommandLineSwitchCase(arg, "network")
1676 type = strtol(arg->Value, &pEnd, 10);
1680 if (_stricmp(arg->Value, "modem") == 0)
1681 type = CONNECTION_TYPE_MODEM;
1682 else if (_stricmp(arg->Value, "broadband") == 0)
1683 type = CONNECTION_TYPE_BROADBAND_HIGH;
1684 else if (_stricmp(arg->Value, "broadband-low") == 0)
1685 type = CONNECTION_TYPE_BROADBAND_LOW;
1686 else if (_stricmp(arg->Value, "broadband-high") == 0)
1687 type = CONNECTION_TYPE_BROADBAND_HIGH;
1688 else if (_stricmp(arg->Value, "wan") == 0)
1689 type = CONNECTION_TYPE_WAN;
1690 else if (_stricmp(arg->Value, "lan") == 0)
1691 type = CONNECTION_TYPE_LAN;
1692 else if ((_stricmp(arg->Value, "autodetect") == 0) ||
1693 (_stricmp(arg->Value, "auto") == 0) ||
1694 (_stricmp(arg->Value, "detect") == 0))
1696 type = CONNECTION_TYPE_AUTODETECT;
1700 freerdp_set_connection_type(settings, type);
1702 CommandLineSwitchCase(arg, "fonts")
1704 settings->AllowFontSmoothing = arg->Value ? TRUE : FALSE;
1706 CommandLineSwitchCase(arg, "wallpaper")
1708 settings->DisableWallpaper = arg->Value ? FALSE : TRUE;
1710 CommandLineSwitchCase(arg, "window-drag")
1712 settings->DisableFullWindowDrag = arg->Value ? FALSE : TRUE;
1714 CommandLineSwitchCase(arg, "menu-anims")
1716 settings->DisableMenuAnims = arg->Value ? FALSE : TRUE;
1718 CommandLineSwitchCase(arg, "themes")
1720 settings->DisableThemes = arg->Value ? FALSE : TRUE;
1722 CommandLineSwitchCase(arg, "aero")
1724 settings->AllowDesktopComposition = arg->Value ? TRUE : FALSE;
1726 CommandLineSwitchCase(arg, "gdi")
1728 if (_stricmp(arg->Value, "sw") == 0)
1729 settings->SoftwareGdi = TRUE;
1730 else if (_stricmp(arg->Value, "hw") == 0)
1731 settings->SoftwareGdi = FALSE;
1733 CommandLineSwitchCase(arg, "gfx")
1735 settings->SupportGraphicsPipeline = TRUE;
1737 CommandLineSwitchCase(arg, "gfx-thin-client")
1739 settings->GfxThinClient = arg->Value ? TRUE : FALSE;
1740 settings->SupportGraphicsPipeline = TRUE;
1742 CommandLineSwitchCase(arg, "gfx-small-cache")
1744 settings->GfxSmallCache = arg->Value ? TRUE : FALSE;
1745 settings->SupportGraphicsPipeline = TRUE;
1747 CommandLineSwitchCase(arg, "gfx-progressive")
1749 settings->GfxProgressive = arg->Value ? TRUE : FALSE;
1750 settings->GfxThinClient = settings->GfxProgressive ? FALSE : TRUE;
1751 settings->SupportGraphicsPipeline = TRUE;
1753 CommandLineSwitchCase(arg, "gfx-h264")
1755 settings->GfxH264 = arg->Value ? TRUE : FALSE;
1756 settings->SupportGraphicsPipeline = TRUE;
1758 CommandLineSwitchCase(arg, "rfx")
1760 settings->RemoteFxCodec = TRUE;
1761 settings->FastPathOutput = TRUE;
1762 settings->ColorDepth = 32;
1763 settings->LargePointerFlag = TRUE;
1764 settings->FrameMarkerCommandEnabled = TRUE;
1766 CommandLineSwitchCase(arg, "rfx-mode")
1768 if (strcmp(arg->Value, "video") == 0)
1769 settings->RemoteFxCodecMode = 0x00;
1770 else if (strcmp(arg->Value, "image") == 0)
1771 settings->RemoteFxCodecMode = 0x02;
1773 CommandLineSwitchCase(arg, "frame-ack")
1775 settings->FrameAcknowledge = atoi(arg->Value);
1777 CommandLineSwitchCase(arg, "nsc")
1779 settings->NSCodec = TRUE;
1780 settings->FastPathOutput = TRUE;
1781 settings->ColorDepth = 32;
1782 settings->LargePointerFlag = TRUE;
1783 settings->FrameMarkerCommandEnabled = TRUE;
1785 CommandLineSwitchCase(arg, "jpeg")
1787 settings->JpegCodec = TRUE;
1788 settings->JpegQuality = 75;
1790 CommandLineSwitchCase(arg, "jpeg-quality")
1792 settings->JpegQuality = atoi(arg->Value) % 100;
1794 CommandLineSwitchCase(arg, "nego")
1796 settings->NegotiateSecurityLayer = arg->Value ? TRUE : FALSE;
1798 CommandLineSwitchCase(arg, "pcb")
1800 settings->SendPreconnectionPdu = TRUE;
1801 settings->PreconnectionBlob = _strdup(arg->Value);
1803 CommandLineSwitchCase(arg, "pcid")
1805 settings->SendPreconnectionPdu = TRUE;
1806 settings->PreconnectionId = atoi(arg->Value);
1808 CommandLineSwitchCase(arg, "sec")
1810 if (strcmp("rdp", arg->Value) == 0) /* Standard RDP */
1812 settings->RdpSecurity = TRUE;
1813 settings->TlsSecurity = FALSE;
1814 settings->NlaSecurity = FALSE;
1815 settings->ExtSecurity = FALSE;
1816 settings->UseRdpSecurityLayer = TRUE;
1818 else if (strcmp("tls", arg->Value) == 0) /* TLS */
1820 settings->RdpSecurity = FALSE;
1821 settings->TlsSecurity = TRUE;
1822 settings->NlaSecurity = FALSE;
1823 settings->ExtSecurity = FALSE;
1825 else if (strcmp("nla", arg->Value) == 0) /* NLA */
1827 settings->RdpSecurity = FALSE;
1828 settings->TlsSecurity = FALSE;
1829 settings->NlaSecurity = TRUE;
1830 settings->ExtSecurity = FALSE;
1832 else if (strcmp("ext", arg->Value) == 0) /* NLA Extended */
1834 settings->RdpSecurity = FALSE;
1835 settings->TlsSecurity = FALSE;
1836 settings->NlaSecurity = FALSE;
1837 settings->ExtSecurity = TRUE;
1841 WLog_ERR(TAG, "unknown protocol security: %s", arg->Value);
1844 CommandLineSwitchCase(arg, "encryption-methods")
1846 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1852 p = freerdp_command_line_parse_comma_separated_values(arg->Value, &count);
1854 for (i = 0; i < count; i++)
1856 if (!strcmp(p[i], "40"))
1857 settings->EncryptionMethods |= ENCRYPTION_METHOD_40BIT;
1858 else if (!strcmp(p[i], "56"))
1859 settings->EncryptionMethods |= ENCRYPTION_METHOD_56BIT;
1860 else if (!strcmp(p[i], "128"))
1861 settings->EncryptionMethods |= ENCRYPTION_METHOD_128BIT;
1862 else if (!strcmp(p[i], "FIPS"))
1863 settings->EncryptionMethods |= ENCRYPTION_METHOD_FIPS;
1865 WLog_ERR(TAG, "unknown encryption method '%s'", p[i]);
1871 CommandLineSwitchCase(arg, "sec-rdp")
1873 settings->RdpSecurity = arg->Value ? TRUE : FALSE;
1875 CommandLineSwitchCase(arg, "sec-tls")
1877 settings->TlsSecurity = arg->Value ? TRUE : FALSE;
1879 CommandLineSwitchCase(arg, "sec-nla")
1881 settings->NlaSecurity = arg->Value ? TRUE : FALSE;
1883 CommandLineSwitchCase(arg, "sec-ext")
1885 settings->ExtSecurity = arg->Value ? TRUE : FALSE;
1887 CommandLineSwitchCase(arg, "tls-ciphers")
1889 if (strcmp(arg->Value, "netmon") == 0)
1891 settings->AllowedTlsCiphers = _strdup("ALL:!ECDH");
1893 else if (strcmp(arg->Value, "ma") == 0)
1895 settings->AllowedTlsCiphers = _strdup("AES128-SHA");
1899 settings->AllowedTlsCiphers = _strdup(arg->Value);
1902 CommandLineSwitchCase(arg, "cert-name")
1904 settings->CertificateName = _strdup(arg->Value);
1906 CommandLineSwitchCase(arg, "cert-ignore")
1908 settings->IgnoreCertificate = TRUE;
1910 CommandLineSwitchCase(arg, "authentication")
1912 settings->Authentication = arg->Value ? TRUE : FALSE;
1914 CommandLineSwitchCase(arg, "encryption")
1916 settings->UseRdpSecurityLayer = arg->Value ? FALSE : TRUE;
1918 CommandLineSwitchCase(arg, "grab-keyboard")
1920 settings->GrabKeyboard = arg->Value ? TRUE : FALSE;
1922 CommandLineSwitchCase(arg, "toggle-fullscreen")
1924 settings->ToggleFullscreen = arg->Value ? TRUE : FALSE;
1926 CommandLineSwitchCase(arg, "mouse-motion")
1928 settings->MouseMotion = arg->Value ? TRUE : FALSE;
1930 CommandLineSwitchCase(arg, "parent-window")
1932 settings->ParentWindowId = strtol(arg->Value, NULL, 0);
1934 CommandLineSwitchCase(arg, "bitmap-cache")
1936 settings->BitmapCacheEnabled = arg->Value ? TRUE : FALSE;
1938 CommandLineSwitchCase(arg, "offscreen-cache")
1940 settings->OffscreenSupportLevel = arg->Value ? TRUE : FALSE;
1942 CommandLineSwitchCase(arg, "glyph-cache")
1944 settings->GlyphSupportLevel = arg->Value ? GLYPH_SUPPORT_FULL : GLYPH_SUPPORT_NONE;
1946 CommandLineSwitchCase(arg, "codec-cache")
1948 settings->BitmapCacheV3Enabled = TRUE;
1950 if (strcmp(arg->Value, "rfx") == 0)
1952 settings->RemoteFxCodec = TRUE;
1954 else if (strcmp(arg->Value, "nsc") == 0)
1956 settings->NSCodec = TRUE;
1958 else if (strcmp(arg->Value, "jpeg") == 0)
1960 settings->JpegCodec = TRUE;
1962 if (settings->JpegQuality == 0)
1963 settings->JpegQuality = 75;
1966 CommandLineSwitchCase(arg, "fast-path")
1968 settings->FastPathInput = arg->Value ? TRUE : FALSE;
1969 settings->FastPathOutput = arg->Value ? TRUE : FALSE;
1971 CommandLineSwitchCase(arg, "max-fast-path-size")
1973 settings->MultifragMaxRequestSize = atoi(arg->Value);
1975 CommandLineSwitchCase(arg, "async-input")
1977 settings->AsyncInput = arg->Value ? TRUE : FALSE;
1979 CommandLineSwitchCase(arg, "async-update")
1981 settings->AsyncUpdate = arg->Value ? TRUE : FALSE;
1983 CommandLineSwitchCase(arg, "async-channels")
1985 settings->AsyncChannels = arg->Value ? TRUE : FALSE;
1987 CommandLineSwitchCase(arg, "async-transport")
1989 settings->AsyncTransport = arg->Value ? TRUE : FALSE;
1991 CommandLineSwitchCase(arg, "wm-class")
1993 settings->WmClass = _strdup(arg->Value);
1995 CommandLineSwitchCase(arg, "play-rfx")
1997 settings->PlayRemoteFxFile = _strdup(arg->Value);
1998 settings->PlayRemoteFx = TRUE;
2000 CommandLineSwitchCase(arg, "auth-only")
2002 settings->AuthenticationOnly = arg->Value ? TRUE : FALSE;
2004 CommandLineSwitchCase(arg, "auto-reconnect")
2006 settings->AutoReconnectionEnabled = arg->Value ? TRUE : FALSE;
2008 CommandLineSwitchCase(arg, "reconnect-cookie")
2012 crypto_base64_decode((const char *) (arg->Value), (int) strlen(arg->Value),
2014 if ((base64 != NULL) && (length == sizeof(ARC_SC_PRIVATE_PACKET)))
2016 memcpy(settings->ServerAutoReconnectCookie, base64, length);
2021 WLog_ERR(TAG, "reconnect-cookie: invalid base64 '%s'", arg->Value);
2024 CommandLineSwitchCase(arg, "print-reconnect-cookie")
2026 settings->PrintReconnectCookie = arg->Value ? TRUE : FALSE;
2028 CommandLineSwitchCase(arg, "assistance")
2030 settings->RemoteAssistanceMode = TRUE;
2031 settings->RemoteAssistancePassword = _strdup(arg->Value);
2033 CommandLineSwitchDefault(arg)
2037 CommandLineSwitchEnd(arg)
2039 while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
2041 if (!settings->Domain && user)
2043 freerdp_parse_username(user, &settings->Username, &settings->Domain);
2047 if (!settings->GatewayDomain && gwUser)
2049 freerdp_parse_username(gwUser, &settings->GatewayUsername,
2050 &settings->GatewayDomain);
2054 freerdp_performance_flags_make(settings);
2056 if (settings->SupportGraphicsPipeline)
2058 settings->FastPathOutput = TRUE;
2059 settings->ColorDepth = 32;
2060 settings->LargePointerFlag = TRUE;
2061 settings->FrameMarkerCommandEnabled = TRUE;
2064 arg = CommandLineFindArgumentA(args, "port");
2066 if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
2068 settings->ServerPort = atoi(arg->Value);
2071 arg = CommandLineFindArgumentA(args, "p");
2073 if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
2075 FillMemory(arg->Value, strlen(arg->Value), '*');
2078 arg = CommandLineFindArgumentA(args, "gp");
2080 if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
2082 FillMemory(arg->Value, strlen(arg->Value), '*');
2088 int freerdp_client_load_static_channel_addin(rdpChannels* channels, rdpSettings* settings, char* name, void* data)
2092 entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC);
2096 if (freerdp_channels_client_load(channels, settings, entry, data) == 0)
2098 WLog_INFO(TAG, "loading channel %s", name);
2106 int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
2111 if ((freerdp_static_channel_collection_find(settings, "rdpsnd")) ||
2112 (freerdp_dynamic_channel_collection_find(settings, "tsmf")))
2114 settings->DeviceRedirection = TRUE; /* rdpsnd requires rdpdr to be registered */
2115 settings->AudioPlayback = TRUE; /* Both rdpsnd and tsmf require this flag to be set */
2118 if (freerdp_dynamic_channel_collection_find(settings, "audin"))
2120 settings->AudioCapture = TRUE;
2123 if (settings->NetworkAutoDetect ||
2124 settings->SupportHeartbeatPdu ||
2125 settings->SupportMultitransport)
2127 settings->DeviceRedirection = TRUE; /* these RDP8 features require rdpdr to be registered */
2130 if (settings->RedirectDrives || settings->RedirectHomeDrive || settings->RedirectSerialPorts
2131 || settings->RedirectSmartCards || settings->RedirectPrinters)
2133 settings->DeviceRedirection = TRUE; /* All of these features require rdpdr */
2136 if (settings->RedirectDrives)
2138 if (!freerdp_device_collection_find(settings, "drive"))
2142 params[0] = "drive";
2143 params[1] = "media";
2146 freerdp_client_add_device_channel(settings, 3, (char**) params);
2150 if (settings->RedirectHomeDrive)
2152 if (!freerdp_device_collection_find(settings, "drive"))
2156 params[0] = "drive";
2160 freerdp_client_add_device_channel(settings, 3, (char**) params);
2164 if (settings->DeviceRedirection)
2166 freerdp_client_load_static_channel_addin(channels, settings, "rdpdr", settings);
2168 if (!freerdp_static_channel_collection_find(settings, "rdpsnd"))
2172 params[0] = "rdpsnd";
2173 params[1] = "sys:fake";
2175 freerdp_client_add_static_channel(settings, 2, (char**) params);
2179 if (settings->RedirectSmartCards)
2181 RDPDR_SMARTCARD* smartcard;
2183 smartcard = (RDPDR_SMARTCARD*) calloc(1, sizeof(RDPDR_SMARTCARD));
2188 smartcard->Type = RDPDR_DTYP_SMARTCARD;
2189 freerdp_device_collection_add(settings, (RDPDR_DEVICE*) smartcard);
2192 if (settings->RedirectPrinters)
2194 RDPDR_PRINTER* printer;
2196 printer = (RDPDR_PRINTER*) calloc(1, sizeof(RDPDR_PRINTER));
2201 printer->Type = RDPDR_DTYP_PRINT;
2202 freerdp_device_collection_add(settings, (RDPDR_DEVICE*) printer);
2205 if (settings->RedirectClipboard)
2207 if (!freerdp_static_channel_collection_find(settings, "cliprdr"))
2211 params[0] = "cliprdr";
2213 freerdp_client_add_static_channel(settings, 1, (char**) params);
2217 if (settings->LyncRdpMode)
2219 settings->EncomspVirtualChannel = TRUE;
2220 settings->RemdeskVirtualChannel = TRUE;
2221 settings->CompressionEnabled = FALSE;
2224 if (settings->RemoteAssistanceMode)
2226 settings->EncomspVirtualChannel = TRUE;
2227 settings->RemdeskVirtualChannel = TRUE;
2230 if (settings->EncomspVirtualChannel)
2231 freerdp_client_load_static_channel_addin(channels, settings, "encomsp", settings);
2233 if (settings->RemdeskVirtualChannel)
2234 freerdp_client_load_static_channel_addin(channels, settings, "remdesk", settings);
2236 for (index = 0; index < settings->StaticChannelCount; index++)
2238 args = settings->StaticChannelArray[index];
2239 freerdp_client_load_static_channel_addin(channels, settings, args->argv[0], args);
2242 if (settings->RemoteApplicationMode)
2244 freerdp_client_load_static_channel_addin(channels, settings, "rail", settings);
2247 if (settings->MultiTouchInput)
2255 freerdp_client_add_dynamic_channel(settings, count, p);
2258 if (settings->SupportGraphicsPipeline)
2266 freerdp_client_add_dynamic_channel(settings, count, p);
2269 if (settings->SupportEchoChannel)
2277 freerdp_client_add_dynamic_channel(settings, count, p);
2280 if (settings->SupportDisplayControl)
2288 freerdp_client_add_dynamic_channel(settings, count, p);
2291 if (settings->DynamicChannelCount)
2292 settings->SupportDynamicChannels = TRUE;
2294 if (settings->SupportDynamicChannels)
2296 freerdp_client_load_static_channel_addin(channels, settings, "drdynvc", settings);