gunzip_util.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Decompression convenience functions
  3. *
  4. * Copyright 2007 David Gibson, IBM Corporation.
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #ifndef _PPC_BOOT_GUNZIP_UTIL_H_
  11. #define _PPC_BOOT_GUNZIP_UTIL_H_
  12. #include "zlib.h"
  13. /*
  14. * These functions are designed to make life easy for decompressing
  15. * kernel images, initrd images or any other gzip compressed image,
  16. * particularly if its useful to decompress part of the image (e.g. to
  17. * examine headers) before decompressing the remainder.
  18. *
  19. * To use:
  20. * - declare a gunzip_state structure
  21. * - use gunzip_start() to initialize the state, associating it
  22. * with a stream of compressed data
  23. * - use gunzip_partial(), gunzip_exactly() and gunzip_discard()
  24. * in any combination to extract pieces of data from the stream
  25. * - Finally use gunzip_finish() to extract the tail of the
  26. * compressed stream and wind up zlib
  27. */
  28. /* scratch space for gunzip; 46912 is from zlib_inflate_workspacesize() */
  29. #define GUNZIP_SCRATCH_SIZE 46912
  30. struct gunzip_state {
  31. z_stream s;
  32. char scratch[46912];
  33. };
  34. void gunzip_start(struct gunzip_state *state, void *src, int srclen);
  35. int gunzip_partial(struct gunzip_state *state, void *dst, int dstlen);
  36. void gunzip_exactly(struct gunzip_state *state, void *dst, int len);
  37. void gunzip_discard(struct gunzip_state *state, int len);
  38. int gunzip_finish(struct gunzip_state *state, void *dst, int len);
  39. #endif /* _PPC_BOOT_GUNZIP_UTIL_H_ */