3 readcons \- prompt console for input
12 char *readcons(char *prompt, char *def, int secret)
15 prompts at the console for input.
16 It returns a NUL-terminated buffer containing the input
17 without a final newline.
18 The buffer should be freed (and perhaps cleared first)
19 when no longer needed.
21 If the user types an empty string (just a newline) and
23 is non-zero, then a copy of
25 is returned instead of the empty string.
29 is non-zero, the input is not echoed to the screen.
31 A stripped-down version of
35 pass = readcons("password", nil, 1);
37 memset(pass, 0, strlen(pass));
40 chal = readcons("challenge", nil, 0);
41 sprint(buf, "%d", strtol(chal, 0, 10));
44 print("response: %s\n", buf);
48 .B \*9/src/lib9/readcons.c