1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef LIBRARIES_NACL_IO_DEVFS_TTY_NODE_H_
6 #define LIBRARIES_NACL_IO_DEVFS_TTY_NODE_H_
13 #include <ppapi/c/pp_var.h>
15 #include "nacl_io/char_node.h"
16 #include "nacl_io/ioctl.h"
17 #include "nacl_io/ostermios.h"
21 class TtyNode
: public CharNode
{
23 explicit TtyNode(Filesystem
* filesystem
);
25 virtual EventEmitter
* GetEventEmitter();
27 virtual Error
VIoctl(int request
, va_list args
);
29 virtual Error
Read(const HandleAttr
& attr
,
34 virtual Error
Write(const HandleAttr
& attr
,
39 virtual Error
Tcgetattr(struct termios
* termios_p
);
40 virtual Error
Tcsetattr(int optional_actions
,
41 const struct termios
* termios_p
);
43 virtual Error
Isatty() { return 0; }
46 ScopedEventEmitter emitter_
;
48 Error
ProcessInput(PP_Var var
);
49 Error
ProcessInput(const char* buffer
, size_t num_bytes
);
50 Error
Echo(const char* string
, int count
);
53 std::deque
<char> input_buffer_
;
54 struct termios termios_
;
56 /// Current height of terminal in rows. Set via ioctl(2).
58 /// Current width of terminal in columns. Set via ioctl(2).
61 // Output handler for TTY. This is set via ioctl(2).
62 struct tioc_nacl_output output_handler_
;
63 // Lock to protect output_handler_. This lock gets aquired whenever
64 // output_handler_ is used or set.
65 sdk_util::SimpleLock output_lock_
;
68 } // namespace nacl_io
70 #endif // LIBRARIES_NACL_IO_DEVFS_TTY_NODE_H_