4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief Server internal header */
30 #include <boost/iostreams/concepts.hpp>
31 #include <boost/iostreams/stream.hpp>
33 ///////////////////////////////ih.p////////////////////////////////////////
43 /** \brief Internal: Nonblocking boost::iostreams::sink
45 The sink discards data if the output socket would.
47 class NonblockingSocketSink
48 : public boost::iostreams::sink
51 typedef ClientSocketHandle<
52 MakeSocketPolicy<StreamFramingPolicy,
54 ConnectedCommunicationPolicy>::policy > Handle;
56 NonblockingSocketSink(Client & client);
57 std::streamsize write(const char * s, std::streamsize n);
59 Client & client() const;
65 typedef boost::iostreams::stream<NonblockingSocketSink> NonblockingSocketOStream;
67 typedef senf::ServerSocketHandle<
68 senf::MakeSocketPolicy< senf::TCPv4SocketProtocol::Policy,
69 senf::UnspecifiedAddressingPolicy>::policy > ServerHandle;
71 /** \brief Internal: Generic client interface
73 The ClientReader encapsulates the interaction of a single network client with the user: It
74 manages prompt display and reading an interactive command.
79 typedef ServerHandle::ClientSocketHandle ClientHandle;
81 virtual ~ClientReader() = 0;
83 Client & client() const;
84 std::string promptString() const;
85 ClientHandle handle() const;
86 std::ostream & stream() const;
89 void handleInput(std::string const & input) const;
93 void translate(std::string & data);
96 ClientReader(Client & client);
99 virtual void v_disablePrompt() = 0;
100 virtual void v_enablePrompt() = 0;
101 virtual void v_translate(std::string & data) = 0;
106 /** \brief Internal: Primitive ClientReader implementation
108 This implementation uses the cooked telnet mode to read lines from the console. It does not
109 support explicit line editing or any other advanced features.
111 class DumbClientReader
112 : public ClientReader
115 DumbClientReader(Client & client);
118 virtual void v_disablePrompt();
119 virtual void v_enablePrompt();
120 virtual void v_translate(std::string & data);
122 void clientData(senf::ReadHelper<ClientHandle>::ptr helper);
132 ///////////////////////////////ih.e////////////////////////////////////////
139 // comment-column: 40
140 // c-file-style: "senf"
141 // indent-tabs-mode: nil
142 // ispell-local-dictionary: "american"
143 // compile-command: "scons -u test"