interaction.ha (632B)
1 use bufio; 2 use encoding::utf8; 3 use io; 4 use os; 5 use strings; 6 use types; 7 use unix::signal; 8 9 type InteractionError = !( 10 Quit 11 | io::EOF 12 | UnexpectedEOF 13 | encoding::utf8::invalid 14 | io::error 15 ); 16 17 type Quit = !void; 18 19 type UnexpectedEOF = !io::EOF; 20 21 fn scanline(s: *Session) (str | InteractionError) = { 22 match (bufio::scan_line(s.input)?) { 23 case let s: const str => 24 return s; 25 case io::EOF => 26 return UnexpectedEOF; 27 }; 28 }; 29 30 fn handle_signals() void = { 31 signal::handle(signal::sig::INT, &sig_ignore); 32 signal::handle(signal::sig::QUIT, &sig_ignore); 33 }; 34 35 fn sig_ignore(s: signal::sig, i: *signal::siginfo, u: *opaque) void = void;