From a7a39d72d92c32444fa48e0676d65ce23b205ae2 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 2 Mar 2018 15:39:07 -0500 Subject: Skip chunks by reading in pngo Pipes. --- bin/pngo.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/pngo.c b/bin/pngo.c index c7a37bd9..5ce62797 100644 --- a/bin/pngo.c +++ b/bin/pngo.c @@ -88,11 +88,6 @@ static struct Chunk readChunk(void) { return chunk; } -static void skipChunk(struct Chunk chunk) { - int error = fseek(file, chunk.size + 4, SEEK_CUR); - if (error) err(EX_IOERR, "%s", path); -} - static void writeChunk(struct Chunk chunk) { chunk.size = htonl(chunk.size); writeExpect(&chunk, sizeof(chunk)); @@ -117,6 +112,12 @@ static void writeCrc(void) { writeExpect(&net, sizeof(net)); } +static void skipChunk(struct Chunk chunk) { + uint8_t discard[chunk.size]; + readExpect(discard, sizeof(discard), "chunk data"); + readCrc(); +} + static struct PACKED { uint32_t width; uint32_t height; -- cgit 1.4.1