|
|
1.1 ! root 1: /* ! 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 the above copyright notice and this paragraph are ! 7: * duplicated in all such forms and that any documentation, ! 8: * advertising materials, and other materials related to such ! 9: * distribution and use acknowledge that the software was developed ! 10: * by the University of California, Berkeley. The name of the ! 11: * University may not be used to endorse or promote products derived ! 12: * from this software without specific prior written permission. ! 13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 16: */ ! 17: ! 18: #ifndef lint ! 19: static char sccsid[] = "@(#)wwtty.c 3.12 (Berkeley) 6/29/88"; ! 20: #endif /* not lint */ ! 21: ! 22: #include "ww.h" ! 23: #include <fcntl.h> ! 24: ! 25: wwgettty(d, t) ! 26: register struct ww_tty *t; ! 27: { ! 28: if (ioctl(d, TIOCGETP, (char *)&t->ww_sgttyb) < 0) ! 29: goto bad; ! 30: if (ioctl(d, TIOCGETC, (char *)&t->ww_tchars) < 0) ! 31: goto bad; ! 32: if (ioctl(d, TIOCGLTC, (char *)&t->ww_ltchars) < 0) ! 33: goto bad; ! 34: if (ioctl(d, TIOCLGET, (char *)&t->ww_lmode) < 0) ! 35: goto bad; ! 36: if (ioctl(d, TIOCGETD, (char *)&t->ww_ldisc) < 0) ! 37: goto bad; ! 38: if ((t->ww_fflags = fcntl(d, F_GETFL, 0)) < 0) ! 39: goto bad; ! 40: return 0; ! 41: bad: ! 42: wwerrno = WWE_SYS; ! 43: return -1; ! 44: } ! 45: ! 46: /* ! 47: * Set the modes of tty 'd' to 't' ! 48: * 'o' is the current modes. We set the line discipline only if ! 49: * it changes, to avoid unnecessary flushing of typeahead. ! 50: */ ! 51: wwsettty(d, t, o) ! 52: register struct ww_tty *t, *o; ! 53: { ! 54: if (ioctl(d, TIOCSETN, (char *)&t->ww_sgttyb) < 0) ! 55: goto bad; ! 56: if (ioctl(d, TIOCSETC, (char *)&t->ww_tchars) < 0) ! 57: goto bad; ! 58: if (ioctl(d, TIOCSLTC, (char *)&t->ww_ltchars) < 0) ! 59: goto bad; ! 60: if (ioctl(d, TIOCLSET, (char *)&t->ww_lmode) < 0) ! 61: goto bad; ! 62: if ((o == 0 || t->ww_ldisc != o->ww_ldisc) && ! 63: ioctl(d, TIOCSETD, (char *)&t->ww_ldisc) < 0) ! 64: goto bad; ! 65: if (fcntl(d, F_SETFL, t->ww_fflags) < 0) ! 66: goto bad; ! 67: return 0; ! 68: bad: ! 69: wwerrno = WWE_SYS; ! 70: return -1; ! 71: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.