Actual source code: fuser.c

petsc-3.14.6 2021-03-30
Report Typos and Errors

  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)
 11: PetscErrorCode  PetscGetUserName(char name[],size_t nlen)
 12: {
 14:   GetUserName((LPTSTR)name,(LPDWORD)(&nlen));
 15:   return(0);
 16: }

 18: #else
 19: /*@C
 20:     PetscGetUserName - Returns the name of the user.

 22:     Not Collective

 24:     Input Parameter:
 25:     nlen - length of name

 27:     Output Parameter:
 28: .   name - contains user name.  Must be long enough to hold the name

 30:     Level: developer

 32: .seealso: PetscGetHostName()
 33: @*/
 34: PetscErrorCode  PetscGetUserName(char name[],size_t nlen)
 35: {
 36:   const char     *user;

 40:   user = getenv("USER");
 41:   if (!user) user = "Unknown";
 42:   PetscStrncpy(name,user,nlen);
 43:   return(0);
 44: }
 45: #endif