source: abuse/trunk/src/username.cpp @ 39

Last change on this file since 39 was 39, checked in by Sam Hocevar, 14 years ago
  • Fix almost 2,000 warnings by using proper "const" keywords where needed.
File size: 499 bytes
Line 
1#ifdef __WATCOMC__
2char const *get_username() { return "DOS user"; }
3#elif (defined(__APPLE__) && !defined(__MACH__))
4char const *get_username() { return "Mac user"; }
5#else
6 
7#include        <stdio.h>
8#include        <pwd.h>
9#include        <sys/types.h>
10#include        <unistd.h>
11
12char const *get_username()
13{
14  struct passwd *pw;
15  char const *name;
16
17  if (!(name = getlogin()))
18  {
19    if ((pw = getpwuid (getuid())))
20      return pw->pw_name;
21    else
22      return "UNIX user";
23  } else return name;
24}
25
26#endif
27
28
Note: See TracBrowser for help on using the repository browser.