[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 14:45:33 UTC 2010
The following commit has been merged in the master branch:
commit 898415927a85d1610d1ad13e352cce7ce1d8dbfe
Author: John Goerzen <jgoerzen at complete.org>
Date: Sat Oct 23 22:06:52 2004 +0100
Playing around with basics
Keywords:
(jgoerzen at complete.org--projects/missingh--head--1.0--patch-105)
diff --git a/ChangeLog b/ChangeLog
index 5c9b4b6..e6a5364 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,24 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--1.0
#
+2004-10-23 16:06:52 GMT John Goerzen <jgoerzen at complete.org> patch-105
+
+ Summary:
+ Playing around with basics
+ Revision:
+ missingh--head--1.0--patch-105
+
+
+ removed files:
+ debian/libghc6-missingh-dev.postinst.debhelper
+ debian/libghc6-missingh-dev.prerm.debhelper
+
+ modified files:
+ ChangeLog libsrc/MissingH/IO.hs
+ libsrc/MissingH/Network/FTP/Client.hs
+ libsrc/MissingH/Network/FTP/Parser.hs
+
+
2004-10-23 15:32:16 GMT John Goerzen <jgoerzen at complete.org> patch-104
Summary:
diff --git a/debian/libghc6-missingh-dev.postinst.debhelper b/debian/libghc6-missingh-dev.postinst.debhelper
deleted file mode 100644
index 8856549..0000000
--- a/debian/libghc6-missingh-dev.postinst.debhelper
+++ /dev/null
@@ -1,26 +0,0 @@
-# Automatically added by dh_haskell
-GHC=ghc-6.2.1
-CONFIGFILE=/usr/lib/haskell-packages/ghc6/lib/MissingH-0.4.0/installed-pkg-config
-
-
-case "$1" in
- configure)
- /usr/lib/$GHC/bin/ghc-pkg -g --add-package \
- < $CONFIGFILE
-
- ;;
-
- abort-upgrade|abort-remove|abort-deconfigure)
-
- ;;
-
- *)
- echo "postinst called with unknown argument \`$1'" >&2
- exit 1
- ;;
-esac
-
-
-
-# arch-tag: haskell-devscripts generic GHC postinst template
-# End automatically added section
diff --git a/debian/libghc6-missingh-dev.prerm.debhelper b/debian/libghc6-missingh-dev.prerm.debhelper
deleted file mode 100644
index a2b3633..0000000
--- a/debian/libghc6-missingh-dev.prerm.debhelper
+++ /dev/null
@@ -1,25 +0,0 @@
-# Automatically added by dh_haskell
-
-GHC=ghc-6.2.1
-CONFIGFILE=/usr/lib/haskell-packages/ghc6/lib/MissingH-0.4.0/installed-pkg-config
-CABALNAME=MissingH
-
-
-
-case "$1" in
- remove|upgrade|deconfigure)
- /usr/lib/$GHC/bin/ghc-pkg -r $CABALNAME
- rm -vf /usr/lib/haskell-packages/ghc6/lib/MissingH-0.4.0/HSMissingH-0.4.0.o
-
- ;;
- failed-upgrade)
- ;;
- *)
- echo "prerm called with unknown argument \`$1'" >&2
- exit 1
- ;;
-esac
-
-
-# arch-tag: haskell-devscripts generic GHC prerm template
-# End automatically added section
diff --git a/libsrc/MissingH/IO.hs b/libsrc/MissingH/IO.hs
index 9da1bc6..9173ba0 100644
--- a/libsrc/MissingH/IO.hs
+++ b/libsrc/MissingH/IO.hs
@@ -98,7 +98,7 @@ In other words:
hInteract :: Handle -> Handle -> (String -> String) -> IO ()
hInteract finput foutput func = do
content <- hGetContents finput
- hPutStr stdout (func content)
+ hPutStr foutput (func content)
{- | Line-based interaction. This is similar to wrapping your
interact functions with 'lines' and 'unlines'. This equality holds:
diff --git a/libsrc/MissingH/Network/FTP/Client.hs b/libsrc/MissingH/Network/FTP/Client.hs
index 0afcef2..8b93ae5 100644
--- a/libsrc/MissingH/Network/FTP/Client.hs
+++ b/libsrc/MissingH/Network/FTP/Client.hs
@@ -51,5 +51,37 @@ Useful standards:
module MissingH.Network.FTP.Client(
)
where
+import MissingH.Network.FTP.Parser
+import Network.Socket
+import qualified Network
+import System.IO
+import MissingH.Logging.Logger
--- nothing yet
\ No newline at end of file
+type FTPConnection = Handle
+
+{-
+getresp h = do c <- hGetContents h
+ return (parseGoodReply c)
+-}
+
+getresp = debugParseGoodReplyHandle
+
+sendcmd h c = hPutStr h (c ++ "\r\n")
+
+{- | Connect to the remote FTP server and read but discard
+ the welcome. Assumes
+ default FTP port, 21, on remote. -}
+easyConnectTo :: Network.HostName -> IO Handle
+easyConnectTo h = do x <- connectTo h (Network.PortNumber 21)
+ return (fst x)
+
+{- | Connect to remote FTP server and read the welcome. -}
+connectTo :: Network.HostName -> Network.PortID -> IO (Handle, FTPResult)
+connectTo h p =
+ do
+ updateGlobalLogger "MissingH.Network.FTP.Parser" (setLevel DEBUG)
+ h <- Network.connectTo h p
+ hSetBuffering h LineBuffering
+ r <- getresp h
+ --r `seq` return (h, r)
+ return (h, r)
diff --git a/libsrc/MissingH/Network/FTP/Parser.hs b/libsrc/MissingH/Network/FTP/Parser.hs
index 363cee6..82cf1cf 100644
--- a/libsrc/MissingH/Network/FTP/Parser.hs
+++ b/libsrc/MissingH/Network/FTP/Parser.hs
@@ -35,8 +35,10 @@ Written by John Goerzen, jgoerzen\@complete.org
-}
module MissingH.Network.FTP.Parser(parseReply, parseGoodReply,
- toPortString, fromPortString,
- debugParseGoodReplyHandle)
+ toPortString, fromPortString,
+ debugParseGoodReply,
+ debugParseGoodReplyHandle,
+ FTPResult)
where
import Text.ParserCombinators.Parsec
@@ -47,6 +49,9 @@ import MissingH.Str
import MissingH.Logging.Logger
import Network.Socket(SockAddr(..), PortNumber(..))
import System.IO(Handle, hGetContents)
+import System.IO.Unsafe
+type FTPResult = (Int, [String])
+
-- import Control.Exception(Exception(PatternMatchFail), throw)
logit :: String -> IO ()
@@ -123,7 +128,7 @@ multiReplyComponent = (try (do
)
) <|> return []
-multiReply :: Parser (Int, [String])
+multiReply :: Parser FTPResult
multiReply = try (do
x <- singleReplyLine
return (fst x, [snd x])
@@ -141,7 +146,7 @@ multiReply = try (do
-- | Parse a FTP reply. Returns a (result code, text) pair.
-parseReply :: String -> (Int, [String])
+parseReply :: String -> FTPResult
parseReply input =
case parse multiReply "(unknown)" input of
Left err -> error (show err)
@@ -151,7 +156,7 @@ parseReply input =
-- If the result code indicates an error, raise an exception instead
-- of just passing it back.
-parseGoodReply :: String -> (Int, [String])
+parseGoodReply :: String -> FTPResult
parseGoodReply input =
let reply = parseReply input
in
@@ -160,7 +165,7 @@ parseGoodReply input =
else reply
-- | Parse a FTP reply. Logs debug messages.
-debugParseGoodReply :: String -> IO (Int, [String])
+debugParseGoodReply :: String -> IO FTPResult
debugParseGoodReply contents =
let logPlugin :: String -> String -> IO String
logPlugin [] [] = return []
@@ -170,10 +175,10 @@ debugParseGoodReply contents =
logPlugin (x:xs) accum =
case x of
'\n' -> do logit (strip (accum))
- next <- logPlugin xs []
+ next <- unsafeInterleaveIO $ logPlugin xs []
return (x : next)
y -> do
- next <- logPlugin xs (accum ++ [x])
+ next <- unsafeInterleaveIO $ logPlugin xs (accum ++ [x])
return (x : next)
in
do
@@ -181,7 +186,7 @@ debugParseGoodReply contents =
return (parseGoodReply loggedStr)
-- | Parse a FTP reply. Log debug messages.
-debugParseGoodReplyHandle :: Handle -> IO (Int, [String])
+debugParseGoodReplyHandle :: Handle -> IO FTPResult
debugParseGoodReplyHandle h = do
c <- hGetContents h
debugParseGoodReply c
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list