summaryrefslogtreecommitdiff
path: root/lib/PEM.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PEM.hs')
-rw-r--r--lib/PEM.hs9
1 files changed, 0 insertions, 9 deletions
diff --git a/lib/PEM.hs b/lib/PEM.hs
index 003f4ff..407929b 100644
--- a/lib/PEM.hs
+++ b/lib/PEM.hs
@@ -1,5 +1,4 @@
1{-# LANGUAGE OverloadedStrings #-} 1{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE CPP #-}
3module PEM where 2module PEM where
4 3
5import Data.Monoid 4import Data.Monoid
@@ -7,12 +6,8 @@ import qualified Data.ByteString.Lazy as LW
7import qualified Data.ByteString.Lazy.Char8 as L 6import qualified Data.ByteString.Lazy.Char8 as L
8import Control.Monad 7import Control.Monad
9import Control.Applicative 8import Control.Applicative
10#if defined(VERSION_memory)
11import qualified Data.ByteString.Char8 as S8 9import qualified Data.ByteString.Char8 as S8
12import Data.ByteArray.Encoding 10import Data.ByteArray.Encoding
13#elif defined(VERSION_dataenc)
14import qualified Codec.Binary.Base64 as Base64
15#endif
16import ScanningParser 11import ScanningParser
17import FunctorToMaybe 12import FunctorToMaybe
18data PEMBlob = PEMBlob { pemType :: L.ByteString 13data PEMBlob = PEMBlob { pemType :: L.ByteString
@@ -36,11 +31,7 @@ pemParser mtyp = ScanningParser (maybe fndany fndtyp mtyp) pbdy
36 pbdy typ xs = (mblob, drop 1 rs) 31 pbdy typ xs = (mblob, drop 1 rs)
37 where 32 where
38 (ys,rs) = span (/="-----END " <> typ <> "-----") xs 33 (ys,rs) = span (/="-----END " <> typ <> "-----") xs
39#if defined(VERSION_memory)
40 mblob = PEMBlob typ <$> LW.fromStrict <$> (functorToMaybe $ convertFromBase Base64 $ L.toStrict dta) 34 mblob = PEMBlob typ <$> LW.fromStrict <$> (functorToMaybe $ convertFromBase Base64 $ L.toStrict dta)
41#elif defined(VERSION_dataenc)
42 mblob = PEMBlob typ <$> LW.pack <$> Base64.decode (L.unpack dta)
43#endif
44 dta = case ys of 35 dta = case ys of
45 [] -> "" 36 [] -> ""
46 dta_lines -> L.concat dta_lines 37 dta_lines -> L.concat dta_lines