()
| 95 | |
| 96 | #[cfg(unix)] |
| 97 | fn platform_host_name() -> Option<String> { |
| 98 | let mut buffer = [0 as libc::c_char; 256]; |
| 99 | unsafe { |
| 100 | if libc::gethostname(buffer.as_mut_ptr(), buffer.len()) != 0 { |
| 101 | None |
| 102 | } else { |
| 103 | buffer[buffer.len() - 1] = 0; |
| 104 | CStr::from_ptr(buffer.as_ptr()).to_str().ok() |
| 105 | } |
| 106 | } |
| 107 | .map(ToOwned::to_owned) |
| 108 | } |
| 109 | |
| 110 | #[cfg(not(unix))] |
| 111 | fn platform_host_name() -> Option<String> { |