rust-most/src/main.rs

28 lines
592 B
Rust
Raw Permalink Normal View History

2019-12-06 02:27:03 -08:00
extern crate libc;
2019-12-06 02:01:59 -08:00
#[allow(non_camel_case_types, non_snake_case, dead_code)]
2019-12-06 02:12:38 -08:00
mod ffi; //generated with `bindgen vendor/most-5.1.0/src/most.h -o src/ffi.rs`
2019-12-05 03:19:41 -08:00
2019-12-06 02:27:03 -08:00
use std::ffi::CString;
use libc::{c_int, c_char};
2019-12-04 01:57:47 -08:00
fn main() {
2019-12-06 02:27:03 -08:00
let args = std::env::args()
.map(|arg| CString::new(arg).unwrap());
let mut c_args: Vec<*mut c_char> = args.map(|arg| arg.into_raw()).collect();
let output = unsafe {
ffi::most_initialize_most();
ffi::most(c_args.len() as c_int, c_args.as_mut_ptr())
};
println!("Output: {}", output);
/*
2019-12-05 03:19:41 -08:00
unsafe {
ffi::most_usage();
}
2019-12-06 02:27:03 -08:00
*/
2019-12-04 01:57:47 -08:00
}