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
use std::ffi::CStr;
use std::os::raw::c_char;
use util;
unsafe fn convert_args(args: *const *const c_char) -> Vec<String> {
let mut rc = Vec::new();
let mut ptr = args;
while !ptr.is_null() && !(*ptr).is_null() {
let opt = CStr::from_ptr(*ptr).to_string_lossy().to_string();
rc.push(opt);
ptr = ptr.offset(1);
}
rc
}
#[no_mangle]
pub unsafe extern "C" fn ipp_main(args: *const *const c_char) -> i32 {
let args = convert_args(args);
match util::util_main(args) {
Ok(_) => 0,
Err(e) => e.as_exit_code(),
}
}