1 /* Copyright (C) 1992,1995,1996,1997,2000,2002 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
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 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 #include <sys/ioctl.h>
24 #include <sysv_termio.h>
27 const speed_t __unix_speeds
[] =
48 /* Set the state of FD to *TERMIOS_P. */
50 tcsetattr (fd
, optional_actions
, termios_p
)
53 const struct termios
*termios_p
;
55 struct __sysv_termio buf
;
58 if (termios_p
== NULL
)
63 switch (optional_actions
)
66 ioctl_function
= _TCSETA
;
69 ioctl_function
= _TCSETAW
;
72 ioctl_function
= _TCSETAF
;
79 if ((termios_p
->c_cflag
& 0x000f0000) >> 16 != (termios_p
->c_cflag
& 0xf))
86 if (termios_p
->c_iflag
& IGNBRK
)
87 buf
.c_iflag
|= _SYSV_IGNBRK
;
88 if (termios_p
->c_iflag
& BRKINT
)
89 buf
.c_iflag
|= _SYSV_BRKINT
;
90 if (termios_p
->c_iflag
& IGNPAR
)
91 buf
.c_iflag
|= _SYSV_IGNPAR
;
92 if (termios_p
->c_iflag
& PARMRK
)
93 buf
.c_iflag
|= _SYSV_PARMRK
;
94 if (termios_p
->c_iflag
& INPCK
)
95 buf
.c_iflag
|= _SYSV_INPCK
;
96 if (termios_p
->c_iflag
& ISTRIP
)
97 buf
.c_iflag
|= _SYSV_ISTRIP
;
98 if (termios_p
->c_iflag
& INLCR
)
99 buf
.c_iflag
|= _SYSV_INLCR
;
100 if (termios_p
->c_iflag
& IGNCR
)
101 buf
.c_iflag
|= _SYSV_IGNCR
;
102 if (termios_p
->c_iflag
& ICRNL
)
103 buf
.c_iflag
|= _SYSV_ICRNL
;
104 if (termios_p
->c_iflag
& IXON
)
105 buf
.c_iflag
|= _SYSV_IXON
;
106 if (termios_p
->c_iflag
& IXOFF
)
107 buf
.c_iflag
|= _SYSV_IXOFF
;
108 if (termios_p
->c_iflag
& IXANY
)
109 buf
.c_iflag
|= _SYSV_IXANY
;
110 if (termios_p
->c_iflag
& IMAXBEL
)
111 buf
.c_iflag
|= _SYSV_IMAXBEL
;
114 if (termios_p
->c_oflag
& OPOST
)
115 buf
.c_oflag
|= _SYSV_OPOST
;
116 if (termios_p
->c_oflag
& ONLCR
)
117 buf
.c_oflag
|= _SYSV_ONLCR
;
119 /* So far, buf.c_cflag contains the speed in CBAUD. */
120 if (termios_p
->c_cflag
& CSTOPB
)
121 buf
.c_cflag
|= _SYSV_CSTOPB
;
122 if (termios_p
->c_cflag
& CREAD
)
123 buf
.c_cflag
|= _SYSV_CREAD
;
124 if (termios_p
->c_cflag
& PARENB
)
125 buf
.c_cflag
|= _SYSV_PARENB
;
126 if (termios_p
->c_cflag
& PARODD
)
127 buf
.c_cflag
|= _SYSV_PARODD
;
128 if (termios_p
->c_cflag
& HUPCL
)
129 buf
.c_cflag
|= _SYSV_HUPCL
;
130 if (termios_p
->c_cflag
& CLOCAL
)
131 buf
.c_cflag
|= _SYSV_CLOCAL
;
132 switch (termios_p
->c_cflag
& CSIZE
)
135 buf
.c_cflag
|= _SYSV_CS5
;
138 buf
.c_cflag
|= _SYSV_CS6
;
141 buf
.c_cflag
|= _SYSV_CS7
;
144 buf
.c_cflag
|= _SYSV_CS8
;
149 if (termios_p
->c_lflag
& ISIG
)
150 buf
.c_lflag
|= _SYSV_ISIG
;
151 if (termios_p
->c_lflag
& ICANON
)
152 buf
.c_lflag
|= _SYSV_ICANON
;
153 if (termios_p
->c_lflag
& ECHO
)
154 buf
.c_lflag
|= _SYSV_ECHO
;
155 if (termios_p
->c_lflag
& ECHOE
)
156 buf
.c_lflag
|= _SYSV_ECHOE
;
157 if (termios_p
->c_lflag
& ECHOK
)
158 buf
.c_lflag
|= _SYSV_ECHOK
;
159 if (termios_p
->c_lflag
& ECHONL
)
160 buf
.c_lflag
|= _SYSV_ECHONL
;
161 if (termios_p
->c_lflag
& NOFLSH
)
162 buf
.c_lflag
|= _SYSV_NOFLSH
;
163 if (termios_p
->c_lflag
& TOSTOP
)
164 buf
.c_lflag
|= _SYSV_TOSTOP
;
165 if (termios_p
->c_lflag
& ECHOCTL
)
166 buf
.c_lflag
|= _SYSV_ECHOCTL
;
167 if (termios_p
->c_lflag
& ECHOPRT
)
168 buf
.c_lflag
|= _SYSV_ECHOPRT
;
169 if (termios_p
->c_lflag
& ECHOKE
)
170 buf
.c_lflag
|= _SYSV_ECHOKE
;
171 if (termios_p
->c_lflag
& FLUSHO
)
172 buf
.c_lflag
|= _SYSV_FLUSHO
;
173 if (termios_p
->c_lflag
& PENDIN
)
174 buf
.c_lflag
|= _SYSV_PENDIN
;
175 if (termios_p
->c_lflag
& IEXTEN
)
176 buf
.c_lflag
|= _SYSV_IEXTEN
;
178 buf
.c_cc
[_SYSV_VINTR
] = termios_p
->c_cc
[VINTR
];
179 buf
.c_cc
[_SYSV_VQUIT
] = termios_p
->c_cc
[VQUIT
];
180 buf
.c_cc
[_SYSV_VERASE
] = termios_p
->c_cc
[VERASE
];
181 buf
.c_cc
[_SYSV_VKILL
] = termios_p
->c_cc
[VKILL
];
182 if (buf
.c_lflag
& _SYSV_ICANON
)
184 buf
.c_cc
[_SYSV_VEOF
] = termios_p
->c_cc
[VEOF
];
185 buf
.c_cc
[_SYSV_VEOL
] = termios_p
->c_cc
[VEOL
];
189 buf
.c_cc
[_SYSV_VMIN
] = termios_p
->c_cc
[VMIN
];
190 buf
.c_cc
[_SYSV_VTIME
] = termios_p
->c_cc
[VTIME
];
192 buf
.c_cc
[_SYSV_VEOL2
] = termios_p
->c_cc
[VEOL2
];
194 if (__ioctl (fd
, ioctl_function
, &buf
) < 0)
198 libc_hidden_def (tcsetattr
)