00001 /* Copyright © 2005-2006 Roger Leigh <rleigh@debian.org> 00002 * 00003 * schroot is free software; you can redistribute it and/or modify it 00004 * under the terms of the GNU General Public License as published by 00005 * the Free Software Foundation; either version 2 of the License, or 00006 * (at your option) any later version. 00007 * 00008 * schroot is distributed in the hope that it will be useful, but 00009 * WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU General Public License 00014 * along with this program; if not, write to the Free Software 00015 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00016 * MA 02111-1307 USA 00017 * 00018 *********************************************************************/ 00019 00020 #ifndef SBUILD_CONFIG_H 00021 #define SBUILD_CONFIG_H 00022 00023 #include <map> 00024 #include <ostream> 00025 #include <vector> 00026 #include <string> 00027 00028 #include "sbuild-chroot.h" 00029 #include "sbuild-error.h" 00030 00031 namespace sbuild 00032 { 00033 00043 class Config 00044 { 00045 public: 00047 typedef std::vector<Chroot::chroot_ptr> chroot_list; 00049 typedef std::map<std::string, std::string> string_map; 00051 typedef std::map<std::string, Chroot::chroot_ptr> chroot_map; 00052 00054 typedef runtime_error_custom<Config> error; 00055 00057 Config(); 00058 00067 Config(std::string const& file, 00068 bool active); 00069 00071 virtual ~Config(); 00072 00081 void 00082 add_config_file (std::string const& file, 00083 bool active); 00084 00093 void 00094 add_config_directory (std::string const& dir, 00095 bool active); 00096 00103 chroot_list 00104 get_chroots () const; 00105 00112 const Chroot::chroot_ptr 00113 find_chroot (std::string const& name) const; 00114 00121 const Chroot::chroot_ptr 00122 find_alias (std::string const& name) const; 00123 00131 string_list 00132 get_chroot_list () const; 00133 00139 void 00140 print_chroot_list (std::ostream& stream) const; 00141 00149 void 00150 print_chroot_info (string_list const& chroots, 00151 std::ostream& stream) const; 00152 00160 string_list 00161 validate_chroots(string_list const& chroots) const; 00162 00163 private: 00173 void 00174 check_security(int fd) const; 00175 00184 void 00185 load (std::string const& file, 00186 bool active); 00187 00189 chroot_map chroots; 00191 string_map aliases; 00192 }; 00193 00194 } 00195 00196 #endif /* SBUILD_CONFIG_H */ 00197 00198 /* 00199 * Local Variables: 00200 * mode:C++ 00201 * End: 00202 */