Back to index

glibc  2.9
tcsetattr.c
Go to the documentation of this file.
00001 /* Copyright (C) 1992, 1994, 1997, 2002 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #include <errno.h>
00020 #include <stddef.h>
00021 #include <termios.h>
00022 
00023 /* These are defined both in <bits/termios.h> and in <bits/ioctls.h>.
00024    They should have the same values, but perhaps not written the same way.  */
00025 #undef ECHO
00026 #undef MDMBUF
00027 #undef TOSTOP
00028 #undef FLUSHO
00029 #undef PENDIN
00030 #undef NOFLSH
00031 #include <sys/ioctl.h>
00032 
00033 
00034 /* Set the state of FD to *TERMIOS_P.  */
00035 int
00036 tcsetattr (fd, optional_actions, termios_p)
00037      int fd;
00038      int optional_actions;
00039      const struct termios *termios_p;
00040 {
00041   struct termios myt;
00042 
00043   if (optional_actions & TCSASOFT)
00044     {
00045       myt = *termios_p;
00046       myt.c_cflag |= CIGNORE;
00047       termios_p = &myt;
00048       optional_actions &= ~TCSASOFT;
00049     }
00050 
00051   switch (optional_actions)
00052     {
00053     case TCSANOW:
00054       return __ioctl (fd, TIOCSETA, termios_p);
00055 
00056     case TCSADRAIN:
00057       return __ioctl (fd, TIOCSETAW, termios_p);
00058 
00059     default:
00060       return __ioctl (fd, TIOCSETAF, termios_p);
00061     }
00062 }
00063 libc_hidden_def (tcsetattr)