32 |
int width = 800; |
int width = 800; |
33 |
int height = 600; |
int height = 600; |
34 |
int keylayout = 0x409; |
int keylayout = 0x409; |
35 |
BOOL motion = True; |
BOOL bitmap_compression = True; |
36 |
|
BOOL sendmotion = True; |
37 |
BOOL orders = True; |
BOOL orders = True; |
38 |
BOOL licence = True; |
BOOL licence = True; |
39 |
|
BOOL use_encryption = True; |
40 |
|
BOOL desktop_save = True; |
41 |
|
BOOL fullscreen = False; |
42 |
|
|
43 |
/* Display usage information */ |
/* Display usage information */ |
44 |
static void usage(char *program) |
static void |
45 |
|
usage(char *program) |
46 |
{ |
{ |
47 |
STATUS("Usage: %s [options] server\n", program); |
STATUS("Usage: %s [options] server\n", program); |
48 |
STATUS(" -u: user name\n"); |
STATUS(" -u: user name\n"); |
60 |
} |
} |
61 |
|
|
62 |
/* Client program */ |
/* Client program */ |
63 |
int main(int argc, char *argv[]) |
int |
64 |
|
main(int argc, char *argv[]) |
65 |
{ |
{ |
66 |
struct passwd *pw; |
struct passwd *pw; |
67 |
char *server; |
char *server; |
81 |
flags = RDP_LOGON_NORMAL; |
flags = RDP_LOGON_NORMAL; |
82 |
domain[0] = password[0] = shell[0] = directory[0] = 0; |
domain[0] = password[0] = shell[0] = directory[0] = 0; |
83 |
|
|
84 |
while ((c = getopt(argc, argv, "u:d:s:c:p:n:w:h:k:bml?")) != -1) |
while ((c = getopt(argc, argv, "u:d:s:c:p:n:g:k:mbleKFVh?")) != -1) |
85 |
{ |
{ |
86 |
switch (c) |
switch (c) |
87 |
{ |
{ |
109 |
case 'n': |
case 'n': |
110 |
strncpy(hostname, optarg, sizeof(hostname)); |
strncpy(hostname, optarg, sizeof(hostname)); |
111 |
break; |
break; |
112 |
|
case 'g': |
113 |
case 'w': |
{ |
114 |
width = strtol(optarg, NULL, 10); |
char *tgem = 0; |
115 |
break; |
width = strtol(optarg, NULL, 10); |
116 |
|
tgem = strchr(optarg, 'x'); |
117 |
case 'h': |
if ((tgem == 0) || (strlen(tgem) < 2)) |
118 |
height = strtol(optarg, NULL, 10); |
{ |
119 |
|
ERROR |
120 |
|
("-g: invalid parameter. Syntax example: -g 1024x768\n"); |
121 |
|
exit(1); |
122 |
|
} |
123 |
|
height = strtol(tgem + 1, NULL, 10); |
124 |
|
} |
125 |
break; |
break; |
126 |
|
|
127 |
case 'k': |
case 'k': |
128 |
keylayout = strtol(optarg, NULL, 16); |
keylayout = strtol(optarg, NULL, 16); |
129 |
|
/* keylayout = find_keyb_code(optarg); */ |
130 |
|
if (keylayout == 0) |
131 |
|
return 0; |
132 |
break; |
break; |
133 |
|
|
134 |
case 'm': |
case 'm': |
135 |
motion = False; |
sendmotion = False; |
136 |
break; |
break; |
137 |
|
|
138 |
case 'b': |
case 'b': |
143 |
licence = False; |
licence = False; |
144 |
break; |
break; |
145 |
|
|
146 |
|
case 'e': |
147 |
|
use_encryption = False; |
148 |
|
break; |
149 |
|
|
150 |
|
case 'F': |
151 |
|
fullscreen = True; |
152 |
|
break; |
153 |
|
|
154 |
|
case 'h': |
155 |
case '?': |
case '?': |
156 |
default: |
default: |
157 |
usage(argv[0]); |
usage(argv[0]); |
188 |
} |
} |
189 |
} |
} |
190 |
|
|
|
if (!rdp_connect(server, flags, domain, password, shell, directory)) |
|
|
return 1; |
|
|
|
|
|
STATUS("Connection successful.\n"); |
|
|
|
|
191 |
strcpy(title, "rdesktop - "); |
strcpy(title, "rdesktop - "); |
192 |
strncat(title, server, sizeof(title)); |
strncat(title, server, sizeof(title)); |
193 |
|
|
194 |
if (ui_create_window(title)) |
if (ui_create_window(title)) |
195 |
{ |
{ |
196 |
|
if (!rdp_connect(server, flags, domain, password, shell, |
197 |
|
directory)) |
198 |
|
return 1; |
199 |
|
|
200 |
|
STATUS("Connection successful.\n"); |
201 |
rdp_main_loop(); |
rdp_main_loop(); |
202 |
ui_destroy_window(); |
ui_destroy_window(); |
203 |
} |
} |
207 |
} |
} |
208 |
|
|
209 |
/* Generate a 32-byte random for the secure transport code. */ |
/* Generate a 32-byte random for the secure transport code. */ |
210 |
void generate_random(uint8 *random) |
void |
211 |
|
generate_random(uint8 *random) |
212 |
{ |
{ |
213 |
struct stat st; |
struct stat st; |
214 |
struct tms tmsbuf; |
struct tms tmsbuf; |
235 |
} |
} |
236 |
|
|
237 |
/* malloc; exit if out of memory */ |
/* malloc; exit if out of memory */ |
238 |
void *xmalloc(int size) |
void * |
239 |
|
xmalloc(int size) |
240 |
{ |
{ |
241 |
void *mem = malloc(size); |
void *mem = malloc(size); |
242 |
if (mem == NULL) |
if (mem == NULL) |
248 |
} |
} |
249 |
|
|
250 |
/* realloc; exit if out of memory */ |
/* realloc; exit if out of memory */ |
251 |
void *xrealloc(void *oldmem, int size) |
void * |
252 |
|
xrealloc(void *oldmem, int size) |
253 |
{ |
{ |
254 |
void *mem = realloc(oldmem, size); |
void *mem = realloc(oldmem, size); |
255 |
if (mem == NULL) |
if (mem == NULL) |
261 |
} |
} |
262 |
|
|
263 |
/* free */ |
/* free */ |
264 |
void xfree(void *mem) |
void |
265 |
|
xfree(void *mem) |
266 |
{ |
{ |
267 |
free(mem); |
free(mem); |
268 |
} |
} |
269 |
|
|
270 |
/* Produce a hex dump */ |
/* Produce a hex dump */ |
271 |
void hexdump(unsigned char *p, unsigned int len) |
void |
272 |
|
hexdump(unsigned char *p, unsigned int len) |
273 |
{ |
{ |
274 |
unsigned char *line = p; |
unsigned char *line = p; |
275 |
unsigned int thisline, offset = 0; |
unsigned int thisline, offset = 0; |