#include <signal.h>
#include "beep.h"
-#define USG
-
#define FREQUENCY 800.0
#define FREQUENCY2 602.0
#define VOLUME 0.5
#include <sys/ioctl.h>
#include <fcntl.h>
-#ifdef USG
#include <termio.h>
struct termio oldtermgtty;
struct termio termgtty;
-#else
-#include <sys/file.h>
-struct sgttyb oldtermgtty;
-struct sgttyb termgtty;
-#endif
static char *terminal = "/dev/tty";
static int termfd;
static int termopen = 0;
-
-#ifndef USG
static int oldflgs, newflgs;
-#endif
static void
openterminal (void)
{
/* get parameters and open terminal */
-#ifdef USG
termfd = open (terminal, O_RDWR | O_NDELAY, 0);
ioctl (termfd, TCGETA, &termgtty);
oldtermgtty = termgtty;
termgtty.c_cc[VMIN] = 1;
termgtty.c_cc[VTIME] = 0;
ioctl (termfd, TCSETAW, &termgtty);
-#else
- termfd = open (terminal, O_RDWR, 0);
- ioctl (termfd, TIOCGETP, &termgtty);
- oldtermgtty = termgtty;
- if (typeaway != LETMESEE)
- termgtty.sg_flags &= ~ECHO;
- termgtty.sg_flags |= CBREAK;
- ioctl (termfd, TIOCSETP, &termgtty);
- oldflgs = fcntl (termfd, F_GETFL);
- newflgs = oldflgs | FNDELAY;
-#endif
-
termopen = 1;
}
static char line[TESTBUFSZ];
int n;
-#ifndef USG
- fcntl (termfd, F_SETFL, newflgs);
-#endif
n = read (termfd, line, sizeof (line) - 1);
-#ifndef USG
- fcntl (termfd, F_SETFL, oldflgs);
-#endif
if (n > 0)
{
static void
closeterminal (void)
{
-#ifdef USG
ioctl (termfd, TCSETAW, &oldtermgtty);
-#else
- ioctl (termfd, TIOCSETP, &oldtermgtty);
-#endif
close (termfd);
}