cmdline: specify to use stdout for output when parsing a file
[libcmdline.git] / src / lib / cmdline_socket.c
index 4474c6f..ee03c5d 100644 (file)
@@ -212,7 +212,8 @@ cmdline_accept(cmdline_parse_ctx_t *ctx, const char *prompt, int s)
 #endif
 
 struct cmdline *
-cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path)
+cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path,
+                int use_stdout)
 {
        int fd;
        fd = open(path, O_RDONLY, 0);
@@ -220,7 +221,7 @@ cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path)
                dprintf("open() failed\n");
                return NULL;
        }
-       return (cmdline_new(ctx, prompt, fd, -1));
+       return (cmdline_new(ctx, prompt, fd, use_stdout ? 1 : -1));
 }
 
 struct cmdline *