/[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 53 by matthewc, Tue May 28 11:48:55 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 213  main(int argc, char *argv[]) Line 214  main(int argc, char *argv[])
214          strcpy(title, "rdesktop - ");          strcpy(title, "rdesktop - ");
215          strncat(title, server, sizeof(title) - sizeof("rdesktop - "));          strncat(title, server, sizeof(title) - sizeof("rdesktop - "));
216    
217            if (!rdp_connect(server, flags, domain, password, shell, directory))
218                    return 1;
219    
220            printf("Connection successful.\n");
221    
222          if (ui_create_window(title))          if (ui_create_window(title))
223          {          {
                 if (!rdp_connect(server, flags, domain, password, shell,  
                                  directory))  
                         return 1;  
   
                 printf("Connection successful.\n");  
224                  rdp_main_loop();                  rdp_main_loop();
                 printf("Disconnecting...\n");  
225                  ui_destroy_window();                  ui_destroy_window();
                 rdp_disconnect();  
226          }          }
227    
228            printf("Disconnecting...\n");
229            rdp_disconnect();
230          return 0;          return 0;
231  }  }
232    
# Line 348  hexdump(unsigned char *p, unsigned int l Line 349  hexdump(unsigned char *p, unsigned int l
349                  line += thisline;                  line += thisline;
350          }          }
351  }  }
352    
353    int
354    load_licence(unsigned char **data)
355    {
356            char path[PATH_MAX];
357            char *home;
358            struct stat st;
359            int fd;
360    
361            home = getenv("HOME");
362            if (home == NULL)
363                    return -1;
364    
365            STRNCPY(path, home, sizeof(path));
366            strncat(path, "/.rdesktop/licence", sizeof(path)-strlen(path)-1);
367    
368            fd = open(path, O_RDONLY);
369            if (fd == -1)
370                    return -1;
371    
372            if (fstat(fd, &st))
373                    return -1;
374    
375            *data = xmalloc(st.st_size);
376            return read(fd, *data, st.st_size);
377    }
378    
379    void
380    save_licence(unsigned char *data, int length)
381    {
382            char path[PATH_MAX];
383            char *home;
384            int fd;
385    
386            home = getenv("HOME");
387            if (home == NULL)
388                    return;
389    
390            STRNCPY(path, home, sizeof(path));
391            strncat(path, "/.rdesktop", sizeof(path)-strlen(path)-1);
392            mkdir(path, 0700);
393    
394            strncat(path, "/licence", sizeof(path)-strlen(path)-1);
395    
396            fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0600);
397            if (fd == -1)
398            {
399                    perror("open");
400                    return;
401            }
402    
403            write(fd, data, length);
404            close(fd);
405    }
406    

Legend:
Removed from v.38  
changed lines
  Added in v.53

  ViewVC Help
Powered by ViewVC 1.1.26