Skip to content
Snippets Groups Projects
Commit 9cef74b7 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: optional argument to hostName() to return full hostname

- value as reported by gethostbyname
parent f3b95df7
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment