From 328f44b37505166a1e8f1fd0ac785512e1e23ad9 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 7 Oct 2011 16:02:59 +0100 Subject: [PATCH] ENH: OSspecific: make userName,domainName,hostName strings --- src/OSspecific/POSIX/POSIX.C | 20 +++++++++---------- src/OpenFOAM/global/argList/argList.C | 4 ++-- src/OpenFOAM/include/OSspecific.H | 12 +++++------ .../primitives/strings/stringOps/stringOps.C | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C index 7ab46939cd..e214e7eeca 100644 --- a/src/OSspecific/POSIX/POSIX.C +++ b/src/OSspecific/POSIX/POSIX.C @@ -123,7 +123,7 @@ bool Foam::setEnv } -Foam::word Foam::hostName(bool full) +Foam::string Foam::hostName(bool full) { char buf[128]; ::gethostname(buf, sizeof(buf)); @@ -142,7 +142,7 @@ Foam::word Foam::hostName(bool full) } -Foam::word Foam::domainName() +Foam::string Foam::domainName() { char buf[128]; ::gethostname(buf, sizeof(buf)); @@ -159,11 +159,11 @@ Foam::word Foam::domainName() } } - return word::null; + return string::null; } -Foam::word Foam::userName() +Foam::string Foam::userName() { struct passwd* pw = ::getpwuid(::getuid()); @@ -173,7 +173,7 @@ Foam::word Foam::userName() } else { - return word::null; + return string::null; } } @@ -209,7 +209,7 @@ Foam::fileName Foam::home() } -Foam::fileName Foam::home(const word& userName) +Foam::fileName Foam::home(const string& userName) { struct passwd* pw; @@ -1069,7 +1069,7 @@ void Foam::fdClose(const int fd) bool Foam::ping ( - const word& destName, + const string& destName, const label destPort, const label timeOut ) @@ -1083,7 +1083,7 @@ bool Foam::ping { FatalErrorIn ( - "Foam::ping(const word&, ...)" + "Foam::ping(const string&, ...)" ) << "gethostbyname error " << h_errno << " for host " << destName << abort(FatalError); } @@ -1097,7 +1097,7 @@ bool Foam::ping { FatalErrorIn ( - "Foam::ping(const word&, const label)" + "Foam::ping(const string&, const label)" ) << "socket error" << abort(FatalError); } @@ -1149,7 +1149,7 @@ bool Foam::ping } -bool Foam::ping(const word& hostname, const label timeOut) +bool Foam::ping(const string& hostname, const label timeOut) { return ping(hostname, 222, timeOut) || ping(hostname, 22, timeOut); } diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 3c42659bf2..5d8758e2d2 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -726,7 +726,7 @@ Foam::argList::argList } - wordList slaveProcs; + stringList slaveProcs; // collect slave machine/pid if (parRunControl_.parRun()) @@ -734,7 +734,7 @@ Foam::argList::argList if (Pstream::master()) { slaveProcs.setSize(Pstream::nProcs() - 1); - word slaveMachine; + string slaveMachine; label slavePid; label procI = 0; diff --git a/src/OpenFOAM/include/OSspecific.H b/src/OpenFOAM/include/OSspecific.H index dc12ef753f..d39a1c54cb 100644 --- a/src/OpenFOAM/include/OSspecific.H +++ b/src/OpenFOAM/include/OSspecific.H @@ -69,13 +69,13 @@ bool setEnv(const word& name, const std::string& value, const bool overwrite); //- Return the system's host name, as per hostname(1) // Optionally with the full name (as per the '-f' option) -word hostName(const bool full=false); +string hostName(const bool full=false); //- Return the system's domain name, as per hostname(1) with the '-d' option -word domainName(); +string domainName(); //- Return the user's login name -word userName(); +string userName(); //- Is user administrator bool isAdministrator(); @@ -84,7 +84,7 @@ bool isAdministrator(); fileName home(); //- Return home directory path name for a particular user -fileName home(const word& userName); +fileName home(const string& userName); //- Return current working directory path name fileName cwd(); @@ -189,10 +189,10 @@ unsigned int sleep(const unsigned int); void fdClose(const int); //- Check if machine is up by pinging given port -bool ping(const word&, const label port, const label timeOut); +bool ping(const string&, const label port, const label timeOut); //- Check if machine is up by pinging port 22 (ssh) and 222 (rsh) -bool ping(const word&, const label timeOut=10); +bool ping(const string&, const label timeOut=10); //- Execute the specified command int system(const std::string& command); diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C index 32e88b16f8..e7493b78e9 100644 --- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C @@ -548,7 +548,7 @@ Foam::string& Foam::stringOps::inplaceExpand // ~OpenFOAM => site/user OpenFOAM configuration directory // ~user => home directory for specified user - word user; + string user; fileName file; if ((begVar = s.find('/')) != string::npos)