/* terminal.h - Craig Kelley - March 9, 1995 
 *
 * This library contains (and will contain more) useful procedures
 * to unclutter programs that deal with "raw" or "cbreak" terminals.
 * It will initialize the terminal (saving the old settings) and pass
 * an identifier to that terminal to the caller.  Then it will restore
 * the old values.  It's useful to trap the restore feature with signals,
 * so a global variable is defined (old_term) that contains the original
 * terminal settings.  The primary goal of this library is to make the
 * term stuff invisible, so that the programmer can deal with more
 * important things.
 */

/* include the proper header files */

#ifdef _POSIX_SOURCE		/* For Linux machines */
#define POSIX
#endif

#ifdef POSIX
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
typdef struct termios tty_struct;
#define TTYSET TCSETS
#define TTYGET TCGETS
#else
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sgtty.h>
typedef struct sgttyb tty_struct;
#define TTYGET TIOCGETP
#define TTYSET TIOCSETP
#endif

#ifdef NeXT			/* The NeXT has it's own agenda */
#include <libc.h>
#endif

#define TERMINAL "/dev/tty"	/* Where the terminal dev resides */

/* funciton prototypes */
extern int restore_terminal(int term);
extern int terminal_cbreak();

/* global variable (to allow for trapping signals) */
tty_struct old_term;		/* for the ioctl funcitons */


