Executor.cci
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 /** \file
15  \brief Executor inline non-template implementation */
16 
17 //#include "Executor.ih"
18 
19 // Custom includes
20 
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::console::Executor
26 
27 prefix_ senf::console::Executor::Executor()
28  : root_(senf::console::root().thisptr()), cwd_ (), oldCwd_ (),
29  autocd_ (false), autocomplete_ (false)
30 {
31  cwd_.push_back(root_);
32 }
33 
34 prefix_ void senf::console::Executor::operator()(std::ostream & output,
35  ParseCommandInfo const & command)
36 {
37  return execute(output, command);
38 }
39 
40 prefix_ void senf::console::Executor::cwd(DirectoryNode & dir)
41 {
42  cwd_.clear();
43  cwd_.push_back(dir.thisptr());
44  oldCwd_ = cwd_;
45  dirstack_.clear();
46 }
47 
48 
49 prefix_ bool senf::console::Executor::autocd()
50  const
51 {
52  return autocd_;
53 }
54 
55 prefix_ senf::console::Executor & senf::console::Executor::autocd(bool v)
56 {
57  autocd_ = v;
58  return *this;
59 }
60 
61 prefix_ bool senf::console::Executor::autocomplete()
62  const
63 {
64  return autocomplete_;
65 }
66 
67 prefix_ senf::console::Executor & senf::console::Executor::autocomplete(bool v)
68 {
69  autocomplete_ = true;
70  return *this;
71 }
72 
73 prefix_ senf::console::DirectoryNode & senf::console::Executor::chroot()
74  const
75 {
76  return *root_;
77 }
78 
79 prefix_ senf::console::Executor & senf::console::Executor::chroot(DirectoryNode & node)
80 {
81  root_ = node.thisptr();
82  cwd_.clear();
83  cwd_.push_back(root_);
84  oldCwd_ = cwd_;
85  return *this;
86 }
87 
88 prefix_ senf::console::Executor & senf::console::Executor::policy(SecurityPolicy policy)
89 {
90  policy_ = policy;
91  return *this;
92 }
93 
94 prefix_ bool senf::console::Executor::skipping()
95  const
96 {
97  return cwd_.empty();
98 }
99 
100 //-/////////////////////////////////////////////////////////////////////////////////////////////////
101 #undef prefix_
102 
103 
104 // Local Variables:
105 // mode: c++
106 // fill-column: 100
107 // comment-column: 40
108 // c-file-style: "senf"
109 // indent-tabs-mode: nil
110 // ispell-local-dictionary: "american"
111 // compile-command: "scons -u test"
112 // End: