From ba527c7cce6eec8d3ec2bedb3128f432c683f030 Mon Sep 17 00:00:00 2001 From: Daniele Pallastrelli Date: Sat, 16 Feb 2019 12:31:28 +0100 Subject: [PATCH] Bump version to v. 1.0 --- CHANGELOG.md | 4 +- cli/remotecli.h | 137 ------------------------------------------------ cli/server.h | 2 +- 3 files changed, 3 insertions(+), 140 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5055748..4ad204f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Changelog -Current Version: 1.0-alpha +Current Version: 1.0 -## [Unreleased] +## [1.0.0] - 2019-02-16 - Fix Clang 3.6 - 7.0 undefined reference bug - Fix infinite loop on EoF diff --git a/cli/remotecli.h b/cli/remotecli.h index 0ea95e3..39a3b20 100644 --- a/cli/remotecli.h +++ b/cli/remotecli.h @@ -38,143 +38,6 @@ namespace cli { -#if 0 -class TcpCliSession : public Session -{ -public: - TcpCliSession( boost::asio::ip::tcp::socket socket, Cli& _cli, std::function< void(std::ostream&)> exitAction ) : - Session( std::move( socket ) ), - cliSession( _cli, this -> OutStream() ) - { - cliSession.ExitAction( exitAction ); - cliSession.Add( std::make_unique< FuncCmd >( "exit", [this](std::ostream&){ cliSession.Exit(); }, "Terminate this session" ) ); - } - -protected: - - virtual void OnConnect() override - { - // to specify hexadecimal value as chars we use - // the syntax \xVVV - // and the std::string ctor that takes the size, - // so that it's not null-terminated - //std::string msg{ "\x0FF\x0FD\x027", 3 }; - waitAck = true; - //std::string iacDoSuppressGoAhead{ "\x0FF\x0FD\x003", 3 }; - //this -> OutStream() << iacDoSuppressGoAhead << std::flush; - - // https://www.ibm.com/support/knowledgecenter/SSLTBW_1.13.0/com.ibm.zos.r13.hald001/telcmds.htm - - std::string iacDoLineMode{ "\x0FF\x0FD\x022", 3 }; - this -> OutStream() << iacDoLineMode << std::flush; - std::string iacSbLineMode0IacSe{ "\x0FF\x0FA\x022\x001\x000\x0FF\x0F0", 7 }; - this -> OutStream() << iacSbLineMode0IacSe << std::flush; - std::string iacWillEcho{ "\x0FF\x0FB\x001", 3 }; - this -> OutStream() << iacWillEcho << std::flush; -/* - constexpr char IAC = '\x0FF'; // 255 - constexpr char DO = '\x0FD'; // 253 - constexpr char VT100 = '\x030'; // 48 - - this -> OutStream() << IAC << DO << VT100 << std::flush; -*/ - //cliSession.Prompt(); - } - virtual void OnDisconnect() override {} - virtual void OnError() override {} - virtual void OnDataReceived( const std::string& data ) override - { - if (waitAck) - { - if ( data[0] == '\x0FF' ) - { - // TODO - for ( size_t i = 0; i < data.size(); ++i ) - std::cout << static_cast( data[i] & 0xFF ) << ' '; - std::cout << std::endl; - } - waitAck = false; -/* - std::string iacWillSuppressGoAhead{ "\x0FF\x0FB\x003", 3 }; - if ( data == iacWillSuppressGoAhead ) - { - waitAck = false; - cliSession.Prompt(); - } - - else - Disconnect(); -*/ - } - else - { - for ( size_t i = 0; i < data.size(); ++i ) - Feed( data[i ] ); -/* - auto str = data; - // trim trailing spaces - std::size_t endpos = str.find_last_not_of(" \t\r\n"); - if( std::string::npos != endpos ) str = str.substr( 0, endpos+1 ); - - if ( cliSession.Feed( str ) ) cliSession.Prompt(); - else Disconnect(); -*/ - } - } -private: - void Feed( char c ) - { - switch ( c ) - { - case 0: break; - case '\n': - case '\r': - { - // trim trailing spaces - std::size_t endpos = buffer.find_last_not_of(" \t\r\n"); - if( std::string::npos != endpos ) buffer = buffer.substr( 0, endpos+1 ); - if ( cliSession.Feed( buffer ) ) cliSession.Prompt(); - else Disconnect(); - - buffer.clear(); - break; - } - default: - Echo( c ); - buffer += c; - } - } - void Echo( char c ) - { - this -> OutStream() << c << std::flush; - } - - std::string buffer; - CliSession cliSession; - bool waitAck = false; -}; - -class CliServer : public Server -{ -public: - CliServer( boost::asio::io_service& ios, short port, Cli& _cli ) : - Server( ios, port ), - cli( _cli ) - {} - void ExitAction( std::function< void(std::ostream&)> action ) - { - exitAction = action; - } - virtual std::shared_ptr< Session > CreateSession( boost::asio::ip::tcp::socket socket ) override - { - return std::make_shared< TcpCliSession >( std::move( socket ), cli, exitAction ); - } -private: - Cli& cli; - std::function< void(std::ostream&)> exitAction; -}; - -#endif // ******************************************************************************* diff --git a/cli/server.h b/cli/server.h index fa12c97..9bd00f6 100644 --- a/cli/server.h +++ b/cli/server.h @@ -144,7 +144,7 @@ class Server boost::asio::ip::tcp::socket socket; }; -} // namespace +} // namespace cli #endif