From b28b997d20951170696c705a0cd39750f88a004c Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 6 Dec 2019 02:27:03 -0800 Subject: [PATCH] Actually run most main() --- src/main.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 1824cbc..bfd6c76 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,27 @@ +extern crate libc; + #[allow(non_camel_case_types, non_snake_case, dead_code)] mod ffi; //generated with `bindgen vendor/most-5.1.0/src/most.h -o src/ffi.rs` +use std::ffi::CString; +use libc::{c_int, c_char}; + fn main() { - println!("Printing most usage:"); + + 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); + /* unsafe { ffi::most_usage(); } + */ }