From 76cdf509b36bb0012cde9bc1760cdf3b26874af2 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 9 Jan 2017 03:51:26 +0100 Subject: Use CIE XYZ instead of sRGB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/vu-repeat.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/vu-repeat.c') diff --git a/src/vu-repeat.c b/src/vu-repeat.c index 69ac8ce..f25253d 100644 --- a/src/vu-repeat.c +++ b/src/vu-repeat.c @@ -1,5 +1,6 @@ /* See LICENSE file for copyright and license details. */ #include "arg.h" +#include "stream.h" #include "util.h" #include @@ -15,9 +16,8 @@ usage(void) int main(int argc, char *argv[]) { - struct stat st; + struct stream stream; size_t count, ptr, n, ptw; - int fd; ssize_t r; char buf[BUFSIZ]; @@ -32,14 +32,25 @@ main(int argc, char *argv[]) if (tozu(argv[0], 0, SIZE_MAX, &count)) eprintf("the count must be an integer in [0, %zu]\n", SIZE_MAX); - fd = open(argv[1], O_RDONLY); - if (fd < 0) - eprintf("open %s:", argv[1]); + stream.file = argv[1]; + stream.fd = open(stream.file, O_RDONLY); + if (stream.fd < 0) + eprintf("open %s:", stream.file); + einit_stream(&stream); + fprint_stream_head(stdout, &stream); + fflush(stdout); + if (ferror(stdout)) + eprintf(":"); while (count--) { - posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL); + for (ptw = 0; ptw < stream.ptr;) { + r = write(STDOUT_FILENO, stream.buf + ptw, stream.ptr - ptw); + if (r < 0) + eprintf("write :"); + ptw += (size_t)r; + } for (ptr = 0;;) { - r = pread(fd, buf, sizeof(buf), ptr); + r = pread(stream.fd, buf, sizeof(buf), ptr); if (r < 0) eprintf("pread %s:", argv[1]); else if (r == 0) @@ -54,6 +65,6 @@ main(int argc, char *argv[]) } } - close(fd); + close(stream.fd); return 0; } -- cgit v1.2.3-70-g09d2