aboutsummaryrefslogtreecommitdiff
path: root/lib/getyn.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-12-07 14:57:32 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2012-12-07 15:16:14 +0200
commit5a7b73860974384d8e00065105435403b0842ab0 (patch)
tree3f029c22f0a29a842002279bb4b5561af61a8aa8 /lib/getyn.c
parentc12cd5695cf1a6c2c44100a68762ab66356f43b8 (diff)
downloadeclat-5a7b73860974384d8e00065105435403b0842ab0.tar.gz
eclat-5a7b73860974384d8e00065105435403b0842ab0.tar.bz2
Re-implement confirmation support.
* doc/eclat-delete-volume.1: Update. * doc/eclat-release-address.1: Update. * doc/eclat.1: Update. * doc/eclat.conf.5: New section "CONFIRMATION" * lib/getyn.c (eclat_vgetyn): Negative default stands for no default at all. * lib/confirm.c (eclat_confirm_mode): Remove. (eclat_confirm): Change signature. Act according to the first argument. * lib/libeclat.h (eclat_confirm_mode): New enum. (eclat_confirm): Change signature. * src/cmdline.opt: Change handling of -Y and -N options. * src/config.c: New statement "confirm". * src/cretags.c: Remove call to eclat_confirm. This is done by the caller. * src/delvol.c: Likewise. * src/reladdr.c: Likewise. * src/eclat.c (confirm_mode): New variable. (command) <flags>: New member. (cmdtab): Mark commands with appropriate flags. (main): Call eclat_confirm to confirm the command. * src/eclat.h (confirm_mode): New extern. (set_command_confirmation): New proto. * etc/eclat.cfin: Set a reasonably safe confirmation default. * lib/forlan.c (strtots): Remove unused variable.
Diffstat (limited to 'lib/getyn.c')
-rw-r--r--lib/getyn.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/getyn.c b/lib/getyn.c
index 8ec8a07..ee49d3f 100644
--- a/lib/getyn.c
+++ b/lib/getyn.c
@@ -21,10 +21,14 @@
int
eclat_vgetyn(int dfl, const char *prompt, va_list ap)
{
- static char *hint[] = { "y/N", "Y/n" };
+ static char *hint[] = { "y/n", "y/N", "Y/n" };
int state = 0;
int c, resp;
-
+
+ if (dfl < -1)
+ dfl = -1;
+ else if (dfl > 1)
+ dfl = 1;
do {
switch (state) {
case 1:
@@ -43,7 +47,9 @@ eclat_vgetyn(int dfl, const char *prompt, va_list ap)
case 'N':
return 0;
case '\n':
- return dfl;
+ if (dfl >= 0)
+ return dfl;
+ /* fall through */
default:
err("Please, reply 'y' or 'n'");
}
@@ -52,7 +58,7 @@ eclat_vgetyn(int dfl, const char *prompt, va_list ap)
break;
case 0:
vfprintf(stdout, prompt, ap);
- fprintf(stdout, " [%s] ", hint[dfl]);
+ fprintf(stdout, " [%s] ", hint[dfl+1]);
fflush(stdout);
state = 1;
break;

Return to:

Send suggestions and report system problems to the System administrator.