2 2181e0c8 2019-03-19 stsp * Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 2181e0c8 2019-03-19 stsp * Permission to use, copy, modify, and distribute this software for any
5 2181e0c8 2019-03-19 stsp * purpose with or without fee is hereby granted, provided that the above
6 2181e0c8 2019-03-19 stsp * copyright notice and this permission notice appear in all copies.
8 2181e0c8 2019-03-19 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 2181e0c8 2019-03-19 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 2181e0c8 2019-03-19 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 2181e0c8 2019-03-19 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 2181e0c8 2019-03-19 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 2181e0c8 2019-03-19 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 2181e0c8 2019-03-19 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 91b40e30 2021-05-21 stsp struct got_deflate_checksum {
18 91b40e30 2021-05-21 stsp /* If not NULL, mix output bytes into this CRC checksum. */
19 91b40e30 2021-05-21 stsp uint32_t *output_crc;
21 91b40e30 2021-05-21 stsp /* If not NULL, mix output bytes into this SHA1 context. */
22 91b40e30 2021-05-21 stsp SHA1_CTX *output_sha1;
25 2181e0c8 2019-03-19 stsp struct got_deflate_buf {
27 dbaa2362 2021-09-28 thomas uint8_t *inbuf;
28 2181e0c8 2019-03-19 stsp size_t inlen;
29 dbaa2362 2021-09-28 thomas uint8_t *outbuf;
30 2181e0c8 2019-03-19 stsp size_t outlen;
32 2181e0c8 2019-03-19 stsp #define GOT_DEFLATE_F_HAVE_MORE 0x01
33 2181e0c8 2019-03-19 stsp #define GOT_DEFLATE_F_OWN_OUTBUF 0x02
36 2181e0c8 2019-03-19 stsp #define GOT_DEFLATE_BUFSIZE 8192
38 2181e0c8 2019-03-19 stsp const struct got_error *got_deflate_init(struct got_deflate_buf *, uint8_t *,
40 2181e0c8 2019-03-19 stsp const struct got_error *got_deflate_read(struct got_deflate_buf *, FILE *,
41 e8f02263 2022-01-23 thomas off_t, size_t *, off_t *);
42 9249e7e3 2022-05-12 thomas const struct got_error *got_deflate_read_mmap(struct got_deflate_buf *,
43 9249e7e3 2022-05-12 thomas uint8_t *, size_t, size_t, size_t *, size_t *);
44 2181e0c8 2019-03-19 stsp void got_deflate_end(struct got_deflate_buf *);
45 e8f02263 2022-01-23 thomas const struct got_error *got_deflate_to_file(off_t *, FILE *, off_t, FILE *,
46 91b40e30 2021-05-21 stsp struct got_deflate_checksum *);
47 e8f02263 2022-01-23 thomas const struct got_error *got_deflate_to_file_mmap(off_t *, uint8_t *,
48 2b0ae357 2022-01-10 thomas size_t, size_t, FILE *, struct got_deflate_checksum *);
49 9249e7e3 2022-05-12 thomas const struct got_error *got_deflate_flush(struct got_deflate_buf *, FILE *,
50 9249e7e3 2022-05-12 thomas struct got_deflate_checksum *, off_t *);
51 9249e7e3 2022-05-12 thomas const struct got_error *got_deflate_append_to_file_mmap(
52 9249e7e3 2022-05-12 thomas struct got_deflate_buf *, off_t *, uint8_t *, size_t, size_t, FILE *,
53 9249e7e3 2022-05-12 thomas struct got_deflate_checksum *);
54 9249e7e3 2022-05-12 thomas const struct got_error *got_deflate_to_mem_mmap(uint8_t **, size_t *, size_t *,
55 9249e7e3 2022-05-12 thomas struct got_deflate_checksum *, uint8_t *, size_t, size_t);