// Smersh // // Douglas Thrift // // $Id$ #include "Environment.hpp" string Environment::get(const string& name) { map::iterator itor(env.find(name)); if (itor != env.end()) return itor->second; char* value(getenv(name.c_str())); return value != NULL ? value : ""; } int Environment::set(const string& name, const string& value, bool overwrite) { pair::iterator, bool> itor(env.insert(pair(name, value))); if (!itor.second && overwrite) itor.first->second = value; return 0; } int Environment::put(const string& env) { istringstream input(env); string name, value; getline(input, name, '='); getline(input, value); return set(name, value); } void Environment::unset(const string& name) { if (env.erase(name) == 0) unsetenv(name.c_str()); }