From 1e7fb38c041103028fa285e598c8f7253b7aae11 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 1 Nov 2012 19:00:53 -0300 Subject: [PATCH] ant-cl/ant-cl.c (image): accept standard input (-) as image source --- tools/ant-cl/ant-cl.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/ant-cl/ant-cl.c b/tools/ant-cl/ant-cl.c index c94a34a..520f216 100644 --- a/tools/ant-cl/ant-cl.c +++ b/tools/ant-cl/ant-cl.c @@ -286,17 +286,22 @@ static void image(struct atrf_dsc *dsc, const char *name) uint8_t img[200] = { 0 }; ssize_t len; - file = fopen(name, "r"); - if (!file) { - perror(name); - exit(1); + if (!strcmp(name, "-")) { + file = stdin; + } else { + file = fopen(name, "r"); + if (!file) { + perror(name); + exit(1); + } } len = fread(img, 1, sizeof(img), file); if (len < 0) { perror(name); exit(1); } - fclose(file); + if (file != stdin) + fclose(file); send_image(dsc, img, len); }