| 1 | #ifndef lint |
| 2 | static char *sccsid = "@(#)wwtty.c 3.6 84/03/03"; |
| 3 | #endif |
| 4 | |
| 5 | #include "ww.h" |
| 6 | #include <fcntl.h> |
| 7 | |
| 8 | wwgettty(d, t) |
| 9 | register struct ww_tty *t; |
| 10 | { |
| 11 | if (ioctl(d, (int)TIOCGETP, (char *)&t->ww_sgttyb) < 0) |
| 12 | goto bad; |
| 13 | if (ioctl(d, (int)TIOCGETC, (char *)&t->ww_tchars) < 0) |
| 14 | goto bad; |
| 15 | if (ioctl(d, (int)TIOCGLTC, (char *)&t->ww_ltchars) < 0) |
| 16 | goto bad; |
| 17 | if (ioctl(d, (int)TIOCLGET, (char *)&t->ww_lmode) < 0) |
| 18 | goto bad; |
| 19 | if (ioctl(d, (int)TIOCGETD, (char *)&t->ww_ldisc) < 0) |
| 20 | goto bad; |
| 21 | if ((t->ww_fflags = fcntl(d, F_GETFL, 0)) < 0) |
| 22 | goto bad; |
| 23 | return 0; |
| 24 | bad: |
| 25 | wwerrno = WWE_SYS; |
| 26 | return -1; |
| 27 | } |
| 28 | |
| 29 | wwsettty(d, t) |
| 30 | register struct ww_tty *t; |
| 31 | { |
| 32 | if (ioctl(d, (int)TIOCSETN, (char *)&t->ww_sgttyb) < 0) |
| 33 | goto bad; |
| 34 | if (ioctl(d, (int)TIOCSETC, (char *)&t->ww_tchars) < 0) |
| 35 | goto bad; |
| 36 | if (ioctl(d, (int)TIOCSLTC, (char *)&t->ww_ltchars) < 0) |
| 37 | goto bad; |
| 38 | if (ioctl(d, (int)TIOCLSET, (char *)&t->ww_lmode) < 0) |
| 39 | goto bad; |
| 40 | if (ioctl(d, (int)TIOCSETD, (char *)&t->ww_ldisc) < 0) |
| 41 | goto bad; |
| 42 | if (fcntl(d, F_SETFL, t->ww_fflags) < 0) |
| 43 | goto bad; |
| 44 | return 0; |
| 45 | bad: |
| 46 | wwerrno = WWE_SYS; |
| 47 | return -1; |
| 48 | } |