| 6835 | } |
| 6836 | |
| 6837 | static bool prompt_yn(const char *question) { |
| 6838 | if (g_auto_answer == AUTO_YES) { |
| 6839 | printf("%s (y/n): y (auto)\n", question); |
| 6840 | return true; |
| 6841 | } |
| 6842 | if (g_auto_answer == AUTO_NO) { |
| 6843 | printf("%s (y/n): n (auto)\n", question); |
| 6844 | return false; |
| 6845 | } |
| 6846 | |
| 6847 | /* Non-interactive stdin: default to "no" to avoid hanging */ |
| 6848 | #ifndef _WIN32 |
| 6849 | if (!isatty(fileno(stdin))) { |
| 6850 | (void)fprintf(stderr, |
| 6851 | "error: interactive prompt requires a terminal. Use -y or -n flags.\n"); |
| 6852 | return false; |
| 6853 | } |
| 6854 | #endif |
| 6855 | |
| 6856 | printf("%s (y/n): ", question); |
| 6857 | (void)fflush(stdout); |
| 6858 | |
| 6859 | char buf[CLI_BUF_16]; |
| 6860 | if (!fgets(buf, sizeof(buf), stdin)) { |
| 6861 | return false; |
| 6862 | } |
| 6863 | return (buf[0] == 'y' || buf[0] == 'Y') ? true : false; |
| 6864 | } |
| 6865 | |
| 6866 | /* ── SHA-256 checksum verification ─────────────────────────────── */ |
| 6867 |
no outgoing calls
no test coverage detected