xor instead of more complicated version from a text editor tutorial
This commit is contained in:
parent
81cc1ef31b
commit
02353836ca
@ -17,7 +17,7 @@ int main(int argc, char *argv[]){
|
|||||||
|
|
||||||
/* disable terminal echo */
|
/* disable terminal echo */
|
||||||
tcgetattr(STDIN_FILENO, &t);
|
tcgetattr(STDIN_FILENO, &t);
|
||||||
t.c_lflag &= ~(ECHO);
|
t.c_lflag ^= ECHO;
|
||||||
tcsetattr(STDIN_FILENO, TCSAFLUSH, &t);
|
tcsetattr(STDIN_FILENO, TCSAFLUSH, &t);
|
||||||
|
|
||||||
eof = EOF;
|
eof = EOF;
|
||||||
@ -30,6 +30,7 @@ int main(int argc, char *argv[]){
|
|||||||
case 'e': to_stderr = 1; break;
|
case 'e': to_stderr = 1; break;
|
||||||
case 'n': include_eof = 1; break;
|
case 'n': include_eof = 1; break;
|
||||||
case 'o': to_stdout = 1; break;
|
case 'o': to_stdout = 1; break;
|
||||||
|
case 'p': printf("not yet implemented\n");
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Usage: %s (-1eno) (-p [program])\n",
|
fprintf(stderr, "Usage: %s (-1eno) (-p [program])\n",
|
||||||
argv[0] == NULL ? program_name : argv[0]);
|
argv[0] == NULL ? program_name : argv[0]);
|
||||||
@ -49,5 +50,9 @@ int main(int argc, char *argv[]){
|
|||||||
if(include_eof && to_stderr)
|
if(include_eof && to_stderr)
|
||||||
putc(c, stderr);
|
putc(c, stderr);
|
||||||
|
|
||||||
|
tcgetattr(STDIN_FILENO, &t);
|
||||||
|
t.c_lflag |= ECHO;
|
||||||
|
tcsetattr(STDIN_FILENO, TCSAFLUSH, &t);
|
||||||
|
|
||||||
return EX_OK;
|
return EX_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user