Verified Commit 634ce3e2 authored by Ave's avatar Ave 🤔

Further modularize code, print program info on launch

parent 115b53a0
......@@ -90,7 +90,7 @@ fn auth_witchcraft(card: &pcsc::Card) {
send_verify_apdu(b"\xFF\x00\x00\x00\x08\xD4\x08\x63\x02\x80\x63\x03\x80", b"\xD5\x09\x90\x00", &card);
}
fn main() {
fn connect() -> pcsc::Card {
// Establish a PC/SC context.
let ctx = match Context::establish(Scope::User) {
Ok(ctx) => ctx,
......@@ -116,7 +116,7 @@ fn main() {
Some(reader) => reader,
None => {
println!("No readers are connected.");
return;
std::process::exit(1);
}
};
println!("Using reader: {:?}", reader);
......@@ -126,13 +126,21 @@ fn main() {
Ok(card) => card,
Err(Error::NoSmartcard) => {
println!("A smartcard is not present in the reader.");
return;
std::process::exit(1);
}
Err(err) => {
eprintln!("Failed to connect to card: {}", err);
std::process::exit(1);
}
};
card
}
fn main() {
println!("FlashUID-rs, developed by aveao, released under GPLv3.\nhttps://gitlab.com/ao/flashuid-rs\n");
let card = connect();
// Disable buzzer
// https://stackoverflow.com/a/41550221/3286892
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment