From 1b5149c6f8e66dcfc4149e5524175728272136f2 Mon Sep 17 00:00:00 2001 From: Kaian Date: Mon, 21 Aug 2017 11:43:09 +0200 Subject: [PATCH] capture: allow reading data from standard input #198 --- src/capture.c | 5 +++++ src/curses/ui_manager.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/capture.c b/src/capture.c index 0602052..35d9290 100644 --- a/src/capture.c +++ b/src/capture.c @@ -169,6 +169,11 @@ capture_offline(const char *infile, const char *outfile) return 1; } + // Check if file is standard input + if (strlen(infile) == 1 && *infile == '-') { + infile = "/dev/stdin"; + } + // Set capture input file capinfo->infile = infile; diff --git a/src/curses/ui_manager.c b/src/curses/ui_manager.c index c17d77f..fedb08e 100644 --- a/src/curses/ui_manager.c +++ b/src/curses/ui_manager.c @@ -68,9 +68,14 @@ ncurses_init() { int bg, fg; const char *term; + FILE *fstdin; + // Set Locale setlocale(LC_CTYPE, ""); + // Allow reading from stdin + fstdin = freopen("/dev/tty", "r", stdin); + // Initialize curses if (!initscr()) { fprintf(stderr, "Unable to initialize ncurses mode.\n");