13 const char *termfile = "/dev/tty";
14 struct termios saved_term;
16 int main(int argc, char **argv)
40 if((fd = open(termfile, O_RDWR)) == -1) {
41 fprintf(stderr, "failed to open terminal device: %s: %s\n", termfile, strerror(errno));
45 if(tcgetattr(fd, &term) == -1) {
46 fprintf(stderr, "failed to get terminal attributes: %s\n", strerror(errno));
50 term.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
51 term.c_oflag &= ~OPOST;
52 term.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
53 term.c_cflag = (term.c_cflag & ~(CSIZE | PARENB)) | CS8;
55 if(tcsetattr(fd, TCSAFLUSH, &term) == -1) {
56 fprintf(stderr, "failed to change terminal attributes: %s\n", strerror(errno));
67 open("ansitris.log", O_WRONLY | O_CREAT, 0664);
70 if(init_game() == -1) {
80 tcsetattr(0, TCSAFLUSH, &saved_term);