Browse code

revert nsis zlibs

git-svn: trunk@3630

aCaB authored on 2008/02/14 11:12:13
Showing 9 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,21 @@
0
+zlib/libpng license 
1
+-------------------
2
+
3
+This software is provided 'as-is', without any express or implied warranty. In 
4
+no event will the authors be held liable for any damages arising from the use
5
+of this software. 
6
+
7
+Permission is granted to anyone to use this software for any purpose, including 
8
+commercial applications, and to alter it and redistribute it freely, subject to 
9
+the following restrictions: 
10
+
11
+  1. The origin of this software must not be misrepresented; you must not
12
+     claim that you wrote the original software. If you use this software in
13
+     a product, an acknowledgment in the product documentation would be
14
+     appreciated but is not required. 
15
+
16
+  2. Altered source versions must be plainly marked as such, and must not be
17
+     misrepresented as being the original software. 
18
+
19
+  3. This notice may not be removed or altered from any source distribution. 
20
+
... ...
@@ -1,3 +1,7 @@
1
+Thu Feb 14 02:53:28 CET 2008 (acab)
2
+-----------------------------------
3
+  * libclamav/nsis: revert Nullsoft-bastardized zlibs
4
+
1 5
 Wed Feb 13 17:14:30 CET 2008 (acab)
2 6
 -----------------------------------
3 7
   * clamd: fix typo on limits setup
... ...
@@ -143,6 +143,10 @@ libclamav_la_SOURCES = \
143 143
 	nsis/nsis_bzlib.h \
144 144
 	nsis/nulsft.c \
145 145
 	nsis/nulsft.h \
146
+	nsis/infblock.c \
147
+	nsis_zconf.h \
148
+	nsis_zlib.h \
149
+	nsis_zutil.h \
146 150
 	pdf.c \
147 151
 	pdf.h \
148 152
 	spin.c \
... ...
@@ -86,10 +86,10 @@ am_libclamav_la_OBJECTS = matcher-ac.lo matcher-bm.lo matcher.lo \
86 86
 	upack.lo line.lo untar.lo unzip.lo inflate64.lo special.lo \
87 87
 	binhex.lo is_tar.lo tnef.lo autoit.lo strlcpy.lo regcomp.lo \
88 88
 	regerror.lo regexec.lo regfree.lo unarj.lo bzlib.lo nulsft.lo \
89
-	pdf.lo spin.lo yc.lo elf.lo sis.lo uuencode.lo phishcheck.lo \
90
-	phish_domaincheck_db.lo phish_whitelist.lo regex_list.lo \
91
-	mspack.lo cab.lo entconv.lo hashtab.lo dconf.lo lzma_iface.lo \
92
-	explode.lo textnorm.lo
89
+	infblock.lo pdf.lo spin.lo yc.lo elf.lo sis.lo uuencode.lo \
90
+	phishcheck.lo phish_domaincheck_db.lo phish_whitelist.lo \
91
+	regex_list.lo mspack.lo cab.lo entconv.lo hashtab.lo dconf.lo \
92
+	lzma_iface.lo explode.lo textnorm.lo
93 93
 libclamav_la_OBJECTS = $(am_libclamav_la_OBJECTS)
94 94
 libclamav_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
95 95
 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
... ...
@@ -377,6 +377,10 @@ libclamav_la_SOURCES = \
377 377
 	nsis/nsis_bzlib.h \
378 378
 	nsis/nulsft.c \
379 379
 	nsis/nulsft.h \
380
+	nsis/infblock.c \
381
+	nsis_zconf.h \
382
+	nsis_zlib.h \
383
+	nsis_zutil.h \
380 384
 	pdf.c \
381 385
 	pdf.h \
382 386
 	spin.c \
... ...
@@ -525,6 +529,7 @@ distclean-compile:
525 525
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fsg.Plo@am__quote@
526 526
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hashtab.Plo@am__quote@
527 527
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htmlnorm.Plo@am__quote@
528
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/infblock.Plo@am__quote@
528 529
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inflate64.Plo@am__quote@
529 530
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/is_tar.Plo@am__quote@
530 531
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libclamav_internal_utils_la-others.Plo@am__quote@
... ...
@@ -650,6 +655,13 @@ nulsft.lo: nsis/nulsft.c
650 650
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
651 651
 @am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nulsft.lo `test -f 'nsis/nulsft.c' || echo '$(srcdir)/'`nsis/nulsft.c
652 652
 
653
+infblock.lo: nsis/infblock.c
654
+@am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT infblock.lo -MD -MP -MF $(DEPDIR)/infblock.Tpo -c -o infblock.lo `test -f 'nsis/infblock.c' || echo '$(srcdir)/'`nsis/infblock.c
655
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/infblock.Tpo $(DEPDIR)/infblock.Plo
656
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='nsis/infblock.c' object='infblock.lo' libtool=yes @AMDEPBACKSLASH@
657
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
658
+@am__fastdepCC_FALSE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o infblock.lo `test -f 'nsis/infblock.c' || echo '$(srcdir)/'`nsis/infblock.c
659
+
653 660
 libclamav_internal_utils_la-str.lo: str.c
654 661
 @am__fastdepCC_TRUE@	$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libclamav_internal_utils_la_CFLAGS) $(CFLAGS) -MT libclamav_internal_utils_la-str.lo -MD -MP -MF $(DEPDIR)/libclamav_internal_utils_la-str.Tpo -c -o libclamav_internal_utils_la-str.lo `test -f 'str.c' || echo '$(srcdir)/'`str.c
655 662
 @am__fastdepCC_TRUE@	mv -f $(DEPDIR)/libclamav_internal_utils_la-str.Tpo $(DEPDIR)/libclamav_internal_utils_la-str.Plo
656 663
new file mode 100644
... ...
@@ -0,0 +1,715 @@
0
+/*
1
+ * This file is a part of the zlib compression module for NSIS.
2
+ * 
3
+ * Copyright and license information can be found below.
4
+ * Modifications Copyright (C) 1999-2007 Nullsoft and Contributors
5
+ * 
6
+ * The original zlib source code is available at
7
+ * http://www.zlib.net/
8
+ * 
9
+ * This software is provided 'as-is', without any express or implied
10
+ * warranty.
11
+ */
12
+
13
+/*
14
+ * Copyright (C) 1995-1998 Jean-loup Gailly.
15
+ * For conditions of distribution and use, see copyright notice in COPYING.nsis
16
+ */
17
+
18
+#include "nsis_zutil.h"
19
+#include <string.h>
20
+
21
+#ifndef min
22
+#  define min(x,y) ((x<y)?x:y)
23
+#endif
24
+
25
+/* defines for inflate input/output */
26
+/*   update pointers and return */
27
+#define UPDBITS {s->bitb=b;s->bitk=k;}
28
+#define UPDIN {z->avail_in=n;z->next_in=p;}
29
+#define UPDOUT {s->write=q;}
30
+#define UPDATE {UPDBITS UPDIN UPDOUT}
31
+#define LEAVE(r) {UPDATE inflate_flush(z); return r;}
32
+
33
+/*   get bytes and bits */
34
+#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;}
35
+
36
+
37
+#define NEEDBYTE {if(!n)LEAVE(Z_OK)}
38
+#define NEXTBYTE (n--,*p++)
39
+#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}}
40
+
41
+#define DUMPBITS(j) {b>>=(j);k-=(j);}
42
+/*   output bytes */
43
+#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q)
44
+#define LOADOUT {q=s->write;m=(uInt)WAVAIL;}
45
+#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}}
46
+#define FLUSH {UPDOUT inflate_flush(z); LOADOUT}
47
+#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE(Z_OK)}}}
48
+#define OUTBYTE(a) {*q++=(Byte)(a);m--;}
49
+/*   load local pointers */
50
+#define LOAD {LOADIN LOADOUT}
51
+
52
+#define LAST (s->last == DRY)
53
+
54
+#define FIXEDH 544      /* number of hufts used by fixed tables */
55
+
56
+
57
+
58
+typedef struct inflate_blocks_state FAR inflate_blocks_statef;
59
+#define exop word.what.Exop
60
+#define bits word.what.Bits
61
+
62
+/* And'ing with mask[n] masks the lower n bits */
63
+local unsigned short inflate_mask[17] = {
64
+    0x0000,
65
+    0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
66
+    0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
67
+}; /* use to reduce .data #define INFLATE_MASK(x, n) (x & (~((unsigned short) 0xFFFF << n))) */
68
+local const char border[] = { /* Order of the bit length code lengths */
69
+        16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
70
+
71
+/* Tables for deflate from PKZIP's appnote.txt. */
72
+local const unsigned short  cplens[31] = { /* Copy lengths for literal codes 257..285 */
73
+        3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
74
+        35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
75
+        /* see note #13 above about 258 */
76
+local const unsigned short  cplext[31] = { /* Extra bits for literal codes 257..285 */
77
+        0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
78
+        3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */
79
+local const unsigned short  cpdist[30] = { /* Copy offsets for distance codes 0..29 */
80
+        1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
81
+        257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
82
+        8193, 12289, 16385, 24577};
83
+local const unsigned short  cpdext[30] = { /* Extra bits for distance codes */
84
+        0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
85
+        7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
86
+        12, 12, 13, 13};
87
+
88
+/* build fixed tables only once--keep them here */
89
+local char fixed_built = 0;
90
+local inflate_huft fixed_mem[FIXEDH];
91
+local uInt fixed_bl=9;
92
+local uInt fixed_bd=5;
93
+local inflate_huft *fixed_tl;
94
+local inflate_huft *fixed_td;
95
+
96
+/* copy as much as possible from the sliding window to the output area */
97
+local void ZEXPORT inflate_flush(nsis_z_streamp z)
98
+{
99
+  inflate_blocks_statef *s = &z->blocks;
100
+  uInt n;
101
+  Bytef *q;
102
+
103
+  /* local copies of source and destination pointers */
104
+  q = s->read;
105
+
106
+again:
107
+  /* compute number of bytes to copy as far as end of window */
108
+  n = (uInt)((q <= s->write ? s->write : s->end) - q);
109
+  n = min(n, z->avail_out);
110
+
111
+  /* update counters */
112
+  z->avail_out -= n;
113
+  /* z->total_out += n; */
114
+
115
+  /* copy as far as end of window */
116
+  zmemcpy(z->next_out, q, n);
117
+  z->next_out += n;
118
+  q += n;
119
+
120
+  /* see if more to copy at beginning of window */
121
+  if (q == s->end)
122
+  {
123
+    /* wrap pointers */
124
+    q = s->window;
125
+    if (s->write == s->end)
126
+      s->write = s->window;
127
+
128
+    /* do the same for the beginning of the window */
129
+    goto again;
130
+  }
131
+
132
+  /* update pointers */
133
+  s->read = q;
134
+}
135
+
136
+#define BMAX 15         /* maximum bit length of any code */
137
+
138
+local int ZEXPORT huft_build(
139
+uIntf *b,               /* code lengths in bits (all assumed <= BMAX) */
140
+uInt n,                 /* number of codes (assumed <= 288) */
141
+uInt s,                 /* number of simple-valued codes (0..s-1) */
142
+const unsigned short *d,         /* list of base values for non-simple codes */
143
+const unsigned short *e,         /* list of extra bits for non-simple codes */
144
+inflate_huft * FAR *t,  /* result: starting table */
145
+uIntf *m,               /* maximum lookup bits, returns actual */
146
+inflate_huft *hp,       /* space for trees */
147
+uInt *hn)               /* working area: values in order of bit length */
148
+{
149
+  static uIntf v[288];             /* work area for huft_build */
150
+  uInt a;                       /* counter for codes of length k */
151
+  uInt c[BMAX+1];               /* bit length count table */
152
+  uInt f;                       /* i repeats in table every f entries */
153
+  int g;                        /* maximum code length */
154
+  int h;                        /* table level */
155
+  uInt i;              /* counter, current code */
156
+  uInt j;              /* counter */
157
+  int k;               /* number of bits in current code */
158
+  int l;                        /* bits per table (returned in m) */
159
+  uIntf *p;            /* pointer into c[], b[], or v[] */
160
+  inflate_huft *q;              /* points to current table */
161
+  struct inflate_huft_s r;      /* table entry for structure assignment */
162
+  inflate_huft *u[BMAX];        /* table stack */
163
+  int w;               /* bits before this table == (l * h) */
164
+  uInt x[BMAX+1];               /* bit offsets, then code stack */
165
+  uIntf *xp;                    /* pointer into x */
166
+  int y;                        /* number of dummy codes added */
167
+  uInt z;                       /* number of entries in current table */
168
+
169
+
170
+  /* Generate counts for each bit length */
171
+  p=c;
172
+  y=16; while (y--) *p++ = 0;
173
+  p = b;
174
+  i = n;
175
+  do {
176
+    c[*p++]++;                  /* assume all entries <= BMAX */
177
+  } while (--i);
178
+  if (c[0] == n)                /* null input--all zero length codes */
179
+  {
180
+    *t = (inflate_huft *)Z_NULL;
181
+    *m = 0;
182
+    return Z_OK;
183
+  }
184
+
185
+
186
+  /* Find minimum and maximum length, bound *m by those */
187
+  l = *m;
188
+  for (j = 1; j <= BMAX; j++)
189
+    if (c[j])
190
+      break;
191
+  k = j;                        /* minimum code length */
192
+  if ((uInt)l < j)
193
+    l = j;
194
+  for (i = BMAX; i; i--)
195
+    if (c[i])
196
+      break;
197
+  g = i;                        /* maximum code length */
198
+  if ((uInt)l > i)
199
+    l = i;
200
+  *m = l;
201
+
202
+
203
+  /* Adjust last length count to fill out codes, if needed */
204
+  for (y = 1 << j; j < i; j++, y <<= 1)
205
+    if ((y -= c[j]) < 0)
206
+      return Z_DATA_ERROR;
207
+  if ((y -= c[i]) < 0)
208
+    return Z_DATA_ERROR;
209
+  c[i] += y;
210
+
211
+
212
+  /* Generate starting offsets into the value table for each length */
213
+  x[1] = j = 0;
214
+  p = c + 1;  xp = x + 2;
215
+  while (--i) {                 /* note that i == g from above */
216
+    *xp++ = (j += *p++);
217
+  }
218
+
219
+
220
+  /* Make a table of values in order of bit lengths */
221
+  p = b;  i = 0;
222
+  do {
223
+    if ((j = *p++) != 0)
224
+      v[x[j]++] = i;
225
+  } while (++i < n);
226
+  n = x[g];                     /* set n to length of v */
227
+
228
+
229
+  /* Generate the Huffman codes and for each, make the table entries */
230
+  x[0] = i = 0;                 /* first Huffman code is zero */
231
+  p = v;                        /* grab values in bit order */
232
+  h = -1;                       /* no tables yet--level -1 */
233
+  w = -l;                       /* bits decoded == (l * h) */
234
+  u[0] = (inflate_huft *)Z_NULL;        /* just to keep compilers happy */
235
+  q = (inflate_huft *)Z_NULL;   /* ditto */
236
+  z = 0;                        /* ditto */
237
+
238
+  r.base = 0;
239
+
240
+  /* go through the bit lengths (k already is bits in shortest code) */
241
+  for (; k <= g; k++)
242
+  {
243
+    a = c[k];
244
+    while (a--)
245
+    {
246
+      int nextw=w;
247
+      /* here i is the Huffman code of length k bits for value *p */
248
+      /* make tables up to required level */
249
+      while (k > (nextw=w + l))
250
+      {
251
+        h++;
252
+
253
+        /* compute minimum size table less than or equal to l bits */
254
+        z = g - nextw;
255
+        z = z > (uInt)l ? (uInt)l : z;        /* table size upper limit */
256
+        if ((f = 1 << (j = k - nextw)) > a + 1)     /* try a k-w bit table */
257
+        {                       /* too few codes for k-w bit table */
258
+          f -= a + 1;           /* deduct codes from patterns left */
259
+          xp = c + k;
260
+          if (j < z)
261
+            while (++j < z && (f <<= 1) > *++xp)     /* try smaller tables up to z bits */
262
+            {
263
+              f -= *xp;         /* else deduct codes from patterns */
264
+            }
265
+        }
266
+        z = 1 << j;             /* table entries for j-bit table */
267
+
268
+        /* allocate new table */
269
+        if (*hn + z > MANY)     /* (note: doesn't matter for fixed) */
270
+          return Z_MEM_ERROR;   /* not enough memory */
271
+        u[h] = q = hp + *hn;
272
+        *hn += z;
273
+
274
+        /* connect to last table, if there is one */
275
+        if (h)
276
+        {
277
+          x[h] = i;             /* save pattern for backing up */
278
+          r.bits = (Byte)l;     /* bits to dump before this table */
279
+          r.exop = (Byte)j;     /* bits in this table */
280
+          j = i >> w;
281
+          r.base = (uInt)(q - u[h-1] - j);   /* offset to this table */
282
+          u[h-1][j] = r;        /* connect to last table */
283
+        }
284
+        else
285
+          *t = q;               /* first table is returned result */
286
+        w=nextw;                 /* previous table always l bits */
287
+      }
288
+
289
+      /* set up table entry in r */
290
+      r.bits = (Byte)(k - w);
291
+      if (p >= v + n)
292
+        r.exop = 128 + 64;      /* out of values--invalid code */
293
+      else if (*p < s)
294
+      {
295
+        r.exop = (Byte)(*p < 256 ? 0 : 32 + 64);     /* 256 is end-of-block */
296
+        r.base = *p++;          /* simple code is just the value */
297
+      }
298
+      else
299
+      {
300
+        r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */
301
+        r.base = d[*p++ - s];
302
+      }
303
+
304
+      /* fill code-like entries with r */
305
+      f = 1 << (k - w);
306
+      for (j = i >> w; j < z; j += f)
307
+        q[j] = r;
308
+
309
+      /* backwards increment the k-bit code i */
310
+      for (j = 1 << (k - 1); i & j; j >>= 1)
311
+        i ^= j;
312
+      i ^= j;
313
+
314
+      /* backup over finished tables */
315
+      while ((i & ((1 << w) - 1)) != x[h])
316
+      {
317
+        h--;                    /* don't need to update q */
318
+        w -= l;
319
+      }
320
+    }
321
+  }
322
+
323
+
324
+  /* Return Z_BUF_ERROR if we were given an incomplete table */
325
+  return (y != 0 && g != 1) ? Z_BUF_ERROR : Z_OK;
326
+}
327
+
328
+int ZEXPORT nsis_inflate(nsis_z_streamp z)
329
+{
330
+  inflate_blocks_statef *s = &z->blocks;
331
+  inflate_codes_statef *c = &s->sub.decode.t_codes;  /* codes state */
332
+
333
+  /* lousy two bytes saved by doing this */
334
+  struct
335
+  {
336
+    uInt t;               /* temporary storage */
337
+    uLong b;              /* bit buffer */
338
+    uInt k;               /* bits in bit buffer */
339
+    Bytef *p;             /* input data pointer */
340
+    uInt n;               /* bytes available there */
341
+    Bytef *q;             /* output window write pointer */
342
+    uInt m;               /* bytes to end of window or read pointer */
343
+
344
+    /* CODES variables */
345
+
346
+    inflate_huft *j;      /* temporary pointer */
347
+    uInt e;               /* extra bits or operation */
348
+    Bytef *f;             /* pointer to copy strings from */
349
+  } _state;
350
+
351
+#define t _state.t
352
+#define b _state.b
353
+#define k _state.k
354
+#define p _state.p
355
+#define n _state.n
356
+#define q _state.q
357
+#define m _state.m
358
+
359
+  /* copy input/output information to locals (UPDATE macro restores) */
360
+  LOAD
361
+
362
+  /* process input based on current state */
363
+  for (;;) switch (s->mode)
364
+  {
365
+    case TYPE:
366
+      NEEDBITS(3)
367
+      t = (uInt)b & 7;
368
+      DUMPBITS(3)
369
+      s->last = (t & 1) ? DRY : TYPE;
370
+      switch (t >> 1)
371
+      {
372
+        case 0:                         /* stored */
373
+          Tracev((stderr, "inflate:     stored block%s\n",
374
+                 LAST ? " (last)" : ""));
375
+          DUMPBITS(k&7)
376
+          s->mode = LENS;               /* get length of stored block */
377
+          break;
378
+        case 1:                         /* fixed */
379
+          Tracev((stderr, "inflate:     fixed codes block%s\n",
380
+                 LAST ? " (last)" : ""));
381
+          {
382
+            if (!fixed_built)
383
+            {
384
+              int _k;              /* temporary variable */
385
+              uInt f = 0;         /* number of hufts used in fixed_mem */
386
+              static uIntf lc[288];           /* length list for huft_build */
387
+
388
+              /* literal table */
389
+              for (_k = 0; _k < 288; _k++)
390
+              {
391
+                char v=8;
392
+                if (_k > 143)
393
+                {
394
+                  if (_k < 256) v++;
395
+                  else if (_k < 280) v--;
396
+                }
397
+                lc[_k] = v;
398
+              }
399
+
400
+              huft_build(lc, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, fixed_mem, &f);
401
+
402
+              /* distance table */
403
+              for (_k = 0; _k < 30; _k++) lc[_k] = 5;
404
+
405
+              huft_build(lc, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, fixed_mem, &f);
406
+
407
+              /* done */
408
+              fixed_built++;
409
+            }
410
+
411
+            /* s->sub.decode.t_codes.mode = CODES_START; */
412
+            s->sub.decode.t_codes.lbits = (Byte)fixed_bl;
413
+            s->sub.decode.t_codes.dbits = (Byte)fixed_bd;
414
+            s->sub.decode.t_codes.ltree = fixed_tl;
415
+            s->sub.decode.t_codes.dtree = fixed_td;
416
+          }
417
+          s->mode = CODES_START;
418
+          break;
419
+        case 2:                         /* dynamic */
420
+          Tracev((stderr, "inflate:     dynamic codes block%s\n",
421
+                 LAST ? " (last)" : ""));
422
+          s->mode = TABLE;
423
+          break;
424
+        case 3:                         /* illegal */
425
+          /* the only illegal value possible is 3 because we check only 2 bits */
426
+          goto bad;
427
+      }
428
+      break;
429
+    case LENS:
430
+      NEEDBITS(16)
431
+      s->sub.left = (uInt)b & 0xffff;
432
+      b = k = 0;                      /* dump bits */
433
+      Tracev((stderr, "inflate:       stored length %u\n", s->sub.left));
434
+      s->mode = s->sub.left ? STORED : (inflate_mode)s->last;
435
+      break;
436
+    case STORED:
437
+    {
438
+      uInt mn;
439
+
440
+      if (n == 0)
441
+        LEAVE(Z_OK)
442
+      NEEDOUT
443
+      mn = min(m, n);
444
+      t = min(s->sub.left, mn);
445
+      zmemcpy(q, p, t);
446
+      p += t;  n -= t;
447
+      q += t;  m -= t;
448
+      if (!(s->sub.left -= t))
449
+        s->mode = (inflate_mode)s->last;
450
+      break;
451
+    }
452
+    case TABLE:
453
+      NEEDBITS(14)
454
+      s->sub.trees.table = t = (uInt)b & 0x3fff;
455
+      if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29)
456
+      {
457
+        s->mode = NZ_BAD;
458
+        LEAVE(Z_DATA_ERROR);
459
+      }
460
+      /* t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); */
461
+      DUMPBITS(14)
462
+      s->sub.trees.index = 0;
463
+      Tracev((stderr, "inflate:       table sizes ok\n"));
464
+      s->mode = BTREE;
465
+    case BTREE:
466
+      while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10))
467
+      {
468
+        NEEDBITS(3)
469
+        s->sub.trees.t_blens[(int)border[s->sub.trees.index++]] = (uInt)b & 7;
470
+        DUMPBITS(3)
471
+      }
472
+      while (s->sub.trees.index < 19)
473
+        s->sub.trees.t_blens[(int)border[s->sub.trees.index++]] = 0;
474
+      s->sub.trees.bb = 7;
475
+
476
+      {
477
+        uInt hn = 0;          /* hufts used in space */
478
+
479
+        t = huft_build(s->sub.trees.t_blens, 19, 19, Z_NULL, Z_NULL,
480
+		       &s->sub.trees.tb, &s->sub.trees.bb, s->hufts, &hn);
481
+        if (t != Z_OK || !s->sub.trees.bb)
482
+        {
483
+          s->mode = NZ_BAD;
484
+          break;
485
+        }
486
+      }
487
+
488
+      s->sub.trees.index = 0;
489
+      Tracev((stderr, "inflate:       bits tree ok\n"));
490
+      s->mode = DTREE;
491
+    case DTREE:
492
+      while (t = s->sub.trees.table,
493
+             s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))
494
+      {
495
+        inflate_huft *h;
496
+        uInt i, j, d;
497
+
498
+        t = s->sub.trees.bb;
499
+        NEEDBITS(t)
500
+        h = s->sub.trees.tb + ((uInt)b & (uInt)inflate_mask[t]);
501
+        t = h->bits;
502
+        d = h->base;
503
+        if (d < 16)
504
+        {
505
+          DUMPBITS(t)
506
+          s->sub.trees.t_blens[s->sub.trees.index++] = d;
507
+        }
508
+        else /* d == 16..18 */
509
+        {
510
+          if (d == 18)
511
+          {
512
+            i=7;
513
+            j=11;
514
+          }
515
+          else
516
+          {
517
+            i=d-14;
518
+            j=3;
519
+          }
520
+          NEEDBITS(t+i)
521
+          DUMPBITS(t)
522
+          j += (uInt)b & (uInt)inflate_mask[i];
523
+          DUMPBITS(i)
524
+          i = s->sub.trees.index;
525
+          t = s->sub.trees.table;
526
+          if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) ||
527
+              (d == 16 && i < 1))
528
+          {
529
+            s->mode = NZ_BAD;
530
+            LEAVE(Z_DATA_ERROR);
531
+          }
532
+          d = d == 16 ? s->sub.trees.t_blens[i - 1] : 0;
533
+          do {
534
+            s->sub.trees.t_blens[i++] = d;
535
+          } while (--j);
536
+          s->sub.trees.index = i;
537
+        }
538
+      }
539
+      s->sub.trees.tb = Z_NULL;
540
+      {
541
+        uInt hn = 0;          /* hufts used in space */
542
+        uInt bl, bd;
543
+        inflate_huft *tl, *td;
544
+        int nl,nd;
545
+        t = s->sub.trees.table;
546
+
547
+        nl = 257 + (t & 0x1f);
548
+        nd = 1 + ((t >> 5) & 0x1f);
549
+        bl = 9;         /* must be <= 9 for lookahead assumptions */
550
+        bd = 6;         /* must be <= 9 for lookahead assumptions */
551
+
552
+        t = huft_build(s->sub.trees.t_blens, nl, 257, cplens, cplext, &tl, &bl, s->hufts, &hn);
553
+        if (bl == 0) t = Z_DATA_ERROR;
554
+        if (t == Z_OK)
555
+        {
556
+          /* build distance tree */
557
+          t = huft_build(s->sub.trees.t_blens + nl, nd, 0, cpdist, cpdext, &td, &bd, s->hufts, &hn);
558
+        }
559
+        if (t != Z_OK || (bd == 0 && nl > 257))
560
+        {
561
+          s->mode = NZ_BAD;
562
+          LEAVE(Z_DATA_ERROR);
563
+        }
564
+        Tracev((stderr, "inflate:       trees ok\n"));
565
+
566
+        /* s->sub.decode.t_codes.mode = CODES_START; */
567
+        s->sub.decode.t_codes.lbits = (Byte)bl;
568
+        s->sub.decode.t_codes.dbits = (Byte)bd;
569
+        s->sub.decode.t_codes.ltree = tl;
570
+        s->sub.decode.t_codes.dtree = td;
571
+      }
572
+      s->mode = CODES_START;
573
+
574
+#define j (_state.j)
575
+#define e (_state.e)
576
+#define f (_state.f)
577
+
578
+    /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
579
+
580
+    case CODES_START:         /* x: set up for LEN */
581
+      c->sub.code.need = c->lbits;
582
+      c->sub.code.tree = c->ltree;
583
+      s->mode = CODES_LEN;
584
+    case CODES_LEN:           /* i: get length/literal/eob next */
585
+      t = c->sub.code.need;
586
+      NEEDBITS(t)
587
+      j = c->sub.code.tree + ((uInt)b & (uInt)inflate_mask[t]);
588
+      DUMPBITS(j->bits)
589
+      e = (uInt)(j->exop);
590
+      if (e == 0)               /* literal */
591
+      {
592
+        c->sub.lit = j->base;
593
+        s->mode = CODES_LIT;
594
+        break;
595
+      }
596
+      if (e & 16)               /* length */
597
+      {
598
+        c->sub.copy.get = e & 15;
599
+        c->len = j->base;
600
+        s->mode = CODES_LENEXT;
601
+        break;
602
+      }
603
+      if ((e & 64) == 0)        /* next table */
604
+      {
605
+        c->sub.code.need = e;
606
+        c->sub.code.tree = j + j->base;
607
+        break;
608
+      }
609
+      if (e & 32)               /* end of block */
610
+      {
611
+        s->mode = CODES_WASH;
612
+        break;
613
+      }
614
+    goto bad;
615
+    case CODES_LENEXT:        /* i: getting length extra (have base) */
616
+      t = c->sub.copy.get;
617
+      NEEDBITS(t)
618
+      c->len += (uInt)b & (uInt)inflate_mask[t];
619
+      DUMPBITS(t)
620
+      c->sub.code.need = c->dbits;
621
+      c->sub.code.tree = c->dtree;
622
+      s->mode = CODES_DIST;
623
+    case CODES_DIST:          /* i: get distance next */
624
+      t = c->sub.code.need;
625
+      NEEDBITS(t)
626
+      j = c->sub.code.tree + ((uInt)b & (uInt)inflate_mask[t]);
627
+      DUMPBITS(j->bits)
628
+      e = (uInt)(j->exop);
629
+      if (e & 16)               /* distance */
630
+      {
631
+        c->sub.copy.get = e & 15;
632
+        c->sub.copy.dist = j->base;
633
+        s->mode = CODES_DISTEXT;
634
+        break;
635
+      }
636
+      if ((e & 64) == 0)        /* next table */
637
+      {
638
+        c->sub.code.need = e;
639
+        c->sub.code.tree = j + j->base;
640
+        break;
641
+      }
642
+      goto bad;        /* invalid code */
643
+    case CODES_DISTEXT:       /* i: getting distance extra */
644
+      t = c->sub.copy.get;
645
+      NEEDBITS(t)
646
+      c->sub.copy.dist += (uInt)b & (uInt)inflate_mask[t];
647
+      DUMPBITS(t)
648
+      s->mode = CODES_COPY;
649
+    case CODES_COPY:          /* o: copying bytes in window, waiting for space */
650
+      f = (uInt)(q - s->window) < c->sub.copy.dist ?
651
+          s->end - (c->sub.copy.dist - (q - s->window)) :
652
+          q - c->sub.copy.dist;
653
+
654
+      while (c->len)
655
+      {
656
+        NEEDOUT
657
+        OUTBYTE(*f++)
658
+        if (f == s->end)
659
+          f = s->window;
660
+        c->len--;
661
+      }
662
+      s->mode = CODES_START;
663
+      break;
664
+    case CODES_LIT:           /* o: got literal, waiting for output space */
665
+      NEEDOUT
666
+      OUTBYTE(c->sub.lit)
667
+      s->mode = CODES_START;
668
+      break;
669
+    case CODES_WASH:          /* o: got eob, possibly more output */
670
+      if (k > 7)        /* return unused byte, if any */
671
+      {
672
+        k -= 8;
673
+        n++;
674
+        p--;            /* can always return one */
675
+      }
676
+      /* flushing will be done in DRY */
677
+
678
+#undef j
679
+#undef e
680
+#undef f
681
+
682
+    case DRY:
683
+      FLUSH
684
+      if (s->write != s->read)
685
+        LEAVE(Z_OK)
686
+      if (s->mode == CODES_WASH)
687
+      {
688
+        Tracev((stderr, "inflate:       codes end, %lu total out\n",
689
+               z->total_out + (q >= s->read ? q - s->read :
690
+               (s->end - s->read) + (q - s->window))));
691
+      }
692
+      /* DRY if last, TYPE if not */
693
+      s->mode = (inflate_mode)s->last;
694
+      if (s->mode == TYPE)
695
+        break;
696
+      LEAVE(Z_STREAM_END)
697
+    /*case BAD:
698
+      r = Z_DATA_ERROR;
699
+      LEAVE
700
+    */
701
+    default: /* we'll call Z_STREAM_ERROR if BAD anyway */
702
+    bad:
703
+      s->mode = NZ_BAD;
704
+      LEAVE(Z_STREAM_ERROR)
705
+  }
706
+}
707
+
708
+#undef t
709
+#undef b
710
+#undef k
711
+#undef p
712
+#undef n
713
+#undef q
714
+#undef m
0 715
new file mode 100644
... ...
@@ -0,0 +1,58 @@
0
+/* zconf.h -- configuration of the zlib compression library
1
+ * Copyright (C) 1995-1998 Jean-loup Gailly.
2
+ * For conditions of distribution and use, see copyright notice in COPYING.nsis.
3
+ */
4
+
5
+/* @(#) $Id: ZCONF.H,v 1.3 2007/01/13 17:28:23 kichik Exp $ */
6
+
7
+#ifndef _ZCONF_H
8
+#define _ZCONF_H
9
+
10
+
11
+#define MAX_MEM_LEVEL 9
12
+
13
+/* Maximum value for windowBits in deflateInit2 and inflateInit2.
14
+ * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
15
+ * created by gzip. (Files created by minigzip can still be extracted by
16
+ * gzip.)
17
+ */
18
+#ifndef MAX_WBITS
19
+#  define MAX_WBITS   15 /* 32K LZ77 window */
20
+#endif
21
+
22
+#define OF(args)  args
23
+
24
+
25
+#ifndef ZEXPORT
26
+#  define ZEXPORT
27
+#endif
28
+#ifndef ZEXPORTVA
29
+#  define ZEXPORTVA
30
+#endif
31
+#ifndef ZEXTERN
32
+#  define ZEXTERN extern
33
+#endif
34
+
35
+#ifndef FAR
36
+#  define FAR
37
+#endif
38
+
39
+typedef unsigned char  Byte;  /* 8 bits */
40
+typedef unsigned int   uInt;  /* 16 bits or more */
41
+typedef unsigned long  uLong; /* 32 bits or more */
42
+
43
+typedef Byte  FAR Bytef;
44
+typedef char  FAR charf;
45
+typedef int   FAR intf;
46
+typedef uInt  FAR uIntf;
47
+typedef uLong FAR uLongf;
48
+
49
+typedef void FAR *voidpf;
50
+typedef void     *voidp;
51
+
52
+#ifndef z_off_t
53
+#  define  z_off_t long
54
+#endif
55
+
56
+
57
+#endif /* _ZCONF_H */
0 58
new file mode 100644
... ...
@@ -0,0 +1,217 @@
0
+/* zlib.h -- interface of the 'zlib' general purpose compression library
1
+  version 1.1.3, July 9th, 1998
2
+
3
+  Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
4
+
5
+  This software is provided 'as-is', without any express or implied
6
+  warranty.  In no event will the authors be held liable for any damages
7
+  arising from the use of this software.
8
+
9
+  Permission is granted to anyone to use this software for any purpose,
10
+  including commercial applications, and to alter it and redistribute it
11
+  freely, subject to the following restrictions:
12
+
13
+  1. The origin of this software must not be misrepresented; you must not
14
+     claim that you wrote the original software. If you use this software
15
+     in a product, an acknowledgment in the product documentation would be
16
+     appreciated but is not required.
17
+  2. Altered source versions must be plainly marked as such, and must not be
18
+     misrepresented as being the original software.
19
+  3. This notice may not be removed or altered from any source distribution.
20
+
21
+  Jean-loup Gailly        Mark Adler
22
+  jloup@gzip.org          madler@alumni.caltech.edu
23
+
24
+
25
+*/
26
+
27
+#ifndef _NSIS_ZLIB_H
28
+#define _NSIS_ZLIB_H
29
+
30
+#include "nsis_zconf.h"
31
+#include "nsis_zutil.h"
32
+
33
+#ifdef __cplusplus
34
+extern "C" {
35
+#endif
36
+
37
+
38
+typedef struct inflate_huft_s FAR inflate_huft;
39
+
40
+
41
+
42
+typedef enum {        /* waiting for "i:"=input, "o:"=output, "x:"=nothing */
43
+      CODES_START,    /* x: set up for LEN */
44
+      CODES_LEN,      /* i: get length/literal/eob next */
45
+      CODES_LENEXT,   /* i: getting length extra (have base) */
46
+      CODES_DIST,     /* i: get distance next */
47
+      CODES_DISTEXT,  /* i: getting distance extra */
48
+      CODES_COPY,     /* o: copying bytes in window, waiting for space */
49
+      CODES_LIT,      /* o: got literal, waiting for output space */
50
+      CODES_WASH,     /* o: got eob, possibly still output waiting */
51
+      /* CODES_END,      x: got eob and all data flushed */
52
+      /* CODES_BADCODE,  x: got error */
53
+
54
+      TYPE,     /* get type bits (3, including end bit) */
55
+      LENS,     /* get lengths for stored */
56
+      STORED,   /* processing stored block */
57
+      TABLE,    /* get table lengths */
58
+      BTREE,    /* get bit lengths tree for a dynamic block */
59
+      DTREE,    /* get length, distance trees for a dynamic block */
60
+      CODES,    /* processing fixed or dynamic block */
61
+      DRY,      /* output remaining window bytes */
62
+      DONE,     /* finished last block, done */
63
+      NZ_BAD       /* got a data error--stuck here */
64
+} inflate_mode;
65
+
66
+/* inflate codes private state */
67
+struct inflate_codes_state {
68
+
69
+  /* mode */
70
+  /* inflate_mode mode;      current inflate_codes mode */
71
+
72
+  /* mode dependent information */
73
+  uInt len;
74
+  union {
75
+    struct {
76
+      inflate_huft *tree;       /* pointer into tree */
77
+      uInt need;                /* bits needed */
78
+    } code;             /* if LEN or DIST, where in tree */
79
+    uInt lit;           /* if LIT, literal */
80
+    struct {
81
+      uInt get;                 /* bits to get for extra */
82
+      uInt dist;                /* distance back to copy from */
83
+    } copy;             /* if EXT or COPY, where and how much */
84
+  } sub;                /* submode */
85
+
86
+  /* mode independent information */
87
+  Byte lbits;           /* ltree bits decoded per branch */
88
+  Byte dbits;           /* dtree bits decoder per branch */
89
+  inflate_huft *ltree;          /* literal/length/eob tree */
90
+  inflate_huft *dtree;          /* distance tree */
91
+
92
+};
93
+
94
+struct inflate_huft_s {
95
+  union {
96
+    struct {
97
+      Byte Exop;        /* number of extra bits or operation */
98
+      Byte Bits;        /* number of bits in this code or subcode */
99
+    } what;
100
+  } word;
101
+  unsigned short base;            /* literal, length base, distance base,
102
+                           or table offset */
103
+};
104
+
105
+#define MANY 1440
106
+
107
+typedef struct inflate_codes_state inflate_codes_statef;
108
+
109
+struct inflate_blocks_state {
110
+
111
+  /* mode */
112
+  inflate_mode  mode;    /* current inflate_block mode */
113
+
114
+  /* mode dependent information */
115
+  union {
116
+    uInt left;          /* if STORED, bytes left to copy */
117
+    struct {
118
+      uInt table;               /* table lengths (14 bits) */
119
+      uInt index;               /* index into blens (or border) */
120
+      uIntf t_blens[258+31+31];             /* bit lengths of codes */
121
+      uInt bb;                  /* bit length tree depth */
122
+      inflate_huft *tb;         /* bit length decoding tree */
123
+    } trees;            /* if DTREE, decoding info for trees */
124
+    struct {
125
+      inflate_codes_statef t_codes;
126
+    } decode;           /* if CODES, current state */
127
+  } sub;                /* submode */
128
+
129
+  uInt last;            /* DRY if this block is the last block, TYPE otherwise */
130
+
131
+  /* mode independent information */
132
+  uInt bitk;            /* bits in bit buffer */
133
+  uLong bitb;           /* bit buffer */
134
+  inflate_huft hufts[MANY];  /* single malloc for tree space */
135
+  Bytef window[1 << MAX_WBITS];        /* sliding window */
136
+  Bytef *end;           /* one byte after sliding window */
137
+  Bytef *read;          /* window read pointer */
138
+  Bytef *write;         /* window write pointer */
139
+  uLong check;          /* check on output */
140
+
141
+};
142
+
143
+typedef struct nsis_z_stream_s {
144
+    Bytef    *next_in;  /* next input byte */
145
+    uInt     avail_in;  /* number of bytes available at next_in */
146
+    uLong    total_in;  /* total nb of input bytes read so far */
147
+
148
+    Bytef    *next_out; /* next output byte should be put there */
149
+    uInt     avail_out; /* remaining free space at next_out */
150
+
151
+    /* char     *msg;      last error message, NULL if no error */
152
+    /* struct internal_state FAR *state; not visible by applications */
153
+    struct inflate_blocks_state blocks;
154
+
155
+} nsis_z_stream;
156
+
157
+typedef nsis_z_stream FAR *nsis_z_streamp;
158
+
159
+
160
+#define Z_NO_FLUSH      0
161
+#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
162
+#define Z_SYNC_FLUSH    2
163
+#define Z_FULL_FLUSH    3
164
+#define Z_FINISH        4
165
+/* Allowed flush values; see deflate() below for details */
166
+
167
+#define Z_OK            0
168
+#define Z_STREAM_END    1
169
+#define Z_NEED_DICT     2
170
+#define Z_ERRNO        (-1)
171
+
172
+/* EXEHEAD doesn't need a specific return code, just < 0 */
173
+#define Z_STREAM_ERROR (-2)
174
+#define Z_DATA_ERROR   (-3)
175
+#define Z_MEM_ERROR    (-4)
176
+#define Z_BUF_ERROR    (-5)
177
+#define Z_VERSION_ERROR (-6)
178
+
179
+/* Return codes for the compression/decompression functions. Negative
180
+ * values are errors, positive values are used for special but normal events.
181
+ */
182
+
183
+#define Z_NO_COMPRESSION         0
184
+#define Z_BEST_SPEED             1
185
+#define Z_BEST_COMPRESSION       9
186
+#define Z_DEFAULT_COMPRESSION  (-1)
187
+/* compression levels */
188
+
189
+#define Z_FILTERED            1
190
+#define Z_HUFFMAN_ONLY        2
191
+#define Z_DEFAULT_STRATEGY    0
192
+/* compression strategy; see deflateInit2() below for details */
193
+
194
+/* Possible values of the data_type field */
195
+
196
+#define Z_DEFLATED   8
197
+/* The deflate compression method (the only one supported in this version) */
198
+
199
+#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
200
+
201
+
202
+#define nsis_inflateInit(x) inflateReset(x)
203
+int ZEXPORT nsis_inflate(nsis_z_streamp z);
204
+#define inflateReset(z) \
205
+{ \
206
+  (z)->blocks.mode = TYPE; \
207
+  (z)->blocks.bitk = (z)->blocks.bitb = 0; \
208
+  (z)->blocks.read = (z)->blocks.write = (z)->blocks.window; \
209
+  (z)->blocks.end = (z)->blocks.window + (1 << DEF_WBITS); \
210
+}
211
+
212
+#ifdef __cplusplus
213
+}
214
+#endif
215
+
216
+#endif /* _ZLIB_H */
0 217
new file mode 100644
... ...
@@ -0,0 +1,74 @@
0
+/*
1
+ * This file is a part of the zlib compression module for NSIS.
2
+ * 
3
+ * Copyright and license information can be found below.
4
+ * Modifications Copyright (C) 1999-2007 Nullsoft and Contributors
5
+ * 
6
+ * The original zlib source code is available at
7
+ * http://www.zlib.net/
8
+ * 
9
+ * This software is provided 'as-is', without any express or implied
10
+ * warranty.
11
+ */
12
+
13
+/* zutil.h -- internal interface and configuration of the compression library
14
+ * Copyright (C) 1995-1998 Jean-loup Gailly.
15
+ * For conditions of distribution and use, see copyright notice in COPYING.nsis.
16
+ */
17
+
18
+/* WARNING: this file should *not* be used by applications. It is
19
+   part of the implementation of the compression library and is
20
+   subject to change. Applications should only use zlib.h.
21
+ */
22
+
23
+/* @(#) $Id: ZUTIL.H,v 1.6 2007/01/25 18:07:40 kichik Exp $ */
24
+
25
+#ifndef _Z_UTIL_H
26
+#define _Z_UTIL_H
27
+
28
+#include "nsis_zlib.h"
29
+
30
+#ifndef local
31
+#  define local static
32
+#endif
33
+
34
+typedef unsigned char  uch;
35
+typedef uch FAR uchf;
36
+typedef unsigned short ush;
37
+typedef ush FAR ushf;
38
+typedef unsigned long  ulg;
39
+
40
+#ifndef DEF_WBITS
41
+#  define DEF_WBITS MAX_WBITS
42
+#endif
43
+/* default windowBits for decompression. MAX_WBITS is for compression only */
44
+
45
+#define DEF_MEM_LEVEL  MAX_MEM_LEVEL
46
+
47
+#define STORED_BLOCK 0
48
+#define STATIC_TREES 1
49
+#define DYN_TREES    2
50
+/* The three kinds of block type */
51
+
52
+#define MIN_MATCH  3
53
+#define MAX_MATCH  258
54
+/* The minimum and maximum match lengths */
55
+
56
+#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
57
+
58
+
59
+#define zmemcpy memcpy
60
+
61
+#define Assert(cond,msg)
62
+#define Trace(x)
63
+#define Tracev(x)
64
+#define Tracevv(x)
65
+#define Tracec(c,x)
66
+#define Tracecv(c,x)
67
+
68
+#define ZALLOC(strm, items, size) malloc((items)*(size))
69
+#define ZFREE(strm, addr)  { if (addr) free(addr); }
70
+#define TRY_FREE(s, p) { ZFREE(s, p); }
71
+#define ERR_RETURN(strm,err) return (err)
72
+
73
+#endif /* _Z_UTIL_H */
... ...
@@ -38,12 +38,20 @@
38 38
 #include "others.h"
39 39
 #include "cltypes.h"
40 40
 #include "nsis_bzlib.h"
41
-#include "zlib.h"
41
+/* #include "zlib.h" */
42
+#include "nsis_zlib.h"
42 43
 #include "lzma_iface.h"
43 44
 #include "matcher.h"
44 45
 #include "scanners.h"
45 46
 #include "nulsft.h" /* SHUT UP GCC -Wextra */
46 47
 
48
+/* NSIS zlib is not thread safe */
49
+#ifdef CL_THREAD_SAFE
50
+#  include <pthread.h>
51
+static pthread_mutex_t nsis_mutex = PTHREAD_MUTEX_INITIALIZER;
52
+#endif
53
+/* NSIS zlib is not thread safe */
54
+
47 55
 #ifndef O_BINARY
48 56
 #define O_BINARY 0
49 57
 #endif
... ...
@@ -74,7 +82,8 @@ struct nsis_st {
74 74
   struct stream_state nsis;
75 75
   nsis_bzstream bz;
76 76
   CLI_LZMA* lz;
77
-  z_stream z;
77
+/*   z_stream z; */
78
+  nsis_z_stream z;
78 79
   unsigned char *freeme;
79 80
   char ofn[1024];
80 81
 };
... ...
@@ -98,8 +107,10 @@ static int nsis_init(struct nsis_st *n) {
98 98
     break;
99 99
   case COMP_ZLIB:
100 100
     memset(&n->bz, 0, sizeof(z_stream));
101
-    inflateInit2(&n->z, -MAX_WBITS);
102
-    n->freecomp=1;
101
+/*     inflateInit2(&n->z, -MAX_WBITS); */
102
+/*     n->freecomp=1; */
103
+    nsis_inflateInit(&n->z);
104
+    n->freecomp=0;
103 105
   }
104 106
   return CL_SUCCESS;
105 107
 }
... ...
@@ -116,7 +127,7 @@ static void nsis_shutdown(struct nsis_st *n) {
116 116
     cli_LzmaShutdown(&n->lz);
117 117
     break;
118 118
   case COMP_ZLIB:
119
-    inflateEnd(&n->z);
119
+/*     inflateEnd(&n->z); */
120 120
     break;
121 121
   }
122 122
 
... ...
@@ -157,7 +168,8 @@ static int nsis_decomp(struct nsis_st *n) {
157 157
     n->z.next_in = n->nsis.next_in;
158 158
     n->z.avail_out = n->nsis.avail_out;
159 159
     n->z.next_out = n->nsis.next_out;
160
-    switch (inflate(&n->z, Z_NO_FLUSH)) {
160
+/*  switch (inflate(&n->z, Z_NO_FLUSH)) { */
161
+    switch (nsis_inflate(&n->z)) {
161 162
     case Z_OK:
162 163
       ret = CL_SUCCESS;
163 164
       break;
... ...
@@ -514,7 +526,13 @@ int cli_scannulsft(int desc, cli_ctx *ctx, off_t offset) {
514 514
     if(cli_leavetemps_flag) cli_dbgmsg("NSIS: Extracting files to %s\n", nsist.dir);
515 515
 
516 516
     do {
517
+#ifdef CL_THREAD_SAFE
518
+        pthread_mutex_lock(&nsis_mutex);
519
+#endif
517 520
         ret = cli_nsis_unpack(&nsist, ctx);
521
+#ifdef CL_THREAD_SAFE
522
+	pthread_mutex_unlock(&nsis_mutex);
523
+#endif
518 524
 	if (ret == CL_SUCCESS) {
519 525
 	  cli_dbgmsg("NSIS: Successully extracted file #%u\n", nsist.fno);
520 526
 	  lseek(nsist.ofd, 0, SEEK_SET);