| 6621 | } |
| 6622 | |
| 6623 | static bool prompt_yn(const char *question) { |
| 6624 | if (g_auto_answer == AUTO_YES) { |
| 6625 | printf("%s (y/n): y (auto)\n", question); |
| 6626 | return true; |
| 6627 | } |
| 6628 | if (g_auto_answer == AUTO_NO) { |
| 6629 | printf("%s (y/n): n (auto)\n", question); |
| 6630 | return false; |
| 6631 | } |
| 6632 | |
| 6633 | /* Non-interactive stdin: default to "no" to avoid hanging */ |
| 6634 | #ifndef _WIN32 |
| 6635 | if (!isatty(fileno(stdin))) { |
| 6636 | (void)fprintf(stderr, |
| 6637 | "error: interactive prompt requires a terminal. Use -y or -n flags.\n"); |
| 6638 | return false; |
| 6639 | } |
| 6640 | #endif |
| 6641 | |
| 6642 | printf("%s (y/n): ", question); |
| 6643 | (void)fflush(stdout); |
| 6644 | |
| 6645 | char buf[CLI_BUF_16]; |
| 6646 | if (!fgets(buf, sizeof(buf), stdin)) { |
| 6647 | return false; |
| 6648 | } |
| 6649 | return (buf[0] == 'y' || buf[0] == 'Y') ? true : false; |
| 6650 | } |
| 6651 | |
| 6652 | /* ── SHA-256 checksum verification ─────────────────────────────── */ |
| 6653 |
no outgoing calls
no test coverage detected