-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | gopher server daemon -- -- simple gopher server daemon @package spacecookie @version 0.2.0.1 -- | Helper utilities used within the library and the server which also -- could be useful for other application code. module Network.Gopher.Util -- | Normalise a path and prevent directory traversal attacks. santinizePath :: FilePath -> FilePath santinizeIfNotUrl :: FilePath -> FilePath -- | ord a Word8 asciiOrd :: Char -> Word8 -- | chr a Word8 asciiChr :: Word8 -> Char -- | Encode a String to a UTF-8 ByteString uEncode :: String -> ByteString -- | Decode a UTF-8 ByteString to a String uDecode :: ByteString -> String -- | Strip \r and \n from ByteStrings stripNewline :: ByteString -> ByteString -- | This module implements a parser for gophermap files. -- -- Example usage: -- --
--   import Network.Gopher.Util.Gophermap
--   import qualified Data.ByteString as B
--   import Data.Attoparsec.ByteString
--   
--   main = do
--     file <- B.readFile "gophermap"
--     print $ parseOnly parseGophermap file
--   
module Network.Gopher.Util.Gophermap -- | Attoparsec Parser for the gophermap file format parseGophermap :: Parser Gophermap -- | A gophermap entry makes all values of a gopher menu item optional -- except for file type and description. When converting to a -- GopherMenuItem, appropriate default values are used. data GophermapEntry -- | file type, description, path, server name, port number GophermapEntry :: GopherFileType -> ByteString -> Maybe FilePath -> Maybe ByteString -> Maybe Integer -> GophermapEntry type Gophermap = [GophermapEntry] -- | Convert a gophermap to a gopher menu response. gophermapToDirectoryResponse :: Gophermap -> GopherResponse instance GHC.Classes.Eq Network.Gopher.Util.Gophermap.GophermapEntry instance GHC.Show.Show Network.Gopher.Util.Gophermap.GophermapEntry -- |

Overview

-- -- This is the main module of the spacecookie library. It allows to write -- gopher applications by taking care of handling gopher requests while -- leaving the application logic to a user-supplied function. -- -- For a small tutorial an example of a trivial pure gopher application: -- --
--   import Network.Gopher
--   import Network.Gopher.Util
--   
--   main = do
--     runGopherPure (GopherConfig "localhost" 7000 Nothing) (\req -> FileResponse (uEncode req))
--   
-- -- This server just returns the request string as a file. -- -- There are three possibilities for a GopherResponse: -- -- -- -- If you use runGopher, it is the same story like in the example -- above, but you can do IO effects. To see a more elaborate -- example, have a look at the server code in this package. module Network.Gopher -- | Run a gopher application that may cause effects in IO. The -- application function is given the gopher request (path) and required -- to produce a GopherResponse. runGopher :: GopherConfig -> (String -> IO GopherResponse) -> IO () -- | Run a gopher application that may not cause effects in IO. runGopherPure :: GopherConfig -> (String -> GopherResponse) -> IO () -- | necessary information to handle gopher requests data GopherConfig GopherConfig :: ByteString -> Integer -> Maybe String -> GopherConfig -- | “name” of the server (either ip address or dns name) [cServerName] :: GopherConfig -> ByteString -- | port to listen on [cServerPort] :: GopherConfig -> Integer -- | user to run the process as [cRunUserName] :: GopherConfig -> Maybe String -- | Convert a gophermap to a gopher menu response. gophermapToDirectoryResponse :: Gophermap -> GopherResponse data GopherResponse -- | gopher menu, wrapper around a list of GopherMenuItems MenuResponse :: [GopherMenuItem] -> GopherResponse -- | return the given ByteString as a file FileResponse :: ByteString -> GopherResponse -- | gopher menu containing a single error with the given String as -- text ErrorResponse :: String -> GopherResponse -- | entry in a gopher menu data GopherMenuItem -- | file type, menu text, filepath (does not need to be a real file), -- server name (optional), port (optional) Item :: GopherFileType -> ByteString -> FilePath -> Maybe ByteString -> Maybe Integer -> GopherMenuItem -- | rfc-defined gopher file types plus info line and HTML data GopherFileType -- | text file, default type File :: GopherFileType -- | a gopher menu Directory :: GopherFileType PhoneBookServer :: GopherFileType -- | error entry in menu Error :: GopherFileType BinHexMacintoshFile :: GopherFileType DOSArchive :: GopherFileType UnixUuencodedFile :: GopherFileType IndexSearchServer :: GopherFileType TelnetSession :: GopherFileType -- | binary file BinaryFile :: GopherFileType RedundantServer :: GopherFileType Tn3270Session :: GopherFileType -- | gif GifFile :: GopherFileType -- | image of any format ImageFile :: GopherFileType -- | menu entry without associated file InfoLine :: GopherFileType -- | Special type for HTML, most commonly used for links to other -- protocols Html :: GopherFileType -- | A gophermap entry makes all values of a gopher menu item optional -- except for file type and description. When converting to a -- GopherMenuItem, appropriate default values are used. data GophermapEntry -- | file type, description, path, server name, port number GophermapEntry :: GopherFileType -> ByteString -> Maybe FilePath -> Maybe ByteString -> Maybe Integer -> GophermapEntry type Gophermap = [GophermapEntry] instance Control.Monad.Error.Class.MonadError GHC.IO.Exception.IOException Network.Gopher.GopherM instance Control.Monad.Reader.Class.MonadReader Network.Gopher.Env Network.Gopher.GopherM instance Control.Monad.IO.Class.MonadIO Network.Gopher.GopherM instance GHC.Base.Monad Network.Gopher.GopherM instance GHC.Base.Applicative Network.Gopher.GopherM instance GHC.Base.Functor Network.Gopher.GopherM instance System.Log.FastLogger.LogStr.ToLogStr Network.Gopher.LogMessage