1*37835Sbostic #include <sys/types.h> 237398Sbostic #include <pwd.h> 337398Sbostic extern struct passwd *getpwuid(); 437398Sbostic extern char *getlogin(); 537398Sbostic extern char *getenv(); 637398Sbostic 737398Sbostic char * logname()837398Sbosticlogname() 937398Sbostic { 1037398Sbostic register struct passwd *pw; 1137398Sbostic register char *cp; 1237398Sbostic 1337398Sbostic cp = getenv("USER"); 1437398Sbostic if (cp != 0 && *cp != '\0') 1537398Sbostic return (cp); 1637398Sbostic cp = getlogin(); 1737398Sbostic if (cp != 0 && *cp != '\0') 1837398Sbostic return (cp); 1937398Sbostic setpwent(); 2037398Sbostic pw=getpwuid(getuid()); 2137398Sbostic endpwent(); 2237398Sbostic return(pw->pw_name); 2337398Sbostic } 24