]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/Extras/getenv.c
Updated documentation and comments about sendmail/pipe.
[nmh] / docs / historical / mh-jun-1982 / Extras / getenv.c
1 #ifdef COMMENT
2 Proprietary Rand Corporation, 1981.
3 Further distribution of this software
4 subject to the terms of the Rand
5 license agreement.
6 #endif
7
8 #include <stdio.h>
9 #include <pwd.h>
10
11 char *
12 getenv(key)
13 char *key;
14 {
15 register char *r;
16 register struct passwd *p;
17
18 if(strcmp(key, "USER") == 0 || strcmp(key, "HOME") == 0)
19 if((p = getpwuid(getruid())) == NULL)
20 return NULL;
21 else
22 return strcmp(key, "USER") == 0 ?
23 p->pw_name : p->pw_dir;
24 return NULL;
25 }