READCONS(3) READCONS(3) NAME readcons - prompt console for input SYNOPSIS #include <u.h> #include <libc.h> char *readcons(char *prompt, char *def, int secret) DESCRIPTION Readcons prompts at the console for input. It returns a NUL-terminated buffer containing the input without a final newline. The buffer should be freed (and perhaps cleared first) when no longer needed. If the user types an empty string (just a newline) and def is non-zero, then a copy of def is returned instead of the empty string. If secret is non-zero, the input is not echoed to the screen. EXAMPLE A stripped-down version of netkey (see passwd(1)): pass = readcons("password", nil, 1); passtokey(key, pass); memset(pass, 0, strlen(pass)); free(pass); for(;;){ chal = readcons("challenge", nil, 0); sprint(buf, "%d", strtol(chal, 0, 10)); free(chal); netcrypt(key, buf); print("response: %s0, buf); } SOURCE /usr/local/plan9/src/lib9/readcons.c Page 1 Plan 9 (printed 12/22/24)