Compare commits

...

3 commits

Author SHA1 Message Date
5924ff9320 Merge pull request 'Fix haxxer typer' (#1) from timoreo/ahuarc-dotfiles:master into master
Merge après 762 ans
2024-01-25 16:30:24 +01:00
8ba4baf099
Add terminal reset 2024-01-10 17:12:21 +01:00
07960b142c
Fix haxxer typer 2024-01-10 17:02:11 +01:00

View file

@ -8,6 +8,13 @@
#define READ "r"
#define CHARS_TO_WRITE 10
void reset_term(){
struct termios terminal_settings;
tcgetattr(STDIN_FILENO, &terminal_settings);
terminal_settings.c_lflag |= (ICANON | ECHO);
tcsetattr(STDIN_FILENO, TCSANOW, &terminal_settings);
}
int main(int argc, char *argv[]) {
if (argc < 2) {
return EXIT_FAILURE;
@ -33,11 +40,17 @@ int main(int argc, char *argv[]) {
for (unsigned int i = 0; i < CHARS_TO_WRITE; i++) {
current_char = fgetc(command_output_fptr);
if(feof(command_output_fptr)){
pclose(command_output_fptr);
reset_term();
return EXIT_SUCCESS;
}
printf("%c", current_char);
}
}
pclose(command_output_fptr);
reset_term();
return EXIT_SUCCESS;
}