new copyright, cflag CIGNORE implements TCSASOFT
authorMarc Teitelbaum <marc@ucbvax.Berkeley.EDU>
Wed, 27 Jun 1990 05:34:23 +0000 (21:34 -0800)
committerMarc Teitelbaum <marc@ucbvax.Berkeley.EDU>
Wed, 27 Jun 1990 05:34:23 +0000 (21:34 -0800)
SCCS-vsn: lib/libc/gen/termios.c 5.2

usr/src/lib/libc/gen/termios.c

index 34e7d9b..fe4f465 100644 (file)
@@ -1,28 +1,19 @@
-/*
+/*-
  * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1989 The Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not 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.
+ * %sccs.include.redist.c%
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)termios.c  5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)termios.c  5.2 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #include <sys/errno.h>
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
 #include <sys/errno.h>
-#include <sys/termios.h>
+#include <sys/ioctl.h>
 #include <sys/tty.h>
 #include <sys/tty.h>
+#include <sys/termios.h>
 #include <stdio.h>
 
 tcgetattr(fd, t)
 #include <stdio.h>
 
 tcgetattr(fd, t)
@@ -38,34 +29,20 @@ tcsetattr(fd, opt, t)
        int fd, opt;
        struct termios *t;
 {
        int fd, opt;
        struct termios *t;
 {
-       long code;
-       int ret;
-       extern errno;
+       struct termios localterm;
 
 
-       switch (opt) {
-       case TCSANOW:
-               code = TIOCSETA; 
-               break;
-       case TCSADRAIN: 
-               code = TIOCSETAW; 
-               break;
-       case TCSADFLUSH: 
-               code = TIOCSETAF; 
-               break;
-       case TCSANOW | TCSASOFT:
-               code = TIOCSETAS; 
-               break;
-       case TCSADRAIN | TCSASOFT:
-               code = TIOCSETAWS;
-               break;
-       case TCSADFLUSH | TCSASOFT:
-               code = TIOCSETAFS;
-               break;
-       default:
-               errno = EINVAL;
-               return(-1);
+       if (opt & TCSASOFT) {
+               localterm = *t;
+               localterm.c_cflag |= CIGNORE;
+               t = &localterm;
+               opt &= TCSASOFT;
        }
        }
-       return(ioctl(fd, code, t));
+       if (opt == TCSANOW)
+               return (ioctl(fd, TIOCSETA, t));
+       else if (opt == TCSADRAIN)
+               return (ioctl(fd, TIOCSETAW, t));
+       else
+               return (ioctl(fd, TIOCSETAF, t));
 }
 
 tcsetpgrp(fd, pgrp)
 }
 
 tcsetpgrp(fd, pgrp)