1 |
/* |
/* |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
Entrypoint and utility functions |
Entrypoint and utility functions |
4 |
Copyright (C) Matthew Chapman 1999-2002 |
Copyright (C) Matthew Chapman 1999-2003 |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
7 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
21 |
#include <stdarg.h> /* va_list va_start va_end */ |
#include <stdarg.h> /* va_list va_start va_end */ |
22 |
#include <unistd.h> /* read close getuid getgid getpid getppid gethostname */ |
#include <unistd.h> /* read close getuid getgid getpid getppid gethostname */ |
23 |
#include <fcntl.h> /* open */ |
#include <fcntl.h> /* open */ |
|
#include <errno.h> /* save licence uses it. */ |
|
24 |
#include <pwd.h> /* getpwuid */ |
#include <pwd.h> /* getpwuid */ |
25 |
#include <termios.h> /* tcgetattr tcsetattr */ |
#include <termios.h> /* tcgetattr tcsetattr */ |
26 |
#include <sys/stat.h> /* stat */ |
#include <sys/stat.h> /* stat */ |
27 |
#include <sys/time.h> /* gettimeofday */ |
#include <sys/time.h> /* gettimeofday */ |
28 |
#include <sys/times.h> /* times */ |
#include <sys/times.h> /* times */ |
29 |
|
#include <errno.h> |
30 |
#include "rdesktop.h" |
#include "rdesktop.h" |
31 |
|
|
32 |
#ifdef EGD_SOCKET |
#ifdef EGD_SOCKET |
45 |
char hostname[16]; |
char hostname[16]; |
46 |
char keymapname[16]; |
char keymapname[16]; |
47 |
int keylayout = 0x409; /* Defaults to US keyboard layout */ |
int keylayout = 0x409; /* Defaults to US keyboard layout */ |
48 |
int width = 800; /* If width or height are reset to zero, the geometry will |
int width = 800; /* If width or height are reset to zero, the geometry will |
49 |
be fetched from _NET_WORKAREA */ |
be fetched from _NET_WORKAREA */ |
50 |
int height = 600; |
int height = 600; |
51 |
int tcp_port_rdp = TCP_PORT_RDP; |
int tcp_port_rdp = TCP_PORT_RDP; |
52 |
|
int server_bpp = 8; |
53 |
BOOL bitmap_compression = True; |
BOOL bitmap_compression = True; |
54 |
BOOL sendmotion = True; |
BOOL sendmotion = True; |
55 |
BOOL orders = True; |
BOOL orders = True; |
65 |
usage(char *program) |
usage(char *program) |
66 |
{ |
{ |
67 |
fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n"); |
fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n"); |
68 |
fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2002 Matt Chapman.\n"); |
fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2003 Matt Chapman.\n"); |
69 |
fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n"); |
fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n"); |
70 |
|
|
71 |
fprintf(stderr, "Usage: %s [options] server[:port]\n", program); |
fprintf(stderr, "Usage: %s [options] server[:port]\n", program); |
85 |
fprintf(stderr, " -K: keep window manager key bindings\n"); |
fprintf(stderr, " -K: keep window manager key bindings\n"); |
86 |
fprintf(stderr, " -T: window title\n"); |
fprintf(stderr, " -T: window title\n"); |
87 |
fprintf(stderr, " -D: hide window manager decorations\n"); |
fprintf(stderr, " -D: hide window manager decorations\n"); |
88 |
|
fprintf(stderr, " -a: server bpp\n"); |
89 |
} |
} |
90 |
|
|
91 |
static BOOL |
static BOOL |
146 |
domain[0] = password[0] = shell[0] = directory[0] = 0; |
domain[0] = password[0] = shell[0] = directory[0] = 0; |
147 |
strcpy(keymapname, "en-us"); |
strcpy(keymapname, "en-us"); |
148 |
|
|
149 |
while ((c = getopt(argc, argv, "u:d:s:c:p:n:k:g:fbemCKT:Dh?")) != -1) |
while ((c = getopt(argc, argv, "u:d:s:c:p:n:k:g:a:fbemCKT:Dh?")) != -1) |
150 |
{ |
{ |
151 |
switch (c) |
switch (c) |
152 |
{ |
{ |
241 |
hide_decorations = True; |
hide_decorations = True; |
242 |
break; |
break; |
243 |
|
|
244 |
|
case 'a': |
245 |
|
server_bpp = strtol(optarg, NULL, 10); |
246 |
|
if (server_bpp != 8 && server_bpp != 16 && server_bpp != 15 |
247 |
|
&& server_bpp != 24) |
248 |
|
{ |
249 |
|
error("invalid server bpp\n"); |
250 |
|
return 1; |
251 |
|
} |
252 |
|
break; |
253 |
|
|
254 |
case 'h': |
case 'h': |
255 |
case '?': |
case '?': |
256 |
default: |
default: |
515 |
} |
} |
516 |
} |
} |
517 |
|
|
518 |
#ifdef SAVE_LICENCE |
|
519 |
int |
int |
520 |
load_licence(unsigned char **data) |
load_licence(unsigned char **data) |
521 |
{ |
{ |
573 |
if ((s_ptr->p) + 4 > data + length) |
if ((s_ptr->p) + 4 > data + length) |
574 |
{ |
{ |
575 |
printf("Error in parsing licence key.\n"); |
printf("Error in parsing licence key.\n"); |
576 |
printf("Strings %d end value %x > supplied length (%x)\n", |
printf("Strings %d end value %x > supplied length (%x)\n", i, |
577 |
i, s_ptr->p, data + length); |
(unsigned int) s_ptr->p, (unsigned int) data + length); |
578 |
return; |
return; |
579 |
} |
} |
580 |
} |
} |
582 |
if (s_ptr->p + len > data + length) |
if (s_ptr->p + len > data + length) |
583 |
{ |
{ |
584 |
printf("Error in parsing licence key.\n"); |
printf("Error in parsing licence key.\n"); |
585 |
printf("End of licence %x > supplied length (%x)\n", s_ptr->p + len, data + length); |
printf("End of licence %x > supplied length (%x)\n", |
586 |
|
(unsigned int) s_ptr->p + len, (unsigned int) data + length); |
587 |
return; |
return; |
588 |
} |
} |
589 |
|
|
619 |
fnamewrk = xmalloc(strlen(fname) + 12); |
fnamewrk = xmalloc(strlen(fname) + 12); |
620 |
for (y = 0;; y++) |
for (y = 0;; y++) |
621 |
{ |
{ |
622 |
sprintf(fnamewrk, "%s.%lu", fname, y); |
sprintf(fnamewrk, "%s.%lu", fname, (long unsigned int) y); |
623 |
fnwrkfd = open(fnamewrk, O_WRONLY | O_CREAT | O_EXCL, 0600); |
fnwrkfd = open(fnamewrk, O_WRONLY | O_CREAT | O_EXCL, 0600); |
624 |
if (fnwrkfd == -1) |
if (fnwrkfd == -1) |
625 |
{ |
{ |
672 |
} |
} |
673 |
|
|
674 |
} |
} |
|
#endif |
|