/[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 33 by matty, Sat Sep 15 12:34:34 2001 UTC revision 66 by astrand, Thu Jul 18 18:28:12 2002 UTC
# Line 23  Line 23 
23  #include <unistd.h>             /* read close getuid getgid getpid getppid gethostname */  #include <unistd.h>             /* read close getuid getgid getpid getppid gethostname */
24  #include <fcntl.h>              /* open */  #include <fcntl.h>              /* open */
25  #include <pwd.h>                /* getpwuid */  #include <pwd.h>                /* getpwuid */
26    #include <limits.h>             /* PATH_MAX */
27  #include <sys/stat.h>           /* stat */  #include <sys/stat.h>           /* stat */
28  #include <sys/time.h>           /* gettimeofday */  #include <sys/time.h>           /* gettimeofday */
29  #include <sys/times.h>          /* times */  #include <sys/times.h>          /* times */
# Line 30  Line 31 
31    
32  char username[16];  char username[16];
33  char hostname[16];  char hostname[16];
34    char keymapname[16];
35    int keylayout = 0x409;          /* Defaults to US keyboard layout */
36  int width;  int width;
37  int height;  int height;
38  int keylayout = 0x409;  int tcp_port_rdp = TCP_PORT_RDP;
39  BOOL bitmap_compression = True;  BOOL bitmap_compression = True;
40  BOOL sendmotion = True;  BOOL sendmotion = True;
41  BOOL orders = True;  BOOL orders = True;
# Line 52  usage(char *program) Line 55  usage(char *program)
55          printf("   -c: working directory\n");          printf("   -c: working directory\n");
56          printf("   -p: password (autologon)\n");          printf("   -p: password (autologon)\n");
57          printf("   -n: client hostname\n");          printf("   -n: client hostname\n");
58          printf("   -k: keyboard layout (hex)\n");          printf("   -k: keyboard layout on terminal server (us,sv,gr etc.)\n");
59          printf("   -g: desktop geometry (WxH)\n");          printf("   -g: desktop geometry (WxH)\n");
60          printf("   -f: full-screen mode\n");          printf("   -f: full-screen mode\n");
61          printf("   -b: force bitmap updates\n");          printf("   -b: force bitmap updates\n");
62          printf("   -e: disable encryption (French TS)\n");          printf("   -e: disable encryption (French TS)\n");
63          printf("   -m: do not send motion events\n");          printf("   -m: do not send motion events\n");
64          printf("   -l: do not request licence\n\n");          printf("   -l: do not request licence\n");
65            printf("   -t: rdp tcp port\n\n");
66  }  }
67    
68  /* Client program */  /* Client program */
# Line 77  main(int argc, char *argv[]) Line 81  main(int argc, char *argv[])
81          int c;          int c;
82    
83          printf("rdesktop: A Remote Desktop Protocol client.\n");          printf("rdesktop: A Remote Desktop Protocol client.\n");
84          printf("Version " VERSION ". Copyright (C) 1999-2001 Matt Chapman.\n");          printf("Version " VERSION
85                   ". Copyright (C) 1999-2001 Matt Chapman.\n");
86          printf("See http://www.rdesktop.org/ for more information.\n\n");          printf("See http://www.rdesktop.org/ for more information.\n\n");
87    
88          flags = RDP_LOGON_NORMAL;          flags = RDP_LOGON_NORMAL;
89          domain[0] = password[0] = shell[0] = directory[0] = 0;          domain[0] = password[0] = shell[0] = directory[0] = 0;
90            strcpy(keymapname, "us");
91    
92          while ((c = getopt(argc, argv, "u:d:s:c:p:n:k:g:fbemlh?")) != -1)          while ((c = getopt(argc, argv, "u:d:s:c:p:n:k:g:t:fbemlh?")) != -1)
93          {          {
94                  switch (c)                  switch (c)
95                  {                  {
# Line 113  main(int argc, char *argv[]) Line 119  main(int argc, char *argv[])
119                                  break;                                  break;
120    
121                          case 'k':                          case 'k':
122                                  keylayout = strtol(optarg, NULL, 16);                                  STRNCPY(keymapname, optarg,
123                                  if (keylayout == 0)                                          sizeof(keymapname));
                                 {  
                                         error("invalid keyboard layout\n");  
                                         return 1;  
                                 }  
124                                  break;                                  break;
125    
126                          case 'g':                          case 'g':
127                                  width = strtol(optarg, &p, 10);                                  width = strtol(optarg, &p, 10);
128                                  if (*p == 'x')                                  if (*p == 'x')
129                                          height = strtol(p+1, NULL, 10);                                          height = strtol(p + 1, NULL, 10);
130    
131                                  if ((width == 0) || (height == 0))                                  if ((width == 0) || (height == 0))
132                                  {                                  {
# Line 153  main(int argc, char *argv[]) Line 155  main(int argc, char *argv[])
155                                  licence = False;                                  licence = False;
156                                  break;                                  break;
157    
158                            case 't':
159                                    tcp_port_rdp = strtol(optarg, NULL, 10);
160                                    break;
161    
162                          case 'h':                          case 'h':
163                          case '?':                          case '?':
164                          default:                          default:
# Line 216  main(int argc, char *argv[]) Line 222  main(int argc, char *argv[])
222          strcpy(title, "rdesktop - ");          strcpy(title, "rdesktop - ");
223          strncat(title, server, sizeof(title) - sizeof("rdesktop - "));          strncat(title, server, sizeof(title) - sizeof("rdesktop - "));
224    
225            xkeymap_init1();
226    
227            if (!rdp_connect(server, flags, domain, password, shell, directory))
228                    return 1;
229    
230            printf("Connection successful.\n");
231    
232          if (ui_create_window(title))          if (ui_create_window(title))
233          {          {
                 if (!rdp_connect(server, flags, domain, password, shell,  
                                  directory))  
                         return 1;  
   
                 printf("Connection successful.\n");  
234                  rdp_main_loop();                  rdp_main_loop();
                 printf("Disconnecting...\n");  
235                  ui_destroy_window();                  ui_destroy_window();
236          }          }
237    
238            printf("Disconnecting...\n");
239          rdp_disconnect();          rdp_disconnect();
240          return 0;          return 0;
241  }  }
242    
243  /* Generate a 32-byte random for the secure transport code. */  /* Generate a 32-byte random for the secure transport code. */
244  void  void
245  generate_random(uint8 *random)  generate_random(uint8 * random)
246  {  {
247          struct stat st;          struct stat st;
248          struct tms tmsbuf;          struct tms tmsbuf;
# Line 339  hexdump(unsigned char *p, unsigned int l Line 347  hexdump(unsigned char *p, unsigned int l
347                          printf("%02x ", line[i]);                          printf("%02x ", line[i]);
348    
349                  for (; i < 16; i++)                  for (; i < 16; i++)
350                                  printf("   ");                          printf("   ");
351    
352                  for (i = 0; i < thisline; i++)                  for (i = 0; i < thisline; i++)
353                          printf("%c",                          printf("%c",
# Line 351  hexdump(unsigned char *p, unsigned int l Line 359  hexdump(unsigned char *p, unsigned int l
359                  line += thisline;                  line += thisline;
360          }          }
361  }  }
362    
363    int
364    load_licence(unsigned char **data)
365    {
366            char path[PATH_MAX];
367            char *home;
368            struct stat st;
369            int fd;
370    
371            home = getenv("HOME");
372            if (home == NULL)
373                    return -1;
374    
375            STRNCPY(path, home, sizeof(path));
376            strncat(path, "/.rdesktop/licence", sizeof(path) - strlen(path) - 1);
377    
378            fd = open(path, O_RDONLY);
379            if (fd == -1)
380                    return -1;
381    
382            if (fstat(fd, &st))
383                    return -1;
384    
385            *data = xmalloc(st.st_size);
386            return read(fd, *data, st.st_size);
387    }
388    
389    void
390    save_licence(unsigned char *data, int length)
391    {
392            char path[PATH_MAX];
393            char *home;
394            int fd;
395    
396            home = getenv("HOME");
397            if (home == NULL)
398                    return;
399    
400            STRNCPY(path, home, sizeof(path));
401            strncat(path, "/.rdesktop", sizeof(path) - strlen(path) - 1);
402            mkdir(path, 0700);
403    
404            strncat(path, "/licence", sizeof(path) - strlen(path) - 1);
405    
406            fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0600);
407            if (fd == -1)
408            {
409                    perror("open");
410                    return;
411            }
412    
413            write(fd, data, length);
414            close(fd);
415    }

Legend:
Removed from v.33  
changed lines
  Added in v.66

  ViewVC Help
Powered by ViewVC 1.1.26