ref: 660cf9275b8374f89c8f5db51a070070f28c1afc
dir: /lib/System/Compress.hs/
module System.Compress(compress) where import Prelude(); import MiniPrelude import Foreign.C.String import Foreign.C.Types import Foreign.Marshal.Alloc import Foreign.Marshal.Utils import Foreign.Ptr import Foreign.Storable import System.IO.Unsafe foreign import ccall "lz77c" c_lz77c :: CString -> CSize -> Ptr CString -> IO CSize -- This really ought to be [Word8] -> [Word8] compress :: String -> String compress file = unsafePerformIO $ do (iptr, ilen) <- newCAStringLen file pptr <- new nullPtr olen <- c_lz77c iptr (intToCSize ilen) pptr optr <- peek pptr res <- peekCAStringLen (optr, cSizeToInt olen) free iptr free optr return res