2019-01-15 00:30:19 -05:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-22 23:13:17 -05:00
|
|
|
#include <Kernel/CharacterDevice.h>
|
2019-01-15 00:30:19 -05:00
|
|
|
#include "DoubleBuffer.h"
|
|
|
|
|
|
|
|
class SlavePTY;
|
|
|
|
|
|
|
|
class MasterPTY final : public CharacterDevice {
|
|
|
|
public:
|
|
|
|
explicit MasterPTY(unsigned index);
|
|
|
|
virtual ~MasterPTY() override;
|
|
|
|
|
2019-01-20 20:33:01 -05:00
|
|
|
// ^CharacterDevice
|
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);
|
2019-01-24 18:13:54 -05:00
|
|
|
bool can_write_from_slave() const;
|
2019-01-15 00:30:19 -05:00
|
|
|
|
|
|
|
private:
|
2019-01-20 20:33:01 -05:00
|
|
|
// ^CharacterDevice
|
|
|
|
virtual const char* class_name() const override { return "MasterPTY"; }
|
|
|
|
|
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;
|
|
|
|
};
|