tar_sys/
lib.rs

1//! Bindings to [libtar][1].
2//!
3//! [1]: http://www.feep.net/libtar
4
5extern crate libc;
6
7use libc::{c_char, c_int, c_long, c_void};
8
9// https://github.com/stainless-steel/libtar/blob/master/lib/libtar.h
10
11#[repr(C)]
12#[allow(dead_code, missing_copy_implementations)]
13pub struct tar_header {
14    name: [c_char; 100],
15    mode: [c_char; 8],
16    uid: [c_char; 8],
17    gid: [c_char; 8],
18    size: [c_char; 12],
19    mtime: [c_char; 12],
20    chksum: [c_char; 8],
21    typeflag: c_char,
22    linkname: [c_char; 100],
23    magic: [c_char; 6],
24    version: [c_char; 2],
25    uname: [c_char; 32],
26    gname: [c_char; 32],
27    devmajor: [c_char; 8],
28    devminor: [c_char; 8],
29    prefix: [c_char; 155],
30    padding: [c_char; 12],
31    gnu_longname: *mut c_char,
32    gnu_longlink: *mut c_char,
33}
34
35#[repr(C)]
36#[allow(dead_code)]
37pub struct TAR {
38    typo: *mut c_void,
39    pathname: *mut c_char,
40    fd: c_long,
41    oflags: c_int,
42    options: c_int,
43    th_buf: tar_header,
44    h: *mut c_void,
45}
46
47extern {
48    // https://github.com/stainless-steel/libtar/blob/master/lib/libtar.h
49
50    pub fn tar_open(t: *mut *mut TAR, pathname: *const c_char, typo: *mut c_void,
51                    oflags: c_int, mode: c_int, options: c_int) -> c_int;
52
53    pub fn tar_close(t: *mut TAR) -> c_int;
54
55    pub fn tar_extract_all(t: *mut TAR, prefix: *const c_char) -> c_int;
56}