Portability | |
---|---|
Stability | provisional |
Maintainer | Nicolas Pouillard <nicolas.pouillard@gmail.com> |
- newtype Mbox s = Mbox {
- mboxMessages :: [MboxMessage s]
- data MboxMessage s = MboxMessage {
- _mboxMsgSender :: s
- _mboxMsgTime :: s
- _mboxMsgBody :: s
- _mboxMsgFile :: FilePath
- _mboxMsgOffset :: Int64
- data Direction
- parseMboxFile :: Direction -> FilePath -> IO (Mbox ByteString)
- parseMboxFiles :: Direction -> [FilePath] -> IO [Mbox ByteString]
- parseMbox :: ByteString -> Mbox ByteString
- safeParseMbox :: FilePath -> Int64 -> ByteString -> Either String (Mbox ByteString)
- parseOneMboxMessage :: FilePath -> Handle -> Integer -> IO (MboxMessage ByteString)
- showMbox :: Mbox ByteString -> ByteString
- showMboxMessage :: MboxMessage ByteString -> ByteString
- showMboxFromLine :: MboxMessage ByteString -> ByteString
- mboxMsgSender :: MboxMessage s :-> s
- mboxMsgTime :: MboxMessage s :-> s
- mboxMsgBody :: MboxMessage s :-> s
- mboxMsgFile :: MboxMessage s :-> FilePath
- mboxMsgOffset :: MboxMessage s :-> Int64
- data Month
- fromQuoting :: (Int64 -> Int64) -> ByteString -> ByteString
- msgYear :: MboxMessage ByteString -> Int
- msgMonthYear :: MboxMessage ByteString -> (Month, Int)
- opposite :: Direction -> Direction
Mailbox, message, and direction data types
An Mbox
is a list of MboxMessage
Mbox | |
|
data MboxMessage s Source
An MboxMessage
represent an mbox message, featuring
the sender, the date-time, and the message body.
MboxMessage | |
|
Eq s => Eq (MboxMessage s) | |
Ord s => Ord (MboxMessage s) | |
Show s => Show (MboxMessage s) |
Mailbox parsing functions
parseMboxFile :: Direction -> FilePath -> IO (Mbox ByteString)Source
Returns a mbox given a direction (forward/backward) and a file path.
parseMboxFiles :: Direction -> [FilePath] -> IO [Mbox ByteString]Source
Returns a mbox list given a direction (forward/backward) and a list of file path. Note that files are opened lazily.
parseMbox :: ByteString -> Mbox ByteStringSource
Turns a ByteString
into an Mbox
by splitting on From_ lines and
unquoting the '>*From's of the message.
safeParseMbox :: FilePath -> Int64 -> ByteString -> Either String (Mbox ByteString)Source
Same as parseMbox
but cat returns an error message.
However only the line can cause an error message currently, so it's fine
to dispatch on the either result.
parseOneMboxMessage :: FilePath -> Handle -> Integer -> IO (MboxMessage ByteString)Source
Given a file handle and an offset, parseOneMboxMessage
returns
the message a this offset.
Mailbox printing functions
showMbox :: Mbox ByteString -> ByteStringSource
Turns an mbox into a ByteString
showMboxMessage :: MboxMessage ByteString -> ByteStringSource
Returns a ByteString
given an mbox message.
showMboxFromLine :: MboxMessage ByteString -> ByteStringSource
Returns an header line in mbox format given an mbox message.
First-class labels
mboxMsgSender :: MboxMessage s :-> sSource
First-class label to message's sender
mboxMsgTime :: MboxMessage s :-> sSource
First-class label to the date and time of the given message
mboxMsgBody :: MboxMessage s :-> sSource
First-class label to message's raw body
mboxMsgFile :: MboxMessage s :-> FilePathSource
First-class label to the file path of mbox's message
mboxMsgOffset :: MboxMessage s :-> Int64Source
First-class label to the offset of the given message into the mbox
Misc
fromQuoting :: (Int64 -> Int64) -> ByteString -> ByteStringSource
fromQuoting f s
returns s
where the quoting level
of From_ lines has been updated using the f
function.
The From_ spefication, quoted from http://qmail.org./man/man5/mbox.html:
>From quoting ensures that the resulting lines are not From_ lines: the program prepends a > to any From_ line, >From_ line, >>From_ line, >>>From_ line, etc.
msgMonthYear :: MboxMessage ByteString -> (Month, Int)Source