8 Console::Console(Stream s):
11 mode = (stream==CIN ? M_READ : M_WRITE);
19 void Console::set_block(bool b)
21 adjust_mode(mode, M_NONBLOCK, !b);
22 sys_set_blocking(handle, b);
25 void Console::set_inherit(bool i)
27 adjust_mode(mode, M_INHERIT, i);
28 sys_set_inherit(handle, i);
31 unsigned Console::do_write(const char *buf, unsigned len)
33 check_access(M_WRITE);
35 return sys_write(handle, buf, len);
38 unsigned Console::do_read(char *buf, unsigned len)
42 unsigned ret = sys_read(handle, buf, len);
49 const Handle &Console::get_handle(Mode m)
55 Console &Console::instance(Stream s)
57 static Console in(CIN);
58 static Console out(COUT);
59 static Console err(CERR);
64 case COUT: return out;
65 case CERR: return err;
68 throw invalid_argument("Console::instance");
71 Console &cin = Console::instance(Console::CIN);
72 Console &cout = Console::instance(Console::COUT);
73 Console &cerr = Console::instance(Console::CERR);