Port usage()
This commit is contained in:
parent
d55f8fd5ed
commit
b64211f27c
@ -10,3 +10,4 @@ crate-type = ["staticlib"]
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2"
|
||||
|
34
main.c
34
main.c
@ -32,44 +32,17 @@
|
||||
#include "util.h"
|
||||
|
||||
const char version[] = VERSION;
|
||||
const char *copyright;
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
extern void print_message_from_rust();
|
||||
extern void print_usage(const char* version);
|
||||
|
||||
int trace_flag = 0;
|
||||
|
||||
void usage()
|
||||
{
|
||||
fprintf(stderr, "DMR Config, Version %s, %s\n", version, copyright);
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, " dmrconfig -r [-t]\n");
|
||||
fprintf(stderr, " Read codeplug from the radio to a file 'device.img'.\n");
|
||||
fprintf(stderr, " Save configuration to a text file 'device.conf'.\n");
|
||||
fprintf(stderr, " dmrconfig -w [-t] file.img\n");
|
||||
fprintf(stderr, " Write codeplug to the radio.\n");
|
||||
fprintf(stderr, " dmrconfig -v [-t] file.conf\n");
|
||||
fprintf(stderr, " Verify configuration script for the radio.\n");
|
||||
fprintf(stderr, " dmrconfig -c [-t] file.conf\n");
|
||||
fprintf(stderr, " Apply configuration script to the radio.\n");
|
||||
fprintf(stderr, " dmrconfig -c file.img file.conf\n");
|
||||
fprintf(stderr, " Apply configuration script to the codeplug image.\n");
|
||||
fprintf(stderr, " Store modified copy to a file 'device.img'.\n");
|
||||
fprintf(stderr, " dmrconfig file.img\n");
|
||||
fprintf(stderr, " Display configuration from the codeplug image.\n");
|
||||
fprintf(stderr, " dmrconfig -u [-t] file.csv\n");
|
||||
fprintf(stderr, " Update contacts database from CSV file.\n");
|
||||
fprintf(stderr, "Options:\n");
|
||||
fprintf(stderr, " -r Read codeplug from the radio.\n");
|
||||
fprintf(stderr, " -w Write codeplug to the radio.\n");
|
||||
fprintf(stderr, " -c Configure the radio from a text script.\n");
|
||||
fprintf(stderr, " -v Verify config file.\n");
|
||||
fprintf(stderr, " -u Update contacts database.\n");
|
||||
fprintf(stderr, " -l List all supported radios.\n");
|
||||
fprintf(stderr, " -t Trace USB protocol.\n");
|
||||
exit(-1);
|
||||
void usage() {
|
||||
print_usage((const char*)version);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
@ -78,7 +51,6 @@ int main(int argc, char **argv)
|
||||
int read_flag = 0, write_flag = 0, config_flag = 0, csv_flag = 0;
|
||||
int list_flag = 0, verify_flag = 0;
|
||||
|
||||
copyright = "Copyright (C) 2018 Serge Vakulenko KK6ABQ";
|
||||
trace_flag = 0;
|
||||
for (;;) {
|
||||
switch (getopt(argc, argv, "tcwrulv")) {
|
||||
|
40
src/lib.rs
40
src/lib.rs
@ -1,8 +1,48 @@
|
||||
use std::ffi::CStr;
|
||||
use libc::c_char;
|
||||
|
||||
const COPYRIGHT: &'static str = "Copyright (C) 2018 Serge Vakulenko KK6ABQ";
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn print_message_from_rust() {
|
||||
println!("Calling from Rust!");
|
||||
}
|
||||
|
||||
#[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]\n
|
||||
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);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
Loading…
Reference in New Issue
Block a user