86 |
BOOL g_use_rdp5 = True; |
BOOL g_use_rdp5 = True; |
87 |
BOOL g_console_session = False; |
BOOL g_console_session = False; |
88 |
BOOL g_numlock_sync = False; |
BOOL g_numlock_sync = False; |
89 |
|
BOOL lspci_enabled = False; |
90 |
BOOL g_owncolmap = False; |
BOOL g_owncolmap = False; |
91 |
BOOL g_ownbackstore = True; /* We can't rely on external BackingStore */ |
BOOL g_ownbackstore = True; /* We can't rely on external BackingStore */ |
92 |
|
BOOL g_seamless_rdp = False; |
93 |
uint32 g_embed_wnd; |
uint32 g_embed_wnd; |
94 |
uint32 g_rdp5_performanceflags = |
uint32 g_rdp5_performanceflags = |
95 |
RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS; |
RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS; |
147 |
#ifdef HAVE_ICONV |
#ifdef HAVE_ICONV |
148 |
fprintf(stderr, " -L: local codepage\n"); |
fprintf(stderr, " -L: local codepage\n"); |
149 |
#endif |
#endif |
150 |
|
fprintf(stderr, " -A: enable SeamlessRDP mode\n"); |
151 |
fprintf(stderr, " -B: use BackingStore of X-server (if available)\n"); |
fprintf(stderr, " -B: use BackingStore of X-server (if available)\n"); |
152 |
fprintf(stderr, " -e: disable encryption (French TS)\n"); |
fprintf(stderr, " -e: disable encryption (French TS)\n"); |
153 |
fprintf(stderr, " -E: disable encryption from client to server\n"); |
fprintf(stderr, " -E: disable encryption from client to server\n"); |
392 |
int c; |
int c; |
393 |
char *locale = NULL; |
char *locale = NULL; |
394 |
int username_option = 0; |
int username_option = 0; |
395 |
|
BOOL geometry_option = False; |
396 |
int run_count = 0; /* Session Directory support */ |
int run_count = 0; /* Session Directory support */ |
397 |
BOOL continue_connect = True; /* Session Directory support */ |
BOOL continue_connect = True; /* Session Directory support */ |
398 |
|
|
419 |
#endif |
#endif |
420 |
|
|
421 |
while ((c = getopt(argc, argv, |
while ((c = getopt(argc, argv, |
422 |
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) |
423 |
{ |
{ |
424 |
switch (c) |
switch (c) |
425 |
{ |
{ |
437 |
break; |
break; |
438 |
#endif |
#endif |
439 |
|
|
440 |
|
case 'A': |
441 |
|
g_seamless_rdp = True; |
442 |
|
break; |
443 |
|
|
444 |
case 'u': |
case 'u': |
445 |
STRNCPY(g_username, optarg, sizeof(g_username)); |
STRNCPY(g_username, optarg, sizeof(g_username)); |
446 |
username_option = 1; |
username_option = 1; |
491 |
break; |
break; |
492 |
|
|
493 |
case 'g': |
case 'g': |
494 |
|
geometry_option = True; |
495 |
g_fullscreen = False; |
g_fullscreen = False; |
496 |
if (!strcmp(optarg, "workarea")) |
if (!strcmp(optarg, "workarea")) |
497 |
{ |
{ |
688 |
{ |
{ |
689 |
serial_enum_devices(&g_num_devices, optarg + 7); |
serial_enum_devices(&g_num_devices, optarg + 7); |
690 |
} |
} |
691 |
|
else if (str_startswith(optarg, "lspci")) |
692 |
|
{ |
693 |
|
lspci_enabled = True; |
694 |
|
} |
695 |
else if (str_startswith(optarg, "lptport")) |
else if (str_startswith(optarg, "lptport")) |
696 |
{ |
{ |
697 |
parallel_enum_devices(&g_num_devices, optarg + 7); |
parallel_enum_devices(&g_num_devices, optarg + 7); |
740 |
STRNCPY(server, argv[optind], sizeof(server)); |
STRNCPY(server, argv[optind], sizeof(server)); |
741 |
parse_server_and_port(server); |
parse_server_and_port(server); |
742 |
|
|
743 |
|
if (g_seamless_rdp) |
744 |
|
{ |
745 |
|
if (g_win_button_size) |
746 |
|
{ |
747 |
|
error("You cannot use -S and -A at the same time\n"); |
748 |
|
return 1; |
749 |
|
} |
750 |
|
g_rdp5_performanceflags &= ~RDP5_NO_FULLWINDOWDRAG; |
751 |
|
if (geometry_option) |
752 |
|
{ |
753 |
|
error("You cannot use -g and -A at the same time\n"); |
754 |
|
return 1; |
755 |
|
} |
756 |
|
if (g_fullscreen) |
757 |
|
{ |
758 |
|
error("You cannot use -f and -A at the same time\n"); |
759 |
|
return 1; |
760 |
|
} |
761 |
|
if (g_hide_decorations) |
762 |
|
{ |
763 |
|
error("You cannot use -D and -A at the same time\n"); |
764 |
|
return 1; |
765 |
|
} |
766 |
|
if (g_embed_wnd) |
767 |
|
{ |
768 |
|
error("You cannot use -X and -A at the same time\n"); |
769 |
|
return 1; |
770 |
|
} |
771 |
|
if (!g_use_rdp5) |
772 |
|
{ |
773 |
|
error("You cannot use -4 and -A at the same time\n"); |
774 |
|
return 1; |
775 |
|
} |
776 |
|
g_width = -100; |
777 |
|
g_grab_keyboard = False; |
778 |
|
} |
779 |
|
|
780 |
if (!username_option) |
if (!username_option) |
781 |
{ |
{ |
782 |
pw = getpwuid(getuid()); |
pw = getpwuid(getuid()); |
854 |
if (g_rdpsnd) |
if (g_rdpsnd) |
855 |
rdpsnd_init(); |
rdpsnd_init(); |
856 |
#endif |
#endif |
857 |
|
|
858 |
|
if (lspci_enabled) |
859 |
|
lspci_init(); |
860 |
|
|
861 |
rdpdr_init(); |
rdpdr_init(); |
862 |
|
|
863 |
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 */ |
1232 |
} |
} |
1233 |
|
|
1234 |
|
|
1235 |
|
/* Split input into lines, and call linehandler for each |
1236 |
|
line. Incomplete lines are saved in the rest variable, which should |
1237 |
|
initially point to NULL. When linehandler returns False, stop and |
1238 |
|
return False. Otherwise, return True. */ |
1239 |
|
BOOL |
1240 |
|
str_handle_lines(const char *input, char **rest, str_handle_lines_t linehandler, void *data) |
1241 |
|
{ |
1242 |
|
char *buf, *p; |
1243 |
|
char *oldrest; |
1244 |
|
size_t inputlen; |
1245 |
|
size_t buflen; |
1246 |
|
size_t restlen = 0; |
1247 |
|
BOOL ret = True; |
1248 |
|
|
1249 |
|
/* Copy data to buffer */ |
1250 |
|
inputlen = strlen(input); |
1251 |
|
if (*rest) |
1252 |
|
restlen = strlen(*rest); |
1253 |
|
buflen = restlen + inputlen + 1; |
1254 |
|
buf = (char *) xmalloc(buflen); |
1255 |
|
buf[0] = '\0'; |
1256 |
|
if (*rest) |
1257 |
|
STRNCPY(buf, *rest, buflen); |
1258 |
|
strncat(buf, input, inputlen); |
1259 |
|
p = buf; |
1260 |
|
|
1261 |
|
while (1) |
1262 |
|
{ |
1263 |
|
char *newline = strchr(p, '\n'); |
1264 |
|
if (newline) |
1265 |
|
{ |
1266 |
|
*newline = '\0'; |
1267 |
|
if (!linehandler(p, data)) |
1268 |
|
{ |
1269 |
|
p = newline + 1; |
1270 |
|
ret = False; |
1271 |
|
break; |
1272 |
|
} |
1273 |
|
p = newline + 1; |
1274 |
|
} |
1275 |
|
else |
1276 |
|
{ |
1277 |
|
break; |
1278 |
|
|
1279 |
|
} |
1280 |
|
} |
1281 |
|
|
1282 |
|
/* Save in rest */ |
1283 |
|
oldrest = *rest; |
1284 |
|
restlen = buf + buflen - p; |
1285 |
|
*rest = (char *) xmalloc(restlen); |
1286 |
|
STRNCPY((*rest), p, restlen); |
1287 |
|
xfree(oldrest); |
1288 |
|
|
1289 |
|
xfree(buf); |
1290 |
|
return ret; |
1291 |
|
} |
1292 |
|
|
1293 |
|
/* Execute the program specified by argv. For each line in |
1294 |
|
stdout/stderr output, call linehandler. Returns false on failure. */ |
1295 |
|
BOOL |
1296 |
|
subprocess(char *const argv[], str_handle_lines_t linehandler, void *data) |
1297 |
|
{ |
1298 |
|
pid_t child; |
1299 |
|
int fd[2]; |
1300 |
|
int n = 1; |
1301 |
|
char output[256]; |
1302 |
|
char *rest = NULL; |
1303 |
|
|
1304 |
|
if (pipe(fd) < 0) |
1305 |
|
{ |
1306 |
|
perror("pipe"); |
1307 |
|
return False; |
1308 |
|
} |
1309 |
|
|
1310 |
|
if ((child = fork()) < 0) |
1311 |
|
{ |
1312 |
|
perror("fork"); |
1313 |
|
return False; |
1314 |
|
} |
1315 |
|
|
1316 |
|
/* Child */ |
1317 |
|
if (child == 0) |
1318 |
|
{ |
1319 |
|
/* Close read end */ |
1320 |
|
close(fd[0]); |
1321 |
|
|
1322 |
|
/* Redirect stdout and stderr to pipe */ |
1323 |
|
dup2(fd[1], 1); |
1324 |
|
dup2(fd[1], 2); |
1325 |
|
|
1326 |
|
/* Execute */ |
1327 |
|
execvp(argv[0], argv); |
1328 |
|
perror("Error executing child"); |
1329 |
|
_exit(128); |
1330 |
|
} |
1331 |
|
|
1332 |
|
/* Parent. Close write end. */ |
1333 |
|
close(fd[1]); |
1334 |
|
while (n > 0) |
1335 |
|
{ |
1336 |
|
n = read(fd[0], output, 255); |
1337 |
|
output[n] = '\0'; |
1338 |
|
str_handle_lines(output, &rest, linehandler, data); |
1339 |
|
} |
1340 |
|
xfree(rest); |
1341 |
|
|
1342 |
|
return True; |
1343 |
|
} |
1344 |
|
|
1345 |
|
|
1346 |
/* not all clibs got ltoa */ |
/* not all clibs got ltoa */ |
1347 |
#define LTOA_BUFSIZE (sizeof(long) * 8 + 1) |
#define LTOA_BUFSIZE (sizeof(long) * 8 + 1) |
1348 |
|
|