nis-util  1.0.D108
nis-util-netmasks/space/netmasks/slurp/check.cc
Go to the documentation of this file.
00001 //
00002 // nis-util - NIS Administration Utilities
00003 // Copyright (C) 2002, 2008, 2009, 2011, 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 #include <lib/ac/string.h>
00020 #include <arpa/inet.h>
00021 #include <netinet/in.h>
00022 #include <lib/ac/stdio.h>
00023 
00024 #include <lib/space/networks/slurp.h>
00025 
00026 #include <nis-util-netmasks/space/netmasks/slurp/check.h>
00027 
00028 
00029 space_netmasks_slurp_check::~space_netmasks_slurp_check()
00030 {
00031 }
00032 
00033 
00034 space_netmasks_slurp_check::space_netmasks_slurp_check(
00035     const rcstring &a_filename,
00036     const space_networks_slurp::pointer &a_networks
00037 ) :
00038     space_netmasks_slurp(a_filename),
00039     networks(a_networks)
00040 {
00041     assert(networks);
00042 }
00043 
00044 
00045 space_netmasks_slurp_check::pointer
00046 space_netmasks_slurp_check::create(const rcstring &a_filename,
00047     const space_networks_slurp::pointer &a_networks)
00048 {
00049     return pointer(new space_netmasks_slurp_check(a_filename, a_networks));
00050 }
00051 
00052 
00053 void
00054 space_netmasks_slurp_check::process(const record::pointer &rp)
00055 {
00056     //
00057     // Do all the usual processing.
00058     //
00059     space_netmasks_slurp::process(rp);
00060 
00061     //
00062     // Make sure each network mask has a corresponding network name.
00063     //
00064     if (!networks->query_by_address(rp->get_number()))
00065     {
00066         error
00067         (
00068             rp->get_source_location(),
00069             "network %s not named in networks map",
00070             rp->get_number().quote_c().c_str()
00071         );
00072     }
00073 }
00074 
00075 
00076 // vim: set ts=8 sw=4 et :