35 |
#include <sys/un.h> /* sockaddr_un */ |
#include <sys/un.h> /* sockaddr_un */ |
36 |
#endif |
#endif |
37 |
|
|
|
#ifdef WITH_OPENSSL |
|
38 |
#include <openssl/md5.h> |
#include <openssl/md5.h> |
|
#else |
|
|
#include "crypto/md5.h" |
|
|
#endif |
|
39 |
|
|
40 |
char g_title[64] = ""; |
char g_title[64] = ""; |
41 |
char g_username[64]; |
char g_username[64]; |
55 |
BOOL g_bitmap_compression = True; |
BOOL g_bitmap_compression = True; |
56 |
BOOL g_sendmotion = True; |
BOOL g_sendmotion = True; |
57 |
BOOL g_bitmap_cache = True; |
BOOL g_bitmap_cache = True; |
58 |
|
BOOL g_bitmap_cache_persist_enable = False; |
59 |
|
BOOL g_bitmap_cache_precache = True; |
60 |
BOOL g_encryption = True; |
BOOL g_encryption = True; |
61 |
BOOL packet_encryption = True; |
BOOL packet_encryption = True; |
62 |
BOOL g_desktop_save = True; |
BOOL g_desktop_save = True; |
122 |
fprintf(stderr, " -N: enable numlock syncronization\n"); |
fprintf(stderr, " -N: enable numlock syncronization\n"); |
123 |
fprintf(stderr, " -X: embed into another window with a given id.\n"); |
fprintf(stderr, " -X: embed into another window with a given id.\n"); |
124 |
fprintf(stderr, " -a: connection colour depth\n"); |
fprintf(stderr, " -a: connection colour depth\n"); |
125 |
fprintf(stderr, |
fprintf(stderr, " -z: enable rdp compression\n"); |
126 |
" -x: RDP5 experience (m[odem 28.8], b[roadband], l[an] or hex number)\n"); |
fprintf(stderr, " -x: RDP5 experience (m[odem 28.8], b[roadband], l[an] or hex nr.)\n"); |
127 |
|
fprintf(stderr, " -P: use persistent bitmap caching\n"); |
128 |
fprintf(stderr, " -r: enable specified device redirection (this flag can be repeated)\n"); |
fprintf(stderr, " -r: enable specified device redirection (this flag can be repeated)\n"); |
129 |
fprintf(stderr, |
fprintf(stderr, |
130 |
" '-r comport:COM1=/dev/ttyS0': enable serial redirection of /dev/ttyS0 to COM1\n"); |
" '-r comport:COM1=/dev/ttyS0': enable serial redirection of /dev/ttyS0 to COM1\n"); |
131 |
fprintf(stderr, " or COM1=/dev/ttyS0,COM2=/dev/ttyS1\n"); |
fprintf(stderr, " or COM1=/dev/ttyS0,COM2=/dev/ttyS1\n"); |
132 |
fprintf(stderr, |
fprintf(stderr, |
133 |
" '-r disk:A=/mnt/floppy': enable redirection of /mnt/floppy to A:\n"); |
" '-r disk:floppy=/mnt/floppy': enable redirection of /mnt/floppy to 'floppy' share\n"); |
134 |
fprintf(stderr, " or A=/mnt/floppy,D=/mnt/cdrom'\n"); |
fprintf(stderr, " or 'floppy=/mnt/floppy,cdrom=/mnt/cdrom'\n"); |
135 |
fprintf(stderr, " '-r clientname=<client name>': Set the client name displayed\n"); |
fprintf(stderr, " '-r clientname=<client name>': Set the client name displayed\n"); |
136 |
fprintf(stderr, " for redirected disks\n"); |
fprintf(stderr, " for redirected disks\n"); |
137 |
fprintf(stderr, |
fprintf(stderr, |
363 |
#define VNCOPT |
#define VNCOPT |
364 |
#endif |
#endif |
365 |
|
|
366 |
while ((c = getopt(argc, argv, VNCOPT "u:d:s:c:p:n:k:g:fbBeEmCDKS:T:NX:a:x:r:045h?")) != -1) |
while ((c = getopt(argc, argv, |
367 |
|
VNCOPT "u:d:s:c:p:n:k:g:fbBeEmzCDKS:T:NX:a:x:Pr:045h?")) != -1) |
368 |
{ |
{ |
369 |
switch (c) |
switch (c) |
370 |
{ |
{ |
525 |
} |
} |
526 |
break; |
break; |
527 |
|
|
528 |
case 'x': |
case 'z': |
529 |
|
DEBUG(("rdp compression enabled\n")); |
530 |
|
flags |= RDP_COMPRESSION; |
531 |
|
break; |
532 |
|
|
533 |
|
case 'x': |
534 |
if (strncmp("modem", optarg, 1) == 0) |
if (strncmp("modem", optarg, 1) == 0) |
535 |
{ |
{ |
536 |
g_rdp5_performanceflags = |
g_rdp5_performanceflags = |
551 |
} |
} |
552 |
break; |
break; |
553 |
|
|
554 |
|
case 'P': |
555 |
|
g_bitmap_cache_persist_enable = True; |
556 |
|
break; |
557 |
|
|
558 |
case 'r': |
case 'r': |
559 |
|
|
560 |
if (strncmp("sound", optarg, 5) == 0) |
if (strncmp("sound", optarg, 5) == 0) |
573 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
574 |
g_rdpsnd = True; |
g_rdpsnd = True; |
575 |
#else |
#else |
576 |
warning("Not compiled with sound support"); |
warning("Not compiled with sound support\n"); |
577 |
#endif |
#endif |
578 |
|
|
579 |
if (strncmp("off", optarg, 3) == 0) |
if (strncmp("off", optarg, 3) == 0) |
580 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
581 |
g_rdpsnd = False; |
g_rdpsnd = False; |
582 |
#else |
#else |
583 |
warning("Not compiled with sound support"); |
warning("Not compiled with sound support\n"); |
584 |
#endif |
#endif |
585 |
|
|
586 |
optarg = p; |
optarg = p; |
591 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
592 |
g_rdpsnd = True; |
g_rdpsnd = True; |
593 |
#else |
#else |
594 |
warning("Not compiled with sound support"); |
warning("Not compiled with sound support\n"); |
595 |
#endif |
#endif |
596 |
} |
} |
597 |
} |
} |
722 |
|
|
723 |
DEBUG(("Disconnecting...\n")); |
DEBUG(("Disconnecting...\n")); |
724 |
rdp_disconnect(); |
rdp_disconnect(); |
725 |
|
cache_save_state(); |
726 |
ui_deinit(); |
ui_deinit(); |
727 |
|
|
728 |
if (ext_disc_reason >= 2) |
if (ext_disc_reason >= 2) |
852 |
void * |
void * |
853 |
xrealloc(void *oldmem, int size) |
xrealloc(void *oldmem, int size) |
854 |
{ |
{ |
855 |
void *mem = realloc(oldmem, size); |
void *mem; |
856 |
|
|
857 |
|
if (size < 1) |
858 |
|
size = 1; |
859 |
|
mem = realloc(oldmem, size); |
860 |
if (mem == NULL) |
if (mem == NULL) |
861 |
{ |
{ |
862 |
error("xrealloc %d\n", size); |
error("xrealloc %d\n", size); |
1134 |
xfree(tmppath); |
xfree(tmppath); |
1135 |
xfree(path); |
xfree(path); |
1136 |
} |
} |
1137 |
|
|
1138 |
|
/* Create the bitmap cache directory */ |
1139 |
|
BOOL |
1140 |
|
rd_pstcache_mkdir(void) |
1141 |
|
{ |
1142 |
|
char *home; |
1143 |
|
char bmpcache_dir[256]; |
1144 |
|
|
1145 |
|
home = getenv("HOME"); |
1146 |
|
|
1147 |
|
if (home == NULL) |
1148 |
|
return False; |
1149 |
|
|
1150 |
|
sprintf(bmpcache_dir, "%s/%s", home, ".rdesktop"); |
1151 |
|
|
1152 |
|
if ((mkdir(bmpcache_dir, S_IRWXU) == -1) && errno != EEXIST) |
1153 |
|
{ |
1154 |
|
perror(bmpcache_dir); |
1155 |
|
return False; |
1156 |
|
} |
1157 |
|
|
1158 |
|
sprintf(bmpcache_dir, "%s/%s", home, ".rdesktop/cache"); |
1159 |
|
|
1160 |
|
if ((mkdir(bmpcache_dir, S_IRWXU) == -1) && errno != EEXIST) |
1161 |
|
{ |
1162 |
|
perror(bmpcache_dir); |
1163 |
|
return False; |
1164 |
|
} |
1165 |
|
|
1166 |
|
return True; |
1167 |
|
} |
1168 |
|
|
1169 |
|
/* open a file in the .rdesktop directory */ |
1170 |
|
int |
1171 |
|
rd_open_file(char *filename) |
1172 |
|
{ |
1173 |
|
char *home; |
1174 |
|
char fn[256]; |
1175 |
|
int fd; |
1176 |
|
|
1177 |
|
home = getenv("HOME"); |
1178 |
|
if (home == NULL) |
1179 |
|
return -1; |
1180 |
|
sprintf(fn, "%s/.rdesktop/%s", home, filename); |
1181 |
|
fd = open(fn, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); |
1182 |
|
if (fd == -1) |
1183 |
|
perror(fn); |
1184 |
|
return fd; |
1185 |
|
} |
1186 |
|
|
1187 |
|
/* close file */ |
1188 |
|
void |
1189 |
|
rd_close_file(int fd) |
1190 |
|
{ |
1191 |
|
close(fd); |
1192 |
|
} |
1193 |
|
|
1194 |
|
/* read from file*/ |
1195 |
|
int |
1196 |
|
rd_read_file(int fd, void *ptr, int len) |
1197 |
|
{ |
1198 |
|
return read(fd, ptr, len); |
1199 |
|
} |
1200 |
|
|
1201 |
|
/* write to file */ |
1202 |
|
int |
1203 |
|
rd_write_file(int fd, void *ptr, int len) |
1204 |
|
{ |
1205 |
|
return write(fd, ptr, len); |
1206 |
|
} |
1207 |
|
|
1208 |
|
/* move file pointer */ |
1209 |
|
int |
1210 |
|
rd_lseek_file(int fd, int offset) |
1211 |
|
{ |
1212 |
|
return lseek(fd, offset, SEEK_SET); |
1213 |
|
} |
1214 |
|
|
1215 |
|
/* do a write lock on a file */ |
1216 |
|
BOOL |
1217 |
|
rd_lock_file(int fd, int start, int len) |
1218 |
|
{ |
1219 |
|
struct flock lock; |
1220 |
|
|
1221 |
|
lock.l_type = F_WRLCK; |
1222 |
|
lock.l_whence = SEEK_SET; |
1223 |
|
lock.l_start = start; |
1224 |
|
lock.l_len = len; |
1225 |
|
if (fcntl(fd, F_SETLK, &lock) == -1) |
1226 |
|
return False; |
1227 |
|
return True; |
1228 |
|
} |