1 /* libarchive.vapi - Bindings for libarchive(3) (version 2).
3 * Copyright (C) 2009 Julian Andres Klode <jak@jak-linux.org>
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 * Julian Andres Klode <jak@jak-linux.org>
25 [CCode (cprefix="ARCHIVE_", lower_case_cprefix="archive_", cheader_filename = "archive.h")]
27 public const int VERSION_NUMBER;
28 public const string VERSION_STRING;
29 public int version_number ();
30 public unowned string version_string ();
32 [CCode (instance_pos = 1.9, cname="archive_read_callback")]
33 public delegate ssize_t ReadCallback (Archive archive, out void* buffer);
34 [CCode (instance_pos = 1.9, cname="archive_skip_callback")]
35 public delegate Posix.off_t SkipCallback (Archive archive, Posix.off_t request);
36 [CCode (instance_pos = 1.9, cname="archive_write_callback")]
37 public delegate ssize_t WriteCallback (Archive archive, void* buffer, size_t length);
38 [CCode (instance_pos = 1.9, cname="archive_open_callback")]
39 public delegate int OpenCallback (Archive archive);
41 [CCode (cname="archive_close_callback")]
42 public delegate int CloseCallback (Archive archive);
44 // In reality a "void (*_progress_func)(void *)" parameter without name.
45 public delegate void ExtractProgressCallback ();
47 [CCode (cprefix="ARCHIVE_", cname="int")]
57 public enum Compression {
93 [CCode (cprefix="ARCHIVE_EXTRACT_", cname="int")]
94 public enum ExtractFlags {
111 [CCode (cname="struct archive", cprefix="archive_")]
112 public class Archive {
113 public int64 position_compressed ();
114 public int64 position_uncompressed ();
116 public Compression compression ();
117 public Format format ();
118 public unowned string compression_name ();
119 public unowned string format_name ();
122 public unowned string error_string ();
123 public void clear_error ();
124 public void set_error (int err, string fmt, ...);
125 public void copy_error (Archive src);
130 [CCode (cname="struct archive", free_function="archive_read_finish")]
131 public class Read : Archive {
133 public Result support_compression_all ();
134 public Result support_compression_bzip2 ();
135 public Result support_compression_compress ();
136 public Result support_compression_gzip ();
137 public Result support_compression_lzma ();
138 public Result support_compression_none ();
139 public Result support_compression_program (string command);
140 public Result support_format_all ();
141 public Result support_format_ar ();
142 public Result support_format_cpio ();
143 public Result support_format_empty ();
144 public Result support_format_gnutar ();
145 public Result support_format_iso9660 ();
146 public Result support_format_mtree ();
147 public Result support_format_tar ();
148 public Result support_format_zip ();
152 [CCode (delegate_target_pos = 0.9)] OpenCallback ocb,
153 [CCode (delegate_target_pos = 0.9)] ReadCallback rcb,
154 [CCode (delegate_target_pos = 0.9)] CloseCallback ccb
157 public Result open2 (
158 [CCode (delegate_target_pos = 0.9)] OpenCallback ocb,
159 [CCode (delegate_target_pos = 0.9)] ReadCallback rcb,
160 [CCode (delegate_target_pos = 0.9)] SkipCallback scb,
161 [CCode (delegate_target_pos = 0.9)] CloseCallback ccb
164 public Result open_filename (string filename, size_t _block_size);
165 public Result open_memory (void* buff, size_t size);
166 public Result open_fd (int fd, size_t block_size);
168 public Result open_FILE (Posix.FILE file);
170 public Result open_FILE (GLib.FileStream file);
172 public Result next_header (out unowned Entry entry);
173 public int64 header_position ();
175 [CCode (cname="archive_read_data")]
176 public ssize_t read_data (void* buffer, size_t size);
177 [CCode (cname="archive_read_block")]
178 public Result read_data_block (out void* buff, out size_t size, out Posix.off_t offset);
179 [CCode (cname="archive_read_data_skip")]
180 public Result read_data_skip ();
181 [CCode (cname="archive_read_data_into_buffer")]
182 public Result read_data_into_buffer (void* buffer, ssize_t len);
183 [CCode (cname="archive_read_data_into_fd")]
184 public Result read_data_into_fd (int fd);
186 public Result extract (Entry entry, ExtractFlags? flags=0);
187 public Result extract2 (Entry entry, Write dest);
188 public void extract_set_progress_callback (ExtractProgressCallback cb);
189 public void extract_set_skip_file (Posix.dev_t dev, Posix.ino_t ino);
190 public Result close ();
193 [CCode (cname = "struct archive", free_function="archive_write_finish")]
194 public class Write : Archive {
196 public Result set_compression_bzip2 ();
197 public Result set_compression_compress ();
198 public Result set_compression_gzip ();
199 public Result set_compression_none ();
200 public Result set_compression_program (string cmd);
201 public Result set_format (Format format);
202 public Result set_format_by_name (string name);
203 public Result set_format_ar_bsd ();
204 public Result set_format_ar_svr4 ();
205 public Result set_format_cpio ();
206 public Result set_format_cpio_newc ();
207 public Result set_format_mtree ();
208 public Result set_format_pax ();
209 public Result set_format_pax_restricted ();
210 public Result set_format_shar ();
211 public Result set_format_shar_dump ();
212 public Result set_format_ustar ();
214 public Result set_bytes_per_block (int bytes_per_block);
215 public int get_bytes_per_block ();
216 public Result set_bytes_in_last_block (int bytes_in_last_block);
217 public int get_bytes_in_last_block ();
218 public Result set_skip_file (Posix.dev_t dev, Posix.ino_t ino);
221 [CCode (delegate_target_pos = 0.9)] OpenCallback ocb,
222 [CCode (delegate_target_pos = 0.9)] WriteCallback rcb,
223 [CCode (delegate_target_pos = 0.9)] CloseCallback ccb
225 public Result open_fd (int fd);
226 public Result open_filename (string filename);
228 public Result open_FILE (Posix.FILE file);
230 public Result open_FILE (GLib.FileStream file);
232 public Result open_memory (void* buffer, size_t buff_size, out size_t used);
234 [CCode (cname="archive_write_header")]
235 public Result write_header (Entry entry);
236 [CCode (cname="archive_write_data")]
237 public ssize_t write_data (void* data, size_t size);
238 [CCode (cname="archive_write_data_block")]
239 public ssize_t write_data_block (void* data, size_t size, Posix.off_t offset);
241 public Result finish_entry ();
242 public Result close ();
246 [CCode (cname = "struct archive", free_function="archive_write_finish")]
247 public class WriteDisk : Write {
250 public Result set_skip_file (Posix.dev_t dev, Posix.ino_t ino);
251 public Result set_options (ExtractFlags flags);
252 public Result set_standard_lookup ();
254 // HACK, they have no name in C. May not work correctly.
255 [CCode (instance_pos = 0, cname="gid_t")]
256 public delegate Posix.gid_t GroupLookup (string group, Posix.gid_t gid);
257 [CCode (instance_pos = 0, cname="uid_t")]
258 public delegate Posix.uid_t UserLookup (string user, Posix.uid_t uid);
259 [CCode (instance_pos = 0, cname="void")]
260 public delegate void Cleanup ();
262 public Result set_group_lookup (
263 [CCode (delegate_target_pos = 0.9) ] GroupLookup lookup,
264 [CCode (delegate_target_pos = 0.9) ] Cleanup? cleanup = null
267 public Result set_user_lookup (
268 [CCode (delegate_target_pos = 0.9) ] UserLookup lookup,
269 [CCode (delegate_target_pos = 0.9) ] Cleanup? cleanup = null
274 [CCode (cname = "struct archive_entry", cheader_filename = "archive_entry.h")]
277 public time_t atime ();
278 public long atime_nsec ();
279 public bool atime_is_set ();
280 public time_t birthtime ();
281 public long birthtime_nsec ();
282 public bool birthtime_is_set ();
283 public time_t ctime ();
284 public long ctime_nsec ();
285 public bool ctime_is_set ();
286 public Posix.dev_t dev ();
287 public Posix.dev_t devmajor ();
288 public Posix.dev_t devminor ();
289 public Posix.mode_t filetype ();
290 public unowned string fflags_text ();
291 public Posix.gid_t gid ();
292 public unowned string gname ();
293 public unowned string hardlink ();
294 public Posix.ino_t ino ();
295 public Posix.mode_t mode ();
296 public time_t mtime ();
297 public long mtime_nsec ();
298 public bool mtime_is_set ();
299 public uint nlink ();
300 public unowned string pathname ();
301 public Posix.dev_t rdev ();
302 public Posix.dev_t rdevmajor ();
303 public Posix.dev_t rdevminor ();
304 public unowned string sourcepath ();
305 public int64 size ();
306 public bool size_is_set ();
307 public unowned string strmode ();
308 public unowned string symlink ();
309 public Posix.uid_t uid ();
310 public unowned string uname ();
311 public void set_atime (time_t atime, long blah);
312 public void unset_atime ();
313 public void set_birthtime (time_t birthtime, long blah);
314 public void unset_birthtime ();
315 public void set_ctime (time_t atime, long blah);
316 public void unset_ctime ();
317 public void set_dev (Posix.dev_t dev);
318 public void set_devmajor (Posix.dev_t major);
319 public void set_devminor (Posix.dev_t major);
320 public void set_filetype (uint filetype);
321 public void set_fflags (ulong set, ulong clear);
322 public unowned string copy_fflags_text (string text);
323 public void set_gid (Posix.gid_t gid);
324 public void set_gname (string gname);
325 public Result update_gname_utf8 (string gname);
326 public void set_hardlink (string link);
327 public void set_ino (ulong ino);
328 public void set_link (string link);
329 public Result update_link_utf8 (string link);
330 public void set_mode (Posix.mode_t mode);
331 public void set_mtime (time_t mtime, long blah);
332 public void unset_mtime ();
333 public void set_nlink (uint nlink);
334 public void set_pathname (string pathname);
335 public Result update_pathname_utf8 (string pathname);
336 public void set_perm (Posix.mode_t mode);
337 public void set_rdev (Posix.dev_t dev);
338 public void set_rdevmajor (Posix.dev_t devmajor);
339 public void set_rdevminor (Posix.dev_t devminor);
340 public void set_size (int64 size);
341 public void unset_size ();
342 public void copy_sourcepath (string sourcepath);
343 public void set_symlink (string symlink);
344 public void set_uid (Posix.uid_t uid);
345 public void set_uname (string uname);
346 public Result update_uname_utf8 (string uname);
348 public unowned Posix.Stat stat ();
349 public void copy_stat (Posix.Stat stat);
351 public unowned Entry clear ();
352 public Entry clone ();
354 public void xattr_clear();
355 public void xattr_add_entry(string name, void* value, size_t size);
356 public int xattr_count();
357 public Result xattr_reset();
358 public Result xattr_next(out unowned string name, out void* value, out size_t size);
361 public class LinkResolver {
362 public LinkResolver ();
363 public void set_strategy (Format format_code);
364 public void linkify (Entry a, Entry b);