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 */ 11bf21cd93STycho Nightingale 12bf21cd93STycho Nightingale /* 13bf21cd93STycho Nightingale * Copyright 2013 Pluribus Networks Inc. 14*4c87aefeSPatrick Mooney * Copyright 2017 Joyent, Inc. 15bf21cd93STycho Nightingale */ 16bf21cd93STycho Nightingale 17bf21cd93STycho Nightingale #include <sys/uio.h> 18bf21cd93STycho Nightingale 19bf21cd93STycho Nightingale #include <termios.h> 20bf21cd93STycho Nightingale #include <unistd.h> 21bf21cd93STycho Nightingale 22bf21cd93STycho Nightingale /* 23bf21cd93STycho Nightingale * Make a pre-existing termios structure into "raw" mode: character-at-a-time 24bf21cd93STycho Nightingale * mode with no characters interpreted, 8-bit data path. 25bf21cd93STycho Nightingale */ 26bf21cd93STycho Nightingale void 27bf21cd93STycho Nightingale cfmakeraw(struct termios *t) 28bf21cd93STycho Nightingale { 29*4c87aefeSPatrick Mooney t->c_iflag &= ~(IMAXBEL|IXOFF|INPCK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR| 30*4c87aefeSPatrick Mooney ICRNL|IXON|IGNPAR); 31bf21cd93STycho Nightingale t->c_iflag |= IGNBRK; 32bf21cd93STycho Nightingale t->c_oflag &= ~OPOST; 33*4c87aefeSPatrick Mooney t->c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|ICANON|ISIG|IEXTEN|NOFLSH| 34*4c87aefeSPatrick Mooney TOSTOP|PENDIN); 35bf21cd93STycho Nightingale t->c_cflag &= ~(CSIZE|PARENB); 36bf21cd93STycho Nightingale t->c_cflag |= CS8|CREAD; 37bf21cd93STycho Nightingale t->c_cc[VMIN] = 1; 38bf21cd93STycho Nightingale t->c_cc[VTIME] = 0; 39bf21cd93STycho Nightingale } 40