aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2013-11-11 20:40:33 -0800
committerSteven Fackler <[email protected]>2013-11-11 20:40:33 -0800
commitbe9948ba07eea965758f4f9e0cd629bbb3d59147 (patch)
treec257842b77205356fef45203ddc55da12415acc5
parentRun tests single threaded (diff)
downloadrust-openssl-be9948ba07eea965758f4f9e0cd629bbb3d59147.tar.xz
rust-openssl-be9948ba07eea965758f4f9e0cd629bbb3d59147.zip
Remove externfn!
-rw-r--r--ffi.rs82
-rw-r--r--lib.rs6
2 files changed, 42 insertions, 46 deletions
diff --git a/ffi.rs b/ffi.rs
index 7711032c..92de2442 100644
--- a/ffi.rs
+++ b/ffi.rs
@@ -37,50 +37,50 @@ pub static SSL_VERIFY_NONE: c_int = 0;
pub static SSL_VERIFY_PEER: c_int = 1;
#[link_args = "-lssl -lcrypto"]
-extern "C" { }
+extern "C" {
+ pub fn ERR_get_error() -> c_ulong;
-externfn!(fn ERR_get_error() -> c_ulong)
+ pub fn SSL_library_init() -> c_int;
-externfn!(fn SSL_library_init() -> c_int)
+ pub fn SSLv3_method() -> *SSL_METHOD;
+ pub fn TLSv1_method() -> *SSL_METHOD;
+ pub fn SSLv23_method() -> *SSL_METHOD;
-externfn!(fn SSLv3_method() -> *SSL_METHOD)
-externfn!(fn TLSv1_method() -> *SSL_METHOD)
-externfn!(fn SSLv23_method() -> *SSL_METHOD)
+ pub fn SSL_CTX_new(method: *SSL_METHOD) -> *SSL_CTX;
+ pub fn SSL_CTX_free(ctx: *SSL_CTX);
+ pub fn SSL_CTX_set_verify(ctx: *SSL_CTX, mode: c_int,
+ verify_callback: Option<extern "C" fn(c_int, *X509_STORE_CTX) -> c_int>);
+ pub fn SSL_CTX_load_verify_locations(ctx: *SSL_CTX, CAfile: *c_char,
+ CApath: *c_char) -> c_int;
+ pub fn SSL_CTX_get_ex_new_index(argl: c_long, argp: *c_void,
+ new_func: Option<CRYPTO_EX_new>,
+ dup_func: Option<CRYPTO_EX_dup>,
+ free_func: Option<CRYPTO_EX_free>)
+ -> c_int;
+ pub fn SSL_CTX_set_ex_data(ctx: *SSL_CTX, idx: c_int, data: *c_void)
+ -> c_int;
+ pub fn SSL_CTX_get_ex_data(ctx: *SSL_CTX, idx: c_int) -> *c_void;
-externfn!(fn SSL_CTX_new(method: *SSL_METHOD) -> *SSL_CTX)
-externfn!(fn SSL_CTX_free(ctx: *SSL_CTX))
-externfn!(fn SSL_CTX_set_verify(ctx: *SSL_CTX, mode: c_int,
- verify_callback: Option<extern "C" fn(c_int, *X509_STORE_CTX) -> c_int>))
-externfn!(fn SSL_CTX_load_verify_locations(ctx: *SSL_CTX, CAfile: *c_char,
- CApath: *c_char) -> c_int)
-externfn!(fn SSL_CTX_get_ex_new_index(argl: c_long, argp: *c_void,
- new_func: Option<CRYPTO_EX_new>,
- dup_func: Option<CRYPTO_EX_dup>,
- free_func: Option<CRYPTO_EX_free>)
- -> c_int)
-externfn!(fn SSL_CTX_set_ex_data(ctx: *SSL_CTX, idx: c_int, data: *c_void)
- -> c_int)
-externfn!(fn SSL_CTX_get_ex_data(ctx: *SSL_CTX, idx: c_int) -> *c_void)
+ pub fn X509_STORE_CTX_get_ex_data(ctx: *X509_STORE_CTX, idx: c_int)
+ -> *c_void;
-externfn!(fn X509_STORE_CTX_get_ex_data(ctx: *X509_STORE_CTX, idx: c_int)
- -> *c_void)
+ pub fn SSL_new(ctx: *SSL_CTX) -> *SSL;
+ pub fn SSL_free(ssl: *SSL);
+ pub fn SSL_set_bio(ssl: *SSL, rbio: *BIO, wbio: *BIO);
+ pub fn SSL_get_rbio(ssl: *SSL) -> *BIO;
+ pub fn SSL_get_wbio(ssl: *SSL) -> *BIO;
+ pub fn SSL_set_connect_state(ssl: *SSL);
+ pub fn SSL_connect(ssl: *SSL) -> c_int;
+ pub fn SSL_get_error(ssl: *SSL, ret: c_int) -> c_int;
+ pub fn SSL_read(ssl: *SSL, buf: *c_void, num: c_int) -> c_int;
+ pub fn SSL_write(ssl: *SSL, buf: *c_void, num: c_int) -> c_int;
+ pub fn SSL_shutdown(ssl: *SSL) -> c_int;
+ pub fn SSL_get_ex_data_X509_STORE_CTX_idx() -> c_int;
+ pub fn SSL_get_SSL_CTX(ssl: *SSL) -> *SSL_CTX;
-externfn!(fn SSL_new(ctx: *SSL_CTX) -> *SSL)
-externfn!(fn SSL_free(ssl: *SSL))
-externfn!(fn SSL_set_bio(ssl: *SSL, rbio: *BIO, wbio: *BIO))
-externfn!(fn SSL_get_rbio(ssl: *SSL) -> *BIO)
-externfn!(fn SSL_get_wbio(ssl: *SSL) -> *BIO)
-externfn!(fn SSL_set_connect_state(ssl: *SSL))
-externfn!(fn SSL_connect(ssl: *SSL) -> c_int)
-externfn!(fn SSL_get_error(ssl: *SSL, ret: c_int) -> c_int)
-externfn!(fn SSL_read(ssl: *SSL, buf: *c_void, num: c_int) -> c_int)
-externfn!(fn SSL_write(ssl: *SSL, buf: *c_void, num: c_int) -> c_int)
-externfn!(fn SSL_shutdown(ssl: *SSL) -> c_int)
-externfn!(fn SSL_get_ex_data_X509_STORE_CTX_idx() -> c_int)
-externfn!(fn SSL_get_SSL_CTX(ssl: *SSL) -> *SSL_CTX)
-
-externfn!(fn BIO_s_mem() -> *BIO_METHOD)
-externfn!(fn BIO_new(type_: *BIO_METHOD) -> *BIO)
-externfn!(fn BIO_free_all(a: *BIO))
-externfn!(fn BIO_read(b: *BIO, buf: *c_void, len: c_int) -> c_int)
-externfn!(fn BIO_write(b: *BIO, buf: *c_void, len: c_int) -> c_int)
+ pub fn BIO_s_mem() -> *BIO_METHOD;
+ pub fn BIO_new(type_: *BIO_METHOD) -> *BIO;
+ pub fn BIO_free_all(a: *BIO);
+ pub fn BIO_read(b: *BIO, buf: *c_void, len: c_int) -> c_int;
+ pub fn BIO_write(b: *BIO, buf: *c_void, len: c_int) -> c_int;
+}
diff --git a/lib.rs b/lib.rs
index cc1d7ef6..f69fcf0e 100644
--- a/lib.rs
+++ b/lib.rs
@@ -25,11 +25,7 @@ static mut FINISHED_INIT: AtomicBool = INIT_ATOMIC_BOOL;
static mut VERIFY_IDX: AtomicInt = INIT_ATOMIC_INT;
-/// Initializes the library.
-///
-/// This does not need to be manually called. It will automatically be called
-/// when needed. Can be safely called multiple times on different threads.
-pub fn init() {
+fn init() {
unsafe {
if STARTED_INIT.swap(true, Acquire) {
while !FINISHED_INIT.load(Release) {