]> git.ipfire.org Git - thirdparty/glibc.git/blame - termios/cfsetspeed.c
update from main archvie 961013
[thirdparty/glibc.git] / termios / cfsetspeed.c
CommitLineData
d41c6f61 1/* Copyright (C) 1992, 1993, 1996 Free Software Foundation, Inc.
28f540f4
RM
2This file is part of the GNU C Library.
3
4The GNU C Library is free software; you can redistribute it and/or
5modify it under the terms of the GNU Library General Public License as
6published by the Free Software Foundation; either version 2 of the
7License, or (at your option) any later version.
8
9The GNU C Library is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12Library General Public License for more details.
13
14You should have received a copy of the GNU Library General Public
15License along with the GNU C Library; see the file COPYING.LIB. If
16not, write to the Free Software Foundation, Inc., 675 Mass Ave,
17Cambridge, MA 02139, USA. */
18
28f540f4
RM
19#include <termios.h>
20#include <errno.h>
21#include <stddef.h>
22
d41c6f61
UD
23static struct speed_struct
24{
25 speed_t value;
26 speed_t internal;
27} speeds[] =
28 {
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
101 };
102
103
28f540f4
RM
104/* Set both the input and output baud rates stored in *TERMIOS_P to SPEED. */
105void
d41c6f61 106cfsetspeed (struct termios *termios_p, speed_t speed)
28f540f4 107{
d41c6f61
UD
108 size_t cnt;
109
110 for (cnt = 0; cnt < sizeof (speeds); ++cnt)
111 if (speed == speeds[cnt].value)
112 {
113 cfsetispeed (termios_p, speed);
114 cfsetospeed (termios_p, speed);
115 return;
116 }
117
118 __set_errno (EINVAL);
28f540f4 119}