From e4bc82154829c496a61d0afc350a46f7aa615132 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 18 Jan 2018 10:33:37 +0100 Subject: [PATCH 1/4] Add {get,set}domainname --- src/unix/bsd/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index b9a88f09..51157ed6 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -390,7 +390,8 @@ extern { pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); - + pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; + pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; pub fn getpeereid(socket: ::c_int, euid: *mut ::uid_t, egid: *mut ::gid_t) -> ::c_int; From dca8a31d007f2b77f002970e8ff0934f96204374 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 18 Jan 2018 10:34:31 +0100 Subject: [PATCH 2/4] Add gethostname. Closes #868 . --- src/unix/bsd/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 51157ed6..b04b15fe 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -392,6 +392,7 @@ extern { pub fn if_freenameindex(ptr: *mut if_nameindex); pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; + pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int; pub fn getpeereid(socket: ::c_int, euid: *mut ::uid_t, egid: *mut ::gid_t) -> ::c_int; From 7c074b85d48bceb871957a683286d2e9b27cca1f Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 18 Jan 2018 17:02:07 +0100 Subject: [PATCH 3/4] remove gethosname, use proper types depending on bsd flavour --- src/unix/bsd/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index b04b15fe..118daf49 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -390,9 +390,15 @@ extern { pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); + + #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly"))] + pub fn getdomainname(name: *mut ::c_char, len: ::c_int) -> ::c_int; + #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly"))] + pub fn setdomainname(name: *const ::c_char, len: ::c_int) -> ::c_int; + #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly")))] pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; + #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly")))] pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; - pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int; pub fn getpeereid(socket: ::c_int, euid: *mut ::uid_t, egid: *mut ::gid_t) -> ::c_int; From 6c63b9d8b2556b03830352bada6791ec5ed41f0e Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 18 Jan 2018 17:11:20 +0100 Subject: [PATCH 4/4] fix style --- src/unix/bsd/apple/mod.rs | 3 ++- src/unix/bsd/freebsdlike/mod.rs | 2 ++ src/unix/bsd/mod.rs | 8 -------- src/unix/bsd/netbsdlike/mod.rs | 2 ++ 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 83911e62..7981f723 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -2352,7 +2352,8 @@ extern { pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char; pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; - + pub fn getdomainname(name: *mut ::c_char, len: ::c_int) -> ::c_int; + pub fn setdomainname(name: *const ::c_char, len: ::c_int) -> ::c_int; pub fn getxattr(path: *const ::c_char, name: *const ::c_char, value: *mut ::c_void, size: ::size_t, position: u32, flags: ::c_int) -> ::ssize_t; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 5cea7595..80a66b73 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1157,6 +1157,8 @@ extern { timeout: *const ::timespec, sigmask: *const sigset_t) -> ::c_int; pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int; + pub fn getdomainname(name: *mut ::c_char, len: ::c_int) -> ::c_int; + pub fn setdomainname(name: *const ::c_char, len: ::c_int) -> ::c_int; } cfg_if! { diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 118daf49..b9a88f09 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -391,14 +391,6 @@ extern { pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); - #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly"))] - pub fn getdomainname(name: *mut ::c_char, len: ::c_int) -> ::c_int; - #[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly"))] - pub fn setdomainname(name: *const ::c_char, len: ::c_int) -> ::c_int; - #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly")))] - pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; - #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly")))] - pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; pub fn getpeereid(socket: ::c_int, euid: *mut ::uid_t, egid: *mut ::gid_t) -> ::c_int; diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 9179e6af..0ab09f66 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -625,6 +625,8 @@ extern { pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char, envp: *const *const ::c_char) -> ::c_int; + pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; + pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; } cfg_if! {