Skip to content

Commit

Permalink
Bump version to v. 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele77 committed Feb 16, 2019
1 parent 8fd6b23 commit ba527c7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 140 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
137 changes: 0 additions & 137 deletions cli/remotecli.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>( 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

// *******************************************************************************

Expand Down
2 changes: 1 addition & 1 deletion cli/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Server
boost::asio::ip::tcp::socket socket;
};

} // namespace
} // namespace cli

#endif

0 comments on commit ba527c7

Please sign in to comment.