2: /*
  3:       Code for manipulating files.
  4: */
  5: #include <petscsys.h>
  6: #if defined(PETSC_HAVE_WINDOWS_H)
  7: #include <windows.h>
  8: #endif
 10: #if defined(PETSC_HAVE_GET_USER_NAME)
 13: PetscErrorCode  PetscGetUserName(char name[],size_t nlen)
 14: {
 16:   GetUserName((LPTSTR)name,(LPDWORD)(&nlen));
 17:   return(0);
 18: }
 20: #else
 23: /*@C
 24:     PetscGetUserName - Returns the name of the user.
 26:     Not Collective
 28:     Input Parameter:
 29:     nlen - length of name
 31:     Output Parameter:
 32: .   name - contains user name.  Must be long enough to hold the name
 34:     Level: developer
 36:     Concepts: user name
 38: .seealso: PetscGetHostName()
 39: @*/
 40: PetscErrorCode  PetscGetUserName(char name[],size_t nlen)
 41: {
 42:   const char     *user;
 46:   user = getenv("USER");
 47:   if (!user) user = "Unknown";
 48:   PetscStrncpy(name,user,nlen);
 49:   return(0);
 50: }
 51: #endif