~ubuntu-branches/ubuntu/karmic/python-scipy/karmic

« back to all changes in this revision

Viewing changes to Lib/xplt/src/play/unix/usernm.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T. Chen (new)
  • Date: 2005-03-16 02:15:29 UTC
  • Revision ID: james.westby@ubuntu.com-20050316021529-xrjlowsejs0cijig
Tags: upstream-0.3.2
ImportĀ upstreamĀ versionĀ 0.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * usernm.c -- $Id: usernm.c,v 1.1 2003/03/08 15:26:48 travo Exp $
 
3
 * p_getuser for UNIX machines
 
4
 *
 
5
 * Copyright (c) 1998.  See accompanying LEGAL file for details.
 
6
 */
 
7
 
 
8
#ifndef _POSIX_SOURCE
 
9
#define _POSIX_SOURCE 1
 
10
#endif
 
11
 
 
12
#include "config.h"
 
13
#include "play.h"
 
14
 
 
15
#ifndef NO_PASSWD
 
16
 
 
17
#include <sys/types.h>
 
18
#include <unistd.h>
 
19
#include <pwd.h>
 
20
 
 
21
char *
 
22
p_getuser(void)
 
23
{
 
24
  char *user = getlogin();
 
25
  if (!user) {
 
26
    struct passwd *pw = getpwuid(getuid());  /* see also pathnm.c */
 
27
    if (pw) user = pw->pw_name;
 
28
  }
 
29
  return user;
 
30
}
 
31
 
 
32
#else
 
33
 
 
34
extern char *cuserid(char *);
 
35
char *
 
36
p_getuser(void)
 
37
{
 
38
  char *user = cuserid((char *)0);
 
39
  return user;
 
40
}
 
41
 
 
42
#endif