hr' = take 72 $ (take 25 hr'') ++ " " ++ x ++ " " ++ hr''
hr'' = repeat '-'
+-- | format headers for printing
formatheaders :: ((T.Text, FieldValue) -> [a]) -> FieldTable -> [a]
formatheaders f (FieldTable ll) = concat $ map f $ M.toList ll
+-- | format headers for setting environment variables
formatheaders' ::
((Int, (T.Text, FieldValue)) -> [(String, String)]) -> FieldTable -> [(String,String)]
formatheaders' f (FieldTable ll) = concat $ map f $ zip [0 ..] $ M.toList ll
printopt (_, Nothing) = []
printopt (opt, Just s) = [opt, s]
--- | prints header and head on stderr and returns cmdline options to callback
+-- | prints header and head on stderr and returns
+-- cmdline options and environment variables to callback
printmsg ::
Maybe Handle
-> (Message, Envelope)
, ("PRIORITY", pri)
, ("REDELIVERED", redeliv)
] ++
- concat ( maybeToList headers'' )
+ headersEnv
return (cmdline, environment)
where
step (_, Nothing) xs = xs
, ("-p", pri)
, ("-R", redeliv)
] ++
- maybeToList headers')
+ headersOpt)
headers = fmap (formatheaders fieldshow) $ msgHeaders msg
- headers' = fmap (formatheaders fieldshow') $ msgHeaders msg
- headers'' = fmap (formatheaders' fieldshow'') $ msgHeaders msg
+ headersOpt = maybeToList $ fmap (formatheaders fieldshow') $ msgHeaders msg
+ headersEnv =
+ concat . maybeToList $ fmap (formatheaders' fieldshow'') $ msgHeaders msg
body = msgBody msg
anriss =
if isimage ctype