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

Last change on this file since 528 was 494, checked in by Sam Hocevar, 11 years ago

style: remove trailing spaces, fix copyright statements.

File size: 648 bytes
RevLine 
[56]1/*
2 *  Abuse - dark 2D side-scrolling platform game
3 *  Copyright (c) 1995 Crack dot Com
[494]4 *  Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
[56]5 *
6 *  This software was released into the Public Domain. As with most public
7 *  domain software, no warranty is made or implied by Crack dot Com or
8 *  Jonathan Clark.
9 */
10
11#include "config.h"
12
13#include <stdio.h>
14#include <pwd.h>
15#include <sys/types.h>
16#include <unistd.h>
17
[39]18char const *get_username()
[2]19{
[39]20  struct passwd *pw;
21  char const *name;
[2]22
23  if (!(name = getlogin()))
24  {
25    if ((pw = getpwuid (getuid())))
26      return pw->pw_name;
27    else
28      return "UNIX user";
[124]29  } else return name;
[2]30}
31
Note: See TracBrowser for help on using the repository browser.