aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/intrinsics/getlog.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran/intrinsics/getlog.c')
-rw-r--r--libgfortran/intrinsics/getlog.c23
1 files changed, 23 insertions, 0 deletions
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 <windows.h>
+#include <lmcons.h> /* 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 */