|
@@ -46,7 +46,7 @@ module System.IO.Uniform.Streamline (
|
|
|
import System.IO (stdout, Handle)
|
|
|
import qualified System.IO.Uniform as S
|
|
|
import qualified System.IO.Uniform.Network as N
|
|
|
-import qualified System.IO.Uniform.Std as Std
|
|
|
+import qualified System.IO.Uniform.Null as Null
|
|
|
import System.IO.Uniform (UniformIO, SomeIO(..), TlsSettings)
|
|
|
import System.IO.Uniform.Streamline.Scanner
|
|
|
import Data.Default.Class
|
|
@@ -57,7 +57,6 @@ import Control.Monad.Trans.Control
|
|
|
import Control.Monad
|
|
|
import Control.Monad.Base
|
|
|
import Control.Monad.IO.Class
|
|
|
-import System.IO.Error
|
|
|
import Data.ByteString (ByteString)
|
|
|
import qualified Data.ByteString as BS
|
|
|
import qualified Data.ByteString.Lazy as LBS
|
|
@@ -66,13 +65,10 @@ import Data.IP (IP)
|
|
|
|
|
|
import qualified Data.Attoparsec.ByteString as A
|
|
|
|
|
|
-import Debug.Trace
|
|
|
-
|
|
|
-- | Internal state for a Streamline monad
|
|
|
data StreamlineState = StreamlineState {str :: SomeIO, buff :: ByteString, targetEOF :: Bool, echo :: Maybe Handle, inLimit :: Int}
|
|
|
instance Default StreamlineState where
|
|
|
- -- | Will open StdIO
|
|
|
- def = StreamlineState (SomeIO Std.StdIO) BS.empty False Nothing (-1)
|
|
|
+ def = StreamlineState (SomeIO Null.NullIO) BS.empty False Nothing (-1)
|
|
|
|
|
|
-- | Monad that emulates character stream IO over block IO.
|
|
|
newtype Streamline m a = Streamline {withTarget' :: StreamlineState -> m (a, StreamlineState)}
|
|
@@ -106,7 +102,7 @@ takeBuff = do
|
|
|
readF
|
|
|
Streamline $ \cl ->
|
|
|
let lim = inLimit cl
|
|
|
- eof = targetEOF cl
|
|
|
+ --eof = targetEOF cl
|
|
|
b = buff cl
|
|
|
in if lim < 0 then return (b, cl{buff=""})
|
|
|
else let (r, b') = BS.splitAt lim b
|
|
@@ -315,7 +311,7 @@ runAttoparsecAndReturn p = do
|
|
|
continueResult c d dd = case c of
|
|
|
A.Fail i _ msg -> do
|
|
|
pushBuff $ BS.concat (reverse dd) `BS.append` i
|
|
|
- return (BS.take (BS.length d - BS.length i) d, Left msg)
|
|
|
+ return ("", Left msg)
|
|
|
A.Done i r -> do
|
|
|
pushBuff i
|
|
|
return (BS.concat (reverse dd) `BS.append`
|
|
@@ -381,9 +377,6 @@ Setting to Nothing will disable echo.
|
|
|
echoTo :: Monad m => Maybe Handle -> Streamline m ()
|
|
|
echoTo h = Streamline $ \cl -> return ((), cl{echo=h})
|
|
|
|
|
|
-eofError :: MonadIO m => String -> m a
|
|
|
-eofError msg = liftIO . ioError $ mkIOError eofErrorType msg Nothing Nothing
|
|
|
-
|
|
|
instance Interruptible Streamline where
|
|
|
type RSt Streamline a = (a, StreamlineState)
|
|
|
resume f (a, st) = withTarget' (f a) st
|