From: Olivier Matz Date: Thu, 27 Oct 2011 20:46:15 +0000 (+0200) Subject: cmdline: specify to use stdout for output when parsing a file X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=820675afa07d25cbd53d98e92fc174021033daa2;p=libcmdline.git cmdline: specify to use stdout for output when parsing a file Signed-off-by: Olivier Matz --- 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);