source: abuse/tags/pd/macabuse/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: 437 bytes
Line 
1#include "system.h"
2
3#if defined( __WATCOMC__ ) || defined( __MAC__ )
4char *get_username() { return "DOS user"; }
5
6#else
7 
8#include        <stdio.h>
9#include        <pwd.h>
10#include        <sys/types.h>
11#include        <unistd.h>
12
13char *get_username()
14{
15  struct passwd         *pw;
16  char                  *name;
17
18  if (!(name = getlogin()))
19  {
20    if ((pw = getpwuid (getuid())))
21      return pw->pw_name;
22    else
23      return "UNIX user";
24  } else return name;
25}
26
27#endif
28
29
Note: See TracBrowser for help on using the repository browser.