build: initial skeleton
Add initial build system integration.
This commit is contained in:
commit
be565d948b
37 changed files with 3870 additions and 0 deletions
8
crates/nss/src/helpers.rs
Normal file
8
crates/nss/src/helpers.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
// SPDX-FileCopyrightText: Matteo Settenvini <matteo.settenvini@montecristosoftware.eu>
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
pub fn set_if_valid<T>(ptr: *mut T, val: T) {
|
||||
if !ptr.is_null() {
|
||||
unsafe { *ptr = val };
|
||||
}
|
||||
}
|
133
crates/nss/src/lib.rs
Normal file
133
crates/nss/src/lib.rs
Normal file
|
@ -0,0 +1,133 @@
|
|||
// 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(),
|
||||
)
|
||||
}
|
7
crates/nss/src/nss_bindings.rs
Normal file
7
crates/nss/src/nss_bindings.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
// SPDX-FileCopyrightText: Matteo Settenvini <matteo.settenvini@montecristosoftware.eu>
|
||||
// SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_upper_case_globals)]
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
Loading…
Add table
Add a link
Reference in a new issue