use maraiah::durandal::{err::*, ffi};

extern "C" {
   fn main_cc(app_name: *mut ffi::c_char);
}

#[no_mangle]
unsafe extern "C" fn Ma_test_fn(fname: *const ffi::c_char)
{
   let fname = ffi::CStr::from_ptr(fname);
   println!("hello, world! from rust: {}", fname.to_str().unwrap());
}

fn main() -> ResultS<()>
{
   println!("rust entry");

   let mut args = std::env::args();
   let app_name = args.next().ok_or(err_msg("bad launch name"))?;
   let app_name = ffi::CString::new(app_name)?;

   unsafe {
      main_cc(app_name.into_raw());
   }

   Ok(())
}

// EOF
