Merge remote-tracking branch 'moduleh/module.h-split'
[linux-2.6/next.git] / arch / powerpc / boot / gunzip_util.h
blobb3dfa6e87b3a07cb43545c3d77a073d588ae551f
1 /*
2 * Decompression convenience functions
4 * Copyright 2007 David Gibson, IBM Corporation.
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_
13 #include "zlib.h"
16 * These functions are designed to make life easy for decompressing
17 * kernel images, initrd images or any other gzip compressed image,
18 * particularly if its useful to decompress part of the image (e.g. to
19 * examine headers) before decompressing the remainder.
21 * To use:
22 * - declare a gunzip_state structure
23 * - use gunzip_start() to initialize the state, associating it
24 * with a stream of compressed data
25 * - use gunzip_partial(), gunzip_exactly() and gunzip_discard()
26 * in any combination to extract pieces of data from the stream
27 * - Finally use gunzip_finish() to extract the tail of the
28 * compressed stream and wind up zlib
31 /* scratch space for gunzip; 46912 is from zlib_inflate_workspacesize() */
32 #define GUNZIP_SCRATCH_SIZE 46912
34 struct gunzip_state {
35 z_stream s;
36 char scratch[46912];
39 void gunzip_start(struct gunzip_state *state, void *src, int srclen);
40 int gunzip_partial(struct gunzip_state *state, void *dst, int dstlen);
41 void gunzip_exactly(struct gunzip_state *state, void *dst, int len);
42 void gunzip_discard(struct gunzip_state *state, int len);
43 int gunzip_finish(struct gunzip_state *state, void *dst, int len);
45 #endif /* _PPC_BOOT_GUNZIP_UTIL_H_ */