[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetC/libc/unistd getlogin.c,NONE,1.1 Makefi
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetC/libc/unistd getlogin.c,NONE,1.1 Makefile.am,1.3,1.4 |
Date: |
Mon, 23 Dec 2002 20:21:54 -0500 |
Update of /cvsroot/dotgnu-pnet/pnetC/libc/unistd
In directory subversions:/tmp/cvs-serv21238/libc/unistd
Modified Files:
Makefile.am
Added Files:
getlogin.c
Log Message:
Add fake password file access routines (getpwnam, etc); stub out
pthread-style mutexes to assist with building thread-safety into
the rest of the library.
--- NEW FILE ---
/*
* getlogin.c - Get the user's login name.
*
* This file is part of the Portable.NET C library.
* Copyright (C) 2002 Southern Storm Software, Pty Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <unistd.h>
#include <string.h>
#include <pthread.h>
typedef __csharp__(System.String) String;
typedef __csharp__(System.Runtime.InteropServices.Marshal) Marshal;
typedef __csharp__(System.Environment) Environment;
static pthread_mutex_t loginMutex = PTHREAD_MUTEX_INITIALIZER;
static char *loginName;
char *
getlogin (void)
{
char *login;
pthread_mutex_lock(&loginMutex);
if (!loginName)
{
String str = __invoke__ Environment.get_UserName ();
loginName = (char *)__invoke__ Marshal.StringToHGlobalAnsi (str);
if (!loginName)
{
loginName = strdup("nobody");
}
}
login = loginName;
pthread_mutex_lock(&loginMutex);
return login;
}
int
getlogin_r (char *name, size_t name_len)
{
char *login = getlogin();
strncpy (name, login, name_len);
return strlen (login);
}
Index: Makefile.am
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetC/libc/unistd/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Makefile.am 17 Aug 2002 11:26:24 -0000 1.3
--- Makefile.am 24 Dec 2002 01:21:52 -0000 1.4
***************
*** 9,12 ****
--- 9,13 ----
dup.c \
dup2.c \
+ getlogin.c \
guid-stub.c \
isatty.c \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetC/libc/unistd getlogin.c,NONE,1.1 Makefile.am,1.3,1.4,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] CVS: pnetC ChangeLog,1.13,1.14 configure.in,1.9,1.10
- Next by Date:
[Dotgnu-pnet-commits] CVS: pnetC/libc Makefile.am,1.3,1.4
- Previous by thread:
[Dotgnu-pnet-commits] CVS: pnetC ChangeLog,1.13,1.14 configure.in,1.9,1.10
- Next by thread:
[Dotgnu-pnet-commits] CVS: pnetC/libc Makefile.am,1.3,1.4
- Index(es):