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, " -x: RDP5 experience (m[odem 28.8], b[roadband], l[an] or hex nr.)\n"); |
126 |
" -x: RDP5 experience (m[odem 28.8], b[roadband], l[an] or hex number)\n"); |
fprintf(stderr, " -P: use persistent bitmap caching\n"); |
127 |
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"); |
128 |
fprintf(stderr, |
fprintf(stderr, |
129 |
" '-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"); |
362 |
#define VNCOPT |
#define VNCOPT |
363 |
#endif |
#endif |
364 |
|
|
365 |
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, |
366 |
|
VNCOPT "u:d:s:c:p:n:k:g:fbBeEmCDKS:T:NX:a:x:Pr:045h?")) != -1) |
367 |
{ |
{ |
368 |
switch (c) |
switch (c) |
369 |
{ |
{ |
546 |
} |
} |
547 |
break; |
break; |
548 |
|
|
549 |
|
case 'P': |
550 |
|
g_bitmap_cache_persist_enable = True; |
551 |
|
break; |
552 |
|
|
553 |
case 'r': |
case 'r': |
554 |
|
|
555 |
if (strncmp("sound", optarg, 5) == 0) |
if (strncmp("sound", optarg, 5) == 0) |
568 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
569 |
g_rdpsnd = True; |
g_rdpsnd = True; |
570 |
#else |
#else |
571 |
warning("Not compiled with sound support"); |
warning("Not compiled with sound support\n"); |
572 |
#endif |
#endif |
573 |
|
|
574 |
if (strncmp("off", optarg, 3) == 0) |
if (strncmp("off", optarg, 3) == 0) |
575 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
576 |
g_rdpsnd = False; |
g_rdpsnd = False; |
577 |
#else |
#else |
578 |
warning("Not compiled with sound support"); |
warning("Not compiled with sound support\n"); |
579 |
#endif |
#endif |
580 |
|
|
581 |
optarg = p; |
optarg = p; |
586 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
587 |
g_rdpsnd = True; |
g_rdpsnd = True; |
588 |
#else |
#else |
589 |
warning("Not compiled with sound support"); |
warning("Not compiled with sound support\n"); |
590 |
#endif |
#endif |
591 |
} |
} |
592 |
} |
} |
717 |
|
|
718 |
DEBUG(("Disconnecting...\n")); |
DEBUG(("Disconnecting...\n")); |
719 |
rdp_disconnect(); |
rdp_disconnect(); |
720 |
|
cache_save_state(); |
721 |
ui_deinit(); |
ui_deinit(); |
722 |
|
|
723 |
if (ext_disc_reason >= 2) |
if (ext_disc_reason >= 2) |
1125 |
xfree(tmppath); |
xfree(tmppath); |
1126 |
xfree(path); |
xfree(path); |
1127 |
} |
} |
1128 |
|
|
1129 |
|
/* Create the bitmap cache directory */ |
1130 |
|
BOOL |
1131 |
|
rd_pstcache_mkdir(void) |
1132 |
|
{ |
1133 |
|
char *home; |
1134 |
|
char bmpcache_dir[256]; |
1135 |
|
|
1136 |
|
home = getenv("HOME"); |
1137 |
|
|
1138 |
|
if (home == NULL) |
1139 |
|
return False; |
1140 |
|
|
1141 |
|
sprintf(bmpcache_dir, "%s/%s", home, ".rdesktop"); |
1142 |
|
|
1143 |
|
if ((mkdir(bmpcache_dir, S_IRWXU) == -1) && errno != EEXIST) |
1144 |
|
{ |
1145 |
|
perror(bmpcache_dir); |
1146 |
|
return False; |
1147 |
|
} |
1148 |
|
|
1149 |
|
sprintf(bmpcache_dir, "%s/%s", home, ".rdesktop/cache"); |
1150 |
|
|
1151 |
|
if ((mkdir(bmpcache_dir, S_IRWXU) == -1) && errno != EEXIST) |
1152 |
|
{ |
1153 |
|
perror(bmpcache_dir); |
1154 |
|
return False; |
1155 |
|
} |
1156 |
|
|
1157 |
|
return True; |
1158 |
|
} |
1159 |
|
|
1160 |
|
/* open a file in the .rdesktop directory */ |
1161 |
|
int |
1162 |
|
rd_open_file(char *filename) |
1163 |
|
{ |
1164 |
|
char *home; |
1165 |
|
char fn[256]; |
1166 |
|
int fd; |
1167 |
|
|
1168 |
|
home = getenv("HOME"); |
1169 |
|
if (home == NULL) |
1170 |
|
return -1; |
1171 |
|
sprintf(fn, "%s/.rdesktop/%s", home, filename); |
1172 |
|
fd = open(fn, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); |
1173 |
|
if (fd == -1) |
1174 |
|
perror(fn); |
1175 |
|
return fd; |
1176 |
|
} |
1177 |
|
|
1178 |
|
/* close file */ |
1179 |
|
void |
1180 |
|
rd_close_file(int fd) |
1181 |
|
{ |
1182 |
|
close(fd); |
1183 |
|
} |
1184 |
|
|
1185 |
|
/* read from file*/ |
1186 |
|
int |
1187 |
|
rd_read_file(int fd, void *ptr, int len) |
1188 |
|
{ |
1189 |
|
return read(fd, ptr, len); |
1190 |
|
} |
1191 |
|
|
1192 |
|
/* write to file */ |
1193 |
|
int |
1194 |
|
rd_write_file(int fd, void *ptr, int len) |
1195 |
|
{ |
1196 |
|
return write(fd, ptr, len); |
1197 |
|
} |
1198 |
|
|
1199 |
|
/* move file pointer */ |
1200 |
|
int |
1201 |
|
rd_lseek_file(int fd, int offset) |
1202 |
|
{ |
1203 |
|
return lseek(fd, offset, SEEK_SET); |
1204 |
|
} |
1205 |
|
|
1206 |
|
/* do a write lock on a file */ |
1207 |
|
BOOL |
1208 |
|
rd_lock_file(int fd, int start, int len) |
1209 |
|
{ |
1210 |
|
struct flock lock; |
1211 |
|
|
1212 |
|
lock.l_type = F_WRLCK; |
1213 |
|
lock.l_whence = SEEK_SET; |
1214 |
|
lock.l_start = start; |
1215 |
|
lock.l_len = len; |
1216 |
|
if (fcntl(fd, F_SETLK, &lock) == -1) |
1217 |
|
return False; |
1218 |
|
return True; |
1219 |
|
} |