commit 23bc48a9950c0704e7698686e89a6980c23529f4 from: Stefan Sperling date: Tue Mar 19 11:55:28 2019 UTC rename got_zstream_* to got_inflate_* commit - e02fc99fa16589e5287b101098e25f62e598a285 commit + 23bc48a9950c0704e7698686e89a6980c23529f4 blob - 45fce72d13ba62cbd804455e3befe0d050f112be blob + ea3d77cbcc5d4f1c753e501db61f4adfd0f37900 --- lib/got_lib_inflate.h +++ lib/got_lib_inflate.h @@ -14,28 +14,28 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -struct got_zstream_buf { +struct got_inflate_buf { z_stream z; char *inbuf; size_t inlen; char *outbuf; size_t outlen; int flags; -#define GOT_ZSTREAM_F_HAVE_MORE 0x01 -#define GOT_ZSTREAM_F_OWN_OUTBUF 0x02 +#define GOT_INFLATE_F_HAVE_MORE 0x01 +#define GOT_INFLATE_F_OWN_OUTBUF 0x02 }; -#define GOT_ZSTREAM_BUFSIZE 8192 +#define GOT_INFLATE_BUFSIZE 8192 -const struct got_error *got_inflate_init(struct got_zstream_buf *, uint8_t *, +const struct got_error *got_inflate_init(struct got_inflate_buf *, uint8_t *, size_t); -const struct got_error *got_inflate_read(struct got_zstream_buf *, FILE *, +const struct got_error *got_inflate_read(struct got_inflate_buf *, FILE *, size_t *); -const struct got_error *got_inflate_read_fd(struct got_zstream_buf *, int, +const struct got_error *got_inflate_read_fd(struct got_inflate_buf *, int, size_t *); -const struct got_error *got_inflate_read_mmap(struct got_zstream_buf *, +const struct got_error *got_inflate_read_mmap(struct got_inflate_buf *, uint8_t *, size_t, size_t, size_t *, size_t *); -void got_inflate_end(struct got_zstream_buf *); +void got_inflate_end(struct got_inflate_buf *); const struct got_error *got_inflate_to_mem(uint8_t **, size_t *, FILE *); const struct got_error *got_inflate_to_mem_fd(uint8_t **, size_t *, int); const struct got_error *got_inflate_to_mem_mmap(uint8_t **, size_t *, uint8_t *, blob - 8d7a9afa256fea6f0cca689baee19fce6680df6e blob + 28506a878c1f7f6d390a31f3b9960addcd1a3470 --- lib/inflate.c +++ lib/inflate.c @@ -34,7 +34,7 @@ #endif const struct got_error * -got_inflate_init(struct got_zstream_buf *zb, uint8_t *outbuf, size_t bufsize) +got_inflate_init(struct got_inflate_buf *zb, uint8_t *outbuf, size_t bufsize) { const struct got_error *err = NULL; @@ -62,7 +62,7 @@ got_inflate_init(struct got_zstream_buf *zb, uint8_t * err = got_error_from_errno(); goto done; } - zb->flags |= GOT_ZSTREAM_F_OWN_OUTBUF; + zb->flags |= GOT_INFLATE_F_OWN_OUTBUF; } else zb->outbuf = outbuf; @@ -73,7 +73,7 @@ done: } const struct got_error * -got_inflate_read(struct got_zstream_buf *zb, FILE *f, size_t *outlenp) +got_inflate_read(struct got_inflate_buf *zb, FILE *f, size_t *outlenp) { size_t last_total_out = zb->z.total_out; z_stream *z = &zb->z; @@ -100,11 +100,11 @@ got_inflate_read(struct got_zstream_buf *zb, FILE *f, } while (ret == Z_OK && z->avail_out > 0); if (ret == Z_OK) { - zb->flags |= GOT_ZSTREAM_F_HAVE_MORE; + zb->flags |= GOT_INFLATE_F_HAVE_MORE; } else { if (ret != Z_STREAM_END) return got_error(GOT_ERR_DECOMPRESSION); - zb->flags &= ~GOT_ZSTREAM_F_HAVE_MORE; + zb->flags &= ~GOT_INFLATE_F_HAVE_MORE; } *outlenp = z->total_out - last_total_out; @@ -112,7 +112,7 @@ got_inflate_read(struct got_zstream_buf *zb, FILE *f, } const struct got_error * -got_inflate_read_fd(struct got_zstream_buf *zb, int fd, size_t *outlenp) +got_inflate_read_fd(struct got_inflate_buf *zb, int fd, size_t *outlenp) { size_t last_total_out = zb->z.total_out; z_stream *z = &zb->z; @@ -139,11 +139,11 @@ got_inflate_read_fd(struct got_zstream_buf *zb, int fd } while (ret == Z_OK && z->avail_out > 0); if (ret == Z_OK) { - zb->flags |= GOT_ZSTREAM_F_HAVE_MORE; + zb->flags |= GOT_INFLATE_F_HAVE_MORE; } else { if (ret != Z_STREAM_END) return got_error(GOT_ERR_DECOMPRESSION); - zb->flags &= ~GOT_ZSTREAM_F_HAVE_MORE; + zb->flags &= ~GOT_INFLATE_F_HAVE_MORE; } *outlenp = z->total_out - last_total_out; @@ -151,7 +151,7 @@ got_inflate_read_fd(struct got_zstream_buf *zb, int fd } const struct got_error * -got_inflate_read_mmap(struct got_zstream_buf *zb, uint8_t *map, size_t offset, +got_inflate_read_mmap(struct got_inflate_buf *zb, uint8_t *map, size_t offset, size_t len, size_t *outlenp, size_t *consumed) { size_t last_total_out = zb->z.total_out; @@ -181,11 +181,11 @@ got_inflate_read_mmap(struct got_zstream_buf *zb, uint } while (ret == Z_OK && z->avail_out > 0); if (ret == Z_OK) { - zb->flags |= GOT_ZSTREAM_F_HAVE_MORE; + zb->flags |= GOT_INFLATE_F_HAVE_MORE; } else { if (ret != Z_STREAM_END) return got_error(GOT_ERR_DECOMPRESSION); - zb->flags &= ~GOT_ZSTREAM_F_HAVE_MORE; + zb->flags &= ~GOT_INFLATE_F_HAVE_MORE; } *outlenp = z->total_out - last_total_out; @@ -193,10 +193,10 @@ got_inflate_read_mmap(struct got_zstream_buf *zb, uint } void -got_inflate_end(struct got_zstream_buf *zb) +got_inflate_end(struct got_inflate_buf *zb) { free(zb->inbuf); - if (zb->flags & GOT_ZSTREAM_F_OWN_OUTBUF) + if (zb->flags & GOT_INFLATE_F_OWN_OUTBUF) free(zb->outbuf); inflateEnd(&zb->z); } @@ -206,14 +206,14 @@ got_inflate_to_mem(uint8_t **outbuf, size_t *outlen, F { const struct got_error *err; size_t avail; - struct got_zstream_buf zb; + struct got_inflate_buf zb; void *newbuf; int nbuf = 1; - *outbuf = calloc(1, GOT_ZSTREAM_BUFSIZE); + *outbuf = calloc(1, GOT_INFLATE_BUFSIZE); if (*outbuf == NULL) return got_error_from_errno(); - err = got_inflate_init(&zb, *outbuf, GOT_ZSTREAM_BUFSIZE); + err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE); if (err) return err; @@ -224,10 +224,10 @@ got_inflate_to_mem(uint8_t **outbuf, size_t *outlen, F if (err) goto done; *outlen += avail; - if (zb.flags & GOT_ZSTREAM_F_HAVE_MORE) { + if (zb.flags & GOT_INFLATE_F_HAVE_MORE) { nbuf++; newbuf = recallocarray(*outbuf, nbuf - 1, nbuf, - GOT_ZSTREAM_BUFSIZE); + GOT_INFLATE_BUFSIZE); if (newbuf == NULL) { err = got_error_from_errno(); free(*outbuf); @@ -237,9 +237,9 @@ got_inflate_to_mem(uint8_t **outbuf, size_t *outlen, F } *outbuf = newbuf; zb.outbuf = newbuf + *outlen; - zb.outlen = (nbuf * GOT_ZSTREAM_BUFSIZE) - *outlen; + zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen; } - } while (zb.flags & GOT_ZSTREAM_F_HAVE_MORE); + } while (zb.flags & GOT_INFLATE_F_HAVE_MORE); done: got_inflate_end(&zb); @@ -251,14 +251,14 @@ got_inflate_to_mem_fd(uint8_t **outbuf, size_t *outlen { const struct got_error *err; size_t avail; - struct got_zstream_buf zb; + struct got_inflate_buf zb; void *newbuf; int nbuf = 1; - *outbuf = calloc(1, GOT_ZSTREAM_BUFSIZE); + *outbuf = calloc(1, GOT_INFLATE_BUFSIZE); if (*outbuf == NULL) return got_error_from_errno(); - err = got_inflate_init(&zb, *outbuf, GOT_ZSTREAM_BUFSIZE); + err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE); if (err) goto done; @@ -269,10 +269,10 @@ got_inflate_to_mem_fd(uint8_t **outbuf, size_t *outlen if (err) goto done; *outlen += avail; - if (zb.flags & GOT_ZSTREAM_F_HAVE_MORE) { + if (zb.flags & GOT_INFLATE_F_HAVE_MORE) { nbuf++; newbuf = recallocarray(*outbuf, nbuf - 1, nbuf, - GOT_ZSTREAM_BUFSIZE); + GOT_INFLATE_BUFSIZE); if (newbuf == NULL) { err = got_error_from_errno(); free(*outbuf); @@ -282,9 +282,9 @@ got_inflate_to_mem_fd(uint8_t **outbuf, size_t *outlen } *outbuf = newbuf; zb.outbuf = newbuf + *outlen; - zb.outlen = (nbuf * GOT_ZSTREAM_BUFSIZE) - *outlen; + zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen; } - } while (zb.flags & GOT_ZSTREAM_F_HAVE_MORE); + } while (zb.flags & GOT_INFLATE_F_HAVE_MORE); done: got_inflate_end(&zb); @@ -297,14 +297,14 @@ got_inflate_to_mem_mmap(uint8_t **outbuf, size_t *outl { const struct got_error *err; size_t avail, consumed; - struct got_zstream_buf zb; + struct got_inflate_buf zb; void *newbuf; int nbuf = 1; - *outbuf = calloc(1, GOT_ZSTREAM_BUFSIZE); + *outbuf = calloc(1, GOT_INFLATE_BUFSIZE); if (*outbuf == NULL) return got_error_from_errno(); - err = got_inflate_init(&zb, *outbuf, GOT_ZSTREAM_BUFSIZE); + err = got_inflate_init(&zb, *outbuf, GOT_INFLATE_BUFSIZE); if (err) { free(*outbuf); *outbuf = NULL; @@ -323,10 +323,10 @@ got_inflate_to_mem_mmap(uint8_t **outbuf, size_t *outl *outlen += avail; if (len == 0) break; - if (zb.flags & GOT_ZSTREAM_F_HAVE_MORE) { + if (zb.flags & GOT_INFLATE_F_HAVE_MORE) { nbuf++; newbuf = recallocarray(*outbuf, nbuf - 1, nbuf, - GOT_ZSTREAM_BUFSIZE); + GOT_INFLATE_BUFSIZE); if (newbuf == NULL) { err = got_error_from_errno(); free(*outbuf); @@ -336,9 +336,9 @@ got_inflate_to_mem_mmap(uint8_t **outbuf, size_t *outl } *outbuf = newbuf; zb.outbuf = newbuf + *outlen; - zb.outlen = (nbuf * GOT_ZSTREAM_BUFSIZE) - *outlen; + zb.outlen = (nbuf * GOT_INFLATE_BUFSIZE) - *outlen; } - } while (zb.flags & GOT_ZSTREAM_F_HAVE_MORE); + } while (zb.flags & GOT_INFLATE_F_HAVE_MORE); done: got_inflate_end(&zb); return err; @@ -349,9 +349,9 @@ got_inflate_to_fd(size_t *outlen, FILE *infile, int ou { const struct got_error *err = NULL; size_t avail; - struct got_zstream_buf zb; + struct got_inflate_buf zb; - err = got_inflate_init(&zb, NULL, GOT_ZSTREAM_BUFSIZE); + err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE); if (err) goto done; @@ -370,7 +370,7 @@ got_inflate_to_fd(size_t *outlen, FILE *infile, int ou } *outlen += avail; } - } while (zb.flags & GOT_ZSTREAM_F_HAVE_MORE); + } while (zb.flags & GOT_INFLATE_F_HAVE_MORE); done: if (err == NULL) { @@ -386,9 +386,9 @@ got_inflate_to_file(size_t *outlen, FILE *infile, FILE { const struct got_error *err; size_t avail; - struct got_zstream_buf zb; + struct got_inflate_buf zb; - err = got_inflate_init(&zb, NULL, GOT_ZSTREAM_BUFSIZE); + err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE); if (err) goto done; @@ -407,7 +407,7 @@ got_inflate_to_file(size_t *outlen, FILE *infile, FILE } *outlen += avail; } - } while (zb.flags & GOT_ZSTREAM_F_HAVE_MORE); + } while (zb.flags & GOT_INFLATE_F_HAVE_MORE); done: if (err == NULL) @@ -421,9 +421,9 @@ got_inflate_to_file_fd(size_t *outlen, int infd, FILE { const struct got_error *err; size_t avail; - struct got_zstream_buf zb; + struct got_inflate_buf zb; - err = got_inflate_init(&zb, NULL, GOT_ZSTREAM_BUFSIZE); + err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE); if (err) goto done; @@ -442,7 +442,7 @@ got_inflate_to_file_fd(size_t *outlen, int infd, FILE } *outlen += avail; } - } while (zb.flags & GOT_ZSTREAM_F_HAVE_MORE); + } while (zb.flags & GOT_INFLATE_F_HAVE_MORE); done: if (err == NULL) @@ -457,10 +457,10 @@ got_inflate_to_file_mmap(size_t *outlen, uint8_t *map, { const struct got_error *err; size_t avail; - struct got_zstream_buf zb; + struct got_inflate_buf zb; size_t consumed; - err = got_inflate_init(&zb, NULL, GOT_ZSTREAM_BUFSIZE); + err = got_inflate_init(&zb, NULL, GOT_INFLATE_BUFSIZE); if (err) goto done; @@ -482,7 +482,7 @@ got_inflate_to_file_mmap(size_t *outlen, uint8_t *map, } *outlen += avail; } - } while (zb.flags & GOT_ZSTREAM_F_HAVE_MORE); + } while (zb.flags & GOT_INFLATE_F_HAVE_MORE); done: if (err == NULL) blob - 0852ad5cbf1531f45a52696be1193ee54ca13779 blob + 61e58f737c3748fff76c8b967a29c0ae43c1557f --- lib/object_parse.c +++ lib/object_parse.c @@ -188,7 +188,7 @@ const struct got_error * got_object_read_header(struct got_object **obj, int fd) { const struct got_error *err; - struct got_zstream_buf zb; + struct got_inflate_buf zb; char *buf; const size_t zbsize = 64; size_t outlen, totlen;