[llvm] [clang-tools-extra] [flang] [clang] [flang ]GETLOG runtime and extension implementation: get login username (PR #70917)

Kiran Chandramohan via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 22 05:55:25 PST 2023


================
@@ -10,9 +10,52 @@
 // extensions that will eventually be implemented in Fortran.
 
 #include "flang/Runtime/extensions.h"
+#include "terminator.h"
 #include "flang/Runtime/command.h"
 #include "flang/Runtime/descriptor.h"
 #include "flang/Runtime/io-api.h"
+#include "flang/Runtime/time-intrinsic.h" // copyBufferAndPad
+#include <cstring>
+
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#define NOMINMAX
+#include <windows.h>
+
+#include <cstdlib> // wcstombs_s
+#include <lmcons.h> // UNLEN=256
+#include <wchar.h> // wchar_t cast to LPWSTR
+#pragma comment(lib, "Advapi32.lib") // Link Advapi32.lib for GetUserName
+#define LOGIN_NAME_MAX UNLEN
+
+inline int getlogin_r(char *buf, size_t bufSize) {
+  wchar_t w_username[UNLEN + 1] = {};
+  DWORD nameLen = UNLEN + 1;
----------------
kiranchandramohan wrote:

```suggestion
  DWORD nameLen{UNLEN + 1};
```

https://github.com/llvm/llvm-project/pull/70917


More information about the cfe-commits mailing list