3 * Copyright (C) 2006-2009 Raffaele Sandrini, Jürg Billeter, Evan Nemerson
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Raffaele Sandrini <raffaele@sandrini.ch>
21 * Jürg Billeter <j@bitron.ch>
22 * Evan Nemerson <evan@polussystems.com>
23 * Jörn Magens <joernmagens@gmx.de>
28 [CCode (lower_case_cprefix = "", cheader_filename = "zlib.h")]
30 [CCode (cname="int", cprefix="Z_")]
38 [CCode (cname="int", cprefix="Z_")]
50 [CCode (cname="int", cprefix="Z_")]
57 [CCode (cname="int", cprefix="Z_")]
58 public enum Strategy {
65 [CCode (cname="int", cprefix="Z_")]
71 [CCode (cname="int", cprefix="Z_")]
72 public enum Algorithm {
75 [CCode (cname="int", cprefix="Z_")]
80 [CCode (cname = "ZLIB_VERSION")]
81 public const string STRING;
82 [CCode (cname = "ZLIB_VERNUM")]
83 public const int NUMBER;
84 [CCode (cname = "ZLIB_VER_MAJOR")]
85 public const int MAJOR;
86 [CCode (cname = "ZLIB_VER_MINOR")]
87 public const int MINOR;
88 [CCode (cname = "ZLIB_VER_REVISION")]
89 public const int REVISION;
91 [CCode (cname = "z_stream", destroy_function = "deflateEnd")]
92 public struct Stream {
93 [CCode (array_length_cname = "avail_in", array_length_type = "ulong")]
94 public uint8[] next_in;
96 public ulong total_in;
98 [CCode (array_length_cname = "avail_out", array_length_type = "ulong")]
99 public uint8[] next_out;
100 public uint avail_out;
101 public ulong total_out;
104 public int data_type;
107 [CCode (cname = "z_stream", destroy_function = "deflateEnd")]
108 public struct DeflateStream : Stream {
109 [CCode (cname = "deflateInit")]
110 public DeflateStream (int level = Level.DEFAULT_COMPRESSION);
111 [CCode (cname = "deflateInit2")]
112 public DeflateStream.full (int level = Level.DEFAULT_COMPRESSION, int method = Algorithm.DEFLATED, int windowBits = 15, int memLevel = 8, int strategy = Strategy.DEFAULT_STRATEGY);
113 [CCode (cname = "deflate")]
114 public int deflate (int flush);
115 [CCode (cname = "deflateSetDictionary")]
116 public int set_dictionary ([CCode (array_length_type = "guint")] uint8[] dictionary);
117 [CCode (cname = "deflateCopy", instance_pos = 0)]
118 public int copy (DeflateStream dest);
119 [CCode (cname = "deflateReset")]
121 [CCode (cname = "deflateParams")]
122 public int params (int level, int strategy);
123 [CCode (cname = "deflateTune")]
124 public int tune (int good_length, int max_lazy, int nice_length, int max_chain);
125 [CCode (cname = "deflateBound")]
126 public ulong bound (ulong sourceLen);
127 [CCode (cname = "deflatePrime")]
128 public int prime (int bits, int value);
129 [CCode (cname = "deflateSetHeader")]
130 public int set_header (GZHeader head);
132 [CCode (cname = "z_stream", destroy_function = "inflateEnd")]
133 public struct InflateStream : Stream {
134 [CCode (cname = "inflateInit")]
135 public InflateStream ();
136 [CCode (cname = "inflateInit2")]
137 public InflateStream.full (int windowBits);
138 [CCode (cname = "inflate")]
139 public int inflate (int flush);
140 [CCode (cname = "inflateSetDictionary")]
141 public int set_dictionary ([CCode (array_length_type = "guint")] uint8[] dictionary);
142 [CCode (cnmae = "inflateSync")]
145 public int prime (int bits, int value);
146 public int get_header (out GZHeader head);
148 [CCode (lower_case_cprefix = "", cheader_filename = "zlib.h")]
150 [CCode (cname = "compress2")]
151 public static int compress ([CCode (array_length = false)] uint8[] dest, ref ulong dest_length, [CCode (array_length_type = "gulong")] uint8[] source, int level = Level.DEFAULT_COMPRESSION);
152 [CCode (cname = "compressBound")]
153 public static int compress_bound (ulong sourceLen);
154 public static int uncompress ([CCode (array_length = false)] uint8[] dest, ref ulong dest_length, [CCode (array_length_type = "gulong")] uint8[] source);
155 public static ulong adler32 (ulong crc = 0UL, [CCode (array_length_type = "guint")] uint8[]? buf = null);
156 public static ulong crc32 (ulong crc = 0UL, [CCode (array_length_type = "guint")] uint8[]? buf = null);
158 [CCode (cname = "gz_header")]
159 public struct GZHeader {
164 [CCode (array_length_cname = "extra_len", array_length_type = "guint")]
165 public uint8[] extra;
166 public uint extra_max;
168 public uint name_max;
169 public string comment;
170 [CCode (cname = "comm_max")]
171 public uint comment_max;
175 [CCode (cname = "gzFile", cprefix = "gz", free_function = "gzclose")]
176 public class GZFileStream {
177 public static GZFileStream open (string path, string mode = "rb");
178 public static GZFileStream dopen (int fd, string mode);
179 public int setparams (int level, int strategy);
180 public int read (uint8[] buf);
181 public int write (uint8[] buf);
183 public int printf (string format, ...);
184 public int puts (string s);
185 public unowned string gets (char[] buf);
186 public int flush (int flush);
187 public int rewind ();
189 public bool direct ();