summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2018-03-02 15:39:07 -0500
committerJune McEnroe <programble@gmail.com>2018-03-02 15:39:07 -0500
commita7a39d72d92c32444fa48e0676d65ce23b205ae2 (patch)
tree7ad44ca4b028356614e957dfcb1366031725f7a7
parentAdd verbose flag to pngo (diff)
downloadsrc-a7a39d72d92c32444fa48e0676d65ce23b205ae2.tar.gz
src-a7a39d72d92c32444fa48e0676d65ce23b205ae2.zip
Skip chunks by reading in pngo
Pipes.
Diffstat (limited to '')
-rw-r--r--bin/pngo.c11
1 files 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;