logname.c

Upload User: acmefrp
Upload Date: 2010-03-06
Package Size: 23768k
Code Size: 0k
Category: OS Develop
Development Platform: C/C++
  1. # include <pwd.h>
  2. # include <sys/types.h>
  3. # include "../hdr/macros.h"
  4. SCCSID(@(#)logname.c 1.1 92/07/30 SMI); /* from System III 5.1 */
  5. char *logname()
  6. {
  7. register char *n;
  8. extern struct passwd *getpwuid();
  9. register struct passwd *pw;
  10. static char name[16];
  11. pw = getpwuid(getuid());
  12. endpwent();
  13. if (pw == 0)
  14. n = "UNKNOWN";
  15. else
  16. n = pw->pw_name;
  17. strcpy(name, n);
  18. return (name);
  19. }