diff options
author | Oskar <[email protected]> | 2024-04-20 00:03:57 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-04-20 00:03:57 +0200 |
commit | e7e9f3077f3dbbe31b22316a47980c417d915b49 (patch) | |
tree | dc8e1a713a7804c2c0afc6676a07690c06acad19 /functions.c | |
parent | e0e28a119e7a0f83ef9382413dba603ae342a8fb (diff) |
Choicemode switches
Diffstat (limited to 'functions.c')
-rw-r--r-- | functions.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/functions.c b/functions.c index 5b434bc..0b17512 100644 --- a/functions.c +++ b/functions.c @@ -9,36 +9,33 @@ int choice(uint8_t mode) { char choice; + char modechoice; - if (mode == MODE_NORMAL) { - do { + do { - fputs("[Y / N] ? ", stdout); + if (mode == MODE_NORMAL) { fputs("[Y / N] ? ", stdout); } + if (mode == MODE_YES) { fputs("[Y / n] ? ", stdout); } + if (mode == MODE_NO) { fputs("[y / N] ? ", stdout); } - choice = getchar(); - if (choice == '\n') { continue; } + choice = getchar(); + if (choice == '\n' && mode == MODE_YES) { modechoice = 'Y'; choice = modechoice; goto modeskip;} + if (choice == '\n' && mode == MODE_NO) { modechoice = 'N'; choice = modechoice; goto modeskip;} + if (choice == '\n' && mode == MODE_NORMAL) { continue; } - while ('\n' != getchar()); + while ('\n' != getchar()); - } while ( (choice != 'Y') && (choice != 'y') && (choice != 'N') && (choice != 'n') ); + modeskip: - if ( (choice == 'Y') || (choice == 'y') ) - { - return 0; - } + } while ( (choice != 'Y') && (choice != 'y') && (choice != 'N') && (choice != 'n') ); - if ((choice == 'N') || (choice == 'n') ) - { - return 1; - } + if ( (choice == 'Y') || (choice == 'y') ) + { + return 0; } - if (mode == MODE_YES) { - - } - - if (mode == MODE_NO) { - + if ((choice == 'N') || (choice == 'n') ) + { + return 1; } return EXIT_FAILURE; |