mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: optional argument to hostName() to return full hostname
- value as reported by gethostbyname
This commit is contained in:
@ -109,12 +109,22 @@ bool Foam::setEnv
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::hostName()
|
||||
Foam::word Foam::hostName(bool full)
|
||||
{
|
||||
char buffer[256];
|
||||
gethostname(buffer, 256);
|
||||
char buf[256];
|
||||
gethostname(buf, 256);
|
||||
|
||||
return buffer;
|
||||
if (full)
|
||||
{
|
||||
struct hostent *hptr = gethostbyname(buf);
|
||||
|
||||
if (hptr)
|
||||
{
|
||||
return hptr->h_name;
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -68,7 +68,8 @@ string getEnv(const word&);
|
||||
bool setEnv(const word& name, const string& value, const bool overwrite);
|
||||
|
||||
//- Return the system's host name
|
||||
word hostName();
|
||||
// Optionally the full name reported from gethostbyname
|
||||
word hostName(const bool full=false);
|
||||
|
||||
//- Return the user's login name
|
||||
word userName();
|
||||
|
||||
Reference in New Issue
Block a user