1bf21cd93STycho Nightingale /*
2bf21cd93STycho Nightingale  * This file and its contents are supplied under the terms of the
3bf21cd93STycho Nightingale  * Common Development and Distribution License ("CDDL"), version 1.0.
4bf21cd93STycho Nightingale  * You may only use this file in accordance with the terms of version
5bf21cd93STycho Nightingale  * 1.0 of the CDDL.
6bf21cd93STycho Nightingale  *
7bf21cd93STycho Nightingale  * A full copy of the text of the CDDL should have accompanied this
8bf21cd93STycho Nightingale  * source.  A copy of the CDDL is also available via the Internet at
9bf21cd93STycho Nightingale  * http://www.illumos.org/license/CDDL.
10bf21cd93STycho Nightingale  */
11*1fa07ac7SMike Zeller /* This file is dual-licensed; see usr/src/contrib/bhyve/LICENSE */
12bf21cd93STycho Nightingale 
13bf21cd93STycho Nightingale /*
14bf21cd93STycho Nightingale  * Copyright 2013 Pluribus Networks Inc.
154c87aefeSPatrick Mooney  * Copyright 2017 Joyent, Inc.
16bf21cd93STycho Nightingale  */
17bf21cd93STycho Nightingale 
18bf21cd93STycho Nightingale #include <sys/uio.h>
19bf21cd93STycho Nightingale 
20bf21cd93STycho Nightingale #include <termios.h>
21bf21cd93STycho Nightingale #include <unistd.h>
22bf21cd93STycho Nightingale 
23bf21cd93STycho Nightingale /*
24bf21cd93STycho Nightingale  * Make a pre-existing termios structure into "raw" mode: character-at-a-time
25bf21cd93STycho Nightingale  * mode with no characters interpreted, 8-bit data path.
26bf21cd93STycho Nightingale  */
27bf21cd93STycho Nightingale void
cfmakeraw(struct termios * t)28bf21cd93STycho Nightingale cfmakeraw(struct termios *t)
29bf21cd93STycho Nightingale {
304c87aefeSPatrick Mooney 	t->c_iflag &= ~(IMAXBEL|IXOFF|INPCK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|
314c87aefeSPatrick Mooney 	    ICRNL|IXON|IGNPAR);
32bf21cd93STycho Nightingale 	t->c_iflag |= IGNBRK;
33bf21cd93STycho Nightingale 	t->c_oflag &= ~OPOST;
344c87aefeSPatrick Mooney 	t->c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN|NOFLSH|
354c87aefeSPatrick Mooney 	    TOSTOP|PENDIN);
36bf21cd93STycho Nightingale 	t->c_cflag &= ~(CSIZE|PARENB);
37bf21cd93STycho Nightingale 	t->c_cflag |= CS8|CREAD;
38bf21cd93STycho Nightingale 	t->c_cc[VMIN] = 1;
39bf21cd93STycho Nightingale 	t->c_cc[VTIME] = 0;
40bf21cd93STycho Nightingale }
41