// get_hostname.cxx #include "dataset_util/get_hostname.h" #include using std::string; string get_hostname() { static string host = "UNINITIALIZED"; static bool done = false; if ( ! done ) { char buff[1024] = ""; int len = 1024; // First try gethostname. int stat = gethostname(buff, len); if ( stat == 0 ) { host = buff; // Give up } else { host = ""; } } return host; }