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)",
|
"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)",
|
"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)",
|
"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)",
|
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -30,7 +30,6 @@ app_dirs = "1.2.1"
|
|||||||
futures = "0.1"
|
futures = "0.1"
|
||||||
futures-cpupool = "0.1"
|
futures-cpupool = "0.1"
|
||||||
fdlimit = "0.1"
|
fdlimit = "0.1"
|
||||||
ws2_32-sys = "0.2"
|
|
||||||
ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" }
|
ctrlc = { git = "https://github.com/paritytech/rust-ctrlc.git" }
|
||||||
jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" }
|
jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" }
|
||||||
ethcore = { path = "ethcore" }
|
ethcore = { path = "ethcore" }
|
||||||
@ -86,7 +85,7 @@ tempdir = "0.3"
|
|||||||
fake-fetch = { path = "util/fake-fetch" }
|
fake-fetch = { path = "util/fake-fetch" }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
winapi = "0.2"
|
winapi = { version = "0.3.4", features = ["winsock2", "winuser", "shellapi"] }
|
||||||
|
|
||||||
[target.'cfg(not(windows))'.dependencies]
|
[target.'cfg(not(windows))'.dependencies]
|
||||||
daemonize = { git = "https://github.com/paritytech/daemonize" }
|
daemonize = { git = "https://github.com/paritytech/daemonize" }
|
||||||
|
@ -95,7 +95,6 @@ extern crate parity_dapps;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate pretty_assertions;
|
extern crate pretty_assertions;
|
||||||
|
|
||||||
#[cfg(windows)] extern crate ws2_32;
|
|
||||||
#[cfg(windows)] extern crate winapi;
|
#[cfg(windows)] extern crate winapi;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[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
|
// 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.
|
// initialize it. There's at least 2 now.
|
||||||
for _ in 0.. 10 {
|
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.
|
// When restarting in the same process this reinits windows sockets.
|
||||||
unsafe {
|
unsafe {
|
||||||
const WS_VERSION: u16 = 0x202;
|
const WS_VERSION: u16 = 0x202;
|
||||||
let mut wsdata: ::winapi::winsock2::WSADATA = ::std::mem::zeroed();
|
let mut wsdata: ::winapi::um::winsock2::WSADATA = ::std::mem::zeroed();
|
||||||
::ws2_32::WSAStartup(WS_VERSION, &mut wsdata);
|
::winapi::um::winsock2::WSAStartup(WS_VERSION, &mut wsdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,34 +16,19 @@
|
|||||||
|
|
||||||
//! Cross-platform open url in default browser
|
//! 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)]
|
#[cfg(windows)]
|
||||||
pub fn open(url: &str) {
|
pub fn open(url: &str) {
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
use winapi::um::shellapi::ShellExecuteA;
|
||||||
|
use winapi::um::winuser::SW_SHOWNORMAL as Normal;
|
||||||
|
|
||||||
unsafe {
|
ShellExecuteA(ptr::null_mut(),
|
||||||
shell::ShellExecuteA(ptr::null_mut(),
|
|
||||||
CString::new("open").unwrap().as_ptr(),
|
CString::new("open").unwrap().as_ptr(),
|
||||||
CString::new(url.to_owned().replace("\n", "%0A")).unwrap().as_ptr(),
|
CString::new(url.to_owned().replace("\n", "%0A")).unwrap().as_ptr(),
|
||||||
ptr::null(),
|
ptr::null(),
|
||||||
ptr::null(),
|
ptr::null(),
|
||||||
shell::Normal);
|
Normal);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os="macos", target_os="freebsd"))]
|
#[cfg(any(target_os="macos", target_os="freebsd"))]
|
||||||
|
Loading…
Reference in New Issue
Block a user