BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / window / wwinit.c
index 76315ba..c41a2ee 100644 (file)
@@ -5,11 +5,23 @@
  * This code is derived from software contributed to Berkeley by
  * Edward Wang at The University of California, Berkeley.
  *
  * This code is derived from software contributed to Berkeley by
  * Edward Wang at The University of California, Berkeley.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms are permitted provided
+ * that: (1) source distributions retain this entire copyright notice and
+ * comment, and (2) distributions including binaries display the following
+ * acknowledgement:  ``This product includes software developed by the
+ * University of California, Berkeley and its contributors'' in the
+ * documentation or other materials provided with the distribution and in
+ * all advertising materials mentioning features or use of this software.
+ * Neither the name of the University nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)wwinit.c   3.40 (Berkeley) %G%";
+static char sccsid[] = "@(#)wwinit.c   3.39 (Berkeley) 6/6/90";
 #endif /* not lint */
 
 #include "ww.h"
 #endif /* not lint */
 
 #include "ww.h"
@@ -39,7 +51,7 @@ wwinit()
        if (wwgettty(0, &wwoldtty) < 0)
                return -1;
        wwwintty = wwoldtty;
        if (wwgettty(0, &wwoldtty) < 0)
                return -1;
        wwwintty = wwoldtty;
-#ifdef OLD_TTY
+#ifndef POSIX_TTY
        wwwintty.ww_sgttyb.sg_flags &= ~XTABS;
        wwnewtty.ww_sgttyb = wwoldtty.ww_sgttyb;
        wwnewtty.ww_sgttyb.sg_erase = -1;
        wwwintty.ww_sgttyb.sg_flags &= ~XTABS;
        wwnewtty.ww_sgttyb = wwoldtty.ww_sgttyb;
        wwnewtty.ww_sgttyb.sg_erase = -1;
@@ -61,12 +73,6 @@ wwinit()
        wwnewtty.ww_lmode = wwoldtty.ww_lmode | LLITOUT;
        wwnewtty.ww_ldisc = wwoldtty.ww_ldisc;
 #else
        wwnewtty.ww_lmode = wwoldtty.ww_lmode | LLITOUT;
        wwnewtty.ww_ldisc = wwoldtty.ww_ldisc;
 #else
-#ifndef OXTABS
-#define OXTABS XTABS
-#endif
-#ifndef _POSIX_VDISABLE
-#define _POSIX_VDISABLE -1
-#endif
        wwwintty.ww_termios.c_oflag &= ~OXTABS;
        wwnewtty.ww_termios = wwoldtty.ww_termios;
        wwnewtty.ww_termios.c_iflag &=
        wwwintty.ww_termios.c_oflag &= ~OXTABS;
        wwnewtty.ww_termios = wwoldtty.ww_termios;
        wwnewtty.ww_termios.c_iflag &=
@@ -76,11 +82,11 @@ wwinit()
        wwnewtty.ww_termios.c_cflag &= ~(CSIZE | PARENB);
        wwnewtty.ww_termios.c_cflag |= CS8;
        wwnewtty.ww_termios.c_lflag = 0;
        wwnewtty.ww_termios.c_cflag &= ~(CSIZE | PARENB);
        wwnewtty.ww_termios.c_cflag |= CS8;
        wwnewtty.ww_termios.c_lflag = 0;
-       for (i = 0; i < NCCS; i++)
+       for (i = 0; i < NCC; i++)
                wwnewtty.ww_termios.c_cc[i] = _POSIX_VDISABLE;
 #endif
        wwnewtty.ww_fflags = wwoldtty.ww_fflags | FASYNC;
                wwnewtty.ww_termios.c_cc[i] = _POSIX_VDISABLE;
 #endif
        wwnewtty.ww_fflags = wwoldtty.ww_fflags | FASYNC;
-       if (wwsettty(0, &wwnewtty) < 0)
+       if (wwsettty(0, &wwnewtty, &wwoldtty) < 0)
                goto bad;
 
        if ((wwterm = getenv("TERM")) == 0) {
                goto bad;
 
        if ((wwterm = getenv("TERM")) == 0) {
@@ -91,70 +97,15 @@ wwinit()
                wwerrno = WWE_BADTERM;
                goto bad;
        }
                wwerrno = WWE_BADTERM;
                goto bad;
        }
-#ifdef OLD_TTY
-       wwospeed = wwoldtty.ww_sgttyb.sg_ospeed;
+#ifndef POSIX_TTY
+       wwbaud = wwbaudmap[wwoldtty.ww_sgttyb.sg_ospeed];
 #else
 #else
-       wwospeed = cfgetospeed(&wwoldtty.ww_termios);
-#endif
-       switch (wwospeed) {
-       default:
-       case B0:
-               wwbaud = 0;
-               break;
-       case B50:
-               wwbaud = 50;
-               break;
-       case B75:
-               wwbaud = 75;
-               break;
-       case B110:
-               wwbaud = 110;
-               break;
-       case B134:
-               wwbaud = 134;
-               break;
-       case B150:
-               wwbaud = 150;
-               break;
-       case B200:
-               wwbaud = 200;
-               break;
-       case B300:
-               wwbaud = 300;
-               break;
-       case B600:
-               wwbaud = 600;
-               break;
-       case B1200:
-               wwbaud = 1200;
-               break;
-       case B1800:
-               wwbaud = 1800;
-               break;
-       case B2400:
-               wwbaud = 2400;
-               break;
-       case B4800:
-               wwbaud = 4800;
-               break;
-       case B9600:
-               wwbaud = 9600;
-               break;
-#ifdef B19200
-       case B19200:
+#ifdef CBAUD
+       wwbaud = wwbaudmap[wwoldtty.ww_termios.c_cflag & CBAUD];
 #else
 #else
-       case EXTA:
+       wwbaud = wwoldtty.ww_termios.c_ospeed;
 #endif
 #endif
-               wwbaud = 19200;
-               break;
-#ifdef B38400
-       case B38400:
-#else
-       case EXTB:
 #endif
 #endif
-               wwbaud = 38400;
-               break;
-       }
 
        if (xxinit() < 0)
                goto bad;
 
        if (xxinit() < 0)
                goto bad;
@@ -268,7 +219,7 @@ bad:
         * Don't bother to free storage.  We're supposed
         * to exit when wwinit fails anyway.
         */
         * Don't bother to free storage.  We're supposed
         * to exit when wwinit fails anyway.
         */
-       (void) wwsettty(0, &wwoldtty);
+       (void) wwsettty(0, &wwoldtty, &wwnewtty);
        (void) signal(SIGIO, SIG_DFL);
        (void) sigsetmask(s);
        return -1;
        (void) signal(SIGIO, SIG_DFL);
        (void) sigsetmask(s);
        return -1;