blast.h 3.3 KB

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