{-# LINE 1 "Data/Iteratee/ZLib.hsc" #-}{-# LANGUAGE CPP #-}{-# LINE 2 "Data/Iteratee/ZLib.hsc" #-}{-# LANGUAGE DeriveDataTypeable #-}{-# LANGUAGE ForeignFunctionInterface #-}{-# OPTIONS -Wall -fno-warn-unused-do-bind #-}moduleData.Iteratee.ZLib(-- * EnumerateesenumInflate,enumDeflate,-- * ExceptionsZLibParamsException(..),ZLibException(..),-- * ParametersCompressParams(..),defaultCompressParams,DecompressParams(..),defaultDecompressParams,Format(..),CompressionLevel(..),Method(..),WindowBits(..),MemoryLevel(..),CompressionStrategy(..),enumSyncFlush,enumFullFlush,enumBlockFlush,)where{-# LINE 31 "Data/Iteratee/ZLib.hsc" #-}importControl.ApplicativeimportControl.ExceptionimportControl.Monad.TransimportData.ByteStringasBSimportData.ByteString.InternalimportData.IterateeimportData.FoldableimportData.TypeableimportForeignimportForeign.C{-# LINE 47 "Data/Iteratee/ZLib.hsc" #-}-- | Denotes error is user-supplied parameterdataZLibParamsException=IncorrectCompressionLevel!Int-- ^ Incorrect compression level was chosen|IncorrectWindowBits!Int-- ^ Incorrect number of window bits was chosen|IncorrectMemoryLevel!Int-- ^ Incorrect memory level was chosenderiving(Eq,Typeable)-- | Denotes error in compression and decompressiondataZLibException=NeedDictionary-- ^ Decompression requires user-supplied dictionary (not supported)|BufferError-- ^ Buffer error - denotes a library error-- | File Error|StreamError-- ^ State of steam inconsistent|DataError-- ^ Input data corrupted|MemoryError-- ^ Not enough memory|VersionError-- ^ Version error|Unexpected!CInt-- ^ Unexpected or unknown error - please report as bug|IncorrectState-- ^ Incorrect state - denotes error in libraryderiving(Eq,Typeable)-- | Denotes the flush that can be sent to streamdataZlibFlush=SyncFlush-- ^ All pending output is flushed and all input that is available is sent-- to inner Iteratee.|FullFlush-- ^ Flush all pending output and reset the compression state. It allows to-- restart from this point if compression was damaged but it can seriously -- affect the compression rate.---- It may be only used during compression.|Block-- ^ If the iteratee is compressing it requests to stop when next block is-- emmited. On the beginning it skips only header if and only if it exists.deriving(Eq,Typeable)instanceShowZlibFlushwhereshowSyncFlush="zlib: flush requested"showFullFlush="zlib: full flush requested"showBlock="zlib: block flush requested"instanceExceptionZlibFlushfromFlush::ZlibFlush->CIntfromFlushSyncFlush=2{-# LINE 104 "Data/Iteratee/ZLib.hsc" #-}fromFlushFullFlush=3{-# LINE 105 "Data/Iteratee/ZLib.hsc" #-}fromFlushBlock=5{-# LINE 106 "Data/Iteratee/ZLib.hsc" #-}instanceShowZLibParamsExceptionwhereshow(IncorrectCompressionLevellvl)="zlib: incorrect compression level "++showlvlshow(IncorrectWindowBitslvl)="zlib: incorrect window bits "++showlvlshow(IncorrectMemoryLevellvl)="zlib: incorrect memory level "++showlvlinstanceShowZLibExceptionwhereshowNeedDictionary="zlib: needs dictionary"showBufferError="zlib: no progress is possible (internal error)"-- show FileError = "zlib: file I/O error"showStreamError="zlib: stream error"showDataError="zlib: data error"showMemoryError="zlib: memory error"showVersionError="zlib: version error"show(Unexpectedlvl)="zlib: unknown error "++showlvlshowIncorrectState="zlib: incorrect state"instanceExceptionZLibParamsExceptioninstanceExceptionZLibExceptionnewtypeZStream=ZStream(ForeignPtrZStream)withZStream::ZStream->(PtrZStream->IOa)->IOawithZStream(ZStreamfptr)=withForeignPtrfptr-- Following code is copied from Duncan Coutts zlib haskell library version-- 0.5.2.0 ((c) 2006-2008 Duncan Coutts, published on BSD licence) and adapted-- | Set of parameters for compression. For sane defaults use-- 'defaultCompressParams'dataCompressParams=CompressParams{compressLevel::!CompressionLevel,compressMethod::!Method,compressWindowBits::!WindowBits,compressMemoryLevel::!MemoryLevel,compressStrategy::!CompressionStrategy,-- | The size of output buffer. That is the size of 'Chunk's that will be-- emitted to inner iterator (except the last 'Chunk').compressBufferSize::!Int,compressDictionary::!(MaybeByteString)}defaultCompressParams::CompressParamsdefaultCompressParams=CompressParamsDefaultCompressionDeflatedDefaultWindowBitsDefaultMemoryLevelDefaultStrategy(8*1024)Nothing-- | Set of parameters for decompression. For sane defaults see -- 'defaultDecompressParams'.dataDecompressParams=DecompressParams{-- | Window size - it have to be at least the size of-- 'compressWindowBits' the stream was compressed with.---- Default in 'defaultDecompressParams' is the maximum window size - -- please do not touch it unless you know what you are doing.decompressWindowBits::!WindowBits,-- | The size of output buffer. That is the size of 'Chunk's that will be-- emitted to inner iterator (except the last 'Chunk').decompressBufferSize::!Int,decompressDictionary::!(MaybeByteString)}defaultDecompressParams::DecompressParamsdefaultDecompressParams=DecompressParamsDefaultWindowBits(8*1024)Nothing-- | Specify the format for compression and decompressiondataFormat=GZip-- ^ The gzip format is widely used and uses a header with checksum and-- some optional metadata about the compress file.---- It is intended primarily for compressing individual files but is also-- used for network protocols such as HTTP.---- The format is described in RFC 1952 -- <http://www.ietf.org/rfc/rfc1952.txt>.|Zlib-- ^ The zlib format uses a minimal header with a checksum but no other-- metadata. It is designed for use in network protocols.---- The format is described in RFC 1950-- <http://www.ietf.org/rfc/rfc1950.txt>|Raw-- ^ The \'raw\' format is just the DEFLATE compressed data stream without-- and additionl headers. ---- Thr format is described in RFC 1951-- <http://www.ietf.org/rfc/rfc1951.txt>|GZipOrZlib-- ^ "Format" for decompressing a 'Zlib' or 'GZip' stream.deriving(Eq)-- | The compression level specify the tradeoff between speed and compression.dataCompressionLevel=DefaultCompression-- ^ Default compression level set at 6.|NoCompression-- ^ No compression, just a block copy.|BestSpeed-- ^ The fastest compression method (however less compression)|BestCompression-- ^ The best compression method (however slowest)|CompressionLevelInt-- ^ Compression level set by number from 1 to 9-- | Specify the compression method.dataMethod=Deflated-- ^ \'Deflate\' is so far the only method supported. -- | This specify the size of compression level. Larger values result in better-- compression at the expense of highier memory usage.---- The compression window size is 2 to the power of the value of the window-- bits. ---- The total memory used depends on windows bits and 'MemoryLevel'.dataWindowBits=WindowBitsInt-- ^ The size of window bits. It have to be between @8@ (which corresponds-- to 256b i.e. 32B) and @15@ (which corresponds to 32 kib i.e. 4kiB).|DefaultWindowBits-- ^ The default window size which is 4kiB-- | The 'MemoryLevel' specifies how much memory should be allocated for the-- internal state. It is a tradeoff between memory usage, speed and-- compression.-- Using more memory allows faster and better compression.---- The memory used for interal state, excluding 'WindowBits', is 512 bits times-- 2 to power of memory level.---- The total amount of memory use depends on the 'WindowBits' and-- 'MemoryLevel'.dataMemoryLevel=DefaultMemoryLevel-- ^ Default memory level set to 8.|MinMemoryLevel-- ^ Use the small amount of memory (equivalent to memory level 1) - i.e.-- 1024b or 256 B.-- It slow and reduces the compresion ratio.|MaxMemoryLevel-- ^ Maximum memory level for optimal compression speed (equivalent to-- memory level 9).-- The internal state is 256kib or 32kiB.|MemoryLevelInt-- ^ A specific level. It have to be between 1 and 9. -- | Tunes the compress algorithm but does not affact the correctness.dataCompressionStrategy=DefaultStrategy-- ^ Default strategy|Filtered-- ^ Use the filtered compression strategy for data produced by a filter-- (or predictor). Filtered data consists mostly of small values with a-- somewhat random distribution. In this case, the compression algorithm-- is tuned to compress them better. The effect of this strategy is to-- force more Huffman coding and less string matching; it is somewhat-- intermediate between 'DefaultStrategy' and 'HuffmanOnly'.|HuffmanOnly-- ^ Use the Huffman-only compression strategy to force Huffman encoding-- only (no string match). fromMethod::Method->CIntfromMethodDeflated=8{-# LINE 274 "Data/Iteratee/ZLib.hsc" #-}fromCompressionLevel::CompressionLevel->EitherZLibParamsExceptionCIntfromCompressionLevelDefaultCompression=Right$!-1fromCompressionLevelNoCompression=Right$!0fromCompressionLevelBestSpeed=Right$!1fromCompressionLevelBestCompression=Right$!9fromCompressionLevel(CompressionLeveln)|n>=0&&n<=9=Right$!fromIntegral$!n|otherwise=Left$!IncorrectCompressionLevelnfromWindowBits::Format->WindowBits->EitherZLibParamsExceptionCIntfromWindowBitsformatbits=formatModifierformat<$>checkWindowBitsbitswherecheckWindowBitsDefaultWindowBits=Right$!15checkWindowBits(WindowBitsn)|n>=8&&n<=15=Right$!fromIntegral$!n|otherwise=Left$!IncorrectWindowBits$!nformatModifierZlib=idformatModifierGZip=(+16)formatModifierGZipOrZlib=(+32)formatModifierRaw=negatefromMemoryLevel::MemoryLevel->EitherZLibParamsExceptionCIntfromMemoryLevelDefaultMemoryLevel=Right$!8fromMemoryLevelMinMemoryLevel=Right$!1fromMemoryLevelMaxMemoryLevel=Right$!9fromMemoryLevel(MemoryLeveln)|n>=1&&n<=9=Right$!fromIntegraln|otherwise=Left$!IncorrectMemoryLevel$!fromIntegralnfromCompressionStrategy::CompressionStrategy->CIntfromCompressionStrategyDefaultStrategy=0{-# LINE 306 "Data/Iteratee/ZLib.hsc" #-}fromCompressionStrategyFiltered=1{-# LINE 307 "Data/Iteratee/ZLib.hsc" #-}fromCompressionStrategyHuffmanOnly=2{-# LINE 308 "Data/Iteratee/ZLib.hsc" #-}fromErrno::CInt->EitherZLibExceptionBoolfromErrno(0)=Right$!True{-# LINE 311 "Data/Iteratee/ZLib.hsc" #-}fromErrno(1)=Right$!False{-# LINE 312 "Data/Iteratee/ZLib.hsc" #-}fromErrno(2)=Left$!NeedDictionary{-# LINE 313 "Data/Iteratee/ZLib.hsc" #-}fromErrno(-5)=Left$!BufferError{-# LINE 314 "Data/Iteratee/ZLib.hsc" #-}--fromErrno (#{const Z_ERRNO}) = Left $! FileErrorfromErrno(-2)=Left$!StreamError{-# LINE 316 "Data/Iteratee/ZLib.hsc" #-}fromErrno(-3)=Left$!DataError{-# LINE 317 "Data/Iteratee/ZLib.hsc" #-}fromErrno(-4)=Left$!MemoryError{-# LINE 318 "Data/Iteratee/ZLib.hsc" #-}fromErrno(-6)=Left$!VersionError{-# LINE 319 "Data/Iteratee/ZLib.hsc" #-}fromErrnon=Left$!Unexpectedn-- Helper functionconvParam::Format->CompressParams->EitherZLibParamsException(CInt,CInt,CInt,CInt,CInt)convParamf(CompressParamscmwls__)=letc'=fromCompressionLevelcm'=fromMethodmb'=fromWindowBitsfwl'=fromMemoryLevells'=fromCompressionStrategyseit=eitherLeftr=Rightineit(\c_->eit(\b_->eit(\l_->r(c_,m',b_,l_,s'))l')b')c'---- In following code we go through 7 states. Some of the operations are-- 'deterministic' like 'insertOut' and some of them depends on input ('fill')-- or library call.---- (Finished)-- ^-- |-- |-- | finish-- |-- insertOut fill[1] |--- (Initial) -------------> (EmptyIn) -----------> (Finishing)-- ^ ^ | ^ |-- | run[2] | | | \------------------\-- | | | | |-- | | | \------------------\ |-- | run[1] | | flush[0] | |-- \------------------\ | | fill[0] | | fill[3]-- | | | | |-- | | | | |-- swapOut | | v flush[1] | v-- (FullOut) -------------> (Invalid) <----------- (Flushing)---- Initial: Initial state, both buffers are empty-- EmptyIn: Empty in buffer, out waits untill filled-- FullOut: Out was filled and sent. In was not entirely read-- Invalid[1]: Both buffers non-empty-- Finishing: There is no more in data and in buffer is empty. Waits till-- all outs was sent.-- Finished: Operation finished-- Flushing: Flush requested-- -- Please note that the decompressing can finish also on flush and finish.---- [1] Named for 'historical' reasonsnewtypeInitial=InitialZStreamdataEmptyIn=EmptyIn!ZStream!ByteStringdataFullOut=FullOut!ZStream!ByteStringdataInvalid=Invalid!ZStream!ByteString!ByteStringdataFinishing=Finishing!ZStream!ByteStringdataFlushing=Flushing!ZStream!ZlibFlush!ByteStringwithByteString::ByteString->(PtrWord8->Int->IOa)->IOawithByteString(PSptrofflen)f=withForeignPtrptr(\ptr'->f(ptr'`plusPtr`off)len){-# LINE 411 "Data/Iteratee/ZLib.hsc" #-}mkByteString::MonadIOm=>Int->mByteStringmkByteStrings=liftIO$creates(\_->return()){-# LINE 414 "Data/Iteratee/ZLib.hsc" #-}putOutBuffer::Int->ZStream->IOByteStringputOutBuffersizezstr=do_out<-mkByteStringsizewithByteString_out$\ptrlen->withZStreamzstr$\zptr->do(\hsc_ptr->pokeByteOffhsc_ptr12)zptrptr{-# LINE 420 "Data/Iteratee/ZLib.hsc" #-}(\hsc_ptr->pokeByteOffhsc_ptr16)zptrlen{-# LINE 421 "Data/Iteratee/ZLib.hsc" #-}return_outputInBuffer::ZStream->ByteString->IO()putInBufferzstr_in=withByteString_in$\ptrlen->withZStreamzstr$\zptr->do(\hsc_ptr->pokeByteOffhsc_ptr0)zptrptr{-# LINE 427 "Data/Iteratee/ZLib.hsc" #-}(\hsc_ptr->pokeByteOffhsc_ptr4)zptrlen{-# LINE 428 "Data/Iteratee/ZLib.hsc" #-}pullOutBuffer::ZStream->ByteString->IOByteStringpullOutBufferzstr_out=withByteString_out$\ptr_->donext_out<-withZStreamzstr$\zptr->(\hsc_ptr->peekByteOffhsc_ptr12)zptr{-# LINE 432 "Data/Iteratee/ZLib.hsc" #-}return$!BS.take(next_out`minusPtr`ptr)_outpullInBuffer::ZStream->ByteString->IOByteStringpullInBufferzstr_in=withByteString_in$\ptr_->donext_in<-withZStreamzstr$\zptr->(\hsc_ptr->peekByteOffhsc_ptr0)zptr{-# LINE 437 "Data/Iteratee/ZLib.hsc" #-}return$!BS.drop(next_in`minusPtr`ptr)_ininsertOut::MonadIOm=>Int->(ZStream->CInt->IOCInt)->Initial->EnumerateeByteStringByteStringmainsertOutsizerunf(Initialzstr)iter=do_out<-liftIO$putOutBuffersizezstr{-# LINE 449 "Data/Iteratee/ZLib.hsc" #-}fillsizerunf(EmptyInzstr_out)iterfill::MonadIOm=>Int->(ZStream->CInt->IOCInt)->EmptyIn->EnumerateeByteStringByteStringmafillsizerun'(EmptyInzstr_out)iter=letfill'(Chunk_in)|not(BS.null_in)=doliftIO$putInBufferzstr_in{-# LINE 464 "Data/Iteratee/ZLib.hsc" #-}doRunsizerun'(Invalidzstr_in_out)iter|otherwise=fillIfill'(EOFNothing)=doout<-liftIO$pullOutBufferzstr_outiter'<-lift$enumPure1Chunkoutiterfinishsizerun'(FinishingzstrBS.empty)iter'fill'(EOF(Justerr))=casefromExceptionerrofJusterr'->flushsizerun'(Flushingzstrerr'_out)iterNothing->throwRecoverableErrerrfill'{-# LINE 479 "Data/Iteratee/ZLib.hsc" #-}fillI=liftIfill'{-# LINE 481 "Data/Iteratee/ZLib.hsc" #-}infillIswapOut::MonadIOm=>Int->(ZStream->CInt->IOCInt)->FullOut->EnumerateeByteStringByteStringmaswapOutsizerun'(FullOutzstr_in)iter=do_out<-liftIO$putOutBuffersizezstr{-# LINE 493 "Data/Iteratee/ZLib.hsc" #-}doRunsizerun'(Invalidzstr_in_out)iterdoRun::MonadIOm=>Int->(ZStream->CInt->IOCInt)->Invalid->EnumerateeByteStringByteStringmadoRunsizerun'(Invalidzstr_in_out)iter=do{-# LINE 505 "Data/Iteratee/ZLib.hsc" #-}status<-liftIO$run'zstr0{-# LINE 506 "Data/Iteratee/ZLib.hsc" #-}{-# LINE 509 "Data/Iteratee/ZLib.hsc" #-}casefromErrnostatusofLefterr->do_<-joinIM$enumErrerriterthrowErr(toExceptionerr)RightFalse->do-- End of streamremaining<-liftIO$pullInBufferzstr_inout<-liftIO$pullOutBufferzstr_outiter'<-lift$enumPure1Chunkoutiteridoneiter'(Chunkremaining)RightTrue->do-- Continue(avail_in,avail_out)<-liftIO$withZStreamzstr$\zptr->doavail_in<-liftIO$(\hsc_ptr->peekByteOffhsc_ptr4)zptr{-# LINE 521 "Data/Iteratee/ZLib.hsc" #-}avail_out<-liftIO$(\hsc_ptr->peekByteOffhsc_ptr16)zptr{-# LINE 522 "Data/Iteratee/ZLib.hsc" #-}return(avail_in,avail_out)::IO(CInt,CInt)caseavail_outof0->doout<-liftIO$pullOutBufferzstr_outiter'<-lift$enumPure1Chunkoutitercaseavail_inof0->insertOutsizerun'(Initialzstr)iter'_->swapOutsizerun'(FullOutzstr_in)iter'_->caseavail_inof0->fillsizerun'(EmptyInzstr_out)iter_->do_<-joinIM$enumErrIncorrectStateiterthrowErr(toExceptionIncorrectState)flush::MonadIOm=>Int->(ZStream->CInt->IOCInt)->Flushing->EnumerateeByteStringByteStringmaflushsizerun'(Flushingzstr_flush_out)iter=dostatus<-liftIO$run'zstr(fromFlush_flush)casefromErrnostatusofLefterr->do_<-joinIM$enumErrerriterthrowErr(toExceptionerr)RightFalse->do-- Finishedout<-liftIO$pullOutBufferzstr_outiter'<-lift$enumPure1Chunkoutiteridoneiter'(ChunkBS.empty)RightTrue->do-- TODO: avail_in is unused, can it be completely removed?-- or should it be used?(_avail_in,avail_out)<-liftIO$withZStreamzstr$\zptr->doavail_in<-liftIO$(\hsc_ptr->peekByteOffhsc_ptr4)zptr{-# LINE 556 "Data/Iteratee/ZLib.hsc" #-}avail_out<-liftIO$(\hsc_ptr->peekByteOffhsc_ptr16)zptr{-# LINE 557 "Data/Iteratee/ZLib.hsc" #-}return(avail_in,avail_out)::IO(CInt,CInt)caseavail_outof0->doout<-liftIO$pullOutBufferzstr_outiter'<-lift$enumPure1Chunkoutiterout'<-liftIO$putOutBuffersizezstrflushsizerun'(Flushingzstr_flushout')iter'_->insertOutsizerun'(Initialzstr)iterfinish::MonadIOm=>Int->(ZStream->CInt->IOCInt)->Finishing->EnumerateeByteStringByteStringmafinishsizerun'fin@(Finishingzstr_in)iter=do{-# LINE 576 "Data/Iteratee/ZLib.hsc" #-}_out<-liftIO$putOutBuffersizezstrstatus<-liftIO$run'zstr4{-# LINE 578 "Data/Iteratee/ZLib.hsc" #-}casefromErrnostatusofLefterr->do_<-lift$enumErrerriterthrowErr(toExceptionerr)RightFalse->do-- Finishedremaining<-liftIO$pullInBufferzstr_inout<-liftIO$pullOutBufferzstr_outiter'<-lift$enumPure1Chunkoutiteridoneiter'(Chunkremaining)RightTrue->do-- TODO: avail_in is unused, is this an error or can it be removed?(_avail_in,avail_out)<-liftIO$withZStreamzstr$\zptr->doavail_in<-liftIO$(\hsc_ptr->peekByteOffhsc_ptr4)zptr{-# LINE 591 "Data/Iteratee/ZLib.hsc" #-}avail_out<-liftIO$(\hsc_ptr->peekByteOffhsc_ptr16)zptr{-# LINE 592 "Data/Iteratee/ZLib.hsc" #-}return(avail_in,avail_out)::IO(CInt,CInt)caseavail_outof0->doout<-liftIO$pullOutBufferzstr_outiter'<-lift$enumPure1Chunkoutiterfinishsizerun'finiter'_->do_<-lift$enumErr(toExceptionIncorrectState)iterthrowErr$!toExceptionIncorrectStateforeignimportccallunsafedeflateInit2_::PtrZStream->CInt->CInt->CInt->CInt->CInt->CString->CInt->IOCIntforeignimportccallunsafeinflateInit2_::PtrZStream->CInt->CString->CInt->IOCIntforeignimportccallunsafeinflate::PtrZStream->CInt->IOCIntforeignimportccallunsafedeflate::PtrZStream->CInt->IOCIntforeignimportccallunsafe"&deflateEnd"deflateEnd::FunPtr(PtrZStream->IO())foreignimportccallunsafe"&inflateEnd"inflateEnd::FunPtr(PtrZStream->IO())foreignimportccallunsafedeflateSetDictionary::PtrZStream->PtrWord8->CUInt->IOCIntforeignimportccallunsafeinflateSetDictionary::PtrZStream->PtrWord8->CUInt->IOCIntdeflateInit2::PtrZStream->CInt->CInt->CInt->CInt->CInt->IOCIntdeflateInit2slmwBmLs'=withCString"1.2.7"$\v->{-# LINE 621 "Data/Iteratee/ZLib.hsc" #-}deflateInit2_slmwBmLs'v(56){-# LINE 622 "Data/Iteratee/ZLib.hsc" #-}inflateInit2::PtrZStream->CInt->IOCIntinflateInit2swB=withCString"1.2.7"$\v->{-# LINE 626 "Data/Iteratee/ZLib.hsc" #-}inflateInit2_swBv(56){-# LINE 627 "Data/Iteratee/ZLib.hsc" #-}{-# LINE 639 "Data/Iteratee/ZLib.hsc" #-}deflate'::ZStream->CInt->IOCIntdeflate'zf=withZStreamz$\p->deflatepfinflate'::ZStream->CInt->IOCIntinflate'zf=withZStreamz$\p->inflatepf{-# LINE 645 "Data/Iteratee/ZLib.hsc" #-}mkCompress::Format->CompressParams->IO(EitherZLibParamsExceptionInitial)mkCompressfrmcp=caseconvParamfrmcpofLefterr->return$!LefterrRight(c,m,b,l,s)->dozstr<-mallocForeignPtrBytes(56){-# LINE 653 "Data/Iteratee/ZLib.hsc" #-}withForeignPtrzstr$\zptr->domemset(castPtrzptr)0(56){-# LINE 655 "Data/Iteratee/ZLib.hsc" #-}deflateInit2zptrcmbls`finally`addForeignPtrFinalizerdeflateEndzstrfor_(compressDictionarycp)$\(PSfpofflen)->withForeignPtrfp$\ptr->deflateSetDictionaryzptr(ptr`plusPtr`off)(fromIntegrallen)return$!Right$!Initial$ZStreamzstrmkDecompress::Format->DecompressParams->IO(EitherZLibParamsException(Initial,MaybeByteString))mkDecompressfrm(DecompressParamsw_md)=casefromWindowBitsfrmwofLefterr->return$!LefterrRightwB'->dozstr<-mallocForeignPtrBytes(56){-# LINE 670 "Data/Iteratee/ZLib.hsc" #-}v<-withForeignPtrzstr$\zptr->domemset(castPtrzptr)0(56){-# LINE 672 "Data/Iteratee/ZLib.hsc" #-}inflateInit2zptrwB'`finally`addForeignPtrFinalizerinflateEndzstrcase(md,frm)of(Just(PSfpofflen),Raw)->dowithForeignPtrfp$\ptr->inflateSetDictionaryzptr(ptr`plusPtr`off)(fromIntegrallen)return$!Nothing(Nothing,_)->return$!Nothing(Justbs,_)->return$!(Justbs)return$!Right$!(Initial$ZStreamzstr,v)-- User-related code-- | Compress the input and send to inner iteratee.enumDeflate::MonadIOm=>Format-- ^ Format of input->CompressParams-- ^ Parameters of compression->EnumerateeByteStringByteStringmaenumDeflatefcp@(CompressParams_____size_)iter=docmp<-liftIO$mkCompressfcpcasecmpofLefterr->do_<-lift$enumErrerriterthrowErr(toExceptionerr)Rightinit'->insertOutsizedeflate'init'iter-- | Decompress the input and send to inner iteratee. If there is end of-- zlib stream it is left unprocessed.enumInflate::MonadIOm=>Format->DecompressParams->EnumerateeByteStringByteStringmaenumInflatefdp@(DecompressParams_size_md)iter=dodcmp<-liftIO$mkDecompressfdpcasedcmpofLefterr->do_<-lift$enumErrerriterthrowErr(toExceptionerr)Right(init',Nothing)->insertOutsizeinflate'init'iterRight(init',(Just(PSfpofflen)))->letinflate''zstrparam=doret<-inflate'zstrparamcasefromErrnoretofLeftNeedDictionary->dowithForeignPtrfp$\ptr->withZStreamzstr$\zptr->inflateSetDictionaryzptr(ptr`plusPtr`off)(fromIntegrallen)inflate'zstrparam_->returnretininsertOutsizeinflate''init'iterenumSyncFlush::Monadm=>EnumeratorByteStringma-- ^ Enumerate synchronise flush. It cause the all pending output to be flushed-- and all available input is sent to inner Iteratee.enumSyncFlush=enumErrSyncFlushenumFullFlush::Monadm=>EnumeratorByteStringma-- ^ Enumerate full flush. It flushes all pending output and reset the-- compression. It allows to restart from this point if compressed data was-- corrupted but it can affect the compression rate.---- It may be only used during compression.enumFullFlush=enumErrFullFlushenumBlockFlush::Monadm=>EnumeratorByteStringma-- ^ Enumerate block flush. If the enumerator is compressing it allows to-- finish current block. If the enumerator is decompressing it forces to stop -- on next block boundary.enumBlockFlush=enumErrBlock