{- | Module : $Header$ Description : NNTP extentions from RFC2980 Copyright : (c) Maciej Piechotka License : LGPL 3 or later Maintainer : uzytkownik2@gmail.com Stability : none Portability : portable This module contains the common features and common interface. -} module Network.NNTP.Common ( -- * Functions xhdr ) where import Control.Applicative hiding (empty) import Control.Monad.Trans import Data.ByteString.Lazy.Char8(empty) import Network.NNTP.Internal import Network.NNTP.ParserHelpers import Text.Parsec hiding (many) xhdr :: Monad m => (Article -> m a) -> NntpT m [a] xhdr f = nntpSendCommand "XHDR Message-ID 0-" empty $ do c <- code <* line case c of 221 -> many (integer *> many1 space *> iD <* line >>= \i -> lift (lift (f (Article i Nothing Nothing)))) <* string ".\r\n" 412 -> error "No news group selected" _ -> error "Unknown response"