3 #include "telnetpp/element.hpp"
5 namespace telnetpp::detail {
10 template <
class Continuation>
11 constexpr
void generate_escaped(telnetpp::bytes data, Continuation &&cont)
13 telnetpp::bytes::iterator begin = data.begin();
14 telnetpp::bytes::iterator current = data.begin();
15 telnetpp::bytes::iterator end = data.end();
21 while (current != end)
23 if (*current == telnetpp::iac)
25 cont({begin, current + 1});
41 template <
class Continuation>
44 telnetpp::byte
const data[] = {telnetpp::iac, cmd.
value()};
52 template <
class Continuation>
53 constexpr
void generate_negotiation(
56 telnetpp::byte
const data[] = {
65 template <
class Continuation>
66 constexpr
void generate_subnegotiation(
69 telnetpp::byte
const preamble[] = {
70 telnetpp::iac, telnetpp::sb, sub.
option()};
72 constexpr telnetpp::byte
const postamble[] = {telnetpp::iac, telnetpp::se};
75 generate_escaped(sub.
content(), cont);
A class that encapsulates the value of a Telnet command.
Definition: command.hpp:13
constexpr command_type value() const noexcept
Returns the value of the command.
Definition: command.hpp:25
A class that encapsulates a Telnet negotiation.
Definition: negotiation.hpp:15
constexpr option_type option_code() const noexcept
Returns the option code (e.g. echo, naws) of this negotiation.
Definition: negotiation.hpp:40
constexpr negotiation_type request() const noexcept
Returns the request (will, wont, do, dont) of this negotiation.
Definition: negotiation.hpp:32
A class that encapsulates a Telnet subnegotiation.
Definition: subnegotiation.hpp:14
constexpr bytes content() const noexcept
Returns the content for this subnegotiation.
Definition: subnegotiation.hpp:35
constexpr option_type option() const noexcept
Returns the option for this subnegotiation.
Definition: subnegotiation.hpp:27