summaryrefslogtreecommitdiff
path: root/libssh2-sys
diff options
context:
space:
mode:
Diffstat (limited to 'libssh2-sys')
-rw-r--r--libssh2-sys/lib.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/libssh2-sys/lib.rs b/libssh2-sys/lib.rs
index 660587a..2432b55 100644
--- a/libssh2-sys/lib.rs
+++ b/libssh2-sys/lib.rs
@@ -533,4 +533,25 @@ fn smoke() {
unsafe { libssh2_init(0) };
}
+#[doc(hidden)]
pub fn issue_14344_workaround() {}
+
+pub fn init() {
+ use std::sync::{Once, ONCE_INIT};
+
+ static INIT: Once = ONCE_INIT;
+ INIT.call_once(|| unsafe {
+ platform_init();
+ assert_eq!(libssh2_init(LIBSSH2_INIT_NO_CRYPTO), 0);
+ assert_eq!(libc::atexit(shutdown), 0);
+ });
+ extern fn shutdown() { unsafe { libssh2_exit(); } }
+
+ #[cfg(unix)]
+ fn platform_init() {
+ openssl_sys::init();
+ }
+
+ #[cfg(windows)]
+ fn platform_init() {}
+}