From dbe0fd17f2323f108715db0bd0f734e9563e40d8 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 8 May 2013 12:27:25 -0400 Subject: mtd-utils: new prompt() helper for talking to the user We've got a few tools that prompt the user for "yes/no" questions. Add a common helper to simplify the various implementations. Signed-off-by: Mike Frysinger Signed-off-by: Artem Bityutskiy --- flash_otp_lock.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'flash_otp_lock.c') diff --git a/flash_otp_lock.c b/flash_otp_lock.c index cc8759e..3c39a2d 100644 --- a/flash_otp_lock.c +++ b/flash_otp_lock.c @@ -13,11 +13,12 @@ #include #include +#include "common.h" int main(int argc,char *argv[]) { int fd, val, ret, offset, size; - char *p, buf[8]; + char *p; if (argc != 5 || strcmp(argv[1], "-u")) { fprintf(stderr, "Usage: %s -u \n", PROGRAM_NAME); @@ -53,8 +54,7 @@ int main(int argc,char *argv[]) printf("About to lock OTP user data on %s from 0x%x to 0x%x\n", argv[2], offset, offset + size); - printf("Are you sure (yes|no)? "); - if (fgets(buf, sizeof(buf), stdin) && strcmp(buf, "yes\n") == 0) { + if (prompt("Are you sure?", false)) { struct otp_info info; info.start = offset; info.length = size; -- cgit v1.2.3