]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - ImplantFile.hs
Doc fix, optimization, and more.
[Lucu.git] / ImplantFile.hs
index 29c11450deab634a6a0c3c0b5d72637f51fecb92..a16c76ec8bee3eb9331cdf9c42a24b99facd99ec 100644 (file)
@@ -2,7 +2,7 @@ import           Codec.Binary.Base64
 import           Codec.Compression.GZip
 import           Control.Monad
 import           Data.Bits
-import           Data.ByteString.Lazy (ByteString)
+import           Data.ByteString.Base (LazyByteString)
 import qualified Data.ByteString.Lazy as L
 import           Data.Char
 import           Data.Digest.SHA1
@@ -117,8 +117,8 @@ generateHaskellSource opts srcFile
              exports  = [HsEVar (UnQual (HsIdent symName))]
              imports  = [ HsImportDecl undefined (Module "Codec.Binary.Base64")
                                        False Nothing Nothing
-                        , HsImportDecl undefined (Module "Data.ByteString.Lazy")
-                                       False Nothing (Just (False, [HsIVar (HsIdent "ByteString")]))
+                        , HsImportDecl undefined (Module "Data.ByteString.Base")
+                                       False Nothing (Just (False, [HsIVar (HsIdent "LazyByteString")]))
                         , HsImportDecl undefined (Module "Data.ByteString.Lazy")
                                        True (Just (Module "L")) Nothing
                         , HsImportDecl undefined (Module "Network.HTTP.Lucu")
@@ -207,7 +207,7 @@ generateHaskellSource opts srcFile
                                    expOutputGunzipped
                                    expOutputGZipped)
                        expOutputGunzipped
-                           = (HsApp (HsVar (UnQual (HsIdent "outputBS")))
+                           = (HsApp (HsVar (UnQual (HsIdent "outputLBS")))
                               (HsParen
                                (HsApp (HsVar (UnQual (HsIdent "decompress")))
                                       (HsVar (UnQual (HsIdent "gzippedData"))))))
@@ -219,7 +219,7 @@ generateHaskellSource opts srcFile
                            = HsQualifier (HsApp (HsVar (UnQual (HsIdent "setContentEncoding")))
                                           (HsList [HsLit (HsString "gzip")]))
                        doOutputGZipped
-                           = HsQualifier (HsApp (HsVar (UnQual (HsIdent "outputBS")))
+                           = HsQualifier (HsApp (HsVar (UnQual (HsIdent "outputLBS")))
                                           (HsVar (UnQual (HsIdent "gzippedData"))))
                    in 
                      HsApp (HsCon (UnQual (HsIdent "Just")))
@@ -239,7 +239,7 @@ generateHaskellSource opts srcFile
                            = HsQualifier (HsApp (HsVar (UnQual (HsIdent "setContentType")))
                                           (HsVar (UnQual (HsIdent "contentType"))))
                        doOutputRawData
-                           = HsQualifier (HsApp (HsVar (UnQual (HsIdent "outputBS")))
+                           = HsQualifier (HsApp (HsVar (UnQual (HsIdent "outputLBS")))
                                           (HsVar (UnQual (HsIdent "rawData"))))
                    in
                      HsApp (HsCon (UnQual (HsIdent "Just")))
@@ -295,7 +295,7 @@ generateHaskellSource opts srcFile
              declGZippedData 
                  = [ HsTypeSig undefined [HsIdent "gzippedData"]
                                (HsQualType []
-                                (HsTyCon (UnQual (HsIdent "ByteString"))))
+                                (HsTyCon (UnQual (HsIdent "LazyByteString"))))
                    , HsFunBind [HsMatch undefined (HsIdent "gzippedData")
                                 [] (HsUnGuardedRhs defGZippedData) []]
                    ]
@@ -311,7 +311,7 @@ generateHaskellSource opts srcFile
              declRawData 
                  = [ HsTypeSig undefined [HsIdent "rawData"]
                                (HsQualType []
-                                (HsTyCon (UnQual (HsIdent "ByteString"))))
+                                (HsTyCon (UnQual (HsIdent "LazyByteString"))))
                    , HsFunBind [HsMatch undefined (HsIdent "rawData")
                                 [] (HsUnGuardedRhs defRawData) []]
                    ]
@@ -397,7 +397,7 @@ getLastModified "-"   = getClockTime
 getLastModified fpath = getModificationTime fpath
 
 
-getETag :: [CmdOpt] -> ByteString -> IO String
+getETag :: [CmdOpt] -> LazyByteString -> IO String
 getETag opts input
     = let eTagOpts = filter (\ x -> case x of
                                       OptETag _ -> True
@@ -425,7 +425,7 @@ getETag opts input
           | n < 16 = (chr $ ord 'a' + n - 10)
 
 
-openInput :: FilePath -> IO ByteString
+openInput :: FilePath -> IO LazyByteString
 openInput "-"   = L.getContents
 openInput fpath = L.readFile fpath
 
@@ -458,7 +458,7 @@ openOutput opts
    -}
   module Foo.Bar.Baz (baz) where
   import Codec.Binary.Base64
-  import Data.ByteString.Lazy (ByteString)
+  import Data.ByteString.Base (LazyByteString)
   import qualified Data.ByteString.Lazy as L
   import Network.HTTP.Lucu
   import System.Time
@@ -470,7 +470,7 @@ openOutput opts
         , resGet
             = Just (do foundEntity entityTag lastModified
                        setContentType contentType
-                       outputBS rawData)
+                       outputLBS rawData)
         , resHead   = Nothing
         , resPost   = Nothing
         , resPut    = Nothing
@@ -486,7 +486,7 @@ openOutput opts
   contentType :: MIMEType
   contentType = read "image/png"
 
-  rawData :: ByteString
+  rawData :: LazyByteString
   rawData = L.pack (decode "IyEvdXNyL2Jpbi9lbnYgcnVuZ2hjCgppbXBvcnQgRGlzdHJ...")
   ------------------------------------------------------------------------------
 
@@ -507,10 +507,10 @@ openOutput opts
 
                        mustGunzip <- liftM not (isEncodingAcceptable "gzip")
                        if mustGunzip then
-                           outputBS (decompress gzippedData)
+                           outputLBS (decompress gzippedData)
                          else
                            do setContentEncoding ["gzip"]
-                              outputBS gzippedData
+                              outputLBS gzippedData
         , resHead   = Nothing
         , resPost   = Nothing
         , resPut    = Nothing
@@ -518,7 +518,7 @@ openOutput opts
         }
   
   -- rawData の代はりに gzippedData
-  gzippedData :: ByteString
+  gzippedData :: LazyByteString
   gzippedData = L.pack (decode "Otb/+DniOlRgAAAAYAAAAGAAAAB/6QOmToAEIGAAAAB...")
   ------------------------------------------------------------------------------
  -}