- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- File List
- File Members

# 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 <sbuild/sbuild-chroot.h>
    00024 #include <sbuild/sbuild-custom-error.h>
    00025
    00026 #include <map>
    00027 #include <ostream>
    00028 #include <vector>
    00029 #include <string>
    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     enum error_code
    00055       {
    00056         ALIAS_EXIST,
    00057         CHROOT_NOTFOUND,
    00058         CHROOT_EXIST,
    00059         DIR_OPEN,
    00060         FILE_NOTREG,
    00061         FILE_OPEN,
    00062         FILE_OWNER,
    00063         FILE_PERMS,
    00064         FILE_STAT
    00065       };
    00066
    00068     typedef custom_error<error_code> error;
    00069
    00071     typedef std::tr1::shared_ptr<chroot_config> ptr;
    00072
    00074     chroot_config ();
    00075
    00084     chroot_config (std::string const& file,
    00085                    bool               active);
    00086
    00088     virtual ~chroot_config ();
    00089
    00099     void
    00100     add (std::string const& location,
    00101          bool               active);
    00102
    00103   private:
    00112     void
    00113     add_config_file (std::string const& file,
    00114                      bool               active);
    00115
    00126     void
    00127     add_config_directory (std::string const& dir,
    00128                           bool               active);
    00129
    00130   protected:
    00141     void
    00142     add (chroot::ptr&   chroot,
    00143          keyfile const& kconfig);
    00144
    00145   public:
    00152     chroot_list
    00153     get_chroots () const;
    00154
    00161     const chroot::ptr
    00162     find_chroot (std::string const& name) const;
    00163
    00170     const chroot::ptr
    00171     find_alias (std::string const& name) const;
    00172
    00180     string_list
    00181     get_chroot_list () const;
    00182
    00188     void
    00189     print_chroot_list (std::ostream& stream) const;
    00190
    00197     void
    00198     print_chroot_list_simple (std::ostream& stream) const;
    00199
    00207     void
    00208     print_chroot_info (string_list const& chroots,
    00209                        std::ostream&      stream) const;
    00210
    00218     void
    00219     print_chroot_location (string_list const& chroots,
    00220                            std::ostream&      stream) const;
    00221
    00229     void
    00230     print_chroot_config (string_list const& chroots,
    00231                          std::ostream&      stream) const;
    00232
    00240     string_list
    00241     validate_chroots (string_list const& chroots) const;
    00242
    00243   private:
    00253     void
    00254     load_data (std::string const& file,
    00255                bool               active);
    00256
    00257   protected:
    00266     virtual void
    00267     parse_data (std::istream& stream,
    00268                 bool          active);
    00269
    00278     virtual void
    00279     load_keyfile (keyfile& kconfig,
    00280                   bool     active);
    00281
    00283     chroot_map chroots;
    00285     string_map aliases;
    00286   };
    00287
    00288 }
    00289
    00290 #endif /* SBUILD_CHROOT_CONFIG_H */
    00291
    00292 /*
    00293  * Local Variables:
    00294  * mode:C++
    00295  * End:
    00296  */