aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/stack.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2018-05-20 11:27:45 -0700
committerSteven Fackler <[email protected]>2018-05-20 12:33:02 -0700
commita6fcef01c0aa71359f583342c813b8db5835178d (patch)
tree33c47b59618e5fe286904462f2d4a540804dd7ef /openssl/src/stack.rs
parentExpose X509_VERIFY_PARAM on libressl (diff)
downloadrust-openssl-a6fcef01c0aa71359f583342c813b8db5835178d.tar.xz
rust-openssl-a6fcef01c0aa71359f583342c813b8db5835178d.zip
Overhaul openssl cfgs
Also expose hostname verification on libressl
Diffstat (limited to 'openssl/src/stack.rs')
-rw-r--r--openssl/src/stack.rs33
1 files changed, 19 insertions, 14 deletions
diff --git a/openssl/src/stack.rs b/openssl/src/stack.rs
index d8589352..4d5c0a13 100644
--- a/openssl/src/stack.rs
+++ b/openssl/src/stack.rs
@@ -1,23 +1,30 @@
-use foreign_types::{ForeignTypeRef, ForeignType, Opaque};
+use ffi;
+use foreign_types::{ForeignType, ForeignTypeRef, Opaque};
use libc::c_int;
use std::borrow::Borrow;
use std::convert::AsRef;
use std::iter;
use std::marker::PhantomData;
use std::mem;
-use ffi;
-use {cvt, cvt_p};
use error::ErrorStack;
use std::ops::{Deref, DerefMut, Index, IndexMut};
+use {cvt, cvt_p};
-#[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_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,
- OPENSSL_sk_new_null, OPENSSL_sk_push};
+cfg_if! {
+ if #[cfg(ossl110)] {
+ use ffi::{
+ OPENSSL_sk_pop, OPENSSL_sk_free, OPENSSL_sk_num, OPENSSL_sk_value, OPENSSL_STACK,
+ OPENSSL_sk_new_null, OPENSSL_sk_push,
+ };
+ } else {
+ 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_new_null as OPENSSL_sk_new_null, sk_push as OPENSSL_sk_push,
+ };
+ }
+}
/// Trait implemented by types which can be placed in a stack.
///
@@ -87,7 +94,7 @@ impl<T: Stackable> ForeignType for Stack<T> {
assert!(
!ptr.is_null(),
"Must not instantiate a Stack from a null-ptr - use Stack::new() in \
- that case"
+ that case"
);
Stack(ptr)
}
@@ -218,9 +225,7 @@ impl<T: Stackable> StackRef<T> {
/// Pushes a value onto the top of the stack.
pub fn push(&mut self, data: T) -> Result<(), ErrorStack> {
unsafe {
- cvt(
- OPENSSL_sk_push(self.as_stack(), data.as_ptr() as *mut _),
- )?;
+ cvt(OPENSSL_sk_push(self.as_stack(), data.as_ptr() as *mut _))?;
mem::forget(data);
Ok(())
}