/[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 38 by matthewc, Thu Apr 4 12:04:33 2002 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 34  char keymapname[16]; Line 35  char keymapname[16];
35  int keylayout;  int keylayout;
36  int width;  int width;
37  int height;  int height;
38    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 59  usage(char *program) Line 61  usage(char *program)
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 85  main(int argc, char *argv[]) Line 88  main(int argc, char *argv[])
88          domain[0] = password[0] = shell[0] = directory[0] = 0;          domain[0] = password[0] = shell[0] = directory[0] = 0;
89          strcpy(keymapname, "us");          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 150  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 213  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();
                 printf("Disconnecting...\n");  
231                  ui_destroy_window();                  ui_destroy_window();
                 rdp_disconnect();  
232          }          }
233    
234            printf("Disconnecting...\n");
235            rdp_disconnect();
236          return 0;          return 0;
237  }  }
238    
# Line 348  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.38  
changed lines
  Added in v.58

  ViewVC Help
Powered by ViewVC 1.1.26