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