update from main archvie 961013
[glibc.git] / termios / cfsetspeed.c
blob5f22eade4b67ca251c9122810b68751d6c8ec6f9
1 /* Copyright (C) 1992, 1993, 1996 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
16 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, 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); ++cnt)
111 if (speed == speeds[cnt].value)
113 cfsetispeed (termios_p, speed);
114 cfsetospeed (termios_p, speed);
115 return;
118 __set_errno (EINVAL);