NAME

initty - initialize tty state

SYNOPSIS

#include <basic/io.h>

extern int ttyerase, ttykill;
extern short ospeed;

int initty(tty, fd)
struct biotty *tty;
int fd;

int exitty(tty, fd)
struct biotty *tty;
int fd;

DESCRIPTION

Ttyerase and ttykill are the erase and kill characters, respectively, of the standard input if it is a tty.  Ospeed is the encoding of baud rate of the standard input if it is a tty (see tty(4) or termio(7)). 

Initty searches for the environment variable BASECHO.  If this variable is located and has a non-null value, this function simply returns zero.  Otherwise, this function returns one after performing several tasks.  First, this function gets the state of the tty associated with file descriptor fd and stores this information in tty.  If fd is zero, ttyerase, ttykill and ospeed are set.  In support of several BASIC I/O functions, initty also modifies the tty’s state to avoid most of the processing normally performed by the UNIX tty driver.  Specifically, character echoing, the collection of characters into lines, erase and kill character processing and tab and newline processing are turned off. 

Exitty sets the state of the tty associated with file descriptor fd to tty and returns zero. 

These functions support tty initialization and wrap-up and do not directly implement any BASIC functions. 

SEE ALSO

io(inc)
bclose(io), initio(io), misc(misc)
tty(4) or termio(7) in the UNIX Programmer’s Manual

DIAGNOSTICS

Exitty returns -1 if the state of the tty can not be set. 

BUGS

It is possible to leave a tty in a disturbed state if a biotty structure is corrupted by the user’s program or if the system call to restore it should fail.  These conditions require pathological behavior on the part of the user’s non-BASIC code and are all but impossible under normal circumstances. 

from The Basmark QuickBASIC Programmer’s Manual by Lawrence Leinweber