]>
Commit | Line | Data |
---|---|---|
c6f26b48 ET |
1 | /* |
2 | * Copyright (C) the libgit2 contributors. All rights reserved. | |
3 | * | |
4 | * This file is part of libgit2, distributed under the GNU GPL v2 with | |
5 | * a Linking Exception. For full terms see the included COPYING file. | |
6 | */ | |
7 | #ifndef INCLUDE_zstream_h__ | |
8 | #define INCLUDE_zstream_h__ | |
9 | ||
eae0bfdc PP |
10 | #include "common.h" |
11 | ||
c6f26b48 ET |
12 | #include <zlib.h> |
13 | ||
e579e0f7 | 14 | #include "str.h" |
c6f26b48 | 15 | |
b88f1713 ET |
16 | typedef enum { |
17 | GIT_ZSTREAM_INFLATE, | |
e579e0f7 | 18 | GIT_ZSTREAM_DEFLATE |
b88f1713 ET |
19 | } git_zstream_t; |
20 | ||
d9b04d78 RB |
21 | typedef struct { |
22 | z_stream z; | |
b88f1713 | 23 | git_zstream_t type; |
d9b04d78 RB |
24 | const char *in; |
25 | size_t in_len; | |
eae0bfdc | 26 | int flush; |
d9b04d78 RB |
27 | int zerr; |
28 | } git_zstream; | |
c6f26b48 | 29 | |
d9b04d78 | 30 | #define GIT_ZSTREAM_INIT {{0}} |
c6f26b48 | 31 | |
b88f1713 | 32 | int git_zstream_init(git_zstream *zstream, git_zstream_t type); |
c6f26b48 ET |
33 | void git_zstream_free(git_zstream *zstream); |
34 | ||
d9b04d78 RB |
35 | int git_zstream_set_input(git_zstream *zstream, const void *in, size_t in_len); |
36 | ||
37 | size_t git_zstream_suggest_output_len(git_zstream *zstream); | |
38 | ||
eae0bfdc PP |
39 | /* get as much output as is available in the input buffer */ |
40 | int git_zstream_get_output_chunk( | |
41 | void *out, size_t *out_len, git_zstream *zstream); | |
42 | ||
43 | /* get all the output from the entire input buffer */ | |
d9b04d78 RB |
44 | int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream); |
45 | ||
46 | bool git_zstream_done(git_zstream *zstream); | |
22a2d3d5 | 47 | bool git_zstream_eos(git_zstream *zstream); |
d9b04d78 RB |
48 | |
49 | void git_zstream_reset(git_zstream *zstream); | |
50 | ||
e579e0f7 MB |
51 | int git_zstream_deflatebuf(git_str *out, const void *in, size_t in_len); |
52 | int git_zstream_inflatebuf(git_str *out, const void *in, size_t in_len); | |
c6f26b48 | 53 | |
eae0bfdc | 54 | #endif |