diff options
| author | Steven Fackler <[email protected]> | 2014-10-12 02:20:51 -0400 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2014-10-12 02:20:51 -0400 |
| commit | 12b7427e0d01cb92810db2f0f51972b34947128e (patch) | |
| tree | 4ea8770a90ca801e48e65032f756dccef069b5c5 /src/ffi.rs | |
| parent | Merge pull request #62 from vhbit/feature-matrix (diff) | |
| parent | Refactor init and error handling code (diff) | |
| download | rust-openssl-12b7427e0d01cb92810db2f0f51972b34947128e.tar.xz rust-openssl-12b7427e0d01cb92810db2f0f51972b34947128e.zip | |
Merge pull request #79 from jroesch/init-cleanup
Refactor code around initialization and error strings.
Diffstat (limited to 'src/ffi.rs')
| -rwxr-xr-x | src/ffi.rs | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -2,6 +2,7 @@ #![allow(dead_code)] use libc::{c_void, c_int, c_char, c_ulong, c_long, c_uint, c_uchar, size_t}; use std::ptr; +use sync::one::{Once, ONCE_INIT}; pub use bn::BIGNUM; @@ -181,6 +182,17 @@ extern {} #[link(name="wsock32")] extern { } +pub fn init() { + static mut INIT: Once = ONCE_INIT; + + unsafe { + INIT.doit(|| { + SSL_library_init(); + SSL_load_error_strings() + }) + } +} + // Functions converted from macros pub unsafe fn BIO_eof(b: *mut BIO) -> bool { BIO_ctrl(b, BIO_CTRL_EOF, 0, ptr::null_mut()) == 1 |