Skip to content

Commit 3dc0872

Browse files
authored
Replace winapi with windows-sys (#525)
1 parent 16e7f87 commit 3dc0872

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ openssl-probe = { version = "0.1.2", optional = true }
2828

2929
[target.'cfg(target_env = "msvc")'.dependencies]
3030
schannel = "0.1.13"
31-
winapi = { version = '0.3', features = ['libloaderapi', 'wincrypt'] }
31+
windows-sys = { version = "0.48", features = ["Win32_System_LibraryLoader", "Win32_Security_Cryptography"] }
3232

3333
[dev-dependencies]
3434
mio = "0.6"

curl-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ features = ["no_log_capture"]
3333
openssl-sys = { version = "0.9.64", optional = true }
3434

3535
[target.'cfg(windows)'.dependencies]
36-
winapi = { version = "0.3", features = ["winsock2", "ws2def"] }
36+
windows-sys = { version = "0.48", features = ["Win32_Networking_WinSock"] }
3737

3838
[target.'cfg(target_env = "msvc")'.build-dependencies]
3939
vcpkg = "0.2"

curl-sys/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ use libc::{c_char, c_double, c_int, c_long, c_short, c_uint, c_void, size_t, tim
1717
#[cfg(unix)]
1818
pub use libc::fd_set;
1919
#[cfg(windows)]
20-
use winapi::shared::ws2def::SOCKADDR;
20+
pub use windows_sys::Win32::Networking::WinSock::FD_SET as fd_set;
2121
#[cfg(windows)]
22-
pub use winapi::um::winsock2::fd_set;
22+
use windows_sys::Win32::Networking::WinSock::SOCKADDR;
2323

2424
#[cfg(target_env = "msvc")]
2525
#[doc(hidden)]

src/easy/windows.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,18 @@ use libc::c_void;
66
mod win {
77
use schannel::cert_context::ValidUses;
88
use schannel::cert_store::CertStore;
9-
use std::ffi::CString;
9+
use std::ffi::*;
1010
use std::mem;
1111
use std::ptr;
12-
use winapi::ctypes::*;
13-
use winapi::um::libloaderapi::*;
14-
use winapi::um::wincrypt::*;
12+
use windows_sys::Win32::Security::Cryptography::*;
13+
use windows_sys::Win32::System::LibraryLoader::*;
1514

1615
fn lookup(module: &str, symbol: &str) -> Option<*const c_void> {
1716
unsafe {
18-
let symbol = CString::new(symbol).unwrap();
1917
let mut mod_buf: Vec<u16> = module.encode_utf16().collect();
2018
mod_buf.push(0);
2119
let handle = GetModuleHandleW(mod_buf.as_mut_ptr());
22-
let n = GetProcAddress(handle, symbol.as_ptr());
23-
if n == ptr::null_mut() {
24-
None
25-
} else {
26-
Some(n as *const c_void)
27-
}
20+
GetProcAddress(handle, symbol.as_ptr()).map(|n| n as *const c_void)
2821
}
2922
}
3023

@@ -104,7 +97,9 @@ mod win {
10497
match valid_uses {
10598
ValidUses::All => {}
10699
ValidUses::Oids(ref oids) => {
107-
let oid = szOID_PKIX_KP_SERVER_AUTH.to_owned();
100+
let oid = CStr::from_ptr(szOID_PKIX_KP_SERVER_AUTH as *const _)
101+
.to_string_lossy()
102+
.into_owned();
108103
if !oids.contains(&oid) {
109104
continue;
110105
}

0 commit comments

Comments
 (0)