]> git.proxmox.com Git - libgit2.git/blob - src/zstream.h
Merge branch 'debian/experimental' into debian/sid
[libgit2.git] / src / zstream.h
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
10 #include "common.h"
11
12 #include <zlib.h>
13
14 #include "buffer.h"
15
16 typedef enum {
17 GIT_ZSTREAM_INFLATE,
18 GIT_ZSTREAM_DEFLATE,
19 } git_zstream_t;
20
21 typedef struct {
22 z_stream z;
23 git_zstream_t type;
24 const char *in;
25 size_t in_len;
26 int flush;
27 int zerr;
28 } git_zstream;
29
30 #define GIT_ZSTREAM_INIT {{0}}
31
32 int git_zstream_init(git_zstream *zstream, git_zstream_t type);
33 void git_zstream_free(git_zstream *zstream);
34
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
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 */
44 int git_zstream_get_output(void *out, size_t *out_len, git_zstream *zstream);
45
46 bool git_zstream_done(git_zstream *zstream);
47 bool git_zstream_eos(git_zstream *zstream);
48
49 void git_zstream_reset(git_zstream *zstream);
50
51 int git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len);
52 int git_zstream_inflatebuf(git_buf *out, const void *in, size_t in_len);
53
54 #endif