1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
/* tty.cxx
$Id: tty.cxx,v 1.2 1999/05/23 05:58:56 elf Exp $
written by Oscar Levi
13 December 1998
Copyright (C) 1998 The Buici Company
-----------
DESCRIPTION
-----------
TTY IO control functions.
*/
#include "standard.h"
#include <termios.h>
#include "tty.h"
#include <errno.h>
extern const char* g_szApplication;
struct termios g_termiosSave;
void disable_echo (int fh)
{
struct termios termios;
if (tcgetattr (fh, &g_termiosSave))
fprintf (stderr, "%s: tcgetattr failed on %d (%s)\n",
g_szApplication, fh, strerror (errno));
// restore_termios = 1;
termios = g_termiosSave;
termios.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
if (tcsetattr (fh, TCSAFLUSH, &termios))
fprintf (stderr, "%s: tcsetattr failed on %d (%s)\n",
g_szApplication, fh, strerror (errno));
}
void restore_echo (int fh)
{
if (tcsetattr (fh, TCSAFLUSH, &g_termiosSave))
fprintf (stderr, "%s: tcsetattr failed on %d (%s)\n",
g_szApplication, fh, strerror (errno));
}
int open_user_tty (void)
{
return open ("/dev/tty", O_RDWR);
}
|