[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:16 UTC 2010
The following commit has been merged in the master branch:
commit 249dd575b34d7573357f1708f17211a09d5023c0
Author: John Goerzen <jgoerzen at complete.org>
Date: Fri Oct 22 21:23:19 2004 +0100
Added basic FTP support, Parsec utilities
Keywords:
(jgoerzen at complete.org--projects/missingh--head--1.0--patch-96)
diff --git a/ChangeLog b/ChangeLog
index 96607a0..a57253e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,29 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--1.0
#
+2004-10-22 15:23:19 GMT John Goerzen <jgoerzen at complete.org> patch-96
+
+ Summary:
+ Added basic FTP support, Parsec utilities
+ Revision:
+ missingh--head--1.0--patch-96
+
+
+ new files:
+ .arch-ids/notes.txt.id
+ libsrc/MissingH/Network/FTP/.arch-ids/=id
+ libsrc/MissingH/Network/FTP/Client.hs
+ libsrc/MissingH/Network/FTP/Parser.hs
+ libsrc/MissingH/Parsec.hs notes.txt
+
+ modified files:
+ ChangeLog Setup.description
+
+ new directories:
+ .arch-ids libsrc/MissingH/Network/FTP
+ libsrc/MissingH/Network/FTP/.arch-ids
+
+
2004-10-21 17:55:21 GMT John Goerzen <jgoerzen at complete.org> patch-95
Summary:
diff --git a/Setup.description b/Setup.description
index df3ad11..33e3eb8 100644
--- a/Setup.description
+++ b/Setup.description
@@ -15,6 +15,9 @@ Modules: MissingH.IO, MissingH.IO.Binary, MissingH.List,
MissingH.Str,
MissingH.Cmd,
MissingH.FiniteMap, MissingH.Path,
+ MissingH.Network.FTP.Client,
+ MissingH.Network.FTP.Parser,
+ MissingH.Parsec,
MissingH.Wash.Mail.Email,
MissingH.Wash.Mail.EmailConfig,
MissingH.Wash.Mail.HeaderField,
diff --git a/libsrc/MissingH/Threads.hs b/libsrc/MissingH/Network/FTP/Client.hs
similarity index 53%
copy from libsrc/MissingH/Threads.hs
copy to libsrc/MissingH/Network/FTP/Client.hs
index 5332e61..0afcef2 100644
--- a/libsrc/MissingH/Threads.hs
+++ b/libsrc/MissingH/Network/FTP/Client.hs
@@ -1,4 +1,4 @@
-{- arch-tag: Thread utilities main file
+{- arch-tag: FTP client support
Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
This program is free software; you can redistribute it and/or modify
@@ -17,37 +17,39 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
{- |
- Module : MissingH.Threads
+ Module : MissingH.Network.FTP.Client
Copyright : Copyright (C) 2004 John Goerzen
License : GNU GPL, version 2 or above
Maintainer : John Goerzen,
Maintainer : jgoerzen at complete.org
Stability : provisional
- Portability: portable
+ Portability: systems with networking
-This module provides various helpful utilities for dealing with threads.
+This module provides a client-side interface to the File Transfer Protocol.
Written by John Goerzen, jgoerzen\@complete.org
+
+Useful standards:
+
+* RFC959, <http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc0959.html>
+
+* Passive mode, RFC1579, <http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc1579.html>
+
+* Extended passive mode, IPv6, RFC2428 <http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc2428.html>
+
+* Feature negotiation, RFC2389, <http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc2389.html>
+
+* Internationalization of FTP, RFC2640, <http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc2640.html>
+
+* FTP security considerations, RFC2577, <http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc2577.html>
+
+* FTP URLs, RFC1738, <http://www.cse.ohio-state.edu/cgi-bin/rfc/rfc1738.html>
+
-}
-module MissingH.Threads(-- * I\/O utilities
- runInThread
+module MissingH.Network.FTP.Client(
)
where
-import Control.Concurrent
-
-{- | Takes a IO action and a function. The IO action will be called in a
-separate thread. When it is completed, the specified function is called with
-its result. This is a simple way of doing callbacks. -}
-
-runInThread :: IO a -> (a -> IO b) -> IO ThreadId
-runInThread action callback =
- let computation :: IO ()
- computation = do
- x <- action
- callback x
- return ()
- in
- forkIO computation
+-- nothing yet
\ No newline at end of file
diff --git a/libsrc/MissingH/Network/FTP/Parser.hs b/libsrc/MissingH/Network/FTP/Parser.hs
new file mode 100644
index 0000000..e1b2d5f
--- /dev/null
+++ b/libsrc/MissingH/Network/FTP/Parser.hs
@@ -0,0 +1,120 @@
+{- arch-tag: FTP protocol parser
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+-}
+
+{- |
+ Module : MissingH.Network.FTP.Parser
+ Copyright : Copyright (C) 2004 John Goerzen
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John Goerzen,
+ Maintainer : jgoerzen at complete.org
+ Stability : provisional
+ Portability: systems with networking
+
+This module provides a parser that is used internally by
+"MissingH.Network.FTP.Client". You almost certainly do not want to use
+this module directly. Use "MissingH.Network.FTP.Client" instead.
+
+Written by John Goerzen, jgoerzen\@complete.org
+
+-}
+
+module MissingH.Network.FTP.Parser(
+ )
+where
+
+import Text.ParserCombinators.Parsec
+import MissingH.Parsec
+
+----------------------------------------------------------------------
+-- Utilities
+----------------------------------------------------------------------
+
+crlf :: Parser String
+crlf = string "\r\n" <?> "CRLF"
+
+sp :: Parser Char
+sp = char ' '
+
+code :: Parser Int
+code = do
+ s <- codeString
+ return (read s)
+
+codeString :: Parser String
+codeString = do
+ first <- oneOf "123456789"
+ remaining <- count 2 digit <?> "3-digit reply code"
+ return (first : remaining)
+
+specificCode :: Int -> Parser Int
+specificCode exp = do
+ s <- string (show exp)
+ return (read s)
+
+line :: Parser String
+line = many (noneOf "\r\n")
+
+----------------------------------------------------------------------
+-- The parsers
+----------------------------------------------------------------------
+
+singleReplyLine :: Parser (Int, String)
+singleReplyLine = do
+ x <- code
+ sp
+ text <- line
+ crlf
+ return (x, text)
+
+expectedReplyLine :: Int -> Parser (Int, String)
+expectedReplyLine expectedcode = do
+ x <- specificCode expectedcode
+ sp
+ text <- line
+ crlf
+ return (x, text)
+
+startOfMultiReply :: Parser (Int, String)
+startOfMultiReply = do
+ x <- code
+ char '-'
+ text <- line
+ crlf
+ return (x, text)
+
+multiReplyComponent :: Parser [String]
+multiReplyComponent = try (do
+ notMatching codeString "found unexpected code"
+ thisLine <- line
+ remainder <- multiReplyComponent
+ return (thisLine : remainder)
+ )
+ <|> return []
+
+multiReply :: Parser (Int, [String])
+multiReply = try (do
+ x <- singleReplyLine
+ return (fst x, [snd x])
+ )
+ <|> (do
+ start <- startOfMultiReply
+ component <- multiReplyComponent
+ end <- expectedReplyLine (fst start)
+ return (fst start, snd start : (component ++ [snd end]))
+ )
diff --git a/libsrc/MissingH/Threads.hs b/libsrc/MissingH/Parsec.hs
similarity index 54%
copy from libsrc/MissingH/Threads.hs
copy to libsrc/MissingH/Parsec.hs
index 5332e61..0dac04b 100644
--- a/libsrc/MissingH/Threads.hs
+++ b/libsrc/MissingH/Parsec.hs
@@ -1,4 +1,4 @@
-{- arch-tag: Thread utilities main file
+{- arch-tag: Parsec utilities
Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-}
{- |
- Module : MissingH.Threads
+ Module : MissingH.Parsec
Copyright : Copyright (C) 2004 John Goerzen
License : GNU GPL, version 2 or above
@@ -26,28 +26,31 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Stability : provisional
Portability: portable
-This module provides various helpful utilities for dealing with threads.
-
Written by John Goerzen, jgoerzen\@complete.org
+
-}
-module MissingH.Threads(-- * I\/O utilities
- runInThread
- )
+module MissingH.Parsec(-- * Utilities
+ notMatching)
where
-import Control.Concurrent
-
-{- | Takes a IO action and a function. The IO action will be called in a
-separate thread. When it is completed, the specified function is called with
-its result. This is a simple way of doing callbacks. -}
-
-runInThread :: IO a -> (a -> IO b) -> IO ThreadId
-runInThread action callback =
- let computation :: IO ()
- computation = do
- x <- action
- callback x
- return ()
+import Text.ParserCombinators.Parsec
+
+{- | Running @notMatching p msg@ will try to apply parser p.
+If it fails, returns (). If it succeds, cause a failure and raise
+the given error message. It will not consume input in either case. -}
+notMatching :: GenParser a b c -> String -> GenParser a b ()
+notMatching p errormsg =
+ let maybeRead = try (do
+ x <- p
+ return (Just x)
+ )
+ <|> return Nothing
+ workerFunc = do
+ x <- maybeRead
+ case x of
+ Nothing -> return ()
+ Just x -> unexpected errormsg
in
- forkIO computation
+ try workerFunc
+
diff --git a/notes.txt b/notes.txt
new file mode 100644
index 0000000..7b3c675
--- /dev/null
+++ b/notes.txt
@@ -0,0 +1,5 @@
+ basename p = reverse $ takeWhile (/= '/') $ reverse p
+
+ dirname p = case reverse $ dropWhile (/= '/') $ reverse p of
+ [] -> "."
+ p' -> p'
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list