207 lines · 4.0 KB · Text
RawDownload
.TH FLATE 2.SH NAMEdeflateinit, deflate, deflatezlib, deflateblock, deflatezlibblock, inflateinit, inflate, inflatezlib, inflateblock, inflatezlibblock, flateerr, mkcrctab, blockcrc, adler32 \- deflate compression.SH SYNOPSIS.B #include <u.h>.br.B #include <libc.h>.br.B #include <flate.h>.PP.ta \w'ulongmm'u.PP.Bint	deflateinit(void).PP.Bint	deflate(void *wr, int (*w)(void*,void*,int),.br.B	void *rr, int (*r)(void*,void*,int),.br.B	int level, int debug).PP.Bint	deflatezlib(void *wr, int (*w)(void*,void*,int),.br.B	void *rr, int (*r)(void*,void*,int),.br.B	int level, int debug).PP.Bint	deflateblock(uchar *dst, int dsize,.br.B	uchar *src, int ssize,.br.B	int level, int debug).PP.Bint	deflatezlibblock(uchar *dst, int dsize,.br.B	uchar *src, int ssize,.br.B	int level, int debug).PP.Bint	inflateinit(void).PP.Bint	inflate(void *wr, int (*w)(void*, void*, int),.br.B	void *getr, int (*get)(void*)).PP.Bint	inflatezlib(void *wr, int (*w)(void*, void*, int),.br.B	void *getr, int (*get)(void*)).PP.Bint	inflateblock(uchar *dst, int dsize,.br.B	uchar *src, int ssize).PP.Bint	inflatezlibblock(uchar *dst, int dsize,.br.B	uchar *src, int ssize).PP.Bchar	*flateerr(int error).PP.Bulong	*mkcrctab(ulong poly).PP.Bulong	blockcrc(ulong *tab, ulong crc, void *buf, int n).PP.Bulong	adler32(ulong adler, void *buf, int n).SH DESCRIPTIONThese routines compress and decompress data using the deflate compression algorithm,which is used for most gzip, zip, and zlib files..PP.I Deflatecompresses input data retrieved by calls to.I rwith arguments.IR rr ,an input buffer, and a count of bytes to read..I Rshould return the number of bytes read;end of input is signaled by returning zero, an input error byreturning a negative number.The compressed output is written to.I wwith arguments.IR wr ,the output data, and the number of bytes to write..I Wshould return the number of bytes written;writing fewer than the requested number of bytes is an error..I Levelindicates the amount of computation deflate should do while compressing the data.Higher.I levelsusually take more time and produce smaller outputs.Valid values are 1 to 9, inclusive; 6 is a good compromise.If.I debugis non-zero, cryptic debugging information is produced on standard error..PP.I Inflatereverses the process, converting compressed data into uncompressed output.Input is retrieved one byte at a time by calling.I getwith the argument.IR getr .End of input of signaled by returning a negative value.The uncompressed output is written to.IR w ,which has the same interface as for.IR deflate ..PP.IDeflateblockand.I inflateblockoperate on blocks of memory but are otherwise similar to.I deflateand.IR inflate ..PPThe zlib functions are similar, but operate on files with a zlib header and trailer..PP.I Deflateinitor.I inflateinitmust be called once before any call to the corresponding routines..PPIf the above routines fail,they return a negative number indicating the problem.The possible values are.IR FlateNoMem ,.IR FlateInputFail ,.IR FlateOutputFail ,.IR FlateCorrupted ,and .IR FlateInternal ..I Flateerrconverts the number into a printable message..I FlateOkis defined to be zero,the successful return value for.IR deflateinit ,.IR deflate ,.IR deflatezlib ,.IR inflateinit ,.IR inflate ,and .IR inflatezlib .The block functions return the number of bytes produced when they succeed..PP.I Mkcrctaballocates(using.IR malloc (2)),initializes, and returns a table for rapid computation of 32 bit CRC values using the polynomial.IR poly ..I Blockcrcuses.IR tab ,a table returned by.IR mkcrctab ,to update.I crcfor the.I nbytes of data in.IR buf ,and returns the new value..I Crcshould initially be zero..I Blockcrcpre-conditions and post-conditions.I crcby ones complementation..PP.I Adler32updates the Adler 32-bit checksum of the.I nbutes of data in.IR buf.The initial value of.I adler(that is, its value after seeing zero bytes) should be 1..SH SOURCE.B /sys/src/libflate