From a5dffa4b67fb0ad635088c9853abf6fcb181ac3c Mon Sep 17 00:00:00 2001 From: Pierre Aubert Date: Thu, 24 Apr 2014 10:30:07 +0200 Subject: Add the function 'confirm_yesno' for interactive User's confirmation is asked in different commands. This commit adds a function for such confirmation. Acked-by: Pantelis Antoniou Signed-off-by: Pierre Aubert --- common/cmd_otp.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'common/cmd_otp.c') diff --git a/common/cmd_otp.c b/common/cmd_otp.c index 67808aa..593bb8c 100644 --- a/common/cmd_otp.c +++ b/common/cmd_otp.c @@ -158,21 +158,9 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) lowup(half + count - 1), page + (half + count - 1) / 2, half + count ); - - i = 0; - while (1) { - if (tstc()) { - const char exp_ans[] = "YES\r"; - char c; - putc(c = getc()); - if (exp_ans[i++] != c) { - printf(" Aborting\n"); - return 1; - } else if (!exp_ans[i]) { - puts("\n"); - break; - } - } + if (!confirm_yesno()) { + printf(" Aborting\n"); + return 1; } } -- cgit v1.1