RetroZilla/extensions/xmlterm/scripts/xtst

44 lines
1.1 KiB
Plaintext
Raw Normal View History

2015-10-21 05:03:22 +02:00
#!/usr/bin/perl
# Script to test remote cookie handling
use strict;
use POSIX qw(:termios_h);
my ($term, $oterm, $echo, $noecho, $fd_stdin);
$fd_stdin = fileno(STDIN);
$term = POSIX::Termios->new();
$term->getattr($fd_stdin);
$oterm = $term->getlflag();
$echo = ECHO | ECHOK | ICANON;
$noecho = $oterm & ~$echo;
my ($old_vmin, $old_vtime);
$old_vmin = $term->getcc(VMIN);
$old_vtime = $term->getcc(VTIME);
$term->setlflag($noecho); # Suppress input echo
$term->setcc(VMIN, 0); # Minimum characters to read
$term->setcc(VTIME, 30); # Wait in units of 0.1 seconds
$term->setattr($fd_stdin, TCSANOW);
print "VMIN,VTIME = ", $old_vmin, ",", $old_vtime, "\n";
print "VMIN,VTIME = ", $term->getcc(VMIN), ",", $term->getcc(VTIME), "\n";
print "\e{A\n"; # HTML stream escape sequence
my $key = "";
my $key2 = "";
print "nread=", sysread(STDIN, $key, 1), "\n";
sysread(STDIN, $key2, 21);
print "--> $key2\n";
$term->setlflag($echo);
$term->setcc(VMIN, $old_vmin);
$term->setcc(VTIME, $old_vtime);
$term->setattr($fd_stdin, TCSANOW);