Skip to content

Instantly share code, notes, and snippets.

@Globidev Globidev/main.c Secret
Created May 10, 2016

Embed
What would you like to do?
Tiny stty
#include <termios.h>
#include <unistd.h>
#include <stdio.h>
#include <assert.h>
#define TEST_FLAG(flag, flags) \
printf(" %s: \t%s\n", #flag, (flags & flag) ? "ON" : "OFF");
int main() {
struct termios term;
assert((tcgetattr(STDOUT_FILENO, &term) == 0));
printf("c_iflags\n");
TEST_FLAG(IGNBRK, term.c_iflag);
TEST_FLAG(BRKINT, term.c_iflag);
TEST_FLAG(IGNPAR, term.c_iflag);
TEST_FLAG(PARMRK, term.c_iflag);
TEST_FLAG(INPCK, term.c_iflag);
TEST_FLAG(ISTRIP, term.c_iflag);
TEST_FLAG(INLCR, term.c_iflag);
TEST_FLAG(IGNCR, term.c_iflag);
TEST_FLAG(ICRNL, term.c_iflag);
TEST_FLAG(IUCLC, term.c_iflag);
TEST_FLAG(IXON, term.c_iflag);
TEST_FLAG(IXANY, term.c_iflag);
TEST_FLAG(IXOFF, term.c_iflag);
TEST_FLAG(IMAXBEL, term.c_iflag);
TEST_FLAG(IUTF8, term.c_iflag);
printf("c_oflags\n");
TEST_FLAG(OPOST, term.c_oflag);
TEST_FLAG(OLCUC, term.c_oflag);
TEST_FLAG(ONLCR, term.c_oflag);
TEST_FLAG(OCRNL, term.c_oflag);
TEST_FLAG(ONOCR, term.c_oflag);
TEST_FLAG(ONLRET, term.c_oflag);
TEST_FLAG(OFILL, term.c_oflag);
TEST_FLAG(OFDEL, term.c_oflag);
TEST_FLAG(NLDLY, term.c_oflag);
TEST_FLAG(CRDLY, term.c_oflag);
TEST_FLAG(TABDLY, term.c_oflag);
TEST_FLAG(BSDLY, term.c_oflag);
TEST_FLAG(VTDLY, term.c_oflag);
TEST_FLAG(FFDLY, term.c_oflag);
printf("c_cflag\n");
TEST_FLAG(CBAUD, term.c_cflag);
TEST_FLAG(CBAUDEX, term.c_cflag);
TEST_FLAG(CIBAUD, term.c_cflag);
TEST_FLAG(CLOCAL, term.c_cflag);
TEST_FLAG(CMSPAR, term.c_cflag);
TEST_FLAG(CREAD, term.c_cflag);
TEST_FLAG(CRTSCTS, term.c_cflag);
TEST_FLAG(CSIZE, term.c_cflag);
TEST_FLAG(CSTOPB, term.c_cflag);
TEST_FLAG(HUPCL, term.c_cflag);
TEST_FLAG(PARENB, term.c_cflag);
TEST_FLAG(PARODD, term.c_cflag);
printf("c_lflags\n");
TEST_FLAG(ISIG, term.c_lflag);
TEST_FLAG(ICANON, term.c_lflag);
TEST_FLAG(XCASE, term.c_lflag);
TEST_FLAG(ECHO, term.c_lflag);
TEST_FLAG(ECHOE, term.c_lflag);
TEST_FLAG(ECHOK, term.c_lflag);
TEST_FLAG(ECHONL, term.c_lflag);
TEST_FLAG(ECHOCTL, term.c_lflag);
TEST_FLAG(ECHOPRT, term.c_lflag);
TEST_FLAG(ECHOKE, term.c_lflag);
TEST_FLAG(FLUSHO, term.c_lflag);
TEST_FLAG(NOFLSH, term.c_lflag);
TEST_FLAG(TOSTOP, term.c_lflag);
TEST_FLAG(PENDIN, term.c_lflag);
TEST_FLAG(IEXTEN, term.c_lflag);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.