home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / mint / init_5 / wtmp.c < prev   
Encoding:
C/C++ Source or Header  |  1993-08-03  |  777 b   |  43 lines

  1. /*
  2.  * BSD style wtmp updating routine Version 1.0 (c) S.R.Usher 1991.
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <utmp.h>
  7.  
  8. #define WTMP_FILE    "/var/adm/wtmp"
  9.  
  10. void write_wtmp(line, name, host, time)
  11. char *line;
  12. char *name;
  13. char *host;
  14. unsigned long time;
  15. {
  16.     register int returned_val;
  17.     FILE *fp;
  18.     int counter = 0;
  19.     struct utmp entry;
  20.  
  21.     if ((fp = fopen(WTMP_FILE, "a")) == NULL)
  22.     {
  23. #ifdef DEBUG
  24.         perror("write_wtmp");
  25. #endif
  26.         return;
  27.     }
  28.  
  29. /*
  30.  * Note, doing this in this order means that it doesn't matter about the Null
  31.  * bytes strncpy adds the the strings if they are greater than 8/16 bytes!
  32.  */
  33.  
  34.     strncpy(entry.ut_line, line, 8);
  35.     strncpy(entry.ut_name, name, 8);
  36.     strncpy(entry.ut_host, host, 16);
  37.     entry.ut_time = time;
  38.  
  39.     fwrite(&entry, sizeof(struct utmp), 1, fp);
  40.  
  41.     fclose(fp);
  42. }
  43.