blob: 0e8d1eb0d84b4a12a8fa1222eb2da12819823aa3 (
plain)
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
|
use libc::{c_char, c_int};
use std::ffi::CString;
extern "C" {
fn tor_version_as_new_as(
platform: *const c_char,
cutoff: *const c_char,
) -> c_int;
}
/// Wrap calls to tor_version_as_new_as, defined in src/or/routerparse.c
pub fn c_tor_version_as_new_as(platform: &str, cutoff: &str) -> bool {
// CHK: These functions should log a warning if an error occurs. This
// can be added when integration with tor's logger is added to rust
let c_platform = match CString::new(platform) {
Ok(n) => n,
Err(_) => return false,
};
let c_cutoff = match CString::new(cutoff) {
Ok(n) => n,
Err(_) => return false,
};
let result: c_int;
unsafe {
result = tor_version_as_new_as(c_platform.as_ptr(), c_cutoff.as_ptr());
result == 1
}
}
|