nis-util  1.0.D108
lib/space/automap/functor/indirect.cc
Go to the documentation of this file.
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/ac/assert.h>
00020 #include <lib/ac/string.h>
00021 #include <libexplain/output.h>
00022 
00023 #include <lib/space/automap/functor/indirect.h>
00024 #include <lib/space/automap.h>
00025 
00026 
00027 space_automap_functor_indirect::~space_automap_functor_indirect()
00028 {
00029 }
00030 
00031 
00032 space_automap_functor_indirect::space_automap_functor_indirect(
00033     space_automap *a_context
00034 ) :
00035     context(a_context)
00036 {
00037     assert(context);
00038 }
00039 
00040 
00041 void
00042 space_automap_functor_indirect::walk(const space_automap_row::pointer &rp)
00043 {
00044     const mount_point &mp = rp->get_mount_point();
00045     if (mp.is_absolute())
00046     {
00047         rcstring suggest = mp.get_mount_point();
00048         suggest = suggest.substr(1, suggest.size() - 1);
00049         if (suggest.empty())
00050             suggest = ".";
00051         if (strchr(suggest.c_str(), '/'))
00052             suggest = suggest.replace("/", "-", suggest.size());
00053         context->error
00054         (
00055             mp.get_source_location(),
00056             "mount points must be relative for indirect maps, "
00057                 "suggest %s instead",
00058             suggest.quote_c().c_str()
00059         );
00060         return;
00061     }
00062     if (strchr(mp.get_mount_point().c_str(), '/'))
00063     {
00064         rcstring suggest = mp.get_mount_point();
00065         suggest = suggest.replace("/", "-", suggest.size());
00066         context->error
00067         (
00068             mp.get_source_location(),
00069             "indirect map keys may not contain slash, suggest %s instead",
00070             suggest.quote_c().c_str()
00071         );
00072     }
00073 }
00074 
00075 
00076 // vim: set ts=8 sw=4 et :