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: Concepts: user name 34: .seealso: PetscGetHostName() 35: @*/ 36: PetscErrorCode PetscGetUserName(char name[],size_t nlen) 37: { 38: const char *user; 42: user = getenv("USER"); 43: if (!user) user = "Unknown"; 44: PetscStrncpy(name,user,nlen); 45: return(0); 46: } 47: #endif