From 92187f2a12bcc9b108773e080074b4cfc47f6db9 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Wed, 22 Dec 2021 21:54:31 -0500 Subject: Support reading gzipped data in merge --- merge.c | 18 ++++++++++++------ torus.1 | 7 ++++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/merge.c b/merge.c index 66a7a5e..42ef2c1 100644 --- a/merge.c +++ b/merge.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "torus.h" @@ -83,10 +84,10 @@ static void drawTile(int offsetY, const struct Tile *tile) { int main(int argc, char *argv[]) { if (argc != 4) return EX_USAGE; - FILE *fileA = fopen(argv[1], "r"); + gzFile fileA = gzopen(argv[1], "r"); if (!fileA) err(EX_NOINPUT, "%s", argv[1]); - FILE *fileB = fopen(argv[2], "r"); + gzFile fileB = gzopen(argv[2], "r"); if (!fileB) err(EX_NOINPUT, "%s", argv[2]); FILE *fileC = fopen(argv[3], "w"); @@ -94,13 +95,18 @@ int main(int argc, char *argv[]) { curse(); + int error; struct Tile tileA, tileB; for (;;) { - size_t countA = fread(&tileA, sizeof(tileA), 1, fileA); - if (ferror(fileA)) err(EX_IOERR, "%s", argv[1]); + size_t countA = gzfread(&tileA, sizeof(tileA), 1, fileA); + if (!countA && gzerror(fileA, &error)) { + errx(EX_IOERR, "%s: %s", argv[1], gzerror(fileA, &error)); + } - size_t countB = fread(&tileB, sizeof(tileB), 1, fileB); - if (ferror(fileB)) err(EX_IOERR, "%s", argv[2]); + size_t countB = gzfread(&tileB, sizeof(tileB), 1, fileB); + if (!countB && gzerror(fileB, &error)) { + errx(EX_IOERR, "%s: %s", argv[2], gzerror(fileB, &error)); + } if (!countA && !countB) break; if (!countA || !countB) errx(EX_DATAERR, "different size inputs"); diff --git a/torus.1 b/torus.1 index 9bf4b52..ddf79a4 100644 --- a/torus.1 +++ b/torus.1 @@ -1,4 +1,4 @@ -.Dd September 20, 2021 +.Dd December 22, 2021 .Dt torus 1 .Os "Causal Agency" . @@ -82,6 +82,11 @@ and .Ar data2 into .Ar data3 . +.Ar data1 +and +.Ar data2 +may be compressed with +.Xr gzip 1 . Differing tiles are presented in a .Xr curses 3 interface -- cgit 1.4.1 div class='path'>path: root/bounce.h (unfollow)
Commit message (Collapse)Author
2019-10-25Clean up server codeJune McEnroe
2019-10-25Clean up listen APIJune McEnroe
2019-10-25Use produce/consume words for ring bufferJune McEnroe
To disambiguate clientRecv and clientRead, say clientConsume.
2019-10-25Implement client reading from ring bufferJune McEnroe
It's still messy but it works!!
2019-10-25Implement ringDiff and ringReadJune McEnroe
2019-10-24Remove manual client naming from manual pageJune McEnroe
2019-10-24Zero entire Client structJune McEnroe
Does zeroing that extra 4K really matter? I'd rather not have uninitialized reads.
2019-10-24Register readers by client usernamesJune McEnroe
2019-10-24Unset non-blocking on clientsJune McEnroe
I figure I'll actually use POLLOUT on clients so should never have issues.
2019-10-24Intercept client QUITJune McEnroe
2019-10-24Only set NeedCapEnd if unregisteredJune McEnroe
2019-10-24Set client-side origin to irc.invalidJune McEnroe
2019-10-24Factor out client-side origin nameJune McEnroe
2019-10-24Intercept all CAP commands from clientsJune McEnroe
2019-10-24Ignore further CAP ENDJune McEnroe
2019-10-24Implement client CAP for server-timeJune McEnroe
2019-10-24Implement ringWriteJune McEnroe
2019-10-24Make clientFormat publicJune McEnroe
2019-10-24Make serverFormat publicJune McEnroe
2019-10-24Rename some thingsJune McEnroe
2019-10-23Add ISUPPORT draft to STANDARDSJune McEnroe
2019-10-23Track own originJune McEnroe
2019-10-23Track channels and sync ISUPPORTJune McEnroe
2019-10-23Track nick changesJune McEnroe
2019-10-23Rename Command to MessageJune McEnroe
2019-10-23Synchronize state after client registrationJune McEnroe
2019-10-23Send to server if client has no needsJune McEnroe
2019-10-23Implement some amount of client connectionJune McEnroe
2019-10-23Set clients non-blockingJune McEnroe
2019-10-23Clean up state.c and factor out parsingJune McEnroe
2019-10-23Respond to pingsJune McEnroe
2019-10-23Add verbose flagJune McEnroe
2019-10-23Set NOSIGPIPE on server connectionJune McEnroe
2019-10-23Set an initial loop capJune McEnroe
2019-10-23Fix rest parsingJune McEnroe
2019-10-23Add dynamic poll listJune McEnroe
2019-10-23Don't assume commands have targets and handle ERRORJune McEnroe
2019-10-23Clean up state somewhatJune McEnroe
2019-10-23Actually send the buffer...June McEnroe
2019-10-23Add stateJune McEnroe