Loading openssl-sys/src/ossl10x.rs +2 −0 Original line number Diff line number Diff line Loading @@ -602,10 +602,12 @@ extern { pub fn EVP_MD_CTX_create() -> *mut EVP_MD_CTX; pub fn EVP_MD_CTX_destroy(ctx: *mut EVP_MD_CTX); pub fn sk_new_null() -> *mut _STACK; pub fn sk_num(st: *const _STACK) -> c_int; pub fn sk_value(st: *const _STACK, n: c_int) -> *mut c_void; pub fn sk_free(st: *mut _STACK); pub fn sk_pop_free(st: *mut _STACK, free: Option<unsafe extern "C" fn (*mut c_void)>); pub fn sk_push(st: *mut _STACK, data: *mut c_void) -> c_int; pub fn sk_pop(st: *mut _STACK) -> *mut c_void; pub fn SSLeay() -> c_ulong; Loading openssl-sys/src/ossl110.rs +2 −0 Original line number Diff line number Diff line Loading @@ -151,7 +151,9 @@ extern { pub fn OpenSSL_version_num() -> c_ulong; pub fn OpenSSL_version(key: c_int) -> *const c_char; pub fn OPENSSL_sk_new_null() -> *mut ::OPENSSL_STACK; pub fn OPENSSL_sk_free(st: *mut ::OPENSSL_STACK); pub fn OPENSSL_sk_pop_free(st: *mut ::OPENSSL_STACK, free: Option<unsafe extern "C" fn (*mut c_void)>); pub fn OPENSSL_sk_push(st: *mut ::OPENSSL_STACK, data: *const c_void) -> c_int; pub fn OPENSSL_sk_pop(st: *mut ::OPENSSL_STACK) -> *mut c_void; } openssl/src/lib.rs +4 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,10 @@ macro_rules! type_ { unsafe fn from_ptr(ptr: *mut $c) -> $n { $n(ptr) } fn as_ptr(&self) -> *mut $c { self.0 } } impl Drop for $n { Loading openssl/src/ssl/mod.rs +4 −0 Original line number Diff line number Diff line Loading @@ -822,6 +822,10 @@ impl OpenSslType for SslCipher { unsafe fn from_ptr(ptr: *mut ffi::SSL_CIPHER) -> SslCipher { SslCipher(ptr) } fn as_ptr(&self) -> *mut ffi::SSL_CIPHER { self.0 } } impl Deref for SslCipher { Loading openssl/src/stack.rs +24 −5 Original line number Diff line number Diff line Loading @@ -6,14 +6,18 @@ use std::marker::PhantomData; use libc::c_int; use std::mem; use {cvt, cvt_p}; use error::ErrorStack; use types::{OpenSslType, OpenSslTypeRef}; use util::Opaque; #[cfg(ossl10x)] use ffi::{sk_pop as OPENSSL_sk_pop, sk_free as OPENSSL_sk_free, sk_num as OPENSSL_sk_num, sk_value as OPENSSL_sk_value, _STACK as OPENSSL_STACK}; sk_value as OPENSSL_sk_value, _STACK as OPENSSL_STACK, sk_new_null as OPENSSL_sk_new_null, sk_push as OPENSSL_sk_push}; #[cfg(ossl110)] use ffi::{OPENSSL_sk_pop, OPENSSL_sk_free, OPENSSL_sk_num, OPENSSL_sk_value, OPENSSL_STACK}; use ffi::{OPENSSL_sk_pop, OPENSSL_sk_free, OPENSSL_sk_num, OPENSSL_sk_value, OPENSSL_STACK, OPENSSL_sk_new_null, OPENSSL_sk_push}; /// Trait implemented by types which can be placed in a stack. /// Loading @@ -31,9 +35,11 @@ pub trait Stackable: OpenSslType { pub struct Stack<T: Stackable>(*mut T::StackType); impl<T: Stackable> Stack<T> { /// Return a new Stack<T>, taking ownership of the handle pub unsafe fn from_ptr(stack: *mut T::StackType) -> Stack<T> { Stack(stack) pub fn new() -> Result<Stack<T>, ErrorStack> { unsafe { let ptr = try!(cvt_p(OPENSSL_sk_new_null())); Ok(Stack(ptr as *mut _)) } } } Loading Loading @@ -79,6 +85,10 @@ impl<T: Stackable> OpenSslType for Stack<T> { unsafe fn from_ptr(ptr: *mut T::StackType) -> Stack<T> { Stack(ptr) } fn as_ptr(&self) -> *mut T::StackType { self.0 } } impl<T: Stackable> Deref for Stack<T> { Loading Loading @@ -198,6 +208,15 @@ impl<T: Stackable> StackRef<T> { } } /// Pushes a value onto the top of the stack. pub fn push(&mut self, data: T) -> Result<(), ErrorStack> { unsafe { try!(cvt(OPENSSL_sk_push(self.as_stack(), data.as_ptr() as *mut _))); mem::forget(data); Ok(()) } } /// Removes the last element from the stack and returns it. pub fn pop(&mut self) -> Option<T> { unsafe { Loading Loading
openssl-sys/src/ossl10x.rs +2 −0 Original line number Diff line number Diff line Loading @@ -602,10 +602,12 @@ extern { pub fn EVP_MD_CTX_create() -> *mut EVP_MD_CTX; pub fn EVP_MD_CTX_destroy(ctx: *mut EVP_MD_CTX); pub fn sk_new_null() -> *mut _STACK; pub fn sk_num(st: *const _STACK) -> c_int; pub fn sk_value(st: *const _STACK, n: c_int) -> *mut c_void; pub fn sk_free(st: *mut _STACK); pub fn sk_pop_free(st: *mut _STACK, free: Option<unsafe extern "C" fn (*mut c_void)>); pub fn sk_push(st: *mut _STACK, data: *mut c_void) -> c_int; pub fn sk_pop(st: *mut _STACK) -> *mut c_void; pub fn SSLeay() -> c_ulong; Loading
openssl-sys/src/ossl110.rs +2 −0 Original line number Diff line number Diff line Loading @@ -151,7 +151,9 @@ extern { pub fn OpenSSL_version_num() -> c_ulong; pub fn OpenSSL_version(key: c_int) -> *const c_char; pub fn OPENSSL_sk_new_null() -> *mut ::OPENSSL_STACK; pub fn OPENSSL_sk_free(st: *mut ::OPENSSL_STACK); pub fn OPENSSL_sk_pop_free(st: *mut ::OPENSSL_STACK, free: Option<unsafe extern "C" fn (*mut c_void)>); pub fn OPENSSL_sk_push(st: *mut ::OPENSSL_STACK, data: *const c_void) -> c_int; pub fn OPENSSL_sk_pop(st: *mut ::OPENSSL_STACK) -> *mut c_void; }
openssl/src/lib.rs +4 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,10 @@ macro_rules! type_ { unsafe fn from_ptr(ptr: *mut $c) -> $n { $n(ptr) } fn as_ptr(&self) -> *mut $c { self.0 } } impl Drop for $n { Loading
openssl/src/ssl/mod.rs +4 −0 Original line number Diff line number Diff line Loading @@ -822,6 +822,10 @@ impl OpenSslType for SslCipher { unsafe fn from_ptr(ptr: *mut ffi::SSL_CIPHER) -> SslCipher { SslCipher(ptr) } fn as_ptr(&self) -> *mut ffi::SSL_CIPHER { self.0 } } impl Deref for SslCipher { Loading
openssl/src/stack.rs +24 −5 Original line number Diff line number Diff line Loading @@ -6,14 +6,18 @@ use std::marker::PhantomData; use libc::c_int; use std::mem; use {cvt, cvt_p}; use error::ErrorStack; use types::{OpenSslType, OpenSslTypeRef}; use util::Opaque; #[cfg(ossl10x)] use ffi::{sk_pop as OPENSSL_sk_pop, sk_free as OPENSSL_sk_free, sk_num as OPENSSL_sk_num, sk_value as OPENSSL_sk_value, _STACK as OPENSSL_STACK}; sk_value as OPENSSL_sk_value, _STACK as OPENSSL_STACK, sk_new_null as OPENSSL_sk_new_null, sk_push as OPENSSL_sk_push}; #[cfg(ossl110)] use ffi::{OPENSSL_sk_pop, OPENSSL_sk_free, OPENSSL_sk_num, OPENSSL_sk_value, OPENSSL_STACK}; use ffi::{OPENSSL_sk_pop, OPENSSL_sk_free, OPENSSL_sk_num, OPENSSL_sk_value, OPENSSL_STACK, OPENSSL_sk_new_null, OPENSSL_sk_push}; /// Trait implemented by types which can be placed in a stack. /// Loading @@ -31,9 +35,11 @@ pub trait Stackable: OpenSslType { pub struct Stack<T: Stackable>(*mut T::StackType); impl<T: Stackable> Stack<T> { /// Return a new Stack<T>, taking ownership of the handle pub unsafe fn from_ptr(stack: *mut T::StackType) -> Stack<T> { Stack(stack) pub fn new() -> Result<Stack<T>, ErrorStack> { unsafe { let ptr = try!(cvt_p(OPENSSL_sk_new_null())); Ok(Stack(ptr as *mut _)) } } } Loading Loading @@ -79,6 +85,10 @@ impl<T: Stackable> OpenSslType for Stack<T> { unsafe fn from_ptr(ptr: *mut T::StackType) -> Stack<T> { Stack(ptr) } fn as_ptr(&self) -> *mut T::StackType { self.0 } } impl<T: Stackable> Deref for Stack<T> { Loading Loading @@ -198,6 +208,15 @@ impl<T: Stackable> StackRef<T> { } } /// Pushes a value onto the top of the stack. pub fn push(&mut self, data: T) -> Result<(), ErrorStack> { unsafe { try!(cvt(OPENSSL_sk_push(self.as_stack(), data.as_ptr() as *mut _))); mem::forget(data); Ok(()) } } /// Removes the last element from the stack and returns it. pub fn pop(&mut self) -> Option<T> { unsafe { Loading