From 86ab632081cc94593ab6c22842d084fce5cf54d4 Mon Sep 17 00:00:00 2001 From: Francois-Xavier Coudert Date: Sun, 25 Sep 2005 23:02:17 +0200 Subject: re PR libfortran/23803 ([mingw32] getlog malfunction) PR libfortran/23803 * intrinsics/getXid.c: Add getpid wrapper for MinGW. * intrinsics/getlog.c: Add getlogin wrapper for MinGW. * intrinsics/hostnm.c: Add gethostname wrapper for MinGW. Co-Authored-By: Danny Smith From-SVN: r104624 --- libgfortran/intrinsics/getlog.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'libgfortran/intrinsics/getlog.c') diff --git a/libgfortran/intrinsics/getlog.c b/libgfortran/intrinsics/getlog.c index 35c52bd..9b73ec2 100644 --- a/libgfortran/intrinsics/getlog.c +++ b/libgfortran/intrinsics/getlog.c @@ -39,6 +39,29 @@ Boston, MA 02110-1301, USA. */ #endif +/* Windows32 version */ +#if defined __MINGW32__ && !defined HAVE_GETLOGIN +#define WIN32_LEAN_AND_MEAN +#include +#include /* for UNLEN */ + +static char * +w32_getlogin (void) +{ + static char name [UNLEN + 1]; + DWORD namelen = sizeof (name); + + GetUserName (name, &namelen); + return (name[0] == 0 ? NULL : name); +} + +#undef getlogin +#define getlogin w32_getlogin +#define HAVE_GETLOGIN 1 + +#endif + + /* GETLOG (LOGIN), g77 intrinsic for retrieving the login name for the process. CHARACTER(len=*), INTENT(OUT) :: LOGIN */ -- cgit v1.1