#include #include #include #include #include static struct { int len; char *buf; } devdsc; typedef struct { short status; /* I/O status */ char ts; /* transmit speed */ char rs; /* receive speed (only if != ts */ char CR_cnt; /* CR fill count */ char LF_cnt; /* LF fill count */ char pf; /* parity flags */ char unused; /* unused */ } SM_IOSB; /* Set/Sense Mode/Char I/O status block */ typedef struct { char class; /* class */ char type; /* type */ short pw; /* page width */ char btc[3]; /* Basic Terminal Characteristics */ char pl; /* page length */ int xtc; /* eXtended Terminal Characteristics */ } C_BUF; static int AllocChan(fd) int fd; { char fs[256]; /* file specification */ int status, ch; if (getname(fd, fs, 1) == 0) { return(-1); } devdsc.len = strlen(fs); devdsc.buf = fs; if ((status = sys$assign (&devdsc, &ch, 0, 0)) != SS$_NORMAL) { errno = EVMSERR; vaxc$errno = status; return(-1); } return(ch); } int gtty(fd, buf) int fd; struct sgttyb *buf; { SM_IOSB sm_iosb; C_BUF t_chars; int status,s; status = isatty(fd); if (status == 0) { errno = ENOTTY; return(-1); } if (status == -1) { return(-1); } if ((s = AllocChan(fd)) == -1) { return(-1); } if ((status = sys$qiow(0, s, IO$_SENSEMODE, &sm_iosb, 0, 0, &t_chars, sizeof(t_chars), 0, 0, 0, 0)) != SS$_NORMAL) { errno = EVMSERR; vaxc$errno = status; return(-1); } return(0); } int stty (fd, buf) int fd; struct sgttyb *buf; { int status; status = isatty(fd); if (status == 0) { errno = ENOTTY; return(-1); } if (status == -1) { return(-1); } return(0); }