File: cfsetspeed.c

package info (click to toggle)
libc-sparc 5.3.12-2
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 18,664 kB
  • ctags: 53,237
  • sloc: ansic: 181,379; asm: 5,080; makefile: 3,340; lex: 521; sh: 439; yacc: 401; awk: 28
file content (50 lines) | stat: -rw-r--r-- 719 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* cfsetspeed.c - emulate BSD cfsetspeed with cfset[io]speed - rick sladkey */

#include <termios.h>

static const struct {
	int flag, val;
} xref[] = {
	B0,	0,
	B50,	50,
	B75,	75,
	B110,	110,
	B134,	134,
	B150,	150,
	B200,	200,
	B300,	300,
	B600,	600,
	B1200,	1200,
	B1800,	1800,
	B2400,	2400,
	B4800,	4800,
	B9600,	9600,
	B19200,	19200,
	B38400,	38400,
#ifdef B57600
	B57600, 57600,
#endif
#ifdef B115200
	B115200,115200,
#endif
#ifdef B230400
	B230400,230400,
#endif
	0,	-1,
};

int cfsetspeed(struct termios *p, int speed)
{
	int i;

	for (i = 0; xref[i].val != -1; i++) {
		if (xref[i].val == speed) {
			speed = xref[i].flag;
			cfsetispeed(p, speed);
			cfsetospeed(p, speed);
			return 0;
		}
	}
	return -1;
}