Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
READCONS(3)		   Library Functions Manual		   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

	      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
       /src/lib9/readcons.c

								   READCONS(3)

NAME | SYNOPSIS | DESCRIPTION | EXAMPLE | SOURCE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=readcons&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help