mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-02 14:07:46 +00:00
hostname: migrate winapi
to windows-sys
crate
This commit is contained in:
parent
05a224d40e
commit
b0b7565ba9
3 changed files with 5 additions and 6 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2498,7 +2498,7 @@ dependencies = [
|
|||
"clap 4.0.17",
|
||||
"hostname",
|
||||
"uucore",
|
||||
"winapi",
|
||||
"windows-sys 0.42.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -20,11 +20,11 @@ hostname = { version = "0.3", features = ["set"] }
|
|||
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["wide"] }
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
winapi = { version="0.3", features=["sysinfoapi", "winsock2"] }
|
||||
windows-sys = { version = "0.42.0", default-features = false, features = ["Win32_Networking_WinSock", "Win32_Foundation"] }
|
||||
|
||||
[[bin]]
|
||||
name = "hostname"
|
||||
path = "src/main.rs"
|
||||
|
||||
[package.metadata.cargo-udeps.ignore]
|
||||
normal = ["uucore_procs", "winapi"]
|
||||
normal = ["uucore_procs"]
|
||||
|
|
|
@ -32,15 +32,14 @@ static OPT_HOST: &str = "host";
|
|||
mod wsa {
|
||||
use std::io;
|
||||
|
||||
use winapi::shared::minwindef::MAKEWORD;
|
||||
use winapi::um::winsock2::{WSACleanup, WSAStartup, WSADATA};
|
||||
use windows_sys::Win32::Networking::WinSock::{WSACleanup, WSAStartup, WSADATA};
|
||||
|
||||
pub(super) struct WsaHandle(());
|
||||
|
||||
pub(super) fn start() -> io::Result<WsaHandle> {
|
||||
let err = unsafe {
|
||||
let mut data = std::mem::MaybeUninit::<WSADATA>::uninit();
|
||||
WSAStartup(MAKEWORD(2, 2), data.as_mut_ptr())
|
||||
WSAStartup(0x0202, data.as_mut_ptr())
|
||||
};
|
||||
if err != 0 {
|
||||
Err(io::Error::from_raw_os_error(err))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue