removed support for -r, -h, and rmail
[unix-history] / usr / src / usr.bin / window / wwtty.c
CommitLineData
60de5df9 1/*
46e9ea25
KB
2 * Copyright (c) 1983 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
6 * provided that this notice is preserved and that due credit is given
7 * to the University of California at Berkeley. The name of the University
8 * may not be used to endorse or promote products derived from this
9 * software without specific prior written permission. This software
10 * is provided ``as is'' without express or implied warranty.
60de5df9
EW
11 */
12
46e9ea25
KB
13#ifndef lint
14static char sccsid[] = "@(#)wwtty.c 3.11 (Berkeley) %G%";
15#endif /* not lint */
16
b94626a3 17#include "ww.h"
b1189050 18#include <fcntl.h>
b94626a3
EW
19
20wwgettty(d, t)
21register struct ww_tty *t;
22{
20029082 23 if (ioctl(d, TIOCGETP, (char *)&t->ww_sgttyb) < 0)
03e75950 24 goto bad;
20029082 25 if (ioctl(d, TIOCGETC, (char *)&t->ww_tchars) < 0)
03e75950 26 goto bad;
20029082 27 if (ioctl(d, TIOCGLTC, (char *)&t->ww_ltchars) < 0)
03e75950 28 goto bad;
20029082 29 if (ioctl(d, TIOCLGET, (char *)&t->ww_lmode) < 0)
03e75950 30 goto bad;
20029082 31 if (ioctl(d, TIOCGETD, (char *)&t->ww_ldisc) < 0)
03e75950 32 goto bad;
b1189050
EW
33 if ((t->ww_fflags = fcntl(d, F_GETFL, 0)) < 0)
34 goto bad;
b94626a3 35 return 0;
03e75950
EW
36bad:
37 wwerrno = WWE_SYS;
38 return -1;
b94626a3
EW
39}
40
4cbd8755
EW
41/*
42 * Set the modes of tty 'd' to 't'
43 * 'o' is the current modes. We set the line discipline only if
44 * it changes, to avoid unnecessary flushing of typeahead.
45 */
46wwsettty(d, t, o)
47register struct ww_tty *t, *o;
b94626a3 48{
20029082 49 if (ioctl(d, TIOCSETN, (char *)&t->ww_sgttyb) < 0)
03e75950 50 goto bad;
20029082 51 if (ioctl(d, TIOCSETC, (char *)&t->ww_tchars) < 0)
03e75950 52 goto bad;
20029082 53 if (ioctl(d, TIOCSLTC, (char *)&t->ww_ltchars) < 0)
03e75950 54 goto bad;
20029082 55 if (ioctl(d, TIOCLSET, (char *)&t->ww_lmode) < 0)
03e75950 56 goto bad;
4cbd8755 57 if ((o == 0 || t->ww_ldisc != o->ww_ldisc) &&
20029082 58 ioctl(d, TIOCSETD, (char *)&t->ww_ldisc) < 0)
03e75950 59 goto bad;
b1189050
EW
60 if (fcntl(d, F_SETFL, t->ww_fflags) < 0)
61 goto bad;
b94626a3 62 return 0;
03e75950
EW
63bad:
64 wwerrno = WWE_SYS;
65 return -1;
b94626a3 66}