forked from AxisCommunications/acap-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
36 lines (31 loc) · 880 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#![forbid(unsafe_code)]
//! A simple example application demonstrating how the licensekey crate may be used
use std::{
ffi::{CStr, CString},
os::unix::ffi::OsStrExt,
};
use log::{info, warn};
const APP_ID: i32 = 0;
const MAJOR_VERSION: i32 = 1;
const MINOR_VERSION: i32 = 0;
fn check_license_status(app_name: &CStr) {
match licensekey::verify(app_name, APP_ID, MAJOR_VERSION, MINOR_VERSION) {
Ok(()) => info!("License key is valid"),
Err(e) => warn!("License key is invalid because {e}"),
}
}
fn main() {
acap_logging::init_logger();
let app_name = CString::new(
std::env::current_exe()
.unwrap()
.file_name()
.unwrap()
.as_bytes(),
)
.unwrap();
loop {
check_license_status(&app_name);
std::thread::sleep(std::time::Duration::from_secs(300));
}
}