| 6671 | } |
| 6672 | |
| 6673 | static bool prompt_yn(const char *question) { |
| 6674 | if (g_auto_answer == AUTO_YES) { |
| 6675 | printf("%s (y/n): y (auto)\n", question); |
| 6676 | return true; |
| 6677 | } |
| 6678 | if (g_auto_answer == AUTO_NO) { |
| 6679 | printf("%s (y/n): n (auto)\n", question); |
| 6680 | return false; |
| 6681 | } |
| 6682 | |
| 6683 | /* Non-interactive stdin: default to "no" to avoid hanging */ |
| 6684 | #ifndef _WIN32 |
| 6685 | if (!isatty(fileno(stdin))) { |
| 6686 | (void)fprintf(stderr, |
| 6687 | "error: interactive prompt requires a terminal. Use -y or -n flags.\n"); |
| 6688 | return false; |
| 6689 | } |
| 6690 | #endif |
| 6691 | |
| 6692 | printf("%s (y/n): ", question); |
| 6693 | (void)fflush(stdout); |
| 6694 | |
| 6695 | char buf[CLI_BUF_16]; |
| 6696 | if (!fgets(buf, sizeof(buf), stdin)) { |
| 6697 | return false; |
| 6698 | } |
| 6699 | return (buf[0] == 'y' || buf[0] == 'Y') ? true : false; |
| 6700 | } |
| 6701 | |
| 6702 | /* ── SHA-256 checksum verification ─────────────────────────────── */ |
| 6703 |
no outgoing calls
no test coverage detected