Commit | Line | Data |
---|---|---|
b94626a3 | 1 | #ifndef lint |
60de5df9 | 2 | static char sccsid[] = "@(#)wwtty.c 3.9 %G%"; |
b94626a3 EW |
3 | #endif |
4 | ||
60de5df9 EW |
5 | /* |
6 | * Copyright (c) 1983 Regents of the University of California, | |
7 | * All rights reserved. Redistribution permitted subject to | |
8 | * the terms of the Berkeley Software License Agreement. | |
9 | */ | |
10 | ||
b94626a3 | 11 | #include "ww.h" |
b1189050 | 12 | #include <fcntl.h> |
b94626a3 EW |
13 | |
14 | wwgettty(d, t) | |
15 | register struct ww_tty *t; | |
16 | { | |
91f10fe7 | 17 | if (ioctl(d, (int)TIOCGETP, (char *)&t->ww_sgttyb) < 0) |
03e75950 | 18 | goto bad; |
91f10fe7 | 19 | if (ioctl(d, (int)TIOCGETC, (char *)&t->ww_tchars) < 0) |
03e75950 | 20 | goto bad; |
91f10fe7 | 21 | if (ioctl(d, (int)TIOCGLTC, (char *)&t->ww_ltchars) < 0) |
03e75950 | 22 | goto bad; |
91f10fe7 | 23 | if (ioctl(d, (int)TIOCLGET, (char *)&t->ww_lmode) < 0) |
03e75950 | 24 | goto bad; |
91f10fe7 | 25 | if (ioctl(d, (int)TIOCGETD, (char *)&t->ww_ldisc) < 0) |
03e75950 | 26 | goto bad; |
b1189050 EW |
27 | if ((t->ww_fflags = fcntl(d, F_GETFL, 0)) < 0) |
28 | goto bad; | |
b94626a3 | 29 | return 0; |
03e75950 EW |
30 | bad: |
31 | wwerrno = WWE_SYS; | |
32 | return -1; | |
b94626a3 EW |
33 | } |
34 | ||
4cbd8755 EW |
35 | /* |
36 | * Set the modes of tty 'd' to 't' | |
37 | * 'o' is the current modes. We set the line discipline only if | |
38 | * it changes, to avoid unnecessary flushing of typeahead. | |
39 | */ | |
40 | wwsettty(d, t, o) | |
41 | register struct ww_tty *t, *o; | |
b94626a3 | 42 | { |
4494450d | 43 | if (ioctl(d, (int)TIOCSETN, (char *)&t->ww_sgttyb) < 0) |
03e75950 | 44 | goto bad; |
91f10fe7 | 45 | if (ioctl(d, (int)TIOCSETC, (char *)&t->ww_tchars) < 0) |
03e75950 | 46 | goto bad; |
91f10fe7 | 47 | if (ioctl(d, (int)TIOCSLTC, (char *)&t->ww_ltchars) < 0) |
03e75950 | 48 | goto bad; |
91f10fe7 | 49 | if (ioctl(d, (int)TIOCLSET, (char *)&t->ww_lmode) < 0) |
03e75950 | 50 | goto bad; |
4cbd8755 EW |
51 | if ((o == 0 || t->ww_ldisc != o->ww_ldisc) && |
52 | ioctl(d, (int)TIOCSETD, (char *)&t->ww_ldisc) < 0) | |
03e75950 | 53 | goto bad; |
b1189050 EW |
54 | if (fcntl(d, F_SETFL, t->ww_fflags) < 0) |
55 | goto bad; | |
b94626a3 | 56 | return 0; |
03e75950 EW |
57 | bad: |
58 | wwerrno = WWE_SYS; | |
59 | return -1; | |
b94626a3 | 60 | } |