diff options
Diffstat (limited to 'src/BTLS/BoringSSL')
-rw-r--r-- | src/BTLS/BoringSSL/Obj.chs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/BTLS/BoringSSL/Obj.chs b/src/BTLS/BoringSSL/Obj.chs index a337ad5..7e132e7 100644 --- a/src/BTLS/BoringSSL/Obj.chs +++ b/src/BTLS/BoringSSL/Obj.chs @@ -16,8 +16,15 @@ module BTLS.BoringSSL.Obj ( objNID2SN ) where -import Foreign.C (CString) +import Foreign (nullPtr) +import Foreign.C (CString, peekCString) #include <openssl/obj.h> -{#fun pure OBJ_nid2sn as objNID2SN {`Int'} -> `CString'#} +{#fun pure OBJ_nid2sn as objNID2SN + {`Int'} -> `Maybe String' peekCStringOrNull*#} + +peekCStringOrNull :: CString -> IO (Maybe String) +peekCStringOrNull ptr + | ptr == nullPtr = return Nothing + | otherwise = Just <$> peekCString ptr |