/[rdesktop]/sourceforge.net/trunk/rdesktop/rdesktop.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/rdesktop.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 435 by astrand, Wed Jul 9 09:18:20 2003 UTC revision 479 by astrand, Mon Oct 6 09:37:24 2003 UTC
# Line 40  Line 40 
40  #include "crypto/md5.h"  #include "crypto/md5.h"
41  #endif  #endif
42    
43  char title[32] = "";  char g_title[64] = "";
44  char username[16];  char g_username[64];
45  char hostname[16];  char hostname[16];
46  char keymapname[16];  char keymapname[16];
47  int keylayout = 0x409;          /* Defaults to US keyboard layout */  int keylayout = 0x409;          /* Defaults to US keyboard layout */
48  int width = 800;                /* If width or height are reset to zero, the geometry will  int g_width = 800;              /* If width or height are reset to zero, the geometry will
49                                     be fetched from _NET_WORKAREA */                                     be fetched from _NET_WORKAREA */
50  int height = 600;  int g_height = 600;
51  int tcp_port_rdp = TCP_PORT_RDP;  int tcp_port_rdp = TCP_PORT_RDP;
52  int server_bpp = 8;  int g_server_bpp = 8;
53  int win_button_size = 0;        /* If zero, disable single app mode */  int g_win_button_size = 0;      /* If zero, disable single app mode */
54  BOOL bitmap_compression = True;  BOOL g_bitmap_compression = True;
55  BOOL sendmotion = True;  BOOL g_sendmotion = True;
56  BOOL orders = True;  BOOL g_orders = True;
57  BOOL encryption = True;  BOOL g_encryption = True;
58  BOOL packet_encryption = True;  BOOL packet_encryption = True;
59  BOOL desktop_save = True;  BOOL g_desktop_save = True;
60  BOOL fullscreen = False;  BOOL g_fullscreen = False;
61  BOOL grab_keyboard = True;  BOOL g_grab_keyboard = True;
62  BOOL hide_decorations = False;  BOOL g_hide_decorations = False;
63  BOOL use_rdp5 = False;  BOOL g_use_rdp5 = True;
64  extern BOOL owncolmap;  extern BOOL g_owncolmap;
65    
66  #ifdef RDP2VNC  #ifdef RDP2VNC
67  extern int rfb_port;  extern int rfb_port;
# Line 81  usage(char *program) Line 81  usage(char *program)
81          fprintf(stderr, "Usage: %s [options] server[:port]\n", program);          fprintf(stderr, "Usage: %s [options] server[:port]\n", program);
82  #ifdef RDP2VNC  #ifdef RDP2VNC
83          fprintf(stderr, "   -V: vnc port\n");          fprintf(stderr, "   -V: vnc port\n");
84          fprintf(stderr, "   -E: defer time (ms)\n");          fprintf(stderr, "   -Q: defer time (ms)\n");
85  #endif  #endif
86          fprintf(stderr, "   -u: user name\n");          fprintf(stderr, "   -u: user name\n");
87          fprintf(stderr, "   -d: domain\n");          fprintf(stderr, "   -d: domain\n");
# Line 95  usage(char *program) Line 95  usage(char *program)
95          fprintf(stderr, "   -f: full-screen mode\n");          fprintf(stderr, "   -f: full-screen mode\n");
96          fprintf(stderr, "   -b: force bitmap updates\n");          fprintf(stderr, "   -b: force bitmap updates\n");
97          fprintf(stderr, "   -e: disable encryption (French TS)\n");          fprintf(stderr, "   -e: disable encryption (French TS)\n");
98          fprintf(stderr, "   -E: disable encryption of everything but the logon packet\n");          fprintf(stderr, "   -E: disable encryption from client to server\n");
99          fprintf(stderr, "   -m: do not send motion events\n");          fprintf(stderr, "   -m: do not send motion events\n");
100          fprintf(stderr, "   -C: use private colour map\n");          fprintf(stderr, "   -C: use private colour map\n");
101          fprintf(stderr, "   -K: keep window manager key bindings\n");          fprintf(stderr, "   -K: keep window manager key bindings\n");
102          fprintf(stderr, "   -T: window title\n");          fprintf(stderr, "   -T: window title\n");
103          fprintf(stderr, "   -D: hide window manager decorations\n");          fprintf(stderr, "   -D: hide window manager decorations\n");
104          fprintf(stderr, "   -a: server bpp\n");          fprintf(stderr, "   -a: server bpp\n");
105          fprintf(stderr, "   -5: Use RDP5 (EXPERIMENTAL!)\n");          fprintf(stderr, "   -4: Use RDP version 4\n");
106            fprintf(stderr, "   -5: Use RDP version 5 (default)\n");
107  }  }
108    
109  static BOOL  static BOOL
# Line 141  read_password(char *password, int size) Line 142  read_password(char *password, int size)
142          return ret;          return ret;
143  }  }
144    
145    static void
146    parse_server_and_port(char *server)
147    {
148            char *p;
149    #ifdef IPv6
150            int addr_colons;
151    #endif
152    
153    #ifdef IPv6
154            p = server;
155            addr_colons = 0;
156            while (*p)
157                    if (*p++ == ':')
158                            addr_colons++;
159            if (addr_colons >= 2)
160            {
161                    /* numeric IPv6 style address format - [1:2:3::4]:port */
162                    p = strchr(server, ']');
163                    if (*server == '[' && p != NULL)
164                    {
165                            if (*(p + 1) == ':' && *(p + 2) != '\0')
166                                    tcp_port_rdp = strtol(p + 2, NULL, 10);
167                            /* remove the port number and brackets from the address */
168                            *p = '\0';
169                            strncpy(server, server + 1, strlen(server));
170                    }
171            }
172            else
173            {
174                    /* dns name or IPv4 style address format - server.example.com:port or 1.2.3.4:port */
175                    p = strchr(server, ':');
176                    if (p != NULL)
177                    {
178                            tcp_port_rdp = strtol(p + 1, NULL, 10);
179                            *p = 0;
180                    }
181            }
182    #else /* no IPv6 support */
183            p = strchr(server, ':');
184            if (p != NULL)
185            {
186                    tcp_port_rdp = strtol(p + 1, NULL, 10);
187                    *p = 0;
188            }
189    #endif /* IPv6 */
190    
191    }
192    
193  /* Client program */  /* Client program */
194  int  int
195  main(int argc, char *argv[])  main(int argc, char *argv[])
# Line 148  main(int argc, char *argv[]) Line 197  main(int argc, char *argv[])
197          char server[64];          char server[64];
198          char fullhostname[64];          char fullhostname[64];
199          char domain[16];          char domain[16];
200          char password[16];          char password[64];
201          char shell[128];          char shell[128];
202          char directory[32];          char directory[32];
203          BOOL prompt_password, rdp_retval = False;          BOOL prompt_password, rdp_retval = False;
# Line 164  main(int argc, char *argv[]) Line 213  main(int argc, char *argv[])
213          strcpy(keymapname, "en-us");          strcpy(keymapname, "en-us");
214    
215  #ifdef RDP2VNC  #ifdef RDP2VNC
216  #define VNCOPT "V:E:"  #define VNCOPT "V:Q:"
217  #else  #else
218  #define VNCOPT  #define VNCOPT
219  #endif  #endif
# Line 180  main(int argc, char *argv[]) Line 229  main(int argc, char *argv[])
229                                          rfb_port += 5900;                                          rfb_port += 5900;
230                                  break;                                  break;
231    
232                          case 'E':                          case 'Q':
233                                  defer_time = strtol(optarg, NULL, 10);                                  defer_time = strtol(optarg, NULL, 10);
234                                  if (defer_time < 0)                                  if (defer_time < 0)
235                                          defer_time = 0;                                          defer_time = 0;
# Line 188  main(int argc, char *argv[]) Line 237  main(int argc, char *argv[])
237  #endif  #endif
238    
239                          case 'u':                          case 'u':
240                                  STRNCPY(username, optarg, sizeof(username));                                  STRNCPY(g_username, optarg, sizeof(g_username));
241                                  username_option = 1;                                  username_option = 1;
242                                  break;                                  break;
243    
# Line 203  main(int argc, char *argv[]) Line 252  main(int argc, char *argv[])
252                          case 'S':                          case 'S':
253                                  if (!strcmp(optarg, "standard"))                                  if (!strcmp(optarg, "standard"))
254                                  {                                  {
255                                          win_button_size = 18;                                          g_win_button_size = 18;
256                                          break;                                          break;
257                                  }                                  }
258    
259                                  win_button_size = strtol(optarg, &p, 10);                                  g_win_button_size = strtol(optarg, &p, 10);
260    
261                                  if (*p)                                  if (*p)
262                                  {                                  {
# Line 248  main(int argc, char *argv[]) Line 297  main(int argc, char *argv[])
297                          case 'g':                          case 'g':
298                                  if (!strcmp(optarg, "workarea"))                                  if (!strcmp(optarg, "workarea"))
299                                  {                                  {
300                                          width = height = 0;                                          g_width = g_height = 0;
301                                          break;                                          break;
302                                  }                                  }
303    
304                                  width = strtol(optarg, &p, 10);                                  g_width = strtol(optarg, &p, 10);
305                                  if (*p == 'x')                                  if (*p == 'x')
306                                          height = strtol(p + 1, NULL, 10);                                          g_height = strtol(p + 1, NULL, 10);
307    
308                                  if ((width == 0) || (height == 0))                                  if ((g_width == 0) || (g_height == 0))
309                                  {                                  {
310                                          error("invalid geometry\n");                                          error("invalid geometry\n");
311                                          return 1;                                          return 1;
# Line 264  main(int argc, char *argv[]) Line 313  main(int argc, char *argv[])
313                                  break;                                  break;
314    
315                          case 'f':                          case 'f':
316                                  fullscreen = True;                                  g_fullscreen = True;
317                                  break;                                  break;
318    
319                          case 'b':                          case 'b':
320                                  orders = False;                                  g_orders = False;
321                                  break;                                  break;
322    
323                          case 'e':                          case 'e':
324                                  encryption = False;                                  g_encryption = False;
325                                  break;                                  break;
326                          case 'E':                          case 'E':
327                                  packet_encryption = False;                                  packet_encryption = False;
328                                  break;                                  break;
329                          case 'm':                          case 'm':
330                                  sendmotion = False;                                  g_sendmotion = False;
331                                  break;                                  break;
332    
333                          case 'C':                          case 'C':
334                                  owncolmap = True;                                  g_owncolmap = True;
335                                  break;                                  break;
336    
337                          case 'K':                          case 'K':
338                                  grab_keyboard = False;                                  g_grab_keyboard = False;
339                                  break;                                  break;
340    
341                          case 'T':                          case 'T':
342                                  STRNCPY(title, optarg, sizeof(title));                                  STRNCPY(g_title, optarg, sizeof(g_title));
343                                  break;                                  break;
344    
345                          case 'D':                          case 'D':
346                                  hide_decorations = True;                                  g_hide_decorations = True;
347                                  break;                                  break;
348    
349                          case 'a':                          case 'a':
350                                  server_bpp = strtol(optarg, NULL, 10);                                  g_server_bpp = strtol(optarg, NULL, 10);
351                                  if (server_bpp != 8 && server_bpp != 16 && server_bpp != 15                                  if (g_server_bpp != 8 && g_server_bpp != 16 && g_server_bpp != 15
352                                      && server_bpp != 24)                                      && g_server_bpp != 24)
353                                  {                                  {
354                                          error("invalid server bpp\n");                                          error("invalid server bpp\n");
355                                          return 1;                                          return 1;
356                                  }                                  }
357                                  break;                                  break;
358    
359                            case '4':
360                                    g_use_rdp5 = False;
361                                    break;
362    
363                          case '5':                          case '5':
364                                  use_rdp5 = True;                                  g_use_rdp5 = True;
365                                  break;                                  break;
366    
367                          case 'h':                          case 'h':
368                          case '?':                          case '?':
369                          default:                          default:
# Line 325  main(int argc, char *argv[]) Line 379  main(int argc, char *argv[])
379          }          }
380    
381          STRNCPY(server, argv[optind], sizeof(server));          STRNCPY(server, argv[optind], sizeof(server));
382          p = strchr(server, ':');          parse_server_and_port(server);
         if (p != NULL)  
         {  
                 tcp_port_rdp = strtol(p + 1, NULL, 10);  
                 *p = 0;  
         }  
383    
384          if (!username_option)          if (!username_option)
385          {          {
# Line 341  main(int argc, char *argv[]) Line 390  main(int argc, char *argv[])
390                          return 1;                          return 1;
391                  }                  }
392    
393                  STRNCPY(username, pw->pw_name, sizeof(username));                  STRNCPY(g_username, pw->pw_name, sizeof(g_username));
394          }          }
395    
396          if (hostname[0] == 0)          if (hostname[0] == 0)
# Line 362  main(int argc, char *argv[]) Line 411  main(int argc, char *argv[])
411          if (prompt_password && read_password(password, sizeof(password)))          if (prompt_password && read_password(password, sizeof(password)))
412                  flags |= RDP_LOGON_AUTO;                  flags |= RDP_LOGON_AUTO;
413    
414          if (title[0] == 0)          if (g_title[0] == 0)
415          {          {
416                  strcpy(title, "rdesktop - ");                  strcpy(g_title, "rdesktop - ");
417                  strncat(title, server, sizeof(title) - sizeof("rdesktop - "));                  strncat(g_title, server, sizeof(g_title) - sizeof("rdesktop - "));
418          }          }
419    
420  #ifdef RDP2VNC  #ifdef RDP2VNC
# Line 376  main(int argc, char *argv[]) Line 425  main(int argc, char *argv[])
425          if (!ui_init())          if (!ui_init())
426                  return 1;                  return 1;
427    
428          /* rdpsnd_init(); */  #ifdef WITH_RDPSND
429            rdpsnd_init();
430    #endif
431          /* rdpdr_init(); */          /* rdpdr_init(); */
432    
433          if (!rdp_connect(server, flags, domain, password, shell, directory))          if (!rdp_connect(server, flags, domain, password, shell, directory))
# Line 385  main(int argc, char *argv[]) Line 436  main(int argc, char *argv[])
436          /* By setting encryption to False here, we have an encrypted login          /* By setting encryption to False here, we have an encrypted login
437             packet but unencrypted transfer of other packets */             packet but unencrypted transfer of other packets */
438          if (!packet_encryption)          if (!packet_encryption)
439                  encryption = False;                  g_encryption = False;
440    
441    
442          DEBUG(("Connection successful.\n"));          DEBUG(("Connection successful.\n"));

Legend:
Removed from v.435  
changed lines
  Added in v.479

  ViewVC Help
Powered by ViewVC 1.1.26