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

Last change on this file since 97 was 90, checked in by Sam Hocevar, 11 years ago
  • Get rid of WATCOMC tests.
File size: 591 bytes
Line 
1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
4 *
5 *  This software was released into the Public Domain. As with most public
6 *  domain software, no warranty is made or implied by Crack dot Com or
7 *  Jonathan Clark.
8 */
9
10#include "config.h"
11
12#include <stdio.h>
13#include <pwd.h>
14#include <sys/types.h>
15#include <unistd.h>
16
17char const *get_username()
18{
19  struct passwd *pw;
20  char const *name;
21
22  if (!(name = getlogin()))
23  {
24    if ((pw = getpwuid (getuid())))
25      return pw->pw_name;
26    else
27      return "UNIX user";
28  } else return name;
29}
30
Note: See TracBrowser for help on using the repository browser.