The Standard ML Basis Library


The Posix.TTY structure

The structure Posix.TTY specifies a general terminal interface, as described in Section 7 of the POSIX standard [CITE]1003.1,1996/.


Synopsis

signature POSIX_TTY
structure TTY : POSIX_TTY

Interface

eqtype pid
eqtype file_desc
structure V : sig
    val eof : int
    val eol : int
    val erase : int
    val intr : int
    val kill : int
    val min : int
    val quit : int
    val susp : int
    val time : int
    val start : int
    val stop : int
    val nccs : int
    type cc
    val cc : (int * char) list -> cc
    val update : (cc * (int * char) list) -> cc
    val sub : (cc * int) -> char
  end
structure I : sig
    include POSIX_FLAGS
    val brkint : flags
    val icrnl : flags
    val ignbrk : flags
    val igncr : flags
    val ignpar : flags
    val inlcr : flags
    val inpck : flags
    val istrip : flags
    val ixoff : flags
    val ixon : flags
    val parmrk : flags
  end
structure O : sig
    include POSIX_FLAGS
    val opost : flags
  end
structure C : sig
    include POSIX_FLAGS
    val clocal : flags
    val cread : flags
    val cs5 : flags
    val cs6 : flags
    val cs7 : flags
    val cs8 : flags
    val csize : flags
    val cstopb : flags
    val hupcl : flags
    val parenb : flags
    val parodd : flags
  end
structure L : sig
    include POSIX_FLAGS
    val echo : flags
    val echoe : flags
    val echok : flags
    val echonl : flags
    val icanon : flags
    val iexten : flags
    val isig : flags
    val noflsh : flags
    val tostop : flags
  end
eqtype speed
val compareSpeed : (speed * speed) -> order
val speedToWord : speed -> SysWord.word
val wordToSpeed : SysWord.word -> speed
val b0 : speed
val b50 : speed
val b75 : speed
val b110 : speed
val b134 : speed
val b150 : speed
val b200 : speed
val b300 : speed
val b600 : speed
val b1200 : speed
val b1800 : speed
val b2400 : speed
val b4800 : speed
val b9600 : speed
val b19200 : speed
val b38400 : speed
type termios
val termios : {iflag : I.flags, oflag : O.flags, cflag : C.flags, lflag : L.flags, cc : V.cc, ispeed : speed, ospeed : speed} -> termios
val fieldsOf : termios -> {iflag : I.flags, oflag : O.flags, cflag : C.flags, lflag : L.flags, cc : V.cc, ispeed : speed, ospeed : speed}
val getiflag : termios -> I.flags
val getoflag : termios -> O.flags
val getcflag : termios -> C.flags
val getlflag : termios -> L.flags
val getcc : termios -> V.cc
structure CF : sig
    val getospeed : termios -> speed
    val setospeed : (termios * speed) -> termios
    val getispeed : termios -> speed
    val setispeed : (termios * speed) -> termios
  end
structure TC : sig
    eqtype set_action
    val sanow : set_action
    val sadrain : set_action
    val saflush : set_action
    eqtype flow_action
    val ooff : flow_action
    val oon : flow_action
    val ioff : flow_action
    val ion : flow_action
    eqtype queue_sel
    val iflush : queue_sel
    val oflush : queue_sel
    val ioflush : queue_sel
    val getattr : file_desc -> termios
    val setattr : (file_desc * set_action * termios) -> unit
    val sendbreak : (file_desc * int) -> unit
    val drain : file_desc -> unit
    val flush : (file_desc * queue_sel) -> unit
    val flow : (file_desc * flow_action) -> unit
  end
val getpgrp : file_desc -> pid
val setpgrp : (file_desc * pid) -> unit

Description

eqtype pid
a process id

eqtype file_desc
an open file descriptor

structure V
The V substructure provides means for specifying the special control characters.

eof
index for the EOF character.

eol
index for the EOL character.

erase
index for the ERASE character.

intr
index for the INTR character.

kill
index for the KILL character.

min
index for the MIN value.

quit
index for the QUIT character.

susp
index for the SUSP character.

time
index for the TIME value.

start
index for the START character.

stop
index for the STOP character.

nccs
is the total number of special characters. In addition, valid indices range from 0 to nccs-1.

type cc
represents a vector of special control characters used by the device driver.

cc l
creates a value of type cc, mapping an index to its paired character. Unspecifed indices are associated with #"\000".

update (cs, l)
returns a copy cs, but with the new mappings specified by l.

sub (cs, i)
returns the special control character associated in cs with the index i. Raises Subscript if i is negative or i >= nccs.

structure I
The I substructure contains flags for specifying input control.

brkint
signal interrupt on break.

icrnl
map CR (i.e., #"\^M") /to NL (i.e., #"\n") on input.

ignbrk
ignore a break condition.

igncr
ignore CR characters.

ignpar
ignore characters with parity errors.

inlcr
map NL to CR on input.

inpck
enable input parity check.

istrip
strip eighth bit of a byte.

ixoff
enable start/stop input control.

ixon
enable start/stop output control.

parmrk
mark parity errors.

structure O
The O substructure contains flags for specifying output control.

opost
perform output processing.

structure C
The C substructure contains flags for specifying basic terminal hardware control.

clocal
ignore modem status lines.

cread
enable receiver.

cs5
cs6
cs7
cs8
specifies the number of bits per bytes (5,6,7,8, respectively) used for both transmission and reception.

csize
mask for cs5, cs6, cs7, and cs8 values.

cstopb
specifies sending two stop bits rather than one.

hupcl
hang up modem connection when the last process with the port open closes it.

parenb
enable parity generation and detection.

parodd
use odd parity rather than even if parenb is set.

structure L
The L substructure contains flags for specifying various local control modes.

echo
echo input characters back to terminal.

echoe
echo ERASE character on backspace in canonical mode.

echok
echo KILL character in canonical mode.

echonl
echo NL character if echonl is not set in canonical mode.

icanon
set canonical mode, enable erase and kill processing.

iexten
enable extended functions.

isig
enable input character to signal conversion.

noflsh
disable input and output flushing after interrupt, quit or suspend.

tostop
send Posix.Signal.ttou for background output.

eqtype speed
represents terminal input and output baud rates.

compareSpeed (sp, sp2)
compares speeds by baud rate.

speedToWord sp
converts a speed value to its underlying word representation.

wordToSpeed w
converts a word to a speed value. No checking is performed to ensure the resulting value corresponds to an allowed speed in the given system.

b0
hang up

b50
b75
b110
b134
b150
b200
b300
b600
b1200
b1800
b2400
b4800
b9600
b19200
b38400
specify usual baud rates with the obvious correspondence, i.e., b1200 is 1200 baud.

type termios
encapsulates the attributes associated with a terminal.

termios {iflag, oflag, cflag, lflag, cc, ispeed, ospeed}
creates a termios value using the given flags, special characters and speeds.

fieldsOf te
returns a concrete representation of a termios value.

getiflag te
returns the I.flags value of te.

getoflag te
returns the O.flags value of te.

getcflag te
returns the C.flags value of te.

fgetlflag te
returns the L.flags value of te.

getcc te
returns the special control character mapping of te.

structure CF
The CF substructure contains various options and functions used for handling terminal line control.

getospeed te
returns the output speed of te.

setospeed (te, sp)
creates a copy of te, but uses the specified output speed sp.

getispeed te
returns the input speed of te.

setispeed (te, sp)
creates a copy of te, but uses the specified input speed sp.

structure TC
The TC substructure contains various options and functions used for handling terminal line control.

eqtype set_action
specifies the behavior of setattr.

sanow
specifies the changes occur immediately.

sadrain
specifies the changes occur after all output is transmitted.

saflush
specifies the changes occur after all output is transmitted and after all received but unread input is discarded.

eqtype flow_action
specifies the behavior of flow.

ooff
causes suspension of output.

oon
restarts suspended output.

ioff
causes the transmission of a STOP character to the terminal device, to stop it transmitting data.

ion
causes the transmission of a START character to the terminal device, to restart it transmitting data.

eqtype queue_sel

iflush
causes all data received but not read to be flushed.

oflush
causes all data written but not transmitted to be flushed.

ioflush
discards all data written but not transmitted, or received but not read.

getattr fd
gets the attributes of the terminal associated with file descriptor fd.

setattr (fd, action, te)
sets the attributes of the terminal associated with file descriptor fd as specifed in te. When the change occurs is specified by action.

sendbreak (fd, d)
causes the transmission of a sequence of zero bits to be sent for a specific duration.

drain fd
waits for all output written to be transmitted.

flush (fd, qs)
discards any data written but not transmitted, or received but not read, depending on the value of qs.

flow (fd, fa)
suspends and restarts transmission or reception of data, depending on the value of fa.

getpgrp fd
returns the process group ID of the foreground process group associated with the terminal attached to fd.

csetpgrp (fd, pid)
sets the foreground process group ID associated with fd to pid.


See Also

POSIX_FLAGS, Posix, OS, Posix.TTY, Posix.FileSys, Posix.Process, Posix.Error

[ INDEX | TOP | Parent | Root ]

Last Modified October 4, 1997
Comments to John Reppy.
Copyright © 1997 Bell Labs, Lucent Technologies