From 0bc22ece49cd4268a1b08507d314aae5d66e28de Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Thu, 24 Feb 2011 09:04:06 +0100 Subject: [PATCH] COMP: fully qualify POSIX function calls --- src/OSspecific/POSIX/POSIX.C | 80 ++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C index 03eefb623b0..4909d082443 100644 --- a/src/OSspecific/POSIX/POSIX.C +++ b/src/OSspecific/POSIX/POSIX.C @@ -63,28 +63,28 @@ defineTypeNameAndDebug(Foam::POSIX, 0); pid_t Foam::pid() { - return getpid(); + return ::getpid(); } pid_t Foam::ppid() { - return getppid(); + return ::getppid(); } pid_t Foam::pgid() { - return getpgrp(); + return ::getpgrp(); } bool Foam::env(const word& envName) { - return getenv(envName.c_str()) != NULL; + return ::getenv(envName.c_str()) != NULL; } Foam::string Foam::getEnv(const word& envName) { - char* env = getenv(envName.c_str()); + char* env = ::getenv(envName.c_str()); if (env) { @@ -113,12 +113,12 @@ bool Foam::setEnv Foam::word Foam::hostName(bool full) { char buf[128]; - gethostname(buf, sizeof(buf)); + ::gethostname(buf, sizeof(buf)); // implementation as per hostname from net-tools if (full) { - struct hostent *hp = gethostbyname(buf); + struct hostent *hp = ::gethostbyname(buf); if (hp) { return hp->h_name; @@ -132,13 +132,13 @@ Foam::word Foam::hostName(bool full) Foam::word Foam::domainName() { char buf[128]; - gethostname(buf, sizeof(buf)); + ::gethostname(buf, sizeof(buf)); // implementation as per hostname from net-tools - struct hostent *hp = gethostbyname(buf); + struct hostent *hp = ::gethostbyname(buf); if (hp) { - char *p = strchr(hp->h_name, '.'); + char *p = ::strchr(hp->h_name, '.'); if (p) { ++p; @@ -152,7 +152,7 @@ Foam::word Foam::domainName() Foam::word Foam::userName() { - struct passwd* pw = getpwuid(getuid()); + struct passwd* pw = ::getpwuid(::getuid()); if (pw != NULL) { @@ -167,14 +167,14 @@ Foam::word Foam::userName() bool Foam::isAdministrator() { - return (geteuid() == 0); + return (::geteuid() == 0); } // use $HOME environment variable or passwd info Foam::fileName Foam::home() { - char* env = getenv("HOME"); + char* env = ::getenv("HOME"); if (env != NULL) { @@ -182,7 +182,7 @@ Foam::fileName Foam::home() } else { - struct passwd* pw = getpwuid(getuid()); + struct passwd* pw = ::getpwuid(getuid()); if (pw != NULL) { @@ -202,18 +202,18 @@ Foam::fileName Foam::home(const word& userName) if (userName.size()) { - pw = getpwnam(userName.c_str()); + pw = ::getpwnam(userName.c_str()); } else { - char* env = getenv("HOME"); + char* env = ::getenv("HOME"); if (env != NULL) { return fileName(env); } - pw = getpwuid(getuid()); + pw = ::getpwuid(::getuid()); } if (pw != NULL) @@ -230,7 +230,7 @@ Foam::fileName Foam::home(const word& userName) Foam::fileName Foam::cwd() { char buf[256]; - if (getcwd(buf, sizeof(buf))) + if (::getcwd(buf, sizeof(buf))) { return buf; } @@ -247,7 +247,7 @@ Foam::fileName Foam::cwd() bool Foam::chDir(const fileName& dir) { - return chdir(dir.c_str()) == 0; + return ::chdir(dir.c_str()) == 0; } @@ -311,7 +311,7 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory) // abort if the file is mandatory, otherwise return null if (mandatory) { - cerr<< "--> FOAM FATAL ERROR in Foam::findEtcFile() :" + std::cerr<< "--> FOAM FATAL ERROR in Foam::findEtcFile() :" " could not find mandatory file\n '" << name.c_str() << "'\n\n" << std::endl; ::exit(1); @@ -591,7 +591,7 @@ Foam::fileNameList Foam::readDir label nEntries = 0; // Attempt to open directory and set the structure pointer - if ((source = opendir(directory.c_str())) == NULL) + if ((source = ::opendir(directory.c_str())) == NULL) { dirEntries.setSize(0); @@ -605,7 +605,7 @@ Foam::fileNameList Foam::readDir else { // Read and parse all the entries in the directory - while ((list = readdir(source)) != NULL) + while ((list = ::readdir(source)) != NULL) { fileName fName(list->d_name); @@ -651,7 +651,7 @@ Foam::fileNameList Foam::readDir // Reset the length of the entries list dirEntries.setSize(nEntries); - closedir(source); + ::closedir(source); } return dirEntries; @@ -781,7 +781,7 @@ bool Foam::ln(const fileName& src, const fileName& dst) return false; } - if (symlink(src.c_str(), dst.c_str()) == 0) + if (::symlink(src.c_str(), dst.c_str()) == 0) { return true; } @@ -810,11 +810,11 @@ bool Foam::mv(const fileName& src, const fileName& dst) { const fileName dstName(dst/src.name()); - return rename(src.c_str(), dstName.c_str()) == 0; + return ::rename(src.c_str(), dstName.c_str()) == 0; } else { - return rename(src.c_str(), dst.c_str()) == 0; + return ::rename(src.c_str(), dst.c_str()) == 0; } } @@ -846,7 +846,7 @@ bool Foam::mvBak(const fileName& src, const std::string& ext) // possible index where we have no choice if (!exists(dstName, false) || n == maxIndex) { - return rename(src.c_str(), dstName.c_str()) == 0; + return ::rename(src.c_str(), dstName.c_str()) == 0; } } @@ -873,7 +873,7 @@ bool Foam::rm(const fileName& file) } else { - return remove(string(file + ".gz").c_str()) == 0; + return ::remove(string(file + ".gz").c_str()) == 0; } } @@ -892,7 +892,7 @@ bool Foam::rmDir(const fileName& directory) struct dirent *list; // Attempt to open directory and set the structure pointer - if ((source = opendir(directory.c_str())) == NULL) + if ((source = ::opendir(directory.c_str())) == NULL) { WarningIn("rmDir(const fileName&)") << "cannot open directory " << directory << endl; @@ -902,7 +902,7 @@ bool Foam::rmDir(const fileName& directory) else { // Read and parse all the entries in the directory - while ((list = readdir(source)) != NULL) + while ((list = ::readdir(source)) != NULL) { fileName fName(list->d_name); @@ -919,7 +919,7 @@ bool Foam::rmDir(const fileName& directory) << " while removing directory " << directory << endl; - closedir(source); + ::closedir(source); return false; } @@ -933,7 +933,7 @@ bool Foam::rmDir(const fileName& directory) << " while removing directory " << directory << endl; - closedir(source); + ::closedir(source); return false; } @@ -947,12 +947,12 @@ bool Foam::rmDir(const fileName& directory) WarningIn("rmDir(const fileName&)") << "failed to remove directory " << directory << endl; - closedir(source); + ::closedir(source); return false; } - closedir(source); + ::closedir(source); return true; } @@ -990,7 +990,7 @@ bool Foam::ping struct sockaddr_in destAddr; // will hold the destination addr u_int addr; - if ((hostPtr = gethostbyname(destName.c_str())) == NULL) + if ((hostPtr = ::gethostbyname(destName.c_str())) == NULL) { FatalErrorIn ( @@ -1003,7 +1003,7 @@ bool Foam::ping addr = (reinterpret_cast<struct in_addr*>(*(hostPtr->h_addr_list)))->s_addr; // Allocate socket - sockfd = socket(AF_INET, SOCK_STREAM, 0); + sockfd = ::socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) { FatalErrorIn @@ -1031,7 +1031,7 @@ bool Foam::ping if ( - connect + ::connect ( sockfd, reinterpret_cast<struct sockaddr*>(&destAddr), @@ -1074,19 +1074,19 @@ int Foam::system(const std::string& command) void* Foam::dlOpen(const fileName& lib) { - return dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL); + return ::dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL); } bool Foam::dlClose(void* handle) { - return dlclose(handle) == 0; + return ::dlclose(handle) == 0; } void* Foam::dlSym(void* handle, const std::string& symbol) { - void* fun = dlsym(handle, symbol.c_str()); + void* fun = ::dlsym(handle, symbol.c_str()); char *error; if ((error = dlerror()) != NULL) -- GitLab