| 14097 | static bool cli_stdin_allowed_for_schema(const char *schema_str, cbm_cli_stdin_kind_t stdin_kind); |
| 14098 | |
| 14099 | cbm_cli_stdin_kind_t cbm_cli_stdin_kind(int fd) { |
| 14100 | #ifdef _WIN32 |
| 14101 | bool terminal = _isatty(fd) != 0; |
| 14102 | #else |
| 14103 | bool terminal = isatty(fd) != 0; |
| 14104 | #endif |
| 14105 | if (terminal) { |
| 14106 | return CBM_CLI_STDIN_TERMINAL; |
| 14107 | } |
| 14108 | struct stat state; |
| 14109 | if (fstat(fd, &state) == 0 && S_ISREG(state.st_mode)) { |
| 14110 | return CBM_CLI_STDIN_FILE; |
| 14111 | } |
| 14112 | return CBM_CLI_STDIN_STREAM; |
| 14113 | } |
| 14114 | |
| 14115 | bool cbm_cli_args_from_stdin_allowed(const char *tool_name, cbm_cli_stdin_kind_t stdin_kind) { |
| 14116 | /* An interactive run has nothing piped to read: consulting the terminal |
no outgoing calls
no test coverage detected