glenda.party
term% ls -F
term% cat index.txt
FLATE(2)                      System Calls Manual                     FLATE(2)



NAME
       deflateinit,  deflate, deflatezlib, deflateblock, deflatezlibblock, in‐
       flateinit, inflate, inflatezlib, inflateblock,  inflatezlibblock,  fla‐
       teerr, mkcrctab, blockcrc, adler32 - deflate compression

SYNOPSIS
       #include <u.h>
       #include <libc.h>
       #include <flate.h>

       int    deflateinit(void)

       int    deflate(void *wr, int (*w)(void*,void*,int),
              void *rr, int (*r)(void*,void*,int),
              int level, int debug)

       int    deflatezlib(void *wr, int (*w)(void*,void*,int),
              void *rr, int (*r)(void*,void*,int),
              int level, int debug)

       int    deflateblock(uchar *dst, int dsize,
              uchar *src, int ssize,
              int level, int debug)

       int    deflatezlibblock(uchar *dst, int dsize,
              uchar *src, int ssize,
              int level, int debug)

       int    inflateinit(void)

       int    inflate(void *wr, int (*w)(void*, void*, int),
              void *getr, int (*get)(void*))

       int    inflatezlib(void *wr, int (*w)(void*, void*, int),
              void *getr, int (*get)(void*))

       int    inflateblock(uchar *dst, int dsize,
              uchar *src, int ssize)

       int    inflatezlibblock(uchar *dst, int dsize,
              uchar *src, int ssize)

       char   *flateerr(int error)

       ulong  *mkcrctab(ulong poly)

       ulong  blockcrc(ulong *tab, ulong crc, void *buf, int n)

       ulong  adler32(ulong adler, void *buf, int n)

DESCRIPTION
       These  routines compress and decompress data using the deflate compres‐
       sion algorithm, which is used for most gzip, zip, and zlib files.

       Deflate compresses input data retrieved by calls to  r  with  arguments
       rr, an input buffer, and a count of bytes to read.  R should return the
       number of bytes read; end of input is signaled by  returning  zero,  an
       input  error  by returning a negative number.  The compressed output is
       written to w with arguments wr, the output  data,  and  the  number  of
       bytes  to  write.  W should return the number of bytes written; writing
       fewer than the requested number of bytes is an error.  Level  indicates
       the amount of computation deflate should do while compressing the data.
       Higher levels usually take  more  time  and  produce  smaller  outputs.
       Valid  values  are 1 to 9, inclusive; 6 is a good compromise.  If debug
       is non-zero, cryptic debugging information is produced on standard  er‐
       ror.

       Inflate  reverses  the  process, converting compressed data into uncom‐
       pressed output.  Input is retrieved one byte at a time by  calling  get
       with  the argument getr.  End of input of signaled by returning a nega‐
       tive value.  The uncompressed output is written to  w,  which  has  the
       same interface as for deflate.

       Deflateblock  and inflateblock operate on blocks of memory but are oth‐
       erwise similar to deflate and inflate.

       The zlib functions are similar, but operate on files with a zlib header
       and trailer.

       Deflateinit  or  inflateinit must be called once before any call to the
       corresponding routines.

       If the above routines fail, they return a  negative  number  indicating
       the  problem.  The possible values are FlateNoMem, FlateInputFail, Fla‐
       teOutputFail, FlateCorrupted, and FlateInternal.  Flateerr converts the
       number  into  a  printable message.  FlateOk is defined to be zero, the
       successful return value  for  deflateinit,  deflate,  deflatezlib,  in‐
       flateinit,  inflate,  and  inflatezlib.  The block functions return the
       number of bytes produced when they succeed.

       Mkcrctab allocates (using malloc(2)), initializes, and returns a  table
       for  rapid  computation of 32 bit CRC values using the polynomial poly.
       Blockcrc uses tab, a table returned by mkcrctab, to update crc for  the
       n  bytes  of  data  in buf, and returns the new value.  Crc should ini‐
       tially be zero.  Blockcrc pre-conditions  and  post-conditions  crc  by
       ones complementation.

       Adler32  updates  the  Adler  32-bit checksum of the n butes of data in
       buf.  The initial value of adler (that is, its value after seeing  zero
       bytes) should be 1.

SOURCE
       /sys/src/libflate



                                                                      FLATE(2)