nis-util
1.0.D108
|
00001 // 00002 // nis-util - NIS Administration Utilities 00003 // Copyright (C) 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 along 00016 // with this program. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 00019 #include <lib/output.h> 00020 #include <lib/space/auto_master/row/normal.h> 00021 #include <lib/space/automap/functor/indirect.h> 00022 00023 00024 space_auto_master_row_normal::~space_auto_master_row_normal() 00025 { 00026 } 00027 00028 00029 space_auto_master_row_normal::space_auto_master_row_normal( 00030 const mount_point &a_mount_point, 00031 const rcstring &field2, 00032 const rcstring &a_options 00033 ) : 00034 space_auto_master_row(a_mount_point, a_options), 00035 maptype(extract_maptype(field2)), 00036 mapname(extract_mapname(field2)) 00037 { 00038 assert(!mapname.empty()); 00039 } 00040 00041 00042 space_auto_master_row_normal::pointer 00043 space_auto_master_row_normal::create(const mount_point &a_mount_point, 00044 const rcstring &field2, const rcstring &a_options) 00045 { 00046 return 00047 pointer 00048 ( 00049 new space_auto_master_row_normal(a_mount_point, field2, a_options) 00050 ); 00051 } 00052 00053 00054 void 00055 space_auto_master_row_normal::print(const output::pointer &op) 00056 const 00057 { 00058 op->put(get_mount_point().get_mount_point()); 00059 op->put(' '); 00060 if (maptype != "yp" && maptype != "nisplus") 00061 { 00062 op->put(maptype); 00063 op->put(':'); 00064 } 00065 op->put(mapname); 00066 if (!get_options().empty()) 00067 { 00068 op->put(' '); 00069 op->put(get_options()); 00070 } 00071 op->put('\n'); 00072 } 00073 00074 00075 void 00076 space_auto_master_row_normal::load_map(const rcstring &filename, 00077 const space_hosts_slurp::pointer &hosts) 00078 { 00079 map = space_automap::create(filename); 00080 space_automap_functor_indirect inspector(map.get()); 00081 map->read_and_process(inspector, hosts.get()); 00082 //map->close(); 00083 } 00084 00085 00086 bool 00087 space_auto_master_row_normal::has_associated_file(void) 00088 const 00089 { 00090 // The "file" map type means a file on the 00091 // client, but this is on the server. 00092 return (maptype == "yp" || maptype == "nisplus"); 00093 } 00094 00095 00096 rcstring 00097 space_auto_master_row_normal::get_filename(void) 00098 const 00099 { 00100 return mapname; 00101 } 00102 00103 00104 // vim: set ts=8 sw=4 et :