Add support for facilities

This commit is contained in:
Mihai Dinculescu
2022-10-15 22:51:57 +01:00
parent 307b83ea95
commit 6be70c8566
23 changed files with 535 additions and 137 deletions

View File

@@ -3,12 +3,12 @@ use std::ffi::CString;
pub fn fixed_c_str_to_string(data: &[i8]) -> String {
let u8slice = unsafe { &*(data as *const _ as *const [u8]) };
let mut value = u8slice.to_vec();
let mut bytes = u8slice.to_vec();
let pos = value.iter().position(|c| *c == 0).unwrap_or(value.len());
let pos = bytes.iter().position(|c| *c == 0).unwrap_or(bytes.len());
value.truncate(pos);
let icao = unsafe { CString::from_vec_unchecked(value) };
bytes.truncate(pos);
let result = unsafe { CString::from_vec_unchecked(bytes) };
icao.to_str().unwrap().to_string()
result.to_str().unwrap_or_default().to_string()
}