home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / posix / cfmakeraw.c next >
Encoding:
C/C++ Source or Header  |  1993-04-23  |  3.0 KB  |  81 lines

  1. /* Copyright (C) 1992 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18. /* Modified by Al Clark 11/12/92 to no assume any initial conditions.
  19.  * Also, compile time variations "#define USEPARITY" to leave parity alone,
  20.  * and "define NOINTR" to disable interrupt on BREAK condition.
  21.  *  GNU C Library terms still apply.
  22.  */
  23.  
  24. #include <ansidecl.h>
  25. #include <termios.h>
  26.  
  27. void
  28. DEFUN(cfmakeraw, (t), struct termios *t)
  29. {
  30. /* I changed it to the current form according to the suggestions 
  31.  * from Bruce Evans. Thanks Bruce. Please report the problems to
  32.  * H.J. Lu (hlu@eecs.wsu.edu).
  33.  */
  34. #if 1
  35.  
  36.     /*  VMIN = 0 means non-blocking for Linux */
  37.     t->c_cc[VMIN] = 1; t->c_cc[VTIME] = 1;
  38.     /* clear some bits with &= ~(bits), set others with |= */
  39.     t->c_cflag &= ~(CSIZE|PARENB|CSTOPB);
  40.     t->c_cflag |=  (CS8|HUPCL|CREAD);
  41.     t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|INPCK|ISTRIP);
  42.     t->c_iflag &= ~(INLCR|IGNCR|ICRNL|IXON|IXOFF);
  43.     t->c_iflag |=  (BRKINT|IGNPAR);
  44.     t->c_oflag &= ~(OPOST|OLCUC|OCRNL|ONOCR|ONLRET|OFILL|OFDEL);
  45.     t->c_oflag &= ~(NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);
  46.     t->c_oflag |=  (ONLCR|NL0|CR0|TAB3|BS0|VT0|FF0);
  47.     t->c_lflag &= ~(ISIG|ICANON|IEXTEN|ECHO|ECHOE|ECHOK|ECHONL);
  48.     t->c_lflag &= ~(NOFLSH|XCASE);
  49. #if 1
  50.     t->c_lflag &= ~(ECHOPRT|ECHOCTL|ECHOKE);
  51. #else
  52.     t->c_lflag |=  (ECHOPRT|ECHOCTL|ECHOKE);
  53. #endif
  54.  
  55. #else
  56.     /*  VMIN = 0 means non-blocking for Linux */
  57.     t->c_cc[VMIN] = 1; t->c_cc[VTIME] = 1;
  58.     /* clear some bits with &= ~(bits), set others with |= */
  59. #ifdef USEPARITY  /* leave parity alone */
  60.     t->c_cflag &= ~(CSTOPB|CLOCAL|CRTSCTS);
  61.     t->c_cflag |=  (HUPCL|CREAD);
  62. #else             /* normal full eight bit case */
  63.     t->c_cflag &= ~(CSIZE|PARENB|PARODD|CSTOPB|CLOCAL|CRTSCTS);
  64.     t->c_cflag |=  (CS8|HUPCL|CREAD);
  65. #endif
  66.     t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|INPCK|ISTRIP);
  67.     t->c_iflag &= ~(INLCR|IGNCR|ICRNL|IXON|IXOFF);
  68. #ifdef NOINTR
  69.     t->c_iflag |=  (IGNPAR);
  70. #else
  71.     t->c_iflag |=  (BRKINT|IGNPAR);
  72. #endif
  73.     t->c_oflag &= ~(OPOST|OLCUC|OCRNL|ONOCR|ONLRET|OFILL|OFDEL);
  74.     t->c_oflag &= ~(NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);
  75.     t->c_oflag |=  (ONLCR|NL0|CR0|TAB3|BS0|VT0|FF0);
  76.     t->c_lflag &= ~(ISIG|ICANON|IEXTEN|ECHO|ECHOE|ECHOK|ECHONL);
  77.     t->c_lflag &= ~(NOFLSH|XCASE|TOSTOP);
  78.     t->c_lflag |=  (ECHOPRT|ECHOCTL|ECHOKE);
  79. #endif
  80. }
  81.