/[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 30 by matty, Fri Sep 14 13:51:38 2001 UTC revision 58 by jsorg71, Sun Jul 14 00:34:21 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;
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\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 82  main(int argc, char *argv[]) Line 86  main(int argc, char *argv[])
86    
87          flags = RDP_LOGON_NORMAL;          flags = RDP_LOGON_NORMAL;
88          domain[0] = password[0] = shell[0] = directory[0] = 0;          domain[0] = password[0] = shell[0] = directory[0] = 0;
89            strcpy(keymapname, "us");
90    
91          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)
92          {          {
93                  switch (c)                  switch (c)
94                  {                  {
# Line 113  main(int argc, char *argv[]) Line 118  main(int argc, char *argv[])
118                                  break;                                  break;
119    
120                          case 'k':                          case 'k':
121                                  keylayout = strtol(optarg, NULL, 16);                                  STRNCPY(keymapname, optarg, sizeof(keymapname));
                                 if (keylayout == 0)  
                                 {  
                                         error("invalid keyboard layout\n");  
                                         return 1;  
                                 }  
122                                  break;                                  break;
123    
124                          case 'g':                          case 'g':
# Line 153  main(int argc, char *argv[]) Line 153  main(int argc, char *argv[])
153                                  licence = False;                                  licence = False;
154                                  break;                                  break;
155    
156                            case 't':
157                                    tcp_port_rdp = strtol(optarg, NULL, 10);
158                                    break;
159    
160                          case 'h':                          case 'h':
161                          case '?':                          case '?':
162                          default:                          default:
# Line 216  main(int argc, char *argv[]) Line 220  main(int argc, char *argv[])
220          strcpy(title, "rdesktop - ");          strcpy(title, "rdesktop - ");
221          strncat(title, server, sizeof(title) - sizeof("rdesktop - "));          strncat(title, server, sizeof(title) - sizeof("rdesktop - "));
222    
223            if (!rdp_connect(server, flags, domain, password, shell, directory))
224                    return 1;
225    
226            printf("Connection successful.\n");
227    
228          if (ui_create_window(title))          if (ui_create_window(title))
229          {          {
                 if (!rdp_connect(server, flags, domain, password, shell,  
                                  directory))  
                         return 1;  
   
                 printf("Connection successful.\n");  
230                  rdp_main_loop();                  rdp_main_loop();
231                  ui_destroy_window();                  ui_destroy_window();
232          }          }
233    
234            printf("Disconnecting...\n");
235          rdp_disconnect();          rdp_disconnect();
236          return 0;          return 0;
237  }  }
# Line 350  hexdump(unsigned char *p, unsigned int l Line 355  hexdump(unsigned char *p, unsigned int l
355                  line += thisline;                  line += thisline;
356          }          }
357  }  }
358    
359    int
360    load_licence(unsigned char **data)
361    {
362            char path[PATH_MAX];
363            char *home;
364            struct stat st;
365            int fd;
366    
367            home = getenv("HOME");
368            if (home == NULL)
369                    return -1;
370    
371            STRNCPY(path, home, sizeof(path));
372            strncat(path, "/.rdesktop/licence", sizeof(path)-strlen(path)-1);
373    
374            fd = open(path, O_RDONLY);
375            if (fd == -1)
376                    return -1;
377    
378            if (fstat(fd, &st))
379                    return -1;
380    
381            *data = xmalloc(st.st_size);
382            return read(fd, *data, st.st_size);
383    }
384    
385    void
386    save_licence(unsigned char *data, int length)
387    {
388            char path[PATH_MAX];
389            char *home;
390            int fd;
391    
392            home = getenv("HOME");
393            if (home == NULL)
394                    return;
395    
396            STRNCPY(path, home, sizeof(path));
397            strncat(path, "/.rdesktop", sizeof(path)-strlen(path)-1);
398            mkdir(path, 0700);
399    
400            strncat(path, "/licence", sizeof(path)-strlen(path)-1);
401    
402            fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0600);
403            if (fd == -1)
404            {
405                    perror("open");
406                    return;
407            }
408    
409            write(fd, data, length);
410            close(fd);
411    }
412    

Legend:
Removed from v.30  
changed lines
  Added in v.58

  ViewVC Help
Powered by ViewVC 1.1.26