123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051(*
* Copyright (c) 2013-2017 Thomas Gazagnaire <thomas@gazagnaire.org>
* and Romain Calascibetta <romain.calascibetta@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)openDecompressmoduleInflate=Zlib_inflatetypet=(Buffer.Bigstring.t,Buffer.Bigstring.t)Inflate.ttypeerror=[`InflateofInflate.error]typewindow=(Buffer.Bigstring.t,Window.adler32)Window.tletsrc=Logs.Src.create"decompress.inflate"~doc:"logs inflate event"moduleLog=(valLogs.src_logsrc:Logs.LOG)letpp_error:errorFmt.t=funppf->function|`Inflateerr->Fmt.pfppf"(`Inflate %a)"(Fmt.hvboxInflate.pp_error)errletpp:tFmt.t=Inflate.ppletwindow_reset:window->window=Window.resetletwindow()=Window.create~crc:Window.adler32~witness:Buffer.bigstringletdefault:window->t=funw->Inflate.default~witness:Buffer.bigstringwleteval~src~dstt:[`Awaitoft|`Endoft|`Erroroft*error|`Flushoft]=letsrc'=Cstruct.to_bigarraysrcinletdst'=Cstruct.to_bigarraydstinInflate.evalsrc'dst't|>function|`Error(t,err)->`Error(t,`Inflateerr)|(`Await_|`Flush_|`End_)asx->xletused_in:t->int=Inflate.used_inletused_out:t->int=Inflate.used_outletwrite:t->int=Inflate.writeletflush:int->int->t->t=Inflate.flushletrefill:int->int->t->t=Inflate.refill