diff options
Diffstat (limited to 'Codec/Encryption/OpenPGP/ASCIIArmor')
-rw-r--r-- | Codec/Encryption/OpenPGP/ASCIIArmor/Multipart.hs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Codec/Encryption/OpenPGP/ASCIIArmor/Multipart.hs b/Codec/Encryption/OpenPGP/ASCIIArmor/Multipart.hs new file mode 100644 index 0000000..8719c7c --- /dev/null +++ b/Codec/Encryption/OpenPGP/ASCIIArmor/Multipart.hs | |||
@@ -0,0 +1,24 @@ | |||
1 | -- ASCIIArmor/Multipart.hs: OpenPGP (RFC4880) ASCII armor implementation | ||
2 | -- Copyright Ⓒ 2012 Clint Adams | ||
3 | -- This software is released under the terms of the ISC license. | ||
4 | -- (See the LICENSE file). | ||
5 | |||
6 | module Codec.Encryption.OpenPGP.ASCIIArmor.Multipart ( | ||
7 | multipartMerge | ||
8 | ) where | ||
9 | |||
10 | import Codec.Encryption.OpenPGP.ASCIIArmor.Types | ||
11 | |||
12 | import Data.ByteString (ByteString) | ||
13 | import qualified Data.ByteString as B | ||
14 | |||
15 | multipartMerge :: [Armor] -> Armor | ||
16 | multipartMerge as = go as (Armor ArmorMessage [] B.empty) | ||
17 | where | ||
18 | go :: [Armor] -> Armor -> Armor | ||
19 | go [] state = state | ||
20 | go ((Armor at hs bs):as) state = go as (go' at hs bs state) | ||
21 | go' :: ArmorType -> [(String,String)] -> ByteString -> Armor -> Armor | ||
22 | go' (ArmorSplitMessage _ _) hs bs (Armor _ ohs obs) = Armor ArmorMessage (ohs ++ hs) (obs `B.append` bs) | ||
23 | go' (ArmorSplitMessageIndefinite _) hs bs (Armor _ ohs obs) = Armor ArmorMessage (ohs ++ hs) (obs `B.append` bs) | ||
24 | go' _ _ _ state = state | ||