| readcons \- prompt console for input |
| char *readcons(char *prompt, char *def, int secret) |
| prompts at the console for input. |
| It returns a NUL-terminated buffer containing the input |
| The buffer should be freed (and perhaps cleared first) |
| If the user types an empty string (just a newline) and |
| is non-zero, then a copy of |
| is returned instead of the empty string. |
| is non-zero, the input is not echoed to the screen. |
| A stripped-down version of |
| pass = readcons("password", nil, 1); |
| memset(pass, 0, strlen(pass)); |
| chal = readcons("challenge", nil, 0); |
| sprint(buf, "%d", strtol(chal, 0, 10)); |
| print("response: %s\n", buf); |
| .B \*9/src/lib9/readcons.c |