/[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 289 by astrand, Thu Jan 16 13:48:02 2003 UTC revision 333 by astrand, Thu Feb 20 12:14:13 2003 UTC
# Line 1  Line 1 
1  /*  /*
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     Entrypoint and utility functions     Entrypoint and utility functions
4     Copyright (C) Matthew Chapman 1999-2002     Copyright (C) Matthew Chapman 1999-2003
5    
6     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
# Line 21  Line 21 
21  #include <stdarg.h>             /* va_list va_start va_end */  #include <stdarg.h>             /* va_list va_start va_end */
22  #include <unistd.h>             /* read close getuid getgid getpid getppid gethostname */  #include <unistd.h>             /* read close getuid getgid getpid getppid gethostname */
23  #include <fcntl.h>              /* open */  #include <fcntl.h>              /* open */
 #include <errno.h>              /* save licence uses it. */  
24  #include <pwd.h>                /* getpwuid */  #include <pwd.h>                /* getpwuid */
25  #include <termios.h>            /* tcgetattr tcsetattr */  #include <termios.h>            /* tcgetattr tcsetattr */
26  #include <sys/stat.h>           /* stat */  #include <sys/stat.h>           /* stat */
27  #include <sys/time.h>           /* gettimeofday */  #include <sys/time.h>           /* gettimeofday */
28  #include <sys/times.h>          /* times */  #include <sys/times.h>          /* times */
29    #include <errno.h>
30  #include "rdesktop.h"  #include "rdesktop.h"
31    
32  #ifdef EGD_SOCKET  #ifdef EGD_SOCKET
# Line 45  char username[16]; Line 45  char 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 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 height = 600;
51  int tcp_port_rdp = TCP_PORT_RDP;  int tcp_port_rdp = TCP_PORT_RDP;
52    int server_bpp = 8;
53    int win_button_size = 0;        /* If zero, disable single app mode */
54  BOOL bitmap_compression = True;  BOOL bitmap_compression = True;
55  BOOL sendmotion = True;  BOOL sendmotion = True;
56  BOOL orders = True;  BOOL orders = True;
# Line 59  BOOL grab_keyboard = True; Line 61  BOOL grab_keyboard = True;
61  BOOL hide_decorations = False;  BOOL hide_decorations = False;
62  extern BOOL owncolmap;  extern BOOL owncolmap;
63    
64    #ifdef RDP2VNC
65    extern int rfb_port;
66    extern int defer_time;
67    void
68    rdp2vnc_connect(char *server, uint32 flags, char *domain, char *password,
69                    char *shell, char *directory);
70    #endif
71  /* Display usage information */  /* Display usage information */
72  static void  static void
73  usage(char *program)  usage(char *program)
74  {  {
75          fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n");          fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n");
76          fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2002 Matt Chapman.\n");          fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2003 Matt Chapman.\n");
77          fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n");          fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n");
78    
79          fprintf(stderr, "Usage: %s [options] server[:port]\n", program);          fprintf(stderr, "Usage: %s [options] server[:port]\n", program);
80    #ifdef RDP2VNC
81            fprintf(stderr, "   -V: vnc port\n");
82            fprintf(stderr, "   -E: defer time (ms)\n");
83    #endif
84          fprintf(stderr, "   -u: user name\n");          fprintf(stderr, "   -u: user name\n");
85          fprintf(stderr, "   -d: domain\n");          fprintf(stderr, "   -d: domain\n");
86          fprintf(stderr, "   -s: shell\n");          fprintf(stderr, "   -s: shell\n");
87            fprintf(stderr, "   -S: caption button size (single application mode)\n");
88          fprintf(stderr, "   -c: working directory\n");          fprintf(stderr, "   -c: working directory\n");
89          fprintf(stderr, "   -p: password (- to prompt)\n");          fprintf(stderr, "   -p: password (- to prompt)\n");
90          fprintf(stderr, "   -n: client hostname\n");          fprintf(stderr, "   -n: client hostname\n");
# Line 84  usage(char *program) Line 98  usage(char *program)
98          fprintf(stderr, "   -K: keep window manager key bindings\n");          fprintf(stderr, "   -K: keep window manager key bindings\n");
99          fprintf(stderr, "   -T: window title\n");          fprintf(stderr, "   -T: window title\n");
100          fprintf(stderr, "   -D: hide window manager decorations\n");          fprintf(stderr, "   -D: hide window manager decorations\n");
101            fprintf(stderr, "   -a: server bpp\n");
102  }  }
103    
104  static BOOL  static BOOL
# Line 144  main(int argc, char *argv[]) Line 159  main(int argc, char *argv[])
159          domain[0] = password[0] = shell[0] = directory[0] = 0;          domain[0] = password[0] = shell[0] = directory[0] = 0;
160          strcpy(keymapname, "en-us");          strcpy(keymapname, "en-us");
161    
162          while ((c = getopt(argc, argv, "u:d:s:c:p:n:k:g:fbemCKT:Dh?")) != -1)  #ifdef RDP2VNC
163    #define VNCOPT "V:E:"
164    #else
165    #define VNCOPT
166    #endif
167    
168            while ((c = getopt(argc, argv, VNCOPT "u:d:s:S:c:p:n:k:g:a:fbemCKT:Dh?")) != -1)
169          {          {
170                  switch (c)                  switch (c)
171                  {                  {
172    #ifdef RDP2VNC
173                            case 'V':
174                                    rfb_port = strtol(optarg, NULL, 10);
175                                    if (rfb_port < 100)
176                                            rfb_port += 5900;
177                                    break;
178    
179                            case 'E':
180                                    defer_time = strtol(optarg, NULL, 10);
181                                    if (defer_time < 0)
182                                            defer_time = 0;
183                                    break;
184    #endif
185    
186                          case 'u':                          case 'u':
187                                  STRNCPY(username, optarg, sizeof(username));                                  STRNCPY(username, optarg, sizeof(username));
188                                  username_option = 1;                                  username_option = 1;
# Line 161  main(int argc, char *argv[]) Line 196  main(int argc, char *argv[])
196                                  STRNCPY(shell, optarg, sizeof(shell));                                  STRNCPY(shell, optarg, sizeof(shell));
197                                  break;                                  break;
198    
199                            case 'S':
200                                    if (!strcmp(optarg, "standard"))
201                                    {
202                                            win_button_size = 18;
203                                            break;
204                                    }
205    
206                                    win_button_size = strtol(optarg, &p, 10);
207    
208                                    if (*p)
209                                    {
210                                            error("invalid button size\n");
211                                            return 1;
212                                    }
213    
214                                    break;
215    
216                          case 'c':                          case 'c':
217                                  STRNCPY(directory, optarg, sizeof(directory));                                  STRNCPY(directory, optarg, sizeof(directory));
218                                  break;                                  break;
# Line 239  main(int argc, char *argv[]) Line 291  main(int argc, char *argv[])
291                                  hide_decorations = True;                                  hide_decorations = True;
292                                  break;                                  break;
293    
294                            case 'a':
295                                    server_bpp = strtol(optarg, NULL, 10);
296                                    if (server_bpp != 8 && server_bpp != 16 && server_bpp != 15
297                                        && server_bpp != 24)
298                                    {
299                                            error("invalid server bpp\n");
300                                            return 1;
301                                    }
302                                    break;
303    
304                          case 'h':                          case 'h':
305                          case '?':                          case '?':
306                          default:                          default:
# Line 297  main(int argc, char *argv[]) Line 359  main(int argc, char *argv[])
359                  strncat(title, server, sizeof(title) - sizeof("rdesktop - "));                  strncat(title, server, sizeof(title) - sizeof("rdesktop - "));
360          }          }
361    
362    #ifdef RDP2VNC
363            rdp2vnc_connect(server, flags, domain, password, shell, directory);
364    #else
365    
366          if (!ui_init())          if (!ui_init())
367                  return 1;                  return 1;
368    
# Line 315  main(int argc, char *argv[]) Line 381  main(int argc, char *argv[])
381          DEBUG(("Disconnecting...\n"));          DEBUG(("Disconnecting...\n"));
382          rdp_disconnect();          rdp_disconnect();
383          ui_deinit();          ui_deinit();
384    
385    #endif
386    
387          return 0;          return 0;
388  }  }
389    
# Line 447  error(char *format, ...) Line 516  error(char *format, ...)
516          va_end(ap);          va_end(ap);
517  }  }
518    
519    /* report a warning */
520    void
521    warning(char *format, ...)
522    {
523            va_list ap;
524    
525            fprintf(stderr, "WARNING: ");
526    
527            va_start(ap, format);
528            vfprintf(stderr, format, ap);
529            va_end(ap);
530    }
531    
532  /* report an unimplemented protocol feature */  /* report an unimplemented protocol feature */
533  void  void
534  unimpl(char *format, ...)  unimpl(char *format, ...)
# Line 490  hexdump(unsigned char *p, unsigned int l Line 572  hexdump(unsigned char *p, unsigned int l
572          }          }
573  }  }
574    
575  #ifdef SAVE_LICENCE  
576  int  int
577  load_licence(unsigned char **data)  load_licence(unsigned char **data)
578  {  {
# Line 548  save_licence(unsigned char *data, int le Line 630  save_licence(unsigned char *data, int le
630                  if ((s_ptr->p) + 4 > data + length)                  if ((s_ptr->p) + 4 > data + length)
631                  {                  {
632                          printf("Error in parsing licence key.\n");                          printf("Error in parsing licence key.\n");
633                          printf("Strings %d end value %x > supplied length (%x)\n",                          printf("Strings %d end value %x > supplied length (%x)\n", i,
634                                 i, s_ptr->p, data + length);                                 (unsigned int) s_ptr->p, (unsigned int) data + length);
635                          return;                          return;
636                  }                  }
637          }          }
# Line 557  save_licence(unsigned char *data, int le Line 639  save_licence(unsigned char *data, int le
639          if (s_ptr->p + len > data + length)          if (s_ptr->p + len > data + length)
640          {          {
641                  printf("Error in parsing licence key.\n");                  printf("Error in parsing licence key.\n");
642                  printf("End of licence %x > supplied length (%x)\n", s_ptr->p + len, data + length);                  printf("End of licence %x > supplied length (%x)\n",
643                           (unsigned int) s_ptr->p + len, (unsigned int) data + length);
644                  return;                  return;
645          }          }
646    
# Line 593  save_licence(unsigned char *data, int le Line 676  save_licence(unsigned char *data, int le
676          fnamewrk = xmalloc(strlen(fname) + 12);          fnamewrk = xmalloc(strlen(fname) + 12);
677          for (y = 0;; y++)          for (y = 0;; y++)
678          {          {
679                  sprintf(fnamewrk, "%s.%lu", fname, y);                  sprintf(fnamewrk, "%s.%lu", fname, (long unsigned int) y);
680                  fnwrkfd = open(fnamewrk, O_WRONLY | O_CREAT | O_EXCL, 0600);                  fnwrkfd = open(fnamewrk, O_WRONLY | O_CREAT | O_EXCL, 0600);
681                  if (fnwrkfd == -1)                  if (fnwrkfd == -1)
682                  {                  {
# Line 646  save_licence(unsigned char *data, int le Line 729  save_licence(unsigned char *data, int le
729          }          }
730    
731  }  }
 #endif  

Legend:
Removed from v.289  
changed lines
  Added in v.333

  ViewVC Help
Powered by ViewVC 1.1.26