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

  1. /*
  2.  * htmp - manipulation routines for "htmp" data base
  3.  * Bill Joy UCB September 24, 1977
  4.  * << get routines >>
  5.  */
  6. struct htmp {
  7.     int    uid;
  8.     char    home[28];
  9.     int    ttytype;
  10. } hentry;
  11.  
  12. char    htmp[]    "/etc/htmp";
  13.  
  14. hget(tty)
  15.     char tty;
  16. {
  17.     register int hunit;
  18.  
  19.     hunit = open(htmp, 0);
  20.     if (hunit < 0)
  21.         goto bad;
  22.     if (seek(hunit, tty * sizeof hentry, 0))
  23.         goto bad;
  24.     if (read(hunit, &hentry, sizeof hentry) != sizeof hentry) {
  25.         hentry.uid = 0;
  26.         hentry.home[0] = '/';
  27.         hentry.home[1] = 0;
  28.         hentry.ttytype = 'un';
  29.     }
  30.     close(hunit);
  31.     return (0);
  32. bad:
  33.     close(hunit);
  34.     return (-1);
  35. }
  36.  
  37. hgethome()
  38. {
  39.  
  40.     return (hentry.home);
  41. }
  42.  
  43. hgetuid()
  44. {
  45.  
  46.     return(hentry.uid);
  47. }
  48.  
  49. hgettype()
  50. {
  51.  
  52.     return(hentry.ttytype);
  53. }
  54.  
  55. hsgettype()
  56. {
  57.     static char ttype[3];
  58.  
  59.     ttype[0] = hentry.ttytype & 0377;
  60.     ttype[1] = (hentry.ttytype >> 8) & 0377;
  61.     return (ttype);
  62. }
  63.