Fix haxxer typer #1
1 changed files with 14 additions and 1 deletions
|
@ -8,6 +8,13 @@
|
||||||
#define READ "r"
|
#define READ "r"
|
||||||
#define CHARS_TO_WRITE 10
|
#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[]) {
|
int main(int argc, char *argv[]) {
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@ -31,13 +38,19 @@ int main(int argc, char *argv[]) {
|
||||||
while (!feof(command_output_fptr)) {
|
while (!feof(command_output_fptr)) {
|
||||||
getchar();
|
getchar();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < CHARS_TO_WRITE && !feof(command_output_fptr); i++) {
|
for (unsigned int i = 0; i < CHARS_TO_WRITE; i++) {
|
||||||
current_char = fgetc(command_output_fptr);
|
current_char = fgetc(command_output_fptr);
|
||||||
|
if(feof(command_output_fptr)){
|
||||||
|
pclose(command_output_fptr);
|
||||||
|
reset_term();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
printf("%c", current_char);
|
printf("%c", current_char);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pclose(command_output_fptr);
|
pclose(command_output_fptr);
|
||||||
|
reset_term();
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue