48#include <openssl/md5.h>
59 fprintf(
stderr,
"rdesktop: A Remote Desktop Protocol client.\n");
61 fprintf(
stderr,
"See http://www.rdesktop.org/ for more information.\n\n");
74 fprintf(
stderr,
" -k: keyboard layout on server (en-us, de, sv, etc.)\n");
82 fprintf(
stderr,
" -B: use BackingStore of X-server (if available)\n");
84 fprintf(
stderr,
" -E: disable encryption from client to server\n");
89 fprintf(
stderr,
" -S: caption button size (single application mode)\n");
92 fprintf(
stderr,
" -X: embed into another window with a given id.\n");
95 fprintf(
stderr,
" -x: RDP5 experience (m[odem 28.8], b[roadband], l[an] or hex nr.)\n");
97 fprintf(
stderr,
" -r: enable specified device redirection (this flag can be repeated)\n");
99 " '-r comport:COM1=/dev/ttyS0': enable serial redirection of /dev/ttyS0 to COM1\n");
102 " '-r disk:floppy=/mnt/floppy': enable redirection of /mnt/floppy to 'floppy' share\n");
103 fprintf(
stderr,
" or 'floppy=/mnt/floppy,cdrom=/mnt/cdrom'\n");
104 fprintf(
stderr,
" '-r clientname=<client name>': Set the client name displayed\n");
107 " '-r lptport:LPT1=/dev/lp0': enable parallel redirection of /dev/lp0 to LPT1\n");
109 fprintf(
stderr,
" '-r printer:mydeskjet': enable printer redirection\n");
111 " or mydeskjet=\"HP LaserJet IIIP\" to enter server driver as well\n");
112 fprintf(
stderr,
" '-r sound:[local|off|remote]': enable sound redirection\n");
115 " '-r clipboard:[off|PRIMARYCLIPBOARD|CLIPBOARD]': enable clipboard\n");
118 " 'PRIMARYCLIPBOARD' looks at both PRIMARY and CLIPBOARD\n");
134 text =
"No information available";
138 text =
"Server initiated disconnect";
142 text =
"Server initiated logoff";
146 text =
"Server idle timeout reached";
150 text =
"Server logon timeout reached";
154 text =
"The session was replaced";
158 text =
"The server is out of memory";
162 text =
"The server denied the connection";
166 text =
"The server denied the connection for security reason";
170 text =
"Internal licensing error";
174 text =
"No license server available";
178 text =
"No valid license available";
182 text =
"Invalid licensing message";
186 text =
"Hardware id doesn't match software license";
190 text =
"Client license error";
194 text =
"Network error during licensing protocol";
198 text =
"Licensing protocol was not completed";
202 text =
"Incorrect client license enryption";
206 text =
"Can't upgrade license";
210 text =
"The server is not licensed to accept remote connections";
216 text =
"Internal protocol error";
220 text =
"Unknown reason";
243 tios.c_lflag &= ~ECHO;
260 tios.c_lflag |=
ECHO;
282 if (addr_colons >= 2)
288 if (*(
p + 1) ==
':' && *(
p + 2) !=
'\0')
321 char fullhostname[64];
332 int username_option = 0;
341 This->keylayout = 0x409;
342 This->keyboard_type = 0x4;
343 This->keyboard_subtype = 0x0;
344 This->keyboard_functionkeys = 0xc;
351 This->server_depth = -1;
355 This->bitmap_cache_persist_enable =
False;
360 This->polygon_ellipse_orders =
True;
399 prompt_password =
False;
403 This->num_devices = 0;
412 VNCOPT "Au:L:d:s:c:p:n:k:g:fbBeEmzCDKS:T:NX:a:x:Pr:045h?")) != -1)
419 if (
This->rfb_port < 100)
420 This->rfb_port += 5900;
425 if (
This->defer_time < 0)
426 This->defer_time = 0;
443 error(
"iconv support not available\n");
462 prompt_password =
True;
484 geometry_option =
True;
493 if (
This->width <= 0)
495 error(
"invalid geometry\n");
502 if (
This->height <= 0)
504 error(
"invalid geometry\n");
514 if (*
p ==
'+' || *
p ==
'-')
516 This->pos |= (*
p ==
'-') ? 2 : 1;
520 if (*
p ==
'+' || *
p ==
'-')
522 This->pos |= (*
p ==
'-') ? 4 : 1;
565 This->win_button_size = 18;
573 error(
"invalid button size\n");
593 if (
This->server_depth != 8 &&
594 This->server_depth != 16 &&
595 This->server_depth != 15 &&
This->server_depth != 24)
597 error(
"Invalid server colour depth.\n");
603 DEBUG((
"rdp compression enabled\n"));
610 This->rdp5_performanceflags =
629 This->bitmap_cache_persist_enable =
True;
650 warning(
"Not compiled with sound support\n");
657 warning(
"Not compiled with sound support\n");
668 warning(
"Not compiled with sound support\n");
716 warning(
"Unknown -r argument\n\n\tPossible arguments are: comport, disk, lptport, printer, sound, clipboard\n");
749 if (
This->seamless_rdp)
751 if (
This->win_button_size)
753 error(
"You cannot use -S and -A at the same time\n");
756 This->rdp5_performanceflags &= ~RDP5_NO_FULLWINDOWDRAG;
759 error(
"You cannot use -g and -A at the same time\n");
762 if (
This->fullscreen)
764 error(
"You cannot use -f and -A at the same time\n");
767 if (
This->hide_decorations)
769 error(
"You cannot use -D and -A at the same time\n");
774 error(
"You cannot use -X and -A at the same time\n");
779 error(
"You cannot use -4 and -A at the same time\n");
786 if (!username_option)
789 if ((pw ==
NULL) || (pw->pw_name ==
NULL))
791 error(
"could not determine username, use -u\n");
799 if (
This->codepage[0] == 0)
812 if (
This->hostname[0] == 0)
814 if (
gethostname(fullhostname,
sizeof(fullhostname)) == -1)
816 error(
"could not determine local hostname, use -n\n");
827 if (
This->keymapname[0] == 0)
845 if (
This->title[0] == 0)
860 if (
This->rdpsnd_enabled)
864 if (
This->lspci_enabled)
869 while (run_count < 2 && continue_connect)
882 if (!
This->packet_encryption)
886 DEBUG((
"Connection successful.\n"));
891 continue_connect =
False;
893 if (continue_connect)
896 DEBUG((
"Disconnecting...\n"));
899 if ((
This->redirect ==
True) && (run_count == 0))
914 continue_connect =
False;
966 memcpy(
addr.sun_path, EGD_SOCKET,
sizeof(EGD_SOCKET));
1012 if (generate_random_egd(
random))
1018 r[0] = (
getpid()) | (getppid() << 16);
1128 unsigned char *
line =
p;
1138 for (
i = 0;
i < thisline;
i++)
1144 for (
i = 0;
i < thisline;
i++)
1181 if (*
src == (
char) 0x00)
1186 while ((nextval =
strchr(
p, needle)))
1190 if (*mvp ==
'\\' && (mvp >
src))
1193 while (*(mvp + 1) != (
char) 0x00)
1212 *nextval = (
char) 0x00;
1227 if ((*
p >=
'a') && (*
p <=
'z'))
1259 buflen = restlen + inputlen + 1;
1269 char *newline =
strchr(
p,
'\n');
1290 restlen =
buf + buflen -
p;
1291 *rest = (
char *)
xmalloc(restlen);
1316 if ((
child = fork()) < 0)
1334 perror(
"Error executing child");
1353#define LTOA_BUFSIZE (sizeof(long) * 8 + 1)
1362 register int divrem;
1364 if (base < 36 || 2 >
base)
1379 *--
tail = (divrem <= 9) ? divrem +
'0' : divrem +
'a' - 10;
1474 char bmpcache_dir[256];
1481 sprintf(bmpcache_dir,
"%s/%s",
home,
".rdesktop");
1489 sprintf(bmpcache_dir,
"%s/%s",
home,
".rdesktop/cache");
1552 lock.l_type = F_WRLCK;
1556 if (fcntl(
fd, F_SETLK, &
lock) == -1)
char * strcat(char *DstString, const char *SrcString)
int strcmp(const char *String1, const char *String2)
char * strncat(char *DstString, const char *SrcString, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
char * strcpy(char *DstString, const char *SrcString)
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
char * strchr(const char *String, int ch)
#define gettimeofday(tv, tz)
struct outqueuenode * tail
struct outqueuenode * head
void cache_save_state(void)
#define exDiscReasonLicenseInternal
#define exDiscReasonLicenseNoRemoteConnections
#define exDiscReasonLicenseNoLicenseServer
#define exDiscReasonNoInfo
#define exDiscReasonOutOfMemory
#define exDiscReasonServerLogonTimeout
#define exDiscReasonLicenseErrClientLicense
#define exDiscReasonServerIdleTimeout
#define exDiscReasonAPIInitiatedDisconnect
#define exDiscReasonLicenseErrClientMsg
#define exDiscReasonLicenseClientEndedProtocol
#define exDiscReasonLicenseCantUpgradeLicense
#define exDiscReasonServerDeniedConnectionFips
#define exDiscReasonLicenseErrClientEncryption
#define exDiscReasonReplacedByOtherConnection
#define exDiscReasonLicenseCantFinishProtocol
#define exDiscReasonAPIInitiatedLogoff
#define exDiscReasonServerDeniedConnection
#define exDiscReasonLicenseNoLicense
#define exDiscReasonLicenseHwidDoesntMatchLicense
int serial_enum_devices(uint32 *id, char *optarg)
void rdp_disconnect(void)
void ui_destroy_window(void)
RD_BOOL rdp_connect(char *server, uint32 flags, char *domain, char *password, char *command, char *directory, RD_BOOL reconnect)
RD_BOOL ui_create_window(void)
RD_BOOL xkeymap_from_locale(const char *locale)
int disk_enum_devices(uint32 *id, char *optarg)
int parallel_enum_devices(uint32 *id, char *optarg)
int printer_enum_devices(uint32 *id, char *optarg)
void rdp_reset_state(void)
void cliprdr_set_mode(const char *optarg)
void rdp_main_loop(RD_BOOL *deactivated, uint32 *ext_disc_reason)
RD_BOOL rdpsnd_init(char *optarg)
#define STRNCPY(dst, src, n)
RD_BOOL(* str_handle_lines_t)(const char *line, void *data)
int getopt(int nargc, char *const *nargv, const char *ostr)
void shell(int argc, const char *argv[])
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
INT WSAAPI gethostname(OUT char FAR *name, IN INT namelen)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLdouble GLdouble GLdouble r
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLenum const GLvoid * addr
GLenum GLenum GLenum input
GLsizeiptr const GLvoid GLenum usage
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
_Check_return_ long __cdecl strtol(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
#define memcpy(s1, s2, n)
#define RDP5_NO_MENUANIMATIONS
#define RDP_LOGON_COMPRESSION
#define RDP_LOGON_LEAVE_AUDIO
#define RDP5_DISABLE_NOTHING
#define RDP5_NO_FULLWINDOWDRAG
#define RDP5_NO_WALLPAPER
#define RDP_LOGON_COMPRESSION2
BOOL rdp_reconnect(RDPCLIENT *This, char *server, uint32 flags, wchar_t *username, wchar_t *domain, wchar_t *password, wchar_t *command, wchar_t *directory, wchar_t *hostname, char *cookie)
#define sprintf(buf, format,...)
static const struct encodedFiletime times[]
static void rdesktop_reset_state(RDPCLIENT *This)
BOOL rd_pstcache_mkdir(void)
int load_licence(RDPCLIENT *This, unsigned char **data)
char * l_to_a(long N, int base)
BOOL str_handle_lines(RDPCLIENT *This, const char *input, char **rest, str_handle_lines_t linehandler, void *data)
int rd_write_file(int fd, void *ptr, int len)
BOOL rd_lock_file(int fd, int start, int len)
void save_licence(RDPCLIENT *This, unsigned char *data, int length)
char * xstrdup(const char *s)
char * next_arg(char *src, char needle)
int rd_read_file(int fd, void *ptr, int len)
void * xrealloc(void *oldmem, int size)
void rd_close_file(int fd)
static void print_disconnect_reason(uint16 reason)
void unimpl(char *format,...)
BOOL str_startswith(const char *s, const char *prefix)
void hexdump(unsigned char *p, unsigned int len)
BOOL subprocess(RDPCLIENT *This, char *const argv[], str_handle_lines_t linehandler, void *data)
void toupper_str(char *p)
int rd_lseek_file(int fd, int offset)
int rd_open_file(char *filename)
void generate_random(uint8 *random)
static BOOL read_password(char *password, int size)
static void parse_server_and_port(RDPCLIENT *This, char *server)
_Check_return_ int __cdecl rename(_In_z_ const char *_OldFilename, _In_z_ const char *_NewFilename)
_Check_return_ _CRTIMP int __cdecl dup2(_In_ int _FileHandleSrc, _In_ int _FileHandleDst)
_CRTIMP intptr_t __cdecl execvp(_In_z_ const char *_Filename, _In_z_ char *const _ArgList[])
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
void MD5_Init(MD5_CTX *ctx)
void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
void MD5_Final(unsigned char *result, MD5_CTX *ctx)
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
void rdp2vnc_connect(char *server, uint32 flags, char *domain, char *password, char *shell, char *directory)
static rfbScreenInfoPtr server
static GLenum _GLUfuncptr fn
void int int ULONGLONG int va_list * ap