use std::ffi::CStr; use libc::c_char; mod radio; const COPYRIGHT: &'static str = "Copyright (C) 2018 Serge Vakulenko KK6ABQ"; #[no_mangle] pub extern "C" fn print_usage(version_ptr: *const c_char) { let version: String = unsafe { CStr::from_ptr(version_ptr) }.to_string_lossy().to_string(); print!("DMR Config, Version {}, {}", version, COPYRIGHT); let msg = r#" Usage: dmrconfig -r [-t] Read codeplug from the radio to a file 'device.img'. Save configuration to a text file 'device.conf'. dmrconfig -w [-t] file.img Write codeplug to the radio. dmrconfig -v [-t] file.conf Verify configuration script for the radio. dmrconfig -c [-t] file.conf Apply configuration script to the radio. dmrconfig -c file.img file.conf Apply configuration script to the codeplug image. Store modified copy to a file 'device.img'. dmrconfig file.img Display configuration from the codeplug image. dmrconfig -u [-t] file.csv Update contacts database from CSV file. Options: -r Read codeplug from the radio. -w Write codeplug to the radio. -c Configure the radio from a text script. -v Verify config file. -u Update contacts database. -l List all supported radios. -t Trace USB protocol."#; print!("{}", msg); std::process::exit(-1); } #[no_mangle] pub extern "C" fn process_options() { use getopts::Options; let mut opts = Options::new(); opts.optflag("t", "", "Trace USB protocol."); opts.optflag("r", "", "Read codeplug from the radio to a file 'device.img'.\nSave configuration to a text file 'device.conf'."); opts.optflag("w", "", "Write codeplug to the radio."); opts.optflag("c", "", "Verify configuration script for the radio."); opts.optflag("u", "", "Update contacts database from CSV file."); opts.optflag("l", "", "List all supported radios."); opts.optflag("v", "", "Verify configuration script for the radio."); } #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } }