f93cf255d4
Closes #238 Update all files to list SPDX license shortname. Most files are BSD 3 clause license. The exceptions are: serge@sl ~/src/shadow$ git grep SPDX-License | grep -v BSD-3-Clause contrib/atudel:# SPDX-License-Identifier: BSD-4-Clause lib/tcbfuncs.c: * SPDX-License-Identifier: 0BSD libmisc/salt.c: * SPDX-License-Identifier: Unlicense src/login_nopam.c: * SPDX-License-Identifier: Unlicense src/nologin.c: * SPDX-License-Identifier: BSD-2-Clause src/vipw.c: * SPDX-License-Identifier: GPL-2.0-or-later Signed-off-by: Serge Hallyn <serge@hallyn.com>
57 lines
976 B
C
57 lines
976 B
C
/*
|
|
* SPDX-FileCopyrightText: 1992 - 1994, Julianne Frances Haugh
|
|
* SPDX-FileCopyrightText: 2007 - 2008, Nicolas François
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
/*
|
|
* Common code for yes/no prompting
|
|
*
|
|
* Used by pwck.c and grpck.c
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#ident "$Id$"
|
|
|
|
#include <stdio.h>
|
|
#include "prototypes.h"
|
|
|
|
/*
|
|
* yes_or_no - get answer to question from the user
|
|
*
|
|
* It returns false if no.
|
|
*
|
|
* If the read_only flag is set, it will print No, and will return
|
|
* false.
|
|
*/
|
|
bool yes_or_no (bool read_only)
|
|
{
|
|
char buf[80];
|
|
|
|
/*
|
|
* In read-only mode all questions are answered "no".
|
|
*/
|
|
if (read_only) {
|
|
(void) puts (_("No"));
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
* Typically, there's a prompt on stdout, sometimes unflushed.
|
|
*/
|
|
(void) fflush (stdout);
|
|
|
|
/*
|
|
* Get a line and see what the first character is.
|
|
*/
|
|
/* TODO: use gettext */
|
|
if (fgets (buf, (int) sizeof buf, stdin) == buf) {
|
|
return buf[0] == 'y' || buf[0] == 'Y';
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|