summaryrefslogtreecommitdiff
path: root/vapi/zlib.vapi
blob: c9adb8e247197d1bac97024ca8df7538d78160fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/* zlib.vala
 *
 * Copyright (C) 2006-2009  Raffaele Sandrini, Jürg Billeter, Evan Nemerson
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 *	Raffaele Sandrini <raffaele@sandrini.ch>
 * 	Jürg Billeter <j@bitron.ch>
 * 	Evan Nemerson <evan@polussystems.com>
 * 	Jörn Magens <joernmagens@gmx.de>
 */

[CCode (lower_case_cprefix = "", cheader_filename = "zlib.h")]
namespace ZLib {
	[CCode (cname="int", cprefix="Z_", has_type_id = false)]
	public enum Flush {
		NO_FLUSH,
		SYNC_FLUSH,
		FULL_FLUSH,
		FINISH,
		BLOCK
	}
	[CCode (cname="int", cprefix="Z_", has_type_id = false)]
	public enum Status {
		OK,
		STREAM_END,
		NEED_DICT,
		ERRNO,
		STREAM_ERROR,
		DATA_ERROR,
		MEM_ERROR,
		BUF_ERROR,
		VERSION_ERROR
	}
	[CCode (cname="int", cprefix="Z_", has_type_id = false)]
	public enum Level {
		NO_COMPRESSION,
		BEST_SPEED,
		BEST_COMPRESSION,
		DEFAULT_COMPRESSION
	}
	[CCode (cname="int", cprefix="Z_", has_type_id = false)]
	public enum Strategy {
		DEFAULT_STRATEGY,
		FILTERED,
		HUFFMAN_ONLY,
		RLE,
		FIXED
	}
	[CCode (cname="int", cprefix="Z_", has_type_id = false)]
	public enum Data {
		BINARY,
		ASCII,
		UNKNOWN
	}
	[CCode (cname="int", cprefix="Z_", has_type_id = false)]
	public enum Algorithm {
		DEFLATED
	}
	[CCode (cname="int", cprefix="Z_", has_type_id = false)]
	public enum Initial {
		NULL
	}
	namespace VERSION {
		[CCode (cname = "ZLIB_VERSION")]
		public const string STRING;
		[CCode (cname = "ZLIB_VERNUM")]
		public const int NUMBER;
		[CCode (cname = "ZLIB_VER_MAJOR")]
		public const int MAJOR;
		[CCode (cname = "ZLIB_VER_MINOR")]
		public const int MINOR;
		[CCode (cname = "ZLIB_VER_REVISION")]
		public const int REVISION;
	}
	[CCode (cname = "z_stream", destroy_function = "deflateEnd", has_type_id = false)]
	public struct Stream {
		[CCode (array_length_cname = "avail_in", array_length_type = "ulong")]
		public unowned uint8[] next_in;
		public uint avail_in;
		public ulong total_in;

		[CCode (array_length_cname = "avail_out", array_length_type = "ulong")]
		public unowned uint8[] next_out;
		public uint avail_out;
		public ulong total_out;

		public string? msg;
		public int data_type;
		public ulong adler;
	}
	[CCode (cname = "z_stream", destroy_function = "deflateEnd", has_type_id = false)]
	public struct DeflateStream : Stream {
		[CCode (cname = "deflateInit")]
		public DeflateStream (int level = Level.DEFAULT_COMPRESSION);
		[CCode (cname = "deflateInit2")]
		public DeflateStream.full (int level = Level.DEFAULT_COMPRESSION, int method = Algorithm.DEFLATED, int windowBits = 15, int memLevel = 8, int strategy = Strategy.DEFAULT_STRATEGY);
		[CCode (cname = "deflate")]
		public int deflate (int flush);
		[CCode (cname = "deflateSetDictionary")]
		public int set_dictionary ([CCode (array_length_type = "guint")] uint8[] dictionary);
		[CCode (cname = "deflateCopy", instance_pos = 0)]
		public int copy (DeflateStream dest);
		[CCode (cname = "deflateReset")]
		public int reset ();
		[CCode (cname = "deflateParams")]
		public int params (int level, int strategy);
		[CCode (cname = "deflateTune")]
		public int tune (int good_length, int max_lazy, int nice_length, int max_chain);
		[CCode (cname = "deflateBound")]
		public ulong bound (ulong sourceLen);
		[CCode (cname = "deflatePrime")]
		public int prime (int bits, int value);
		[CCode (cname = "deflateSetHeader")]
		public int set_header (GZHeader head);
	}
	[CCode (cname = "z_stream", destroy_function = "inflateEnd", has_type_id = false)]
	public struct InflateStream : Stream {
		[CCode (cname = "inflateInit")]
		public InflateStream ();
		[CCode (cname = "inflateInit2")]
		public InflateStream.full (int windowBits);
		[CCode (cname = "inflate")]
		public int inflate (int flush);
		[CCode (cname = "inflateSetDictionary")]
		public int set_dictionary ([CCode (array_length_type = "guint")] uint8[] dictionary);
		[CCode (cname = "inflateSync")]
		public int sync ();
		[CCode (cname = "inflateReset")]
		public int reset ();
		[CCode (cname = "inflatePrime")]
		public int prime (int bits, int value);
		[CCode (cname = "inflateGetHeader")]
		public int get_header (out GZHeader head);
	}
	[CCode (lower_case_cprefix = "", cheader_filename = "zlib.h")]
	namespace Utility {
		[CCode (cname = "compress2")]
		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);
		[CCode (cname = "compressBound")]
		public static int compress_bound (ulong sourceLen);
		public static int uncompress ([CCode (array_length = false)] uint8[] dest, ref ulong dest_length, [CCode (array_length_type = "gulong")] uint8[] source);
		public static ulong adler32 (ulong crc = 0UL, [CCode (array_length_type = "guint")] uint8[]? buf = null);
		public static ulong crc32 (ulong crc = 0UL, [CCode (array_length_type = "guint")] uint8[]? buf = null);
	}
	[CCode (cname = "gz_header", has_type_id = false)]
	public struct GZHeader {
		public int text;
		public ulong time;
		public int xflags;
		public int os;
		[CCode (array_length_cname = "extra_len", array_length_type = "guint")]
		public unowned uint8[] extra;
		public uint extra_max;
		public unowned string? name;
		public uint name_max;
		public unowned string comment;
		[CCode (cname = "comm_max")]
		public uint comment_max;
		public int hcrc;
		public int done;
	}
	[CCode (cname = "struct gzFile_s", cprefix = "gz", free_function = "gzclose")]
	[Compact]
	public class GZFileStream {
		public static GZFileStream open (string path, string mode = "rb");
		public static GZFileStream dopen (int fd, string mode);
		public int setparams (int level, int strategy);
		public int read (uint8[] buf);
		public int write (uint8[] buf);
		[PrintfFormat]
		public int printf (string format, ...);
		public int puts (string s);
		public unowned string gets (char[] buf);
		public int flush (int flush);
		public int rewind ();
		public bool eof ();
		public bool direct ();
	}
}