2 Copyright (C) 2010 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 extern char** environ;
30 EnvironmentalProtectionAgency* EnvironmentalProtectionAgency::_global_epa = 0;
32 EnvironmentalProtectionAgency::EnvironmentalProtectionAgency ()
37 EnvironmentalProtectionAgency::~EnvironmentalProtectionAgency()
43 EnvironmentalProtectionAgency::save ()
47 for (size_t i = 0; environ[i]; ++i) {
49 string estring = environ[i];
50 string::size_type equal = estring.find_first_of ('=');
52 if (equal == string::npos) {
53 /* say what? an environ value without = ? */
57 string before = estring.substr (0, equal);
58 string after = estring.substr (equal+1);
60 cerr << "Save [" << before << "] = " << after << endl;
62 e.insert (pair<string,string>(before,after));
66 EnvironmentalProtectionAgency::restore ()
68 for (map<string,string>::iterator i = e.begin(); i != e.end(); ++i) {
69 cerr << "Restore [" << i->first << "] = " << i->second << endl;
70 setenv (i->first.c_str(), i->second.c_str(), 1);