wearefair-grpc 1.3.1.pre.a → 1.3.1.pre.c
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/src/ruby/lib/grpc/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/grpc_c.so +0 -0
- data/third_party/zlib/adler32.c +14 -7
- data/third_party/zlib/compress.c +24 -18
- data/third_party/zlib/crc32.c +29 -12
- data/third_party/zlib/deflate.c +499 -303
- data/third_party/zlib/deflate.h +19 -16
- data/third_party/zlib/gzguts.h +16 -7
- data/third_party/zlib/gzlib.c +17 -14
- data/third_party/zlib/gzread.c +108 -48
- data/third_party/zlib/gzwrite.c +210 -122
- data/third_party/zlib/infback.c +2 -2
- data/third_party/zlib/inffast.c +34 -51
- data/third_party/zlib/inflate.c +86 -37
- data/third_party/zlib/inflate.h +7 -4
- data/third_party/zlib/inftrees.c +12 -14
- data/third_party/zlib/trees.c +38 -61
- data/third_party/zlib/uncompr.c +66 -32
- data/third_party/zlib/zconf.h +32 -9
- data/third_party/zlib/zlib.h +298 -154
- data/third_party/zlib/zutil.c +25 -24
- data/third_party/zlib/zutil.h +35 -17
- metadata +3 -2
data/third_party/zlib/inflate.h
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/* inflate.h -- internal inflate state definition
|
2
|
-
* Copyright (C) 1995-
|
2
|
+
* Copyright (C) 1995-2016 Mark Adler
|
3
3
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
4
4
|
*/
|
5
5
|
|
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
/* Possible inflate modes between inflate() calls */
|
20
20
|
typedef enum {
|
21
|
-
HEAD,
|
21
|
+
HEAD = 16180, /* i: waiting for magic header */
|
22
22
|
FLAGS, /* i: waiting for method and flags (gzip) */
|
23
23
|
TIME, /* i: waiting for modification time (gzip) */
|
24
24
|
OS, /* i: waiting for extra flags and operating system (gzip) */
|
@@ -77,11 +77,14 @@ typedef enum {
|
|
77
77
|
CHECK -> LENGTH -> DONE
|
78
78
|
*/
|
79
79
|
|
80
|
-
/*
|
80
|
+
/* State maintained between inflate() calls -- approximately 7K bytes, not
|
81
|
+
including the allocated sliding window, which is up to 32K bytes. */
|
81
82
|
struct inflate_state {
|
83
|
+
z_streamp strm; /* pointer back to this zlib stream */
|
82
84
|
inflate_mode mode; /* current inflate mode */
|
83
85
|
int last; /* true if processing last block */
|
84
|
-
int wrap; /* bit 0 true for zlib, bit 1 true for gzip
|
86
|
+
int wrap; /* bit 0 true for zlib, bit 1 true for gzip,
|
87
|
+
bit 2 true to validate check value */
|
85
88
|
int havedict; /* true if dictionary provided */
|
86
89
|
int flags; /* gzip header method and flags (0 if zlib) */
|
87
90
|
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
|
data/third_party/zlib/inftrees.c
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/* inftrees.c -- generate Huffman trees for efficient decoding
|
2
|
-
* Copyright (C) 1995-
|
2
|
+
* Copyright (C) 1995-2017 Mark Adler
|
3
3
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
4
4
|
*/
|
5
5
|
|
@@ -9,7 +9,7 @@
|
|
9
9
|
#define MAXBITS 15
|
10
10
|
|
11
11
|
const char inflate_copyright[] =
|
12
|
-
" inflate 1.2.
|
12
|
+
" inflate 1.2.11 Copyright 1995-2017 Mark Adler ";
|
13
13
|
/*
|
14
14
|
If you use the zlib library in a product, an acknowledgment is welcome
|
15
15
|
in the documentation of your product. If for some reason you cannot
|
@@ -54,7 +54,7 @@ unsigned short FAR *work;
|
|
54
54
|
code FAR *next; /* next available space in table */
|
55
55
|
const unsigned short FAR *base; /* base value table to use */
|
56
56
|
const unsigned short FAR *extra; /* extra bits table to use */
|
57
|
-
|
57
|
+
unsigned match; /* use base and extra for symbol >= match */
|
58
58
|
unsigned short count[MAXBITS+1]; /* number of codes of each length */
|
59
59
|
unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
|
60
60
|
static const unsigned short lbase[31] = { /* Length codes 257..285 base */
|
@@ -62,7 +62,7 @@ unsigned short FAR *work;
|
|
62
62
|
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
63
63
|
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
64
64
|
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
65
|
-
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16,
|
65
|
+
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202};
|
66
66
|
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
67
67
|
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
68
68
|
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
@@ -181,19 +181,17 @@ unsigned short FAR *work;
|
|
181
181
|
switch (type) {
|
182
182
|
case CODES:
|
183
183
|
base = extra = work; /* dummy value--not used */
|
184
|
-
|
184
|
+
match = 20;
|
185
185
|
break;
|
186
186
|
case LENS:
|
187
187
|
base = lbase;
|
188
|
-
base -= 257;
|
189
188
|
extra = lext;
|
190
|
-
|
191
|
-
end = 256;
|
189
|
+
match = 257;
|
192
190
|
break;
|
193
|
-
default:
|
191
|
+
default: /* DISTS */
|
194
192
|
base = dbase;
|
195
193
|
extra = dext;
|
196
|
-
|
194
|
+
match = 0;
|
197
195
|
}
|
198
196
|
|
199
197
|
/* initialize state for loop */
|
@@ -216,13 +214,13 @@ unsigned short FAR *work;
|
|
216
214
|
for (;;) {
|
217
215
|
/* create table entry */
|
218
216
|
here.bits = (unsigned char)(len - drop);
|
219
|
-
if (
|
217
|
+
if (work[sym] + 1U < match) {
|
220
218
|
here.op = (unsigned char)0;
|
221
219
|
here.val = work[sym];
|
222
220
|
}
|
223
|
-
else if (
|
224
|
-
here.op = (unsigned char)(extra[work[sym]]);
|
225
|
-
here.val = base[work[sym]];
|
221
|
+
else if (work[sym] >= match) {
|
222
|
+
here.op = (unsigned char)(extra[work[sym] - match]);
|
223
|
+
here.val = base[work[sym] - match];
|
226
224
|
}
|
227
225
|
else {
|
228
226
|
here.op = (unsigned char)(32 + 64); /* end of block */
|
data/third_party/zlib/trees.c
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/* trees.c -- output deflated data using Huffman coding
|
2
|
-
* Copyright (C) 1995-
|
2
|
+
* Copyright (C) 1995-2017 Jean-loup Gailly
|
3
3
|
* detect_data_type() function provided freely by Cosmin Truta, 2006
|
4
4
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
5
5
|
*/
|
@@ -36,7 +36,7 @@
|
|
36
36
|
|
37
37
|
#include "deflate.h"
|
38
38
|
|
39
|
-
#ifdef
|
39
|
+
#ifdef ZLIB_DEBUG
|
40
40
|
# include <ctype.h>
|
41
41
|
#endif
|
42
42
|
|
@@ -122,13 +122,13 @@ struct static_tree_desc_s {
|
|
122
122
|
int max_length; /* max bit length for the codes */
|
123
123
|
};
|
124
124
|
|
125
|
-
local static_tree_desc static_l_desc =
|
125
|
+
local const static_tree_desc static_l_desc =
|
126
126
|
{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
|
127
127
|
|
128
|
-
local static_tree_desc static_d_desc =
|
128
|
+
local const static_tree_desc static_d_desc =
|
129
129
|
{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
|
130
130
|
|
131
|
-
local static_tree_desc static_bl_desc =
|
131
|
+
local const static_tree_desc static_bl_desc =
|
132
132
|
{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
|
133
133
|
|
134
134
|
/* ===========================================================================
|
@@ -152,18 +152,16 @@ local int detect_data_type OF((deflate_state *s));
|
|
152
152
|
local unsigned bi_reverse OF((unsigned value, int length));
|
153
153
|
local void bi_windup OF((deflate_state *s));
|
154
154
|
local void bi_flush OF((deflate_state *s));
|
155
|
-
local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
|
156
|
-
int header));
|
157
155
|
|
158
156
|
#ifdef GEN_TREES_H
|
159
157
|
local void gen_trees_header OF((void));
|
160
158
|
#endif
|
161
159
|
|
162
|
-
#ifndef
|
160
|
+
#ifndef ZLIB_DEBUG
|
163
161
|
# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
|
164
162
|
/* Send a code of the given tree. c and tree must not have side effects */
|
165
163
|
|
166
|
-
#else /*
|
164
|
+
#else /* !ZLIB_DEBUG */
|
167
165
|
# define send_code(s, c, tree) \
|
168
166
|
{ if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
|
169
167
|
send_bits(s, tree[c].Code, tree[c].Len); }
|
@@ -182,7 +180,7 @@ local void gen_trees_header OF((void));
|
|
182
180
|
* Send a value on a given number of bits.
|
183
181
|
* IN assertion: length <= 16 and value fits in length bits.
|
184
182
|
*/
|
185
|
-
#ifdef
|
183
|
+
#ifdef ZLIB_DEBUG
|
186
184
|
local void send_bits OF((deflate_state *s, int value, int length));
|
187
185
|
|
188
186
|
local void send_bits(s, value, length)
|
@@ -208,12 +206,12 @@ local void send_bits(s, value, length)
|
|
208
206
|
s->bi_valid += length;
|
209
207
|
}
|
210
208
|
}
|
211
|
-
#else /* !
|
209
|
+
#else /* !ZLIB_DEBUG */
|
212
210
|
|
213
211
|
#define send_bits(s, value, length) \
|
214
212
|
{ int len = length;\
|
215
213
|
if (s->bi_valid > (int)Buf_size - len) {\
|
216
|
-
int val = value;\
|
214
|
+
int val = (int)value;\
|
217
215
|
s->bi_buf |= (ush)val << s->bi_valid;\
|
218
216
|
put_short(s, s->bi_buf);\
|
219
217
|
s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
|
@@ -223,7 +221,7 @@ local void send_bits(s, value, length)
|
|
223
221
|
s->bi_valid += len;\
|
224
222
|
}\
|
225
223
|
}
|
226
|
-
#endif /*
|
224
|
+
#endif /* ZLIB_DEBUG */
|
227
225
|
|
228
226
|
|
229
227
|
/* the arguments must not have side effects */
|
@@ -317,7 +315,7 @@ local void tr_static_init()
|
|
317
315
|
* Genererate the file trees.h describing the static trees.
|
318
316
|
*/
|
319
317
|
#ifdef GEN_TREES_H
|
320
|
-
# ifndef
|
318
|
+
# ifndef ZLIB_DEBUG
|
321
319
|
# include <stdio.h>
|
322
320
|
# endif
|
323
321
|
|
@@ -394,7 +392,7 @@ void ZLIB_INTERNAL _tr_init(s)
|
|
394
392
|
|
395
393
|
s->bi_buf = 0;
|
396
394
|
s->bi_valid = 0;
|
397
|
-
#ifdef
|
395
|
+
#ifdef ZLIB_DEBUG
|
398
396
|
s->compressed_len = 0L;
|
399
397
|
s->bits_sent = 0L;
|
400
398
|
#endif
|
@@ -522,12 +520,12 @@ local void gen_bitlen(s, desc)
|
|
522
520
|
xbits = 0;
|
523
521
|
if (n >= base) xbits = extra[n-base];
|
524
522
|
f = tree[n].Freq;
|
525
|
-
s->opt_len += (ulg)f * (bits + xbits);
|
526
|
-
if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
|
523
|
+
s->opt_len += (ulg)f * (unsigned)(bits + xbits);
|
524
|
+
if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits);
|
527
525
|
}
|
528
526
|
if (overflow == 0) return;
|
529
527
|
|
530
|
-
|
528
|
+
Tracev((stderr,"\nbit length overflow\n"));
|
531
529
|
/* This happens for example on obj2 and pic of the Calgary corpus */
|
532
530
|
|
533
531
|
/* Find the first bit length which could increase: */
|
@@ -554,9 +552,8 @@ local void gen_bitlen(s, desc)
|
|
554
552
|
m = s->heap[--h];
|
555
553
|
if (m > max_code) continue;
|
556
554
|
if ((unsigned) tree[m].Len != (unsigned) bits) {
|
557
|
-
|
558
|
-
s->opt_len += ((
|
559
|
-
*(long)tree[m].Freq;
|
555
|
+
Tracev((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
|
556
|
+
s->opt_len += ((ulg)bits - tree[m].Len) * tree[m].Freq;
|
560
557
|
tree[m].Len = (ush)bits;
|
561
558
|
}
|
562
559
|
n--;
|
@@ -578,7 +575,7 @@ local void gen_codes (tree, max_code, bl_count)
|
|
578
575
|
ushf *bl_count; /* number of codes at each bit length */
|
579
576
|
{
|
580
577
|
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
|
581
|
-
|
578
|
+
unsigned code = 0; /* running code value */
|
582
579
|
int bits; /* bit index */
|
583
580
|
int n; /* code index */
|
584
581
|
|
@@ -586,7 +583,8 @@ local void gen_codes (tree, max_code, bl_count)
|
|
586
583
|
* without bit reversal.
|
587
584
|
*/
|
588
585
|
for (bits = 1; bits <= MAX_BITS; bits++) {
|
589
|
-
|
586
|
+
code = (code + bl_count[bits-1]) << 1;
|
587
|
+
next_code[bits] = (ush)code;
|
590
588
|
}
|
591
589
|
/* Check that the bit counts in bl_count are consistent. The last code
|
592
590
|
* must be all ones.
|
@@ -599,7 +597,7 @@ local void gen_codes (tree, max_code, bl_count)
|
|
599
597
|
int len = tree[n].Len;
|
600
598
|
if (len == 0) continue;
|
601
599
|
/* Now reverse the bits */
|
602
|
-
tree[n].Code = bi_reverse(next_code[len]++, len);
|
600
|
+
tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
|
603
601
|
|
604
602
|
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
|
605
603
|
n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
|
@@ -821,7 +819,7 @@ local int build_bl_tree(s)
|
|
821
819
|
if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
|
822
820
|
}
|
823
821
|
/* Update opt_len to include the bit length tree and counts */
|
824
|
-
s->opt_len += 3*(max_blindex+1) + 5+5+4;
|
822
|
+
s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4;
|
825
823
|
Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
|
826
824
|
s->opt_len, s->static_len));
|
827
825
|
|
@@ -869,11 +867,17 @@ void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
|
|
869
867
|
int last; /* one if this is the last block for a file */
|
870
868
|
{
|
871
869
|
send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */
|
872
|
-
|
870
|
+
bi_windup(s); /* align on byte boundary */
|
871
|
+
put_short(s, (ush)stored_len);
|
872
|
+
put_short(s, (ush)~stored_len);
|
873
|
+
zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len);
|
874
|
+
s->pending += stored_len;
|
875
|
+
#ifdef ZLIB_DEBUG
|
873
876
|
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
|
874
877
|
s->compressed_len += (stored_len + 4) << 3;
|
878
|
+
s->bits_sent += 2*16;
|
879
|
+
s->bits_sent += stored_len<<3;
|
875
880
|
#endif
|
876
|
-
copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
|
877
881
|
}
|
878
882
|
|
879
883
|
/* ===========================================================================
|
@@ -894,7 +898,7 @@ void ZLIB_INTERNAL _tr_align(s)
|
|
894
898
|
{
|
895
899
|
send_bits(s, STATIC_TREES<<1, 3);
|
896
900
|
send_code(s, END_BLOCK, static_ltree);
|
897
|
-
#ifdef
|
901
|
+
#ifdef ZLIB_DEBUG
|
898
902
|
s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
|
899
903
|
#endif
|
900
904
|
bi_flush(s);
|
@@ -902,7 +906,7 @@ void ZLIB_INTERNAL _tr_align(s)
|
|
902
906
|
|
903
907
|
/* ===========================================================================
|
904
908
|
* Determine the best encoding for the current block: dynamic trees, static
|
905
|
-
* trees or store, and
|
909
|
+
* trees or store, and write out the encoded block.
|
906
910
|
*/
|
907
911
|
void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
908
912
|
deflate_state *s;
|
@@ -974,7 +978,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
|
974
978
|
send_bits(s, (STATIC_TREES<<1)+last, 3);
|
975
979
|
compress_block(s, (const ct_data *)static_ltree,
|
976
980
|
(const ct_data *)static_dtree);
|
977
|
-
#ifdef
|
981
|
+
#ifdef ZLIB_DEBUG
|
978
982
|
s->compressed_len += 3 + s->static_len;
|
979
983
|
#endif
|
980
984
|
} else {
|
@@ -983,7 +987,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
|
983
987
|
max_blindex+1);
|
984
988
|
compress_block(s, (const ct_data *)s->dyn_ltree,
|
985
989
|
(const ct_data *)s->dyn_dtree);
|
986
|
-
#ifdef
|
990
|
+
#ifdef ZLIB_DEBUG
|
987
991
|
s->compressed_len += 3 + s->opt_len;
|
988
992
|
#endif
|
989
993
|
}
|
@@ -995,7 +999,7 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
|
995
999
|
|
996
1000
|
if (last) {
|
997
1001
|
bi_windup(s);
|
998
|
-
#ifdef
|
1002
|
+
#ifdef ZLIB_DEBUG
|
999
1003
|
s->compressed_len += 7; /* align on byte boundary */
|
1000
1004
|
#endif
|
1001
1005
|
}
|
@@ -1090,7 +1094,7 @@ local void compress_block(s, ltree, dtree)
|
|
1090
1094
|
send_code(s, code, dtree); /* send the distance code */
|
1091
1095
|
extra = extra_dbits[code];
|
1092
1096
|
if (extra != 0) {
|
1093
|
-
dist -= base_dist[code];
|
1097
|
+
dist -= (unsigned)base_dist[code];
|
1094
1098
|
send_bits(s, dist, extra); /* send the extra distance bits */
|
1095
1099
|
}
|
1096
1100
|
} /* literal or match pair ? */
|
@@ -1193,34 +1197,7 @@ local void bi_windup(s)
|
|
1193
1197
|
}
|
1194
1198
|
s->bi_buf = 0;
|
1195
1199
|
s->bi_valid = 0;
|
1196
|
-
#ifdef
|
1200
|
+
#ifdef ZLIB_DEBUG
|
1197
1201
|
s->bits_sent = (s->bits_sent+7) & ~7;
|
1198
1202
|
#endif
|
1199
1203
|
}
|
1200
|
-
|
1201
|
-
/* ===========================================================================
|
1202
|
-
* Copy a stored block, storing first the length and its
|
1203
|
-
* one's complement if requested.
|
1204
|
-
*/
|
1205
|
-
local void copy_block(s, buf, len, header)
|
1206
|
-
deflate_state *s;
|
1207
|
-
charf *buf; /* the input data */
|
1208
|
-
unsigned len; /* its length */
|
1209
|
-
int header; /* true if block header must be written */
|
1210
|
-
{
|
1211
|
-
bi_windup(s); /* align on byte boundary */
|
1212
|
-
|
1213
|
-
if (header) {
|
1214
|
-
put_short(s, (ush)len);
|
1215
|
-
put_short(s, (ush)~len);
|
1216
|
-
#ifdef DEBUG
|
1217
|
-
s->bits_sent += 2*16;
|
1218
|
-
#endif
|
1219
|
-
}
|
1220
|
-
#ifdef DEBUG
|
1221
|
-
s->bits_sent += (ulg)len<<3;
|
1222
|
-
#endif
|
1223
|
-
while (len--) {
|
1224
|
-
put_byte(s, *buf++);
|
1225
|
-
}
|
1226
|
-
}
|
data/third_party/zlib/uncompr.c
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/* uncompr.c -- decompress a memory buffer
|
2
|
-
* Copyright (C) 1995-2003, 2010 Jean-loup Gailly
|
2
|
+
* Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler
|
3
3
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
4
4
|
*/
|
5
5
|
|
@@ -9,51 +9,85 @@
|
|
9
9
|
#include "zlib.h"
|
10
10
|
|
11
11
|
/* ===========================================================================
|
12
|
-
Decompresses the source buffer into the destination buffer. sourceLen is
|
13
|
-
the byte length of the source buffer. Upon entry, destLen is the total
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
Decompresses the source buffer into the destination buffer. *sourceLen is
|
13
|
+
the byte length of the source buffer. Upon entry, *destLen is the total size
|
14
|
+
of the destination buffer, which must be large enough to hold the entire
|
15
|
+
uncompressed data. (The size of the uncompressed data must have been saved
|
16
|
+
previously by the compressor and transmitted to the decompressor by some
|
17
|
+
mechanism outside the scope of this compression library.) Upon exit,
|
18
|
+
*destLen is the size of the decompressed data and *sourceLen is the number
|
19
|
+
of source bytes consumed. Upon return, source + *sourceLen points to the
|
20
|
+
first unused input byte.
|
21
|
+
|
22
|
+
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
23
|
+
memory, Z_BUF_ERROR if there was not enough room in the output buffer, or
|
24
|
+
Z_DATA_ERROR if the input data was corrupted, including if the input data is
|
25
|
+
an incomplete zlib stream.
|
23
26
|
*/
|
24
|
-
int ZEXPORT
|
27
|
+
int ZEXPORT uncompress2 (dest, destLen, source, sourceLen)
|
25
28
|
Bytef *dest;
|
26
29
|
uLongf *destLen;
|
27
30
|
const Bytef *source;
|
28
|
-
uLong sourceLen;
|
31
|
+
uLong *sourceLen;
|
29
32
|
{
|
30
33
|
z_stream stream;
|
31
34
|
int err;
|
35
|
+
const uInt max = (uInt)-1;
|
36
|
+
uLong len, left;
|
37
|
+
Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */
|
32
38
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
len = *sourceLen;
|
40
|
+
if (*destLen) {
|
41
|
+
left = *destLen;
|
42
|
+
*destLen = 0;
|
43
|
+
}
|
44
|
+
else {
|
45
|
+
left = 1;
|
46
|
+
dest = buf;
|
47
|
+
}
|
41
48
|
|
49
|
+
stream.next_in = (z_const Bytef *)source;
|
50
|
+
stream.avail_in = 0;
|
42
51
|
stream.zalloc = (alloc_func)0;
|
43
52
|
stream.zfree = (free_func)0;
|
53
|
+
stream.opaque = (voidpf)0;
|
44
54
|
|
45
55
|
err = inflateInit(&stream);
|
46
56
|
if (err != Z_OK) return err;
|
47
57
|
|
48
|
-
|
49
|
-
|
50
|
-
inflateEnd(&stream);
|
51
|
-
if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
|
52
|
-
return Z_DATA_ERROR;
|
53
|
-
return err;
|
54
|
-
}
|
55
|
-
*destLen = stream.total_out;
|
58
|
+
stream.next_out = dest;
|
59
|
+
stream.avail_out = 0;
|
56
60
|
|
57
|
-
|
58
|
-
|
61
|
+
do {
|
62
|
+
if (stream.avail_out == 0) {
|
63
|
+
stream.avail_out = left > (uLong)max ? max : (uInt)left;
|
64
|
+
left -= stream.avail_out;
|
65
|
+
}
|
66
|
+
if (stream.avail_in == 0) {
|
67
|
+
stream.avail_in = len > (uLong)max ? max : (uInt)len;
|
68
|
+
len -= stream.avail_in;
|
69
|
+
}
|
70
|
+
err = inflate(&stream, Z_NO_FLUSH);
|
71
|
+
} while (err == Z_OK);
|
72
|
+
|
73
|
+
*sourceLen -= len + stream.avail_in;
|
74
|
+
if (dest != buf)
|
75
|
+
*destLen = stream.total_out;
|
76
|
+
else if (stream.total_out && err == Z_BUF_ERROR)
|
77
|
+
left = 1;
|
78
|
+
|
79
|
+
inflateEnd(&stream);
|
80
|
+
return err == Z_STREAM_END ? Z_OK :
|
81
|
+
err == Z_NEED_DICT ? Z_DATA_ERROR :
|
82
|
+
err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR :
|
83
|
+
err;
|
84
|
+
}
|
85
|
+
|
86
|
+
int ZEXPORT uncompress (dest, destLen, source, sourceLen)
|
87
|
+
Bytef *dest;
|
88
|
+
uLongf *destLen;
|
89
|
+
const Bytef *source;
|
90
|
+
uLong sourceLen;
|
91
|
+
{
|
92
|
+
return uncompress2(dest, destLen, source, &sourceLen);
|
59
93
|
}
|