From e0e28a119e7a0f83ef9382413dba603ae342a8fb Mon Sep 17 00:00:00 2001 From: Oskar Date: Fri, 19 Apr 2024 23:32:15 +0200 Subject: adding modes to choice --- functions.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'functions.c') diff --git a/functions.c b/functions.c index 84cf0cb..5b434bc 100644 --- a/functions.c +++ b/functions.c @@ -6,28 +6,39 @@ #include #include -int choice() { +int choice(uint8_t mode) { + char choice; - do { + if (mode == MODE_NORMAL) { + do { + + fputs("[Y / N] ? ", stdout); - fputs("[Y / N] ? ", stdout); + choice = getchar(); + if (choice == '\n') { continue; } - choice = getchar(); - if (choice == '\n') { continue; } + while ('\n' != getchar()); - while ('\n' != getchar()); + } while ( (choice != 'Y') && (choice != 'y') && (choice != 'N') && (choice != 'n') ); - } while ( (choice != 'Y') && (choice != 'y') && (choice != 'N') && (choice != 'n') ); + if ( (choice == 'Y') || (choice == 'y') ) + { + return 0; + } - if ( (choice == 'Y') || (choice == 'y') ) - { - return 0; + if ((choice == 'N') || (choice == 'n') ) + { + return 1; + } } - if ((choice == 'N') || (choice == 'n') ) - { - return 1; + if (mode == MODE_YES) { + + } + + if (mode == MODE_NO) { + } return EXIT_FAILURE; -- cgit v1.2.3