source: abuse/tags/pd/abuse/src/username.c @ 49

Last change on this file since 49 was 49, checked in by Sam Hocevar, 11 years ago
  • Imported original public domain release, for future reference.
  • Property svn:keywords set to Id
File size: 420 bytes
Line 
1#if defined( __WATCOMC__ ) || defined( __POWERPC__ )
2char *get_username() { return "DOS user"; }
3
4#else
5 
6#include        <stdio.h>
7#include        <pwd.h>
8#include        <sys/types.h>
9#include        <unistd.h>
10
11char *get_username()
12{
13  struct passwd         *pw;
14  char                  *name;
15
16  if (!(name = getlogin()))
17  {
18    if ((pw = getpwuid (getuid())))
19      return pw->pw_name;
20    else
21      return "UNIX user";
22  } else return name;
23}
24
25#endif
26
27
Note: See TracBrowser for help on using the repository browser.