1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use libc::c_char;

#[link(name = "pub", kind = "static")]
extern "C" {
    fn Run(cstrs: *const c_char) -> libc::c_int;
}

pub fn encode(args: Vec<String>) -> Vec<u8> {
    if args.is_empty() {
        "\0".into()
    } else {
        args.join("\0")
    }
    .as_bytes()
    .into()
}

pub fn run(args: Vec<String>) -> i32 {
    unsafe { Run(encode(args).as_ptr() as *const c_char) as i32 }
}