source: trunk/third/perl/h2pl/cbreak.pl @ 9009

Revision 9009, 574 bytes checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r9008, which included commits to RCS files with non-trunk default branches.
Line 
1$sgttyb_t   = 'C4 S';
2
3sub cbreak {
4    &set_cbreak(1);
5}
6
7sub cooked {
8    &set_cbreak(0);
9}
10
11sub set_cbreak {
12    local($on) = @_;
13
14    require 'sizeof.ph';
15    require 'sys/ioctl.ph';
16
17    ioctl(STDIN,&TIOCGETP,$sgttyb)
18        || die "Can't ioctl TIOCGETP: $!";
19
20    @ary = unpack($sgttyb_t,$sgttyb);
21    if ($on) {
22        $ary[4] |= &CBREAK;
23        $ary[4] &= ~&ECHO;
24    } else {
25        $ary[4] &= ~&CBREAK;
26        $ary[4] |= &ECHO;
27    }
28    $sgttyb = pack($sgttyb_t,@ary);
29    ioctl(STDIN,&TIOCSETP,$sgttyb)
30            || die "Can't ioctl TIOCSETP: $!";
31
32}
33
341;
Note: See TracBrowser for help on using the repository browser.