summaryrefslogtreecommitdiff
path: root/src/termios/cfsetospeed.c
blob: edb3f9946aa76714f195ab91bb25e1ebd8a3ab49 (plain)
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
#include <termios.h>
#include <errno.h>
#include "_assert.h"

int cfsetospeed(struct termios *termios_p, speed_t speed)
{
	ASSERT_NONNULL(termios_p);
	switch (speed) {
	case B0:
	case B50:
	case B75:
	case B110:
	case B134:
	case B150:
	case B200:
	case B300:
	case B600:
	case B1200:
	case B1800:
	case B2400:
	case B4800:
	case B9600:
	case B19200:
	case B38400:
		termios_p->c_oflag &= ~B38400;
		termios_p->c_oflag |= speed;
		return 0;

	default:
		break;
	}

	errno = EINVAL;
	return -1;
}
/*
POSIX(1)
*/