IO-Stty-0.03000750000765000024 011370451211 12110 5ustar00toddstaff000000000000IO-Stty-0.03/Build.PL000444000765000024 154011370451211 13546 0ustar00toddstaff000000000000use strict; use warnings; use Module::Build; my $builder = Module::Build->new( module_name => 'IO::Stty', author => 'Austin Schutz ', dist_version_from => 'lib/IO/Stty.pm', abstract_from => 'lib/IO/Stty.pm', dist_abstract => 'lib/IO/Stty.pm', license => 'perl', build_requires => { 'Test::More' => '0', 'Module::Build' => '0.35', }, add_to_cleanup => ['IO-Stty-*' ], script_files => ['scripts/stty.pl'], meta_merge => { resources => { homepage => 'http://github.com/toddr/IO-Stty', # bugtracker => 'https://rt.cpan.org/NoAuth/Bugs.html?Dist=IO-Stty', MailingList => 'mailto:toddr@cpan.org', repository => 'git://github.com/toddr/IO-Stty.git', } } ); $builder->create_build_script; IO-Stty-0.03/Changes000444000765000024 35211370451211 13525 0ustar00toddstaff000000000000Revision history for Perl extension IO::Stty 0.02_01 Tue Mar 23 2010 - Re-vamp module to Module::Build - stty.txt merged into POD so it shows up on CPAN - add Changes log - basic tests - die if no parameters passed to stty IO-Stty-0.03/META.yml000444000765000024 125011370451211 13521 0ustar00toddstaff000000000000--- abstract: lib/IO/Stty.pm author: - 'Austin Schutz (Initial version and maintenance)' - 'Todd Rinaldo (Maintenance)' build_requires: Module::Build: 0.35 Test::More: 0 configure_requires: Module::Build: 0.36 generated_by: 'Module::Build version 0.3607' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: IO-Stty provides: IO::Stty: file: lib/IO/Stty.pm version: 0.03 resources: MailingList: mailto:toddr@cpan.org homepage: http://github.com/toddr/IO-Stty license: http://dev.perl.org/licenses/ repository: git://github.com/toddr/IO-Stty.git version: 0.03 IO-Stty-0.03/README000444000765000024 1614711370451211 13163 0ustar00toddstaff000000000000NAME Change and print terminal line settings SYNOPSIS # calling the script directly stty.pl [setting...] stty.pl {-a,-g,-v,--version} # Calling Stty module use IO::Stty; IO::Stty::stty(\*TTYHANDLE, @modes); use IO::Stty; $old_mode=IO::Stty::stty(\*STDIN,'-g'); # Turn off echoing. IO::Stty::stty(\*STDIN,'-echo'); # Do whatever.. grab input maybe? $read_password = <>; # Now restore the old mode. IO::Stty::stty(\*STDIN,$old_mode); # What settings do we have anyway? print IO::Stty::stty(\*STDIN,'-a'); DESCRIPTION This is the PERL POSIX compliant stty. INTRO This has not been tailored to the IO::File stuff but will work with it as indicated. Before you go futzing with term parameters it's a good idea to grab the current settings and restore them when you finish. stty accepts the following non-option arguments that change aspects of the terminal line operation. A `[-]' before a capability means that it can be turned off by preceding it with a `-'. stty parameters Control settings [-]parenb Generate parity bit in output and expect parity bit in input. [-]parodd Set odd parity (even with `-'). cs5 cs6 cs7 cs8 Set character size to 5, 6, 7, or 8 bits. [-]hupcl [-]hup Send a hangup signal when the last process closes the tty. [-]cstopb Use two stop bits per character (one with `-'). [-]cread Allow input to be received. [-]clocal Disable modem control signals. Input settings [-]ignbrk Ignore break characters. [-]brkint Breaks cause an interrupt signal. [-]ignpar Ignore characters with parity errors. [-]parmrk Mark parity errors (with a 255-0-character sequence). [-]inpck Enable input parity checking. [-]istrip Clear high (8th) bit of input characters. [-]inlcr Translate newline to carriage return. [-]igncr Ignore carriage return. [-]icrnl Translate carriage return to newline. [-]ixon Enable XON/XOFF flow control. [-]ixoff Enable sending of stop character when the system input buffer is almost full, and start character when it becomes almost empty again. Output settings [-]opost Postprocess output. Local settings [-]isig Enable interrupt, quit, and suspend special characters. [-]icanon Enable erase, kill, werase, and rprnt special characters. [-]echo Echo input characters. [-]echoe, [-]crterase Echo erase characters as backspace-space-backspace. [-]echok Echo a newline after a kill character. [-]echonl Echo newline even if not echoing other characters. [-]noflsh Disable flushing after interrupt and quit special characters. * Though this claims non-posixhood it is supported by the perl POSIX.pm. [-]tostop (np) Stop background jobs that try to write to the terminal. Combination settings ek Reset the erase and kill special characters to their default values. sane Same as: cread -ignbrk brkint -inlcr -igncr icrnl -ixoff opost isig icanon echo echoe echok -echonl -noflsh -tostop also sets all special characters to their default values. [-]cooked Same as: brkint ignpar istrip icrnl ixon opost isig icanon plus sets the eof and eol characters to their default values if they are the same as the min and time characters. With `-', same as raw. [-]raw Same as: -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -opost -isig -icanon min 1 time 0 With `-', same as cooked. [-]pass8 Same as: -parenb -istrip cs8 With `-', same as parenb istrip cs7. dec Same as: echoe echoctl echoke -ixany Also sets the interrupt special character to Ctrl-C, erase to Del, and kill to Ctrl-U. Special characters The special characters' default values vary from system to system. They are set with the syntax `name value', where the names are listed below and the value can be given either literally, in hat notation (`^c'), or as an integer which may start with `0x' to indicate hexadecimal, `0' to indicate octal, or any other digit to indicate decimal. Giving a value of `^-' or `undef' disables that special character. intr Send an interrupt signal. quit Send a quit signal. erase Erase the last character typed. kill Erase the current line. eof Send an end of file (terminate the input). eol End the line. start Restart the output after stopping it. stop Stop the output. susp Send a terminal stop signal. Special settings min N Set the minimum number of characters that will satisfy a read until the time value has expired, when -icanon is set. time N Set the number of tenths of a second before reads time out if the min number of characters have not been read, when -icanon is set. N Set the input and output speeds to N. N can be one of: 0 50 75 110 134 134.5 150 200 300 600 1200 1800 2400 4800 9600 19200 38400 exta extb. exta is the same as 19200; extb is the same as 38400. 0 hangs up the line if -clocal is set. OPTIONS -a Print all current settings in human-readable form. -g Print all current settings in a form that can be used as an argument to another stty command to restore the current settings. -v,--version Print version info. Direct Subroutines stty() IO::Stty::stty(\*STDIN, @params); From comments: I'm not feeling very inspired about this. Terminal parameters are obscure and boring. Basically what this will do is get the current setting, take the parameters, modify the setting and write it back. Zzzz. This is not especially efficent and probably not too fast. Assuming the POSIX spec has been implemented properly it should mostly work. show_me_the_crap() Needs documentation AUTHOR Austin Schutz (Initial version and maintenance) Todd Rinaldo (Maintenance) BUGS This is use at your own risk software. Do anything you want with it except blame me for it blowing up your machine because it's full of bugs. See above for what functions are supported. It's mostly standard POSIX stuff. If any of the settings are wrong and you actually know what some of these extremely arcane settings (like what 'sane' should be in POSIX land) really should be, please open an RT ticket. ACKNOWLEDGEMENTS None COPYRIGHT & LICENSE Copyright 1997 Austin Schutz, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. IO-Stty-0.03/lib000750000765000024 011370451211 12656 5ustar00toddstaff000000000000IO-Stty-0.03/lib/IO000750000765000024 011370451211 13165 5ustar00toddstaff000000000000IO-Stty-0.03/lib/IO/Stty.pm000444000765000024 5113511370451211 14655 0ustar00toddstaff000000000000package IO::Stty; use strict; use warnings; use POSIX; our $VERSION='0.03'; =head1 NAME Change and print terminal line settings =head1 SYNOPSIS # calling the script directly stty.pl [setting...] stty.pl {-a,-g,-v,--version} # Calling Stty module use IO::Stty; IO::Stty::stty(\*TTYHANDLE, @modes); use IO::Stty; $old_mode=IO::Stty::stty(\*STDIN,'-g'); # Turn off echoing. IO::Stty::stty(\*STDIN,'-echo'); # Do whatever.. grab input maybe? $read_password = <>; # Now restore the old mode. IO::Stty::stty(\*STDIN,$old_mode); # What settings do we have anyway? print IO::Stty::stty(\*STDIN,'-a'); =head1 DESCRIPTION This is the PERL POSIX compliant stty. =head1 INTRO This has not been tailored to the IO::File stuff but will work with it as indicated. Before you go futzing with term parameters it's a good idea to grab the current settings and restore them when you finish. stty accepts the following non-option arguments that change aspects of the terminal line operation. A `[-]' before a capability means that it can be turned off by preceding it with a `-'. =head1 stty parameters =head2 Control settings =over 4 =item [-]parenb Generate parity bit in output and expect parity bit in input. =item [-]parodd Set odd parity (even with `-'). =item cs5 cs6 cs7 cs8 Set character size to 5, 6, 7, or 8 bits. =item [-]hupcl [-]hup Send a hangup signal when the last process closes the tty. =item [-]cstopb Use two stop bits per character (one with `-'). =item [-]cread Allow input to be received. =item [-]clocal Disable modem control signals. =back =head2 Input settings =over 4 =item [-]ignbrk Ignore break characters. =item [-]brkint Breaks cause an interrupt signal. =item [-]ignpar Ignore characters with parity errors. =item [-]parmrk Mark parity errors (with a 255-0-character sequence). =item [-]inpck Enable input parity checking. =item [-]istrip Clear high (8th) bit of input characters. =item [-]inlcr Translate newline to carriage return. =item [-]igncr Ignore carriage return. =item [-]icrnl Translate carriage return to newline. =item [-]ixon Enable XON/XOFF flow control. =item [-]ixoff Enable sending of stop character when the system input buffer is almost full, and start character when it becomes almost empty again. =back =head2 Output settings =over 4 =item [-]opost Postprocess output. =back =head2 Local settings =over 4 =item [-]isig Enable interrupt, quit, and suspend special characters. =item [-]icanon Enable erase, kill, werase, and rprnt special characters. =item [-]echo Echo input characters. =item [-]echoe, [-]crterase Echo erase characters as backspace-space-backspace. =item [-]echok Echo a newline after a kill character. =item [-]echonl Echo newline even if not echoing other characters. =item [-]noflsh Disable flushing after interrupt and quit special characters. * Though this claims non-posixhood it is supported by the perl POSIX.pm. =item [-]tostop (np) Stop background jobs that try to write to the terminal. =back =head2 Combination settings =over 4 =item ek Reset the erase and kill special characters to their default values. =item sane Same as: cread -ignbrk brkint -inlcr -igncr icrnl -ixoff opost isig icanon echo echoe echok -echonl -noflsh -tostop also sets all special characters to their default values. =item [-]cooked Same as: brkint ignpar istrip icrnl ixon opost isig icanon plus sets the eof and eol characters to their default values if they are the same as the min and time characters. With `-', same as raw. =item [-]raw Same as: -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -opost -isig -icanon min 1 time 0 With `-', same as cooked. =item [-]pass8 Same as: -parenb -istrip cs8 With `-', same as parenb istrip cs7. =item dec Same as: echoe echoctl echoke -ixany Also sets the interrupt special character to Ctrl-C, erase to Del, and kill to Ctrl-U. =back =head2 Special characters The special characters' default values vary from system to system. They are set with the syntax `name value', where the names are listed below and the value can be given either literally, in hat notation (`^c'), or as an integer which may start with `0x' to indicate hexadecimal, `0' to indicate octal, or any other digit to indicate decimal. Giving a value of `^-' or `undef' disables that special character. =over 4 =item intr Send an interrupt signal. =item quit Send a quit signal. =item erase Erase the last character typed. =item kill Erase the current line. =item eof Send an end of file (terminate the input). =item eol End the line. =item start Restart the output after stopping it. =item stop Stop the output. =item susp Send a terminal stop signal. =back =head2 Special settings =over 4 =item min N Set the minimum number of characters that will satisfy a read until the time value has expired, when -icanon is set. =item time N Set the number of tenths of a second before reads time out if the min number of characters have not been read, when -icanon is set. =item N Set the input and output speeds to N. N can be one of: 0 50 75 110 134 134.5 150 200 300 600 1200 1800 2400 4800 9600 19200 38400 exta extb. exta is the same as 19200; extb is the same as 38400. 0 hangs up the line if -clocal is set. =back =head2 OPTIONS =over 4 =item -a Print all current settings in human-readable form. =item -g Print all current settings in a form that can be used as an argument to another stty command to restore the current settings. =item -v,--version Print version info. =back =head1 Direct Subroutines =over 4 =item B IO::Stty::stty(\*STDIN, @params); From comments: I'm not feeling very inspired about this. Terminal parameters are obscure and boring. Basically what this will do is get the current setting, take the parameters, modify the setting and write it back. Zzzz. This is not especially efficent and probably not too fast. Assuming the POSIX spec has been implemented properly it should mostly work. =cut sub stty { my $tty_handle = shift; # This should be a \*HANDLE @_ or die("No parameters passed to stty"); # Version info if ($_[0] eq '-v' || $_[0] =~ /version/ ) { return $IO::Stty::VERSION."\n"; } my @parameters; my $parameter; # Build the 'this really means this' cases. foreach $parameter (@_) { if($parameter eq 'ek') { push (@parameters,'erase',8,'kill',21); next; } if($parameter eq 'sane') { push (@parameters,'cread','-ignbrk','brkint','-inlcr','-igncr','icrnl', '-ixoff','opost','isig','icanon','iexten','echo','echoe','echok', '-echonl','-noflsh','-tostop','echok','intr',3,'quit',28,'erase', 8,'kill',21,'eof',4,'eol',0,'stop',19,'start',17,'susp',26, 'time',0,'min',0 ); next; # Ugh. } if($parameter eq 'cooked' || $parameter eq '-raw') { # Is this right? push (@parameters,'brkint','ignpar','istrip','icrnl','ixon','opost', 'isig','icanon'); push (@parameters,'intr',3,'quit',28,'erase',8,'kill',21,'eof', 4,'eol',0,'stop',19,'start',17,'susp',26,'time',0,'min',0); next; } if($parameter eq 'raw' || $parameter eq '-cooked') { push (@parameters,'-ignbrk','-brkint','-ignpar','-parmrk','-inpck', '-istrip','-inlcr','-igncr','-icrnl','-ixon','-ixoff', '-opost','-isig','-icanon','min',1,'time',0 ); next; } if($parameter eq 'pass8') { push (@parameters,'-parenb','-istrip','cs8'); next; } if($parameter eq '-pass8') { push (@parameters,'parenb','istrip','cs7'); next; } if($parameter eq 'crt') { push (@parameters,'echoe','echok'); next; } if($parameter eq 'dec') { # 127 == delete, no? push (@parameters,'echoe','echok','intr',3,'erase', 127,'kill',21); next; } if($parameter =~ /^\d+$/) { push (@parameters,'ispeed',$parameter,'ospeed',$parameter); next; } push (@parameters,$parameter); } # Notice fileno() instead of handle->fileno(). I want it to work with # normal fhs. my ($file_num) = fileno($tty_handle); # Is it a terminal? return undef unless isatty($file_num); my($tty_name) = ttyname($file_num); # make a terminal object. my($termios)= POSIX::Termios->new(); $termios->getattr($file_num) || warn "Couldn't get terminal parameters for '$tty_name', fine num ($file_num)"; my($c_cflag) = $termios->getcflag; my($c_iflag) = $termios->getiflag; my($ispeed) = $termios->getispeed; my($c_lflag) = $termios->getlflag; my($c_oflag) = $termios->getoflag; my($ospeed) = $termios->getospeed; my(%control_chars); $control_chars{'INTR'}=$termios->getcc(VINTR); $control_chars{'QUIT'}=$termios->getcc(VQUIT); $control_chars{'ERASE'}=$termios->getcc(VERASE); $control_chars{'KILL'}=$termios->getcc(VKILL); $control_chars{'EOF'}=$termios->getcc(VEOF); $control_chars{'TIME'}=$termios->getcc(VTIME); $control_chars{'MIN'}=$termios->getcc(VMIN); $control_chars{'START'}=$termios->getcc(VSTART); $control_chars{'STOP'}=$termios->getcc(VSTOP); $control_chars{'SUSP'}=$termios->getcc(VSUSP); $control_chars{'EOL'}=$termios->getcc(VEOL); # OK.. we have our crap. # Do we want to know what the crap is? if($parameters[0] eq '-a') { return show_me_the_crap ($c_cflag,$c_iflag,$ispeed,$c_lflag,$c_oflag, $ospeed,\%control_chars); } # did we get the '-g' flag? if($parameters[0] eq '-g') { return "$c_cflag:$c_iflag:$ispeed:$c_lflag:$c_oflag:$ospeed:". $control_chars{'INTR'}.":". $control_chars{'QUIT'}.":". $control_chars{'ERASE'}.":". $control_chars{'KILL'}.":". $control_chars{'EOF'}.":". $control_chars{'TIME'}.":". $control_chars{'MIN'}.":". $control_chars{'START'}.":". $control_chars{'STOP'}.":". $control_chars{'SUSP'}.":". $control_chars{'EOL'}; } # Or the converse.. -g used before and we're getting the return. # Note that this uses the functionality of stty -g, not any specific # method. Don't take the output here and feed it to the OS stty. # This will make perl -w happy. my(@useless_var) = split(':',$parameters[0]); if (@useless_var == 17) { # print "Feeding back...\n"; @parameters = split(':',$parameters[0]); ($c_cflag,$c_iflag,$ispeed,$c_lflag,$c_oflag,$ospeed)=(@parameters); $control_chars{'INTR'}=$parameters[6]; $control_chars{'QUIT'}=$parameters[7]; $control_chars{'ERASE'}=$parameters[8]; $control_chars{'KILL'}=$parameters[9]; $control_chars{'EOF'}=$parameters[10]; $control_chars{'TIME'}=$parameters[11]; $control_chars{'MIN'}=$parameters[12]; $control_chars{'START'}=$parameters[13]; $control_chars{'STOP'}=$parameters[14]; $control_chars{'SUSP'}=$parameters[15]; $control_chars{'EOL'}=$parameters[16]; @parameters=(); # Unset so while loop is passed. } # So.. what shall we set? my($set_value); while ($parameter = shift(@parameters)) { # print "Param:$parameter:\n"; $set_value = 1; # On by default... # unset if starts w/ -, as in -crtscts $set_value = 0 if $parameter=~ s/^\-//; # Now the fun part. # c_cc field crap. if ($parameter eq 'intr') { $control_chars{'INTR'} = shift @parameters; next;} if ($parameter eq 'quit') { $control_chars{'QUIT'} = shift @parameters; next;} if ($parameter eq 'erase') { $control_chars{'ERASE'} = shift @parameters; next;} if ($parameter eq 'kill') { $control_chars{'KILL'} = shift @parameters; next;} if ($parameter eq 'eof') { $control_chars{'EOF'} = shift @parameters; next;} if ($parameter eq 'eol') { $control_chars{'EOL'} = shift @parameters; next;} if ($parameter eq 'start') { $control_chars{'START'} = shift @parameters; next;} if ($parameter eq 'stop') { $control_chars{'STOP'} = shift @parameters; next;} if ($parameter eq 'susp') { $control_chars{'SUSP'} = shift @parameters; next;} if ($parameter eq 'min') { $control_chars{'MIN'} = shift @parameters; next;} if ($parameter eq 'time') { $control_chars{'TIME'} = shift @parameters; next;} # c_cflag crap if ($parameter eq 'clocal') { $c_cflag = ($set_value ? ($c_cflag | CLOCAL) : ($c_cflag & (~CLOCAL))); next; } if ($parameter eq 'cread') { $c_cflag = ($set_value ? ($c_cflag | CREAD) : ($c_cflag & (~CREAD))); next; } # As best I can tell, doing |~CS8 will clear the bits.. under solaris # anyway, where CS5 = 0, CS6 = 0x20, CS7= 0x40, CS8=0x60 if ($parameter eq 'cs5') { $c_cflag = (($c_cflag & ~CS8 )| CS5); next; } if ($parameter eq 'cs6') { $c_cflag = (($c_cflag & ~CS8 )| CS6); next; } if ($parameter eq 'cs7') { $c_cflag = (($c_cflag & ~CS8 )| CS7); next; } if ($parameter eq 'cs8') { $c_cflag = ($c_cflag | CS8); next; } if ($parameter eq 'cstopb') { $c_cflag = ($set_value ? ($c_cflag | CSTOPB) : ($c_cflag & (~CSTOPB))); next; } if ($parameter eq 'hupcl' || $parameter eq 'hup') { $c_cflag = ($set_value ? ($c_cflag | HUPCL) : ($c_cflag & (~HUPCL))); next; } if ($parameter eq 'parenb') { $c_cflag = ($set_value ? ($c_cflag | PARENB) : ($c_cflag & (~PARENB))); next; } if ($parameter eq 'parodd') { $c_cflag = ($set_value ? ($c_cflag | PARODD) : ($c_cflag & (~PARODD))); next; } # That was fun. Still awake? c_iflag time. if ($parameter eq 'brkint') { $c_iflag = (($set_value ? ($c_iflag | BRKINT) : ($c_iflag & (~BRKINT)))); next; } if ($parameter eq 'icrnl') { $c_iflag = (($set_value ? ($c_iflag | ICRNL) : ($c_iflag & (~ICRNL)))); next; } if ($parameter eq 'ignbrk') { $c_iflag = (($set_value ? ($c_iflag | IGNBRK) : ($c_iflag & (~IGNBRK)))); next; } if ($parameter eq 'igncr') { $c_iflag = (($set_value ? ($c_iflag | IGNCR) : ($c_iflag & (~IGNCR)))); next; } if ($parameter eq 'ignpar') { $c_iflag = (($set_value ? ($c_iflag | IGNPAR) : ($c_iflag & (~IGNPAR)))); next; } if ($parameter eq 'inlcr') { $c_iflag = (($set_value ? ($c_iflag | INLCR) : ($c_iflag & (~INLCR)))); next; } if ($parameter eq 'inpck') { $c_iflag = (($set_value ? ($c_iflag | INPCK) : ($c_iflag & (~INPCK)))); next; } if ($parameter eq 'istrip') { $c_iflag = (($set_value ? ($c_iflag | ISTRIP) : ($c_iflag & (~ISTRIP)))); next; } if ($parameter eq 'ixoff') { $c_iflag = (($set_value ? ($c_iflag | IXOFF) : ($c_iflag & (~IXOFF)))); next; } if ($parameter eq 'ixon') { $c_iflag = (($set_value ? ($c_iflag | IXON) : ($c_iflag & (~IXON)))); next; } if ($parameter eq 'parmrk') { $c_iflag = (($set_value ? ($c_iflag | PARMRK) : ($c_iflag & (~PARMRK)))); next; } # Are we there yet? No. Are we there yet? No. Are we there yet... # print "Values: $c_lflag,".($c_lflag | ECHO)." ".($c_lflag & (~ECHO))."\n"; if ($parameter eq 'echo') { $c_lflag = (($set_value ? ($c_lflag | ECHO) : ($c_lflag & (~ECHO)))); next; } if ($parameter eq 'echoe') { $c_lflag = (($set_value ? ($c_lflag | ECHOE) : ($c_lflag & (~ECHOE)))); next; } if ($parameter eq 'echok') { $c_lflag = (($set_value ? ($c_lflag | ECHOK) : ($c_lflag & (~ECHOK)))); next; } if ($parameter eq 'echonl') { $c_lflag = (($set_value ? ($c_lflag | ECHONL) : ($c_lflag & (~ECHONL)))); next; } if ($parameter eq 'icanon') { $c_lflag = (($set_value ? ($c_lflag | ICANON) : ($c_lflag & (~ICANON)))); next; } if ($parameter eq 'iexten') { $c_lflag = (($set_value ? ($c_lflag | IEXTEN) : ($c_lflag & (~IEXTEN)))); next; } if ($parameter eq 'isig') { $c_lflag = (($set_value ? ($c_lflag | ISIG) : ($c_lflag & (~ISIG)))); next; } if ($parameter eq 'noflsh') { $c_lflag = (($set_value ? ($c_lflag | NOFLSH) : ($c_lflag & (~NOFLSH)))); next; } if ($parameter eq 'tostop') { $c_lflag = (($set_value ? ($c_lflag | TOSTOP) : ($c_lflag & (~TOSTOP)))); next; } # Make it stop! Make it stop! # c_oflag crap. if ($parameter eq 'opost') { $c_oflag = (($set_value ? ($c_oflag | OPOST) : ($c_oflag & (~OPOST)))); next; } # Speed? if ($parameter eq 'ospeed') { $ospeed = &{"POSIX::B".shift(@parameters)}; next; } if ($parameter eq 'ispeed') { $ispeed = &{"POSIX::B".shift(@parameters)}; next; } # Default.. parameter hasn't matched anything # print "char:".sprintf("%lo",ord($parameter))."\n"; warn "IO::Stty::stty passed invalid parameter '$parameter'\n"; } # What a pain in the ass! Ok.. let's write the crap back. $termios->setcflag($c_cflag); $termios->setiflag($c_iflag); $termios->setispeed($ispeed); $termios->setlflag($c_lflag); $termios->setoflag($c_oflag); $termios->setospeed($ospeed); $termios->setcc(VINTR,$control_chars{'INTR'}); $termios->setcc(VQUIT,$control_chars{'QUIT'}); $termios->setcc(VERASE,$control_chars{'ERASE'}); $termios->setcc(VKILL,$control_chars{'KILL'}); $termios->setcc(VEOF,$control_chars{'EOF'}); $termios->setcc(VTIME,$control_chars{'TIME'}); $termios->setcc(VMIN,$control_chars{'MIN'}); $termios->setcc(VSTART,$control_chars{'START'}); $termios->setcc(VSTOP,$control_chars{'STOP'}); $termios->setcc(VSUSP,$control_chars{'SUSP'}); $termios->setcc(VEOL,$control_chars{'EOL'}); $termios->setattr($file_num,TCSANOW); # TCSANOW = do immediately. don't unbuffer first. # OK.. that sucked. } =item B Needs documentation =cut sub show_me_the_crap { my ($c_cflag,$c_iflag,$ispeed,$c_lflag,$c_oflag, $ospeed,$control_chars) = @_; my(%cc) = %$control_chars; # rs = return string my($rs)=''; $rs .= 'speed '; if ($ospeed == B0) { $rs .= 0; } if ($ospeed == B50) { $rs .= 50; } if ($ospeed == B75) { $rs .= 75; } if ($ospeed == B110) { $rs .= 110; } if ($ospeed == B134) { $rs .= 134; } if ($ospeed == B150) { $rs .= 150; } if ($ospeed == B200) { $rs .= 200; } if ($ospeed == B300) { $rs .= 300; } if ($ospeed == B600) { $rs .= 600; } if ($ospeed == B1200) { $rs .= 1200; } if ($ospeed == B1800) { $rs .= 1800; } if ($ospeed == B2400) { $rs .= 2400; } if ($ospeed == B4800) { $rs .= 4800; } if ($ospeed == B9600) { $rs .= 9600; } if ($ospeed == B19200) { $rs .= 19200; } if ($ospeed == B38400) { $rs .= 38400; } $rs .= " baud\n"; $rs .= < (Initial version and maintenance) Todd Rinaldo (Maintenance) =head1 BUGS This is use at your own risk software. Do anything you want with it except blame me for it blowing up your machine because it's full of bugs. See above for what functions are supported. It's mostly standard POSIX stuff. If any of the settings are wrong and you actually know what some of these extremely arcane settings (like what 'sane' should be in POSIX land) really should be, please open an RT ticket. =head1 ACKNOWLEDGEMENTS None =head1 COPYRIGHT & LICENSE Copyright 1997 Austin Schutz, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; IO-Stty-0.03/scripts000750000765000024 011370451211 13577 5ustar00toddstaff000000000000IO-Stty-0.03/scripts/stty.pl000555000765000024 30611370451211 15263 0ustar00toddstaff000000000000#!/usr/local/perl/bin/perl require IO::Stty; foreach $param (@ARGV) { push (@params,split(/\s/,$param)); } $stty = IO::Stty::stty(\*STDIN,@params); if ($stty ne '0 but true') { print $stty; } IO-Stty-0.03/t000750000765000024 011370451211 12353 5ustar00toddstaff000000000000IO-Stty-0.03/t/00-load.t000444000765000024 21311370451211 14012 0ustar00toddstaff000000000000#!perl -T use Test::More tests => 1; BEGIN { use_ok( 'IO::Stty' ); } diag( "Testing IO::Stty $IO::Stty::VERSION, Perl $], $^X" ); IO-Stty-0.03/t/98-pod-coverage.t000444000765000024 104711370451211 15515 0ustar00toddstaff000000000000use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod::Coverage my $min_tpc = 1.08; eval "use Test::Pod::Coverage $min_tpc"; plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage" if $@; # Test::Pod::Coverage doesn't require a minimum Pod::Coverage version, # but older versions don't recognize some common documentation styles my $min_pc = 0.18; eval "use Pod::Coverage $min_pc"; plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@; all_pod_coverage_ok(); IO-Stty-0.03/t/99-pod.t000444000765000024 35011370451211 13701 0ustar00toddstaff000000000000#!perl -T use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; all_pod_files_ok();