sbuild-chroot-config.h

Go to the documentation of this file.
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_CHROOT_CONFIG_H
00021 #define SBUILD_CHROOT_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     typedef std::tr1::shared_ptr<chroot_config> ptr;
00058 
00060     chroot_config ();
00061 
00070     chroot_config (std::string const& file,
00071                    bool               active);
00072 
00074     virtual ~chroot_config ();
00075 
00085     void
00086     add (std::string const& location,
00087          bool               active);
00088 
00089   private:
00098     void
00099     add_config_file (std::string const& file,
00100                      bool               active);
00101 
00110     void
00111     add_config_directory (std::string const& dir,
00112                           bool               active);
00113 
00114   protected:
00124     void
00125     add (chroot::ptr& chroot);
00126 
00127   public:
00134     chroot_list
00135     get_chroots () const;
00136 
00143     const chroot::ptr
00144     find_chroot (std::string const& name) const;
00145 
00152     const chroot::ptr
00153     find_alias (std::string const& name) const;
00154 
00162     string_list
00163     get_chroot_list () const;
00164 
00170     void
00171     print_chroot_list (std::ostream& stream) const;
00172 
00179     void
00180     print_chroot_list_simple (std::ostream& stream) const;
00181 
00189     void
00190     print_chroot_info (string_list const& chroots,
00191                        std::ostream&      stream) const;
00192 
00200     void
00201     print_chroot_location (string_list const& chroots,
00202                            std::ostream&      stream) const;
00203 
00211     void
00212     print_chroot_config (string_list const& chroots,
00213                          std::ostream&      stream) const;
00214 
00222     string_list
00223     validate_chroots (string_list const& chroots) const;
00224 
00225   private:
00235     void
00236     check_security (int fd) const;
00237 
00246     void
00247     load_data (std::string const& file,
00248                bool               active);
00249 
00258     virtual void
00259     parse_data (std::istream& stream,
00260                 bool          active);
00261 
00263     chroot_map chroots;
00265     string_map aliases;
00266   };
00267 
00268 }
00269 
00270 #endif /* SBUILD_CHROOT_CONFIG_H */
00271 
00272 /*
00273  * Local Variables:
00274  * mode:C++
00275  * End:
00276  */

Generated on Sun Mar 19 12:07:47 2006 for schroot by  doxygen 1.4.6