More work on docs for the new opcodes.
[retro/experimental.git] / ngaro / perl / restore-term.c
blob0c51bedc6df8e8d7f822d747ea49448196681ce9
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <termios.h>
4 #include <unistd.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <fcntl.h>
9 #define STDIN 0
11 int main(void)
13 struct termios t;
14 int fd;
15 char fname[1024];
17 fname[0] = 0;
18 strncat(fname, getenv("HOME"), 1000);
19 strcat(fname, "/.term_settings");
20 fd = open(fname, O_RDWR);
21 if(fd == -1) return 2;
23 if(read(fd, &t, sizeof(struct termios)) != sizeof(struct termios))
24 return 3;
25 if(close(fd)) return 4;
27 if(tcsetattr(STDIN, TCSANOW, &t)) return 5;
29 if(unlink(fname)) return 6;
31 return 0;