From 820675afa07d25cbd53d98e92fc174021033daa2 Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Thu, 27 Oct 2011 22:46:15 +0200 Subject: [PATCH] cmdline: specify to use stdout for output when parsing a file Signed-off-by: Olivier Matz --- src/lib/cmdline_socket.c | 5 +++-- src/lib/cmdline_socket.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/lib/cmdline_socket.c b/src/lib/cmdline_socket.c index 4474c6f..ee03c5d 100644 --- a/src/lib/cmdline_socket.c +++ b/src/lib/cmdline_socket.c @@ -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 * diff --git a/src/lib/cmdline_socket.h b/src/lib/cmdline_socket.h index 3ae2f66..768dc2e 100644 --- a/src/lib/cmdline_socket.h +++ b/src/lib/cmdline_socket.h @@ -69,7 +69,8 @@ int cmdline_unix_listen(char *filename); struct cmdline *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); +struct cmdline *cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, + const char *path, int use_stdout); struct cmdline *cmdline_stdin_new(cmdline_parse_ctx_t *ctx, const char *prompt); void cmdline_stdin_exit(struct cmdline *cl); -- 2.20.1