commit ea3483263da315fd6cf5b25598ac6cc044ee64e0 Author: Matteo Settenvini Date: Sat Aug 13 10:32:40 2022 +0200 Create initial skeleton diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a729bbc --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/build +/target +/Cargo.lock diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c7e055b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.23) + +project(nss_malcontent + DESCRIPTION "" + VERSION 0.1.0 + LANGUAGES C) + +include(FetchContent) +FetchContent_Declare( + Corrosion + GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git + GIT_TAG v0.2.1 +) + +set(Rust_TOOLCHAIN nightly) +FetchContent_MakeAvailable(Corrosion) +corrosion_import_crate(MANIFEST_PATH Cargo.toml) + +get_target_property(corrosion_install_libraries malcontent-nss INTERFACE_LINK_LIBRARIES) +install(IMPORTED_RUNTIME_ARTIFACTS ${corrosion_install_libraries}) \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..f045b4e --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "malcontent-nss" +version = "0.1.0" +edition = "2021" +authors = ["Matteo Settenvini nss_status { + todo!() +} + +#[no_mangle] +pub extern "C" fn _nss_malcontent_gethostbyname3_r( + name: *const c_char, + af: c_int, + host: *mut hostent, + buffer: *mut c_char, + buflen: size_t, + errnop: *mut c_int, + h_errnop: *mut c_int, + ttlp: *mut i32, + canonp: *mut *mut char, +) -> nss_status { + todo!() +} + +#[no_mangle] +pub extern "C" fn _nss_malcontent_gethostbyname2_r( + name: *const c_char, + af: c_int, + host: *mut hostent, + buffer: *mut c_char, + buflen: size_t, + errnop: *mut c_int, + h_errnop: *mut c_int, +) -> nss_status { + _nss_malcontent_gethostbyname3_r( + name, + af, + host, + buffer, + buflen, + errnop, + h_errnop, + ptr::null_mut(), + ptr::null_mut(), + ) +} + +#[no_mangle] +pub extern "C" fn _nss_malcontent_gethostbyname_r( + name: *const c_char, + host: *mut hostent, + buffer: *mut c_char, + buflen: size_t, + errnop: *mut c_int, + h_errnop: *mut c_int, +) -> nss_status { + _nss_malcontent_gethostbyname3_r( + name, + AF_INET, + host, + buffer, + buflen, + errnop, + h_errnop, + ptr::null_mut(), + ptr::null_mut(), + ) +} + +// ----------------- by addr ----------------- + +#[no_mangle] +pub extern "C" fn _nss_malcontent_gethostbyaddr2_r( + addr: *const c_void, + len: socklen_t, + af: c_int, + host: *mut hostent, + buffer: *mut c_char, + buflen: size_t, + errnop: *mut c_int, + h_errnop: *mut c_int, + ttlp: *mut i32, +) -> nss_status { + todo!() +} + +#[no_mangle] +pub extern "C" fn _nss_malcontent_gethostbyaddr_r( + addr: *const c_void, + len: socklen_t, + af: c_int, + host: *mut hostent, + buffer: *mut c_char, + buflen: size_t, + errnop: *mut c_int, + h_errnop: *mut c_int, +) -> nss_status { + _nss_malcontent_gethostbyaddr2_r( + addr, + len, + af, + host, + buffer, + buflen, + errnop, + h_errnop, + ptr::null_mut(), + ) +} diff --git a/wrapper.h b/wrapper.h new file mode 100644 index 0000000..7ef4fd2 --- /dev/null +++ b/wrapper.h @@ -0,0 +1 @@ +#include \ No newline at end of file