string: factorize skip_spaces and export it to be generally available
[safe/jmp/linux-2.6] / lib / decompress_bunzip2.c
index 708e2a8..7607420 100644 (file)
 */
 
 
-#ifndef STATIC
+#ifdef STATIC
+#define PREBOOT
+#else
 #include <linux/decompress/bunzip2.h>
-#endif /* !STATIC */
+#include <linux/slab.h>
+#endif /* STATIC */
 
 #include <linux/decompress/mm.h>
-#include <linux/slab.h>
 
 #ifndef INT_MAX
 #define INT_MAX 0x7fffffff
@@ -297,7 +299,7 @@ static int INIT get_next_block(struct bunzip_data *bd)
                   again when using them (during symbol decoding).*/
                base = hufGroup->base-1;
                limit = hufGroup->limit-1;
-               /* Calculate permute[].  Concurently, initialize
+               /* Calculate permute[].  Concurrently, initialize
                 * temp[] and limit[]. */
                pp = 0;
                for (i = minLen; i <= maxLen; i++) {
@@ -681,9 +683,7 @@ STATIC int INIT bunzip2(unsigned char *buf, int len,
        set_error_fn(error_fn);
        if (flush)
                outbuf = malloc(BZIP2_IOBUF_SIZE);
-       else
-               len -= 4; /* Uncompressed size hack active in pre-boot
-                            environment */
+
        if (!outbuf) {
                error("Could not allocate output bufer");
                return -1;
@@ -733,4 +733,14 @@ exit_0:
        return i;
 }
 
-#define decompress bunzip2
+#ifdef PREBOOT
+STATIC int INIT decompress(unsigned char *buf, int len,
+                       int(*fill)(void*, unsigned int),
+                       int(*flush)(void*, unsigned int),
+                       unsigned char *outbuf,
+                       int *pos,
+                       void(*error_fn)(char *x))
+{
+       return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error_fn);
+}
+#endif