Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Napisz program, który sprawdzi, czy z deskryptorem standardowego wejścia (STDIN_FILENO lub wartość 0) jest związany terminal. Jeśli tak, to program powinien wypisać nazwę pliku urządzenia tego terminala, oraz kilka jego bieżących ustawień.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <termios.h>
- int main(void)
- {
- if(isatty(STDIN_FILENO)){
- struct termios termios_p;
- tcgetattr(STDIN_FILENO, &termios_p);
- printf("Nazwa terminala: %s\n", ttyname(STDIN_FILENO));
- if(termios_p.c_lflag & ECHO)
- printf("* Echo wlaczone\n");
- else
- printf("* Echo wylaczone\n");
- if(termios_p.c_lflag & OPOST)
- printf("* Opost wlaczone\n");
- else
- printf("* Opost wylaczone\n");
- if(termios_p.c_cflag & CREAD)
- printf("* Cread wlaczone\n");
- else
- printf("* Cread wylaczone\n");
- }
- else{
- perror("isatty");
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement