cf10519d6c636a1d6e8811961c245f191663daee
[freerdp-ubuntu-pcb-backport.git] / libfreerdp-utils / args.c
1 /**
2  * FreeRDP: A Remote Desktop Protocol client.
3  * Arguments Parsing
4  *
5  * Copyright 2009-2011 Jay Sorg
6  * Copyright 2011 Vic Lee
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 #include "config.h"
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <freerdp/settings.h>
26 #include <freerdp/utils/print.h>
27 #include <freerdp/utils/memory.h>
28 #include <freerdp/utils/args.h>
29
30 /**
31  * Parse command-line arguments and update rdpSettings members accordingly.
32  * @param settings pointer to rdpSettings struct to be updated.
33  * @param argc number of arguments available.
34  * @param argv string array of the arguments.
35  * @param plugin_callback function to be called when a plugin needs to be loaded.
36  * @param plugin_user_data pointer to be passed to the plugin_callback function.
37  * @param ui_callback function to be called when a UI-specific argument is being processed.
38  * @param ui_user_data pointer to be passed to the ui_callback function.
39  * @return number of arguments that were parsed, or FREERDP_ARGS_PARSE_RESULT on failure or --version/--help
40  */
41 int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
42         ProcessPluginArgs plugin_callback, void* plugin_user_data,
43         ProcessUIArgs ui_callback, void* ui_user_data)
44 {
45         int t;
46         char* p;
47         int i, j;
48         int index = 1;
49         int num_extensions = 0;
50         RDP_PLUGIN_DATA* plugin_data;
51
52         while (index < argc)
53         {
54                 if ((strcmp("-h", argv[index]) == 0 ) || (strcmp("--help", argv[index]) == 0 ))
55                 {
56                         printf("\n"
57                                 "FreeRDP - A Free Remote Desktop Protocol Client\n"
58                                 "See http://www.freerdp.com for more information\n"
59                                 "\n"
60                                 "Usage: %s [options] server:port\n"
61                                 "  -0: connect to console session\n"
62                                 "  -a: set color depth in bit, default is 16\n"
63                                 "  -c: initial working directory\n"
64                                 "  -D: hide window decorations\n"
65                                 "  -T: window title\n"
66                                 "  -d: domain\n"
67                                 "  -f: fullscreen mode\n"
68                                 "  -g: set geometry, using format WxH or X%% or 'workarea', default is 1024x768\n"
69                                 "  -h: print this help\n"
70                                 "  -k: set keyboard layout ID\n"
71                                 "  -K: do not interfere with window manager bindings\n"
72                                 "  -m: don't send mouse motion events\n"
73                                 "  -n: hostname\n"
74                                 "  -o: console audio\n"
75                                 "  -p: password\n"
76                                 "  -s: set startup-shell\n"
77                                 "  -t: alternative port number, default is 3389\n"
78                                 "  -u: username\n"
79                                 "  -x: performance flags (m[odem], b[roadband] or l[an])\n"
80                                 "  -X: embed into another window with a given XID.\n"
81                                 "  -z: enable compression\n"
82                                 "  --app: RemoteApp connection. This implies -g workarea\n"
83                                 "  --ext: load an extension\n"
84                                 "  --no-auth: disable authentication\n"
85                                 "  --no-fastpath: disable fast-path\n"
86                                 "  --gdi: graphics rendering (hw, sw)\n"
87                                 "  --no-osb: disable offscreen bitmaps\n"
88                                 "  --no-bmp-cache: disable bitmap cache\n"
89                                 "  --plugin: load a virtual channel plugin\n"
90                                 "  --rfx: enable RemoteFX\n"
91                                 "  --rfx-mode: RemoteFX operational flags (v[ideo], i[mage]), default is video\n"
92                                 "  --nsc: enable NSCodec (experimental)\n"
93                                 "  --disable-wallpaper: disables wallpaper\n"
94                                 "  --composition: enable desktop composition\n"
95                                 "  --disable-full-window-drag: disables full window drag\n"
96                                 "  --disable-menu-animations: disables menu animations\n"
97                                 "  --disable-theming: disables theming\n"
98                                 "  --no-rdp: disable Standard RDP encryption\n"
99                                 "  --no-tls: disable TLS encryption\n"
100                                 "  --no-nla: disable network level authentication\n"
101                                 "  --ntlm: force NTLM authentication protocol version (1 or 2)\n"
102                                 "  --ignore-certificate: ignore verification of logon certificate\n"
103                                 "  --sec: force protocol security (rdp, tls or nla)\n"
104                                 "  --secure-checksum: use salted checksums with Standard RDP encryption\n"
105                                 "  --version: print version information\n"
106                                 "\n", argv[0]);
107                         return FREERDP_ARGS_PARSE_HELP; //TODO: What is the correct return
108                 }
109                 else if (strcmp("-a", argv[index]) == 0)
110                 {
111                         index++;
112                         if (index == argc)
113                         {
114                                 printf("missing color depth\n");
115                                 return FREERDP_ARGS_PARSE_FAILURE;
116                         }
117                         settings->color_depth = atoi(argv[index]);
118                 }
119                 else if (strcmp("-u", argv[index]) == 0)
120                 {
121                         index++;
122                         if (index == argc)
123                         {
124                                 printf("missing username\n");
125                                 return FREERDP_ARGS_PARSE_FAILURE;
126                         }
127                         settings->username = xstrdup(argv[index]);
128                 }
129                 else if (strcmp("-p", argv[index]) == 0)
130                 {
131                         index++;
132                         if (index == argc)
133                         {
134                                 printf("missing password\n");
135                                 return FREERDP_ARGS_PARSE_FAILURE;
136                         }
137                         settings->password = xstrdup(argv[index]);
138                         settings->autologon = 1;
139
140                         /*
141                          * Overwrite original password which could be revealed by a simple "ps aux" command.
142                          * This approach won't hide the password length, but it is better than nothing.
143                          */
144
145                         memset(argv[index], '*', strlen(argv[index]));
146                 }
147                 else if (strcmp("-d", argv[index]) == 0)
148                 {
149                         index++;
150                         if (index == argc)
151                         {
152                                 printf("missing domain\n");
153                                 return FREERDP_ARGS_PARSE_FAILURE;
154                         }
155                         settings->domain = xstrdup(argv[index]);
156                 }
157                 else if (strcmp("-s", argv[index]) == 0)
158                 {
159                         index++;
160                         if (index == argc)
161                         {
162                                 printf("missing shell\n");
163                                 return FREERDP_ARGS_PARSE_FAILURE;
164                         }
165                         settings->shell = xstrdup(argv[index]);
166                 }
167                 else if (strcmp("-c", argv[index]) == 0)
168                 {
169                         index++;
170                         if (index == argc)
171                         {
172                                 printf("missing directory\n");
173                                 return FREERDP_ARGS_PARSE_FAILURE;
174                         }
175                         settings->directory = xstrdup(argv[index]);
176                 }
177                 else if (strcmp("-g", argv[index]) == 0)
178                 {
179                         index++;
180                         if (index == argc)
181                         {
182                                 printf("missing dimensions\n");
183                                 return FREERDP_ARGS_PARSE_FAILURE;
184                         }
185
186                         if (strncmp("workarea", argv[index], 1) == 0)
187                         {
188                                 settings->workarea = true;
189                         }
190                         else
191                         {
192                                 settings->width = (uint16) strtol(argv[index], &p, 10);
193
194                                 if (*p == 'x')
195                                 {
196                                         settings->height = (uint16) strtol(p + 1, &p, 10);
197                                 }
198                                 if (*p == '%')
199                                 {
200                                         settings->percent_screen = settings->width;
201                                         if (settings->percent_screen <= 0 || settings->percent_screen > 100)
202                                         {
203                                                 printf("invalid geometry percentage\n");
204                                                 return FREERDP_ARGS_PARSE_FAILURE;
205                                         }
206                                 }
207                                 else
208                                 {
209                                         if (ui_callback != NULL)
210                                                 ui_callback(settings, "-g", p, ui_user_data);
211                                 }
212                         }
213                 }
214                 else if (strcmp("-f", argv[index]) == 0)
215                 {
216                         settings->fullscreen = true;
217                 }
218                 else if (strcmp("-D", argv[index]) == 0)
219                 {
220                         settings->decorations = false;
221                 }
222                 else if (strcmp("-T", argv[index]) == 0)
223                 {
224                         index++;
225                         if (index == argc)
226                         {
227                                 printf("missing window title\n");
228                                 return FREERDP_ARGS_PARSE_FAILURE;
229                         }
230
231                         settings->window_title = xstrdup(argv[index]);
232                 }
233                 else if (strcmp("-t", argv[index]) == 0)
234                 {
235                         index++;
236                         if (index == argc)
237                         {
238                                 printf("missing port number\n");
239                                 return FREERDP_ARGS_PARSE_FAILURE;
240                         }
241                         settings->port = atoi(argv[index]);
242                 }
243                 else if (strcmp("-k", argv[index]) == 0)
244                 {
245                         index++;
246                         if (index == argc)
247                         {
248                                 printf("missing keyboard layout id\n");
249                                 return FREERDP_ARGS_PARSE_FAILURE;
250                         }
251                         sscanf(argv[index], "%X", &(settings->kbd_layout));
252                 }
253                 else if (strcmp("-K", argv[index]) == 0)
254                 {
255                         settings->grab_keyboard = false;
256                 }
257                 else if (strcmp("-n", argv[index]) == 0)
258                 {
259                         index++;
260                         if (index == argc)
261                         {
262                                 printf("missing client hostname\n");
263                                 return FREERDP_ARGS_PARSE_FAILURE;
264                         }
265                         strncpy(settings->client_hostname, argv[index], sizeof(settings->client_hostname) - 1);
266                         settings->client_hostname[sizeof(settings->client_hostname) - 1] = 0;
267                 }
268                 else if (strcmp("-o", argv[index]) == 0)
269                 {
270                         settings->console_audio = true;
271                 }
272                 else if (strcmp("-0", argv[index]) == 0)
273                 {
274                         settings->console_session = true;
275                 }
276                 else if (strcmp("-z", argv[index]) == 0)
277                 {
278                         settings->compression = true;
279                 }
280                 else if (strcmp("--ntlm", argv[index]) == 0)
281                 {
282                         index++;
283
284                         settings->ntlm_version = atoi(argv[index]);
285
286                         if (settings->ntlm_version != 2)
287                                 settings->ntlm_version = 1;
288                 }
289                 else if (strcmp("--no-glyph-cache", argv[index]) == 0)
290                 {
291                         settings->glyph_cache = false;
292                 }
293                 else if (strcmp("--no-osb", argv[index]) == 0)
294                 {
295                         settings->offscreen_bitmap_cache = false;
296                 }
297                 else if (strcmp("--no-bmp-cache", argv[index]) == 0)
298                 {
299                         settings->bitmap_cache = false;
300                 }
301                 else if (strcmp("--no-auth", argv[index]) == 0)
302                 {
303                         settings->authentication = false;
304                 }
305                 else if (strcmp("--ignore-certificate", argv[index]) == 0)
306                 {
307                         settings->ignore_certificate = true;
308                 }
309                 else if (strcmp("--certificate-name", argv[index]) == 0)
310                 {
311                         index++;
312                         if (index == argc)
313                         {
314                                 printf("missing certificate name\n");
315                                 return FREERDP_ARGS_PARSE_FAILURE;
316                         }
317
318                         settings->certificate_name = xstrdup(argv[index]);
319                 }
320                 else if (strcmp("--no-fastpath", argv[index]) == 0)
321                 {
322                         settings->fastpath_input = false;
323                         settings->fastpath_output = false;
324                 }
325                 else if (strcmp("--gdi", argv[index]) == 0)
326                 {
327                         index++;
328                         if (index == argc)
329                         {
330                                 printf("missing GDI backend\n");
331                                 return FREERDP_ARGS_PARSE_FAILURE;
332                         }
333                         if (strncmp("sw", argv[index], 1) == 0) /* software */
334                         {
335                                 settings->sw_gdi = true;
336                         }
337                         else if (strncmp("hw", argv[index], 1) == 0) /* hardware */
338                         {
339                                 settings->sw_gdi = false;
340                         }
341                         else
342                         {
343                                 printf("unknown GDI backend\n");
344                                 return FREERDP_ARGS_PARSE_FAILURE;
345                         }
346                 }
347                 else if (strcmp("--rfx", argv[index]) == 0)
348                 {
349                         settings->rfx_codec = true;
350                         settings->fastpath_output = true;
351                         settings->color_depth = 32;
352                         settings->frame_acknowledge = false;
353                         settings->performance_flags = PERF_FLAG_NONE;
354                         settings->large_pointer = true;
355                 }
356                 else if (strcmp("--rfx-mode", argv[index]) == 0)
357                 {
358                         index++;
359                         if (index == argc)
360                         {
361                                 printf("missing RemoteFX mode flag\n");
362                                 return FREERDP_ARGS_PARSE_FAILURE;
363                         }
364                         if (argv[index][0] == 'v') /* video */
365                         {
366                                 settings->rfx_codec_mode = 0x00;
367                         }
368                         else if (argv[index][0] == 'i') /* image */
369                         {
370                                 settings->rfx_codec_mode = 0x02;
371                         }
372                         else
373                         {
374                                 printf("unknown RemoteFX mode flag\n");
375                                 return FREERDP_ARGS_PARSE_FAILURE;
376                         }
377                 }
378                 else if (strcmp("--nsc", argv[index]) == 0)
379                 {
380                         settings->ns_codec = true;
381                 }
382                 else if (strcmp("--dump-rfx", argv[index]) == 0)
383                 {
384                         index++;
385                         if (index == argc)
386                         {
387                                 printf("missing file name\n");
388                                 return FREERDP_ARGS_PARSE_FAILURE;
389                         }
390                         settings->dump_rfx_file = xstrdup(argv[index]);
391                         settings->dump_rfx = true;
392                 }
393                 else if (strcmp("--play-rfx", argv[index]) == 0)
394                 {
395                         index++;
396                         if (index == argc)
397                         {
398                                 printf("missing file name\n");
399                                 return FREERDP_ARGS_PARSE_FAILURE;
400                         }
401                         settings->play_rfx_file = xstrdup(argv[index]);
402                         settings->play_rfx = true;
403                 }
404                 else if (strcmp("--fonts", argv[index]) == 0)
405                 {
406                         settings->smooth_fonts = true;
407                 }
408                 else if (strcmp("--disable-wallpaper", argv[index]) == 0)
409                 {
410                         settings->disable_wallpaper = true;
411                 }
412                 else if (strcmp("--disable-full-window-drag", argv[index]) == 0)
413                 {
414                         settings->disable_full_window_drag = true;
415                 }
416                 else if (strcmp("--disable-menu-animations", argv[index]) == 0)
417                 {
418                         settings->disable_menu_animations = true;
419                 }
420                 else if (strcmp("--disable-theming", argv[index]) == 0)
421                 {
422                         settings->disable_theming = true;
423                 }
424                 else if (strcmp("--composition", argv[index]) == 0)
425                 {
426                         settings->desktop_composition = true;
427                 }
428                 else if (strcmp("--no-motion", argv[index]) == 0)
429                 {
430                         settings->mouse_motion = false;
431                 }
432                 else if (strcmp("--app", argv[index]) == 0)
433                 {
434                         settings->remote_app = true;
435                         settings->rail_langbar_supported = true;
436                         settings->workarea = true;
437                         settings->performance_flags = PERF_DISABLE_WALLPAPER | PERF_DISABLE_FULLWINDOWDRAG;
438                 }
439                 else if (strcmp("-x", argv[index]) == 0)
440                 {
441                         index++;
442                         if (index == argc)
443                         {
444                                 printf("missing performance flag\n");
445                                 return FREERDP_ARGS_PARSE_FAILURE;
446                         }
447                         if (argv[index][0] == 'm') /* modem */
448                         {
449                                 settings->performance_flags = PERF_DISABLE_WALLPAPER |
450                                         PERF_DISABLE_FULLWINDOWDRAG | PERF_DISABLE_MENUANIMATIONS |
451                                         PERF_DISABLE_THEMING;
452
453                                 settings->connection_type = CONNECTION_TYPE_MODEM;
454                         }
455                         else if (argv[index][0] == 'b') /* broadband */
456                         {
457                                 settings->performance_flags = PERF_DISABLE_WALLPAPER;
458                                 settings->connection_type = CONNECTION_TYPE_BROADBAND_HIGH;
459                         }
460                         else if (argv[index][0] == 'l') /* lan */
461                         {
462                                 settings->performance_flags = PERF_FLAG_NONE;
463                                 settings->connection_type = CONNECTION_TYPE_LAN;
464                         }
465                         else
466                         {
467                                 settings->performance_flags = strtol(argv[index], 0, 16);
468                         }
469                 }
470                 else if (strcmp("-X", argv[index]) == 0)
471                 {
472                         index++;
473
474                         if (index == argc)
475                         {
476                                 printf("missing parent window XID\n");
477                                 return FREERDP_ARGS_PARSE_FAILURE;
478                         }
479
480                         settings->parent_window_xid = strtoul(argv[index], NULL, 16);
481
482                         if (settings->parent_window_xid == 0)
483                         {
484                                 printf("invalid parent window XID\n");
485                                 return FREERDP_ARGS_PARSE_FAILURE;
486                         }
487                 }
488                 else if (strcmp("--no-rdp", argv[index]) == 0)
489                 {
490                         settings->rdp_security = false;
491                 }
492                 else if (strcmp("--no-tls", argv[index]) == 0)
493                 {
494                         settings->tls_security = false;
495                 }
496                 else if (strcmp("--no-nla", argv[index]) == 0)
497                 {
498                         settings->nla_security = false;
499                 }
500                 else if (strcmp("--sec", argv[index]) == 0)
501                 {
502                         index++;
503                         if (index == argc)
504                         {
505                                 printf("missing protocol security\n");
506                                 return FREERDP_ARGS_PARSE_FAILURE;
507                         }
508                         if (strncmp("rdp", argv[index], 1) == 0) /* Standard RDP */
509                         {
510                                 settings->rdp_security = true;
511                                 settings->tls_security = false;
512                                 settings->nla_security = false;
513                                 settings->encryption = true;
514                                 settings->encryption_method = ENCRYPTION_METHOD_40BIT | ENCRYPTION_METHOD_128BIT | ENCRYPTION_METHOD_FIPS;
515                                 settings->encryption_level = ENCRYPTION_LEVEL_CLIENT_COMPATIBLE;
516                         }
517                         else if (strncmp("tls", argv[index], 1) == 0) /* TLS */
518                         {
519                                 settings->rdp_security = false;
520                                 settings->tls_security = true;
521                                 settings->nla_security = false;
522                         }
523                         else if (strncmp("nla", argv[index], 1) == 0) /* NLA */
524                         {
525                                 settings->rdp_security = false;
526                                 settings->tls_security = false;
527                                 settings->nla_security = true;
528                         }
529                         else
530                         {
531                                 printf("unknown protocol security\n");
532                                 return FREERDP_ARGS_PARSE_FAILURE;
533                         }
534                 }
535                 else if (strcmp("--plugin", argv[index]) == 0)
536                 {
537                         index++;
538                         t = index;
539                         if (index == argc)
540                         {
541                                 printf("missing plugin name\n");
542                                 return FREERDP_ARGS_PARSE_FAILURE;
543                         }
544                         plugin_data = NULL;
545                         if (index < argc - 1 && strcmp("--data", argv[index + 1]) == 0)
546                         {
547                                 index += 2;
548                                 i = 0;
549                                 while (index < argc && strcmp("--", argv[index]) != 0)
550                                 {
551                                         if (plugin_data == NULL)
552                                                 plugin_data = (RDP_PLUGIN_DATA*) xmalloc(sizeof(RDP_PLUGIN_DATA) * (i + 2));
553                                         else
554                                                 plugin_data = (RDP_PLUGIN_DATA*) xrealloc(plugin_data, sizeof(RDP_PLUGIN_DATA) * (i + 2));
555
556                                         plugin_data[i].size = sizeof(RDP_PLUGIN_DATA);
557                                         plugin_data[i].data[0] = NULL;
558                                         plugin_data[i].data[1] = NULL;
559                                         plugin_data[i].data[2] = NULL;
560                                         plugin_data[i].data[3] = NULL;
561                                         plugin_data[i + 1].size = 0;
562
563                                         for (j = 0, p = argv[index]; j < 4 && p != NULL; j++)
564                                         {
565                                                 if (*p == '\'')
566                                                 {
567                                                         plugin_data[i].data[j] = p + 1;
568                                                         p = strchr(p + 1, '\'');
569                                                         if (p)
570                                                                 *p++ = 0;
571                                                 }
572                                                 else
573                                                         plugin_data[i].data[j] = p;
574
575                                                 p = strchr(p, ':');
576                                                 if (p != NULL)
577                                                         *p++ = 0;
578                                         }
579                                         index++;
580                                         i++;
581                                 }
582                         }
583
584                         if (plugin_callback != NULL)
585                         {
586                                 if (!plugin_callback(settings, argv[t], plugin_data, plugin_user_data))
587                                         return FREERDP_ARGS_PARSE_FAILURE;
588                         }
589                 }
590                 else if (strcmp("--ext", argv[index]) == 0)
591                 {
592                         index++;
593                         if (index == argc)
594                         {
595                                 printf("missing extension name\n");
596                                 return FREERDP_ARGS_PARSE_FAILURE;
597                         }
598                         if (num_extensions >= sizeof(settings->extensions) / sizeof(struct rdp_ext_set))
599                         {
600                                 printf("maximum extensions reached\n");
601                                 return FREERDP_ARGS_PARSE_FAILURE;
602                         }
603                         snprintf(settings->extensions[num_extensions].name,
604                                 sizeof(settings->extensions[num_extensions].name),
605                                 "%s", argv[index]);
606                         settings->extensions[num_extensions].data = NULL;
607                         if (index < argc - 1 && strcmp("--data", argv[index + 1]) == 0)
608                         {
609                                 index += 2;
610                                 settings->extensions[num_extensions].data = argv[index];
611                                 i = 0;
612                                 while (index < argc && strcmp("--", argv[index]) != 0)
613                                 {
614                                         index++;
615                                         i++;
616                                 }
617                         }
618                         num_extensions++;
619                 }
620                 else if (strcmp("--secure-checksum", argv[index]) == 0)
621                 {
622                         settings->secure_checksum = true;
623                 }
624                 else if (strcmp("--version", argv[index]) == 0)
625                 {
626                         printf("This is FreeRDP version %s\n", FREERDP_VERSION_FULL);
627                         return FREERDP_ARGS_PARSE_VERSION;
628                 }
629                 else if (argv[index][0] != '-')
630                 {
631                         if (argv[index][0] == '[' && (p = strchr(argv[index], ']'))
632                                 && (p[1] == 0 || (p[1] == ':' && !strchr(p + 2, ':'))))
633                         {
634                                 /* Either "[...]" or "[...]:..." with at most one : after the brackets */
635                                 settings->hostname = xstrdup(argv[index] + 1);
636                                 if ((p = strchr((char*)settings->hostname, ']')))
637                                 {
638                                         *p = 0;
639                                         if (p[1] == ':')
640                                                 settings->port = atoi(p + 2);
641                                 }
642                         }
643                         else
644                         {
645                                 /* Port number is cut off and used if exactly one : in the string */
646                                 settings->hostname = xstrdup(argv[index]);
647                                 if ((p = strchr((char*)settings->hostname, ':')) && !strchr(p + 1, ':'))
648                                 {
649                                         *p = 0;
650                                         settings->port = atoi(p + 1);
651                                 }
652                         }
653                         /* server is the last argument for the current session. arguments
654                            followed will be parsed for the next session. */
655                         index++;
656
657                         if (settings->smooth_fonts)
658                                 settings->performance_flags |= PERF_ENABLE_FONT_SMOOTHING;
659
660                         if (settings->desktop_composition)
661                                 settings->performance_flags |= PERF_ENABLE_DESKTOP_COMPOSITION;
662
663                         if (settings->disable_wallpaper)
664                                 settings->performance_flags |= PERF_DISABLE_WALLPAPER;
665
666                         if (settings->disable_full_window_drag)
667                                 settings->performance_flags |= PERF_DISABLE_FULLWINDOWDRAG;
668
669                         if (settings->disable_menu_animations)
670                                 settings->performance_flags |= PERF_DISABLE_MENUANIMATIONS;
671
672                         if (settings->disable_theming)
673                                 settings->performance_flags |= PERF_DISABLE_THEMING;
674
675                         return index;
676                 }
677                 else
678                 {
679                         if (ui_callback != NULL)
680                         {
681                                 t = ui_callback(settings, argv[index], (index + 1 < argc && argv[index + 1][0] != '-' ?
682                                         argv[index + 1] : NULL), ui_user_data);
683                                 if (t == 0)
684                                 {
685                                         printf("invalid option: %s\n", argv[index]);
686                                         return FREERDP_ARGS_PARSE_FAILURE;
687                                 }
688                                 index += t - 1;
689                         }
690                 }
691                 index++;
692         }
693         printf("missing server name\n");
694         return FREERDP_ARGS_PARSE_FAILURE;
695 }