Blame


1 718b3ab0 2018-03-17 stsp /*
2 718b3ab0 2018-03-17 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 718b3ab0 2018-03-17 stsp *
4 718b3ab0 2018-03-17 stsp * Permission to use, copy, modify, and distribute this software for any
5 718b3ab0 2018-03-17 stsp * purpose with or without fee is hereby granted, provided that the above
6 718b3ab0 2018-03-17 stsp * copyright notice and this permission notice appear in all copies.
7 718b3ab0 2018-03-17 stsp *
8 718b3ab0 2018-03-17 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 718b3ab0 2018-03-17 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 718b3ab0 2018-03-17 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 718b3ab0 2018-03-17 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 718b3ab0 2018-03-17 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 718b3ab0 2018-03-17 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 718b3ab0 2018-03-17 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 718b3ab0 2018-03-17 stsp */
16 718b3ab0 2018-03-17 stsp
17 718b3ab0 2018-03-17 stsp struct got_zstream_buf {
18 718b3ab0 2018-03-17 stsp z_stream z;
19 718b3ab0 2018-03-17 stsp char *inbuf;
20 718b3ab0 2018-03-17 stsp size_t inlen;
21 718b3ab0 2018-03-17 stsp char *outbuf;
22 718b3ab0 2018-03-17 stsp size_t outlen;
23 718b3ab0 2018-03-17 stsp int flags;
24 718b3ab0 2018-03-17 stsp #define GOT_ZSTREAM_F_HAVE_MORE 0x01
25 718b3ab0 2018-03-17 stsp #define GOT_ZSTREAM_F_OWN_OUTBUF 0x02
26 718b3ab0 2018-03-17 stsp };
27 718b3ab0 2018-03-17 stsp
28 718b3ab0 2018-03-17 stsp #define GOT_ZSTREAM_BUFSIZE 8192
29 718b3ab0 2018-03-17 stsp
30 718b3ab0 2018-03-17 stsp const struct got_error *got_inflate_init(struct got_zstream_buf *, uint8_t *,
31 718b3ab0 2018-03-17 stsp size_t);
32 718b3ab0 2018-03-17 stsp const struct got_error *got_inflate_read(struct got_zstream_buf *, FILE *,
33 718b3ab0 2018-03-17 stsp size_t *);
34 962916a2 2018-04-24 stsp const struct got_error *got_inflate_read_fd(struct got_zstream_buf *, int,
35 962916a2 2018-04-24 stsp size_t *);
36 718b3ab0 2018-03-17 stsp void got_inflate_end(struct got_zstream_buf *);
37 718b3ab0 2018-03-17 stsp const struct got_error *got_inflate_to_mem(uint8_t **, size_t *, FILE *);
38 8b2180d4 2018-04-26 stsp const struct got_error *got_inflate_to_mem_fd(uint8_t **, size_t *, int);
39 718b3ab0 2018-03-17 stsp const struct got_error *got_inflate_to_file(size_t *, FILE *, FILE *);
40 8b2180d4 2018-04-26 stsp const struct got_error *got_inflate_to_file_fd(size_t *, int, FILE *);
41 8b2180d4 2018-04-26 stsp const struct got_error *got_inflate_to_fd(size_t *, FILE *, int);