diff options
| author | Steven Fackler <[email protected]> | 2016-10-16 15:54:09 -0700 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2016-10-16 15:54:09 -0700 |
| commit | 8f89f0bfa98ac69582f22244dae0f5cc923046e1 (patch) | |
| tree | d63fe6016909990fba62e64825fd5cc2ea0e2f54 /openssl/src/lib.rs | |
| parent | Merge pull request #475 from sfackler/no-enums (diff) | |
| download | rust-openssl-8f89f0bfa98ac69582f22244dae0f5cc923046e1.tar.xz rust-openssl-8f89f0bfa98ac69582f22244dae0f5cc923046e1.zip | |
Start on error + BN refactor
Diffstat (limited to 'openssl/src/lib.rs')
| -rw-r--r-- | openssl/src/lib.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/openssl/src/lib.rs b/openssl/src/lib.rs index 62968742..39c9fffe 100644 --- a/openssl/src/lib.rs +++ b/openssl/src/lib.rs @@ -16,6 +16,10 @@ extern crate tempdir; #[doc(inline)] pub use ffi::init; +use libc::c_int; + +use error::ErrorStack; + mod macros; pub mod asn1; @@ -28,3 +32,27 @@ pub mod nid; pub mod ssl; pub mod version; pub mod x509; + +pub fn cvt_p<T>(r: *mut T) -> Result<*mut T, ErrorStack> { + if r.is_null() { + Err(ErrorStack::get()) + } else { + Ok(r) + } +} + +pub fn cvt(r: c_int) -> Result<c_int, ErrorStack> { + if r <= 0 { + Err(ErrorStack::get()) + } else { + Ok(r) + } +} + +pub fn cvt_n(r: c_int) -> Result<c_int, ErrorStack> { + if r < 0 { + Err(ErrorStack::get()) + } else { + Ok(r) + } +} |