69 |
2 xpos neg, |
2 xpos neg, |
70 |
4 ypos neg */ |
4 ypos neg */ |
71 |
extern int g_tcp_port_rdp; |
extern int g_tcp_port_rdp; |
72 |
int g_server_depth = 8; |
int g_server_depth = -1; |
73 |
int g_win_button_size = 0; /* If zero, disable single app mode */ |
int g_win_button_size = 0; /* If zero, disable single app mode */ |
74 |
BOOL g_bitmap_compression = True; |
BOOL g_bitmap_compression = True; |
75 |
BOOL g_sendmotion = True; |
BOOL g_sendmotion = True; |
84 |
BOOL g_grab_keyboard = True; |
BOOL g_grab_keyboard = True; |
85 |
BOOL g_hide_decorations = False; |
BOOL g_hide_decorations = False; |
86 |
BOOL g_use_rdp5 = True; |
BOOL g_use_rdp5 = True; |
87 |
|
BOOL g_rdpclip = True; |
88 |
BOOL g_console_session = False; |
BOOL g_console_session = False; |
89 |
BOOL g_numlock_sync = False; |
BOOL g_numlock_sync = False; |
90 |
|
BOOL lspci_enabled = False; |
91 |
BOOL g_owncolmap = False; |
BOOL g_owncolmap = False; |
92 |
BOOL g_ownbackstore = True; /* We can't rely on external BackingStore */ |
BOOL g_ownbackstore = True; /* We can't rely on external BackingStore */ |
93 |
|
BOOL g_seamless_rdp = False; |
94 |
uint32 g_embed_wnd; |
uint32 g_embed_wnd; |
95 |
uint32 g_rdp5_performanceflags = |
uint32 g_rdp5_performanceflags = |
96 |
RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS; |
RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS; |
148 |
#ifdef HAVE_ICONV |
#ifdef HAVE_ICONV |
149 |
fprintf(stderr, " -L: local codepage\n"); |
fprintf(stderr, " -L: local codepage\n"); |
150 |
#endif |
#endif |
151 |
|
fprintf(stderr, " -A: enable SeamlessRDP mode\n"); |
152 |
fprintf(stderr, " -B: use BackingStore of X-server (if available)\n"); |
fprintf(stderr, " -B: use BackingStore of X-server (if available)\n"); |
153 |
fprintf(stderr, " -e: disable encryption (French TS)\n"); |
fprintf(stderr, " -e: disable encryption (French TS)\n"); |
154 |
fprintf(stderr, " -E: disable encryption from client to server\n"); |
fprintf(stderr, " -E: disable encryption from client to server\n"); |
179 |
fprintf(stderr, " '-r printer:mydeskjet': enable printer redirection\n"); |
fprintf(stderr, " '-r printer:mydeskjet': enable printer redirection\n"); |
180 |
fprintf(stderr, |
fprintf(stderr, |
181 |
" or mydeskjet=\"HP LaserJet IIIP\" to enter server driver as well\n"); |
" or mydeskjet=\"HP LaserJet IIIP\" to enter server driver as well\n"); |
182 |
fprintf(stderr, " '-r sound:[local|off|remote]': enable sound redirection\n"); |
#ifdef WITH_RDPSND |
183 |
|
fprintf(stderr, |
184 |
|
" '-r sound:[local[:driver[:device]]|off|remote]': enable sound redirection\n"); |
185 |
fprintf(stderr, " remote would leave sound on server\n"); |
fprintf(stderr, " remote would leave sound on server\n"); |
186 |
|
fprintf(stderr, " available drivers for 'local':\n"); |
187 |
|
rdpsnd_show_help(); |
188 |
|
#endif |
189 |
|
fprintf(stderr, |
190 |
|
" '-r clipboard:[off|PRIMARYCLIPBOARD|CLIPBOARD]': enable clipboard\n"); |
191 |
|
fprintf(stderr, " redirection.\n"); |
192 |
|
fprintf(stderr, |
193 |
|
" 'PRIMARYCLIPBOARD' looks at both PRIMARY and CLIPBOARD\n"); |
194 |
|
fprintf(stderr, " when sending data to server.\n"); |
195 |
|
fprintf(stderr, " 'CLIPBOARD' looks at only CLIPBOARD.\n"); |
196 |
fprintf(stderr, " -0: attach to console\n"); |
fprintf(stderr, " -0: attach to console\n"); |
197 |
fprintf(stderr, " -4: use RDP version 4\n"); |
fprintf(stderr, " -4: use RDP version 4\n"); |
198 |
fprintf(stderr, " -5: use RDP version 5 (default)\n"); |
fprintf(stderr, " -5: use RDP version 5 (default)\n"); |
405 |
int c; |
int c; |
406 |
char *locale = NULL; |
char *locale = NULL; |
407 |
int username_option = 0; |
int username_option = 0; |
408 |
|
BOOL geometry_option = False; |
409 |
int run_count = 0; /* Session Directory support */ |
int run_count = 0; /* Session Directory support */ |
410 |
BOOL continue_connect = True; /* Session Directory support */ |
BOOL continue_connect = True; /* Session Directory support */ |
411 |
|
|
432 |
#endif |
#endif |
433 |
|
|
434 |
while ((c = getopt(argc, argv, |
while ((c = getopt(argc, argv, |
435 |
VNCOPT "u:L:d:s:c:p:n:k:g:fbBeEmzCDKS:T:NX:a:x:Pr:045h?")) != -1) |
VNCOPT "Au:L:d:s:c:p:n:k:g:fbBeEmzCDKS:T:NX:a:x:Pr:045h?")) != -1) |
436 |
{ |
{ |
437 |
switch (c) |
switch (c) |
438 |
{ |
{ |
450 |
break; |
break; |
451 |
#endif |
#endif |
452 |
|
|
453 |
|
case 'A': |
454 |
|
g_seamless_rdp = True; |
455 |
|
break; |
456 |
|
|
457 |
case 'u': |
case 'u': |
458 |
STRNCPY(g_username, optarg, sizeof(g_username)); |
STRNCPY(g_username, optarg, sizeof(g_username)); |
459 |
username_option = 1; |
username_option = 1; |
504 |
break; |
break; |
505 |
|
|
506 |
case 'g': |
case 'g': |
507 |
|
geometry_option = True; |
508 |
g_fullscreen = False; |
g_fullscreen = False; |
509 |
if (!strcmp(optarg, "workarea")) |
if (!strcmp(optarg, "workarea")) |
510 |
{ |
{ |
660 |
|
|
661 |
if (*optarg == ':') |
if (*optarg == ':') |
662 |
{ |
{ |
663 |
*optarg++; |
optarg++; |
664 |
while ((p = next_arg(optarg, ','))) |
while ((p = next_arg(optarg, ','))) |
665 |
{ |
{ |
666 |
if (str_startswith(optarg, "remote")) |
if (str_startswith(optarg, "remote")) |
668 |
|
|
669 |
if (str_startswith(optarg, "local")) |
if (str_startswith(optarg, "local")) |
670 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
671 |
g_rdpsnd = True; |
{ |
672 |
|
char *driver = NULL, *options = |
673 |
|
NULL; |
674 |
|
|
675 |
|
if ((driver = |
676 |
|
next_arg(optarg, ':'))) |
677 |
|
{ |
678 |
|
if (!strlen(driver)) |
679 |
|
{ |
680 |
|
driver = NULL; |
681 |
|
} |
682 |
|
else if ((options = |
683 |
|
next_arg(driver, |
684 |
|
':'))) |
685 |
|
{ |
686 |
|
if (!strlen |
687 |
|
(options)) |
688 |
|
options = |
689 |
|
NULL; |
690 |
|
} |
691 |
|
} |
692 |
|
|
693 |
|
if (!rdpsnd_select_driver |
694 |
|
(driver, options)) |
695 |
|
{ |
696 |
|
warning("Driver not available\n"); |
697 |
|
} |
698 |
|
else |
699 |
|
{ |
700 |
|
g_rdpsnd = True; |
701 |
|
} |
702 |
|
} |
703 |
|
|
704 |
#else |
#else |
705 |
warning("Not compiled with sound support\n"); |
warning("Not compiled with sound support\n"); |
706 |
#endif |
#endif |
718 |
else |
else |
719 |
{ |
{ |
720 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
721 |
g_rdpsnd = True; |
if (!rdpsnd_select_driver(NULL, NULL)) |
722 |
|
{ |
723 |
|
warning("No sound-driver available\n"); |
724 |
|
} |
725 |
|
else |
726 |
|
{ |
727 |
|
g_rdpsnd = True; |
728 |
|
} |
729 |
#else |
#else |
730 |
warning("Not compiled with sound support\n"); |
warning("Not compiled with sound support\n"); |
731 |
#endif |
#endif |
740 |
{ |
{ |
741 |
serial_enum_devices(&g_num_devices, optarg + 7); |
serial_enum_devices(&g_num_devices, optarg + 7); |
742 |
} |
} |
743 |
|
else if (str_startswith(optarg, "lspci")) |
744 |
|
{ |
745 |
|
lspci_enabled = True; |
746 |
|
} |
747 |
else if (str_startswith(optarg, "lptport")) |
else if (str_startswith(optarg, "lptport")) |
748 |
{ |
{ |
749 |
parallel_enum_devices(&g_num_devices, optarg + 7); |
parallel_enum_devices(&g_num_devices, optarg + 7); |
757 |
g_rdpdr_clientname = xmalloc(strlen(optarg + 11) + 1); |
g_rdpdr_clientname = xmalloc(strlen(optarg + 11) + 1); |
758 |
strcpy(g_rdpdr_clientname, optarg + 11); |
strcpy(g_rdpdr_clientname, optarg + 11); |
759 |
} |
} |
760 |
|
else if (str_startswith(optarg, "clipboard")) |
761 |
|
{ |
762 |
|
optarg += 9; |
763 |
|
|
764 |
|
if (*optarg == ':') |
765 |
|
{ |
766 |
|
optarg++; |
767 |
|
|
768 |
|
if (str_startswith(optarg, "off")) |
769 |
|
g_rdpclip = False; |
770 |
|
else |
771 |
|
cliprdr_set_mode(optarg); |
772 |
|
} |
773 |
|
else |
774 |
|
g_rdpclip = True; |
775 |
|
} |
776 |
else |
else |
777 |
{ |
{ |
778 |
warning("Unknown -r argument\n\n\tPossible arguments are: comport, disk, lptport, printer, sound\n"); |
warning("Unknown -r argument\n\n\tPossible arguments are: comport, disk, lptport, printer, sound, clipboard\n"); |
779 |
} |
} |
780 |
break; |
break; |
781 |
|
|
808 |
STRNCPY(server, argv[optind], sizeof(server)); |
STRNCPY(server, argv[optind], sizeof(server)); |
809 |
parse_server_and_port(server); |
parse_server_and_port(server); |
810 |
|
|
811 |
|
if (g_seamless_rdp) |
812 |
|
{ |
813 |
|
if (g_win_button_size) |
814 |
|
{ |
815 |
|
error("You cannot use -S and -A at the same time\n"); |
816 |
|
return 1; |
817 |
|
} |
818 |
|
g_rdp5_performanceflags &= ~RDP5_NO_FULLWINDOWDRAG; |
819 |
|
if (geometry_option) |
820 |
|
{ |
821 |
|
error("You cannot use -g and -A at the same time\n"); |
822 |
|
return 1; |
823 |
|
} |
824 |
|
if (g_fullscreen) |
825 |
|
{ |
826 |
|
error("You cannot use -f and -A at the same time\n"); |
827 |
|
return 1; |
828 |
|
} |
829 |
|
if (g_hide_decorations) |
830 |
|
{ |
831 |
|
error("You cannot use -D and -A at the same time\n"); |
832 |
|
return 1; |
833 |
|
} |
834 |
|
if (g_embed_wnd) |
835 |
|
{ |
836 |
|
error("You cannot use -X and -A at the same time\n"); |
837 |
|
return 1; |
838 |
|
} |
839 |
|
if (!g_use_rdp5) |
840 |
|
{ |
841 |
|
error("You cannot use -4 and -A at the same time\n"); |
842 |
|
return 1; |
843 |
|
} |
844 |
|
g_width = -100; |
845 |
|
g_grab_keyboard = False; |
846 |
|
} |
847 |
|
|
848 |
if (!username_option) |
if (!username_option) |
849 |
{ |
{ |
850 |
pw = getpwuid(getuid()); |
pw = getpwuid(getuid()); |
922 |
if (g_rdpsnd) |
if (g_rdpsnd) |
923 |
rdpsnd_init(); |
rdpsnd_init(); |
924 |
#endif |
#endif |
925 |
|
|
926 |
|
if (lspci_enabled) |
927 |
|
lspci_init(); |
928 |
|
|
929 |
rdpdr_init(); |
rdpdr_init(); |
930 |
|
|
931 |
while (run_count < 2 && continue_connect) /* add support for Session Directory; only reconnect once */ |
while (run_count < 2 && continue_connect) /* add support for Session Directory; only reconnect once */ |
1255 |
while (*(mvp + 1) != (char) 0x00) |
while (*(mvp + 1) != (char) 0x00) |
1256 |
{ |
{ |
1257 |
*mvp = *(mvp + 1); |
*mvp = *(mvp + 1); |
1258 |
*mvp++; |
mvp++; |
1259 |
} |
} |
1260 |
*mvp = (char) 0x00; |
*mvp = (char) 0x00; |
1261 |
p = nextval; |
p = nextval; |
1300 |
} |
} |
1301 |
|
|
1302 |
|
|
1303 |
|
/* Split input into lines, and call linehandler for each |
1304 |
|
line. Incomplete lines are saved in the rest variable, which should |
1305 |
|
initially point to NULL. When linehandler returns False, stop and |
1306 |
|
return False. Otherwise, return True. */ |
1307 |
|
BOOL |
1308 |
|
str_handle_lines(const char *input, char **rest, str_handle_lines_t linehandler, void *data) |
1309 |
|
{ |
1310 |
|
char *buf, *p; |
1311 |
|
char *oldrest; |
1312 |
|
size_t inputlen; |
1313 |
|
size_t buflen; |
1314 |
|
size_t restlen = 0; |
1315 |
|
BOOL ret = True; |
1316 |
|
|
1317 |
|
/* Copy data to buffer */ |
1318 |
|
inputlen = strlen(input); |
1319 |
|
if (*rest) |
1320 |
|
restlen = strlen(*rest); |
1321 |
|
buflen = restlen + inputlen + 1; |
1322 |
|
buf = (char *) xmalloc(buflen); |
1323 |
|
buf[0] = '\0'; |
1324 |
|
if (*rest) |
1325 |
|
STRNCPY(buf, *rest, buflen); |
1326 |
|
strncat(buf, input, inputlen); |
1327 |
|
p = buf; |
1328 |
|
|
1329 |
|
while (1) |
1330 |
|
{ |
1331 |
|
char *newline = strchr(p, '\n'); |
1332 |
|
if (newline) |
1333 |
|
{ |
1334 |
|
*newline = '\0'; |
1335 |
|
if (!linehandler(p, data)) |
1336 |
|
{ |
1337 |
|
p = newline + 1; |
1338 |
|
ret = False; |
1339 |
|
break; |
1340 |
|
} |
1341 |
|
p = newline + 1; |
1342 |
|
} |
1343 |
|
else |
1344 |
|
{ |
1345 |
|
break; |
1346 |
|
|
1347 |
|
} |
1348 |
|
} |
1349 |
|
|
1350 |
|
/* Save in rest */ |
1351 |
|
oldrest = *rest; |
1352 |
|
restlen = buf + buflen - p; |
1353 |
|
*rest = (char *) xmalloc(restlen); |
1354 |
|
STRNCPY((*rest), p, restlen); |
1355 |
|
xfree(oldrest); |
1356 |
|
|
1357 |
|
xfree(buf); |
1358 |
|
return ret; |
1359 |
|
} |
1360 |
|
|
1361 |
|
/* Execute the program specified by argv. For each line in |
1362 |
|
stdout/stderr output, call linehandler. Returns false on failure. */ |
1363 |
|
BOOL |
1364 |
|
subprocess(char *const argv[], str_handle_lines_t linehandler, void *data) |
1365 |
|
{ |
1366 |
|
pid_t child; |
1367 |
|
int fd[2]; |
1368 |
|
int n = 1; |
1369 |
|
char output[256]; |
1370 |
|
char *rest = NULL; |
1371 |
|
|
1372 |
|
if (pipe(fd) < 0) |
1373 |
|
{ |
1374 |
|
perror("pipe"); |
1375 |
|
return False; |
1376 |
|
} |
1377 |
|
|
1378 |
|
if ((child = fork()) < 0) |
1379 |
|
{ |
1380 |
|
perror("fork"); |
1381 |
|
return False; |
1382 |
|
} |
1383 |
|
|
1384 |
|
/* Child */ |
1385 |
|
if (child == 0) |
1386 |
|
{ |
1387 |
|
/* Close read end */ |
1388 |
|
close(fd[0]); |
1389 |
|
|
1390 |
|
/* Redirect stdout and stderr to pipe */ |
1391 |
|
dup2(fd[1], 1); |
1392 |
|
dup2(fd[1], 2); |
1393 |
|
|
1394 |
|
/* Execute */ |
1395 |
|
execvp(argv[0], argv); |
1396 |
|
perror("Error executing child"); |
1397 |
|
_exit(128); |
1398 |
|
} |
1399 |
|
|
1400 |
|
/* Parent. Close write end. */ |
1401 |
|
close(fd[1]); |
1402 |
|
while (n > 0) |
1403 |
|
{ |
1404 |
|
n = read(fd[0], output, 255); |
1405 |
|
output[n] = '\0'; |
1406 |
|
str_handle_lines(output, &rest, linehandler, data); |
1407 |
|
} |
1408 |
|
xfree(rest); |
1409 |
|
|
1410 |
|
return True; |
1411 |
|
} |
1412 |
|
|
1413 |
|
|
1414 |
/* not all clibs got ltoa */ |
/* not all clibs got ltoa */ |
1415 |
#define LTOA_BUFSIZE (sizeof(long) * 8 + 1) |
#define LTOA_BUFSIZE (sizeof(long) * 8 + 1) |
1416 |
|
|