ladybird/Servers/TelnetServer/Parser.h
Conrad Pankoff 040947ee47 TelnetServer: Implement basic telnet server
Fixes #407

Depends on #530 to run reliably.
2019-09-08 10:56:34 +02:00

33 lines
554 B
C++

#pragma once
#include <AK/Function.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <AK/Types.h>
#include "Command.h"
#define IAC 0xff
class Parser {
public:
Function<void(const Command&)> on_command;
Function<void(const StringView&)> on_data;
Function<void()> on_error;
void write(const StringView&);
protected:
enum State {
Free,
ReadCommand,
ReadSubcommand,
Error,
};
void write(const String& str);
private:
State m_state { State::Free };
u8 m_command { 0 };
};