[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:50:36 UTC 2010
The following commit has been merged in the master branch:
commit 62982859d5c581c2f42e25563ce0156e653e85b2
Author: John Goerzen <jgoerzen at complete.org>
Date: Wed Dec 15 06:00:15 2004 +0100
preliminary gopher work
Keywords:
(jgoerzen at complete.org--projects/missingh--head--0.7--patch-65)
diff --git a/ChangeLog b/ChangeLog
index 33c8c70..4688ab9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,21 @@
# arch-tag: automatic-ChangeLog--jgoerzen at complete.org--projects/missingh--head--0.7
#
+2004-12-14 23:00:15 GMT John Goerzen <jgoerzen at complete.org> patch-65
+
+ Summary:
+ preliminary gopher work
+ Revision:
+ missingh--head--0.7--patch-65
+
+
+ new files:
+ libsrc/MissingH/Network/Gopher.hs
+
+ modified files:
+ ChangeLog libsrc/MissingH/ConfigParser.hs
+
+
2004-12-10 22:47:12 GMT John Goerzen <jgoerzen at complete.org> patch-64
Summary:
diff --git a/libsrc/MissingH/ConfigParser.hs b/libsrc/MissingH/ConfigParser.hs
index 63ea07e..cb1492a 100644
--- a/libsrc/MissingH/ConfigParser.hs
+++ b/libsrc/MissingH/ConfigParser.hs
@@ -420,8 +420,10 @@ instance Get_C String where
instance Get_C Bool where
get = getbool
-instance Read t => Get_C t where
- get cp s o = get cp s o >>= return . read
+instance (Num t, Read t) => Get_C t where
+ get = genericget
+
+genericget cp s o = get cp s o >>= return . read
getbool :: MonadError CPError m =>
ConfigParser -> SectionSpec -> OptionSpec -> m Bool
diff --git a/libsrc/MissingH/Network/Gopher.hs b/libsrc/MissingH/Network/Gopher.hs
new file mode 100644
index 0000000..3a48e17
--- /dev/null
+++ b/libsrc/MissingH/Network/Gopher.hs
@@ -0,0 +1,86 @@
+{- arch-tag: Gopher support
+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.Gopher
+ Copyright : Copyright (C) 2004 John Goerzen
+ License : GNU GPL, version 2 or above
+
+ Maintainer : John Goerzen,
+ Maintainer : jgoerzen at complete.org
+ Stability : experimental
+ Portability: systems with networking
+
+This module provides types and generic support for Gopher clients or serves.
+
+Related standards: RFC1436 <http://www.faqs.org/rfcs/rfc1436.html>,
+Gopher+ spec <gopher://gopher.quux.org/1/Archives/mirrors/boombox.micro.umn.edu/pub/gopher/gopher_protocol/Gopher%2B/Gopher%2B.txt>
+
+Written by John Goerzen, jgoerzen\@complete.org
+-}
+
+module MissingH.Network.Gopher (-- * Types
+ GopherEntry(..)
+ )
+ where
+
+import MissingH.Printf
+import MissingH.Str
+import Data.FiniteMap
+
+{- | Type representing an entry in a Gopher directory.
+
+May add more Gopher+ stuff in here down the road.
+
+You can show a 'GopherEntry'. This will produce a one-line string suitable
+for use on a Gopher server.
+
+You can 'read' to a 'GopherEntry'. This will parse a string as a one-line
+piece of text suitable for use generating a 'GopherEntry'.
+
+Neither show nor read will consider the 'ea' member. -}
+data GopherEntry = GopherEntry
+ {
+ selector :: String, -- ^ Path to file on server
+ gophertype :: Char, -- ^ Gopher0 type character
+ name :: String, -- ^ Gopher menu name
+ host :: String, -- ^ Content host name
+ port :: Integer, -- ^ Remote port
+ gopherpsupport :: Bool, -- ^ Whether Gopher+ is supported
+ ea :: FiniteMap String String -- ^ Gopher+ extended attributes
+ }
+
+instance Show GopherEntry where
+ show x = let basic = vsprintf "%c%s\t%s\t%s\t%d"
+ (gophertype x) (name x) (selector x) (host x)
+ (port x)
+ in if gopherpsupport x then
+ basic ++ "\t+"
+ else basic
+
+instance Read GopherEntry where
+ read s = let parts = split "\t" s
+ in
+ GopherEntry {selector = parts !! 2,
+ gophertype = head (parts !! 0),
+ name = parts !! 1,
+ host = parts !! 3,
+ port = read (parts !! 4),
+ gopherpsupport = length parts > 5 && (parts !! 5 == "+"),
+ ea = emptyFM
+ }
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list