diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C index fecea27cbe..380c785c0b 100644 --- a/src/OSspecific/POSIX/POSIX.C +++ b/src/OSspecific/POSIX/POSIX.C @@ -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; } diff --git a/src/OpenFOAM/include/OSspecific.H b/src/OpenFOAM/include/OSspecific.H index 7b4c3a5320..3ee759a596 100644 --- a/src/OpenFOAM/include/OSspecific.H +++ b/src/OpenFOAM/include/OSspecific.H @@ -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();