nis-util
1.0.D108
|
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_HOSTS_H 00020 #define LIB_SPACE_HOSTS_H 00021 00022 #include <boost/shared_ptr.hpp> 00023 00024 #include <lib/space.h> 00025 00030 class space_hosts: 00031 public space 00032 { 00033 public: 00034 typedef boost::shared_ptr<space_hosts> pointer; 00035 00039 virtual ~space_hosts(); 00040 00048 static pointer create(const rcstring &filename); 00049 00054 class record 00055 { 00056 public: 00057 typedef boost::shared_ptr<record> pointer; 00058 00059 ~record(); 00060 00061 typedef std::vector<rcstring> names_t; 00062 00063 static pointer create(const source_location &locn, 00064 const rcstring &ip_address, const names_t &names); 00065 00072 rcstring representation() const; 00073 00074 const source_location &get_source_location(void) const { return locn; } 00075 rcstring get_ip_address(void) const { return ip_address; } 00076 const names_t &get_names(void) const { return names; } 00077 00078 bool operator<(const record &rhs) const; 00079 bool operator<=(const record &rhs) const; 00080 bool operator>(const record &rhs) const; 00081 bool operator>=(const record &rhs) const; 00082 00083 private: 00084 record(const source_location &locn, const rcstring &ip_address, 00085 const names_t &names); 00086 00087 source_location locn; 00088 rcstring ip_address; 00089 names_t names; 00090 unsigned long ip_address_binary; 00091 }; 00092 00104 record::pointer get(void); 00105 00111 static bool valid_ip_address(const rcstring &input, rcstring &output); 00112 00118 static bool valid_host_name(const rcstring &input, rcstring &output); 00119 00120 protected: 00128 space_hosts(const rcstring &filename); 00129 00130 private: 00135 record::pointer last_rp; 00136 00140 space_hosts(); 00141 00145 space_hosts(const space_hosts &); 00146 00150 space_hosts &operator=(const space_hosts &); 00151 }; 00152 00153 // vim: set ts=8 sw=4 et : 00154 #endif // LIB_SPACE_HOSTS_H