X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=ImplantFile.hs;h=8ba976d681f95d6c31fe9dbe17aa4c86d23826fe;hb=ee292ed7f669b5f49fcdf035389fedf7d8742621;hp=26be80e73e7dcd109160dcfe68be812ff4c66af2;hpb=3d017dd65ddede9a11c5b7a34a91e04340e67bc4;p=Lucu.git diff --git a/ImplantFile.hs b/ImplantFile.hs index 26be80e..8ba976d 100644 --- a/ImplantFile.hs +++ b/ImplantFile.hs @@ -5,7 +5,7 @@ import Data.Bits import qualified Data.ByteString.Lazy as Lazy (ByteString) import qualified Data.ByteString.Lazy as L hiding (ByteString) import Data.Char -import Data.Digest.SHA1 +import Data.Digest.SHA2 import Data.Int import Data.Maybe import Data.Time @@ -120,6 +120,8 @@ generateHaskellSource opts srcFile False Nothing Nothing , HsImportDecl undefined (Module "Data.ByteString.Lazy") True (Just (Module "L")) Nothing + , HsImportDecl undefined (Module "Data.Maybe") + False Nothing Nothing , HsImportDecl undefined (Module "Data.Time") False Nothing Nothing , HsImportDecl undefined (Module "Network.HTTP.Lucu") @@ -300,8 +302,10 @@ generateHaskellSource opts srcFile defGZippedData = HsApp (HsVar (Qual (Module "L") (HsIdent "pack"))) (HsParen - (HsApp (HsVar (UnQual (HsIdent "decode"))) - (HsLit (HsString gzippedB64)))) + (HsApp (HsVar (UnQual (HsIdent "fromJust"))) + (HsParen + (HsApp (HsVar (UnQual (HsIdent "decode"))) + (HsLit (HsString gzippedB64)))))) declRawData :: [HsDecl] declRawData @@ -316,8 +320,10 @@ generateHaskellSource opts srcFile defRawData = HsApp (HsVar (Qual (Module "L") (HsIdent "pack"))) (HsParen - (HsApp (HsVar (UnQual (HsIdent "decode"))) - (HsLit (HsString rawB64)))) + (HsApp (HsVar (UnQual (HsIdent "fromJust"))) + (HsParen + (HsApp (HsVar (UnQual (HsIdent "decode"))) + (HsLit (HsString rawB64)))))) hPutStrLn output header hPutStrLn output (prettyPrint hsModule) @@ -393,7 +399,7 @@ getMIMEType opts srcFile getLastModified :: FilePath -> IO UTCTime getLastModified "-" = getCurrentTime getLastModified fpath = getFileStatus fpath - >>= return . posixSecondsToUTCTime . toEnum . fromEnum . modificationTime + >>= return . posixSecondsToUTCTime . fromRational . toRational . modificationTime getETag :: [CmdOpt] -> Lazy.ByteString -> IO String @@ -408,7 +414,7 @@ getETag opts input _ -> error "too many --etag options." where mkETagFromInput :: String - mkETagFromInput = "SHA-1:" ++ (toHex $ hash $ L.unpack input) + mkETagFromInput = "SHA-1:" ++ (toHex $ toOctets $ sha256 $ L.unpack input) toHex :: [Word8] -> String toHex [] = "" @@ -459,6 +465,7 @@ openOutput opts module Foo.Bar.Baz (baz) where import Codec.Binary.Base64 import qualified Data.ByteString.Lazy as L + import Data.Maybe import Data.Time import Network.HTTP.Lucu @@ -486,7 +493,7 @@ openOutput opts contentType = read "image/png" rawData :: L.ByteString - rawData = L.pack (decode "IyEvdXNyL2Jpbi9lbnYgcnVuZ2hjCgppbXBvcnQgRGlzdHJ...") + rawData = L.pack (fromJust (decode "IyEvdXNyL2Jpbi9lbnYgcnVuZ2hjCgppbXBvcnQgRGlzdHJ...")) ------------------------------------------------------------------------------ 壓縮される場合は次のやうに變はる: @@ -518,6 +525,6 @@ openOutput opts -- rawData の代はりに gzippedData gzippedData :: L.ByteString - gzippedData = L.pack (decode "Otb/+DniOlRgAAAAYAAAAGAAAAB/6QOmToAEIGAAAAB...") + gzippedData = L.pack (fromJust (decode "Otb/+DniOlRgAAAAYAAAAGAAAAB/6QOmToAEIGAAAAB...")) ------------------------------------------------------------------------------ -}