linux-parental-controls/crates/nss/src/lib.rs

134 lines
2.8 KiB
Rust
Raw Normal View History

// SPDX-FileCopyrightText: 2022 Matteo Settenvini <matteo.settenvini@montecristosoftware.eu>
// SPDX-License-Identifier: EUPL-1.2
mod helpers;
mod nss_bindings;
use {
crate::helpers::set_if_valid,
crate::nss_bindings::{HErrno, gaih_addrtuple, nss_status},
libc::{AF_INET, hostent, size_t, socklen_t},
nix::errno::Errno,
std::os::raw::{c_char, c_int, c_void},
std::ptr,
};
// -------------- by host ---------------
#[unsafe(no_mangle)]
pub extern "C" fn _nss_parental_ctrls_gethostbyname4_r(
_name: *const c_char,
_pat: *mut *mut gaih_addrtuple,
_buffer: *mut c_char,
_buflen: size_t,
_errnop: *mut Errno,
_h_errnop: *mut HErrno,
_ttlp: *mut i32,
) -> nss_status {
todo!()
}
#[unsafe(no_mangle)]
pub extern "C" fn _nss_parental_ctrls_gethostbyname3_r(
_name: *const c_char,
_af: c_int,
_host: *mut hostent,
_buffer: *mut c_char,
_buflen: size_t,
_errnop: *mut Errno,
_h_errnop: *mut HErrno,
_ttlp: *mut i32,
_canonp: *mut *mut char,
) -> nss_status {
todo!()
}
#[unsafe(no_mangle)]
pub extern "C" fn _nss_parental_ctrls_gethostbyname2_r(
name: *const c_char,
af: c_int,
host: *mut hostent,
buffer: *mut c_char,
buflen: size_t,
errnop: *mut Errno,
h_errnop: *mut HErrno,
) -> nss_status {
_nss_parental_ctrls_gethostbyname3_r(
name,
af,
host,
buffer,
buflen,
errnop,
h_errnop,
ptr::null_mut(),
ptr::null_mut(),
)
}
#[unsafe(no_mangle)]
pub extern "C" fn _nss_parental_ctrls_gethostbyname_r(
name: *const c_char,
host: *mut hostent,
buffer: *mut c_char,
buflen: size_t,
errnop: *mut Errno,
h_errnop: *mut HErrno,
) -> nss_status {
_nss_parental_ctrls_gethostbyname3_r(
name,
AF_INET,
host,
buffer,
buflen,
errnop,
h_errnop,
ptr::null_mut(),
ptr::null_mut(),
)
}
// ----------------- by addr -----------------
#[unsafe(no_mangle)]
pub extern "C" fn _nss_parental_ctrls_gethostbyaddr2_r(
_addr: *const c_void,
_len: socklen_t,
_af: c_int,
_host: *mut hostent,
_buffer: *mut c_char,
_buflen: size_t,
errnop: *mut Errno,
h_errnop: *mut HErrno,
_ttlp: *mut i32,
) -> nss_status {
set_if_valid(errnop, Errno::from_raw(0));
set_if_valid(h_errnop, HErrno::Success);
todo!()
}
#[unsafe(no_mangle)]
pub extern "C" fn _nss_parental_ctrls_gethostbyaddr_r(
addr: *const c_void,
len: socklen_t,
af: c_int,
host: *mut hostent,
buffer: *mut c_char,
buflen: size_t,
errnop: *mut Errno,
h_errnop: *mut HErrno,
) -> nss_status {
_nss_parental_ctrls_gethostbyaddr2_r(
addr,
len,
af,
host,
buffer,
buflen,
errnop,
h_errnop,
ptr::null_mut(),
)
}