summaryrefslogtreecommitdiff
path: root/src/contrib/blast/blast.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/contrib/blast/blast.c')
-rw-r--r--src/contrib/blast/blast.c46
1 files changed, 13 insertions, 33 deletions
diff --git a/src/contrib/blast/blast.c b/src/contrib/blast/blast.c
index e6e6590..69ef0fe 100644
--- a/src/contrib/blast/blast.c
+++ b/src/contrib/blast/blast.c
@@ -1,7 +1,7 @@
/* blast.c
- * Copyright (C) 2003, 2012, 2013 Mark Adler
+ * Copyright (C) 2003, 2012 Mark Adler
* For conditions of distribution and use, see copyright notice in blast.h
- * version 1.3, 24 Aug 2013
+ * version 1.2, 24 Oct 2012
*
* blast.c decompresses data compressed by the PKWare Compression Library.
* This function provides functionality similar to the explode() function of
@@ -24,12 +24,8 @@
* 1.1 16 Feb 2003 - Fixed distance check for > 4 GB uncompressed data
* 1.2 24 Oct 2012 - Add note about using binary mode in stdio
* - Fix comparisons of differently signed integers
- * 1.3 24 Aug 2013 - Return unused input from blast()
- * - Fix test code to correctly report unused input
- * - Enable the provision of initial input to blast()
*/
-#include <stddef.h> /* for NULL */
#include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */
#include "blast.h" /* prototype for blast() */
@@ -260,7 +256,7 @@ local int construct(struct huffman *h, const unsigned char *rep, int n)
* next, 0 for literals, 1 for length/distance.
*
* - If literals are uncoded, then the next eight bits are the literal, in the
- * normal bit order in the stream, i.e. no bit-reversal is needed. Similarly,
+ * normal bit order in th stream, i.e. no bit-reversal is needed. Similarly,
* no bit reversal is needed for either the length extra bits or the distance
* extra bits.
*
@@ -380,8 +376,7 @@ local int decomp(struct state *s)
}
/* See comments in blast.h */
-int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow,
- unsigned *left, unsigned char **in)
+int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow)
{
struct state s; /* input/output state */
int err; /* return value */
@@ -389,12 +384,7 @@ int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow,
/* initialize input state */
s.infun = infun;
s.inhow = inhow;
- if (left != NULL && *left) {
- s.left = *left;
- s.in = *in;
- }
- else
- s.left = 0;
+ s.left = 0;
s.bitbuf = 0;
s.bitcnt = 0;
@@ -410,12 +400,6 @@ int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow,
else
err = decomp(&s); /* decompress */
- /* return unused input */
- if (left != NULL)
- *left = s.left;
- if (in != NULL)
- *in = s.left ? s.in : NULL;
-
/* write any leftover output and update the error code if needed */
if (err != 1 && s.next && s.outfun(s.outhow, s.out, s.next) && err == 0)
err = 1;
@@ -445,20 +429,16 @@ local int outf(void *how, unsigned char *buf, unsigned len)
/* Decompress a PKWare Compression Library stream from stdin to stdout */
int main(void)
{
- int ret;
- unsigned left;
+ int ret, n;
/* decompress to stdout */
- left = 0;
- ret = blast(inf, stdin, outf, stdout, &left, NULL);
- if (ret != 0)
- fprintf(stderr, "blast error: %d\n", ret);
-
- /* count any leftover bytes */
- while (getchar() != EOF)
- left++;
- if (left)
- fprintf(stderr, "blast warning: %u unused bytes of input\n", left);
+ ret = blast(inf, stdin, outf, stdout);
+ if (ret != 0) fprintf(stderr, "blast error: %d\n", ret);
+
+ /* see if there are any leftover bytes */
+ n = 0;
+ while (getchar() != EOF) n++;
+ if (n) fprintf(stderr, "blast warning: %d unused bytes of input\n", n);
/* return blast() error code */
return ret;