Skip to content

Commit f28b13c

Browse files
authored
Remove winapi 0.2 dependency (#294)
This commit removes the `winapi 0.2` dependency and also deletes the `Multi::fdset` method. While technically a breaking change this was deprecated 2 years ago at this point so I'm hoping that this crate can practically get away with the breakage.
1 parent 9a71c69 commit f28b13c

File tree

4 files changed

+11
-47
lines changed

4 files changed

+11
-47
lines changed

Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@ socket2 = "0.3.7"
2424
openssl-sys = { version = "0.9.43", optional = true }
2525
openssl-probe = { version = "0.1.2", optional = true }
2626

27-
[target.'cfg(windows)'.dependencies]
28-
winapi = "0.2.7"
29-
3027
[target.'cfg(target_env = "msvc")'.dependencies]
3128
schannel = "0.1.13"
32-
kernel32-sys = "0.2.2"
29+
winapi = { version = '0.3', features = ['libloaderapi', 'wincrypt'] }
3330

3431
[dev-dependencies]
3532
mio = "0.6"

src/easy/windows.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,27 @@ use libc::c_void;
44

55
#[cfg(target_env = "msvc")]
66
mod win {
7-
use kernel32;
7+
extern crate winapi;
88
use schannel::cert_context::ValidUses;
99
use schannel::cert_store::CertStore;
1010
use std::ffi::CString;
1111
use std::mem;
1212
use std::ptr;
13-
use winapi::{self, c_int, c_long, c_uchar, c_void};
13+
use self::winapi::ctypes::*;
14+
use self::winapi::um::libloaderapi::*;
15+
use self::winapi::um::wincrypt::*;
1416

1517
fn lookup(module: &str, symbol: &str) -> Option<*const c_void> {
1618
unsafe {
1719
let symbol = CString::new(symbol).unwrap();
1820
let mut mod_buf: Vec<u16> = module.encode_utf16().collect();
1921
mod_buf.push(0);
20-
let handle = kernel32::GetModuleHandleW(mod_buf.as_mut_ptr());
21-
let n = kernel32::GetProcAddress(handle, symbol.as_ptr());
22-
if n == ptr::null() {
22+
let handle = GetModuleHandleW(mod_buf.as_mut_ptr());
23+
let n = GetProcAddress(handle, symbol.as_ptr());
24+
if n == ptr::null_mut() {
2325
None
2426
} else {
25-
Some(n)
27+
Some(n as *const c_void)
2628
}
2729
}
2830
}
@@ -103,7 +105,7 @@ mod win {
103105
match valid_uses {
104106
ValidUses::All => {}
105107
ValidUses::Oids(ref oids) => {
106-
let oid = winapi::wincrypt::szOID_PKIX_KP_SERVER_AUTH.to_owned();
108+
let oid = szOID_PKIX_KP_SERVER_AUTH.to_owned();
107109
if !oids.contains(&oid) {
108110
continue;
109111
}

src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ extern crate openssl_probe;
5959
#[cfg(need_openssl_init)]
6060
extern crate openssl_sys;
6161

62-
#[cfg(windows)]
63-
extern crate winapi;
64-
65-
#[cfg(target_env = "msvc")]
66-
extern crate kernel32;
6762
#[cfg(target_env = "msvc")]
6863
extern crate schannel;
6964

src/multi.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ use curl_sys;
88
use libc::{c_char, c_int, c_long, c_short, c_void};
99

1010
#[cfg(unix)]
11-
use libc::{fd_set, pollfd, POLLIN, POLLOUT, POLLPRI};
12-
#[cfg(windows)]
13-
use winapi::winsock2::fd_set;
11+
use libc::{pollfd, POLLIN, POLLOUT, POLLPRI};
1412

1513
use easy::{Easy, Easy2};
1614
use panic;
@@ -667,34 +665,6 @@ impl Multi {
667665
}
668666
}
669667

670-
#[doc(hidden)]
671-
#[deprecated(note = "renamed to fdset2")]
672-
pub fn fdset(
673-
&self,
674-
read: Option<&mut fd_set>,
675-
write: Option<&mut fd_set>,
676-
except: Option<&mut fd_set>,
677-
) -> Result<Option<i32>, MultiError> {
678-
unsafe {
679-
let mut ret = 0;
680-
let read = read.map(|r| r as *mut _).unwrap_or(0 as *mut _);
681-
let write = write.map(|r| r as *mut _).unwrap_or(0 as *mut _);
682-
let except = except.map(|r| r as *mut _).unwrap_or(0 as *mut _);
683-
cvt(curl_sys::curl_multi_fdset(
684-
self.raw,
685-
read as *mut _,
686-
write as *mut _,
687-
except as *mut _,
688-
&mut ret,
689-
))?;
690-
if ret == -1 {
691-
Ok(None)
692-
} else {
693-
Ok(Some(ret))
694-
}
695-
}
696-
}
697-
698668
/// Attempt to close the multi handle and clean up all associated resources.
699669
///
700670
/// Cleans up and removes a whole multi stack. It does not free or touch any

0 commit comments

Comments
 (0)