(compare_entry): Partially undo patch made by Klaus Espenlaub. There
[glibc/history.git] / termios / cfsetspeed.c
blobb3c8aa3f424b485479a21b3ce3ef505082aec9b9
1 /* Copyright (C) 1992, 1993, 1996, 1997 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 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.
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.
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 not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
19 #include <termios.h>
20 #include <errno.h>
21 #include <stddef.h>
23 static struct speed_struct
25 speed_t value;
26 speed_t internal;
27 } speeds[] =
29 #ifdef B0
30 { 0, B0 },
31 #endif
32 #ifdef B50
33 { 50, B50 },
34 #endif
35 #ifdef B75
36 { 75, B75 },
37 #endif
38 #ifdef B110
39 { 110, B110 },
40 #endif
41 #ifdef B134
42 { 134, B134 },
43 #endif
44 #ifdef B150
45 { 150, B150 },
46 #endif
47 #ifdef B200
48 { 200, B200 },
49 #endif
50 #ifdef B300
51 { 300, B300 },
52 #endif
53 #ifdef B600
54 { 600, B600 },
55 #endif
56 #ifdef B1200
57 { 1200, B1200 },
58 #endif
59 #ifdef B1200
60 { 1200, B1200 },
61 #endif
62 #ifdef B1800
63 { 1800, B1800 },
64 #endif
65 #ifdef B2400
66 { 2400, B2400 },
67 #endif
68 #ifdef B4800
69 { 4800, B4800 },
70 #endif
71 #ifdef B9600
72 { 9600, B9600 },
73 #endif
74 #ifdef B19200
75 { 19200, B19200 },
76 #endif
77 #ifdef B38400
78 { 38400, B38400 },
79 #endif
80 #ifdef B57600
81 { 57600, B57600 },
82 #endif
83 #ifdef B76800
84 { 76800, B76800 },
85 #endif
86 #ifdef B115200
87 { 115200, B115200 },
88 #endif
89 #ifdef B153600
90 { 153600, B153600 },
91 #endif
92 #ifdef B230400
93 { 230400, B230400 },
94 #endif
95 #ifdef B307200
96 { 307200, B307200 },
97 #endif
98 #ifdef B460800
99 { 460800, B460800 },
100 #endif
104 /* Set both the input and output baud rates stored in *TERMIOS_P to SPEED. */
105 void
106 cfsetspeed (struct termios *termios_p, speed_t speed)
108 size_t cnt;
110 for (cnt = 0; cnt < sizeof (speeds) / sizeof (speeds[0]); ++cnt)
111 if (speed == speeds[cnt].internal)
113 cfsetispeed (termios_p, speed);
114 cfsetospeed (termios_p, speed);
115 return;
117 else if (speed == speeds[cnt].value)
119 cfsetispeed (termios_p, speeds[cnt].internal);
120 cfsetospeed (termios_p, speeds[cnt].internal);
121 return;
124 __set_errno (EINVAL);