06-26-07 12:17 PM
Hi all,
Is there some portable (OS-independent?) way of turning echo on and
off for a terminal device? At the moment I have something similar to
the following for Un*x, but of course I can't use this with DJGPP in a
'DOS' console program.
#include <termios.h>
static int setnoecho (struct termios *t)
{
if (isatty (STDIN_FILENO) == 0)
{
fprintf(stderr, "Device is not a TTY.\n");
return(-1);
}
if (tcgetattr (STDIN_FILENO, t) < 0)
{
fprintf(stderr, "tcgetattr() failed.\n");
return(-1);
}
t->c_lflag &= ~ECHO;
tcsetattr (STDIN_FILENO, TCSANOW, t);
return (0);
}
static void setecho (struct termios *t)
{
t->c_lflag |= ECHO;
tcsetattr (STDIN_FILENO, TCSANOW, t);
}
[ Post a follow-up to this message ]
|