#include <stdio.h>
#include <termio.h>
#include <sys/fcntl.h>

main(int argc, char *argv[]) 
{
	struct termios tp;
	int fd;
	char buf[80];

	if (argc < 2) {
		printf("Must give me a terminal name\n");
		exit(-1);
	}

	if ((fd = open(argv[1], O_RDONLY)) < 0) {
		printf("bad terminal device, try another\n");
		exit(-1);
	}
	
	if (tcgetattr(fd, &tp) < 0) {
		printf("Couldn't get term attributes");
		exit(-1);
	}

	if (tcsetattr(fd, TCSAFLUSH, &tp) < 0) {
		perror("Couldn't set term attributes");
		exit(-1);
	}
	
	if (tcgetattr(fd, &tp) < 0) {
		printf("Couldn't get term attributes");
		exit(-1);
	}

	tp.c_iflag = 022406;
	tp.c_oflag = 04;
	tp.c_cflag = 02275;
	tp.c_lflag = 0105073;

	printf("iflag - 0%o; oflag - 0%o; cflag - 0%o; lflag - 0%o\n",
			tp.c_iflag, tp.c_oflag, tp.c_cflag, tp.c_lflag);
	
}