import qualified Data.ByteString.Lazy as Lazy (ByteString)
import qualified Data.ByteString.Lazy as L hiding (ByteString)
import Data.Char
-import Data.Digest.SHA2
import Data.Int
import Data.Maybe
import Data.Time
import Data.Time.Clock.POSIX
-import Data.Word
import Language.Haskell.Pretty
import Language.Haskell.Syntax
import Network.HTTP.Lucu.MIMEType
import Network.HTTP.Lucu.MIMEType.DefaultExtensionMap
import Network.HTTP.Lucu.MIMEType.Guess
+import OpenSSL
+import OpenSSL.EVP.Digest
import System.Console.GetOpt
import System.Environment
import System.Exit
main :: IO ()
-main = do (opts, sources, errors) <- return . getOpt Permute options =<< getArgs
+main = withOpenSSL $
+ do (opts, sources, errors) <- return . getOpt Permute options =<< getArgs
when (not $ null errors)
$ do mapM_ putStr errors
_ -> False) opts
in
case eTagOpts of
- [] -> return mkETagFromInput
+ [] -> getDigestByName "SHA1" >>= return . mkETagFromInput . fromJust
(OptETag str):[] -> return str
_ -> error "too many --etag options."
where
- mkETagFromInput :: String
- mkETagFromInput = "SHA-1:" ++ (toHex $ toOctets $ sha256 $ L.unpack input)
+ mkETagFromInput :: Digest -> String
+ mkETagFromInput sha1 = "SHA-1:" ++ (toHex $ digestLBS sha1 input)
- toHex :: [Word8] -> String
+ toHex :: [Char] -> String
toHex [] = ""
- toHex (x:xs) = hexByte (fromIntegral x) ++ toHex xs
+ toHex (x:xs) = hexByte (fromEnum x) ++ toHex xs
hexByte :: Int -> String
hexByte n
Author: PHO <phonohawk at ps dot sakura dot ne dot jp>
Maintainer: PHO <phonohawk at ps dot sakura dot ne dot jp>
Stability: experimental
-Homepage: http://ccm.sherry.jp/Lucu/
+Homepage: http://cielonegro.org/Lucu
Category: Network
Tested-With: GHC == 6.8.1
Cabal-Version: >= 1.2
Library
Build-Depends:
- Crypto, base, bytestring, containers, dataenc, directory,
+ HsOpenSSL, base, bytestring, containers, dataenc, directory,
haskell-src, hxt, mtl, network, stm, time, unix, zlib
Exposed-Modules:
Network.HTTP.Lucu