| 13 | #include "cmdline_socket.h" |
| 14 | |
| 15 | struct cmdline * |
| 16 | cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path) |
| 17 | { |
| 18 | int fd; |
| 19 | |
| 20 | /* everything else is checked in cmdline_new() */ |
| 21 | if (!path) |
| 22 | return NULL; |
| 23 | |
| 24 | fd = open(path, O_RDONLY, 0); |
| 25 | if (fd < 0) { |
| 26 | dprintf("open() failed\n"); |
| 27 | return NULL; |
| 28 | } |
| 29 | return cmdline_new(ctx, prompt, fd, -1); |
| 30 | } |
| 31 | |
| 32 | struct cmdline * |
| 33 | cmdline_stdin_new(cmdline_parse_ctx_t *ctx, const char *prompt) |