parity uses winapi 0.3.4 (#8366)
* parity uses winapi 0.3.4 * remove redundant unsafe
This commit is contained in:
parent
0a9114203b
commit
1356d6d8d5
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -1991,8 +1991,7 @@ dependencies = [
|
||||
"term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -30,7 +30,6 @@ app_dirs = "1.2.1"
|
||||
futures = "0.1"
|
||||
futures-cpupool = "0.1"
|
||||
fdlimit = "0.1"
|
||||
ws2_32-sys = "0.2"
|
||||
ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" }
|
||||
jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" }
|
||||
ethcore = { path = "ethcore" }
|
||||
@ -86,7 +85,7 @@ tempdir = "0.3"
|
||||
fake-fetch = { path = "util/fake-fetch" }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = "0.2"
|
||||
winapi = { version = "0.3.4", features = ["winsock2", "winuser", "shellapi"] }
|
||||
|
||||
[target.'cfg(not(windows))'.dependencies]
|
||||
daemonize = { git = "https://github.com/paritytech/daemonize" }
|
||||
|
@ -95,7 +95,6 @@ extern crate parity_dapps;
|
||||
#[macro_use]
|
||||
extern crate pretty_assertions;
|
||||
|
||||
#[cfg(windows)] extern crate ws2_32;
|
||||
#[cfg(windows)] extern crate winapi;
|
||||
|
||||
#[cfg(test)]
|
||||
@ -238,7 +237,7 @@ fn global_cleanup() {
|
||||
// The loop is required because of internal refernce counter for winsock dll. We don't know how many crates we use do
|
||||
// initialize it. There's at least 2 now.
|
||||
for _ in 0.. 10 {
|
||||
unsafe { ::ws2_32::WSACleanup(); }
|
||||
unsafe { ::winapi::um::winsock2::WSACleanup(); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,8 +249,8 @@ fn global_init() {
|
||||
// When restarting in the same process this reinits windows sockets.
|
||||
unsafe {
|
||||
const WS_VERSION: u16 = 0x202;
|
||||
let mut wsdata: ::winapi::winsock2::WSADATA = ::std::mem::zeroed();
|
||||
::ws2_32::WSAStartup(WS_VERSION, &mut wsdata);
|
||||
let mut wsdata: ::winapi::um::winsock2::WSADATA = ::std::mem::zeroed();
|
||||
::winapi::um::winsock2::WSAStartup(WS_VERSION, &mut wsdata);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,34 +16,19 @@
|
||||
|
||||
//! Cross-platform open url in default browser
|
||||
|
||||
#[cfg(windows)]
|
||||
mod shell {
|
||||
extern crate winapi;
|
||||
|
||||
use self::winapi::*;
|
||||
extern "system" {
|
||||
pub fn ShellExecuteA(
|
||||
hwnd: HWND, lpOperation: LPCSTR, lpFile: LPCSTR, lpParameters: LPCSTR, lpDirectory: LPCSTR,
|
||||
nShowCmd: c_int
|
||||
) -> HINSTANCE;
|
||||
}
|
||||
|
||||
pub use self::winapi::SW_SHOWNORMAL as Normal;
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
pub fn open(url: &str) {
|
||||
use std::ffi::CString;
|
||||
use std::ptr;
|
||||
use winapi::um::shellapi::ShellExecuteA;
|
||||
use winapi::um::winuser::SW_SHOWNORMAL as Normal;
|
||||
|
||||
unsafe {
|
||||
shell::ShellExecuteA(ptr::null_mut(),
|
||||
CString::new("open").unwrap().as_ptr(),
|
||||
CString::new(url.to_owned().replace("\n", "%0A")).unwrap().as_ptr(),
|
||||
ptr::null(),
|
||||
ptr::null(),
|
||||
shell::Normal);
|
||||
}
|
||||
ShellExecuteA(ptr::null_mut(),
|
||||
CString::new("open").unwrap().as_ptr(),
|
||||
CString::new(url.to_owned().replace("\n", "%0A")).unwrap().as_ptr(),
|
||||
ptr::null(),
|
||||
ptr::null(),
|
||||
Normal);
|
||||
}
|
||||
|
||||
#[cfg(any(target_os="macos", target_os="freebsd"))]
|
||||
|
Loading…
Reference in New Issue
Block a user