diff options
author | Don Stewart <dons@galois.com> | 2008-01-04 16:23:04 -0800 |
---|---|---|
committer | Don Stewart <dons@galois.com> | 2008-01-04 16:23:04 -0800 |
commit | 35f0f40cfabeb49b468c6ae3c68fedded145a022 (patch) | |
tree | 0d4fa2b367a987c86ef5c14a06b7b91aee2dc6a7 /Codec/MIME/Utils.hs | |
parent | 62e3911810c18e77a13794cb5899a9ebc6b0bbb3 (diff) |
Move MIME stuff into proper Codec.* namespace.
Add copyrights where missing.
Diffstat (limited to 'Codec/MIME/Utils.hs')
-rw-r--r-- | Codec/MIME/Utils.hs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Codec/MIME/Utils.hs b/Codec/MIME/Utils.hs new file mode 100644 index 0000000..a5db2d9 --- /dev/null +++ b/Codec/MIME/Utils.hs @@ -0,0 +1,30 @@ +{- | + Module : MIME.Utils + Copyright : (c) 2007 + + Maintainer : tse-dev-team@galois.com + Stability : unstable + Portability : GHC + + Extracting content from MIME values and types. +-} +module MIME.Utils + ( findMultipartNamed -- :: String -> MIMEValue -> Maybe MIMEValue + ) where + +import MIME.Type +import Data.List ( find ) +import Control.Monad ( msum ) + +-- | Given a parameter name, locate it within a MIME value, +-- returning the corresponding (sub) MIME value. +findMultipartNamed :: String -> MIMEValue -> Maybe MIMEValue +findMultipartNamed nm mv = + case mime_val_content mv of + Multi ms -> msum (map (findMultipartNamed nm) ms) + Single {} -> do cd <- mime_val_disp mv + find (withDispName nm) (dispParams cd) + return mv + where withDispName a (Name b) = a == b + withDispName _ _ = False + |