Files
plan9port/man/man3/readcons.3
Dmitri Vereshchagin 10564b1175 tmac/tmac.an: define .MR in a groff compatible way
groff 1.23.0 added .MR to its -man macro package.  The NEWS file states
that the inclusion of the macro "was prompted by its introduction to
Plan 9 from User Space's troff in August 2020."  From d32deab it seems
that the name for Plan 9 from User Space's implementation was suggested
by groff maintainer G. Brandon Robinson.

Not sure if the intention was to make these definitions compatible, but
it would be nice if they were.

Currently, Plan 9 from User Space's .MR expects its second argument to
be parenthesized.  groff's .MR does not.  This results in extra
parentheses appearing in manual references when viewing Plan 9 from User
Space's manual pages on a system using groff.
2025-07-27 09:58:50 -04:00

51 lines
988 B
Groff

.TH READCONS 3
.SH NAME
readcons \- prompt console for input
.SH SYNOPSIS
.B
#include <u.h>
.PP
.B
#include <libc.h>
.PP
.B
char *readcons(char *prompt, char *def, int secret)
.SH DESCRIPTION
.I 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.
.PP
If the user types an empty string (just a newline) and
.I def
is non-zero, then a copy of
.I def
is returned instead of the empty string.
.PP
If
.I secret
is non-zero, the input is not echoed to the screen.
.SH EXAMPLE
A stripped-down version of
.I netkey
(see
.MR passwd 1 ):
.IP
.EX
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: %s\n", buf);
}
.EE
.SH SOURCE
.B \*9/src/lib9/readcons.c