22 #include <freerdp/config.h>
27 #include <winpr/assert.h>
28 #include <winpr/string.h>
29 #include <winpr/crt.h>
30 #include <winpr/wlog.h>
31 #include <winpr/path.h>
32 #include <winpr/ncrypt.h>
33 #include <winpr/environment.h>
34 #include <winpr/timezone.h>
36 #include <freerdp/freerdp.h>
37 #include <freerdp/addin.h>
38 #include <freerdp/settings.h>
39 #include <freerdp/client.h>
40 #include <freerdp/client/channels.h>
41 #include <freerdp/channels/drdynvc.h>
42 #include <freerdp/channels/cliprdr.h>
43 #include <freerdp/channels/encomsp.h>
44 #include <freerdp/channels/rdpear.h>
45 #include <freerdp/channels/rdp2tcp.h>
46 #include <freerdp/channels/remdesk.h>
47 #include <freerdp/channels/rdpsnd.h>
48 #include <freerdp/channels/disp.h>
49 #include <freerdp/crypto/crypto.h>
50 #include <freerdp/locale/keyboard.h>
51 #include <freerdp/utils/passphrase.h>
52 #include <freerdp/utils/proxy_utils.h>
53 #include <freerdp/utils/string.h>
54 #include <freerdp/channels/urbdrc.h>
55 #include <freerdp/channels/rdpdr.h>
56 #include <freerdp/locale/locale.h>
58 #if defined(CHANNEL_AINPUT_CLIENT)
59 #include <freerdp/channels/ainput.h>
62 #include <freerdp/channels/audin.h>
63 #include <freerdp/channels/echo.h>
65 #include <freerdp/client/cmdline.h>
66 #include <freerdp/version.h>
67 #include <freerdp/client/utils/smartcard_cli.h>
69 #include <openssl/tls1.h>
72 #include <freerdp/log.h>
73 #define TAG CLIENT_TAG("common.cmdline")
75 static const char str_force[] =
"force";
77 static const char* option_starts_with(
const char* what,
const char* val);
78 static BOOL option_ends_with(
const char* str,
const char* ext);
79 static BOOL option_equals(
const char* what,
const char* val);
81 static BOOL freerdp_client_print_codepages(
const char* arg)
85 const char* filter = NULL;
90 filter = strchr(arg,
',');
96 pages = freerdp_keyboard_get_matching_codepages(column, filter, &count);
100 printf(
"%-10s %-8s %-60s %-36s %-48s\n",
"<id>",
"<locale>",
"<win langid>",
"<language>",
102 for (
size_t x = 0; x < count; x++)
105 char buffer[2048] = { 0 };
107 if (strnlen(page->subLanguageSymbol, ARRAYSIZE(page->subLanguageSymbol)) > 0)
108 (void)_snprintf(buffer,
sizeof(buffer),
"[%s|%s]", page->primaryLanguageSymbol,
109 page->subLanguageSymbol);
111 (
void)_snprintf(buffer,
sizeof(buffer),
"[%s]", page->primaryLanguageSymbol);
112 printf(
"id=0x%04" PRIx16
": [%-6s] %-60s %-36s %-48s\n", page->id, page->locale, buffer,
113 page->primaryLanguage, page->subLanguage);
115 freerdp_codepages_free(pages);
119 static BOOL freerdp_path_valid(
const char* path, BOOL* special)
121 const char DynamicDrives[] =
"DynamicDrives";
128 (option_equals(
"*", path) || option_equals(DynamicDrives, path) || option_equals(
"%", path))
132 isPath = winpr_PathFileExists(path);
135 *special = isSpecial;
137 return isSpecial || isPath;
140 static BOOL freerdp_sanitize_drive_name(
char* name,
const char* invalid,
const char* replacement)
142 if (!name || !invalid || !replacement)
144 if (strlen(invalid) != strlen(replacement))
147 while (*invalid !=
'\0')
149 const char what = *invalid++;
150 const char with = *replacement++;
153 while ((cur = strchr(cur, what)) != NULL)
159 static char* name_from_path(
const char* path)
161 const char* name =
"NULL";
164 if (option_equals(
"%", path))
166 else if (option_equals(
"*", path))
167 name =
"hotplug-all";
168 else if (option_equals(
"DynamicDrives", path))
173 return _strdup(name);
176 static BOOL freerdp_client_add_drive(rdpSettings* settings,
const char* path,
const char* name)
197 if (!skip && winpr_PathFileExists(name))
199 if (!winpr_PathFileExists(path) || (!PathIsRelativeA(name) && PathIsRelativeA(path)))
201 const char* tmp = path;
209 dname = _strdup(name);
211 dname = name_from_path(path);
213 if (freerdp_sanitize_drive_name(dname,
"\\/",
"__"))
215 const char* args[] = { dname, path };
216 device = freerdp_device_new(RDPDR_DTYP_FILESYSTEM, ARRAYSIZE(args), args);
226 BOOL isSpecial = FALSE;
227 BOOL isPath = freerdp_path_valid(path, &isSpecial);
229 if (!isPath && !isSpecial)
231 WLog_WARN(TAG,
"Invalid drive to redirect: '%s' does not exist, skipping.", path);
232 freerdp_device_free(device);
234 else if (!freerdp_device_collection_add(settings, device))
241 freerdp_device_free(device);
245 static BOOL value_to_int(
const char* value, LONGLONG* result, LONGLONG min, LONGLONG max)
249 if (!value || !result)
253 rc = _strtoi64(value, NULL, 0);
258 if ((rc < min) || (rc > max))
265 static BOOL value_to_uint(
const char* value, ULONGLONG* result, ULONGLONG min, ULONGLONG max)
267 unsigned long long rc = 0;
269 if (!value || !result)
273 rc = _strtoui64(value, NULL, 0);
278 if ((rc < min) || (rc > max))
285 BOOL freerdp_client_print_version(
void)
287 printf(
"This is FreeRDP version %s (%s)\n", FREERDP_VERSION_FULL, FREERDP_GIT_REVISION);
291 BOOL freerdp_client_print_version_ex(
int argc,
char** argv)
293 WINPR_ASSERT(argc >= 0);
294 WINPR_ASSERT(argv || (argc == 0));
295 const char* name = (argc > 0) ? argv[0] :
"argc < 1";
296 printf(
"This is FreeRDP version [%s] %s (%s)\n", name, FREERDP_VERSION_FULL,
297 FREERDP_GIT_REVISION);
301 BOOL freerdp_client_print_buildconfig(
void)
303 printf(
"%s", freerdp_get_build_config());
307 BOOL freerdp_client_print_buildconfig_ex(
int argc,
char** argv)
309 WINPR_ASSERT(argc >= 0);
310 WINPR_ASSERT(argv || (argc == 0));
311 const char* name = (argc > 0) ? argv[0] :
"argc < 1";
312 printf(
"[%s] %s", name, freerdp_get_build_config());
316 static void freerdp_client_print_scancodes(
void)
318 printf(
"RDP scancodes and their name for use with /kbd:remap\n");
320 for (UINT32 x = 0; x < UINT16_MAX; x++)
322 const char* name = freerdp_keyboard_scancode_name(x);
324 printf(
"0x%04" PRIx32
" --> %s\n", x, name);
328 static BOOL is_delimiter(
char c,
const char* delimiters)
331 while ((d = *delimiters++) !=
'\0')
339 static const char* get_last(
const char* start,
size_t len,
const char* delimiters)
341 const char* last = NULL;
342 for (
size_t x = 0; x < len; x++)
345 if (is_delimiter(c, delimiters))
351 static SSIZE_T next_delimiter(
const char* text,
size_t len,
size_t max,
const char* delimiters)
356 const char* last = get_last(text, max, delimiters);
360 return (SSIZE_T)(last - text);
363 static SSIZE_T forced_newline_at(
const char* text,
size_t len,
size_t limit,
364 const char* force_newline)
367 while ((d = *force_newline++) !=
'\0')
369 const char* tok = strchr(text, d);
372 const size_t offset = WINPR_ASSERTING_INT_CAST(
size_t, tok - text);
373 if ((offset > len) || (offset > limit))
375 return (SSIZE_T)(offset);
381 static BOOL print_align(
size_t start_offset,
size_t* current)
383 WINPR_ASSERT(current);
384 if (*current < start_offset)
386 const int rc = printf(
"%*c", (
int)(start_offset - *current),
' ');
389 *current += (size_t)rc;
394 static char* print_token(
char* text,
size_t start_offset,
size_t* current,
size_t limit,
395 const char* delimiters,
const char* force_newline)
398 const size_t tlen = strnlen(text, limit);
400 const SSIZE_T force_at = forced_newline_at(text, len, limit - *current, force_newline);
401 BOOL isForce = (force_at >= 0);
404 len = MIN(len, (
size_t)force_at);
406 if (!print_align(start_offset, current))
409 const SSIZE_T delim = next_delimiter(text, len, limit - *current, delimiters);
410 const BOOL isDelim = delim > 0;
413 len = MIN(len, (
size_t)delim + 1);
416 rc = printf(
"%.*s", (
int)len, text);
420 if (isForce || isDelim)
425 const size_t offset = len + ((isForce && (force_at == 0)) ? 1 : 0);
426 return &text[offset];
429 *current += (size_t)rc;
431 if (tlen == (
size_t)rc)
433 return &text[(size_t)rc];
436 static size_t print_optionals(
const char* text,
size_t start_offset,
size_t current)
438 const size_t limit = 80;
439 char* str = _strdup(text);
444 cur = print_token(cur, start_offset + 1, ¤t, limit,
"[], ",
"\r\n");
445 }
while (cur != NULL);
451 static size_t print_description(
const char* text,
size_t start_offset,
size_t current)
453 const size_t limit = 80;
454 char* str = _strdup(text);
458 cur = print_token(cur, start_offset, ¤t, limit,
" ",
"\r\n");
461 const int rc = printf(
"\n");
464 const size_t src = WINPR_ASSERTING_INT_CAST(
size_t, rc);
465 WINPR_ASSERT(SIZE_MAX - src > current);
471 static int cmp_cmdline_args(
const void* pva,
const void* pvb)
476 if (!a->Name && !b->Name)
482 return strcmp(a->Name, b->Name);
497 const size_t description_offset = 30 + 8;
499 if (arg->Flags & (COMMAND_LINE_VALUE_BOOL | COMMAND_LINE_VALUE_FLAG))
501 if ((arg->Flags & (uint32_t)~COMMAND_LINE_VALUE_BOOL) == 0)
502 rc = printf(
" %s%s", arg->Default ?
"-" :
"+", arg->Name);
503 else if ((arg->Flags & COMMAND_LINE_VALUE_OPTIONAL) != 0)
504 rc = printf(
" [%s|/]%s", arg->Default ?
"-" :
"+", arg->Name);
507 rc = printf(
" %s%s", arg->Default ?
"-" :
"+", arg->Name);
511 rc = printf(
" /%s", arg->Name);
517 if ((arg->Flags & COMMAND_LINE_VALUE_REQUIRED) ||
518 (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL))
522 if (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL)
528 pos = print_optionals(arg->Format, pos, pos);
540 pos = print_optionals(arg->Format, pos, pos);
543 if (pos > description_offset)
551 rc = printf(
"%*c", (
int)(description_offset - pos),
' ');
556 if (arg->Flags & COMMAND_LINE_VALUE_BOOL)
558 rc = printf(
"%s ", arg->Default ?
"Disable" :
"Enable");
564 print_description(arg->Text, description_offset, pos);
565 }
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
568 BOOL freerdp_client_print_command_line_help(
int argc,
char** argv)
570 return freerdp_client_print_command_line_help_ex(argc, argv, NULL);
574 SSIZE_T count,
size_t* pcount)
576 WINPR_ASSERT(pcount);
581 while (cur && cur->Name)
596 while (cur && cur->Name)
598 largs[lcount++] = *cur++;
601 cur = global_cmd_args;
602 while (cur && cur->Name)
604 largs[lcount++] = *cur++;
610 BOOL freerdp_client_print_command_line_help_ex(
int argc,
char** argv,
613 const char* name =
"FreeRDP";
625 printf(
"FreeRDP - A Free Remote Desktop Protocol Implementation\n");
626 printf(
"See www.freerdp.com for more information\n");
628 printf(
"Usage: %s [file] [options] [/v:<server>[:port]]\n", argv[0]);
631 printf(
" /flag (enables flag)\n");
632 printf(
" /option:<value> (specifies option with value)\n");
633 printf(
" +toggle -toggle (enables or disables toggle, where '/' is a synonym of '+')\n");
636 freerdp_client_print_command_line_args(largs, lcount);
640 printf(
"Examples:\n");
641 printf(
" %s connection.rdp /p:Pwd123! /f\n", name);
642 printf(
" %s /u:CONTOSO\\JohnDoe /p:Pwd123! /v:rdp.contoso.com\n", name);
643 printf(
" %s /u:JohnDoe /p:Pwd123! /w:1366 /h:768 /v:192.168.1.100:4489\n", name);
644 printf(
" %s /u:JohnDoe /p:Pwd123! /vmconnect:C824F53E-95D2-46C6-9A18-23A5BB403532 "
645 "/v:192.168.1.100\n",
647 printf(
" %s /u:\\AzureAD\\user@corp.example /p:pwd /v:host\n", name);
649 printf(
"Clipboard Redirection: +clipboard\n");
651 printf(
"Drive Redirection: /drive:home,/home/user\n");
652 printf(
"Smartcard Redirection: /smartcard:<device>\n");
653 printf(
"Smartcard logon with Kerberos authentication: /smartcard-logon /sec:nla\n");
655 #if defined(CHANNEL_SERIAL_CLIENT)
656 printf(
"Serial Port Redirection: /serial:<name>,<device>,[SerCx2|SerCx|Serial],[permissive]\n");
657 printf(
"Serial Port Redirection: /serial:COM1,/dev/ttyS0\n");
659 #if defined(CHANNEL_PARALLEL_CLIENT)
660 printf(
"Parallel Port Redirection: /parallel:<name>,<device>\n");
662 printf(
"Printer Redirection: /printer:<device>,<driver>,[default]\n");
663 printf(
"TCP redirection: /rdp2tcp:/usr/bin/rdp2tcp\n");
665 printf(
"Audio Output Redirection: /sound:sys:oss,dev:1,format:1\n");
666 printf(
"Audio Output Redirection: /sound:sys:alsa\n");
667 printf(
"Audio Input Redirection: /microphone:sys:oss,dev:1,format:1\n");
668 printf(
"Audio Input Redirection: /microphone:sys:alsa\n");
670 printf(
"Multimedia Redirection: /video\n");
671 #ifdef CHANNEL_URBDRC_CLIENT
672 printf(
"USB Device Redirection: /usb:id:054c:0268#4669:6e6b,addr:04:0c\n");
675 printf(
"For Gateways, the https_proxy environment variable is respected:\n");
677 printf(
" set HTTPS_PROXY=http://proxy.contoso.com:3128/\n");
679 printf(
" export https_proxy=http://proxy.contoso.com:3128/\n");
681 printf(
" %s /g:rdp.contoso.com ...\n", name);
683 printf(
"More documentation is coming, in the meantime consult source files\n");
688 static BOOL option_is_rdp_file(
const char* option)
690 WINPR_ASSERT(option);
692 if (option_ends_with(option,
".rdp"))
694 if (option_ends_with(option,
".rdpw"))
699 static BOOL option_is_incident_file(
const char* option)
701 WINPR_ASSERT(option);
703 if (option_ends_with(option,
".msrcIncident"))
708 static int freerdp_client_command_line_pre_filter(
void* context,
int index,
int argc, LPSTR* argv)
713 rdpSettings* settings = NULL;
718 length = strlen(argv[index]);
722 if (option_is_rdp_file(argv[index]))
724 settings = (rdpSettings*)context;
727 return COMMAND_LINE_ERROR_MEMORY;
735 if (option_is_incident_file(argv[index]))
737 settings = (rdpSettings*)context;
740 return COMMAND_LINE_ERROR_MEMORY;
750 BOOL freerdp_client_add_device_channel(rdpSettings* settings,
size_t count,
751 const char*
const* params)
753 WINPR_ASSERT(settings);
754 WINPR_ASSERT(params);
755 WINPR_ASSERT(count > 0);
757 if (option_equals(params[0],
"drive"))
766 rc = freerdp_client_add_drive(settings, params[1], NULL);
768 rc = freerdp_client_add_drive(settings, params[2], params[1]);
772 else if (option_equals(params[0],
"printer"))
784 printer = freerdp_device_new(RDPDR_DTYP_PRINT, count - 1, ¶ms[1]);
788 if (!freerdp_device_collection_add(settings, printer))
790 freerdp_device_free(printer);
796 else if (option_equals(params[0],
"smartcard"))
808 smartcard = freerdp_device_new(RDPDR_DTYP_SMARTCARD, count - 1, ¶ms[1]);
813 if (!freerdp_device_collection_add(settings, smartcard))
815 freerdp_device_free(smartcard);
821 #if defined(CHANNEL_SERIAL_CLIENT)
822 else if (option_equals(params[0],
"serial"))
834 serial = freerdp_device_new(RDPDR_DTYP_SERIAL, count - 1, ¶ms[1]);
839 if (!freerdp_device_collection_add(settings, serial))
841 freerdp_device_free(serial);
848 else if (option_equals(params[0],
"parallel"))
860 parallel = freerdp_device_new(RDPDR_DTYP_PARALLEL, count - 1, ¶ms[1]);
865 if (!freerdp_device_collection_add(settings, parallel))
867 freerdp_device_free(parallel);
877 BOOL freerdp_client_del_static_channel(rdpSettings* settings,
const char* name)
879 return freerdp_static_channel_collection_del(settings, name);
882 BOOL freerdp_client_add_static_channel(rdpSettings* settings,
size_t count,
883 const char*
const* params)
887 if (!settings || !params || !params[0] || (count > INT_MAX))
890 if (freerdp_static_channel_collection_find(settings, params[0]))
893 _args = freerdp_addin_argv_new(count, params);
898 if (!freerdp_static_channel_collection_add(settings, _args))
903 freerdp_addin_argv_free(_args);
907 BOOL freerdp_client_del_dynamic_channel(rdpSettings* settings,
const char* name)
909 return freerdp_dynamic_channel_collection_del(settings, name);
912 BOOL freerdp_client_add_dynamic_channel(rdpSettings* settings,
size_t count,
913 const char*
const* params)
917 if (!settings || !params || !params[0] || (count > INT_MAX))
920 if (freerdp_dynamic_channel_collection_find(settings, params[0]))
923 _args = freerdp_addin_argv_new(count, params);
928 if (!freerdp_dynamic_channel_collection_add(settings, _args))
934 freerdp_addin_argv_free(_args);
938 static BOOL read_pem_file(rdpSettings* settings, FreeRDP_Settings_Keys_String
id,
const char* file)
941 char* pem = crypto_read_pem(file, &length);
942 if (!pem || (length == 0))
956 CMDLINE_SUBOPTION_STRING,
957 CMDLINE_SUBOPTION_FILE,
958 } CmdLineSubOptionType;
960 typedef BOOL (*CmdLineSubOptionCb)(
const char* value, rdpSettings* settings);
964 FreeRDP_Settings_Keys_String id;
965 CmdLineSubOptionType opttype;
966 CmdLineSubOptionCb cb;
969 static BOOL parseSubOptions(rdpSettings* settings,
const CmdLineSubOptions* opts,
size_t count,
974 for (
size_t xx = 0; xx < count; xx++)
976 const CmdLineSubOptions* opt = &opts[xx];
978 if (option_starts_with(opt->optname, arg))
980 const size_t optlen = strlen(opt->optname);
981 const char* val = &arg[optlen];
984 switch (opt->opttype)
986 case CMDLINE_SUBOPTION_STRING:
989 case CMDLINE_SUBOPTION_FILE:
990 status = read_pem_file(settings, opt->id, val);
993 WLog_ERR(TAG,
"invalid subOption type");
1000 if (opt->cb && !opt->cb(val, settings))
1009 WLog_ERR(TAG,
"option %s not handled", arg);
1014 #define fail_at(arg, rc) fail_at_((arg), (rc), __FILE__, __func__, __LINE__)
1018 const DWORD level = WLOG_ERROR;
1019 wLog* log = WLog_Get(TAG);
1020 if (WLog_IsLevelActive(log, level))
1021 WLog_PrintMessage(log, WLOG_MESSAGE_TEXT, level, line, file, fkt,
1022 "Command line parsing failed at '%s' value '%s' [%d]", arg->Name,
1029 rdpSettings* settings = (rdpSettings*)context;
1030 int status = CHANNEL_RC_OK;
1031 BOOL enable = arg->Value ? TRUE : FALSE;
1033 CommandLineSwitchStart(arg) CommandLineSwitchCase(arg,
"a")
1036 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
1038 if (!freerdp_client_add_device_channel(settings, count, (
const char*
const*)ptr))
1039 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1041 status = COMMAND_LINE_ERROR;
1043 CommandLineParserFree(ptr);
1045 return fail_at(arg, status);
1047 CommandLineSwitchCase(arg,
"kerberos")
1051 char** ptr = CommandLineParseCommaSeparatedValuesEx(
"kerberos", arg->Value, &count);
1054 const CmdLineSubOptions opts[] = {
1055 {
"kdc-url:", FreeRDP_KerberosKdcUrl, CMDLINE_SUBOPTION_STRING, NULL },
1056 {
"start-time:", FreeRDP_KerberosStartTime, CMDLINE_SUBOPTION_STRING, NULL },
1057 {
"lifetime:", FreeRDP_KerberosLifeTime, CMDLINE_SUBOPTION_STRING, NULL },
1058 {
"renewable-lifetime:", FreeRDP_KerberosRenewableLifeTime,
1059 CMDLINE_SUBOPTION_STRING, NULL },
1060 {
"cache:", FreeRDP_KerberosCache, CMDLINE_SUBOPTION_STRING, NULL },
1061 {
"armor:", FreeRDP_KerberosArmor, CMDLINE_SUBOPTION_STRING, NULL },
1062 {
"pkinit-anchors:", FreeRDP_PkinitAnchors, CMDLINE_SUBOPTION_STRING, NULL },
1063 {
"pkcs11-module:", FreeRDP_Pkcs11Module, CMDLINE_SUBOPTION_STRING, NULL }
1066 for (
size_t x = 1; x < count; x++)
1068 const char* cur = ptr[x];
1069 if (!parseSubOptions(settings, opts, ARRAYSIZE(opts), cur))
1071 CommandLineParserFree(ptr);
1072 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
1076 CommandLineParserFree(ptr);
1079 CommandLineSwitchCase(arg,
"vc")
1082 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
1083 if (!freerdp_client_add_static_channel(settings, count, (
const char*
const*)ptr))
1084 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1085 CommandLineParserFree(ptr);
1087 return fail_at(arg, status);
1089 CommandLineSwitchCase(arg,
"dvc")
1092 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
1093 if (!freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr))
1094 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1095 CommandLineParserFree(ptr);
1097 return fail_at(arg, status);
1099 CommandLineSwitchCase(arg,
"drive")
1102 char** ptr = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
1103 if (!freerdp_client_add_device_channel(settings, count, (
const char*
const*)ptr))
1104 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1105 CommandLineParserFree(ptr);
1107 return fail_at(arg, status);
1109 #if defined(CHANNEL_SERIAL_CLIENT)
1110 CommandLineSwitchCase(arg,
"serial")
1113 char** ptr = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
1114 if (!freerdp_client_add_device_channel(settings, count, (
const char*
const*)ptr))
1115 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1116 CommandLineParserFree(ptr);
1118 return fail_at(arg, status);
1121 #if defined(CHANNEL_PARALLEL_CLIENT)
1122 CommandLineSwitchCase(arg,
"parallel")
1125 char** ptr = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
1126 if (!freerdp_client_add_device_channel(settings, count, (
const char*
const*)ptr))
1127 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1128 CommandLineParserFree(ptr);
1130 return fail_at(arg, status);
1133 CommandLineSwitchCase(arg,
"smartcard")
1136 char** ptr = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
1137 if (!freerdp_client_add_device_channel(settings, count, (
const char*
const*)ptr))
1138 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1139 CommandLineParserFree(ptr);
1141 return fail_at(arg, status);
1143 CommandLineSwitchCase(arg,
"printer")
1146 char** ptr = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
1147 if (!freerdp_client_add_device_channel(settings, count, (
const char*
const*)ptr))
1148 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1149 CommandLineParserFree(ptr);
1151 return fail_at(arg, status);
1153 CommandLineSwitchCase(arg,
"usb")
1157 CommandLineParseCommaSeparatedValuesEx(URBDRC_CHANNEL_NAME, arg->Value, &count);
1158 if (!freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr))
1159 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1160 CommandLineParserFree(ptr);
1162 return fail_at(arg, status);
1164 CommandLineSwitchCase(arg,
"multitouch")
1167 return fail_at(arg, COMMAND_LINE_ERROR);
1169 CommandLineSwitchCase(arg,
"gestures")
1172 return fail_at(arg, COMMAND_LINE_ERROR);
1174 CommandLineSwitchCase(arg,
"echo")
1177 return fail_at(arg, COMMAND_LINE_ERROR);
1179 CommandLineSwitchCase(arg,
"ssh-agent")
1182 return fail_at(arg, COMMAND_LINE_ERROR);
1184 CommandLineSwitchCase(arg,
"disp")
1187 return fail_at(arg, COMMAND_LINE_ERROR);
1189 CommandLineSwitchCase(arg,
"geometry")
1192 return fail_at(arg, COMMAND_LINE_ERROR);
1194 CommandLineSwitchCase(arg,
"video")
1198 return fail_at(arg, COMMAND_LINE_ERROR);
1200 return fail_at(arg, COMMAND_LINE_ERROR);
1202 CommandLineSwitchCase(arg,
"sound")
1206 CommandLineParseCommaSeparatedValuesEx(RDPSND_CHANNEL_NAME, arg->Value, &count);
1207 if (!freerdp_client_add_static_channel(settings, count, (
const char*
const*)ptr))
1208 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1209 if (!freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr))
1210 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1212 CommandLineParserFree(ptr);
1214 return fail_at(arg, status);
1216 CommandLineSwitchCase(arg,
"microphone")
1219 char** ptr = CommandLineParseCommaSeparatedValuesEx(AUDIN_CHANNEL_NAME, arg->Value, &count);
1220 if (!freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr))
1221 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1222 CommandLineParserFree(ptr);
1224 return fail_at(arg, status);
1226 #if defined(CHANNEL_TSMF_CLIENT)
1227 CommandLineSwitchCase(arg,
"multimedia")
1230 char** ptr = CommandLineParseCommaSeparatedValuesEx(
"tsmf", arg->Value, &count);
1231 if (!freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr))
1232 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1233 CommandLineParserFree(ptr);
1235 return fail_at(arg, status);
1238 CommandLineSwitchCase(arg,
"heartbeat")
1241 return fail_at(arg, COMMAND_LINE_ERROR);
1243 CommandLineSwitchCase(arg,
"multitransport")
1246 return fail_at(arg, COMMAND_LINE_ERROR);
1251 (TRANSPORT_TYPE_UDP_FECR | TRANSPORT_TYPE_UDP_FECL | TRANSPORT_TYPE_UDP_PREFERRED);
1254 return fail_at(arg, COMMAND_LINE_ERROR);
1256 CommandLineSwitchEnd(arg)
1263 int status = freerdp_client_command_line_post_filter_int(context, arg);
1264 return status == CHANNEL_RC_OK ? 1 : -1;
1267 static BOOL freerdp_parse_username_ptr(
const char* username,
const char** user,
size_t* userlen,
1268 const char** domain,
size_t* domainlen)
1271 WINPR_ASSERT(userlen);
1272 WINPR_ASSERT(domain);
1273 WINPR_ASSERT(domainlen);
1278 const char* p = strchr(username,
'\\');
1288 const size_t length = (size_t)(p - username);
1290 *userlen = strlen(*user);
1293 *domainlen = length;
1302 *userlen = strlen(username);
1308 static BOOL freerdp_parse_username_settings(
const char* username, rdpSettings* settings,
1309 FreeRDP_Settings_Keys_String userID,
1310 FreeRDP_Settings_Keys_String domainID)
1312 const char* user = NULL;
1313 const char* domain = NULL;
1315 size_t domainlen = 0;
1317 const BOOL rc = freerdp_parse_username_ptr(username, &user, &userlen, &domain, &domainlen);
1325 BOOL freerdp_parse_username(
const char* username,
char** puser,
char** pdomain)
1327 const char* user = NULL;
1328 const char* domain = NULL;
1330 size_t domainlen = 0;
1335 const BOOL rc = freerdp_parse_username_ptr(username, &user, &userlen, &domain, &domainlen);
1341 *puser = strndup(user, userlen);
1348 *pdomain = strndup(domain, domainlen);
1360 BOOL freerdp_parse_hostname(
const char* hostname,
char** host,
int* port)
1363 p = strrchr(hostname,
':');
1367 size_t length = (size_t)(p - hostname);
1370 if (!value_to_int(p + 1, &val, 1, UINT16_MAX))
1373 *host = (
char*)calloc(length + 1UL,
sizeof(
char));
1378 CopyMemory(*host, hostname, length);
1379 (*host)[length] =
'\0';
1380 *port = (UINT16)val;
1384 *host = _strdup(hostname);
1395 static BOOL freerdp_apply_connection_type(rdpSettings* settings, UINT32 type)
1397 struct network_settings
1399 FreeRDP_Settings_Keys_Bool id;
1402 const struct network_settings config[] = {
1403 { FreeRDP_DisableWallpaper, { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
1404 { FreeRDP_AllowFontSmoothing, { FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE } },
1405 { FreeRDP_AllowDesktopComposition, { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE } },
1406 { FreeRDP_DisableFullWindowDrag, { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
1407 { FreeRDP_DisableMenuAnims, { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
1408 { FreeRDP_DisableThemes, { TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE } }
1413 case CONNECTION_TYPE_INVALID:
1416 case CONNECTION_TYPE_MODEM:
1417 case CONNECTION_TYPE_BROADBAND_LOW:
1418 case CONNECTION_TYPE_BROADBAND_HIGH:
1419 case CONNECTION_TYPE_SATELLITE:
1420 case CONNECTION_TYPE_WAN:
1421 case CONNECTION_TYPE_LAN:
1422 case CONNECTION_TYPE_AUTODETECT:
1425 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
1429 for (
size_t x = 0; x < ARRAYSIZE(config); x++)
1431 const struct network_settings* cur = &config[x];
1438 BOOL freerdp_set_connection_type(rdpSettings* settings, UINT32 type)
1446 case CONNECTION_TYPE_INVALID:
1447 case CONNECTION_TYPE_MODEM:
1448 case CONNECTION_TYPE_BROADBAND_LOW:
1449 case CONNECTION_TYPE_SATELLITE:
1450 case CONNECTION_TYPE_BROADBAND_HIGH:
1451 case CONNECTION_TYPE_WAN:
1452 case CONNECTION_TYPE_LAN:
1453 if (!freerdp_apply_connection_type(settings, type))
1456 case CONNECTION_TYPE_AUTODETECT:
1457 if (!freerdp_apply_connection_type(settings, type))
1460 #ifdef WITH_GFX_H264
1471 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
1478 static UINT32 freerdp_get_keyboard_layout_for_type(
const char* name, DWORD type)
1483 freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD, &count);
1485 if (!layouts || (count == 0))
1488 for (
size_t x = 0; x < count; x++)
1491 if (option_equals(layout->name, name))
1499 freerdp_keyboard_layouts_free(layouts, count);
1503 static UINT32 freerdp_map_keyboard_layout_name_to_id(
const char* name)
1505 const UINT32 variants[] = { RDP_KEYBOARD_LAYOUT_TYPE_STANDARD, RDP_KEYBOARD_LAYOUT_TYPE_VARIANT,
1506 RDP_KEYBOARD_LAYOUT_TYPE_IME };
1508 for (
size_t x = 0; x < ARRAYSIZE(variants); x++)
1510 UINT32 rc = freerdp_get_keyboard_layout_for_type(name, variants[x]);
1518 static int freerdp_detect_command_line_pre_filter(
void* context,
int index,
int argc, LPSTR* argv)
1521 WINPR_UNUSED(context);
1528 length = strlen(argv[index]);
1532 if (option_is_rdp_file(argv[index]))
1540 if (option_is_incident_file(argv[index]))
1550 static int freerdp_detect_windows_style_command_line_syntax(
int argc,
char** argv,
size_t* count,
1555 int detect_status = 0;
1558 memcpy(largs, global_cmd_args,
sizeof(global_cmd_args));
1560 flags = COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_SILENCE_PARSER;
1561 flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
1565 flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
1570 CommandLineClearArgumentsA(largs);
1571 status = CommandLineParseArgumentsA(argc, argv, largs, flags, NULL,
1572 freerdp_detect_command_line_pre_filter, NULL);
1581 if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
1585 }
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
1587 if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
1590 return detect_status;
1593 static int freerdp_detect_posix_style_command_line_syntax(
int argc,
char** argv,
size_t* count,
1598 int detect_status = 0;
1601 memcpy(largs, global_cmd_args,
sizeof(global_cmd_args));
1603 flags = COMMAND_LINE_SEPARATOR_SPACE | COMMAND_LINE_SILENCE_PARSER;
1604 flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
1605 flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
1609 flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
1614 CommandLineClearArgumentsA(largs);
1615 status = CommandLineParseArgumentsA(argc, argv, largs, flags, NULL,
1616 freerdp_detect_command_line_pre_filter, NULL);
1625 if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
1629 }
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
1631 if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
1634 return detect_status;
1637 static BOOL freerdp_client_detect_command_line(
int argc,
char** argv, DWORD* flags)
1639 int posix_cli_status = 0;
1640 size_t posix_cli_count = 0;
1641 int windows_cli_status = 0;
1642 size_t windows_cli_count = 0;
1643 const BOOL ignoreUnknown = TRUE;
1644 windows_cli_status = freerdp_detect_windows_style_command_line_syntax(
1645 argc, argv, &windows_cli_count, ignoreUnknown);
1647 freerdp_detect_posix_style_command_line_syntax(argc, argv, &posix_cli_count, ignoreUnknown);
1650 *flags = COMMAND_LINE_SEPARATOR_SPACE;
1651 *flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
1652 *flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
1654 if (posix_cli_status <= COMMAND_LINE_STATUS_PRINT)
1658 if ((windows_cli_count && (windows_cli_count >= posix_cli_count)) ||
1659 (windows_cli_status <= COMMAND_LINE_STATUS_PRINT))
1661 windows_cli_count = 1;
1662 *flags = COMMAND_LINE_SEPARATOR_COLON;
1663 *flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
1666 WLog_DBG(TAG,
"windows: %d/%" PRIuz
" posix: %d/%" PRIuz
"", windows_cli_status,
1667 windows_cli_count, posix_cli_status, posix_cli_count);
1668 if ((posix_cli_count == 0) && (windows_cli_count == 0))
1670 if ((posix_cli_status == COMMAND_LINE_ERROR) && (windows_cli_status == COMMAND_LINE_ERROR))
1676 int freerdp_client_settings_command_line_status_print(rdpSettings* settings,
int status,
int argc,
1679 return freerdp_client_settings_command_line_status_print_ex(settings, status, argc, argv, NULL);
1682 static void freerdp_client_print_keyboard_type_list(
const char* msg, DWORD type)
1686 layouts = freerdp_keyboard_get_layouts(type, &count);
1688 printf(
"\n%s\n", msg);
1690 for (
size_t x = 0; x < count; x++)
1693 printf(
"0x%08" PRIX32
"\t%s\n", layout->code, layout->name);
1696 freerdp_keyboard_layouts_free(layouts, count);
1699 static void freerdp_client_print_keyboard_list(
void)
1701 freerdp_client_print_keyboard_type_list(
"Keyboard Layouts", RDP_KEYBOARD_LAYOUT_TYPE_STANDARD);
1702 freerdp_client_print_keyboard_type_list(
"Keyboard Layout Variants",
1703 RDP_KEYBOARD_LAYOUT_TYPE_VARIANT);
1704 freerdp_client_print_keyboard_type_list(
"Keyboard Layout Variants",
1705 RDP_KEYBOARD_LAYOUT_TYPE_IME);
1708 static void freerdp_client_print_timezone_list(
void)
1712 while (EnumDynamicTimeZoneInformation(index++, &info) != ERROR_NO_MORE_ITEMS)
1714 char TimeZoneKeyName[ARRAYSIZE(info.TimeZoneKeyName) + 1] = { 0 };
1716 (void)ConvertWCharNToUtf8(info.TimeZoneKeyName, ARRAYSIZE(info.TimeZoneKeyName),
1717 TimeZoneKeyName, ARRAYSIZE(TimeZoneKeyName));
1718 printf(
"%" PRIu32
": '%s'\n", index, TimeZoneKeyName);
1722 static void freerdp_client_print_tune_list(
const rdpSettings* settings)
1726 for (SSIZE_T x = 0; x < FreeRDP_Settings_StableAPI_MAX; x++)
1734 case RDP_SETTINGS_TYPE_BOOL:
1735 printf(
"%" PRIdz
"\t%50s\tBOOL\t%s\n", x, name,
1740 case RDP_SETTINGS_TYPE_UINT16:
1741 printf(
"%" PRIdz
"\t%50s\tUINT16\t%" PRIu16
"\n", x, name,
1744 case RDP_SETTINGS_TYPE_INT16:
1745 printf(
"%" PRIdz
"\t%50s\tINT16\t%" PRId16
"\n", x, name,
1748 case RDP_SETTINGS_TYPE_UINT32:
1749 printf(
"%" PRIdz
"\t%50s\tUINT32\t%" PRIu32
"\n", x, name,
1752 case RDP_SETTINGS_TYPE_INT32:
1753 printf(
"%" PRIdz
"\t%50s\tINT32\t%" PRId32
"\n", x, name,
1756 case RDP_SETTINGS_TYPE_UINT64:
1757 printf(
"%" PRIdz
"\t%50s\tUINT64\t%" PRIu64
"\n", x, name,
1760 case RDP_SETTINGS_TYPE_INT64:
1761 printf(
"%" PRIdz
"\t%50s\tINT64\t%" PRId64
"\n", x, name,
1764 case RDP_SETTINGS_TYPE_STRING:
1765 printf(
"%" PRIdz
"\t%50s\tSTRING\t%s"
1770 case RDP_SETTINGS_TYPE_POINTER:
1771 printf(
"%" PRIdz
"\t%50s\tPOINTER\t%p"
1783 int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings,
int status,
1784 int argc,
char** argv,
1789 memcpy(largs, global_cmd_args,
sizeof(global_cmd_args));
1791 if (status == COMMAND_LINE_STATUS_PRINT_VERSION)
1793 freerdp_client_print_version();
1797 if (status == COMMAND_LINE_STATUS_PRINT_BUILDCONFIG)
1799 freerdp_client_print_version_ex(argc, argv);
1800 freerdp_client_print_buildconfig_ex(argc, argv);
1803 else if (status == COMMAND_LINE_STATUS_PRINT)
1805 (void)CommandLineParseArgumentsA(argc, argv, largs, 0x112, NULL, NULL, NULL);
1807 arg = CommandLineFindArgumentA(largs,
"list");
1810 if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
1812 if (option_equals(
"timezones", arg->Value))
1813 freerdp_client_print_timezone_list();
1814 else if (option_equals(
"tune", arg->Value))
1815 freerdp_client_print_tune_list(settings);
1816 else if (option_equals(
"kbd", arg->Value))
1817 freerdp_client_print_keyboard_list();
1818 else if (option_starts_with(
"kbd-lang", arg->Value))
1820 const char* val = NULL;
1821 if (option_starts_with(
"kbd-lang:", arg->Value))
1822 val = &arg->Value[9];
1823 else if (!option_equals(
"kbd-lang", arg->Value))
1824 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1826 if (val && strchr(val,
','))
1827 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1828 freerdp_client_print_codepages(val);
1830 else if (option_equals(
"kbd-scancode", arg->Value))
1831 freerdp_client_print_scancodes();
1832 else if (option_equals(
"monitor", arg->Value))
1835 return COMMAND_LINE_ERROR;
1837 else if (option_starts_with(
"smartcard", arg->Value))
1840 if (option_starts_with(
"smartcard:", arg->Value))
1842 else if (!option_equals(
"smartcard", arg->Value))
1843 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1847 const char* sub = strchr(arg->Value,
':') + 1;
1848 const CmdLineSubOptions options[] = {
1849 {
"pkinit-anchors:", FreeRDP_PkinitAnchors, CMDLINE_SUBOPTION_STRING,
1851 {
"pkcs11-module:", FreeRDP_Pkcs11Module, CMDLINE_SUBOPTION_STRING, NULL }
1856 char** ptr = CommandLineParseCommaSeparatedValuesEx(
"smartcard", sub, &count);
1858 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1861 CommandLineParserFree(ptr);
1862 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1865 for (
size_t x = 1; x < count; x++)
1867 const char* cur = ptr[x];
1868 if (!parseSubOptions(settings, options, ARRAYSIZE(options), cur))
1870 CommandLineParserFree(ptr);
1871 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1875 CommandLineParserFree(ptr);
1878 freerdp_smartcard_list(settings);
1882 freerdp_client_print_command_line_help_ex(argc, argv, custom);
1883 return COMMAND_LINE_ERROR;
1886 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
1887 arg = CommandLineFindArgumentA(largs,
"tune-list");
1890 if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
1892 WLog_WARN(TAG,
"Option /tune-list is deprecated, use /list:tune instead");
1893 freerdp_client_print_tune_list(settings);
1896 arg = CommandLineFindArgumentA(largs,
"kbd-lang-list");
1899 if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
1901 WLog_WARN(TAG,
"Option /kbd-lang-list is deprecated, use /list:kbd-lang instead");
1902 freerdp_client_print_codepages(arg->Value);
1905 arg = CommandLineFindArgumentA(largs,
"kbd-list");
1908 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1910 WLog_WARN(TAG,
"Option /kbd-list is deprecated, use /list:kbd instead");
1911 freerdp_client_print_keyboard_list();
1914 arg = CommandLineFindArgumentA(largs,
"monitor-list");
1917 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1919 WLog_WARN(TAG,
"Option /monitor-list is deprecated, use /list:monitor instead");
1921 return COMMAND_LINE_ERROR;
1924 arg = CommandLineFindArgumentA(largs,
"smartcard-list");
1927 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1929 WLog_WARN(TAG,
"Option /smartcard-list is deprecated, use /list:smartcard instead");
1930 freerdp_smartcard_list(settings);
1933 arg = CommandLineFindArgumentA(largs,
"kbd-scancode-list");
1936 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1939 "Option /kbd-scancode-list is deprecated, use /list:kbd-scancode instead");
1940 freerdp_client_print_scancodes();
1946 else if (status < 0)
1948 freerdp_client_print_command_line_help_ex(argc, argv, custom);
1953 if (status <= COMMAND_LINE_STATUS_PRINT && status >= COMMAND_LINE_STATUS_PRINT_LAST)
1966 static BOOL parseSizeValue(
const char* input,
unsigned long* v1,
unsigned long* v2)
1968 const char* xcharpos = NULL;
1969 char* endPtr = NULL;
1970 unsigned long v = 0;
1972 v = strtoul(input, &endPtr, 10);
1974 if ((v == 0 || v == ULONG_MAX) && (errno != 0))
1980 xcharpos = strchr(input,
'x');
1982 if (!xcharpos || xcharpos != endPtr)
1986 v = strtoul(xcharpos + 1, &endPtr, 10);
1988 if ((v == 0 || v == ULONG_MAX) && (errno != 0))
1991 if (*endPtr !=
'\0')
2003 const char* arguments[] = {
"network",
"gfx",
"rfx",
"bpp" };
2004 WINPR_ASSERT(settings);
2010 for (
size_t x = 0; x < ARRAYSIZE(arguments); x++)
2012 const char* arg = arguments[x];
2014 if (p && (p->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
2018 return freerdp_set_connection_type(settings, CONNECTION_TYPE_AUTODETECT);
2021 static BOOL setSmartcardEmulation(
const char* value, rdpSettings* settings)
2026 const char* option_starts_with(
const char* what,
const char* val)
2030 const size_t wlen = strlen(what);
2032 if (_strnicmp(what, val, wlen) != 0)
2037 BOOL option_ends_with(
const char* str,
const char* ext)
2041 const size_t strLen = strlen(str);
2042 const size_t extLen = strlen(ext);
2044 if (strLen < extLen)
2047 return _strnicmp(&str[strLen - extLen], ext, extLen) == 0;
2050 BOOL option_equals(
const char* what,
const char* val)
2054 return _stricmp(what, val) == 0;
2063 } PARSE_ON_OFF_RESULT;
2065 static PARSE_ON_OFF_RESULT parse_on_off_option(
const char* value)
2067 WINPR_ASSERT(value);
2068 const char* sep = strchr(value,
':');
2071 if (option_equals(
"on", &sep[1]))
2073 if (option_equals(
"off", &sep[1]))
2082 CLIP_DIR_PARSE_LOCAL,
2083 CLIP_DIR_PARSE_REMOTE,
2085 } PARSE_CLIP_DIR_RESULT;
2087 static PARSE_CLIP_DIR_RESULT parse_clip_direciton_to_option(
const char* value)
2089 WINPR_ASSERT(value);
2090 const char* sep = strchr(value,
':');
2092 return CLIP_DIR_PARSE_FAIL;
2093 if (option_equals(
"all", &sep[1]))
2094 return CLIP_DIR_PARSE_ALL;
2095 if (option_equals(
"off", &sep[1]))
2096 return CLIP_DIR_PARSE_OFF;
2097 if (option_equals(
"local", &sep[1]))
2098 return CLIP_DIR_PARSE_LOCAL;
2099 if (option_equals(
"remote", &sep[1]))
2100 return CLIP_DIR_PARSE_REMOTE;
2101 return CLIP_DIR_PARSE_FAIL;
2104 static int parse_tls_ciphers(rdpSettings* settings,
const char* Value)
2106 const char* ciphers = NULL;
2108 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2110 if (option_equals(Value,
"netmon"))
2112 ciphers =
"ALL:!ECDH:!ADH:!DHE";
2114 else if (option_equals(Value,
"ma"))
2116 ciphers =
"AES128-SHA";
2124 return COMMAND_LINE_ERROR_MEMORY;
2128 static int parse_tls_seclevel(rdpSettings* settings,
const char* Value)
2132 if (!value_to_int(Value, &val, 0, 5))
2133 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2136 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2140 static int parse_tls_secrets_file(rdpSettings* settings,
const char* Value)
2143 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2146 return COMMAND_LINE_ERROR_MEMORY;
2150 static int parse_tls_enforce(rdpSettings* settings,
const char* Value)
2152 UINT16 version = TLS1_2_VERSION;
2161 const struct map_t map[] = { {
"1.0", TLS1_VERSION },
2162 {
"1.1", TLS1_1_VERSION },
2163 {
"1.2", TLS1_2_VERSION }
2164 #if defined(TLS1_3_VERSION)
2166 {
"1.3", TLS1_3_VERSION }
2170 for (
size_t x = 0; x < ARRAYSIZE(map); x++)
2172 const struct map_t* cur = &map[x];
2173 if (option_equals(cur->name, Value))
2175 version = cur->version;
2183 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2189 int rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2190 CommandLineSwitchStart(arg) CommandLineSwitchCase(arg,
"tls")
2192 if (option_starts_with(
"ciphers:", arg->Value))
2193 rc = parse_tls_ciphers(settings, &arg->Value[8]);
2194 else if (option_starts_with(
"seclevel:", arg->Value))
2195 rc = parse_tls_seclevel(settings, &arg->Value[9]);
2196 else if (option_starts_with(
"secrets-file:", arg->Value))
2197 rc = parse_tls_secrets_file(settings, &arg->Value[13]);
2198 else if (option_starts_with(
"enforce:", arg->Value))
2199 rc = parse_tls_enforce(settings, &arg->Value[8]);
2202 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
2203 CommandLineSwitchCase(arg,
"tls-ciphers")
2205 WLog_WARN(TAG,
"Option /tls-ciphers is deprecated, use /tls:ciphers instead");
2206 rc = parse_tls_ciphers(settings, arg->Value);
2208 CommandLineSwitchCase(arg,
"tls-seclevel")
2210 WLog_WARN(TAG,
"Option /tls-seclevel is deprecated, use /tls:seclevel instead");
2211 rc = parse_tls_seclevel(settings, arg->Value);
2213 CommandLineSwitchCase(arg,
"tls-secrets-file")
2215 WLog_WARN(TAG,
"Option /tls-secrets-file is deprecated, use /tls:secrets-file instead");
2216 rc = parse_tls_secrets_file(settings, arg->Value);
2218 CommandLineSwitchCase(arg,
"enforce-tlsv1_2")
2220 WLog_WARN(TAG,
"Option /enforce-tlsv1_2 is deprecated, use /tls:enforce:1.2 instead");
2221 rc = parse_tls_enforce(settings,
"1.2");
2224 CommandLineSwitchDefault(arg)
2227 CommandLineSwitchEnd(arg)
2234 WINPR_ASSERT(settings);
2238 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
2239 for (
size_t x = 0; x < count; x++)
2242 larg.Value = ptr[x];
2244 int rc = parse_tls_cipher_options(settings, &larg);
2247 CommandLineParserFree(ptr);
2251 CommandLineParserFree(ptr);
2257 WINPR_ASSERT(settings);
2261 return COMMAND_LINE_ERROR;
2265 int rc = CHANNEL_RC_OK;
2267 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
2268 if (!ptr || (count == 0))
2269 rc = COMMAND_LINE_ERROR;
2272 BOOL GfxH264 = FALSE;
2273 BOOL GfxAVC444 = FALSE;
2274 BOOL RemoteFxCodec = FALSE;
2275 BOOL GfxProgressive = FALSE;
2276 BOOL codecSelected = FALSE;
2278 for (
size_t x = 0; x < count; x++)
2280 const char* val = ptr[x];
2281 #ifdef WITH_GFX_H264
2282 if (option_starts_with(
"AVC444", val))
2284 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2285 if (bval == PARSE_FAIL)
2286 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2288 GfxAVC444 = bval != PARSE_OFF;
2289 codecSelected = TRUE;
2291 else if (option_starts_with(
"AVC420", val))
2293 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2294 if (bval == PARSE_FAIL)
2295 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2297 GfxH264 = bval != PARSE_OFF;
2298 codecSelected = TRUE;
2302 if (option_starts_with(
"RFX", val))
2304 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2305 if (bval == PARSE_FAIL)
2306 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2308 RemoteFxCodec = bval != PARSE_OFF;
2309 codecSelected = TRUE;
2311 else if (option_starts_with(
"progressive", val))
2313 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2314 if (bval == PARSE_FAIL)
2315 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2317 GfxProgressive = bval != PARSE_OFF;
2318 codecSelected = TRUE;
2320 else if (option_starts_with(
"mask:", val))
2323 const char* uv = &val[5];
2324 if (!value_to_uint(uv, &v, 0, UINT32_MAX))
2325 rc = COMMAND_LINE_ERROR;
2330 rc = COMMAND_LINE_ERROR;
2333 else if (option_starts_with(
"small-cache", val))
2335 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2336 if (bval == PARSE_FAIL)
2337 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2340 rc = COMMAND_LINE_ERROR;
2342 else if (option_starts_with(
"thin-client", val))
2344 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2345 if (bval == PARSE_FAIL)
2346 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2349 rc = COMMAND_LINE_ERROR;
2350 if ((rc == CHANNEL_RC_OK) && (bval > 0))
2354 rc = COMMAND_LINE_ERROR;
2357 else if (option_starts_with(
"frame-ack", val))
2359 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2360 if (bval == PARSE_FAIL)
2361 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2364 rc = COMMAND_LINE_ERROR;
2367 rc = COMMAND_LINE_ERROR;
2370 if ((rc == CHANNEL_RC_OK) && codecSelected)
2373 rc = COMMAND_LINE_ERROR;
2375 rc = COMMAND_LINE_ERROR;
2377 rc = COMMAND_LINE_ERROR;
2379 rc = COMMAND_LINE_ERROR;
2381 rc = COMMAND_LINE_ERROR;
2384 CommandLineParserFree(ptr);
2385 if (rc != CHANNEL_RC_OK)
2388 return CHANNEL_RC_OK;
2391 static int parse_kbd_layout(rdpSettings* settings,
const char* value)
2393 WINPR_ASSERT(settings);
2394 WINPR_ASSERT(value);
2398 const BOOL isInt = value_to_int(value, &ival, 1, UINT32_MAX);
2401 ival = freerdp_map_keyboard_layout_name_to_id(value);
2405 WLog_ERR(TAG,
"Could not identify keyboard layout: %s", value);
2406 WLog_ERR(TAG,
"Use /list:kbd to list available layouts");
2407 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2414 rc = COMMAND_LINE_ERROR;
2419 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
2422 WINPR_ASSERT(settings);
2426 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2428 return COMMAND_LINE_ERROR;
2430 if (option_equals(arg->Value,
"rfx"))
2433 return COMMAND_LINE_ERROR;
2435 else if (option_equals(arg->Value,
"nsc"))
2438 return COMMAND_LINE_ERROR;
2441 #if defined(WITH_JPEG)
2442 else if (option_equals(arg->Value,
"jpeg"))
2445 return COMMAND_LINE_ERROR;
2450 return COMMAND_LINE_ERROR;
2459 static BOOL check_kbd_remap_valid(
const char* token)
2464 WINPR_ASSERT(token);
2466 if (strlen(token) > 10)
2469 if (!freerdp_extract_key_value(token, &key, &value))
2471 WLog_WARN(TAG,
"/kbd:remap invalid entry '%s'", token);
2479 WINPR_ASSERT(settings);
2483 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2485 return COMMAND_LINE_ERROR_MEMORY;
2486 char* p = strchr(arg->Value,
'[');
2491 const char scheme[] =
"://";
2492 const char* val = strstr(arg->Value, scheme);
2494 val += strnlen(scheme,
sizeof(scheme));
2497 p = strchr(val,
':');
2504 if (!value_to_int(&p[1], &lval, 1, UINT16_MAX))
2505 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2507 length = (size_t)(p - arg->Value);
2509 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2512 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2517 return COMMAND_LINE_ERROR_MEMORY;
2523 char* p2 = strchr(arg->Value,
']');
2527 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2529 length = (size_t)(p2 - p);
2531 return COMMAND_LINE_ERROR_MEMORY;
2533 if (*(p2 + 1) ==
':')
2537 if (!value_to_int(&p2[2], &val, 0, UINT16_MAX))
2538 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2541 return COMMAND_LINE_ERROR;
2544 printf(
"hostname %s port %" PRIu32
"\n",
2553 WINPR_ASSERT(settings);
2557 char* cur = arg->Value;
2559 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2561 return COMMAND_LINE_ERROR;
2567 char* next = strchr(cur,
',');
2575 if (option_equals(
"fqdn", cur))
2577 else if (option_equals(
"ip", cur))
2579 else if (option_equals(
"netbios", cur))
2582 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2585 mask = (mask & 0x07);
2586 value |= mask << (count * 3);
2588 }
while (cur != NULL);
2591 return COMMAND_LINE_ERROR;
2594 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2598 static int parse_prevent_session_lock_options(rdpSettings* settings,
2601 WINPR_ASSERT(settings);
2605 return COMMAND_LINE_ERROR_MEMORY;
2607 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
2611 if (!value_to_int(arg->Value, &val, 1, UINT32_MAX))
2612 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2615 return COMMAND_LINE_ERROR_MEMORY;
2623 WINPR_ASSERT(settings);
2627 return COMMAND_LINE_ERROR;
2634 return COMMAND_LINE_ERROR;
2636 return COMMAND_LINE_ERROR;
2638 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
2641 return COMMAND_LINE_ERROR;
2644 return COMMAND_LINE_ERROR_MEMORY;
2652 WINPR_ASSERT(settings);
2656 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2657 char* p = strchr(arg->Value,
'x');
2661 unsigned long w = 0;
2662 unsigned long h = 0;
2664 if (!parseSizeValue(arg->Value, &w, &h) || (w > UINT16_MAX) || (h > UINT16_MAX))
2665 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2668 return COMMAND_LINE_ERROR;
2670 return COMMAND_LINE_ERROR;
2674 char* str = _strdup(arg->Value);
2676 return COMMAND_LINE_ERROR_MEMORY;
2678 p = strchr(str,
'%');
2682 BOOL partial = FALSE;
2684 status = COMMAND_LINE_ERROR;
2711 if (!value_to_int(str, &val, 0, 100))
2713 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2733 WINPR_ASSERT(settings);
2736 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
2739 UINT32* MonitorIds = NULL;
2740 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
2743 return COMMAND_LINE_ERROR_MEMORY;
2750 CommandLineParserFree(ptr);
2754 MonitorIds = freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorIds, 0);
2755 for (UINT32 i = 0; i < count; i++)
2759 if (!value_to_int(ptr[i], &val, 0, UINT16_MAX))
2760 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2762 MonitorIds[i] = (UINT32)val;
2765 CommandLineParserFree(ptr);
2771 static int parse_dynamic_resolution_options(rdpSettings* settings,
2774 WINPR_ASSERT(settings);
2777 const BOOL val = arg->Value != 0;
2781 WLog_ERR(TAG,
"Smart sizing and dynamic resolution are mutually exclusive options");
2782 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2786 return COMMAND_LINE_ERROR;
2788 return COMMAND_LINE_ERROR;
2795 WINPR_ASSERT(settings);
2800 WLog_ERR(TAG,
"Smart sizing and dynamic resolution are mutually exclusive options");
2801 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2805 return COMMAND_LINE_ERROR;
2809 unsigned long w = 0;
2810 unsigned long h = 0;
2812 if (!parseSizeValue(arg->Value, &w, &h) || (w > UINT16_MAX) || (h > UINT16_MAX))
2813 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2816 return COMMAND_LINE_ERROR;
2818 return COMMAND_LINE_ERROR;
2825 WINPR_ASSERT(settings);
2830 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
2831 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2841 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2845 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2852 WINPR_ASSERT(settings);
2855 int rc = CHANNEL_RC_OK;
2857 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
2858 if (!ptr || (count == 0))
2859 rc = COMMAND_LINE_ERROR;
2862 for (
size_t x = 0; x < count; x++)
2864 const char* val = ptr[x];
2866 if (option_starts_with(
"remap:", val))
2869 char* now = _strdup(&val[6]);
2874 if (!check_kbd_remap_valid(now))
2875 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2878 const size_t olen = strlen(old);
2879 const size_t alen = strlen(now);
2880 const size_t tlen = olen + alen + 2;
2881 char* tmp = calloc(tlen,
sizeof(
char));
2883 rc = COMMAND_LINE_ERROR_MEMORY;
2885 (
void)_snprintf(tmp, tlen,
"%s,%s", old, now);
2893 rc = COMMAND_LINE_ERROR;
2897 else if (option_starts_with(
"layout:", val))
2899 rc = parse_kbd_layout(settings, &val[7]);
2901 else if (option_starts_with(
"lang:", val))
2904 const BOOL isInt = value_to_int(&val[5], &ival, 1, UINT32_MAX);
2906 ival = freerdp_get_locale_id_from_string(&val[5]);
2909 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2912 rc = COMMAND_LINE_ERROR;
2914 else if (option_starts_with(
"type:", val))
2917 const BOOL isInt = value_to_int(&val[5], &ival, 1, UINT32_MAX);
2919 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2921 rc = COMMAND_LINE_ERROR;
2923 else if (option_starts_with(
"subtype:", val))
2926 const BOOL isInt = value_to_int(&val[8], &ival, 1, UINT32_MAX);
2928 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2931 rc = COMMAND_LINE_ERROR;
2933 else if (option_starts_with(
"fn-key:", val))
2936 const BOOL isInt = value_to_int(&val[7], &ival, 1, UINT32_MAX);
2938 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2941 rc = COMMAND_LINE_ERROR;
2943 else if (option_starts_with(
"unicode", val))
2945 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2946 if (bval == PARSE_FAIL)
2947 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2950 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2952 else if (option_starts_with(
"pipe:", val))
2955 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2957 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2959 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
2960 else if (count == 1)
2963 rc = parse_kbd_layout(settings, val);
2967 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2973 CommandLineParserFree(ptr);
2979 WINPR_ASSERT(settings);
2984 return COMMAND_LINE_ERROR_MEMORY;
2986 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
2988 const char* cur = arg->Value;
2991 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2993 if (!proxy_parse_uri(settings, cur))
2994 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2998 WLog_ERR(TAG,
"Option http-proxy needs argument.");
2999 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3006 WINPR_ASSERT(settings);
3009 BOOL failed = FALSE;
3011 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3016 BOOL modernsyntax = FALSE;
3017 BOOL oldsyntax = FALSE;
3018 for (
size_t x = 0; (x < count) && !failed; x++)
3020 const char* carg = ptr[x];
3021 if (option_starts_with(
"file:", carg))
3023 const char* val = &carg[5];
3028 modernsyntax = TRUE;
3030 else if (option_equals(
"replay", carg))
3037 else if (option_equals(
"record", carg))
3044 else if (option_equals(
"nodelay", carg))
3051 modernsyntax = TRUE;
3066 if (oldsyntax && (count != 2))
3069 CommandLineParserFree(ptr);
3071 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3077 WINPR_ASSERT(settings);
3080 if (arg->Value == BoolValueTrue || arg->Value == BoolValueFalse)
3083 (arg->Value == BoolValueTrue)))
3084 return COMMAND_LINE_ERROR;
3090 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3091 for (
size_t x = 0; (x < count) && (rc == 0); x++)
3093 const char* usesel =
"use-selection:";
3095 const char* cur = ptr[x];
3096 if (option_starts_with(usesel, cur))
3098 const char* val = &cur[strlen(usesel)];
3100 rc = COMMAND_LINE_ERROR_MEMORY;
3102 return COMMAND_LINE_ERROR;
3104 else if (option_starts_with(
"direction-to", cur))
3108 (uint32_t)~(CLIPRDR_FLAG_LOCAL_TO_REMOTE | CLIPRDR_FLAG_REMOTE_TO_LOCAL);
3109 const PARSE_CLIP_DIR_RESULT bval = parse_clip_direciton_to_option(cur);
3113 case CLIP_DIR_PARSE_ALL:
3114 bflags |= CLIPRDR_FLAG_LOCAL_TO_REMOTE | CLIPRDR_FLAG_REMOTE_TO_LOCAL;
3116 case CLIP_DIR_PARSE_LOCAL:
3117 bflags |= CLIPRDR_FLAG_REMOTE_TO_LOCAL;
3119 case CLIP_DIR_PARSE_REMOTE:
3120 bflags |= CLIPRDR_FLAG_LOCAL_TO_REMOTE;
3122 case CLIP_DIR_PARSE_OFF:
3124 case CLIP_DIR_PARSE_FAIL:
3126 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3132 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3134 else if (option_starts_with(
"files-to", cur))
3138 (uint32_t)~(CLIPRDR_FLAG_LOCAL_TO_REMOTE_FILES |
3139 CLIPRDR_FLAG_REMOTE_TO_LOCAL_FILES);
3140 const PARSE_CLIP_DIR_RESULT bval = parse_clip_direciton_to_option(cur);
3144 case CLIP_DIR_PARSE_ALL:
3146 CLIPRDR_FLAG_LOCAL_TO_REMOTE_FILES | CLIPRDR_FLAG_REMOTE_TO_LOCAL_FILES;
3148 case CLIP_DIR_PARSE_LOCAL:
3149 bflags |= CLIPRDR_FLAG_REMOTE_TO_LOCAL_FILES;
3151 case CLIP_DIR_PARSE_REMOTE:
3152 bflags |= CLIPRDR_FLAG_LOCAL_TO_REMOTE_FILES;
3154 case CLIP_DIR_PARSE_OFF:
3156 case CLIP_DIR_PARSE_FAIL:
3158 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3164 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3167 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3169 CommandLineParserFree(ptr);
3179 WINPR_ASSERT(settings);
3184 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
3185 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3189 case AUDIO_MODE_REDIRECT:
3191 return COMMAND_LINE_ERROR;
3194 case AUDIO_MODE_PLAY_ON_SERVER:
3196 return COMMAND_LINE_ERROR;
3199 case AUDIO_MODE_NONE:
3201 return COMMAND_LINE_ERROR;
3203 return COMMAND_LINE_ERROR;
3207 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3214 WINPR_ASSERT(settings);
3217 UINT32 type = CONNECTION_TYPE_INVALID;
3219 if (option_equals(arg->Value,
"invalid"))
3220 type = CONNECTION_TYPE_INVALID;
3221 else if (option_equals(arg->Value,
"modem"))
3222 type = CONNECTION_TYPE_MODEM;
3223 else if (option_equals(arg->Value,
"broadband"))
3224 type = CONNECTION_TYPE_BROADBAND_HIGH;
3225 else if (option_equals(arg->Value,
"broadband-low"))
3226 type = CONNECTION_TYPE_BROADBAND_LOW;
3227 else if (option_equals(arg->Value,
"broadband-high"))
3228 type = CONNECTION_TYPE_BROADBAND_HIGH;
3229 else if (option_equals(arg->Value,
"wan"))
3230 type = CONNECTION_TYPE_WAN;
3231 else if (option_equals(arg->Value,
"lan"))
3232 type = CONNECTION_TYPE_LAN;
3233 else if ((option_equals(arg->Value,
"autodetect")) || (option_equals(arg->Value,
"auto")) ||
3234 (option_equals(arg->Value,
"detect")))
3236 type = CONNECTION_TYPE_AUTODETECT;
3242 if (!value_to_int(arg->Value, &val, 0, 7))
3243 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3248 if (!freerdp_set_connection_type(settings, type))
3249 return COMMAND_LINE_ERROR;
3255 WINPR_ASSERT(settings);
3259 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3261 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3263 FreeRDP_Settings_Keys_Bool singleOptionWithoutOnOff = FreeRDP_BOOL_UNUSED;
3264 for (
size_t x = 0; x < count; x++)
3266 const char* cur = ptr[x];
3267 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(cur);
3268 if (bval == PARSE_FAIL)
3270 CommandLineParserFree(ptr);
3271 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3274 const BOOL val = bval != PARSE_OFF;
3275 FreeRDP_Settings_Keys_Bool
id = FreeRDP_BOOL_UNUSED;
3276 if (option_starts_with(
"rdp", cur))
3278 id = FreeRDP_RdpSecurity;
3280 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3282 else if (option_starts_with(
"tls", cur))
3283 id = FreeRDP_TlsSecurity;
3284 else if (option_starts_with(
"nla", cur))
3285 id = FreeRDP_NlaSecurity;
3286 else if (option_starts_with(
"ext", cur))
3287 id = FreeRDP_ExtSecurity;
3288 else if (option_equals(
"aad", cur))
3289 id = FreeRDP_AadSecurity;
3292 WLog_ERR(TAG,
"unknown protocol security: %s", arg->Value);
3293 CommandLineParserFree(ptr);
3294 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3297 if ((bval == PARSE_NONE) && (count == 1))
3298 singleOptionWithoutOnOff = id;
3300 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3303 if (singleOptionWithoutOnOff != FreeRDP_BOOL_UNUSED)
3305 const FreeRDP_Settings_Keys_Bool options[] = { FreeRDP_AadSecurity,
3306 FreeRDP_UseRdpSecurityLayer,
3307 FreeRDP_RdpSecurity, FreeRDP_NlaSecurity,
3308 FreeRDP_TlsSecurity };
3310 for (
size_t i = 0; i < ARRAYSIZE(options); i++)
3313 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3317 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3318 if (singleOptionWithoutOnOff == FreeRDP_RdpSecurity)
3321 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3324 CommandLineParserFree(ptr);
3328 static int parse_encryption_methods_options(rdpSettings* settings,
3331 WINPR_ASSERT(settings);
3334 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
3337 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3339 UINT32 EncryptionMethods = 0;
3340 for (UINT32 i = 0; i < count; i++)
3342 if (option_equals(ptr[i],
"40"))
3343 EncryptionMethods |= ENCRYPTION_METHOD_40BIT;
3344 else if (option_equals(ptr[i],
"56"))
3345 EncryptionMethods |= ENCRYPTION_METHOD_56BIT;
3346 else if (option_equals(ptr[i],
"128"))
3347 EncryptionMethods |= ENCRYPTION_METHOD_128BIT;
3348 else if (option_equals(ptr[i],
"FIPS"))
3349 EncryptionMethods |= ENCRYPTION_METHOD_FIPS;
3351 WLog_ERR(TAG,
"unknown encryption method '%s'", ptr[i]);
3355 return COMMAND_LINE_ERROR;
3356 CommandLineParserFree(ptr);
3363 WINPR_ASSERT(settings);
3368 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3369 for (
size_t x = 0; (x < count) && (rc == 0); x++)
3371 const char deny[] =
"deny";
3372 const char ignore[] =
"ignore";
3373 const char tofu[] =
"tofu";
3374 const char name[] =
"name:";
3375 const char fingerprints[] =
"fingerprint:";
3377 const char* cur = ptr[x];
3378 if (option_equals(deny, cur))
3381 return COMMAND_LINE_ERROR;
3383 else if (option_equals(ignore, cur))
3386 return COMMAND_LINE_ERROR;
3388 else if (option_equals(tofu, cur))
3391 return COMMAND_LINE_ERROR;
3393 else if (option_starts_with(name, cur))
3395 const char* val = &cur[strnlen(name,
sizeof(name))];
3397 rc = COMMAND_LINE_ERROR_MEMORY;
3399 else if (option_starts_with(fingerprints, cur))
3401 const char* val = &cur[strnlen(fingerprints,
sizeof(fingerprints))];
3404 rc = COMMAND_LINE_ERROR_MEMORY;
3407 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3409 CommandLineParserFree(ptr);
3416 WINPR_ASSERT(settings);
3420 char** ptr = CommandLineParseCommaSeparatedValuesEx(
"mouse", arg->Value, &count);
3424 for (
size_t x = 1; x < count; x++)
3426 const char* cur = ptr[x];
3428 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(cur);
3429 if (bval == PARSE_FAIL)
3430 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3433 const BOOL val = bval != PARSE_OFF;
3435 if (option_starts_with(
"relative", cur))
3438 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3440 else if (option_starts_with(
"grab", cur))
3443 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3451 CommandLineParserFree(ptr);
3458 WINPR_ASSERT(settings);
3462 UINT32 Floatbar = 0x0017;
3466 char* start = arg->Value;
3471 start = strchr(start,
',');
3480 if (option_starts_with(
"sticky:", cur))
3484 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(cur);
3496 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3500 else if (option_starts_with(
"default:", cur))
3502 const char* val = cur + 8;
3505 if (option_equals(
"visible", val))
3507 else if (option_equals(
"hidden", val))
3510 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3513 else if (option_starts_with(
"show:", cur))
3515 const char* val = cur + 5;
3518 if (option_equals(
"always", val))
3520 else if (option_equals(
"fullscreen", val))
3522 else if (option_equals(
"window", val))
3525 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3528 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3532 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3538 WINPR_ASSERT(settings);
3541 BYTE* base64 = NULL;
3544 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3546 crypto_base64_decode((
const char*)(arg->Value), strlen(arg->Value), &base64, &length);
3552 return COMMAND_LINE_ERROR;
3556 WLog_ERR(TAG,
"reconnect-cookie: invalid base64 '%s'", arg->Value);
3565 WINPR_ASSERT(settings);
3570 if (!value_to_int(arg->Value, &val, 100, 180))
3571 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3579 return COMMAND_LINE_ERROR;
3581 return COMMAND_LINE_ERROR;
3585 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3592 WINPR_ASSERT(settings);
3597 if (!value_to_int(arg->Value, &val, 100, 180))
3598 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3606 return COMMAND_LINE_ERROR;
3610 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3617 WINPR_ASSERT(settings);
3623 return COMMAND_LINE_ERROR;
3625 char** ptr = CommandLineParseCommaSeparatedValuesEx(
"smartcard-logon", arg->Value, &count);
3628 const CmdLineSubOptions opts[] = {
3629 {
"cert:", FreeRDP_SmartcardCertificate, CMDLINE_SUBOPTION_FILE,
3630 setSmartcardEmulation },
3631 {
"key:", FreeRDP_SmartcardPrivateKey, CMDLINE_SUBOPTION_FILE, setSmartcardEmulation },
3632 {
"pin:", FreeRDP_Password, CMDLINE_SUBOPTION_STRING, NULL },
3633 {
"csp:", FreeRDP_CspName, CMDLINE_SUBOPTION_STRING, NULL },
3634 {
"reader:", FreeRDP_ReaderName, CMDLINE_SUBOPTION_STRING, NULL },
3635 {
"card:", FreeRDP_CardName, CMDLINE_SUBOPTION_STRING, NULL },
3636 {
"container:", FreeRDP_ContainerName, CMDLINE_SUBOPTION_STRING, NULL }
3639 for (
size_t x = 1; x < count; x++)
3641 const char* cur = ptr[x];
3642 if (!parseSubOptions(settings, opts, ARRAYSIZE(opts), cur))
3644 CommandLineParserFree(ptr);
3645 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3649 CommandLineParserFree(ptr);
3655 WINPR_ASSERT(settings);
3659 char** ptr = CommandLineParseCommaSeparatedValuesEx(
"tune", arg->Value, &count);
3661 return COMMAND_LINE_ERROR;
3662 for (
size_t x = 1; x < count; x++)
3664 const char* cur = ptr[x];
3665 char* sep = strchr(cur,
':');
3668 CommandLineParserFree(ptr);
3669 return COMMAND_LINE_ERROR;
3672 if (!freerdp_settings_set_value_for_name(settings, cur, sep))
3674 CommandLineParserFree(ptr);
3675 return COMMAND_LINE_ERROR;
3679 CommandLineParserFree(ptr);
3683 static int parse_app_option_program(rdpSettings* settings,
const char* cmd)
3685 const FreeRDP_Settings_Keys_Bool ids[] = { FreeRDP_RemoteApplicationMode,
3686 FreeRDP_RemoteAppLanguageBarSupported,
3687 FreeRDP_Workarea, FreeRDP_DisableWallpaper,
3688 FreeRDP_DisableFullWindowDrag };
3691 return COMMAND_LINE_ERROR_MEMORY;
3693 for (
size_t y = 0; y < ARRAYSIZE(ids); y++)
3696 return COMMAND_LINE_ERROR;
3698 return CHANNEL_RC_OK;
3703 WINPR_ASSERT(settings);
3706 int rc = CHANNEL_RC_OK;
3708 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3709 if (!ptr || (count == 0))
3710 rc = COMMAND_LINE_ERROR;
3717 int (*fkt)(rdpSettings* settings,
const char* value);
3719 const struct app_map amap[] = { {
"tenantid:", FreeRDP_GatewayAvdAadtenantid,
3720 parse_app_option_program },
3721 {
"ad:", FreeRDP_GatewayAzureActiveDirectory, NULL } };
3722 for (
size_t x = 0; x < count; x++)
3724 BOOL handled = FALSE;
3725 const char* val = ptr[x];
3727 if (option_starts_with(
"use-tenantid", val))
3729 PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
3730 if (bval == PARSE_FAIL)
3732 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3740 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3746 for (
size_t y = 0; y < ARRAYSIZE(amap); y++)
3748 const struct app_map* cur = &amap[y];
3749 if (option_starts_with(cur->name, val))
3751 const char* xval = &val[strlen(cur->name)];
3753 rc = cur->fkt(settings, xval);
3757 if (!freerdp_settings_set_value_for_name(settings, name, xval))
3758 rc = COMMAND_LINE_ERROR_MEMORY;
3767 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3774 CommandLineParserFree(ptr);
3780 WINPR_ASSERT(settings);
3783 int rc = CHANNEL_RC_OK;
3785 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3786 if (!ptr || (count == 0))
3787 rc = COMMAND_LINE_ERROR;
3794 int (*fkt)(rdpSettings* settings,
const char* value);
3796 const struct app_map amap[] = { {
"program:", FreeRDP_RemoteApplicationProgram,
3797 parse_app_option_program },
3798 {
"workdir:", FreeRDP_RemoteApplicationWorkingDir, NULL },
3799 {
"name:", FreeRDP_RemoteApplicationName, NULL },
3800 {
"icon:", FreeRDP_RemoteApplicationIcon, NULL },
3801 {
"cmd:", FreeRDP_RemoteApplicationCmdLine, NULL },
3802 {
"file:", FreeRDP_RemoteApplicationFile, NULL },
3803 {
"guid:", FreeRDP_RemoteApplicationGuid, NULL },
3804 {
"hidef:", FreeRDP_HiDefRemoteApp, NULL } };
3805 for (
size_t x = 0; x < count; x++)
3807 BOOL handled = FALSE;
3808 const char* val = ptr[x];
3810 for (
size_t y = 0; y < ARRAYSIZE(amap); y++)
3812 const struct app_map* cur = &amap[y];
3813 if (option_starts_with(cur->name, val))
3815 const char* xval = &val[strlen(cur->name)];
3817 rc = cur->fkt(settings, xval);
3821 if (!freerdp_settings_set_value_for_name(settings, name, xval))
3822 rc = COMMAND_LINE_ERROR_MEMORY;
3830 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
3831 if (!handled && (count == 1))
3834 rc = parse_app_option_program(settings, val);
3839 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3846 CommandLineParserFree(ptr);
3852 WINPR_ASSERT(settings);
3855 int rc = CHANNEL_RC_OK;
3857 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3858 if (!ptr || (count == 0))
3859 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3861 for (
size_t x = 0; x < count; x++)
3863 const char* val = ptr[x];
3865 if (option_starts_with(
"codec:", val))
3868 rc = COMMAND_LINE_ERROR;
3869 else if (option_equals(arg->Value,
"rfx"))
3872 rc = COMMAND_LINE_ERROR;
3874 else if (option_equals(arg->Value,
"nsc"))
3877 rc = COMMAND_LINE_ERROR;
3880 #if defined(WITH_JPEG)
3881 else if (option_equals(arg->Value,
"jpeg"))
3884 rc = COMMAND_LINE_ERROR;
3889 return COMMAND_LINE_ERROR;
3895 else if (option_starts_with(
"persist-file:", val))
3899 rc = COMMAND_LINE_ERROR_MEMORY;
3901 rc = COMMAND_LINE_ERROR;
3905 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
3906 if (bval == PARSE_FAIL)
3907 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3910 if (option_starts_with(
"bitmap", val))
3914 rc = COMMAND_LINE_ERROR;
3916 else if (option_starts_with(
"glyph", val))
3919 bval != PARSE_OFF ? GLYPH_SUPPORT_FULL
3920 : GLYPH_SUPPORT_NONE))
3921 rc = COMMAND_LINE_ERROR;
3923 else if (option_starts_with(
"persist", val))
3927 rc = COMMAND_LINE_ERROR;
3929 else if (option_starts_with(
"offscreen", val))
3933 rc = COMMAND_LINE_ERROR;
3939 CommandLineParserFree(ptr);
3943 static BOOL parse_gateway_host_option(rdpSettings* settings,
const char* host)
3945 WINPR_ASSERT(settings);
3950 if (!freerdp_parse_hostname(host, &name, &port))
3964 static BOOL parse_gateway_cred_option(rdpSettings* settings,
const char* value,
3965 FreeRDP_Settings_Keys_String what)
3967 WINPR_ASSERT(settings);
3968 WINPR_ASSERT(value);
3972 case FreeRDP_GatewayUsername:
3973 if (!freerdp_parse_username_settings(value, settings, FreeRDP_GatewayUsername,
3974 FreeRDP_GatewayDomain))
3986 static BOOL parse_gateway_type_option(rdpSettings* settings,
const char* value)
3988 WINPR_ASSERT(settings);
3989 WINPR_ASSERT(value);
3991 if (option_equals(value,
"rpc"))
4001 if (option_equals(value,
"http"))
4008 else if (option_equals(value,
"auto"))
4015 else if (option_equals(value,
"arm"))
4027 static BOOL parse_gateway_usage_option(rdpSettings* settings,
const char* value)
4031 WINPR_ASSERT(settings);
4032 WINPR_ASSERT(value);
4034 if (option_equals(value,
"none"))
4035 type = TSC_PROXY_MODE_NONE_DIRECT;
4036 else if (option_equals(value,
"direct"))
4037 type = TSC_PROXY_MODE_DIRECT;
4038 else if (option_equals(value,
"detect"))
4039 type = TSC_PROXY_MODE_DETECT;
4040 else if (option_equals(value,
"default"))
4041 type = TSC_PROXY_MODE_DEFAULT;
4046 if (!value_to_int(value, &val, TSC_PROXY_MODE_NONE_DIRECT, TSC_PROXY_MODE_NONE_DETECT))
4057 WINPR_ASSERT(settings);
4061 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
4069 BOOL allowHttpOpts = FALSE;
4070 for (
size_t x = 0; x < count; x++)
4072 BOOL validOption = FALSE;
4073 const char* argval = ptr[x];
4075 WINPR_ASSERT(argval);
4077 const char* gw = option_starts_with(
"g:", argval);
4080 if (!parse_gateway_host_option(settings, gw))
4083 allowHttpOpts = FALSE;
4086 const char* gu = option_starts_with(
"u:", argval);
4089 if (!parse_gateway_cred_option(settings, gu, FreeRDP_GatewayUsername))
4092 allowHttpOpts = FALSE;
4095 const char* gd = option_starts_with(
"d:", argval);
4098 if (!parse_gateway_cred_option(settings, gd, FreeRDP_GatewayDomain))
4101 allowHttpOpts = FALSE;
4104 const char* gp = option_starts_with(
"p:", argval);
4107 if (!parse_gateway_cred_option(settings, gp, FreeRDP_GatewayPassword))
4110 allowHttpOpts = FALSE;
4113 const char* gt = option_starts_with(
"type:", argval);
4116 if (!parse_gateway_type_option(settings, gt))
4122 const char* gat = option_starts_with(
"access-token:", argval);
4128 allowHttpOpts = FALSE;
4131 const char* bearer = option_starts_with(
"bearer:", argval);
4137 allowHttpOpts = FALSE;
4140 const char* gwurl = option_starts_with(
"url:", argval);
4148 allowHttpOpts = FALSE;
4151 const char* um = option_starts_with(
"usage-method:", argval);
4154 if (!parse_gateway_usage_option(settings, um))
4157 allowHttpOpts = FALSE;
4162 if (option_equals(argval,
"no-websockets"))
4168 else if (option_equals(argval,
"extauth-sspi-ntlm"))
4182 CommandLineParserFree(ptr);
4189 WINPR_ASSERT(value);
4195 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
4196 FillMemory(arg->Value, strlen(arg->Value),
'*');
4201 const char* credentials[] = {
4204 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
4213 for (
size_t x = 0; x < ARRAYSIZE(credentials); x++)
4215 const char* cred = credentials[x];
4216 fill_credential_string(args, cred);
4220 if (arg && ((arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT) != 0))
4222 const char* gwcreds[] = {
"p:",
"access-token:" };
4223 char* saveptr = NULL;
4224 char* tok = strtok_s(arg->Value,
",", &saveptr);
4227 for (
size_t x = 0; x < ARRAYSIZE(gwcreds); x++)
4229 const char* opt = gwcreds[x];
4230 if (option_starts_with(opt, tok))
4232 char* val = &tok[strlen(opt)];
4233 FillMemory(val, strlen(val),
'*');
4236 tok = strtok_s(NULL,
",", &saveptr);
4241 static int freerdp_client_settings_parse_command_line_arguments_int(
4242 rdpSettings* settings,
int argc,
char* argv[], BOOL allowUnknown,
4249 BOOL assist = FALSE;
4251 BOOL promptForPassword = FALSE;
4252 BOOL compatibility = FALSE;
4260 ext = option_is_rdp_file(argv[1]);
4261 assist = option_is_incident_file(argv[1]);
4264 if (!ext && !assist)
4265 compatibility = freerdp_client_detect_command_line(argc, argv, &flags);
4267 compatibility = freerdp_client_detect_command_line(argc - 1, &argv[1], &flags);
4278 WLog_WARN(TAG,
"Unsupported command line syntax!");
4279 WLog_WARN(TAG,
"FreeRDP 1.0 style syntax was dropped with version 3!");
4285 flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
4289 if (freerdp_client_settings_parse_connection_file(settings, argv[1]))
4290 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
4295 if (freerdp_client_settings_parse_assistance_file(settings, argc, argv) < 0)
4296 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
4299 CommandLineClearArgumentsA(largs);
4300 status = CommandLineParseArgumentsA(argc, argv, largs, flags, settings,
4301 freerdp_client_command_line_pre_filter,
4302 freerdp_client_command_line_post_filter);
4307 prepare_default_settings(settings, largs, ext);
4310 CommandLineFindArgumentA(largs,
"v");
4316 return COMMAND_LINE_ERROR_MEMORY;
4320 BOOL enable = arg->Value ? TRUE : FALSE;
4322 if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
4325 CommandLineSwitchStart(arg)
4327 CommandLineSwitchCase(arg,
"v")
4329 const int rc = parse_host_options(settings, arg);
4331 return fail_at(arg, rc);
4333 CommandLineSwitchCase(arg,
"spn-class")
4337 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4339 CommandLineSwitchCase(arg,
"sspi-module")
4342 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4344 CommandLineSwitchCase(arg,
"winscard-module")
4347 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4349 CommandLineSwitchCase(arg,
"redirect-prefer")
4351 const int rc = parse_redirect_prefer_options(settings, arg);
4353 return fail_at(arg, rc);
4355 CommandLineSwitchCase(arg,
"credentials-delegation")
4358 return fail_at(arg, COMMAND_LINE_ERROR);
4360 CommandLineSwitchCase(arg,
"prevent-session-lock")
4362 const int rc = parse_prevent_session_lock_options(settings, arg);
4364 return fail_at(arg, rc);
4366 CommandLineSwitchCase(arg,
"vmconnect")
4368 const int rc = parse_vmconnect_options(settings, arg);
4370 return fail_at(arg, rc);
4372 CommandLineSwitchCase(arg,
"w")
4376 if (!value_to_int(arg->Value, &val, -1, UINT32_MAX))
4377 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4380 return fail_at(arg, COMMAND_LINE_ERROR);
4382 CommandLineSwitchCase(arg,
"h")
4386 if (!value_to_int(arg->Value, &val, -1, UINT32_MAX))
4387 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4390 return fail_at(arg, COMMAND_LINE_ERROR);
4392 CommandLineSwitchCase(arg,
"size")
4394 const int rc = parse_size_options(settings, arg);
4396 return fail_at(arg, rc);
4398 CommandLineSwitchCase(arg,
"f")
4401 return fail_at(arg, COMMAND_LINE_ERROR);
4403 CommandLineSwitchCase(arg,
"suppress-output")
4406 return fail_at(arg, COMMAND_LINE_ERROR);
4408 CommandLineSwitchCase(arg,
"multimon")
4411 return fail_at(arg, COMMAND_LINE_ERROR);
4413 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
4415 if (option_equals(arg->Value, str_force))
4418 return fail_at(arg, COMMAND_LINE_ERROR);
4422 CommandLineSwitchCase(arg,
"span")
4425 return fail_at(arg, COMMAND_LINE_ERROR);
4427 CommandLineSwitchCase(arg,
"workarea")
4430 return fail_at(arg, COMMAND_LINE_ERROR);
4432 CommandLineSwitchCase(arg,
"monitors")
4434 const int rc = parse_monitors_options(settings, arg);
4436 return fail_at(arg, rc);
4438 CommandLineSwitchCase(arg,
"t")
4441 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4443 CommandLineSwitchCase(arg,
"decorations")
4446 return fail_at(arg, COMMAND_LINE_ERROR);
4448 CommandLineSwitchCase(arg,
"dynamic-resolution")
4450 const int rc = parse_dynamic_resolution_options(settings, arg);
4452 return fail_at(arg, rc);
4454 CommandLineSwitchCase(arg,
"smart-sizing")
4456 const int rc = parse_smart_sizing_options(settings, arg);
4458 return fail_at(arg, rc);
4460 CommandLineSwitchCase(arg,
"bpp")
4462 const int rc = parse_bpp_options(settings, arg);
4464 return fail_at(arg, rc);
4466 CommandLineSwitchCase(arg,
"admin")
4469 return fail_at(arg, COMMAND_LINE_ERROR);
4471 CommandLineSwitchCase(arg,
"relax-order-checks")
4475 return fail_at(arg, COMMAND_LINE_ERROR);
4477 CommandLineSwitchCase(arg,
"restricted-admin")
4480 return fail_at(arg, COMMAND_LINE_ERROR);
4482 return fail_at(arg, COMMAND_LINE_ERROR);
4484 CommandLineSwitchCase(arg,
"remoteGuard")
4487 return fail_at(arg, COMMAND_LINE_ERROR);
4489 return fail_at(arg, COMMAND_LINE_ERROR);
4491 CommandLineSwitchCase(arg,
"pth")
4494 return fail_at(arg, COMMAND_LINE_ERROR);
4496 return fail_at(arg, COMMAND_LINE_ERROR);
4499 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4501 CommandLineSwitchCase(arg,
"client-hostname")
4504 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4506 CommandLineSwitchCase(arg,
"kbd")
4508 int rc = parse_kbd_options(settings, arg);
4510 return fail_at(arg, rc);
4512 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
4513 CommandLineSwitchCase(arg,
"kbd-remap")
4515 WLog_WARN(TAG,
"/kbd-remap:<key>=<value>,<key2>=<value2> is deprecated, use "
4516 "/kbd:remap:<key>=<value>,remap:<key2>=<value2>,... instead");
4518 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4520 CommandLineSwitchCase(arg,
"kbd-lang")
4524 WLog_WARN(TAG,
"/kbd-lang:<value> is deprecated, use /kbd:lang:<value> instead");
4525 if (!value_to_int(arg->Value, &val, 1, UINT32_MAX))
4527 WLog_ERR(TAG,
"Could not identify keyboard active language %s", arg->Value);
4528 WLog_ERR(TAG,
"Use /list:kbd-lang to list available layouts");
4529 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4533 return fail_at(arg, COMMAND_LINE_ERROR);
4535 CommandLineSwitchCase(arg,
"kbd-type")
4539 WLog_WARN(TAG,
"/kbd-type:<value> is deprecated, use /kbd:type:<value> instead");
4540 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
4541 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4544 return fail_at(arg, COMMAND_LINE_ERROR);
4546 CommandLineSwitchCase(arg,
"kbd-unicode")
4548 WLog_WARN(TAG,
"/kbd-unicode is deprecated, use /kbd:unicode[:on|off] instead");
4550 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4552 CommandLineSwitchCase(arg,
"kbd-subtype")
4556 WLog_WARN(TAG,
"/kbd-subtype:<value> is deprecated, use /kbd:subtype:<value> instead");
4557 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
4558 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4561 return fail_at(arg, COMMAND_LINE_ERROR);
4563 CommandLineSwitchCase(arg,
"kbd-fn-key")
4567 WLog_WARN(TAG,
"/kbd-fn-key:<value> is deprecated, use /kbd:fn-key:<value> instead");
4568 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
4569 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4572 return fail_at(arg, COMMAND_LINE_ERROR);
4575 CommandLineSwitchCase(arg,
"u")
4577 WINPR_ASSERT(arg->Value);
4580 CommandLineSwitchCase(arg,
"d")
4583 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4585 CommandLineSwitchCase(arg,
"p")
4588 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4590 CommandLineSwitchCase(arg,
"gateway")
4592 if (!parse_gateway_options(settings, arg))
4593 return fail_at(arg, COMMAND_LINE_ERROR);
4595 CommandLineSwitchCase(arg,
"proxy")
4597 const int rc = parse_proxy_options(settings, arg);
4599 return fail_at(arg, rc);
4601 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
4602 CommandLineSwitchCase(arg,
"g")
4604 if (!parse_gateway_host_option(settings, arg->Value))
4605 return fail_at(arg, COMMAND_LINE_ERROR);
4607 CommandLineSwitchCase(arg,
"gu")
4609 if (!parse_gateway_cred_option(settings, arg->Value, FreeRDP_GatewayUsername))
4610 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4612 CommandLineSwitchCase(arg,
"gd")
4614 if (!parse_gateway_cred_option(settings, arg->Value, FreeRDP_GatewayDomain))
4615 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4617 CommandLineSwitchCase(arg,
"gp")
4619 if (!parse_gateway_cred_option(settings, arg->Value, FreeRDP_GatewayPassword))
4620 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4622 CommandLineSwitchCase(arg,
"gt")
4624 if (!parse_gateway_type_option(settings, arg->Value))
4625 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4627 CommandLineSwitchCase(arg,
"gat")
4630 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4632 CommandLineSwitchCase(arg,
"gateway-usage-method")
4634 if (!parse_gateway_usage_option(settings, arg->Value))
4635 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4638 CommandLineSwitchCase(arg,
"azure")
4640 int rc = parse_aad_options(settings, arg);
4642 return fail_at(arg, rc);
4644 CommandLineSwitchCase(arg,
"app")
4646 int rc = parse_app_options(settings, arg);
4648 return fail_at(arg, rc);
4650 CommandLineSwitchCase(arg,
"load-balance-info")
4652 WINPR_ASSERT(arg->Value);
4654 strlen(arg->Value)))
4655 return fail_at(arg, COMMAND_LINE_ERROR);
4657 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
4658 CommandLineSwitchCase(arg,
"app-workdir")
4662 "/app-workdir:<directory> is deprecated, use /app:workdir:<directory> instead");
4665 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4667 CommandLineSwitchCase(arg,
"app-name")
4669 WLog_WARN(TAG,
"/app-name:<directory> is deprecated, use /app:name:<name> instead");
4671 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4673 CommandLineSwitchCase(arg,
"app-icon")
4675 WLog_WARN(TAG,
"/app-icon:<filename> is deprecated, use /app:icon:<filename> instead");
4677 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4679 CommandLineSwitchCase(arg,
"app-cmd")
4681 WLog_WARN(TAG,
"/app-cmd:<command> is deprecated, use /app:cmd:<command> instead");
4684 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4686 CommandLineSwitchCase(arg,
"app-file")
4688 WLog_WARN(TAG,
"/app-file:<filename> is deprecated, use /app:file:<filename> instead");
4690 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4692 CommandLineSwitchCase(arg,
"app-guid")
4694 WLog_WARN(TAG,
"/app-guid:<guid> is deprecated, use /app:guid:<guid> instead");
4696 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4699 CommandLineSwitchCase(arg,
"compression")
4702 return fail_at(arg, COMMAND_LINE_ERROR);
4704 CommandLineSwitchCase(arg,
"compression-level")
4708 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
4709 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4712 return fail_at(arg, COMMAND_LINE_ERROR);
4714 CommandLineSwitchCase(arg,
"drives")
4717 return fail_at(arg, COMMAND_LINE_ERROR);
4719 CommandLineSwitchCase(arg,
"dump")
4721 const int rc = parse_dump_options(settings, arg);
4723 return fail_at(arg, rc);
4725 CommandLineSwitchCase(arg,
"disable-output")
4728 return fail_at(arg, COMMAND_LINE_ERROR);
4730 CommandLineSwitchCase(arg,
"home-drive")
4733 return fail_at(arg, COMMAND_LINE_ERROR);
4735 CommandLineSwitchCase(arg,
"ipv4")
4737 if (arg->Value != NULL && strncmp(arg->Value, str_force, ARRAYSIZE(str_force)) == 0)
4740 return fail_at(arg, COMMAND_LINE_ERROR);
4745 return fail_at(arg, COMMAND_LINE_ERROR);
4748 CommandLineSwitchCase(arg,
"ipv6")
4750 if (arg->Value != NULL && strncmp(arg->Value, str_force, ARRAYSIZE(str_force)) == 0)
4753 return fail_at(arg, COMMAND_LINE_ERROR);
4758 return fail_at(arg, COMMAND_LINE_ERROR);
4761 CommandLineSwitchCase(arg,
"clipboard")
4763 const int rc = parse_clipboard_options(settings, arg);
4765 return fail_at(arg, rc);
4767 CommandLineSwitchCase(arg,
"server-name")
4770 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4772 CommandLineSwitchCase(arg,
"shell")
4775 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4777 CommandLineSwitchCase(arg,
"shell-dir")
4780 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4782 CommandLineSwitchCase(arg,
"audio-mode")
4784 const int rc = parse_audio_mode_options(settings, arg);
4786 return fail_at(arg, rc);
4788 CommandLineSwitchCase(arg,
"network")
4790 const int rc = parse_network_options(settings, arg);
4792 return fail_at(arg, rc);
4794 CommandLineSwitchCase(arg,
"fonts")
4797 return fail_at(arg, COMMAND_LINE_ERROR);
4799 CommandLineSwitchCase(arg,
"wallpaper")
4802 return fail_at(arg, COMMAND_LINE_ERROR);
4804 CommandLineSwitchCase(arg,
"window-drag")
4807 return fail_at(arg, COMMAND_LINE_ERROR);
4809 CommandLineSwitchCase(arg,
"window-position")
4811 unsigned long x = 0;
4812 unsigned long y = 0;
4815 return fail_at(arg, COMMAND_LINE_ERROR_MISSING_ARGUMENT);
4817 if (!parseSizeValue(arg->Value, &x, &y) || x > UINT16_MAX || y > UINT16_MAX)
4819 WLog_ERR(TAG,
"invalid window-position argument");
4820 return fail_at(arg, COMMAND_LINE_ERROR_MISSING_ARGUMENT);
4824 return fail_at(arg, COMMAND_LINE_ERROR);
4826 return fail_at(arg, COMMAND_LINE_ERROR);
4828 CommandLineSwitchCase(arg,
"menu-anims")
4831 return fail_at(arg, COMMAND_LINE_ERROR);
4833 CommandLineSwitchCase(arg,
"themes")
4836 return fail_at(arg, COMMAND_LINE_ERROR);
4838 CommandLineSwitchCase(arg,
"timeout")
4841 if (!value_to_uint(arg->Value, &val, 1, 600000))
4842 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4844 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4846 CommandLineSwitchCase(arg,
"timezone")
4851 char TimeZoneKeyName[ARRAYSIZE(info.TimeZoneKeyName) + 1] = { 0 };
4852 while (EnumDynamicTimeZoneInformation(index++, &info) != ERROR_NO_MORE_ITEMS)
4854 (void)ConvertWCharNToUtf8(info.TimeZoneKeyName, ARRAYSIZE(info.TimeZoneKeyName),
4855 TimeZoneKeyName, ARRAYSIZE(TimeZoneKeyName));
4857 WINPR_ASSERT(arg->Value);
4858 if (strncmp(TimeZoneKeyName, arg->Value, ARRAYSIZE(TimeZoneKeyName)) == 0)
4865 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4869 return fail_at(arg, COMMAND_LINE_ERROR);
4874 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4876 tz->Bias = info.Bias;
4877 tz->DaylightBias = info.DaylightBias;
4878 tz->DaylightDate = info.DaylightDate;
4879 memcpy(tz->DaylightName, info.DaylightName,
sizeof(tz->DaylightName));
4880 tz->StandardBias = info.StandardBias;
4881 tz->StandardDate = info.StandardDate;
4882 memcpy(tz->StandardName, info.StandardName,
sizeof(tz->StandardName));
4884 CommandLineSwitchCase(arg,
"aero")
4887 return fail_at(arg, COMMAND_LINE_ERROR);
4889 CommandLineSwitchCase(arg,
"gdi")
4891 if (option_equals(arg->Value,
"sw"))
4894 return fail_at(arg, COMMAND_LINE_ERROR);
4896 else if (option_equals(arg->Value,
"hw"))
4899 return fail_at(arg, COMMAND_LINE_ERROR);
4902 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4904 CommandLineSwitchCase(arg,
"gfx")
4906 int rc = parse_gfx_options(settings, arg);
4908 return fail_at(arg, rc);
4910 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
4911 CommandLineSwitchCase(arg,
"gfx-thin-client")
4913 WLog_WARN(TAG,
"/gfx-thin-client is deprecated, use /gfx:thin-client[:on|off] instead");
4915 return fail_at(arg, COMMAND_LINE_ERROR);
4920 return fail_at(arg, COMMAND_LINE_ERROR);
4924 return fail_at(arg, COMMAND_LINE_ERROR);
4926 CommandLineSwitchCase(arg,
"gfx-small-cache")
4928 WLog_WARN(TAG,
"/gfx-small-cache is deprecated, use /gfx:small-cache[:on|off] instead");
4930 return fail_at(arg, COMMAND_LINE_ERROR);
4934 return fail_at(arg, COMMAND_LINE_ERROR);
4936 CommandLineSwitchCase(arg,
"gfx-progressive")
4938 WLog_WARN(TAG,
"/gfx-progressive is deprecated, use /gfx:progressive[:on|off] instead");
4940 return fail_at(arg, COMMAND_LINE_ERROR);
4942 return fail_at(arg, COMMAND_LINE_ERROR);
4947 return fail_at(arg, COMMAND_LINE_ERROR);
4950 #ifdef WITH_GFX_H264
4951 CommandLineSwitchCase(arg,
"gfx-h264")
4953 WLog_WARN(TAG,
"/gfx-h264 is deprecated, use /gfx:avc420 instead");
4954 int rc = parse_gfx_options(settings, arg);
4956 return fail_at(arg, rc);
4960 CommandLineSwitchCase(arg,
"rfx")
4963 return fail_at(arg, COMMAND_LINE_ERROR);
4965 CommandLineSwitchCase(arg,
"rfx-mode")
4968 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4970 if (option_equals(arg->Value,
"video"))
4973 return fail_at(arg, COMMAND_LINE_ERROR);
4975 else if (option_equals(arg->Value,
"image"))
4978 return fail_at(arg, COMMAND_LINE_ERROR);
4980 return fail_at(arg, COMMAND_LINE_ERROR);
4983 CommandLineSwitchCase(arg,
"frame-ack")
4987 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
4988 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4991 return fail_at(arg, COMMAND_LINE_ERROR);
4993 CommandLineSwitchCase(arg,
"nsc")
4996 return fail_at(arg, COMMAND_LINE_ERROR);
4998 #if defined(WITH_JPEG)
4999 CommandLineSwitchCase(arg,
"jpeg")
5002 return fail_at(arg, COMMAND_LINE_ERROR);
5004 return fail_at(arg, COMMAND_LINE_ERROR);
5006 CommandLineSwitchCase(arg,
"jpeg-quality")
5010 if (!value_to_int(arg->Value, &val, 0, 100))
5011 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5014 return fail_at(arg, COMMAND_LINE_ERROR);
5017 CommandLineSwitchCase(arg,
"nego")
5020 return fail_at(arg, COMMAND_LINE_ERROR);
5022 CommandLineSwitchCase(arg,
"pcb")
5025 return fail_at(arg, COMMAND_LINE_ERROR);
5028 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5030 CommandLineSwitchCase(arg,
"pcid")
5034 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
5035 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5038 return fail_at(arg, COMMAND_LINE_ERROR);
5040 return fail_at(arg, COMMAND_LINE_ERROR);
5043 CommandLineSwitchCase(arg,
"connect-child-session")
5057 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5060 CommandLineSwitchCase(arg,
"sec")
5062 const int rc = parse_sec_options(settings, arg);
5064 return fail_at(arg, rc);
5066 CommandLineSwitchCase(arg,
"encryption-methods")
5068 const int rc = parse_encryption_methods_options(settings, arg);
5070 return fail_at(arg, rc);
5072 CommandLineSwitchCase(arg,
"args-from")
5074 WLog_ERR(TAG,
"/args-from:%s can not be used in combination with other arguments!",
5076 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5078 CommandLineSwitchCase(arg,
"from-stdin")
5081 return fail_at(arg, COMMAND_LINE_ERROR);
5083 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
5086 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5087 promptForPassword = (option_equals(arg->Value, str_force));
5089 if (!promptForPassword)
5090 return fail_at(arg, COMMAND_LINE_ERROR);
5093 CommandLineSwitchCase(arg,
"log-level")
5095 wLog* root = WLog_GetRoot();
5097 if (!WLog_SetStringLogLevel(root, arg->Value))
5098 return fail_at(arg, COMMAND_LINE_ERROR);
5100 CommandLineSwitchCase(arg,
"log-filters")
5102 if (!WLog_AddStringLogFilters(arg->Value))
5103 return fail_at(arg, COMMAND_LINE_ERROR);
5105 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
5106 CommandLineSwitchCase(arg,
"sec-rdp")
5108 WLog_WARN(TAG,
"/sec-rdp is deprecated, use /sec:rdp[:on|off] instead");
5110 return fail_at(arg, COMMAND_LINE_ERROR);
5112 CommandLineSwitchCase(arg,
"sec-tls")
5114 WLog_WARN(TAG,
"/sec-tls is deprecated, use /sec:tls[:on|off] instead");
5116 return fail_at(arg, COMMAND_LINE_ERROR);
5118 CommandLineSwitchCase(arg,
"sec-nla")
5120 WLog_WARN(TAG,
"/sec-nla is deprecated, use /sec:nla[:on|off] instead");
5122 return fail_at(arg, COMMAND_LINE_ERROR);
5124 CommandLineSwitchCase(arg,
"sec-ext")
5126 WLog_WARN(TAG,
"/sec-ext is deprecated, use /sec:ext[:on|off] instead");
5128 return fail_at(arg, COMMAND_LINE_ERROR);
5131 CommandLineSwitchCase(arg,
"tls")
5133 int rc = parse_tls_options(settings, arg);
5135 return fail_at(arg, rc);
5137 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
5138 CommandLineSwitchCase(arg,
"tls-ciphers")
5140 WLog_WARN(TAG,
"/tls-ciphers:<cipher list> is deprecated, use "
5141 "/tls:ciphers:<cipher list> instead");
5142 int rc = parse_tls_cipher_options(settings, arg);
5144 return fail_at(arg, rc);
5146 CommandLineSwitchCase(arg,
"tls-seclevel")
5149 "/tls-seclevel:<level> is deprecated, use /tls:sec-level:<level> instead");
5150 int rc = parse_tls_cipher_options(settings, arg);
5152 return fail_at(arg, rc);
5154 CommandLineSwitchCase(arg,
"tls-secrets-file")
5156 WLog_WARN(TAG,
"/tls-secrets-file:<filename> is deprecated, use "
5157 "/tls:secrets-file:<filename> instead");
5158 int rc = parse_tls_cipher_options(settings, arg);
5160 return fail_at(arg, rc);
5162 CommandLineSwitchCase(arg,
"enforce-tlsv1_2")
5164 WLog_WARN(TAG,
"/enforce-tlsv1_2 is deprecated, use /tls:enforce:1.2 instead");
5165 int rc = parse_tls_cipher_options(settings, arg);
5167 return fail_at(arg, rc);
5170 CommandLineSwitchCase(arg,
"cert")
5172 const int rc = parse_cert_options(settings, arg);
5174 return fail_at(arg, rc);
5177 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
5178 CommandLineSwitchCase(arg,
"cert-name")
5180 WLog_WARN(TAG,
"/cert-name is deprecated, use /cert:name instead");
5182 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5184 CommandLineSwitchCase(arg,
"cert-ignore")
5186 WLog_WARN(TAG,
"/cert-ignore is deprecated, use /cert:ignore instead");
5188 return fail_at(arg, COMMAND_LINE_ERROR);
5190 CommandLineSwitchCase(arg,
"cert-tofu")
5192 WLog_WARN(TAG,
"/cert-tofu is deprecated, use /cert:tofu instead");
5194 return fail_at(arg, COMMAND_LINE_ERROR);
5196 CommandLineSwitchCase(arg,
"cert-deny")
5198 WLog_WARN(TAG,
"/cert-deny is deprecated, use /cert:deny instead");
5200 return fail_at(arg, COMMAND_LINE_ERROR);
5203 CommandLineSwitchCase(arg,
"authentication")
5206 return fail_at(arg, COMMAND_LINE_ERROR);
5208 CommandLineSwitchCase(arg,
"encryption")
5211 return fail_at(arg, COMMAND_LINE_ERROR);
5213 CommandLineSwitchCase(arg,
"grab-keyboard")
5216 return fail_at(arg, COMMAND_LINE_ERROR);
5218 CommandLineSwitchCase(arg,
"grab-mouse")
5221 return fail_at(arg, COMMAND_LINE_ERROR);
5223 CommandLineSwitchCase(arg,
"mouse-relative")
5226 return fail_at(arg, COMMAND_LINE_ERROR);
5228 CommandLineSwitchCase(arg,
"mouse")
5230 const int rc = parse_mouse_options(settings, arg);
5232 return fail_at(arg, rc);
5234 CommandLineSwitchCase(arg,
"unmap-buttons")
5237 return fail_at(arg, COMMAND_LINE_ERROR);
5239 CommandLineSwitchCase(arg,
"toggle-fullscreen")
5242 return fail_at(arg, COMMAND_LINE_ERROR);
5244 CommandLineSwitchCase(arg,
"force-console-callbacks")
5247 return fail_at(arg, COMMAND_LINE_ERROR);
5249 CommandLineSwitchCase(arg,
"floatbar")
5251 const int rc = parse_floatbar_options(settings, arg);
5253 return fail_at(arg, rc);
5255 CommandLineSwitchCase(arg,
"mouse-motion")
5258 return fail_at(arg, COMMAND_LINE_ERROR);
5260 CommandLineSwitchCase(arg,
"parent-window")
5264 if (!value_to_uint(arg->Value, &val, 0, UINT64_MAX))
5265 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5268 return fail_at(arg, COMMAND_LINE_ERROR);
5270 CommandLineSwitchCase(arg,
"client-build-number")
5274 if (!value_to_uint(arg->Value, &val, 0, UINT32_MAX))
5275 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5277 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5279 CommandLineSwitchCase(arg,
"cache")
5281 int rc = parse_cache_options(settings, arg);
5283 return fail_at(arg, rc);
5285 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
5286 CommandLineSwitchCase(arg,
"bitmap-cache")
5288 WLog_WARN(TAG,
"/bitmap-cache is deprecated, use /cache:bitmap[:on|off] instead");
5290 return fail_at(arg, COMMAND_LINE_ERROR);
5292 CommandLineSwitchCase(arg,
"persist-cache")
5294 WLog_WARN(TAG,
"/persist-cache is deprecated, use /cache:persist[:on|off] instead");
5296 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5298 CommandLineSwitchCase(arg,
"persist-cache-file")
5300 WLog_WARN(TAG,
"/persist-cache-file:<filename> is deprecated, use "
5301 "/cache:persist-file:<filename> instead");
5303 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5306 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5308 CommandLineSwitchCase(arg,
"offscreen-cache")
5310 WLog_WARN(TAG,
"/bitmap-cache is deprecated, use /cache:bitmap[:on|off] instead");
5313 return fail_at(arg, COMMAND_LINE_ERROR);
5315 CommandLineSwitchCase(arg,
"glyph-cache")
5317 WLog_WARN(TAG,
"/glyph-cache is deprecated, use /cache:glyph[:on|off] instead");
5319 arg->Value ? GLYPH_SUPPORT_FULL : GLYPH_SUPPORT_NONE))
5320 return fail_at(arg, COMMAND_LINE_ERROR);
5322 CommandLineSwitchCase(arg,
"codec-cache")
5325 "/codec-cache:<option> is deprecated, use /cache:codec:<option> instead");
5326 const int rc = parse_codec_cache_options(settings, arg);
5328 return fail_at(arg, rc);
5331 CommandLineSwitchCase(arg,
"max-fast-path-size")
5335 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
5336 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5340 return fail_at(arg, COMMAND_LINE_ERROR);
5342 CommandLineSwitchCase(arg,
"auto-request-control")
5346 return fail_at(arg, COMMAND_LINE_ERROR);
5348 CommandLineSwitchCase(arg,
"async-update")
5351 return fail_at(arg, COMMAND_LINE_ERROR);
5353 CommandLineSwitchCase(arg,
"async-channels")
5356 return fail_at(arg, COMMAND_LINE_ERROR);
5358 CommandLineSwitchCase(arg,
"wm-class")
5361 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5363 CommandLineSwitchCase(arg,
"play-rfx")
5366 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5369 return fail_at(arg, COMMAND_LINE_ERROR);
5371 CommandLineSwitchCase(arg,
"auth-only")
5374 return fail_at(arg, COMMAND_LINE_ERROR);
5376 CommandLineSwitchCase(arg,
"auth-pkg-list")
5380 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5382 CommandLineSwitchCase(arg,
"auto-reconnect")
5385 return fail_at(arg, COMMAND_LINE_ERROR);
5387 CommandLineSwitchCase(arg,
"auto-reconnect-max-retries")
5391 if (!value_to_int(arg->Value, &val, 0, 1000))
5392 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5396 return fail_at(arg, COMMAND_LINE_ERROR);
5398 CommandLineSwitchCase(arg,
"reconnect-cookie")
5400 const int rc = parse_reconnect_cookie_options(settings, arg);
5402 return fail_at(arg, rc);
5404 CommandLineSwitchCase(arg,
"print-reconnect-cookie")
5407 return fail_at(arg, COMMAND_LINE_ERROR);
5409 CommandLineSwitchCase(arg,
"pwidth")
5413 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
5414 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5417 return fail_at(arg, COMMAND_LINE_ERROR);
5419 CommandLineSwitchCase(arg,
"pheight")
5423 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
5424 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5427 return fail_at(arg, COMMAND_LINE_ERROR);
5429 CommandLineSwitchCase(arg,
"orientation")
5433 if (!value_to_int(arg->Value, &val, 0, UINT16_MAX))
5434 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5437 return fail_at(arg, COMMAND_LINE_ERROR);
5439 CommandLineSwitchCase(arg,
"old-license")
5442 return fail_at(arg, COMMAND_LINE_ERROR);
5444 CommandLineSwitchCase(arg,
"scale")
5446 const int rc = parse_scale_options(settings, arg);
5448 return fail_at(arg, rc);
5450 CommandLineSwitchCase(arg,
"scale-desktop")
5454 if (!value_to_int(arg->Value, &val, 100, 500))
5455 return fail_at(arg, COMMAND_LINE_ERROR);
5458 return fail_at(arg, COMMAND_LINE_ERROR);
5460 CommandLineSwitchCase(arg,
"scale-device")
5462 const int rc = parse_scale_device_options(settings, arg);
5464 return fail_at(arg, rc);
5466 CommandLineSwitchCase(arg,
"action-script")
5469 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5471 CommandLineSwitchCase(arg, RDP2TCP_DVC_CHANNEL_NAME)
5474 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5476 CommandLineSwitchCase(arg,
"fipsmode")
5479 return fail_at(arg, COMMAND_LINE_ERROR);
5481 CommandLineSwitchCase(arg,
"smartcard-logon")
5483 const int rc = parse_smartcard_logon_options(settings, arg);
5485 return fail_at(arg, rc);
5487 CommandLineSwitchCase(arg,
"tune")
5489 const int rc = parse_tune_options(settings, arg);
5491 return fail_at(arg, rc);
5493 CommandLineSwitchDefault(arg)
5497 const int rc = handle_option(arg, handle_userdata);
5499 return fail_at(arg, rc);
5502 CommandLineSwitchEnd(arg)
5503 }
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
5510 return COMMAND_LINE_ERROR;
5513 return COMMAND_LINE_ERROR;
5515 if (!freerdp_parse_username_settings(user, settings, FreeRDP_Username, FreeRDP_Domain))
5516 return COMMAND_LINE_ERROR;
5521 return COMMAND_LINE_ERROR;
5525 if (promptForPassword)
5530 char buffer[512 + 1] = { 0 };
5532 if (!freerdp_passphrase_read(instance->context,
"Password: ", buffer,
5533 ARRAYSIZE(buffer) - 1, 1))
5534 return COMMAND_LINE_ERROR;
5536 return COMMAND_LINE_ERROR;
5544 char buffer[512 + 1] = { 0 };
5546 if (!freerdp_passphrase_read(instance->context,
"Gateway Password: ", buffer,
5547 ARRAYSIZE(buffer) - 1, 1))
5548 return COMMAND_LINE_ERROR;
5550 return COMMAND_LINE_ERROR;
5555 freerdp_performance_flags_make(settings);
5562 return COMMAND_LINE_ERROR;
5564 return COMMAND_LINE_ERROR;
5567 arg = CommandLineFindArgumentA(largs,
"port");
5568 if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
5572 if (!value_to_int(arg->Value, &val, 1, UINT16_MAX))
5573 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5576 return fail_at(arg, COMMAND_LINE_ERROR);
5583 return fail_at(arg, COMMAND_LINE_ERROR);
5586 WLog_INFO(TAG,
"/vmconnect uses custom port %" PRIu32, port);
5589 fill_credential_strings(largs);
5594 static void argv_free(
int* pargc,
char** pargv[])
5596 WINPR_ASSERT(pargc);
5597 WINPR_ASSERT(pargv);
5598 const int argc = *pargc;
5599 char** argv = *pargv;
5605 for (
int x = 0; x < argc; x++)
5610 static BOOL argv_append(
int* pargc,
char** pargv[],
char* what)
5612 WINPR_ASSERT(pargc);
5613 WINPR_ASSERT(pargv);
5621 int nargc = *pargc + 1;
5622 char** tmp = (
char**)realloc((
void*)*pargv, (size_t)nargc *
sizeof(
char*));
5632 static BOOL argv_append_dup(
int* pargc,
char** pargv[],
const char* what)
5636 copy = _strdup(what);
5638 const BOOL rc = argv_append(pargc, pargv, copy);
5644 static BOOL args_from_fp(FILE* fp,
int* aargc,
char** aargv[],
const char* file,
const char* cmd)
5646 BOOL success = FALSE;
5648 WINPR_ASSERT(aargc);
5649 WINPR_ASSERT(aargv);
5654 WLog_ERR(TAG,
"Failed to read command line options from file '%s'", file);
5657 if (!argv_append_dup(aargc, aargv, cmd))
5663 INT64 rc = GetLine(&line, &size, fp);
5664 if ((rc < 0) || !line)
5674 const char cur = (line[rc - 1]);
5675 if ((cur ==
'\n') || (cur ==
'\r'))
5677 line[rc - 1] =
'\0';
5689 if (!argv_append(aargc, aargv, line))
5700 argv_free(aargc, aargv);
5704 static BOOL args_from_env(
const char* name,
int* aargc,
char** aargv[],
const char* arg,
5707 BOOL success = FALSE;
5710 WINPR_ASSERT(aargc);
5711 WINPR_ASSERT(aargv);
5716 WLog_ERR(TAG,
"%s - environment variable name empty", arg);
5720 const DWORD size = GetEnvironmentVariableX(name, env, 0);
5723 WLog_ERR(TAG,
"%s - no environment variable '%s'", arg, name);
5726 env = calloc(size + 1,
sizeof(
char));
5729 const DWORD rc = GetEnvironmentVariableX(name, env, size);
5734 WLog_ERR(TAG,
"%s - environment variable '%s' is empty", arg);
5738 if (!argv_append_dup(aargc, aargv, cmd))
5741 char* context = NULL;
5742 char* tok = strtok_s(env,
"\n", &context);
5745 if (!argv_append_dup(aargc, aargv, tok))
5747 tok = strtok_s(NULL,
"\n", &context);
5754 argv_free(aargc, aargv);
5758 int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
int oargc,
5759 char* oargv[], BOOL allowUnknown)
5761 return freerdp_client_settings_parse_command_line_arguments_ex(
5762 settings, oargc, oargv, allowUnknown, NULL, 0, NULL, NULL);
5765 int freerdp_client_settings_parse_command_line_arguments_ex(
5766 rdpSettings* settings,
int oargc,
char** oargv, BOOL allowUnknown,
5771 char** argv = oargv;
5774 char** aargv = NULL;
5775 if ((argc == 2) && option_starts_with(
"/args-from:", argv[1]))
5777 BOOL success = FALSE;
5778 const char* file = strchr(argv[1],
':') + 1;
5781 if (option_starts_with(
"fd:", file))
5783 ULONGLONG result = 0;
5784 const char* val = strchr(file,
':') + 1;
5785 if (!value_to_uint(val, &result, 0, INT_MAX))
5787 fp = fdopen((
int)result,
"r");
5788 success = args_from_fp(fp, &aargc, &aargv, file, oargv[0]);
5790 else if (strncmp(file,
"env:", 4) == 0)
5792 const char* name = strchr(file,
':') + 1;
5793 success = args_from_env(name, &aargc, &aargv, oargv[1], oargv[0]);
5795 else if (strcmp(file,
"stdin") != 0)
5797 fp = winpr_fopen(file,
"r");
5798 success = args_from_fp(fp, &aargc, &aargv, file, oargv[0]);
5801 success = args_from_fp(fp, &aargc, &aargv, file, oargv[0]);
5809 WINPR_ASSERT(count <= SSIZE_MAX);
5815 res = freerdp_client_settings_parse_command_line_arguments_int(
5816 settings, argc, argv, allowUnknown, largs, lcount, handle_option, handle_userdata);
5819 argv_free(&aargc, &aargv);
5823 static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels, rdpSettings* settings,
5824 const char* name,
void* data)
5826 PVIRTUALCHANNELENTRY entry = NULL;
5827 PVIRTUALCHANNELENTRY pvce = freerdp_load_channel_addin_entry(
5828 name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX);
5829 PVIRTUALCHANNELENTRYEX pvceex = WINPR_FUNC_PTR_CAST(pvce, PVIRTUALCHANNELENTRYEX);
5832 entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC);
5836 if (freerdp_channels_client_load_ex(channels, settings, pvceex, data) == 0)
5838 WLog_DBG(TAG,
"loading channelEx %s", name);
5844 if (freerdp_channels_client_load(channels, settings, entry, data) == 0)
5846 WLog_DBG(TAG,
"loading channel %s", name);
5856 FreeRDP_Settings_Keys_Bool settingId;
5857 const char* channelName;
5861 BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
5863 ChannelToLoad dynChannels[] = {
5864 #if defined(CHANNEL_AINPUT_CLIENT)
5865 { FreeRDP_BOOL_UNUSED, AINPUT_CHANNEL_NAME, NULL },
5867 { FreeRDP_AudioCapture, AUDIN_CHANNEL_NAME, NULL },
5868 { FreeRDP_AudioPlayback, RDPSND_CHANNEL_NAME, NULL },
5869 #ifdef CHANNEL_RDPEI_CLIENT
5870 { FreeRDP_MultiTouchInput, RDPEI_CHANNEL_NAME, NULL },
5872 { FreeRDP_SupportGraphicsPipeline, RDPGFX_CHANNEL_NAME, NULL },
5873 { FreeRDP_SupportEchoChannel, ECHO_CHANNEL_NAME, NULL },
5874 { FreeRDP_SupportSSHAgentChannel,
"sshagent", NULL },
5875 { FreeRDP_SupportDisplayControl, DISP_CHANNEL_NAME, NULL },
5876 { FreeRDP_SupportGeometryTracking, GEOMETRY_CHANNEL_NAME, NULL },
5877 { FreeRDP_SupportVideoOptimized, VIDEO_CHANNEL_NAME, NULL },
5878 { FreeRDP_RemoteCredentialGuard, RDPEAR_CHANNEL_NAME, NULL },
5881 ChannelToLoad staticChannels[] = {
5882 { FreeRDP_AudioPlayback, RDPSND_CHANNEL_NAME, NULL },
5883 { FreeRDP_RedirectClipboard, CLIPRDR_SVC_CHANNEL_NAME, NULL },
5884 #if defined(CHANNEL_ENCOMSP_CLIENT)
5885 { FreeRDP_EncomspVirtualChannel, ENCOMSP_SVC_CHANNEL_NAME, settings },
5887 { FreeRDP_RemdeskVirtualChannel, REMDESK_SVC_CHANNEL_NAME, settings },
5888 { FreeRDP_RemoteApplicationMode, RAIL_SVC_CHANNEL_NAME, settings }
5894 for (
size_t i = 0; i < ARRAYSIZE(dynChannels); i++)
5896 if ((dynChannels[i].settingId == FreeRDP_BOOL_UNUSED) ||
5899 const char*
const p[] = { dynChannels[i].channelName };
5901 if (!freerdp_client_add_dynamic_channel(settings, ARRAYSIZE(p), p))
5909 if ((freerdp_static_channel_collection_find(settings, RDPSND_CHANNEL_NAME)) ||
5910 (freerdp_dynamic_channel_collection_find(settings, RDPSND_CHANNEL_NAME))
5911 #
if defined(CHANNEL_TSMF_CLIENT)
5912 || (freerdp_dynamic_channel_collection_find(settings,
"tsmf"))
5922 if (freerdp_dynamic_channel_collection_find(settings, AUDIN_CHANNEL_NAME))
5938 if (DrivesToRedirect && (strlen(DrivesToRedirect) != 0))
5948 char* context = NULL;
5950 value = _strdup(DrivesToRedirect);
5954 tok = strtok_s(value,
";", &context);
5957 WLog_ERR(TAG,
"DrivesToRedirect contains invalid data: '%s'", DrivesToRedirect);
5974 const char* name = NULL;
5975 const char* drive = tok;
5976 char* subcontext = NULL;
5977 char* start = strtok_s(tok,
"(", &subcontext);
5978 char* end = strtok_s(NULL,
")", &subcontext);
5982 if (freerdp_path_valid(name, NULL) && freerdp_path_valid(drive, NULL))
5984 success = freerdp_client_add_drive(settings, name, NULL);
5986 success = freerdp_client_add_drive(settings, drive, NULL);
5989 success = freerdp_client_add_drive(settings, drive, name);
5997 tok = strtok_s(NULL,
";", &context);
6006 if (!freerdp_device_collection_find(settings,
"drive"))
6008 const char*
const params[] = {
"drive",
"media",
"*" };
6010 if (!freerdp_client_add_device_channel(settings, ARRAYSIZE(params), params))
6027 if (!freerdp_device_collection_find(settings,
"drive"))
6029 const char* params[] = {
"drive",
"home",
"%" };
6031 if (!freerdp_client_add_device_channel(settings, ARRAYSIZE(params), params))
6038 if (!freerdp_client_load_static_channel_addin(channels, settings, RDPDR_SVC_CHANNEL_NAME,
6042 if (!freerdp_static_channel_collection_find(settings, RDPSND_CHANNEL_NAME) &&
6043 !freerdp_dynamic_channel_collection_find(settings, RDPSND_CHANNEL_NAME))
6045 const char*
const params[] = { RDPSND_CHANNEL_NAME,
"sys:fake" };
6047 if (!freerdp_client_add_static_channel(settings, ARRAYSIZE(params), params))
6050 if (!freerdp_client_add_dynamic_channel(settings, ARRAYSIZE(params), params))
6057 if (!freerdp_device_collection_find_type(settings, RDPDR_DTYP_SMARTCARD))
6059 RDPDR_DEVICE* smartcard = freerdp_device_new(RDPDR_DTYP_SMARTCARD, 0, NULL);
6064 if (!freerdp_device_collection_add(settings, smartcard))
6066 freerdp_device_free(smartcard);
6074 if (!freerdp_device_collection_find_type(settings, RDPDR_DTYP_PRINT))
6076 RDPDR_DEVICE* printer = freerdp_device_new(RDPDR_DTYP_PRINT, 0, NULL);
6081 if (!freerdp_device_collection_add(settings, printer))
6083 freerdp_device_free(printer);
6110 for (
size_t i = 0; i < ARRAYSIZE(staticChannels); i++)
6112 if ((staticChannels[i].settingId == 0) ||
6115 if (staticChannels[i].args)
6117 if (!freerdp_client_load_static_channel_addin(
6118 channels, settings, staticChannels[i].channelName, staticChannels[i].args))
6123 const char*
const p[] = { staticChannels[i].channelName };
6124 if (!freerdp_client_add_static_channel(settings, ARRAYSIZE(p), p))
6133 if (!freerdp_client_load_static_channel_addin(channels, settings, RDP2TCP_DVC_CHANNEL_NAME,
6142 freerdp_settings_get_pointer_array_writable(settings, FreeRDP_StaticChannelArray, i);
6144 if (!freerdp_client_load_static_channel_addin(channels, settings, _args->argv[0], _args))
6156 if (!freerdp_client_load_static_channel_addin(channels, settings, DRDYNVC_SVC_CHANNEL_NAME,
6164 void freerdp_client_warn_unmaintained(
int argc,
char* argv[])
6166 const char* app = (argc > 0) ? argv[0] :
"INVALID_ARGV";
6167 const DWORD log_level = WLOG_WARN;
6168 wLog* log = WLog_Get(TAG);
6171 if (!WLog_IsLevelActive(log, log_level))
6174 WLog_Print_unchecked(log, log_level,
"[unmaintained] %s client is currently unmaintained!",
6176 WLog_Print_unchecked(
6178 " If problems occur please check https://github.com/FreeRDP/FreeRDP/issues for "
6180 WLog_Print_unchecked(
6182 "Be prepared to fix issues yourself though as nobody is actively working on this.");
6183 WLog_Print_unchecked(
6185 " Developers hang out in https://matrix.to/#/#FreeRDP:matrix.org?via=matrix.org "
6186 "- dont hesitate to ask some questions. (replies might take some time depending "
6187 "on your timezone) - if you intend using this component write us a message");
6190 void freerdp_client_warn_experimental(
int argc,
char* argv[])
6192 const char* app = (argc > 0) ? argv[0] :
"INVALID_ARGV";
6193 const DWORD log_level = WLOG_WARN;
6194 wLog* log = WLog_Get(TAG);
6197 if (!WLog_IsLevelActive(log, log_level))
6200 WLog_Print_unchecked(log, log_level,
"[experimental] %s client is currently experimental!",
6202 WLog_Print_unchecked(
6204 " If problems occur please check https://github.com/FreeRDP/FreeRDP/issues for "
6205 "known issues or create a new one!");
6206 WLog_Print_unchecked(
6208 " Developers hang out in https://matrix.to/#/#FreeRDP:matrix.org?via=matrix.org "
6209 "- dont hesitate to ask some questions. (replies might take some time depending "
6210 "on your timezone)");
6213 void freerdp_client_warn_deprecated(
int argc,
char* argv[])
6215 const char* app = (argc > 0) ? argv[0] :
"INVALID_ARGV";
6216 const DWORD log_level = WLOG_WARN;
6217 wLog* log = WLog_Get(TAG);
6220 if (!WLog_IsLevelActive(log, log_level))
6223 WLog_Print_unchecked(log, log_level,
"[deprecated] %s client has been deprecated", app);
6224 WLog_Print_unchecked(log, log_level,
"As replacement there is a SDL based client available.");
6225 WLog_Print_unchecked(
6227 "If you are interested in keeping %s alive get in touch with the developers", app);
6228 WLog_Print_unchecked(
6230 "The project is hosted at https://github.com/freerdp/freerdp and "
6231 " developers hang out in https://matrix.to/#/#FreeRDP:matrix.org?via=matrix.org "
6232 "- dont hesitate to ask some questions. (replies might take some time depending "
6233 "on your timezone)");
FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.
FREERDP_API BOOL freerdp_settings_set_string(rdpSettings *settings, FreeRDP_Settings_Keys_String id, const char *param)
Sets a string settings value. The param is copied.
FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.
FREERDP_API const void * freerdp_settings_get_pointer(const rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id)
Returns a immutable pointer settings value.
FREERDP_API INT64 freerdp_settings_get_int64(const rdpSettings *settings, FreeRDP_Settings_Keys_Int64 id)
Returns a INT64 settings value.
FREERDP_API char * freerdp_settings_get_string_writable(rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a string settings value.
FREERDP_API SSIZE_T freerdp_settings_get_type_for_key(SSIZE_T key)
Get a key type for the key index.
FREERDP_API UINT64 freerdp_settings_get_uint64(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt64 id)
Returns a UINT64 settings value.
FREERDP_API const char * freerdp_settings_get_string(const rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a immutable string settings value.
FREERDP_API BOOL freerdp_settings_set_pointer_len(rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id, const void *data, size_t len)
Set a pointer to value data.
FREERDP_API UINT16 freerdp_settings_get_uint16(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt16 id)
Returns a UINT16 settings value.
FREERDP_API BOOL freerdp_set_gateway_usage_method(rdpSettings *settings, UINT32 GatewayUsageMethod)
FREERDP_API BOOL freerdp_settings_set_uint64(rdpSettings *settings, FreeRDP_Settings_Keys_UInt64 id, UINT64 param)
Sets a UINT64 settings value.
FREERDP_API INT32 freerdp_settings_get_int32(const rdpSettings *settings, FreeRDP_Settings_Keys_Int32 id)
Returns a INT32 settings value.
FREERDP_API BOOL freerdp_settings_set_string_len(rdpSettings *settings, FreeRDP_Settings_Keys_String id, const char *param, size_t len)
Sets a string settings value. The param is copied.
FREERDP_API BOOL freerdp_settings_set_uint32(rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id, UINT32 param)
Sets a UINT32 settings value.
FREERDP_API BOOL freerdp_settings_append_string(rdpSettings *settings, FreeRDP_Settings_Keys_String id, const char *separator, const char *param)
appends a string to a settings value. The param is copied. If the initial value of the setting was no...
FREERDP_API BOOL freerdp_settings_set_uint16(rdpSettings *settings, FreeRDP_Settings_Keys_UInt16 id, UINT16 param)
Sets a UINT16 settings value.
FREERDP_API INT16 freerdp_settings_get_int16(const rdpSettings *settings, FreeRDP_Settings_Keys_Int16 id)
Returns a INT16 settings value.
FREERDP_API BOOL freerdp_settings_set_bool(rdpSettings *settings, FreeRDP_Settings_Keys_Bool id, BOOL param)
Sets a BOOL settings value.
FREERDP_API void * freerdp_settings_get_pointer_writable(rdpSettings *settings, FreeRDP_Settings_Keys_Pointer id)
Returns a mutable pointer settings value.
FREERDP_API const char * freerdp_settings_get_name_for_key(SSIZE_T key)
Returns the type name for a key.