/[rdesktop]/sourceforge.net/branches/seamlessrdp-branch/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/branches/seamlessrdp-branch/rdesktop/rdesktop.c

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

revision 416 by forsberg, Fri Jun 6 11:11:20 2003 UTC revision 450 by jsorg71, Wed Aug 27 22:51:33 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[32] = "";
44  char username[16];  char g_username[16];
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 desktop_save = True;  BOOL packet_encryption = True;
59  BOOL fullscreen = False;  BOOL g_desktop_save = True;
60  BOOL grab_keyboard = True;  BOOL g_fullscreen = False;
61  BOOL hide_decorations = False;  BOOL g_grab_keyboard = True;
62  BOOL use_rdp5 = False;  BOOL g_hide_decorations = False;
63  extern BOOL owncolmap;  BOOL g_use_rdp5 = False;
64    extern BOOL g_owncolmap;
65    
66  #ifdef RDP2VNC  #ifdef RDP2VNC
67  extern int rfb_port;  extern int rfb_port;
# Line 94  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");
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");
# Line 139  read_password(char *password, int size) Line 141  read_password(char *password, int size)
141          return ret;          return ret;
142  }  }
143    
144    static void
145    parse_server_and_port(char *server)
146    {
147            char *p;
148    #ifdef IPv6
149            int addr_colons;
150    #endif
151    
152    #ifdef IPv6
153            p = server;
154            addr_colons = 0;
155            while (*p)
156                    if (*p++ == ':')
157                            addr_colons++;
158            if (addr_colons >= 2)
159            {
160                    /* numeric IPv6 style address format - [1:2:3::4]:port */
161                    p = strchr(server, ']');
162                    if (*server == '[' && p != NULL)
163                    {
164                            if (*(p + 1) == ':' && *(p + 2) != '\0')
165                                    tcp_port_rdp = strtol(p + 2, NULL, 10);
166                            /* remove the port number and brackets from the address */
167                            *p = '\0';
168                            strncpy(server, server + 1, strlen(server));
169                    }
170            }
171            else
172            {
173                    /* dns name or IPv4 style address format - server.example.com:port or 1.2.3.4:port */
174                    p = strchr(server, ':');
175                    if (p != NULL)
176                    {
177                            tcp_port_rdp = strtol(p + 1, NULL, 10);
178                            *p = 0;
179                    }
180            }
181    #else /* no IPv6 support */
182            p = strchr(server, ':');
183            if (p != NULL)
184            {
185                    tcp_port_rdp = strtol(p + 1, NULL, 10);
186                    *p = 0;
187            }
188    #endif /* IPv6 */
189    
190    }
191    
192  /* Client program */  /* Client program */
193  int  int
194  main(int argc, char *argv[])  main(int argc, char *argv[])
# Line 149  main(int argc, char *argv[]) Line 199  main(int argc, char *argv[])
199          char password[16];          char password[16];
200          char shell[128];          char shell[128];
201          char directory[32];          char directory[32];
202          BOOL prompt_password;          BOOL prompt_password, rdp_retval = False;
203          struct passwd *pw;          struct passwd *pw;
204          uint32 flags;          uint32 flags;
205          char *p;          char *p;
# Line 167  main(int argc, char *argv[]) Line 217  main(int argc, char *argv[])
217  #define VNCOPT  #define VNCOPT
218  #endif  #endif
219    
220          while ((c = getopt(argc, argv, VNCOPT "u:d:s:S:c:p:n:k:g:a:fbemCKT:Dh?54")) != -1)          while ((c = getopt(argc, argv, VNCOPT "u:d:s:S:c:p:n:k:g:a:fbeEmCKT:Dh?54")) != -1)
221          {          {
222                  switch (c)                  switch (c)
223                  {                  {
# Line 186  main(int argc, char *argv[]) Line 236  main(int argc, char *argv[])
236  #endif  #endif
237    
238                          case 'u':                          case 'u':
239                                  STRNCPY(username, optarg, sizeof(username));                                  STRNCPY(g_username, optarg, sizeof(g_username));
240                                  username_option = 1;                                  username_option = 1;
241                                  break;                                  break;
242    
# Line 201  main(int argc, char *argv[]) Line 251  main(int argc, char *argv[])
251                          case 'S':                          case 'S':
252                                  if (!strcmp(optarg, "standard"))                                  if (!strcmp(optarg, "standard"))
253                                  {                                  {
254                                          win_button_size = 18;                                          g_win_button_size = 18;
255                                          break;                                          break;
256                                  }                                  }
257    
258                                  win_button_size = strtol(optarg, &p, 10);                                  g_win_button_size = strtol(optarg, &p, 10);
259    
260                                  if (*p)                                  if (*p)
261                                  {                                  {
# Line 246  main(int argc, char *argv[]) Line 296  main(int argc, char *argv[])
296                          case 'g':                          case 'g':
297                                  if (!strcmp(optarg, "workarea"))                                  if (!strcmp(optarg, "workarea"))
298                                  {                                  {
299                                          width = height = 0;                                          g_width = g_height = 0;
300                                          break;                                          break;
301                                  }                                  }
302    
303                                  width = strtol(optarg, &p, 10);                                  g_width = strtol(optarg, &p, 10);
304                                  if (*p == 'x')                                  if (*p == 'x')
305                                          height = strtol(p + 1, NULL, 10);                                          g_height = strtol(p + 1, NULL, 10);
306    
307                                  if ((width == 0) || (height == 0))                                  if ((g_width == 0) || (g_height == 0))
308                                  {                                  {
309                                          error("invalid geometry\n");                                          error("invalid geometry\n");
310                                          return 1;                                          return 1;
# Line 262  main(int argc, char *argv[]) Line 312  main(int argc, char *argv[])
312                                  break;                                  break;
313    
314                          case 'f':                          case 'f':
315                                  fullscreen = True;                                  g_fullscreen = True;
316                                  break;                                  break;
317    
318                          case 'b':                          case 'b':
319                                  orders = False;                                  g_orders = False;
320                                  break;                                  break;
321    
322                          case 'e':                          case 'e':
323                                  encryption = False;                                  g_encryption = False;
324                                    break;
325                            case 'E':
326                                    packet_encryption = False;
327                                  break;                                  break;
   
328                          case 'm':                          case 'm':
329                                  sendmotion = False;                                  g_sendmotion = False;
330                                  break;                                  break;
331    
332                          case 'C':                          case 'C':
333                                  owncolmap = True;                                  g_owncolmap = True;
334                                  break;                                  break;
335    
336                          case 'K':                          case 'K':
337                                  grab_keyboard = False;                                  g_grab_keyboard = False;
338                                  break;                                  break;
339    
340                          case 'T':                          case 'T':
341                                  STRNCPY(title, optarg, sizeof(title));                                  STRNCPY(g_title, optarg, sizeof(g_title));
342                                  break;                                  break;
343    
344                          case 'D':                          case 'D':
345                                  hide_decorations = True;                                  g_hide_decorations = True;
346                                  break;                                  break;
347    
348                          case 'a':                          case 'a':
349                                  server_bpp = strtol(optarg, NULL, 10);                                  g_server_bpp = strtol(optarg, NULL, 10);
350                                  if (server_bpp != 8 && server_bpp != 16 && server_bpp != 15                                  if (g_server_bpp != 8 && g_server_bpp != 16 && g_server_bpp != 15
351                                      && server_bpp != 24)                                      && g_server_bpp != 24)
352                                  {                                  {
353                                          error("invalid server bpp\n");                                          error("invalid server bpp\n");
354                                          return 1;                                          return 1;
# Line 304  main(int argc, char *argv[]) Line 356  main(int argc, char *argv[])
356                                  break;                                  break;
357    
358                          case '5':                          case '5':
359                                  use_rdp5 = True;                                  g_use_rdp5 = True;
360                                  break;                                  break;
361                          case 'h':                          case 'h':
362                          case '?':                          case '?':
# Line 321  main(int argc, char *argv[]) Line 373  main(int argc, char *argv[])
373          }          }
374    
375          STRNCPY(server, argv[optind], sizeof(server));          STRNCPY(server, argv[optind], sizeof(server));
376          p = strchr(server, ':');          parse_server_and_port(server);
         if (p != NULL)  
         {  
                 tcp_port_rdp = strtol(p + 1, NULL, 10);  
                 *p = 0;  
         }  
377    
378          if (!username_option)          if (!username_option)
379          {          {
# Line 337  main(int argc, char *argv[]) Line 384  main(int argc, char *argv[])
384                          return 1;                          return 1;
385                  }                  }
386    
387                  STRNCPY(username, pw->pw_name, sizeof(username));                  STRNCPY(g_username, pw->pw_name, sizeof(g_username));
388          }          }
389    
390          if (hostname[0] == 0)          if (hostname[0] == 0)
# Line 358  main(int argc, char *argv[]) Line 405  main(int argc, char *argv[])
405          if (prompt_password && read_password(password, sizeof(password)))          if (prompt_password && read_password(password, sizeof(password)))
406                  flags |= RDP_LOGON_AUTO;                  flags |= RDP_LOGON_AUTO;
407    
408          if (title[0] == 0)          if (g_title[0] == 0)
409          {          {
410                  strcpy(title, "rdesktop - ");                  strcpy(g_title, "rdesktop - ");
411                  strncat(title, server, sizeof(title) - sizeof("rdesktop - "));                  strncat(g_title, server, sizeof(g_title) - sizeof("rdesktop - "));
412          }          }
413    
414  #ifdef RDP2VNC  #ifdef RDP2VNC
415          rdp2vnc_connect(server, flags, domain, password, shell, directory);          rdp2vnc_connect(server, flags, domain, password, shell, directory);
416            return 0;
417  #else  #else
418    
419          if (!ui_init())          if (!ui_init())
420                  return 1;                  return 1;
421    
422          ipc_init();             // Must be run after ui_init, we need X to be setup.          /* rdpsnd_init(); */
423            /* rdpdr_init(); */
         if (use_rdp5)  
                 cliprdr_init(); // FIXME: Should perhaps be integrated into the channel management code?  
424    
425          if (!rdp_connect(server, flags, domain, password, shell, directory))          if (!rdp_connect(server, flags, domain, password, shell, directory))
426                  return 1;                  return 1;
427    
428            /* By setting encryption to False here, we have an encrypted login
429               packet but unencrypted transfer of other packets */
430            if (!packet_encryption)
431                    g_encryption = False;
432    
433    
434          DEBUG(("Connection successful.\n"));          DEBUG(("Connection successful.\n"));
435          memset(password, 0, sizeof(password));          memset(password, 0, sizeof(password));
436    
437          if (ui_create_window())          if (ui_create_window())
438          {          {
439                  rdp_main_loop();                  rdp_retval = rdp_main_loop();
440                  ui_destroy_window();                  ui_destroy_window();
441          }          }
442    
# Line 392  main(int argc, char *argv[]) Line 444  main(int argc, char *argv[])
444          rdp_disconnect();          rdp_disconnect();
445          ui_deinit();          ui_deinit();
446    
447            if (True == rdp_retval)
448                    return 0;
449            else
450                    return 2;
451    
452  #endif  #endif
453    
         return 0;  
454  }  }
455    
456  #ifdef EGD_SOCKET  #ifdef EGD_SOCKET

Legend:
Removed from v.416  
changed lines
  Added in v.450

  ViewVC Help
Powered by ViewVC 1.1.26