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 = 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 WINPR_ASSERT(SIZE_MAX - rc > current);
465 current += (size_t)rc;
470 static int cmp_cmdline_args(
const void* pva,
const void* pvb)
475 if (!a->Name && !b->Name)
481 return strcmp(a->Name, b->Name);
496 const size_t description_offset = 30 + 8;
498 if (arg->Flags & (COMMAND_LINE_VALUE_BOOL | COMMAND_LINE_VALUE_FLAG))
500 if ((arg->Flags & ~COMMAND_LINE_VALUE_BOOL) == 0)
501 rc = printf(
" %s%s", arg->Default ?
"-" :
"+", arg->Name);
502 else if ((arg->Flags & COMMAND_LINE_VALUE_OPTIONAL) != 0)
503 rc = printf(
" [%s|/]%s", arg->Default ?
"-" :
"+", arg->Name);
506 rc = printf(
" %s%s", arg->Default ?
"-" :
"+", arg->Name);
510 rc = printf(
" /%s", arg->Name);
516 if ((arg->Flags & COMMAND_LINE_VALUE_REQUIRED) ||
517 (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL))
521 if (arg->Flags & COMMAND_LINE_VALUE_OPTIONAL)
527 pos = print_optionals(arg->Format, pos, pos);
539 pos = print_optionals(arg->Format, pos, pos);
542 if (pos > description_offset)
550 rc = printf(
"%*c", (
int)(description_offset - pos),
' ');
555 if (arg->Flags & COMMAND_LINE_VALUE_BOOL)
557 rc = printf(
"%s ", arg->Default ?
"Disable" :
"Enable");
563 print_description(arg->Text, description_offset, pos);
564 }
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
567 BOOL freerdp_client_print_command_line_help(
int argc,
char** argv)
569 return freerdp_client_print_command_line_help_ex(argc, argv, NULL);
573 SSIZE_T count,
size_t* pcount)
575 WINPR_ASSERT(pcount);
580 while (cur && cur->Name)
595 while (cur && cur->Name)
597 largs[lcount++] = *cur++;
600 cur = global_cmd_args;
601 while (cur && cur->Name)
603 largs[lcount++] = *cur++;
609 BOOL freerdp_client_print_command_line_help_ex(
int argc,
char** argv,
612 const char* name =
"FreeRDP";
624 printf(
"FreeRDP - A Free Remote Desktop Protocol Implementation\n");
625 printf(
"See www.freerdp.com for more information\n");
627 printf(
"Usage: %s [file] [options] [/v:<server>[:port]]\n", argv[0]);
630 printf(
" /flag (enables flag)\n");
631 printf(
" /option:<value> (specifies option with value)\n");
632 printf(
" +toggle -toggle (enables or disables toggle, where '/' is a synonym of '+')\n");
635 freerdp_client_print_command_line_args(largs, lcount);
639 printf(
"Examples:\n");
640 printf(
" %s connection.rdp /p:Pwd123! /f\n", name);
641 printf(
" %s /u:CONTOSO\\JohnDoe /p:Pwd123! /v:rdp.contoso.com\n", name);
642 printf(
" %s /u:JohnDoe /p:Pwd123! /w:1366 /h:768 /v:192.168.1.100:4489\n", name);
643 printf(
" %s /u:JohnDoe /p:Pwd123! /vmconnect:C824F53E-95D2-46C6-9A18-23A5BB403532 "
644 "/v:192.168.1.100\n",
646 printf(
" %s /u:\\AzureAD\\user@corp.example /p:pwd /v:host\n", name);
648 printf(
"Clipboard Redirection: +clipboard\n");
650 printf(
"Drive Redirection: /drive:home,/home/user\n");
651 printf(
"Smartcard Redirection: /smartcard:<device>\n");
652 printf(
"Smartcard logon with Kerberos authentication: /smartcard-logon /sec:nla\n");
654 #if defined(CHANNEL_SERIAL_CLIENT)
655 printf(
"Serial Port Redirection: /serial:<name>,<device>,[SerCx2|SerCx|Serial],[permissive]\n");
656 printf(
"Serial Port Redirection: /serial:COM1,/dev/ttyS0\n");
658 #if defined(CHANNEL_PARALLEL_CLIENT)
659 printf(
"Parallel Port Redirection: /parallel:<name>,<device>\n");
661 printf(
"Printer Redirection: /printer:<device>,<driver>,[default]\n");
662 printf(
"TCP redirection: /rdp2tcp:/usr/bin/rdp2tcp\n");
664 printf(
"Audio Output Redirection: /sound:sys:oss,dev:1,format:1\n");
665 printf(
"Audio Output Redirection: /sound:sys:alsa\n");
666 printf(
"Audio Input Redirection: /microphone:sys:oss,dev:1,format:1\n");
667 printf(
"Audio Input Redirection: /microphone:sys:alsa\n");
669 printf(
"Multimedia Redirection: /video\n");
670 #ifdef CHANNEL_URBDRC_CLIENT
671 printf(
"USB Device Redirection: /usb:id:054c:0268#4669:6e6b,addr:04:0c\n");
674 printf(
"For Gateways, the https_proxy environment variable is respected:\n");
676 printf(
" set HTTPS_PROXY=http://proxy.contoso.com:3128/\n");
678 printf(
" export https_proxy=http://proxy.contoso.com:3128/\n");
680 printf(
" %s /g:rdp.contoso.com ...\n", name);
682 printf(
"More documentation is coming, in the meantime consult source files\n");
687 static BOOL option_is_rdp_file(
const char* option)
689 WINPR_ASSERT(option);
691 if (option_ends_with(option,
".rdp"))
693 if (option_ends_with(option,
".rdpw"))
698 static BOOL option_is_incident_file(
const char* option)
700 WINPR_ASSERT(option);
702 if (option_ends_with(option,
".msrcIncident"))
707 static int freerdp_client_command_line_pre_filter(
void* context,
int index,
int argc, LPSTR* argv)
712 rdpSettings* settings = NULL;
717 length = strlen(argv[index]);
721 if (option_is_rdp_file(argv[index]))
723 settings = (rdpSettings*)context;
726 return COMMAND_LINE_ERROR_MEMORY;
734 if (option_is_incident_file(argv[index]))
736 settings = (rdpSettings*)context;
739 return COMMAND_LINE_ERROR_MEMORY;
749 BOOL freerdp_client_add_device_channel(rdpSettings* settings,
size_t count,
750 const char*
const* params)
752 WINPR_ASSERT(settings);
753 WINPR_ASSERT(params);
754 WINPR_ASSERT(count > 0);
756 if (option_equals(params[0],
"drive"))
765 rc = freerdp_client_add_drive(settings, params[1], NULL);
767 rc = freerdp_client_add_drive(settings, params[2], params[1]);
771 else if (option_equals(params[0],
"printer"))
783 printer = freerdp_device_new(RDPDR_DTYP_PRINT, count - 1, ¶ms[1]);
787 if (!freerdp_device_collection_add(settings, printer))
789 freerdp_device_free(printer);
795 else if (option_equals(params[0],
"smartcard"))
807 smartcard = freerdp_device_new(RDPDR_DTYP_SMARTCARD, count - 1, ¶ms[1]);
812 if (!freerdp_device_collection_add(settings, smartcard))
814 freerdp_device_free(smartcard);
820 #if defined(CHANNEL_SERIAL_CLIENT)
821 else if (option_equals(params[0],
"serial"))
833 serial = freerdp_device_new(RDPDR_DTYP_SERIAL, count - 1, ¶ms[1]);
838 if (!freerdp_device_collection_add(settings, serial))
840 freerdp_device_free(serial);
847 else if (option_equals(params[0],
"parallel"))
859 parallel = freerdp_device_new(RDPDR_DTYP_PARALLEL, count - 1, ¶ms[1]);
864 if (!freerdp_device_collection_add(settings, parallel))
866 freerdp_device_free(parallel);
876 BOOL freerdp_client_del_static_channel(rdpSettings* settings,
const char* name)
878 return freerdp_static_channel_collection_del(settings, name);
881 BOOL freerdp_client_add_static_channel(rdpSettings* settings,
size_t count,
882 const char*
const* params)
886 if (!settings || !params || !params[0] || (count > INT_MAX))
889 if (freerdp_static_channel_collection_find(settings, params[0]))
892 _args = freerdp_addin_argv_new(count, params);
897 if (!freerdp_static_channel_collection_add(settings, _args))
902 freerdp_addin_argv_free(_args);
906 BOOL freerdp_client_del_dynamic_channel(rdpSettings* settings,
const char* name)
908 return freerdp_dynamic_channel_collection_del(settings, name);
911 BOOL freerdp_client_add_dynamic_channel(rdpSettings* settings,
size_t count,
912 const char*
const* params)
916 if (!settings || !params || !params[0] || (count > INT_MAX))
919 if (freerdp_dynamic_channel_collection_find(settings, params[0]))
922 _args = freerdp_addin_argv_new(count, params);
927 if (!freerdp_dynamic_channel_collection_add(settings, _args))
933 freerdp_addin_argv_free(_args);
937 static BOOL read_pem_file(rdpSettings* settings, FreeRDP_Settings_Keys_String
id,
const char* file)
940 char* pem = crypto_read_pem(file, &length);
941 if (!pem || (length == 0))
955 CMDLINE_SUBOPTION_STRING,
956 CMDLINE_SUBOPTION_FILE,
957 } CmdLineSubOptionType;
959 typedef BOOL (*CmdLineSubOptionCb)(
const char* value, rdpSettings* settings);
963 FreeRDP_Settings_Keys_String id;
964 CmdLineSubOptionType opttype;
965 CmdLineSubOptionCb cb;
968 static BOOL parseSubOptions(rdpSettings* settings,
const CmdLineSubOptions* opts,
size_t count,
973 for (
size_t xx = 0; xx < count; xx++)
975 const CmdLineSubOptions* opt = &opts[xx];
977 if (option_starts_with(opt->optname, arg))
979 const size_t optlen = strlen(opt->optname);
980 const char* val = &arg[optlen];
983 switch (opt->opttype)
985 case CMDLINE_SUBOPTION_STRING:
988 case CMDLINE_SUBOPTION_FILE:
989 status = read_pem_file(settings, opt->id, val);
992 WLog_ERR(TAG,
"invalid subOption type");
999 if (opt->cb && !opt->cb(val, settings))
1008 WLog_ERR(TAG,
"option %s not handled", arg);
1013 #define fail_at(arg, rc) fail_at_((arg), (rc), __FILE__, __func__, __LINE__)
1017 const DWORD level = WLOG_ERROR;
1018 wLog* log = WLog_Get(TAG);
1019 if (WLog_IsLevelActive(log, level))
1020 WLog_PrintMessage(log, WLOG_MESSAGE_TEXT, level, line, file, fkt,
1021 "Command line parsing failed at '%s' value '%s' [%d]", arg->Name,
1028 rdpSettings* settings = (rdpSettings*)context;
1029 int status = CHANNEL_RC_OK;
1030 BOOL enable = arg->Value ? TRUE : FALSE;
1032 CommandLineSwitchStart(arg) CommandLineSwitchCase(arg,
"a")
1035 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
1037 if (!freerdp_client_add_device_channel(settings, count, (
const char*
const*)ptr))
1038 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1040 status = COMMAND_LINE_ERROR;
1042 CommandLineParserFree(ptr);
1044 return fail_at(arg, status);
1046 CommandLineSwitchCase(arg,
"kerberos")
1050 char** ptr = CommandLineParseCommaSeparatedValuesEx(
"kerberos", arg->Value, &count);
1053 const CmdLineSubOptions opts[] = {
1054 {
"kdc-url:", FreeRDP_KerberosKdcUrl, CMDLINE_SUBOPTION_STRING, NULL },
1055 {
"start-time:", FreeRDP_KerberosStartTime, CMDLINE_SUBOPTION_STRING, NULL },
1056 {
"lifetime:", FreeRDP_KerberosLifeTime, CMDLINE_SUBOPTION_STRING, NULL },
1057 {
"renewable-lifetime:", FreeRDP_KerberosRenewableLifeTime,
1058 CMDLINE_SUBOPTION_STRING, NULL },
1059 {
"cache:", FreeRDP_KerberosCache, CMDLINE_SUBOPTION_STRING, NULL },
1060 {
"armor:", FreeRDP_KerberosArmor, CMDLINE_SUBOPTION_STRING, NULL },
1061 {
"pkinit-anchors:", FreeRDP_PkinitAnchors, CMDLINE_SUBOPTION_STRING, NULL },
1062 {
"pkcs11-module:", FreeRDP_Pkcs11Module, CMDLINE_SUBOPTION_STRING, NULL }
1065 for (
size_t x = 1; x < count; x++)
1067 const char* cur = ptr[x];
1068 if (!parseSubOptions(settings, opts, ARRAYSIZE(opts), cur))
1070 CommandLineParserFree(ptr);
1071 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
1075 CommandLineParserFree(ptr);
1078 CommandLineSwitchCase(arg,
"vc")
1081 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
1082 if (!freerdp_client_add_static_channel(settings, count, (
const char*
const*)ptr))
1083 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1084 CommandLineParserFree(ptr);
1086 return fail_at(arg, status);
1088 CommandLineSwitchCase(arg,
"dvc")
1091 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
1092 if (!freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr))
1093 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1094 CommandLineParserFree(ptr);
1096 return fail_at(arg, status);
1098 CommandLineSwitchCase(arg,
"drive")
1101 char** ptr = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
1102 if (!freerdp_client_add_device_channel(settings, count, (
const char*
const*)ptr))
1103 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1104 CommandLineParserFree(ptr);
1106 return fail_at(arg, status);
1108 #if defined(CHANNEL_SERIAL_CLIENT)
1109 CommandLineSwitchCase(arg,
"serial")
1112 char** ptr = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
1113 if (!freerdp_client_add_device_channel(settings, count, (
const char*
const*)ptr))
1114 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1115 CommandLineParserFree(ptr);
1117 return fail_at(arg, status);
1120 #if defined(CHANNEL_PARALLEL_CLIENT)
1121 CommandLineSwitchCase(arg,
"parallel")
1124 char** ptr = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
1125 if (!freerdp_client_add_device_channel(settings, count, (
const char*
const*)ptr))
1126 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1127 CommandLineParserFree(ptr);
1129 return fail_at(arg, status);
1132 CommandLineSwitchCase(arg,
"smartcard")
1135 char** ptr = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
1136 if (!freerdp_client_add_device_channel(settings, count, (
const char*
const*)ptr))
1137 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1138 CommandLineParserFree(ptr);
1140 return fail_at(arg, status);
1142 CommandLineSwitchCase(arg,
"printer")
1145 char** ptr = CommandLineParseCommaSeparatedValuesEx(arg->Name, arg->Value, &count);
1146 if (!freerdp_client_add_device_channel(settings, count, (
const char*
const*)ptr))
1147 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1148 CommandLineParserFree(ptr);
1150 return fail_at(arg, status);
1152 CommandLineSwitchCase(arg,
"usb")
1156 CommandLineParseCommaSeparatedValuesEx(URBDRC_CHANNEL_NAME, arg->Value, &count);
1157 if (!freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr))
1158 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1159 CommandLineParserFree(ptr);
1161 return fail_at(arg, status);
1163 CommandLineSwitchCase(arg,
"multitouch")
1166 return fail_at(arg, COMMAND_LINE_ERROR);
1168 CommandLineSwitchCase(arg,
"gestures")
1171 return fail_at(arg, COMMAND_LINE_ERROR);
1173 CommandLineSwitchCase(arg,
"echo")
1176 return fail_at(arg, COMMAND_LINE_ERROR);
1178 CommandLineSwitchCase(arg,
"ssh-agent")
1181 return fail_at(arg, COMMAND_LINE_ERROR);
1183 CommandLineSwitchCase(arg,
"disp")
1186 return fail_at(arg, COMMAND_LINE_ERROR);
1188 CommandLineSwitchCase(arg,
"geometry")
1191 return fail_at(arg, COMMAND_LINE_ERROR);
1193 CommandLineSwitchCase(arg,
"video")
1197 return fail_at(arg, COMMAND_LINE_ERROR);
1199 return fail_at(arg, COMMAND_LINE_ERROR);
1201 CommandLineSwitchCase(arg,
"sound")
1205 CommandLineParseCommaSeparatedValuesEx(RDPSND_CHANNEL_NAME, arg->Value, &count);
1206 if (!freerdp_client_add_static_channel(settings, count, (
const char*
const*)ptr))
1207 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1208 if (!freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr))
1209 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1211 CommandLineParserFree(ptr);
1213 return fail_at(arg, status);
1215 CommandLineSwitchCase(arg,
"microphone")
1218 char** ptr = CommandLineParseCommaSeparatedValuesEx(AUDIN_CHANNEL_NAME, arg->Value, &count);
1219 if (!freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr))
1220 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1221 CommandLineParserFree(ptr);
1223 return fail_at(arg, status);
1225 #if defined(CHANNEL_TSMF_CLIENT)
1226 CommandLineSwitchCase(arg,
"multimedia")
1229 char** ptr = CommandLineParseCommaSeparatedValuesEx(
"tsmf", arg->Value, &count);
1230 if (!freerdp_client_add_dynamic_channel(settings, count, (
const char*
const*)ptr))
1231 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1232 CommandLineParserFree(ptr);
1234 return fail_at(arg, status);
1237 CommandLineSwitchCase(arg,
"heartbeat")
1240 return fail_at(arg, COMMAND_LINE_ERROR);
1242 CommandLineSwitchCase(arg,
"multitransport")
1245 return fail_at(arg, COMMAND_LINE_ERROR);
1250 (TRANSPORT_TYPE_UDP_FECR | TRANSPORT_TYPE_UDP_FECL | TRANSPORT_TYPE_UDP_PREFERRED);
1253 return fail_at(arg, COMMAND_LINE_ERROR);
1255 CommandLineSwitchEnd(arg)
1262 int status = freerdp_client_command_line_post_filter_int(context, arg);
1263 return status == CHANNEL_RC_OK ? 1 : -1;
1266 static BOOL freerdp_parse_username_ptr(
const char* username,
const char** user,
size_t* userlen,
1267 const char** domain,
size_t* domainlen)
1270 WINPR_ASSERT(userlen);
1271 WINPR_ASSERT(domain);
1272 WINPR_ASSERT(domainlen);
1277 const char* p = strchr(username,
'\\');
1287 const size_t length = (size_t)(p - username);
1289 *userlen = strlen(*user);
1292 *domainlen = length;
1301 *userlen = strlen(username);
1307 static BOOL freerdp_parse_username_settings(
const char* username, rdpSettings* settings,
1308 FreeRDP_Settings_Keys_String userID,
1309 FreeRDP_Settings_Keys_String domainID)
1311 const char* user = NULL;
1312 const char* domain = NULL;
1314 size_t domainlen = 0;
1316 const BOOL rc = freerdp_parse_username_ptr(username, &user, &userlen, &domain, &domainlen);
1324 BOOL freerdp_parse_username(
const char* username,
char** puser,
char** pdomain)
1326 const char* user = NULL;
1327 const char* domain = NULL;
1329 size_t domainlen = 0;
1334 const BOOL rc = freerdp_parse_username_ptr(username, &user, &userlen, &domain, &domainlen);
1340 *puser = strndup(user, userlen);
1347 *pdomain = strndup(domain, domainlen);
1359 BOOL freerdp_parse_hostname(
const char* hostname,
char** host,
int* port)
1362 p = strrchr(hostname,
':');
1366 size_t length = (size_t)(p - hostname);
1369 if (!value_to_int(p + 1, &val, 1, UINT16_MAX))
1372 *host = (
char*)calloc(length + 1UL,
sizeof(
char));
1377 CopyMemory(*host, hostname, length);
1378 (*host)[length] =
'\0';
1379 *port = (UINT16)val;
1383 *host = _strdup(hostname);
1394 static BOOL freerdp_apply_connection_type(rdpSettings* settings, UINT32 type)
1396 struct network_settings
1398 FreeRDP_Settings_Keys_Bool id;
1401 const struct network_settings config[] = {
1402 { FreeRDP_DisableWallpaper, { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
1403 { FreeRDP_AllowFontSmoothing, { FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE } },
1404 { FreeRDP_AllowDesktopComposition, { FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE } },
1405 { FreeRDP_DisableFullWindowDrag, { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
1406 { FreeRDP_DisableMenuAnims, { TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE } },
1407 { FreeRDP_DisableThemes, { TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE } }
1412 case CONNECTION_TYPE_INVALID:
1415 case CONNECTION_TYPE_MODEM:
1416 case CONNECTION_TYPE_BROADBAND_LOW:
1417 case CONNECTION_TYPE_BROADBAND_HIGH:
1418 case CONNECTION_TYPE_SATELLITE:
1419 case CONNECTION_TYPE_WAN:
1420 case CONNECTION_TYPE_LAN:
1421 case CONNECTION_TYPE_AUTODETECT:
1424 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
1428 for (
size_t x = 0; x < ARRAYSIZE(config); x++)
1430 const struct network_settings* cur = &config[x];
1437 BOOL freerdp_set_connection_type(rdpSettings* settings, UINT32 type)
1445 case CONNECTION_TYPE_INVALID:
1446 case CONNECTION_TYPE_MODEM:
1447 case CONNECTION_TYPE_BROADBAND_LOW:
1448 case CONNECTION_TYPE_SATELLITE:
1449 case CONNECTION_TYPE_BROADBAND_HIGH:
1450 case CONNECTION_TYPE_WAN:
1451 case CONNECTION_TYPE_LAN:
1452 if (!freerdp_apply_connection_type(settings, type))
1455 case CONNECTION_TYPE_AUTODETECT:
1456 if (!freerdp_apply_connection_type(settings, type))
1459 #ifdef WITH_GFX_H264
1470 WLog_WARN(TAG,
"Unknown ConnectionType %" PRIu32
", aborting", type);
1477 static UINT32 freerdp_get_keyboard_layout_for_type(
const char* name, DWORD type)
1482 freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD, &count);
1484 if (!layouts || (count == 0))
1487 for (
size_t x = 0; x < count; x++)
1490 if (option_equals(layout->name, name))
1498 freerdp_keyboard_layouts_free(layouts, count);
1502 static UINT32 freerdp_map_keyboard_layout_name_to_id(
const char* name)
1504 const UINT32 variants[] = { RDP_KEYBOARD_LAYOUT_TYPE_STANDARD, RDP_KEYBOARD_LAYOUT_TYPE_VARIANT,
1505 RDP_KEYBOARD_LAYOUT_TYPE_IME };
1507 for (
size_t x = 0; x < ARRAYSIZE(variants); x++)
1509 UINT32 rc = freerdp_get_keyboard_layout_for_type(name, variants[x]);
1517 static int freerdp_detect_command_line_pre_filter(
void* context,
int index,
int argc, LPSTR* argv)
1520 WINPR_UNUSED(context);
1527 length = strlen(argv[index]);
1531 if (option_is_rdp_file(argv[index]))
1539 if (option_is_incident_file(argv[index]))
1549 static int freerdp_detect_windows_style_command_line_syntax(
int argc,
char** argv,
size_t* count,
1554 int detect_status = 0;
1557 memcpy(largs, global_cmd_args,
sizeof(global_cmd_args));
1559 flags = COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_SILENCE_PARSER;
1560 flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
1564 flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
1569 CommandLineClearArgumentsA(largs);
1570 status = CommandLineParseArgumentsA(argc, argv, largs, flags, NULL,
1571 freerdp_detect_command_line_pre_filter, NULL);
1580 if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
1584 }
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
1586 if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
1589 return detect_status;
1592 static int freerdp_detect_posix_style_command_line_syntax(
int argc,
char** argv,
size_t* count,
1597 int detect_status = 0;
1600 memcpy(largs, global_cmd_args,
sizeof(global_cmd_args));
1602 flags = COMMAND_LINE_SEPARATOR_SPACE | COMMAND_LINE_SILENCE_PARSER;
1603 flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
1604 flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
1608 flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
1613 CommandLineClearArgumentsA(largs);
1614 status = CommandLineParseArgumentsA(argc, argv, largs, flags, NULL,
1615 freerdp_detect_command_line_pre_filter, NULL);
1624 if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
1628 }
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
1630 if ((status <= COMMAND_LINE_ERROR) && (status >= COMMAND_LINE_ERROR_LAST))
1633 return detect_status;
1636 static BOOL freerdp_client_detect_command_line(
int argc,
char** argv, DWORD* flags)
1638 int posix_cli_status = 0;
1639 size_t posix_cli_count = 0;
1640 int windows_cli_status = 0;
1641 size_t windows_cli_count = 0;
1642 const BOOL ignoreUnknown = TRUE;
1643 windows_cli_status = freerdp_detect_windows_style_command_line_syntax(
1644 argc, argv, &windows_cli_count, ignoreUnknown);
1646 freerdp_detect_posix_style_command_line_syntax(argc, argv, &posix_cli_count, ignoreUnknown);
1649 *flags = COMMAND_LINE_SEPARATOR_SPACE;
1650 *flags |= COMMAND_LINE_SIGIL_DASH | COMMAND_LINE_SIGIL_DOUBLE_DASH;
1651 *flags |= COMMAND_LINE_SIGIL_ENABLE_DISABLE;
1653 if (posix_cli_status <= COMMAND_LINE_STATUS_PRINT)
1657 if ((windows_cli_count && (windows_cli_count >= posix_cli_count)) ||
1658 (windows_cli_status <= COMMAND_LINE_STATUS_PRINT))
1660 windows_cli_count = 1;
1661 *flags = COMMAND_LINE_SEPARATOR_COLON;
1662 *flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS;
1665 WLog_DBG(TAG,
"windows: %d/%" PRIuz
" posix: %d/%" PRIuz
"", windows_cli_status,
1666 windows_cli_count, posix_cli_status, posix_cli_count);
1667 if ((posix_cli_count == 0) && (windows_cli_count == 0))
1669 if ((posix_cli_status == COMMAND_LINE_ERROR) && (windows_cli_status == COMMAND_LINE_ERROR))
1675 int freerdp_client_settings_command_line_status_print(rdpSettings* settings,
int status,
int argc,
1678 return freerdp_client_settings_command_line_status_print_ex(settings, status, argc, argv, NULL);
1681 static void freerdp_client_print_keyboard_type_list(
const char* msg, DWORD type)
1685 layouts = freerdp_keyboard_get_layouts(type, &count);
1687 printf(
"\n%s\n", msg);
1689 for (
size_t x = 0; x < count; x++)
1692 printf(
"0x%08" PRIX32
"\t%s\n", layout->code, layout->name);
1695 freerdp_keyboard_layouts_free(layouts, count);
1698 static void freerdp_client_print_keyboard_list(
void)
1700 freerdp_client_print_keyboard_type_list(
"Keyboard Layouts", RDP_KEYBOARD_LAYOUT_TYPE_STANDARD);
1701 freerdp_client_print_keyboard_type_list(
"Keyboard Layout Variants",
1702 RDP_KEYBOARD_LAYOUT_TYPE_VARIANT);
1703 freerdp_client_print_keyboard_type_list(
"Keyboard Layout Variants",
1704 RDP_KEYBOARD_LAYOUT_TYPE_IME);
1707 static void freerdp_client_print_timezone_list(
void)
1711 while (EnumDynamicTimeZoneInformation(index++, &info) != ERROR_NO_MORE_ITEMS)
1713 char TimeZoneKeyName[ARRAYSIZE(info.TimeZoneKeyName) + 1] = { 0 };
1715 (void)ConvertWCharNToUtf8(info.TimeZoneKeyName, ARRAYSIZE(info.TimeZoneKeyName),
1716 TimeZoneKeyName, ARRAYSIZE(TimeZoneKeyName));
1717 printf(
"%" PRIu32
": '%s'\n", index, TimeZoneKeyName);
1721 static void freerdp_client_print_tune_list(
const rdpSettings* settings)
1725 for (SSIZE_T x = 0; x < FreeRDP_Settings_StableAPI_MAX; x++)
1733 case RDP_SETTINGS_TYPE_BOOL:
1734 printf(
"%" PRIdz
"\t%50s\tBOOL\t%s\n", x, name,
1739 case RDP_SETTINGS_TYPE_UINT16:
1740 printf(
"%" PRIdz
"\t%50s\tUINT16\t%" PRIu16
"\n", x, name,
1743 case RDP_SETTINGS_TYPE_INT16:
1744 printf(
"%" PRIdz
"\t%50s\tINT16\t%" PRId16
"\n", x, name,
1747 case RDP_SETTINGS_TYPE_UINT32:
1748 printf(
"%" PRIdz
"\t%50s\tUINT32\t%" PRIu32
"\n", x, name,
1751 case RDP_SETTINGS_TYPE_INT32:
1752 printf(
"%" PRIdz
"\t%50s\tINT32\t%" PRId32
"\n", x, name,
1755 case RDP_SETTINGS_TYPE_UINT64:
1756 printf(
"%" PRIdz
"\t%50s\tUINT64\t%" PRIu64
"\n", x, name,
1759 case RDP_SETTINGS_TYPE_INT64:
1760 printf(
"%" PRIdz
"\t%50s\tINT64\t%" PRId64
"\n", x, name,
1763 case RDP_SETTINGS_TYPE_STRING:
1764 printf(
"%" PRIdz
"\t%50s\tSTRING\t%s"
1769 case RDP_SETTINGS_TYPE_POINTER:
1770 printf(
"%" PRIdz
"\t%50s\tPOINTER\t%p"
1782 int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings,
int status,
1783 int argc,
char** argv,
1788 memcpy(largs, global_cmd_args,
sizeof(global_cmd_args));
1790 if (status == COMMAND_LINE_STATUS_PRINT_VERSION)
1792 freerdp_client_print_version();
1796 if (status == COMMAND_LINE_STATUS_PRINT_BUILDCONFIG)
1798 freerdp_client_print_version_ex(argc, argv);
1799 freerdp_client_print_buildconfig_ex(argc, argv);
1802 else if (status == COMMAND_LINE_STATUS_PRINT)
1804 (void)CommandLineParseArgumentsA(argc, argv, largs, 0x112, NULL, NULL, NULL);
1806 arg = CommandLineFindArgumentA(largs,
"list");
1809 if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
1811 if (option_equals(
"timezones", arg->Value))
1812 freerdp_client_print_timezone_list();
1813 else if (option_equals(
"tune", arg->Value))
1814 freerdp_client_print_tune_list(settings);
1815 else if (option_equals(
"kbd", arg->Value))
1816 freerdp_client_print_keyboard_list();
1817 else if (option_starts_with(
"kbd-lang", arg->Value))
1819 const char* val = NULL;
1820 if (option_starts_with(
"kbd-lang:", arg->Value))
1821 val = &arg->Value[9];
1822 else if (!option_equals(
"kbd-lang", arg->Value))
1823 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1825 if (val && strchr(val,
','))
1826 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1827 freerdp_client_print_codepages(val);
1829 else if (option_equals(
"kbd-scancode", arg->Value))
1830 freerdp_client_print_scancodes();
1831 else if (option_equals(
"monitor", arg->Value))
1834 return COMMAND_LINE_ERROR;
1836 else if (option_starts_with(
"smartcard", arg->Value))
1839 if (option_starts_with(
"smartcard:", arg->Value))
1841 else if (!option_equals(
"smartcard", arg->Value))
1842 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1846 const char* sub = strchr(arg->Value,
':') + 1;
1847 const CmdLineSubOptions options[] = {
1848 {
"pkinit-anchors:", FreeRDP_PkinitAnchors, CMDLINE_SUBOPTION_STRING,
1850 {
"pkcs11-module:", FreeRDP_Pkcs11Module, CMDLINE_SUBOPTION_STRING, NULL }
1855 char** ptr = CommandLineParseCommaSeparatedValuesEx(
"smartcard", sub, &count);
1857 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1860 CommandLineParserFree(ptr);
1861 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1864 for (
size_t x = 1; x < count; x++)
1866 const char* cur = ptr[x];
1867 if (!parseSubOptions(settings, options, ARRAYSIZE(options), cur))
1869 CommandLineParserFree(ptr);
1870 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
1874 CommandLineParserFree(ptr);
1877 freerdp_smartcard_list(settings);
1881 freerdp_client_print_command_line_help_ex(argc, argv, custom);
1882 return COMMAND_LINE_ERROR;
1885 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
1886 arg = CommandLineFindArgumentA(largs,
"tune-list");
1889 if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
1891 WLog_WARN(TAG,
"Option /tune-list is deprecated, use /list:tune instead");
1892 freerdp_client_print_tune_list(settings);
1895 arg = CommandLineFindArgumentA(largs,
"kbd-lang-list");
1898 if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
1900 WLog_WARN(TAG,
"Option /kbd-lang-list is deprecated, use /list:kbd-lang instead");
1901 freerdp_client_print_codepages(arg->Value);
1904 arg = CommandLineFindArgumentA(largs,
"kbd-list");
1907 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1909 WLog_WARN(TAG,
"Option /kbd-list is deprecated, use /list:kbd instead");
1910 freerdp_client_print_keyboard_list();
1913 arg = CommandLineFindArgumentA(largs,
"monitor-list");
1916 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1918 WLog_WARN(TAG,
"Option /monitor-list is deprecated, use /list:monitor instead");
1920 return COMMAND_LINE_ERROR;
1923 arg = CommandLineFindArgumentA(largs,
"smartcard-list");
1926 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1928 WLog_WARN(TAG,
"Option /smartcard-list is deprecated, use /list:smartcard instead");
1929 freerdp_smartcard_list(settings);
1932 arg = CommandLineFindArgumentA(largs,
"kbd-scancode-list");
1935 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
1938 "Option /kbd-scancode-list is deprecated, use /list:kbd-scancode instead");
1939 freerdp_client_print_scancodes();
1945 else if (status < 0)
1947 freerdp_client_print_command_line_help_ex(argc, argv, custom);
1952 if (status <= COMMAND_LINE_STATUS_PRINT && status >= COMMAND_LINE_STATUS_PRINT_LAST)
1965 static BOOL parseSizeValue(
const char* input,
unsigned long* v1,
unsigned long* v2)
1967 const char* xcharpos = NULL;
1968 char* endPtr = NULL;
1969 unsigned long v = 0;
1971 v = strtoul(input, &endPtr, 10);
1973 if ((v == 0 || v == ULONG_MAX) && (errno != 0))
1979 xcharpos = strchr(input,
'x');
1981 if (!xcharpos || xcharpos != endPtr)
1985 v = strtoul(xcharpos + 1, &endPtr, 10);
1987 if ((v == 0 || v == ULONG_MAX) && (errno != 0))
1990 if (*endPtr !=
'\0')
2002 const char* arguments[] = {
"network",
"gfx",
"rfx",
"bpp" };
2003 WINPR_ASSERT(settings);
2009 for (
size_t x = 0; x < ARRAYSIZE(arguments); x++)
2011 const char* arg = arguments[x];
2013 if (p && (p->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
2017 return freerdp_set_connection_type(settings, CONNECTION_TYPE_AUTODETECT);
2020 static BOOL setSmartcardEmulation(
const char* value, rdpSettings* settings)
2025 const char* option_starts_with(
const char* what,
const char* val)
2029 const size_t wlen = strlen(what);
2031 if (_strnicmp(what, val, wlen) != 0)
2036 BOOL option_ends_with(
const char* str,
const char* ext)
2040 const size_t strLen = strlen(str);
2041 const size_t extLen = strlen(ext);
2043 if (strLen < extLen)
2046 return _strnicmp(&str[strLen - extLen], ext, extLen) == 0;
2049 BOOL option_equals(
const char* what,
const char* val)
2053 return _stricmp(what, val) == 0;
2062 } PARSE_ON_OFF_RESULT;
2064 static PARSE_ON_OFF_RESULT parse_on_off_option(
const char* value)
2066 WINPR_ASSERT(value);
2067 const char* sep = strchr(value,
':');
2070 if (option_equals(
"on", &sep[1]))
2072 if (option_equals(
"off", &sep[1]))
2081 CLIP_DIR_PARSE_LOCAL,
2082 CLIP_DIR_PARSE_REMOTE,
2084 } PARSE_CLIP_DIR_RESULT;
2086 static PARSE_CLIP_DIR_RESULT parse_clip_direciton_to_option(
const char* value)
2088 WINPR_ASSERT(value);
2089 const char* sep = strchr(value,
':');
2091 return CLIP_DIR_PARSE_FAIL;
2092 if (option_equals(
"all", &sep[1]))
2093 return CLIP_DIR_PARSE_ALL;
2094 if (option_equals(
"off", &sep[1]))
2095 return CLIP_DIR_PARSE_OFF;
2096 if (option_equals(
"local", &sep[1]))
2097 return CLIP_DIR_PARSE_LOCAL;
2098 if (option_equals(
"remote", &sep[1]))
2099 return CLIP_DIR_PARSE_REMOTE;
2100 return CLIP_DIR_PARSE_FAIL;
2103 static int parse_tls_ciphers(rdpSettings* settings,
const char* Value)
2105 const char* ciphers = NULL;
2107 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2109 if (option_equals(Value,
"netmon"))
2111 ciphers =
"ALL:!ECDH:!ADH:!DHE";
2113 else if (option_equals(Value,
"ma"))
2115 ciphers =
"AES128-SHA";
2123 return COMMAND_LINE_ERROR_MEMORY;
2127 static int parse_tls_seclevel(rdpSettings* settings,
const char* Value)
2131 if (!value_to_int(Value, &val, 0, 5))
2132 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2135 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2139 static int parse_tls_secrets_file(rdpSettings* settings,
const char* Value)
2142 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2145 return COMMAND_LINE_ERROR_MEMORY;
2149 static int parse_tls_enforce(rdpSettings* settings,
const char* Value)
2151 UINT16 version = TLS1_2_VERSION;
2160 const struct map_t map[] = { {
"1.0", TLS1_VERSION },
2161 {
"1.1", TLS1_1_VERSION },
2162 {
"1.2", TLS1_2_VERSION }
2163 #if defined(TLS1_3_VERSION)
2165 {
"1.3", TLS1_3_VERSION }
2169 for (
size_t x = 0; x < ARRAYSIZE(map); x++)
2171 const struct map_t* cur = &map[x];
2172 if (option_equals(cur->name, Value))
2174 version = cur->version;
2182 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2188 int rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2189 CommandLineSwitchStart(arg) CommandLineSwitchCase(arg,
"tls")
2191 if (option_starts_with(
"ciphers:", arg->Value))
2192 rc = parse_tls_ciphers(settings, &arg->Value[8]);
2193 else if (option_starts_with(
"seclevel:", arg->Value))
2194 rc = parse_tls_seclevel(settings, &arg->Value[9]);
2195 else if (option_starts_with(
"secrets-file:", arg->Value))
2196 rc = parse_tls_secrets_file(settings, &arg->Value[13]);
2197 else if (option_starts_with(
"enforce:", arg->Value))
2198 rc = parse_tls_enforce(settings, &arg->Value[8]);
2201 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
2202 CommandLineSwitchCase(arg,
"tls-ciphers")
2204 WLog_WARN(TAG,
"Option /tls-ciphers is deprecated, use /tls:ciphers instead");
2205 rc = parse_tls_ciphers(settings, arg->Value);
2207 CommandLineSwitchCase(arg,
"tls-seclevel")
2209 WLog_WARN(TAG,
"Option /tls-seclevel is deprecated, use /tls:seclevel instead");
2210 rc = parse_tls_seclevel(settings, arg->Value);
2212 CommandLineSwitchCase(arg,
"tls-secrets-file")
2214 WLog_WARN(TAG,
"Option /tls-secrets-file is deprecated, use /tls:secrets-file instead");
2215 rc = parse_tls_secrets_file(settings, arg->Value);
2217 CommandLineSwitchCase(arg,
"enforce-tlsv1_2")
2219 WLog_WARN(TAG,
"Option /enforce-tlsv1_2 is deprecated, use /tls:enforce:1.2 instead");
2220 rc = parse_tls_enforce(settings,
"1.2");
2223 CommandLineSwitchDefault(arg)
2226 CommandLineSwitchEnd(arg)
2233 WINPR_ASSERT(settings);
2237 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
2238 for (
size_t x = 0; x < count; x++)
2241 larg.Value = ptr[x];
2243 int rc = parse_tls_cipher_options(settings, &larg);
2246 CommandLineParserFree(ptr);
2250 CommandLineParserFree(ptr);
2256 WINPR_ASSERT(settings);
2260 return COMMAND_LINE_ERROR;
2264 int rc = CHANNEL_RC_OK;
2266 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
2267 if (!ptr || (count == 0))
2268 rc = COMMAND_LINE_ERROR;
2271 BOOL GfxH264 = FALSE;
2272 BOOL GfxAVC444 = FALSE;
2273 BOOL RemoteFxCodec = FALSE;
2274 BOOL GfxProgressive = FALSE;
2275 BOOL codecSelected = FALSE;
2277 for (
size_t x = 0; x < count; x++)
2279 const char* val = ptr[x];
2280 #ifdef WITH_GFX_H264
2281 if (option_starts_with(
"AVC444", val))
2283 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2284 if (bval == PARSE_FAIL)
2285 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2287 GfxAVC444 = bval != PARSE_OFF;
2288 codecSelected = TRUE;
2290 else if (option_starts_with(
"AVC420", val))
2292 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2293 if (bval == PARSE_FAIL)
2294 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2296 GfxH264 = bval != PARSE_OFF;
2297 codecSelected = TRUE;
2301 if (option_starts_with(
"RFX", val))
2303 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2304 if (bval == PARSE_FAIL)
2305 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2307 RemoteFxCodec = bval != PARSE_OFF;
2308 codecSelected = TRUE;
2310 else if (option_starts_with(
"progressive", val))
2312 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2313 if (bval == PARSE_FAIL)
2314 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2316 GfxProgressive = bval != PARSE_OFF;
2317 codecSelected = TRUE;
2319 else if (option_starts_with(
"mask:", val))
2322 const char* uv = &val[5];
2323 if (!value_to_uint(uv, &v, 0, UINT32_MAX))
2324 rc = COMMAND_LINE_ERROR;
2329 rc = COMMAND_LINE_ERROR;
2332 else if (option_starts_with(
"small-cache", val))
2334 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2335 if (bval == PARSE_FAIL)
2336 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2339 rc = COMMAND_LINE_ERROR;
2341 else if (option_starts_with(
"thin-client", val))
2343 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2344 if (bval == PARSE_FAIL)
2345 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2348 rc = COMMAND_LINE_ERROR;
2349 if ((rc == CHANNEL_RC_OK) && (bval > 0))
2353 rc = COMMAND_LINE_ERROR;
2356 else if (option_starts_with(
"frame-ack", val))
2358 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2359 if (bval == PARSE_FAIL)
2360 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2363 rc = COMMAND_LINE_ERROR;
2366 rc = COMMAND_LINE_ERROR;
2369 if ((rc == CHANNEL_RC_OK) && codecSelected)
2372 rc = COMMAND_LINE_ERROR;
2374 rc = COMMAND_LINE_ERROR;
2376 rc = COMMAND_LINE_ERROR;
2378 rc = COMMAND_LINE_ERROR;
2380 rc = COMMAND_LINE_ERROR;
2383 CommandLineParserFree(ptr);
2384 if (rc != CHANNEL_RC_OK)
2387 return CHANNEL_RC_OK;
2390 static int parse_kbd_layout(rdpSettings* settings,
const char* value)
2392 WINPR_ASSERT(settings);
2393 WINPR_ASSERT(value);
2397 const BOOL isInt = value_to_int(value, &ival, 1, UINT32_MAX);
2400 ival = freerdp_map_keyboard_layout_name_to_id(value);
2404 WLog_ERR(TAG,
"Could not identify keyboard layout: %s", value);
2405 WLog_ERR(TAG,
"Use /list:kbd to list available layouts");
2406 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2413 rc = COMMAND_LINE_ERROR;
2418 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
2421 WINPR_ASSERT(settings);
2425 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2427 return COMMAND_LINE_ERROR;
2429 if (option_equals(arg->Value,
"rfx"))
2432 return COMMAND_LINE_ERROR;
2434 else if (option_equals(arg->Value,
"nsc"))
2437 return COMMAND_LINE_ERROR;
2440 #if defined(WITH_JPEG)
2441 else if (option_equals(arg->Value,
"jpeg"))
2444 return COMMAND_LINE_ERROR;
2449 return COMMAND_LINE_ERROR;
2458 static BOOL check_kbd_remap_valid(
const char* token)
2463 WINPR_ASSERT(token);
2465 if (strlen(token) > 10)
2468 if (!freerdp_extract_key_value(token, &key, &value))
2470 WLog_WARN(TAG,
"/kbd:remap invalid entry '%s'", token);
2478 WINPR_ASSERT(settings);
2482 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2484 return COMMAND_LINE_ERROR_MEMORY;
2485 char* p = strchr(arg->Value,
'[');
2490 const char scheme[] =
"://";
2491 const char* val = strstr(arg->Value, scheme);
2493 val += strnlen(scheme,
sizeof(scheme));
2496 p = strchr(val,
':');
2503 if (!value_to_int(&p[1], &lval, 1, UINT16_MAX))
2504 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2506 length = (size_t)(p - arg->Value);
2508 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2511 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2516 return COMMAND_LINE_ERROR_MEMORY;
2522 char* p2 = strchr(arg->Value,
']');
2526 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2528 length = (size_t)(p2 - p);
2530 return COMMAND_LINE_ERROR_MEMORY;
2532 if (*(p2 + 1) ==
':')
2536 if (!value_to_int(&p2[2], &val, 0, UINT16_MAX))
2537 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2540 return COMMAND_LINE_ERROR;
2543 printf(
"hostname %s port %" PRIu32
"\n",
2552 WINPR_ASSERT(settings);
2556 char* cur = arg->Value;
2558 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2560 return COMMAND_LINE_ERROR;
2566 char* next = strchr(cur,
',');
2574 if (option_equals(
"fqdn", cur))
2576 else if (option_equals(
"ip", cur))
2578 else if (option_equals(
"netbios", cur))
2581 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2584 mask = (mask & 0x07);
2585 value |= mask << (count * 3);
2587 }
while (cur != NULL);
2590 return COMMAND_LINE_ERROR;
2593 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2597 static int parse_prevent_session_lock_options(rdpSettings* settings,
2600 WINPR_ASSERT(settings);
2604 return COMMAND_LINE_ERROR_MEMORY;
2606 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
2610 if (!value_to_int(arg->Value, &val, 1, UINT32_MAX))
2611 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2614 return COMMAND_LINE_ERROR_MEMORY;
2622 WINPR_ASSERT(settings);
2626 return COMMAND_LINE_ERROR;
2633 return COMMAND_LINE_ERROR;
2635 return COMMAND_LINE_ERROR;
2637 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
2640 return COMMAND_LINE_ERROR;
2643 return COMMAND_LINE_ERROR_MEMORY;
2651 WINPR_ASSERT(settings);
2655 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2656 char* p = strchr(arg->Value,
'x');
2660 unsigned long w = 0;
2661 unsigned long h = 0;
2663 if (!parseSizeValue(arg->Value, &w, &h) || (w > UINT16_MAX) || (h > UINT16_MAX))
2664 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2667 return COMMAND_LINE_ERROR;
2669 return COMMAND_LINE_ERROR;
2673 char* str = _strdup(arg->Value);
2675 return COMMAND_LINE_ERROR_MEMORY;
2677 p = strchr(str,
'%');
2681 BOOL partial = FALSE;
2683 status = COMMAND_LINE_ERROR;
2710 if (!value_to_int(str, &val, 0, 100))
2712 status = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2732 WINPR_ASSERT(settings);
2735 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
2738 UINT32* MonitorIds = NULL;
2739 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
2742 return COMMAND_LINE_ERROR_MEMORY;
2749 CommandLineParserFree(ptr);
2753 MonitorIds = freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorIds, 0);
2754 for (UINT32 i = 0; i < count; i++)
2758 if (!value_to_int(ptr[i], &val, 0, UINT16_MAX))
2759 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2761 MonitorIds[i] = (UINT32)val;
2764 CommandLineParserFree(ptr);
2770 static int parse_dynamic_resolution_options(rdpSettings* settings,
2773 WINPR_ASSERT(settings);
2776 const BOOL val = arg->Value != 0;
2780 WLog_ERR(TAG,
"Smart sizing and dynamic resolution are mutually exclusive options");
2781 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2785 return COMMAND_LINE_ERROR;
2787 return COMMAND_LINE_ERROR;
2794 WINPR_ASSERT(settings);
2799 WLog_ERR(TAG,
"Smart sizing and dynamic resolution are mutually exclusive options");
2800 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2804 return COMMAND_LINE_ERROR;
2808 unsigned long w = 0;
2809 unsigned long h = 0;
2811 if (!parseSizeValue(arg->Value, &w, &h) || (w > UINT16_MAX) || (h > UINT16_MAX))
2812 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2815 return COMMAND_LINE_ERROR;
2817 return COMMAND_LINE_ERROR;
2824 WINPR_ASSERT(settings);
2829 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
2830 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2840 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2844 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2851 WINPR_ASSERT(settings);
2854 int rc = CHANNEL_RC_OK;
2856 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
2857 if (!ptr || (count == 0))
2858 rc = COMMAND_LINE_ERROR;
2861 for (
size_t x = 0; x < count; x++)
2863 const char* val = ptr[x];
2865 if (option_starts_with(
"remap:", val))
2868 char* now = _strdup(&val[6]);
2873 if (!check_kbd_remap_valid(now))
2874 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2877 const size_t olen = strlen(old);
2878 const size_t alen = strlen(now);
2879 const size_t tlen = olen + alen + 2;
2880 char* tmp = calloc(tlen,
sizeof(
char));
2882 rc = COMMAND_LINE_ERROR_MEMORY;
2884 (
void)_snprintf(tmp, tlen,
"%s,%s", old, now);
2892 rc = COMMAND_LINE_ERROR;
2896 else if (option_starts_with(
"layout:", val))
2898 rc = parse_kbd_layout(settings, &val[7]);
2900 else if (option_starts_with(
"lang:", val))
2903 const BOOL isInt = value_to_int(&val[5], &ival, 1, UINT32_MAX);
2905 ival = freerdp_get_locale_id_from_string(&val[5]);
2908 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2911 rc = COMMAND_LINE_ERROR;
2913 else if (option_starts_with(
"type:", val))
2916 const BOOL isInt = value_to_int(&val[5], &ival, 1, UINT32_MAX);
2918 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2920 rc = COMMAND_LINE_ERROR;
2922 else if (option_starts_with(
"subtype:", val))
2925 const BOOL isInt = value_to_int(&val[8], &ival, 1, UINT32_MAX);
2927 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2930 rc = COMMAND_LINE_ERROR;
2932 else if (option_starts_with(
"fn-key:", val))
2935 const BOOL isInt = value_to_int(&val[7], &ival, 1, UINT32_MAX);
2937 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2940 rc = COMMAND_LINE_ERROR;
2942 else if (option_starts_with(
"unicode", val))
2944 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
2945 if (bval == PARSE_FAIL)
2946 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2949 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2951 else if (option_starts_with(
"pipe:", val))
2954 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2956 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2958 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
2959 else if (count == 1)
2962 rc = parse_kbd_layout(settings, val);
2966 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2972 CommandLineParserFree(ptr);
2978 WINPR_ASSERT(settings);
2983 return COMMAND_LINE_ERROR_MEMORY;
2985 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
2987 const char* cur = arg->Value;
2990 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2992 if (!proxy_parse_uri(settings, cur))
2993 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
2997 WLog_ERR(TAG,
"Option http-proxy needs argument.");
2998 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3005 WINPR_ASSERT(settings);
3008 BOOL failed = FALSE;
3010 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3015 BOOL modernsyntax = FALSE;
3016 BOOL oldsyntax = FALSE;
3017 for (
size_t x = 0; (x < count) && !failed; x++)
3019 const char* carg = ptr[x];
3020 if (option_starts_with(
"file:", carg))
3022 const char* val = &carg[5];
3027 modernsyntax = TRUE;
3029 else if (option_equals(
"replay", carg))
3036 else if (option_equals(
"record", carg))
3043 else if (option_equals(
"nodelay", carg))
3050 modernsyntax = TRUE;
3065 if (oldsyntax && (count != 2))
3068 CommandLineParserFree(ptr);
3070 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3076 WINPR_ASSERT(settings);
3079 if (arg->Value == BoolValueTrue || arg->Value == BoolValueFalse)
3082 (arg->Value == BoolValueTrue)))
3083 return COMMAND_LINE_ERROR;
3089 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3090 for (
size_t x = 0; (x < count) && (rc == 0); x++)
3092 const char* usesel =
"use-selection:";
3094 const char* cur = ptr[x];
3095 if (option_starts_with(usesel, cur))
3097 const char* val = &cur[strlen(usesel)];
3099 rc = COMMAND_LINE_ERROR_MEMORY;
3101 return COMMAND_LINE_ERROR;
3103 else if (option_starts_with(
"direction-to", cur))
3107 ~(CLIPRDR_FLAG_LOCAL_TO_REMOTE | CLIPRDR_FLAG_REMOTE_TO_LOCAL);
3108 const PARSE_CLIP_DIR_RESULT bval = parse_clip_direciton_to_option(cur);
3112 case CLIP_DIR_PARSE_ALL:
3113 bflags |= CLIPRDR_FLAG_LOCAL_TO_REMOTE | CLIPRDR_FLAG_REMOTE_TO_LOCAL;
3115 case CLIP_DIR_PARSE_LOCAL:
3116 bflags |= CLIPRDR_FLAG_REMOTE_TO_LOCAL;
3118 case CLIP_DIR_PARSE_REMOTE:
3119 bflags |= CLIPRDR_FLAG_LOCAL_TO_REMOTE;
3121 case CLIP_DIR_PARSE_OFF:
3123 case CLIP_DIR_PARSE_FAIL:
3125 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3131 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3133 else if (option_starts_with(
"files-to", cur))
3137 ~(CLIPRDR_FLAG_LOCAL_TO_REMOTE_FILES | CLIPRDR_FLAG_REMOTE_TO_LOCAL_FILES);
3138 const PARSE_CLIP_DIR_RESULT bval = parse_clip_direciton_to_option(cur);
3142 case CLIP_DIR_PARSE_ALL:
3144 CLIPRDR_FLAG_LOCAL_TO_REMOTE_FILES | CLIPRDR_FLAG_REMOTE_TO_LOCAL_FILES;
3146 case CLIP_DIR_PARSE_LOCAL:
3147 bflags |= CLIPRDR_FLAG_REMOTE_TO_LOCAL_FILES;
3149 case CLIP_DIR_PARSE_REMOTE:
3150 bflags |= CLIPRDR_FLAG_LOCAL_TO_REMOTE_FILES;
3152 case CLIP_DIR_PARSE_OFF:
3154 case CLIP_DIR_PARSE_FAIL:
3156 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3162 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3165 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3167 CommandLineParserFree(ptr);
3177 WINPR_ASSERT(settings);
3182 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
3183 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3187 case AUDIO_MODE_REDIRECT:
3189 return COMMAND_LINE_ERROR;
3192 case AUDIO_MODE_PLAY_ON_SERVER:
3194 return COMMAND_LINE_ERROR;
3197 case AUDIO_MODE_NONE:
3199 return COMMAND_LINE_ERROR;
3201 return COMMAND_LINE_ERROR;
3205 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3212 WINPR_ASSERT(settings);
3215 UINT32 type = CONNECTION_TYPE_INVALID;
3217 if (option_equals(arg->Value,
"invalid"))
3218 type = CONNECTION_TYPE_INVALID;
3219 else if (option_equals(arg->Value,
"modem"))
3220 type = CONNECTION_TYPE_MODEM;
3221 else if (option_equals(arg->Value,
"broadband"))
3222 type = CONNECTION_TYPE_BROADBAND_HIGH;
3223 else if (option_equals(arg->Value,
"broadband-low"))
3224 type = CONNECTION_TYPE_BROADBAND_LOW;
3225 else if (option_equals(arg->Value,
"broadband-high"))
3226 type = CONNECTION_TYPE_BROADBAND_HIGH;
3227 else if (option_equals(arg->Value,
"wan"))
3228 type = CONNECTION_TYPE_WAN;
3229 else if (option_equals(arg->Value,
"lan"))
3230 type = CONNECTION_TYPE_LAN;
3231 else if ((option_equals(arg->Value,
"autodetect")) || (option_equals(arg->Value,
"auto")) ||
3232 (option_equals(arg->Value,
"detect")))
3234 type = CONNECTION_TYPE_AUTODETECT;
3240 if (!value_to_int(arg->Value, &val, 0, 7))
3241 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3246 if (!freerdp_set_connection_type(settings, type))
3247 return COMMAND_LINE_ERROR;
3253 WINPR_ASSERT(settings);
3257 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3259 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3261 FreeRDP_Settings_Keys_Bool singleOptionWithoutOnOff = FreeRDP_BOOL_UNUSED;
3262 for (
size_t x = 0; x < count; x++)
3264 const char* cur = ptr[x];
3265 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(cur);
3266 if (bval == PARSE_FAIL)
3268 CommandLineParserFree(ptr);
3269 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3272 const BOOL val = bval != PARSE_OFF;
3273 FreeRDP_Settings_Keys_Bool
id = FreeRDP_BOOL_UNUSED;
3274 if (option_starts_with(
"rdp", cur))
3276 id = FreeRDP_RdpSecurity;
3278 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3280 else if (option_starts_with(
"tls", cur))
3281 id = FreeRDP_TlsSecurity;
3282 else if (option_starts_with(
"nla", cur))
3283 id = FreeRDP_NlaSecurity;
3284 else if (option_starts_with(
"ext", cur))
3285 id = FreeRDP_ExtSecurity;
3286 else if (option_equals(
"aad", cur))
3287 id = FreeRDP_AadSecurity;
3290 WLog_ERR(TAG,
"unknown protocol security: %s", arg->Value);
3291 CommandLineParserFree(ptr);
3292 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3295 if ((bval == PARSE_NONE) && (count == 1))
3296 singleOptionWithoutOnOff = id;
3298 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3301 if (singleOptionWithoutOnOff != FreeRDP_BOOL_UNUSED)
3303 const FreeRDP_Settings_Keys_Bool options[] = { FreeRDP_AadSecurity,
3304 FreeRDP_UseRdpSecurityLayer,
3305 FreeRDP_RdpSecurity, FreeRDP_NlaSecurity,
3306 FreeRDP_TlsSecurity };
3308 for (
size_t i = 0; i < ARRAYSIZE(options); i++)
3311 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3315 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3316 if (singleOptionWithoutOnOff == FreeRDP_RdpSecurity)
3319 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3322 CommandLineParserFree(ptr);
3326 static int parse_encryption_methods_options(rdpSettings* settings,
3329 WINPR_ASSERT(settings);
3332 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
3335 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3337 UINT32 EncryptionMethods = 0;
3338 for (UINT32 i = 0; i < count; i++)
3340 if (option_equals(ptr[i],
"40"))
3341 EncryptionMethods |= ENCRYPTION_METHOD_40BIT;
3342 else if (option_equals(ptr[i],
"56"))
3343 EncryptionMethods |= ENCRYPTION_METHOD_56BIT;
3344 else if (option_equals(ptr[i],
"128"))
3345 EncryptionMethods |= ENCRYPTION_METHOD_128BIT;
3346 else if (option_equals(ptr[i],
"FIPS"))
3347 EncryptionMethods |= ENCRYPTION_METHOD_FIPS;
3349 WLog_ERR(TAG,
"unknown encryption method '%s'", ptr[i]);
3353 return COMMAND_LINE_ERROR;
3354 CommandLineParserFree(ptr);
3361 WINPR_ASSERT(settings);
3366 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3367 for (
size_t x = 0; (x < count) && (rc == 0); x++)
3369 const char deny[] =
"deny";
3370 const char ignore[] =
"ignore";
3371 const char tofu[] =
"tofu";
3372 const char name[] =
"name:";
3373 const char fingerprints[] =
"fingerprint:";
3375 const char* cur = ptr[x];
3376 if (option_equals(deny, cur))
3379 return COMMAND_LINE_ERROR;
3381 else if (option_equals(ignore, cur))
3384 return COMMAND_LINE_ERROR;
3386 else if (option_equals(tofu, cur))
3389 return COMMAND_LINE_ERROR;
3391 else if (option_starts_with(name, cur))
3393 const char* val = &cur[strnlen(name,
sizeof(name))];
3395 rc = COMMAND_LINE_ERROR_MEMORY;
3397 else if (option_starts_with(fingerprints, cur))
3399 const char* val = &cur[strnlen(fingerprints,
sizeof(fingerprints))];
3402 rc = COMMAND_LINE_ERROR_MEMORY;
3405 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3407 CommandLineParserFree(ptr);
3414 WINPR_ASSERT(settings);
3418 char** ptr = CommandLineParseCommaSeparatedValuesEx(
"mouse", arg->Value, &count);
3422 for (
size_t x = 1; x < count; x++)
3424 const char* cur = ptr[x];
3426 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(cur);
3427 if (bval == PARSE_FAIL)
3428 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3431 const BOOL val = bval != PARSE_OFF;
3433 if (option_starts_with(
"relative", cur))
3436 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3438 else if (option_starts_with(
"grab", cur))
3441 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3449 CommandLineParserFree(ptr);
3456 WINPR_ASSERT(settings);
3460 UINT32 Floatbar = 0x0017;
3464 char* start = arg->Value;
3469 start = strchr(start,
',');
3478 if (option_starts_with(
"sticky:", cur))
3482 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(cur);
3494 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3498 else if (option_starts_with(
"default:", cur))
3500 const char* val = cur + 8;
3503 if (option_equals(
"visible", val))
3505 else if (option_equals(
"hidden", val))
3508 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3511 else if (option_starts_with(
"show:", cur))
3513 const char* val = cur + 5;
3516 if (option_equals(
"always", val))
3518 else if (option_equals(
"fullscreen", val))
3520 else if (option_equals(
"window", val))
3523 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3526 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3530 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3536 WINPR_ASSERT(settings);
3539 BYTE* base64 = NULL;
3542 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3544 crypto_base64_decode((
const char*)(arg->Value), strlen(arg->Value), &base64, &length);
3550 return COMMAND_LINE_ERROR;
3554 WLog_ERR(TAG,
"reconnect-cookie: invalid base64 '%s'", arg->Value);
3563 WINPR_ASSERT(settings);
3568 if (!value_to_int(arg->Value, &val, 100, 180))
3569 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3577 return COMMAND_LINE_ERROR;
3579 return COMMAND_LINE_ERROR;
3583 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3590 WINPR_ASSERT(settings);
3595 if (!value_to_int(arg->Value, &val, 100, 180))
3596 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3604 return COMMAND_LINE_ERROR;
3608 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3615 WINPR_ASSERT(settings);
3621 return COMMAND_LINE_ERROR;
3623 char** ptr = CommandLineParseCommaSeparatedValuesEx(
"smartcard-logon", arg->Value, &count);
3626 const CmdLineSubOptions opts[] = {
3627 {
"cert:", FreeRDP_SmartcardCertificate, CMDLINE_SUBOPTION_FILE,
3628 setSmartcardEmulation },
3629 {
"key:", FreeRDP_SmartcardPrivateKey, CMDLINE_SUBOPTION_FILE, setSmartcardEmulation },
3630 {
"pin:", FreeRDP_Password, CMDLINE_SUBOPTION_STRING, NULL },
3631 {
"csp:", FreeRDP_CspName, CMDLINE_SUBOPTION_STRING, NULL },
3632 {
"reader:", FreeRDP_ReaderName, CMDLINE_SUBOPTION_STRING, NULL },
3633 {
"card:", FreeRDP_CardName, CMDLINE_SUBOPTION_STRING, NULL },
3634 {
"container:", FreeRDP_ContainerName, CMDLINE_SUBOPTION_STRING, NULL }
3637 for (
size_t x = 1; x < count; x++)
3639 const char* cur = ptr[x];
3640 if (!parseSubOptions(settings, opts, ARRAYSIZE(opts), cur))
3642 CommandLineParserFree(ptr);
3643 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3647 CommandLineParserFree(ptr);
3653 WINPR_ASSERT(settings);
3657 char** ptr = CommandLineParseCommaSeparatedValuesEx(
"tune", arg->Value, &count);
3659 return COMMAND_LINE_ERROR;
3660 for (
size_t x = 1; x < count; x++)
3662 const char* cur = ptr[x];
3663 char* sep = strchr(cur,
':');
3666 CommandLineParserFree(ptr);
3667 return COMMAND_LINE_ERROR;
3670 if (!freerdp_settings_set_value_for_name(settings, cur, sep))
3672 CommandLineParserFree(ptr);
3673 return COMMAND_LINE_ERROR;
3677 CommandLineParserFree(ptr);
3681 static int parse_app_option_program(rdpSettings* settings,
const char* cmd)
3683 const FreeRDP_Settings_Keys_Bool ids[] = { FreeRDP_RemoteApplicationMode,
3684 FreeRDP_RemoteAppLanguageBarSupported,
3685 FreeRDP_Workarea, FreeRDP_DisableWallpaper,
3686 FreeRDP_DisableFullWindowDrag };
3689 return COMMAND_LINE_ERROR_MEMORY;
3691 for (
size_t y = 0; y < ARRAYSIZE(ids); y++)
3694 return COMMAND_LINE_ERROR;
3696 return CHANNEL_RC_OK;
3701 WINPR_ASSERT(settings);
3704 int rc = CHANNEL_RC_OK;
3706 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3707 if (!ptr || (count == 0))
3708 rc = COMMAND_LINE_ERROR;
3715 int (*fkt)(rdpSettings* settings,
const char* value);
3717 const struct app_map amap[] = { {
"program:", FreeRDP_RemoteApplicationProgram,
3718 parse_app_option_program },
3719 {
"workdir:", FreeRDP_RemoteApplicationWorkingDir, NULL },
3720 {
"name:", FreeRDP_RemoteApplicationName, NULL },
3721 {
"icon:", FreeRDP_RemoteApplicationIcon, NULL },
3722 {
"cmd:", FreeRDP_RemoteApplicationCmdLine, NULL },
3723 {
"file:", FreeRDP_RemoteApplicationFile, NULL },
3724 {
"guid:", FreeRDP_RemoteApplicationGuid, NULL },
3725 {
"hidef:", FreeRDP_HiDefRemoteApp, NULL } };
3726 for (
size_t x = 0; x < count; x++)
3728 BOOL handled = FALSE;
3729 const char* val = ptr[x];
3731 for (
size_t y = 0; y < ARRAYSIZE(amap); y++)
3733 const struct app_map* cur = &amap[y];
3734 if (option_starts_with(cur->name, val))
3736 const char* xval = &val[strlen(cur->name)];
3738 rc = cur->fkt(settings, xval);
3742 if (!freerdp_settings_set_value_for_name(settings, name, xval))
3743 rc = COMMAND_LINE_ERROR_MEMORY;
3751 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
3752 if (!handled && (count == 1))
3755 rc = parse_app_option_program(settings, val);
3760 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3767 CommandLineParserFree(ptr);
3773 WINPR_ASSERT(settings);
3776 int rc = CHANNEL_RC_OK;
3778 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3779 if (!ptr || (count == 0))
3780 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3782 for (
size_t x = 0; x < count; x++)
3784 const char* val = ptr[x];
3786 if (option_starts_with(
"codec:", val))
3789 rc = COMMAND_LINE_ERROR;
3790 else if (option_equals(arg->Value,
"rfx"))
3793 rc = COMMAND_LINE_ERROR;
3795 else if (option_equals(arg->Value,
"nsc"))
3798 rc = COMMAND_LINE_ERROR;
3801 #if defined(WITH_JPEG)
3802 else if (option_equals(arg->Value,
"jpeg"))
3805 rc = COMMAND_LINE_ERROR;
3810 return COMMAND_LINE_ERROR;
3816 else if (option_starts_with(
"persist-file:", val))
3820 rc = COMMAND_LINE_ERROR_MEMORY;
3822 rc = COMMAND_LINE_ERROR;
3826 const PARSE_ON_OFF_RESULT bval = parse_on_off_option(val);
3827 if (bval == PARSE_FAIL)
3828 rc = COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
3831 if (option_starts_with(
"bitmap", val))
3835 rc = COMMAND_LINE_ERROR;
3837 else if (option_starts_with(
"glyph", val))
3840 bval != PARSE_OFF ? GLYPH_SUPPORT_FULL
3841 : GLYPH_SUPPORT_NONE))
3842 rc = COMMAND_LINE_ERROR;
3844 else if (option_starts_with(
"persist", val))
3848 rc = COMMAND_LINE_ERROR;
3850 else if (option_starts_with(
"offscreen", val))
3854 rc = COMMAND_LINE_ERROR;
3860 CommandLineParserFree(ptr);
3864 static BOOL parse_gateway_host_option(rdpSettings* settings,
const char* host)
3866 WINPR_ASSERT(settings);
3871 if (!freerdp_parse_hostname(host, &name, &port))
3885 static BOOL parse_gateway_cred_option(rdpSettings* settings,
const char* value,
3886 FreeRDP_Settings_Keys_String what)
3888 WINPR_ASSERT(settings);
3889 WINPR_ASSERT(value);
3893 case FreeRDP_GatewayUsername:
3894 if (!freerdp_parse_username_settings(value, settings, FreeRDP_GatewayUsername,
3895 FreeRDP_GatewayDomain))
3907 static BOOL parse_gateway_type_option(rdpSettings* settings,
const char* value)
3909 WINPR_ASSERT(settings);
3910 WINPR_ASSERT(value);
3912 if (option_equals(value,
"rpc"))
3922 if (option_equals(value,
"http"))
3929 else if (option_equals(value,
"auto"))
3936 else if (option_equals(value,
"arm"))
3948 static BOOL parse_gateway_usage_option(rdpSettings* settings,
const char* value)
3952 WINPR_ASSERT(settings);
3953 WINPR_ASSERT(value);
3955 if (option_equals(value,
"none"))
3956 type = TSC_PROXY_MODE_NONE_DIRECT;
3957 else if (option_equals(value,
"direct"))
3958 type = TSC_PROXY_MODE_DIRECT;
3959 else if (option_equals(value,
"detect"))
3960 type = TSC_PROXY_MODE_DETECT;
3961 else if (option_equals(value,
"default"))
3962 type = TSC_PROXY_MODE_DEFAULT;
3967 if (!value_to_int(value, &val, TSC_PROXY_MODE_NONE_DIRECT, TSC_PROXY_MODE_NONE_DETECT))
3978 WINPR_ASSERT(settings);
3982 char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count);
3990 BOOL allowHttpOpts = FALSE;
3991 for (
size_t x = 0; x < count; x++)
3993 BOOL validOption = FALSE;
3994 const char* argval = ptr[x];
3996 WINPR_ASSERT(argval);
3998 const char* gw = option_starts_with(
"g:", argval);
4001 if (!parse_gateway_host_option(settings, gw))
4004 allowHttpOpts = FALSE;
4007 const char* gu = option_starts_with(
"u:", argval);
4010 if (!parse_gateway_cred_option(settings, gu, FreeRDP_GatewayUsername))
4013 allowHttpOpts = FALSE;
4016 const char* gd = option_starts_with(
"d:", argval);
4019 if (!parse_gateway_cred_option(settings, gd, FreeRDP_GatewayDomain))
4022 allowHttpOpts = FALSE;
4025 const char* gp = option_starts_with(
"p:", argval);
4028 if (!parse_gateway_cred_option(settings, gp, FreeRDP_GatewayPassword))
4031 allowHttpOpts = FALSE;
4034 const char* gt = option_starts_with(
"type:", argval);
4037 if (!parse_gateway_type_option(settings, gt))
4043 const char* gat = option_starts_with(
"access-token:", argval);
4049 allowHttpOpts = FALSE;
4052 const char* bearer = option_starts_with(
"bearer:", argval);
4058 allowHttpOpts = FALSE;
4061 const char* gwurl = option_starts_with(
"url:", argval);
4069 allowHttpOpts = FALSE;
4072 const char* um = option_starts_with(
"usage-method:", argval);
4075 if (!parse_gateway_usage_option(settings, um))
4078 allowHttpOpts = FALSE;
4083 if (option_equals(argval,
"no-websockets"))
4089 else if (option_equals(argval,
"extauth-sspi-ntlm"))
4103 CommandLineParserFree(ptr);
4110 WINPR_ASSERT(value);
4116 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
4117 FillMemory(arg->Value, strlen(arg->Value),
'*');
4122 const char* credentials[] = {
4125 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
4134 for (
size_t x = 0; x < ARRAYSIZE(credentials); x++)
4136 const char* cred = credentials[x];
4137 fill_credential_string(args, cred);
4141 if (arg && ((arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT) != 0))
4143 const char* gwcreds[] = {
"p:",
"access-token:" };
4144 char* saveptr = NULL;
4145 char* tok = strtok_s(arg->Value,
",", &saveptr);
4148 for (
size_t x = 0; x < ARRAYSIZE(gwcreds); x++)
4150 const char* opt = gwcreds[x];
4151 if (option_starts_with(opt, tok))
4153 char* val = &tok[strlen(opt)];
4154 FillMemory(val, strlen(val),
'*');
4157 tok = strtok_s(NULL,
",", &saveptr);
4162 static int freerdp_client_settings_parse_command_line_arguments_int(
4163 rdpSettings* settings,
int argc,
char* argv[], BOOL allowUnknown,
4170 BOOL assist = FALSE;
4172 BOOL promptForPassword = FALSE;
4173 BOOL compatibility = FALSE;
4181 ext = option_is_rdp_file(argv[1]);
4182 assist = option_is_incident_file(argv[1]);
4185 if (!ext && !assist)
4186 compatibility = freerdp_client_detect_command_line(argc, argv, &flags);
4188 compatibility = freerdp_client_detect_command_line(argc - 1, &argv[1], &flags);
4199 WLog_WARN(TAG,
"Unsupported command line syntax!");
4200 WLog_WARN(TAG,
"FreeRDP 1.0 style syntax was dropped with version 3!");
4206 flags |= COMMAND_LINE_IGN_UNKNOWN_KEYWORD;
4210 if (freerdp_client_settings_parse_connection_file(settings, argv[1]))
4211 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
4216 if (freerdp_client_settings_parse_assistance_file(settings, argc, argv) < 0)
4217 return COMMAND_LINE_ERROR_UNEXPECTED_VALUE;
4220 CommandLineClearArgumentsA(largs);
4221 status = CommandLineParseArgumentsA(argc, argv, largs, flags, settings,
4222 freerdp_client_command_line_pre_filter,
4223 freerdp_client_command_line_post_filter);
4228 prepare_default_settings(settings, largs, ext);
4231 CommandLineFindArgumentA(largs,
"v");
4237 return COMMAND_LINE_ERROR_MEMORY;
4241 BOOL enable = arg->Value ? TRUE : FALSE;
4243 if (!(arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT))
4246 CommandLineSwitchStart(arg)
4248 CommandLineSwitchCase(arg,
"v")
4250 const int rc = parse_host_options(settings, arg);
4252 return fail_at(arg, rc);
4254 CommandLineSwitchCase(arg,
"spn-class")
4258 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4260 CommandLineSwitchCase(arg,
"sspi-module")
4263 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4265 CommandLineSwitchCase(arg,
"winscard-module")
4268 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4270 CommandLineSwitchCase(arg,
"redirect-prefer")
4272 const int rc = parse_redirect_prefer_options(settings, arg);
4274 return fail_at(arg, rc);
4276 CommandLineSwitchCase(arg,
"credentials-delegation")
4279 return fail_at(arg, COMMAND_LINE_ERROR);
4281 CommandLineSwitchCase(arg,
"prevent-session-lock")
4283 const int rc = parse_prevent_session_lock_options(settings, arg);
4285 return fail_at(arg, rc);
4287 CommandLineSwitchCase(arg,
"vmconnect")
4289 const int rc = parse_vmconnect_options(settings, arg);
4291 return fail_at(arg, rc);
4293 CommandLineSwitchCase(arg,
"w")
4297 if (!value_to_int(arg->Value, &val, -1, UINT32_MAX))
4298 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4301 return fail_at(arg, COMMAND_LINE_ERROR);
4303 CommandLineSwitchCase(arg,
"h")
4307 if (!value_to_int(arg->Value, &val, -1, UINT32_MAX))
4308 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4311 return fail_at(arg, COMMAND_LINE_ERROR);
4313 CommandLineSwitchCase(arg,
"size")
4315 const int rc = parse_size_options(settings, arg);
4317 return fail_at(arg, rc);
4319 CommandLineSwitchCase(arg,
"f")
4322 return fail_at(arg, COMMAND_LINE_ERROR);
4324 CommandLineSwitchCase(arg,
"suppress-output")
4327 return fail_at(arg, COMMAND_LINE_ERROR);
4329 CommandLineSwitchCase(arg,
"multimon")
4332 return fail_at(arg, COMMAND_LINE_ERROR);
4334 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
4336 if (option_equals(arg->Value, str_force))
4339 return fail_at(arg, COMMAND_LINE_ERROR);
4343 CommandLineSwitchCase(arg,
"span")
4346 return fail_at(arg, COMMAND_LINE_ERROR);
4348 CommandLineSwitchCase(arg,
"workarea")
4351 return fail_at(arg, COMMAND_LINE_ERROR);
4353 CommandLineSwitchCase(arg,
"monitors")
4355 const int rc = parse_monitors_options(settings, arg);
4357 return fail_at(arg, rc);
4359 CommandLineSwitchCase(arg,
"t")
4362 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4364 CommandLineSwitchCase(arg,
"decorations")
4367 return fail_at(arg, COMMAND_LINE_ERROR);
4369 CommandLineSwitchCase(arg,
"dynamic-resolution")
4371 const int rc = parse_dynamic_resolution_options(settings, arg);
4373 return fail_at(arg, rc);
4375 CommandLineSwitchCase(arg,
"smart-sizing")
4377 const int rc = parse_smart_sizing_options(settings, arg);
4379 return fail_at(arg, rc);
4381 CommandLineSwitchCase(arg,
"bpp")
4383 const int rc = parse_bpp_options(settings, arg);
4385 return fail_at(arg, rc);
4387 CommandLineSwitchCase(arg,
"admin")
4390 return fail_at(arg, COMMAND_LINE_ERROR);
4392 CommandLineSwitchCase(arg,
"relax-order-checks")
4396 return fail_at(arg, COMMAND_LINE_ERROR);
4398 CommandLineSwitchCase(arg,
"restricted-admin")
4401 return fail_at(arg, COMMAND_LINE_ERROR);
4403 return fail_at(arg, COMMAND_LINE_ERROR);
4405 CommandLineSwitchCase(arg,
"remoteGuard")
4408 return fail_at(arg, COMMAND_LINE_ERROR);
4410 return fail_at(arg, COMMAND_LINE_ERROR);
4412 CommandLineSwitchCase(arg,
"pth")
4415 return fail_at(arg, COMMAND_LINE_ERROR);
4417 return fail_at(arg, COMMAND_LINE_ERROR);
4420 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4422 CommandLineSwitchCase(arg,
"client-hostname")
4425 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4427 CommandLineSwitchCase(arg,
"kbd")
4429 int rc = parse_kbd_options(settings, arg);
4431 return fail_at(arg, rc);
4433 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
4434 CommandLineSwitchCase(arg,
"kbd-remap")
4436 WLog_WARN(TAG,
"/kbd-remap:<key>=<value>,<key2>=<value2> is deprecated, use "
4437 "/kbd:remap:<key>=<value>,remap:<key2>=<value2>,... instead");
4439 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4441 CommandLineSwitchCase(arg,
"kbd-lang")
4445 WLog_WARN(TAG,
"/kbd-lang:<value> is deprecated, use /kbd:lang:<value> instead");
4446 if (!value_to_int(arg->Value, &val, 1, UINT32_MAX))
4448 WLog_ERR(TAG,
"Could not identify keyboard active language %s", arg->Value);
4449 WLog_ERR(TAG,
"Use /list:kbd-lang to list available layouts");
4450 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4454 return fail_at(arg, COMMAND_LINE_ERROR);
4456 CommandLineSwitchCase(arg,
"kbd-type")
4460 WLog_WARN(TAG,
"/kbd-type:<value> is deprecated, use /kbd:type:<value> instead");
4461 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
4462 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4465 return fail_at(arg, COMMAND_LINE_ERROR);
4467 CommandLineSwitchCase(arg,
"kbd-unicode")
4469 WLog_WARN(TAG,
"/kbd-unicode is deprecated, use /kbd:unicode[:on|off] instead");
4471 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4473 CommandLineSwitchCase(arg,
"kbd-subtype")
4477 WLog_WARN(TAG,
"/kbd-subtype:<value> is deprecated, use /kbd:subtype:<value> instead");
4478 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
4479 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4482 return fail_at(arg, COMMAND_LINE_ERROR);
4484 CommandLineSwitchCase(arg,
"kbd-fn-key")
4488 WLog_WARN(TAG,
"/kbd-fn-key:<value> is deprecated, use /kbd:fn-key:<value> instead");
4489 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
4490 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4493 return fail_at(arg, COMMAND_LINE_ERROR);
4496 CommandLineSwitchCase(arg,
"u")
4498 WINPR_ASSERT(arg->Value);
4501 CommandLineSwitchCase(arg,
"d")
4504 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4506 CommandLineSwitchCase(arg,
"p")
4509 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4511 CommandLineSwitchCase(arg,
"gateway")
4513 if (!parse_gateway_options(settings, arg))
4514 return fail_at(arg, COMMAND_LINE_ERROR);
4516 CommandLineSwitchCase(arg,
"proxy")
4518 const int rc = parse_proxy_options(settings, arg);
4520 return fail_at(arg, rc);
4522 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
4523 CommandLineSwitchCase(arg,
"g")
4525 if (!parse_gateway_host_option(settings, arg->Value))
4526 return fail_at(arg, COMMAND_LINE_ERROR);
4528 CommandLineSwitchCase(arg,
"gu")
4530 if (!parse_gateway_cred_option(settings, arg->Value, FreeRDP_GatewayUsername))
4531 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4533 CommandLineSwitchCase(arg,
"gd")
4535 if (!parse_gateway_cred_option(settings, arg->Value, FreeRDP_GatewayDomain))
4536 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4538 CommandLineSwitchCase(arg,
"gp")
4540 if (!parse_gateway_cred_option(settings, arg->Value, FreeRDP_GatewayPassword))
4541 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4543 CommandLineSwitchCase(arg,
"gt")
4545 if (!parse_gateway_type_option(settings, arg->Value))
4546 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4548 CommandLineSwitchCase(arg,
"gat")
4551 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4553 CommandLineSwitchCase(arg,
"gateway-usage-method")
4555 if (!parse_gateway_usage_option(settings, arg->Value))
4556 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4559 CommandLineSwitchCase(arg,
"app")
4561 int rc = parse_app_options(settings, arg);
4563 return fail_at(arg, rc);
4565 CommandLineSwitchCase(arg,
"load-balance-info")
4567 WINPR_ASSERT(arg->Value);
4569 strlen(arg->Value)))
4570 return fail_at(arg, COMMAND_LINE_ERROR);
4572 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
4573 CommandLineSwitchCase(arg,
"app-workdir")
4577 "/app-workdir:<directory> is deprecated, use /app:workdir:<directory> instead");
4580 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4582 CommandLineSwitchCase(arg,
"app-name")
4584 WLog_WARN(TAG,
"/app-name:<directory> is deprecated, use /app:name:<name> instead");
4586 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4588 CommandLineSwitchCase(arg,
"app-icon")
4590 WLog_WARN(TAG,
"/app-icon:<filename> is deprecated, use /app:icon:<filename> instead");
4592 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4594 CommandLineSwitchCase(arg,
"app-cmd")
4596 WLog_WARN(TAG,
"/app-cmd:<command> is deprecated, use /app:cmd:<command> instead");
4599 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4601 CommandLineSwitchCase(arg,
"app-file")
4603 WLog_WARN(TAG,
"/app-file:<filename> is deprecated, use /app:file:<filename> instead");
4605 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4607 CommandLineSwitchCase(arg,
"app-guid")
4609 WLog_WARN(TAG,
"/app-guid:<guid> is deprecated, use /app:guid:<guid> instead");
4611 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4614 CommandLineSwitchCase(arg,
"compression")
4617 return fail_at(arg, COMMAND_LINE_ERROR);
4619 CommandLineSwitchCase(arg,
"compression-level")
4623 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
4624 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4627 return fail_at(arg, COMMAND_LINE_ERROR);
4629 CommandLineSwitchCase(arg,
"drives")
4632 return fail_at(arg, COMMAND_LINE_ERROR);
4634 CommandLineSwitchCase(arg,
"dump")
4636 const int rc = parse_dump_options(settings, arg);
4638 return fail_at(arg, rc);
4640 CommandLineSwitchCase(arg,
"disable-output")
4643 return fail_at(arg, COMMAND_LINE_ERROR);
4645 CommandLineSwitchCase(arg,
"home-drive")
4648 return fail_at(arg, COMMAND_LINE_ERROR);
4650 CommandLineSwitchCase(arg,
"ipv4")
4652 if (arg->Value != NULL && strncmp(arg->Value, str_force, ARRAYSIZE(str_force)) == 0)
4655 return fail_at(arg, COMMAND_LINE_ERROR);
4660 return fail_at(arg, COMMAND_LINE_ERROR);
4663 CommandLineSwitchCase(arg,
"ipv6")
4665 if (arg->Value != NULL && strncmp(arg->Value, str_force, ARRAYSIZE(str_force)) == 0)
4668 return fail_at(arg, COMMAND_LINE_ERROR);
4673 return fail_at(arg, COMMAND_LINE_ERROR);
4676 CommandLineSwitchCase(arg,
"clipboard")
4678 const int rc = parse_clipboard_options(settings, arg);
4680 return fail_at(arg, rc);
4682 CommandLineSwitchCase(arg,
"server-name")
4685 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4687 CommandLineSwitchCase(arg,
"shell")
4690 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4692 CommandLineSwitchCase(arg,
"shell-dir")
4695 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4697 CommandLineSwitchCase(arg,
"audio-mode")
4699 const int rc = parse_audio_mode_options(settings, arg);
4701 return fail_at(arg, rc);
4703 CommandLineSwitchCase(arg,
"network")
4705 const int rc = parse_network_options(settings, arg);
4707 return fail_at(arg, rc);
4709 CommandLineSwitchCase(arg,
"fonts")
4712 return fail_at(arg, COMMAND_LINE_ERROR);
4714 CommandLineSwitchCase(arg,
"wallpaper")
4717 return fail_at(arg, COMMAND_LINE_ERROR);
4719 CommandLineSwitchCase(arg,
"window-drag")
4722 return fail_at(arg, COMMAND_LINE_ERROR);
4724 CommandLineSwitchCase(arg,
"window-position")
4726 unsigned long x = 0;
4727 unsigned long y = 0;
4730 return fail_at(arg, COMMAND_LINE_ERROR_MISSING_ARGUMENT);
4732 if (!parseSizeValue(arg->Value, &x, &y) || x > UINT16_MAX || y > UINT16_MAX)
4734 WLog_ERR(TAG,
"invalid window-position argument");
4735 return fail_at(arg, COMMAND_LINE_ERROR_MISSING_ARGUMENT);
4739 return fail_at(arg, COMMAND_LINE_ERROR);
4741 return fail_at(arg, COMMAND_LINE_ERROR);
4743 CommandLineSwitchCase(arg,
"menu-anims")
4746 return fail_at(arg, COMMAND_LINE_ERROR);
4748 CommandLineSwitchCase(arg,
"themes")
4751 return fail_at(arg, COMMAND_LINE_ERROR);
4753 CommandLineSwitchCase(arg,
"timeout")
4756 if (!value_to_uint(arg->Value, &val, 1, 600000))
4757 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4759 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4761 CommandLineSwitchCase(arg,
"timezone")
4766 char TimeZoneKeyName[ARRAYSIZE(info.TimeZoneKeyName) + 1] = { 0 };
4767 while (EnumDynamicTimeZoneInformation(index++, &info) != ERROR_NO_MORE_ITEMS)
4769 (void)ConvertWCharNToUtf8(info.TimeZoneKeyName, ARRAYSIZE(info.TimeZoneKeyName),
4770 TimeZoneKeyName, ARRAYSIZE(TimeZoneKeyName));
4772 WINPR_ASSERT(arg->Value);
4773 if (strncmp(TimeZoneKeyName, arg->Value, ARRAYSIZE(TimeZoneKeyName)) == 0)
4780 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4784 return fail_at(arg, COMMAND_LINE_ERROR);
4789 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4791 tz->Bias = info.Bias;
4792 tz->DaylightBias = info.DaylightBias;
4793 tz->DaylightDate = info.DaylightDate;
4794 memcpy(tz->DaylightName, info.DaylightName,
sizeof(tz->DaylightName));
4795 tz->StandardBias = info.StandardBias;
4796 tz->StandardDate = info.StandardDate;
4797 memcpy(tz->StandardName, info.StandardName,
sizeof(tz->StandardName));
4799 CommandLineSwitchCase(arg,
"aero")
4802 return fail_at(arg, COMMAND_LINE_ERROR);
4804 CommandLineSwitchCase(arg,
"gdi")
4806 if (option_equals(arg->Value,
"sw"))
4809 return fail_at(arg, COMMAND_LINE_ERROR);
4811 else if (option_equals(arg->Value,
"hw"))
4814 return fail_at(arg, COMMAND_LINE_ERROR);
4817 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4819 CommandLineSwitchCase(arg,
"gfx")
4821 int rc = parse_gfx_options(settings, arg);
4823 return fail_at(arg, rc);
4825 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
4826 CommandLineSwitchCase(arg,
"gfx-thin-client")
4828 WLog_WARN(TAG,
"/gfx-thin-client is deprecated, use /gfx:thin-client[:on|off] instead");
4830 return fail_at(arg, COMMAND_LINE_ERROR);
4835 return fail_at(arg, COMMAND_LINE_ERROR);
4839 return fail_at(arg, COMMAND_LINE_ERROR);
4841 CommandLineSwitchCase(arg,
"gfx-small-cache")
4843 WLog_WARN(TAG,
"/gfx-small-cache is deprecated, use /gfx:small-cache[:on|off] instead");
4845 return fail_at(arg, COMMAND_LINE_ERROR);
4849 return fail_at(arg, COMMAND_LINE_ERROR);
4851 CommandLineSwitchCase(arg,
"gfx-progressive")
4853 WLog_WARN(TAG,
"/gfx-progressive is deprecated, use /gfx:progressive[:on|off] instead");
4855 return fail_at(arg, COMMAND_LINE_ERROR);
4857 return fail_at(arg, COMMAND_LINE_ERROR);
4862 return fail_at(arg, COMMAND_LINE_ERROR);
4865 #ifdef WITH_GFX_H264
4866 CommandLineSwitchCase(arg,
"gfx-h264")
4868 WLog_WARN(TAG,
"/gfx-h264 is deprecated, use /gfx:avc420 instead");
4869 int rc = parse_gfx_options(settings, arg);
4871 return fail_at(arg, rc);
4875 CommandLineSwitchCase(arg,
"rfx")
4878 return fail_at(arg, COMMAND_LINE_ERROR);
4880 CommandLineSwitchCase(arg,
"rfx-mode")
4883 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4885 if (option_equals(arg->Value,
"video"))
4888 return fail_at(arg, COMMAND_LINE_ERROR);
4890 else if (option_equals(arg->Value,
"image"))
4893 return fail_at(arg, COMMAND_LINE_ERROR);
4895 return fail_at(arg, COMMAND_LINE_ERROR);
4898 CommandLineSwitchCase(arg,
"frame-ack")
4902 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
4903 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4906 return fail_at(arg, COMMAND_LINE_ERROR);
4908 CommandLineSwitchCase(arg,
"nsc")
4911 return fail_at(arg, COMMAND_LINE_ERROR);
4913 #if defined(WITH_JPEG)
4914 CommandLineSwitchCase(arg,
"jpeg")
4917 return fail_at(arg, COMMAND_LINE_ERROR);
4919 return fail_at(arg, COMMAND_LINE_ERROR);
4921 CommandLineSwitchCase(arg,
"jpeg-quality")
4925 if (!value_to_int(arg->Value, &val, 0, 100))
4926 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4929 return fail_at(arg, COMMAND_LINE_ERROR);
4932 CommandLineSwitchCase(arg,
"nego")
4935 return fail_at(arg, COMMAND_LINE_ERROR);
4937 CommandLineSwitchCase(arg,
"pcb")
4940 return fail_at(arg, COMMAND_LINE_ERROR);
4943 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4945 CommandLineSwitchCase(arg,
"pcid")
4949 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
4950 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4953 return fail_at(arg, COMMAND_LINE_ERROR);
4955 return fail_at(arg, COMMAND_LINE_ERROR);
4958 CommandLineSwitchCase(arg,
"connect-child-session")
4972 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
4975 CommandLineSwitchCase(arg,
"sec")
4977 const int rc = parse_sec_options(settings, arg);
4979 return fail_at(arg, rc);
4981 CommandLineSwitchCase(arg,
"encryption-methods")
4983 const int rc = parse_encryption_methods_options(settings, arg);
4985 return fail_at(arg, rc);
4987 CommandLineSwitchCase(arg,
"args-from")
4989 WLog_ERR(TAG,
"/args-from:%s can not be used in combination with other arguments!",
4991 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
4993 CommandLineSwitchCase(arg,
"from-stdin")
4996 return fail_at(arg, COMMAND_LINE_ERROR);
4998 if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
5001 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5002 promptForPassword = (option_equals(arg->Value, str_force));
5004 if (!promptForPassword)
5005 return fail_at(arg, COMMAND_LINE_ERROR);
5008 CommandLineSwitchCase(arg,
"log-level")
5010 wLog* root = WLog_GetRoot();
5012 if (!WLog_SetStringLogLevel(root, arg->Value))
5013 return fail_at(arg, COMMAND_LINE_ERROR);
5015 CommandLineSwitchCase(arg,
"log-filters")
5017 if (!WLog_AddStringLogFilters(arg->Value))
5018 return fail_at(arg, COMMAND_LINE_ERROR);
5020 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
5021 CommandLineSwitchCase(arg,
"sec-rdp")
5023 WLog_WARN(TAG,
"/sec-rdp is deprecated, use /sec:rdp[:on|off] instead");
5025 return fail_at(arg, COMMAND_LINE_ERROR);
5027 CommandLineSwitchCase(arg,
"sec-tls")
5029 WLog_WARN(TAG,
"/sec-tls is deprecated, use /sec:tls[:on|off] instead");
5031 return fail_at(arg, COMMAND_LINE_ERROR);
5033 CommandLineSwitchCase(arg,
"sec-nla")
5035 WLog_WARN(TAG,
"/sec-nla is deprecated, use /sec:nla[:on|off] instead");
5037 return fail_at(arg, COMMAND_LINE_ERROR);
5039 CommandLineSwitchCase(arg,
"sec-ext")
5041 WLog_WARN(TAG,
"/sec-ext is deprecated, use /sec:ext[:on|off] instead");
5043 return fail_at(arg, COMMAND_LINE_ERROR);
5046 CommandLineSwitchCase(arg,
"tls")
5048 int rc = parse_tls_options(settings, arg);
5050 return fail_at(arg, rc);
5052 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
5053 CommandLineSwitchCase(arg,
"tls-ciphers")
5055 WLog_WARN(TAG,
"/tls-ciphers:<cipher list> is deprecated, use "
5056 "/tls:ciphers:<cipher list> instead");
5057 int rc = parse_tls_cipher_options(settings, arg);
5059 return fail_at(arg, rc);
5061 CommandLineSwitchCase(arg,
"tls-seclevel")
5064 "/tls-seclevel:<level> is deprecated, use /tls:sec-level:<level> instead");
5065 int rc = parse_tls_cipher_options(settings, arg);
5067 return fail_at(arg, rc);
5069 CommandLineSwitchCase(arg,
"tls-secrets-file")
5071 WLog_WARN(TAG,
"/tls-secrets-file:<filename> is deprecated, use "
5072 "/tls:secrets-file:<filename> instead");
5073 int rc = parse_tls_cipher_options(settings, arg);
5075 return fail_at(arg, rc);
5077 CommandLineSwitchCase(arg,
"enforce-tlsv1_2")
5079 WLog_WARN(TAG,
"/enforce-tlsv1_2 is deprecated, use /tls:enforce:1.2 instead");
5080 int rc = parse_tls_cipher_options(settings, arg);
5082 return fail_at(arg, rc);
5085 CommandLineSwitchCase(arg,
"cert")
5087 const int rc = parse_cert_options(settings, arg);
5089 return fail_at(arg, rc);
5092 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
5093 CommandLineSwitchCase(arg,
"cert-name")
5095 WLog_WARN(TAG,
"/cert-name is deprecated, use /cert:name instead");
5097 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5099 CommandLineSwitchCase(arg,
"cert-ignore")
5101 WLog_WARN(TAG,
"/cert-ignore is deprecated, use /cert:ignore instead");
5103 return fail_at(arg, COMMAND_LINE_ERROR);
5105 CommandLineSwitchCase(arg,
"cert-tofu")
5107 WLog_WARN(TAG,
"/cert-tofu is deprecated, use /cert:tofu instead");
5109 return fail_at(arg, COMMAND_LINE_ERROR);
5111 CommandLineSwitchCase(arg,
"cert-deny")
5113 WLog_WARN(TAG,
"/cert-deny is deprecated, use /cert:deny instead");
5115 return fail_at(arg, COMMAND_LINE_ERROR);
5118 CommandLineSwitchCase(arg,
"authentication")
5121 return fail_at(arg, COMMAND_LINE_ERROR);
5123 CommandLineSwitchCase(arg,
"encryption")
5126 return fail_at(arg, COMMAND_LINE_ERROR);
5128 CommandLineSwitchCase(arg,
"grab-keyboard")
5131 return fail_at(arg, COMMAND_LINE_ERROR);
5133 CommandLineSwitchCase(arg,
"grab-mouse")
5136 return fail_at(arg, COMMAND_LINE_ERROR);
5138 CommandLineSwitchCase(arg,
"mouse-relative")
5141 return fail_at(arg, COMMAND_LINE_ERROR);
5143 CommandLineSwitchCase(arg,
"mouse")
5145 const int rc = parse_mouse_options(settings, arg);
5147 return fail_at(arg, rc);
5149 CommandLineSwitchCase(arg,
"unmap-buttons")
5152 return fail_at(arg, COMMAND_LINE_ERROR);
5154 CommandLineSwitchCase(arg,
"toggle-fullscreen")
5157 return fail_at(arg, COMMAND_LINE_ERROR);
5159 CommandLineSwitchCase(arg,
"force-console-callbacks")
5162 return fail_at(arg, COMMAND_LINE_ERROR);
5164 CommandLineSwitchCase(arg,
"floatbar")
5166 const int rc = parse_floatbar_options(settings, arg);
5168 return fail_at(arg, rc);
5170 CommandLineSwitchCase(arg,
"mouse-motion")
5173 return fail_at(arg, COMMAND_LINE_ERROR);
5175 CommandLineSwitchCase(arg,
"parent-window")
5179 if (!value_to_uint(arg->Value, &val, 0, UINT64_MAX))
5180 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5183 return fail_at(arg, COMMAND_LINE_ERROR);
5185 CommandLineSwitchCase(arg,
"client-build-number")
5189 if (!value_to_uint(arg->Value, &val, 0, UINT32_MAX))
5190 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5192 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5194 CommandLineSwitchCase(arg,
"cache")
5196 int rc = parse_cache_options(settings, arg);
5198 return fail_at(arg, rc);
5200 #if defined(WITH_FREERDP_DEPRECATED_COMMANDLINE)
5201 CommandLineSwitchCase(arg,
"bitmap-cache")
5203 WLog_WARN(TAG,
"/bitmap-cache is deprecated, use /cache:bitmap[:on|off] instead");
5205 return fail_at(arg, COMMAND_LINE_ERROR);
5207 CommandLineSwitchCase(arg,
"persist-cache")
5209 WLog_WARN(TAG,
"/persist-cache is deprecated, use /cache:persist[:on|off] instead");
5211 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5213 CommandLineSwitchCase(arg,
"persist-cache-file")
5215 WLog_WARN(TAG,
"/persist-cache-file:<filename> is deprecated, use "
5216 "/cache:persist-file:<filename> instead");
5218 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5221 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5223 CommandLineSwitchCase(arg,
"offscreen-cache")
5225 WLog_WARN(TAG,
"/bitmap-cache is deprecated, use /cache:bitmap[:on|off] instead");
5228 return fail_at(arg, COMMAND_LINE_ERROR);
5230 CommandLineSwitchCase(arg,
"glyph-cache")
5232 WLog_WARN(TAG,
"/glyph-cache is deprecated, use /cache:glyph[:on|off] instead");
5234 arg->Value ? GLYPH_SUPPORT_FULL : GLYPH_SUPPORT_NONE))
5235 return fail_at(arg, COMMAND_LINE_ERROR);
5237 CommandLineSwitchCase(arg,
"codec-cache")
5240 "/codec-cache:<option> is deprecated, use /cache:codec:<option> instead");
5241 const int rc = parse_codec_cache_options(settings, arg);
5243 return fail_at(arg, rc);
5246 CommandLineSwitchCase(arg,
"max-fast-path-size")
5250 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
5251 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5255 return fail_at(arg, COMMAND_LINE_ERROR);
5257 CommandLineSwitchCase(arg,
"auto-request-control")
5261 return fail_at(arg, COMMAND_LINE_ERROR);
5263 CommandLineSwitchCase(arg,
"async-update")
5266 return fail_at(arg, COMMAND_LINE_ERROR);
5268 CommandLineSwitchCase(arg,
"async-channels")
5271 return fail_at(arg, COMMAND_LINE_ERROR);
5273 CommandLineSwitchCase(arg,
"wm-class")
5276 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5278 CommandLineSwitchCase(arg,
"play-rfx")
5281 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5284 return fail_at(arg, COMMAND_LINE_ERROR);
5286 CommandLineSwitchCase(arg,
"auth-only")
5289 return fail_at(arg, COMMAND_LINE_ERROR);
5291 CommandLineSwitchCase(arg,
"auth-pkg-list")
5295 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5297 CommandLineSwitchCase(arg,
"auto-reconnect")
5300 return fail_at(arg, COMMAND_LINE_ERROR);
5302 CommandLineSwitchCase(arg,
"auto-reconnect-max-retries")
5306 if (!value_to_int(arg->Value, &val, 0, 1000))
5307 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5311 return fail_at(arg, COMMAND_LINE_ERROR);
5313 CommandLineSwitchCase(arg,
"reconnect-cookie")
5315 const int rc = parse_reconnect_cookie_options(settings, arg);
5317 return fail_at(arg, rc);
5319 CommandLineSwitchCase(arg,
"print-reconnect-cookie")
5322 return fail_at(arg, COMMAND_LINE_ERROR);
5324 CommandLineSwitchCase(arg,
"pwidth")
5328 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
5329 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5332 return fail_at(arg, COMMAND_LINE_ERROR);
5334 CommandLineSwitchCase(arg,
"pheight")
5338 if (!value_to_int(arg->Value, &val, 0, UINT32_MAX))
5339 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5342 return fail_at(arg, COMMAND_LINE_ERROR);
5344 CommandLineSwitchCase(arg,
"orientation")
5348 if (!value_to_int(arg->Value, &val, 0, UINT16_MAX))
5349 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5352 return fail_at(arg, COMMAND_LINE_ERROR);
5354 CommandLineSwitchCase(arg,
"old-license")
5357 return fail_at(arg, COMMAND_LINE_ERROR);
5359 CommandLineSwitchCase(arg,
"scale")
5361 const int rc = parse_scale_options(settings, arg);
5363 return fail_at(arg, rc);
5365 CommandLineSwitchCase(arg,
"scale-desktop")
5369 if (!value_to_int(arg->Value, &val, 100, 500))
5370 return fail_at(arg, COMMAND_LINE_ERROR);
5373 return fail_at(arg, COMMAND_LINE_ERROR);
5375 CommandLineSwitchCase(arg,
"scale-device")
5377 const int rc = parse_scale_device_options(settings, arg);
5379 return fail_at(arg, rc);
5381 CommandLineSwitchCase(arg,
"action-script")
5384 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5386 CommandLineSwitchCase(arg, RDP2TCP_DVC_CHANNEL_NAME)
5389 return fail_at(arg, COMMAND_LINE_ERROR_MEMORY);
5391 CommandLineSwitchCase(arg,
"fipsmode")
5394 return fail_at(arg, COMMAND_LINE_ERROR);
5396 CommandLineSwitchCase(arg,
"smartcard-logon")
5398 const int rc = parse_smartcard_logon_options(settings, arg);
5400 return fail_at(arg, rc);
5402 CommandLineSwitchCase(arg,
"tune")
5404 const int rc = parse_tune_options(settings, arg);
5406 return fail_at(arg, rc);
5408 CommandLineSwitchDefault(arg)
5412 const int rc = handle_option(arg, handle_userdata);
5414 return fail_at(arg, rc);
5417 CommandLineSwitchEnd(arg)
5418 }
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
5425 return COMMAND_LINE_ERROR;
5428 return COMMAND_LINE_ERROR;
5430 if (!freerdp_parse_username_settings(user, settings, FreeRDP_Username, FreeRDP_Domain))
5431 return COMMAND_LINE_ERROR;
5436 return COMMAND_LINE_ERROR;
5440 if (promptForPassword)
5445 char buffer[512 + 1] = { 0 };
5447 if (!freerdp_passphrase_read(instance->context,
"Password: ", buffer,
5448 ARRAYSIZE(buffer) - 1, 1))
5449 return COMMAND_LINE_ERROR;
5451 return COMMAND_LINE_ERROR;
5459 char buffer[512 + 1] = { 0 };
5461 if (!freerdp_passphrase_read(instance->context,
"Gateway Password: ", buffer,
5462 ARRAYSIZE(buffer) - 1, 1))
5463 return COMMAND_LINE_ERROR;
5465 return COMMAND_LINE_ERROR;
5470 freerdp_performance_flags_make(settings);
5477 return COMMAND_LINE_ERROR;
5479 return COMMAND_LINE_ERROR;
5482 arg = CommandLineFindArgumentA(largs,
"port");
5483 if (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)
5487 if (!value_to_int(arg->Value, &val, 1, UINT16_MAX))
5488 return fail_at(arg, COMMAND_LINE_ERROR_UNEXPECTED_VALUE);
5491 return fail_at(arg, COMMAND_LINE_ERROR);
5498 return fail_at(arg, COMMAND_LINE_ERROR);
5501 WLog_INFO(TAG,
"/vmconnect uses custom port %" PRIu32, port);
5504 fill_credential_strings(largs);
5509 static void argv_free(
int* pargc,
char** pargv[])
5511 WINPR_ASSERT(pargc);
5512 WINPR_ASSERT(pargv);
5513 const int argc = *pargc;
5514 char** argv = *pargv;
5520 for (
int x = 0; x < argc; x++)
5525 static BOOL argv_append(
int* pargc,
char** pargv[],
char* what)
5527 WINPR_ASSERT(pargc);
5528 WINPR_ASSERT(pargv);
5536 int nargc = *pargc + 1;
5537 char** tmp = realloc(*pargv, nargc *
sizeof(
char*));
5547 static BOOL argv_append_dup(
int* pargc,
char** pargv[],
const char* what)
5551 copy = _strdup(what);
5553 const BOOL rc = argv_append(pargc, pargv, copy);
5559 static BOOL args_from_fp(FILE* fp,
int* aargc,
char** aargv[],
const char* file,
const char* cmd)
5561 BOOL success = FALSE;
5563 WINPR_ASSERT(aargc);
5564 WINPR_ASSERT(aargv);
5569 WLog_ERR(TAG,
"Failed to read command line options from file '%s'", file);
5572 if (!argv_append_dup(aargc, aargv, cmd))
5578 INT64 rc = GetLine(&line, &size, fp);
5579 if ((rc < 0) || !line)
5589 const char cur = (line[rc - 1]);
5590 if ((cur ==
'\n') || (cur ==
'\r'))
5592 line[rc - 1] =
'\0';
5604 if (!argv_append(aargc, aargv, line))
5615 argv_free(aargc, aargv);
5619 static BOOL args_from_env(
const char* name,
int* aargc,
char** aargv[],
const char* arg,
5622 BOOL success = FALSE;
5625 WINPR_ASSERT(aargc);
5626 WINPR_ASSERT(aargv);
5631 WLog_ERR(TAG,
"%s - environment variable name empty", arg);
5635 const DWORD size = GetEnvironmentVariableX(name, env, 0);
5638 WLog_ERR(TAG,
"%s - no environment variable '%s'", arg, name);
5641 env = calloc(size + 1,
sizeof(
char));
5644 const DWORD rc = GetEnvironmentVariableX(name, env, size);
5649 WLog_ERR(TAG,
"%s - environment variable '%s' is empty", arg);
5653 if (!argv_append_dup(aargc, aargv, cmd))
5656 char* context = NULL;
5657 char* tok = strtok_s(env,
"\n", &context);
5660 if (!argv_append_dup(aargc, aargv, tok))
5662 tok = strtok_s(NULL,
"\n", &context);
5669 argv_free(aargc, aargv);
5673 int freerdp_client_settings_parse_command_line_arguments(rdpSettings* settings,
int oargc,
5674 char* oargv[], BOOL allowUnknown)
5676 return freerdp_client_settings_parse_command_line_arguments_ex(
5677 settings, oargc, oargv, allowUnknown, NULL, 0, NULL, NULL);
5680 int freerdp_client_settings_parse_command_line_arguments_ex(
5681 rdpSettings* settings,
int oargc,
char** oargv, BOOL allowUnknown,
5686 char** argv = oargv;
5689 char** aargv = NULL;
5690 if ((argc == 2) && option_starts_with(
"/args-from:", argv[1]))
5692 BOOL success = FALSE;
5693 const char* file = strchr(argv[1],
':') + 1;
5696 if (option_starts_with(
"fd:", file))
5698 ULONGLONG result = 0;
5699 const char* val = strchr(file,
':') + 1;
5700 if (!value_to_uint(val, &result, 0, INT_MAX))
5702 fp = fdopen((
int)result,
"r");
5703 success = args_from_fp(fp, &aargc, &aargv, file, oargv[0]);
5705 else if (strncmp(file,
"env:", 4) == 0)
5707 const char* name = strchr(file,
':') + 1;
5708 success = args_from_env(name, &aargc, &aargv, oargv[1], oargv[0]);
5710 else if (strcmp(file,
"stdin") != 0)
5712 fp = winpr_fopen(file,
"r");
5713 success = args_from_fp(fp, &aargc, &aargv, file, oargv[0]);
5716 success = args_from_fp(fp, &aargc, &aargv, file, oargv[0]);
5729 res = freerdp_client_settings_parse_command_line_arguments_int(
5730 settings, argc, argv, allowUnknown, largs, lcount, handle_option, handle_userdata);
5733 argv_free(&aargc, &aargv);
5737 static BOOL freerdp_client_load_static_channel_addin(rdpChannels* channels, rdpSettings* settings,
5738 const char* name,
void* data)
5740 PVIRTUALCHANNELENTRY entry = NULL;
5741 PVIRTUALCHANNELENTRY pvce = freerdp_load_channel_addin_entry(
5742 name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC | FREERDP_ADDIN_CHANNEL_ENTRYEX);
5743 PVIRTUALCHANNELENTRYEX pvceex = WINPR_FUNC_PTR_CAST(pvce, PVIRTUALCHANNELENTRYEX);
5746 entry = freerdp_load_channel_addin_entry(name, NULL, NULL, FREERDP_ADDIN_CHANNEL_STATIC);
5750 if (freerdp_channels_client_load_ex(channels, settings, pvceex, data) == 0)
5752 WLog_DBG(TAG,
"loading channelEx %s", name);
5758 if (freerdp_channels_client_load(channels, settings, entry, data) == 0)
5760 WLog_DBG(TAG,
"loading channel %s", name);
5770 FreeRDP_Settings_Keys_Bool settingId;
5771 const char* channelName;
5775 BOOL freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
5777 ChannelToLoad dynChannels[] = {
5778 #if defined(CHANNEL_AINPUT_CLIENT)
5779 { FreeRDP_BOOL_UNUSED, AINPUT_CHANNEL_NAME, NULL },
5781 { FreeRDP_AudioCapture, AUDIN_CHANNEL_NAME, NULL },
5782 { FreeRDP_AudioPlayback, RDPSND_CHANNEL_NAME, NULL },
5783 #ifdef CHANNEL_RDPEI_CLIENT
5784 { FreeRDP_MultiTouchInput, RDPEI_CHANNEL_NAME, NULL },
5786 { FreeRDP_SupportGraphicsPipeline, RDPGFX_CHANNEL_NAME, NULL },
5787 { FreeRDP_SupportEchoChannel, ECHO_CHANNEL_NAME, NULL },
5788 { FreeRDP_SupportSSHAgentChannel,
"sshagent", NULL },
5789 { FreeRDP_SupportDisplayControl, DISP_CHANNEL_NAME, NULL },
5790 { FreeRDP_SupportGeometryTracking, GEOMETRY_CHANNEL_NAME, NULL },
5791 { FreeRDP_SupportVideoOptimized, VIDEO_CHANNEL_NAME, NULL },
5792 { FreeRDP_RemoteCredentialGuard, RDPEAR_CHANNEL_NAME, NULL },
5795 ChannelToLoad staticChannels[] = {
5796 { FreeRDP_AudioPlayback, RDPSND_CHANNEL_NAME, NULL },
5797 { FreeRDP_RedirectClipboard, CLIPRDR_SVC_CHANNEL_NAME, NULL },
5798 #if defined(CHANNEL_ENCOMSP_CLIENT)
5799 { FreeRDP_EncomspVirtualChannel, ENCOMSP_SVC_CHANNEL_NAME, settings },
5801 { FreeRDP_RemdeskVirtualChannel, REMDESK_SVC_CHANNEL_NAME, settings },
5802 { FreeRDP_RemoteApplicationMode, RAIL_SVC_CHANNEL_NAME, settings }
5808 for (
size_t i = 0; i < ARRAYSIZE(dynChannels); i++)
5810 if ((dynChannels[i].settingId == FreeRDP_BOOL_UNUSED) ||
5813 const char* p[] = { dynChannels[i].channelName };
5815 if (!freerdp_client_add_dynamic_channel(settings, ARRAYSIZE(p), p))
5823 if ((freerdp_static_channel_collection_find(settings, RDPSND_CHANNEL_NAME)) ||
5824 (freerdp_dynamic_channel_collection_find(settings, RDPSND_CHANNEL_NAME))
5825 #
if defined(CHANNEL_TSMF_CLIENT)
5826 || (freerdp_dynamic_channel_collection_find(settings,
"tsmf"))
5831 return COMMAND_LINE_ERROR;
5833 return COMMAND_LINE_ERROR;
5836 if (freerdp_dynamic_channel_collection_find(settings, AUDIN_CHANNEL_NAME))
5839 return COMMAND_LINE_ERROR;
5847 return COMMAND_LINE_ERROR;
5852 if (DrivesToRedirect && (strlen(DrivesToRedirect) != 0))
5862 char* context = NULL;
5864 value = _strdup(DrivesToRedirect);
5868 tok = strtok_s(value,
";", &context);
5871 WLog_ERR(TAG,
"DrivesToRedirect contains invalid data: '%s'", DrivesToRedirect);
5888 const char* name = NULL;
5889 const char* drive = tok;
5890 char* subcontext = NULL;
5891 char* start = strtok_s(tok,
"(", &subcontext);
5892 char* end = strtok_s(NULL,
")", &subcontext);
5896 if (freerdp_path_valid(name, NULL) && freerdp_path_valid(drive, NULL))
5898 success = freerdp_client_add_drive(settings, name, NULL);
5900 success = freerdp_client_add_drive(settings, drive, NULL);
5903 success = freerdp_client_add_drive(settings, drive, name);
5911 tok = strtok_s(NULL,
";", &context);
5919 return COMMAND_LINE_ERROR;
5923 if (!freerdp_device_collection_find(settings,
"drive"))
5925 const char* params[] = {
"drive",
"media",
"*" };
5927 if (!freerdp_client_add_device_channel(settings, ARRAYSIZE(params), params))
5939 return COMMAND_LINE_ERROR;
5944 if (!freerdp_device_collection_find(settings,
"drive"))
5946 const char* params[] = {
"drive",
"home",
"%" };
5948 if (!freerdp_client_add_device_channel(settings, ARRAYSIZE(params), params))
5955 if (!freerdp_client_load_static_channel_addin(channels, settings, RDPDR_SVC_CHANNEL_NAME,
5959 if (!freerdp_static_channel_collection_find(settings, RDPSND_CHANNEL_NAME) &&
5960 !freerdp_dynamic_channel_collection_find(settings, RDPSND_CHANNEL_NAME))
5962 const char* params[] = { RDPSND_CHANNEL_NAME,
"sys:fake" };
5964 if (!freerdp_client_add_static_channel(settings, ARRAYSIZE(params), params))
5967 if (!freerdp_client_add_dynamic_channel(settings, ARRAYSIZE(params), params))
5974 if (!freerdp_device_collection_find_type(settings, RDPDR_DTYP_SMARTCARD))
5976 RDPDR_DEVICE* smartcard = freerdp_device_new(RDPDR_DTYP_SMARTCARD, 0, NULL);
5981 if (!freerdp_device_collection_add(settings, smartcard))
5983 freerdp_device_free(smartcard);
5991 if (!freerdp_device_collection_find_type(settings, RDPDR_DTYP_PRINT))
5993 RDPDR_DEVICE* printer = freerdp_device_new(RDPDR_DTYP_PRINT, 0, NULL);
5998 if (!freerdp_device_collection_add(settings, printer))
6000 freerdp_device_free(printer);
6027 for (
size_t i = 0; i < ARRAYSIZE(staticChannels); i++)
6029 if ((staticChannels[i].settingId == 0) ||
6032 if (staticChannels[i].args)
6034 if (!freerdp_client_load_static_channel_addin(
6035 channels, settings, staticChannels[i].channelName, staticChannels[i].args))
6040 const char* p[] = { staticChannels[i].channelName };
6041 if (!freerdp_client_add_static_channel(settings, ARRAYSIZE(p), p))
6050 if (!freerdp_client_load_static_channel_addin(channels, settings, RDP2TCP_DVC_CHANNEL_NAME,
6059 freerdp_settings_get_pointer_array_writable(settings, FreeRDP_StaticChannelArray, i);
6061 if (!freerdp_client_load_static_channel_addin(channels, settings, _args->argv[0], _args))
6073 if (!freerdp_client_load_static_channel_addin(channels, settings, DRDYNVC_SVC_CHANNEL_NAME,
6081 void freerdp_client_warn_unmaintained(
int argc,
char* argv[])
6083 const char* app = (argc > 0) ? argv[0] :
"INVALID_ARGV";
6084 const DWORD log_level = WLOG_WARN;
6085 wLog* log = WLog_Get(TAG);
6088 if (!WLog_IsLevelActive(log, log_level))
6091 WLog_Print_unchecked(log, log_level,
"[unmaintained] %s client is currently unmaintained!",
6093 WLog_Print_unchecked(
6095 " If problems occur please check https://github.com/FreeRDP/FreeRDP/issues for "
6097 WLog_Print_unchecked(
6099 "Be prepared to fix issues yourself though as nobody is actively working on this.");
6100 WLog_Print_unchecked(
6102 " Developers hang out in https://matrix.to/#/#FreeRDP:matrix.org?via=matrix.org "
6103 "- dont hesitate to ask some questions. (replies might take some time depending "
6104 "on your timezone) - if you intend using this component write us a message");
6107 void freerdp_client_warn_experimental(
int argc,
char* argv[])
6109 const char* app = (argc > 0) ? argv[0] :
"INVALID_ARGV";
6110 const DWORD log_level = WLOG_WARN;
6111 wLog* log = WLog_Get(TAG);
6114 if (!WLog_IsLevelActive(log, log_level))
6117 WLog_Print_unchecked(log, log_level,
"[experimental] %s client is currently experimental!",
6119 WLog_Print_unchecked(
6121 " If problems occur please check https://github.com/FreeRDP/FreeRDP/issues for "
6122 "known issues or create a new one!");
6123 WLog_Print_unchecked(
6125 " Developers hang out in https://matrix.to/#/#FreeRDP:matrix.org?via=matrix.org "
6126 "- dont hesitate to ask some questions. (replies might take some time depending "
6127 "on your timezone)");
6130 void freerdp_client_warn_deprecated(
int argc,
char* argv[])
6132 const char* app = (argc > 0) ? argv[0] :
"INVALID_ARGV";
6133 const DWORD log_level = WLOG_WARN;
6134 wLog* log = WLog_Get(TAG);
6137 if (!WLog_IsLevelActive(log, log_level))
6140 WLog_Print_unchecked(log, log_level,
"[deprecated] %s client has been deprecated", app);
6141 WLog_Print_unchecked(log, log_level,
"As replacement there is a SDL based client available.");
6142 WLog_Print_unchecked(
6144 "If you are interested in keeping %s alive get in touch with the developers", app);
6145 WLog_Print_unchecked(
6147 "The project is hosted at https://github.com/freerdp/freerdp and "
6148 " developers hang out in https://matrix.to/#/#FreeRDP:matrix.org?via=matrix.org "
6149 "- dont hesitate to ask some questions. (replies might take some time depending "
6150 "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.