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 chroot_config 00044 { 00045 public: 00047 typedef std::vector<chroot::ptr> chroot_list; 00049 typedef std::map<std::string, std::string> string_map; 00051 typedef std::map<std::string, chroot::ptr> chroot_map; 00052 00054 typedef runtime_error_custom<chroot_config> error; 00055 00057 chroot_config (); 00058 00067 chroot_config (std::string const& file, 00068 bool active); 00069 00071 virtual ~chroot_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::ptr 00113 find_chroot (std::string const& name) const; 00114 00121 const 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 void 00161 print_chroot_config (string_list const& chroots, 00162 std::ostream& stream) const; 00163 00171 string_list 00172 validate_chroots (string_list const& chroots) const; 00173 00174 private: 00184 void 00185 check_security (int fd) const; 00186 00195 void 00196 load (std::string const& file, 00197 bool active); 00198 00200 chroot_map chroots; 00202 string_map aliases; 00203 }; 00204 00205 } 00206 00207 #endif /* SBUILD_CONFIG_H */ 00208 00209 /* 00210 * Local Variables: 00211 * mode:C++ 00212 * End: 00213 */