nis-util  1.0.D108
lib/space/netgroup.h
Go to the documentation of this file.
00001 //
00002 // nis-util - NIS Administration Utilities
00003 // Copyright (C) 2001-2003, 2008, 2009, 2012 Peter Miller
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or (at
00008 // your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 //
00018 
00019 #ifndef LIB_SPACE_NETGROUP_H
00020 #define LIB_SPACE_NETGROUP_H
00021 
00022 #include <boost/shared_ptr.hpp>
00023 
00024 #include <lib/space.h>
00025 
00026 class symtab; // forward
00027 class space_netgroup_check; // forward
00028 
00033 class space_netgroup:
00034     public space
00035 {
00036 public:
00037     typedef boost::shared_ptr<space_netgroup> pointer;
00038 
00042     virtual ~space_netgroup();
00043 
00044 public:
00052     static pointer create(const rcstring &filename);
00053 
00066     struct entry_t
00067     {
00072         rcstring reference_to_netgroup;
00073 
00079         rcstring host;
00080 
00086         rcstring user;
00087 
00094         rcstring domain;
00095 
00100         bool host_any(void) const;
00101 
00106         bool host_ignore(void) const;
00107 
00112         bool host_indexing(void) const;
00113 
00118         bool user_any(void) const;
00119 
00124         bool user_ignore(void) const;
00125 
00130         bool user_indexing(void) const;
00131 
00138         rcstring representation(void) const;
00139 
00143         bool operator==(const entry_t &) const;
00144     };
00145 
00149     class record
00150     {
00151     public:
00152         typedef boost::shared_ptr<record> pointer;
00153 
00154         ~record();
00155 
00156         typedef std::vector<entry_t> members_t;
00157 
00169         static pointer create(const source_location &locn, const rcstring &name,
00170             const members_t &members);
00171 
00178         rcstring representation(void) const;
00179 
00180         const source_location &get_source_location(void) const { return locn; }
00181         rcstring get_name(void) const { return name; }
00182         const members_t &get_members(void) const { return members; }
00183 
00184     private:
00196         record(const source_location &locn, const rcstring &name,
00197             const members_t &members);
00198 
00203         source_location locn;
00204 
00209         rcstring name;
00210 
00215         members_t members;
00216 
00220         record();
00221 
00225         record(const record &rhs);
00226 
00230         record &operator=(const record &rhs);
00231     };
00232 
00241     record::pointer get(void);
00242 
00249     static rcstring is_ok_netgroup_name(const rcstring &);
00250 
00251 protected:
00259     space_netgroup(const rcstring &filename);
00260 
00261 private:
00269     bool parse_group(const rcstring &s, entry_t &result,
00270         const source_location &glocn);
00271 
00276     space_netgroup();
00277 
00282     space_netgroup(const space_netgroup &);
00283 
00288     space_netgroup &operator=(const space_netgroup &);
00289 };
00290 
00291 // vim: set ts=8 sw=4 et :
00292 #endif // LIB_SPACE_NETGROUP_H