2019-01-15 00:30:19 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <VirtualFileSystem/CharacterDevice.h>
|
|
|
|
#include "DoubleBuffer.h"
|
|
|
|
|
|
|
|
class SlavePTY;
|
|
|
|
|
|
|
|
class MasterPTY final : public CharacterDevice {
|
|
|
|
public:
|
|
|
|
explicit MasterPTY(unsigned index);
|
|
|
|
virtual ~MasterPTY() override;
|
|
|
|
|
2019-01-15 18:20:38 -05:00
|
|
|
virtual ssize_t read(Process&, byte*, size_t) override;
|
|
|
|
virtual ssize_t write(Process&, const byte*, size_t) override;
|
2019-01-15 18:10:13 -05:00
|
|
|
virtual bool can_read(Process&) const override;
|
2019-01-15 03:17:22 -05:00
|
|
|
virtual bool can_write(Process&) const override;
|
2019-01-15 00:30:19 -05:00
|
|
|
virtual bool is_master_pty() const override { return true; }
|
|
|
|
|
2019-01-16 07:36:10 -05:00
|
|
|
unsigned index() const { return m_index; }
|
2019-01-15 00:30:19 -05:00
|
|
|
String pts_name() const;
|
|
|
|
void on_slave_write(const byte*, size_t);
|
|
|
|
|
|
|
|
private:
|
2019-01-15 20:11:50 -05:00
|
|
|
SlavePTY& m_slave;
|
2019-01-15 00:30:19 -05:00
|
|
|
unsigned m_index;
|
|
|
|
DoubleBuffer m_buffer;
|
|
|
|
};
|