home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / ucb / 2bsd.tar.gz / 2bsd.tar / upgrade / libretro / htmps.c < prev    next >
Encoding:
C/C++ Source or Header  |  1979-04-19  |  703 b   |  55 lines

  1. /*
  2.  * htmp - manipulation routines for "htmp" data base
  3.  * Bill Joy UCB September 24, 1977
  4.  * << set routines >>
  5.  */
  6. struct htmp {
  7.     int    uid;
  8.     char    home[28];
  9.     int    ttytype;
  10. } hentry;
  11.  
  12. char    htmp[];
  13.  
  14. hput(tty)
  15.     char tty;
  16. {
  17.     register int hunit;
  18.  
  19.     hunit = open(htmp, 1);
  20.     if (hunit < 0)
  21.         return (-1);
  22.     seek(hunit, tty * sizeof hentry, 0);
  23.     if (write(hunit, &hentry, sizeof hentry) != sizeof hentry)
  24.         goto bad;
  25.     close(hunit);
  26.     return (0);
  27. bad:
  28.     close(hunit);
  29.     return (-1);
  30. }
  31.  
  32. hsethome(cp)
  33.     char *cp;
  34. {
  35.     register int i;
  36.  
  37.     for (i = 0; i < 27 && cp[i]; i++)
  38.         hentry.home[i] = cp[i];
  39.     hentry.home[i] = 0;
  40. }
  41.  
  42. hsetuid(uid)
  43.     int uid;
  44. {
  45.  
  46.     hentry.uid = uid;
  47. }
  48.  
  49. hsettype(type)
  50.     int type;
  51. {
  52.  
  53.     hentry.ttytype = type;
  54. }
  55.