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

  1. #include <retrofit.h>
  2. #include <pwd.h>
  3.  
  4. getenv(name)
  5.     char *name;
  6. {
  7.     register int ttyno;
  8.     static char hgot;
  9.  
  10. top:
  11.     if (strcmp(name, "TERM") == 0) {
  12.         if (!hgot)
  13.             goto getit;
  14.         return (hsgettype());
  15.     }
  16.     if (strcmp(name, "HOME") == 0) {
  17.         if (getuid() == 0)
  18.             return ("/");
  19.         if (!hgot)
  20.             goto getit;
  21.         return (hgethome());
  22.     }
  23.     return (0);
  24. getit:
  25.     ttyno = ttyn(2);
  26.     if (ttyno < 0 || ttyno == 'x' || hget(ttyno) < 0) {
  27.         register struct passwd *p = getpwuid(getuid());
  28.         extern struct htmp {
  29.             int    uid;
  30.             char    home[28];
  31.             int    ttytype;
  32.         } hentry;
  33.         strcpy(hentry.home, p->pw_dir);
  34.         hentry.ttytype = 'xx';
  35.     }
  36.     hgot = 1;
  37.     goto top;
  38. }
  39.