mirror of
https://github.com/danog/libdvb.git
synced 2024-11-30 04:19:00 +01:00
cleaning; frontend name without libc
This commit is contained in:
parent
302887dc3d
commit
478bcdd8dd
@ -33,7 +33,6 @@ use {
|
||||
Context,
|
||||
Result,
|
||||
},
|
||||
libc,
|
||||
thiserror::Error,
|
||||
|
||||
crate::ioctl::{
|
||||
@ -201,8 +200,8 @@ impl FeDevice {
|
||||
let mut feinfo = FeInfo::default();
|
||||
self.ioctl(FE_GET_INFO, feinfo.as_mut_ptr()).context("fe get info")?;
|
||||
|
||||
let len = unsafe { libc::strnlen(feinfo.name.as_ptr() as *const _, feinfo.name.len()) };
|
||||
if let Ok(name) = CStr::from_bytes_with_nul(&feinfo.name[.. len + 1]) {
|
||||
if let Some(len) = feinfo.name.iter().position(|&b| b == 0) {
|
||||
let name = unsafe { CStr::from_ptr(feinfo.name[.. len + 1].as_ptr()) };
|
||||
if let Ok(name) = name.to_str() {
|
||||
self.name = name.to_owned();
|
||||
}
|
||||
@ -370,25 +369,23 @@ impl FeDevice {
|
||||
pub fn ioctl_set_property(&self, cmdseq: &[DtvProperty]) -> Result<()> {
|
||||
self.check_cmdseq(cmdseq).context("fe property check")?;
|
||||
|
||||
let cmd = DtvProperties::new(cmdseq);
|
||||
let cmd = DtvProperties {
|
||||
num: cmdseq.len() as u32,
|
||||
props: cmdseq.as_ptr(),
|
||||
};
|
||||
|
||||
self.ioctl(FE_SET_PROPERTY, cmd.as_ptr())
|
||||
}
|
||||
|
||||
/// Gets properties from frontend device
|
||||
pub fn ioctl_get_property(&self, cmdseq: &mut [DtvProperty]) -> Result<()> {
|
||||
// same as DtvProperties but with mut props
|
||||
#[repr(C)]
|
||||
struct DtvPropertiesMut {
|
||||
num: u32,
|
||||
props: *mut DtvProperty,
|
||||
}
|
||||
|
||||
let mut cmd = DtvPropertiesMut {
|
||||
num: cmdseq.len() as u32,
|
||||
props: cmdseq.as_mut_ptr(),
|
||||
};
|
||||
|
||||
self.ioctl(FE_GET_PROPERTY, &mut cmd as *mut _)
|
||||
self.ioctl(FE_GET_PROPERTY, cmd.as_mut_ptr())
|
||||
}
|
||||
|
||||
/// Sets DiSEqC master command
|
||||
|
@ -118,7 +118,7 @@ mod fe_type {
|
||||
#[derive(Debug)]
|
||||
pub struct FeInfo {
|
||||
/// Name of the frontend
|
||||
pub name: [u8; 128],
|
||||
pub name: [std::os::raw::c_char; 128],
|
||||
/// DEPRECATED: frontend delivery system
|
||||
pub fe_type: u32,
|
||||
/// Minimal frequency supported by the frontend
|
||||
@ -710,7 +710,6 @@ pub const DTV_IOCTL_MAX_MSGS: usize = 64;
|
||||
|
||||
/// a set of command/value pairs for FE_SET_PROPERTY
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct DtvProperties {
|
||||
pub num: u32,
|
||||
pub props: *const DtvProperty,
|
||||
@ -719,15 +718,22 @@ pub struct DtvProperties {
|
||||
|
||||
impl DtvProperties {
|
||||
#[inline]
|
||||
pub fn new(props: &[DtvProperty]) -> DtvProperties {
|
||||
DtvProperties {
|
||||
num: props.len() as u32,
|
||||
props: props.as_ptr(),
|
||||
}
|
||||
pub fn as_ptr(&self) -> *const DtvProperties { self as *const _ }
|
||||
}
|
||||
|
||||
|
||||
// a set of command/value pairs for FE_GET_PROPERTY
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct DtvPropertiesMut {
|
||||
pub num: u32,
|
||||
pub props: *mut DtvProperty,
|
||||
}
|
||||
|
||||
|
||||
impl DtvPropertiesMut {
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const DtvProperties { self as *const _ }
|
||||
pub fn as_mut_ptr(&mut self) -> *mut DtvPropertiesMut { self as *mut _ }
|
||||
}
|
||||
|
||||
|
||||
@ -770,7 +776,7 @@ pub const FE_GET_INFO: IoctlInt = io_read::<FeInfo>(b'o', 61);
|
||||
|
||||
pub const FE_DISEQC_RESET_OVERLOAD: IoctlInt = io_none(b'o', 62);
|
||||
pub const FE_DISEQC_SEND_MASTER_CMD: IoctlInt = io_write::<DiseqcMasterCmd>(b'o', 63);
|
||||
pub const FE_DISEQC_RECV_SLAVE_REPLY: IoctlInt = io_read::<DiseqcSlaveReply>(b'0', 64);
|
||||
pub const FE_DISEQC_RECV_SLAVE_REPLY: IoctlInt = io_read::<DiseqcSlaveReply>(b'o', 64);
|
||||
pub const FE_DISEQC_SEND_BURST: IoctlInt = io_none(b'o', 65);
|
||||
|
||||
pub const FE_SET_TONE: IoctlInt = io_none(b'o', 66);
|
||||
@ -787,4 +793,4 @@ pub const FE_GET_EVENT: IoctlInt = io_read::<FeEvent>(b'o', 78);
|
||||
pub const FE_SET_FRONTEND_TUNE_MODE: IoctlInt = io_none(b'o', 81);
|
||||
|
||||
pub const FE_SET_PROPERTY: IoctlInt = io_write::<DtvProperties>(b'o', 82);
|
||||
pub const FE_GET_PROPERTY: IoctlInt = io_read::<DtvProperties>(b'o', 83);
|
||||
pub const FE_GET_PROPERTY: IoctlInt = io_read::<DtvPropertiesMut>(b'o', 83);
|
||||
|
Loading…
Reference in New Issue
Block a user