annotate src/zlib-1.2.8/contrib/blast/blast.h @ 43:5ea0608b923f

Current zlib source
author Chris Cannam
date Tue, 18 Oct 2016 14:33:52 +0100
parents
children
rev   line source
Chris@43 1 /* blast.h -- interface for blast.c
Chris@43 2 Copyright (C) 2003, 2012 Mark Adler
Chris@43 3 version 1.2, 24 Oct 2012
Chris@43 4
Chris@43 5 This software is provided 'as-is', without any express or implied
Chris@43 6 warranty. In no event will the author be held liable for any damages
Chris@43 7 arising from the use of this software.
Chris@43 8
Chris@43 9 Permission is granted to anyone to use this software for any purpose,
Chris@43 10 including commercial applications, and to alter it and redistribute it
Chris@43 11 freely, subject to the following restrictions:
Chris@43 12
Chris@43 13 1. The origin of this software must not be misrepresented; you must not
Chris@43 14 claim that you wrote the original software. If you use this software
Chris@43 15 in a product, an acknowledgment in the product documentation would be
Chris@43 16 appreciated but is not required.
Chris@43 17 2. Altered source versions must be plainly marked as such, and must not be
Chris@43 18 misrepresented as being the original software.
Chris@43 19 3. This notice may not be removed or altered from any source distribution.
Chris@43 20
Chris@43 21 Mark Adler madler@alumni.caltech.edu
Chris@43 22 */
Chris@43 23
Chris@43 24
Chris@43 25 /*
Chris@43 26 * blast() decompresses the PKWare Data Compression Library (DCL) compressed
Chris@43 27 * format. It provides the same functionality as the explode() function in
Chris@43 28 * that library. (Note: PKWare overused the "implode" verb, and the format
Chris@43 29 * used by their library implode() function is completely different and
Chris@43 30 * incompatible with the implode compression method supported by PKZIP.)
Chris@43 31 *
Chris@43 32 * The binary mode for stdio functions should be used to assure that the
Chris@43 33 * compressed data is not corrupted when read or written. For example:
Chris@43 34 * fopen(..., "rb") and fopen(..., "wb").
Chris@43 35 */
Chris@43 36
Chris@43 37
Chris@43 38 typedef unsigned (*blast_in)(void *how, unsigned char **buf);
Chris@43 39 typedef int (*blast_out)(void *how, unsigned char *buf, unsigned len);
Chris@43 40 /* Definitions for input/output functions passed to blast(). See below for
Chris@43 41 * what the provided functions need to do.
Chris@43 42 */
Chris@43 43
Chris@43 44
Chris@43 45 int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow);
Chris@43 46 /* Decompress input to output using the provided infun() and outfun() calls.
Chris@43 47 * On success, the return value of blast() is zero. If there is an error in
Chris@43 48 * the source data, i.e. it is not in the proper format, then a negative value
Chris@43 49 * is returned. If there is not enough input available or there is not enough
Chris@43 50 * output space, then a positive error is returned.
Chris@43 51 *
Chris@43 52 * The input function is invoked: len = infun(how, &buf), where buf is set by
Chris@43 53 * infun() to point to the input buffer, and infun() returns the number of
Chris@43 54 * available bytes there. If infun() returns zero, then blast() returns with
Chris@43 55 * an input error. (blast() only asks for input if it needs it.) inhow is for
Chris@43 56 * use by the application to pass an input descriptor to infun(), if desired.
Chris@43 57 *
Chris@43 58 * The output function is invoked: err = outfun(how, buf, len), where the bytes
Chris@43 59 * to be written are buf[0..len-1]. If err is not zero, then blast() returns
Chris@43 60 * with an output error. outfun() is always called with len <= 4096. outhow
Chris@43 61 * is for use by the application to pass an output descriptor to outfun(), if
Chris@43 62 * desired.
Chris@43 63 *
Chris@43 64 * The return codes are:
Chris@43 65 *
Chris@43 66 * 2: ran out of input before completing decompression
Chris@43 67 * 1: output error before completing decompression
Chris@43 68 * 0: successful decompression
Chris@43 69 * -1: literal flag not zero or one
Chris@43 70 * -2: dictionary size not in 4..6
Chris@43 71 * -3: distance is too far back
Chris@43 72 *
Chris@43 73 * At the bottom of blast.c is an example program that uses blast() that can be
Chris@43 74 * compiled to produce a command-line decompression filter by defining TEST.
Chris@43 75 */