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