Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (26 sloc) 629 Bytes
{- -*- haskell -*- -}
-- #hide
module OpenSSL.Utils
( failIfNull
, failIf
, raiseOpenSSLError
, unsafeCoercePtr
)
where
import Foreign
import GHC.Base
import OpenSSL.ERR
failIfNull :: Ptr a -> IO (Ptr a)
failIfNull ptr
= if ptr == nullPtr then
raiseOpenSSLError
else
return ptr
failIf :: (a -> Bool) -> a -> IO a
failIf f a
| f a = raiseOpenSSLError
| otherwise = return a
raiseOpenSSLError :: IO a
raiseOpenSSLError = getError >>= errorString >>= fail
unsafeCoercePtr :: Ptr a -> Ptr b
unsafeCoercePtr = unsafeCoerce#
Jump to Line
Something went wrong with that request. Please try again.