--- sourceforge.net/trunk/rdesktop/rdesktop.c 2003/01/28 12:27:28 297 +++ sourceforge.net/trunk/rdesktop/rdesktop.c 2003/04/16 08:19:15 365 @@ -1,7 +1,7 @@ -/* +/* -*- c-basic-offset: 8 -*- rdesktop: A Remote Desktop Protocol client. Entrypoint and utility functions - Copyright (C) Matthew Chapman 1999-2002 + Copyright (C) Matthew Chapman 1999-2003 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,12 +21,12 @@ #include /* va_list va_start va_end */ #include /* read close getuid getgid getpid getppid gethostname */ #include /* open */ -#include /* save licence uses it. */ #include /* getpwuid */ #include /* tcgetattr tcsetattr */ #include /* stat */ #include /* gettimeofday */ #include /* times */ +#include #include "rdesktop.h" #ifdef EGD_SOCKET @@ -45,10 +45,12 @@ char hostname[16]; char keymapname[16]; int keylayout = 0x409; /* Defaults to US keyboard layout */ -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 be fetched from _NET_WORKAREA */ int height = 600; int tcp_port_rdp = TCP_PORT_RDP; +int server_bpp = 8; +int win_button_size = 0; /* If zero, disable single app mode */ BOOL bitmap_compression = True; BOOL sendmotion = True; BOOL orders = True; @@ -57,20 +59,33 @@ BOOL fullscreen = False; BOOL grab_keyboard = True; BOOL hide_decorations = False; +BOOL use_rdp5 = False; extern BOOL owncolmap; +#ifdef RDP2VNC +extern int rfb_port; +extern int defer_time; +void +rdp2vnc_connect(char *server, uint32 flags, char *domain, char *password, + char *shell, char *directory); +#endif /* Display usage information */ static void usage(char *program) { fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n"); - fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2002 Matt Chapman.\n"); + fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2003 Matt Chapman.\n"); fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n"); fprintf(stderr, "Usage: %s [options] server[:port]\n", program); +#ifdef RDP2VNC + fprintf(stderr, " -V: vnc port\n"); + fprintf(stderr, " -E: defer time (ms)\n"); +#endif fprintf(stderr, " -u: user name\n"); fprintf(stderr, " -d: domain\n"); fprintf(stderr, " -s: shell\n"); + fprintf(stderr, " -S: caption button size (single application mode)\n"); fprintf(stderr, " -c: working directory\n"); fprintf(stderr, " -p: password (- to prompt)\n"); fprintf(stderr, " -n: client hostname\n"); @@ -84,6 +99,8 @@ fprintf(stderr, " -K: keep window manager key bindings\n"); fprintf(stderr, " -T: window title\n"); fprintf(stderr, " -D: hide window manager decorations\n"); + fprintf(stderr, " -a: server bpp\n"); + fprintf(stderr, " -5: Use RDP5 (EXPERIMENTAL!)\n"); } static BOOL @@ -144,10 +161,30 @@ domain[0] = password[0] = shell[0] = directory[0] = 0; strcpy(keymapname, "en-us"); - while ((c = getopt(argc, argv, "u:d:s:c:p:n:k:g:fbemCKT:Dh?")) != -1) +#ifdef RDP2VNC +#define VNCOPT "V:E:" +#else +#define VNCOPT +#endif + + while ((c = getopt(argc, argv, VNCOPT "u:d:s:S:c:p:n:k:g:a:fbemCKT:Dh?54")) != -1) { switch (c) { +#ifdef RDP2VNC + case 'V': + rfb_port = strtol(optarg, NULL, 10); + if (rfb_port < 100) + rfb_port += 5900; + break; + + case 'E': + defer_time = strtol(optarg, NULL, 10); + if (defer_time < 0) + defer_time = 0; + break; +#endif + case 'u': STRNCPY(username, optarg, sizeof(username)); username_option = 1; @@ -161,6 +198,23 @@ STRNCPY(shell, optarg, sizeof(shell)); break; + case 'S': + if (!strcmp(optarg, "standard")) + { + win_button_size = 18; + break; + } + + win_button_size = strtol(optarg, &p, 10); + + if (*p) + { + error("invalid button size\n"); + return 1; + } + + break; + case 'c': STRNCPY(directory, optarg, sizeof(directory)); break; @@ -239,6 +293,19 @@ hide_decorations = True; break; + case 'a': + server_bpp = strtol(optarg, NULL, 10); + if (server_bpp != 8 && server_bpp != 16 && server_bpp != 15 + && server_bpp != 24) + { + error("invalid server bpp\n"); + return 1; + } + break; + + case '5': + use_rdp5 = True; + break; case 'h': case '?': default: @@ -297,6 +364,10 @@ strncat(title, server, sizeof(title) - sizeof("rdesktop - ")); } +#ifdef RDP2VNC + rdp2vnc_connect(server, flags, domain, password, shell, directory); +#else + if (!ui_init()) return 1; @@ -315,6 +386,9 @@ DEBUG(("Disconnecting...\n")); rdp_disconnect(); ui_deinit(); + +#endif + return 0; } @@ -503,7 +577,7 @@ } } -#ifdef SAVE_LICENCE + int load_licence(unsigned char **data) { @@ -548,12 +622,12 @@ s_ptr = &s; s_ptr->p = data; /* Skip first two bytes */ - in_uint16(s_ptr, len); + in_uint16_le(s_ptr, len); /* Skip three strings */ for (i = 0; i < 3; i++) { - in_uint32(s_ptr, len); + in_uint32_le(s_ptr, len); s_ptr->p += len; /* Make sure that we won't be past the end of data after * reading the next length value @@ -561,16 +635,17 @@ if ((s_ptr->p) + 4 > data + length) { printf("Error in parsing licence key.\n"); - printf("Strings %d end value %x > supplied length (%x)\n", - i, s_ptr->p, data + length); + printf("Strings %d end value %x > supplied length (%x)\n", i, + (unsigned int) s_ptr->p, (unsigned int) data + length); return; } } - in_uint32(s_ptr, len); + in_uint32_le(s_ptr, len); if (s_ptr->p + len > data + length) { printf("Error in parsing licence key.\n"); - printf("End of licence %x > supplied length (%x)\n", s_ptr->p + len, data + length); + printf("End of licence %x > supplied length (%x)\n", + (unsigned int) s_ptr->p + len, (unsigned int) data + length); return; } @@ -606,7 +681,7 @@ fnamewrk = xmalloc(strlen(fname) + 12); for (y = 0;; y++) { - sprintf(fnamewrk, "%s.%lu", fname, y); + sprintf(fnamewrk, "%s.%lu", fname, (long unsigned int) y); fnwrkfd = open(fnamewrk, O_WRONLY | O_CREAT | O_EXCL, 0600); if (fnwrkfd == -1) { @@ -659,4 +734,3 @@ } } -#endif