switch to new MPL based Fraunhofer FOKUS Public License
[senf.git] / senf / Utils / Console / Executor.cc
index e9649c4..2f45483 100644 (file)
@@ -1,24 +1,29 @@
 // $Id$
 //
-// Copyright (C) 2008 
+// Copyright (C) 2008
 // Fraunhofer Institute for Open Communication Systems (FOKUS)
-// Competence Center NETwork research (NET), St. Augustin, GERMANY
-//     Stefan Bund <g0dil@berlios.de>
 //
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
+// The contents of this file are subject to the Fraunhofer FOKUS Public License
+// Version 1.0 (the "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at 
+// http://senf.berlios.de/license.html
 //
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// The Fraunhofer FOKUS Public License Version 1.0 is based on, 
+// but modifies the Mozilla Public License Version 1.1.
+// See the full license text for the amendments.
 //
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the
-// Free Software Foundation, Inc.,
-// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+// Software distributed under the License is distributed on an "AS IS" basis, 
+// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
+// for the specific language governing rights and limitations under the License.
+//
+// The Original Code is Fraunhofer FOKUS code.
+//
+// The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. 
+// (registered association), Hansastraße 27 c, 80686 Munich, Germany.
+// All Rights Reserved.
+//
+// Contributor(s):
+//   Stefan Bund <g0dil@berlios.de>
 
 /** \file
     \brief Executor non-inline non-template implementation */
 #include <boost/preprocessor/stringize.hpp>
 #include <senf/Utils/senfassert.hh>
 #include <senf/Utils/Range.hh>
-#include "Server.hh"
 #include "senf/Utils/IgnoreValue.hh"
+#include "Server.hh"
 
 //#include "Executor.mpp"
 #define prefix_
-///////////////////////////////cc.p////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 
 namespace {
 
@@ -49,16 +54,16 @@ namespace {
             return token.value();
         }
     };
-    
+
 }
 
-///////////////////////////////////////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 // senf::console::Executor
 
 prefix_ senf::console::DirectoryNode & senf::console::Executor::cwd()
     const
 {
-    SENF_ASSERT( ! cwd_.empty() );
+    SENF_ASSERT( ! cwd_.empty(), "Internal error: CWD history empty ?" );
     while (cwd_.size()>1 && (cwd_.back().expired() || ! cwd_.back().lock()->active()))
         cwd_.pop_back();
     return * cwd_.back().lock();
@@ -87,7 +92,7 @@ prefix_ void senf::console::Executor::execute(std::ostream & output,
 
     try {
         switch(command.builtin()) {
-        case ParseCommandInfo::NoBuiltin : 
+        case ParseCommandInfo::NoBuiltin :
             if (skipping())
                 return;
             exec(output, command);
@@ -105,7 +110,7 @@ prefix_ void senf::console::Executor::execute(std::ostream & output,
                     "'cd' cannot be skipped (don't use 'cd' in conf-files)");
             }
             break;
-            
+
         case ParseCommandInfo::BuiltinLS :
             if (skipping())
                 break;
@@ -134,12 +139,12 @@ prefix_ void senf::console::Executor::execute(std::ostream & output,
             else
                 exec(output, command);
             break;
-            
+
         case ParseCommandInfo::BuiltinPOPD :
             // The parser ensures, we have no arguments
             popd();
             break;
-            
+
         case ParseCommandInfo::BuiltinEXIT :
             if (skipping())
                 break;
@@ -261,7 +266,7 @@ prefix_ void senf::console::Executor::ll(std::ostream & output,
 {
 #   define HELP_COLUMN 28
 
-    unsigned width (senf::console::Client::getWidth(output, 80u, 60u)-(HELP_COLUMN+1));
+    unsigned width (Client::getWidth(output, 80u, 60u)-(HELP_COLUMN+1));
     Path dir (cwd_);
     traverseDirectory(path, dir);
     DirectoryNode & node (*dir.back().lock());
@@ -287,7 +292,7 @@ namespace {
 
     typedef std::map<senf::console::DirectoryNode*,std::string> NodesMap;
 
-    void dolr(std::ostream & output, unsigned width, NodesMap & nodes, std::string const & base, 
+    void dolr(std::ostream & output, unsigned width, NodesMap & nodes, std::string const & base,
               unsigned level, senf::console::DirectoryNode & node)
     {
         boost::format fmt ("%s%s%s  %|" BOOST_PP_STRINGIZE(HELP_COLUMN) "t|%s\n");
@@ -301,7 +306,7 @@ namespace {
                 NodesMap::iterator j (nodes.find(&subnode));
                 if (j == nodes.end()) {
                     output << fmt
-                        % pad % i->first 
+                        % pad % i->first
                         % ( i->second->isDirectory() ? "/" : i->second->isLink() ? "@" : "" )
                         % i->second->shorthelp().substr(0,width);
                     std::string subbase (base);
@@ -311,12 +316,12 @@ namespace {
                     nodes.insert(std::make_pair(&subnode, subbase));
                     dolr(output, width, nodes, subbase, level+1, subnode);
                 } else
-                    output << pad << i->first 
+                    output << pad << i->first
                            << ( i->second->isDirectory() ? "/" : i->second->isLink() ? "@" : "" )
                            << " -> " << j->second << "\n";
             } else {
                 output << fmt
-                    % pad % i->first 
+                    % pad % i->first
                     % ( i->second->isDirectory() ? "/" : i->second->isLink() ? "@" : "" )
                     % i->second->shorthelp().substr(0,width);
             }
@@ -332,7 +337,7 @@ prefix_ void senf::console::Executor::lr(std::ostream & output,
     traverseDirectory(path, dir);
     DirectoryNode & node (*dir.back().lock());
     NodesMap nodes;
-    dolr(output, senf::console::Client::getWidth(output, 80u, 60u)-(HELP_COLUMN+1), 
+    dolr(output, Client::getWidth(output, 80u, 60u)-(HELP_COLUMN+1),
          nodes, "", 0, node);
 }
 
@@ -471,7 +476,7 @@ prefix_ void senf::console::senf_console_format_value(DirectoryNode::ptr value,
         os << "<Null Directory>";
 }
 
-///////////////////////////////cc.e////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
 #undef prefix_
 //#include "Executor.mpp"