From bc7830ba80267a4a228ed1de62e0f65045b3d174 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 12 Jan 2017 11:27:40 +0100 Subject: Fix and improve vu-from-image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/util/io.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/util') diff --git a/src/util/io.h b/src/util/io.h index 25f360c..ac326c8 100644 --- a/src/util/io.h +++ b/src/util/io.h @@ -1,6 +1,7 @@ /* See LICENSE file for copyright and license details. */ #define ewriteall(...) enwriteall(1, __VA_ARGS__) +#define ereadall(...) enreadall(1, __VA_ARGS__) int writeall(int fd, void *buf, size_t n); @@ -10,3 +11,14 @@ enwriteall(int status, int fd, void *buf, size_t n, const char *fname) if (writeall(fd, buf, n)) enprintf(status, "write %s:", fname); } + +ssize_t readall(int fd, void *buf, size_t n); + +static inline size_t +enreadall(int status, int fd, void *buf, size_t n, const char *fname) +{ + ssize_t r = readall(fd, buf, n); + if (r < 0) + enprintf(status, "read %s:", fname); + return (size_t)r; +} -- cgit v1.2.3-70-g09d2